n4archive / pigame

A pygame wrapper for the libary pitft_touchscreen.
GNU Lesser General Public License v3.0
6 stars 1 forks source link

Add Portrait Support for touchscreens #14

Closed BroMarduk closed 3 years ago

BroMarduk commented 5 years ago

Add in the ability to support rotations of 0 and 180. (Portrait mode)

nift4 commented 5 years ago

Any calculation tips?

BroMarduk commented 5 years ago

Yes. I was going to start here, but have not tested yet. The hardcoded resolutions probably need to be changed to variables for different resolutions.

if pitft.pigamerotr==0:
    rel=(rel[0],rel[1])
if pitft.pigamerotr==90:
    e={"x":e["x"],"y":240-e["y"]}
    rel=(rel[0],rel[1]*-1)
elif pitft.pigamerotr==180:
    e={"x":320-e["x"],"y":240-e["y"]}
    rel=(rel[0]*-1,rel[1]*-1)
elif pitft.pigamerotr==270:
    e={"x":320-e["x"],"y":e["y"]}
    rel=(rel[0]*-1,rel[1])
else:
    raise(Exception("PiTft rotation is unsupported"))