8
8
9
9
class PointerDriver (_indev_base .IndevBase ):
10
10
11
- def __init__ (self , touch_cal = None , debug = False ): # NOQA
11
+ def __init__ (self , touch_cal = None , startup_rotation = lv . DISPLAY_ROTATION . _0 , debug = False ): # NOQA
12
12
self ._last_x = - 1
13
13
self ._last_y = - 1
14
14
self .__debug = debug
@@ -25,6 +25,7 @@ def __init__(self, touch_cal=None, debug=False): # NOQA
25
25
self ._orig_height = self ._height
26
26
self ._set_type (lv .INDEV_TYPE .POINTER ) # NOQA
27
27
self .__cal_running = None
28
+ self .__startup_rotation = startup_rotation
28
29
29
30
def __cal_callback (self , alphaX , betaX , deltaX , alphaY , betaY , deltaY ):
30
31
self ._cal .alphaX = alphaX
@@ -77,9 +78,21 @@ def _get_coords(self):
77
78
def _calc_coords (self , x , y ):
78
79
if self .is_calibrated :
79
80
cal = self ._cal
80
- xpos = int (round (x * cal .alphaX + y * cal .betaX + cal .deltaX ))
81
- ypos = int (round (x * cal .alphaY + y * cal .betaY + cal .deltaY ))
82
- return xpos , ypos
81
+ x = int (round (x * cal .alphaX + y * cal .betaX + cal .deltaX ))
82
+ y = int (round (x * cal .alphaY + y * cal .betaY + cal .deltaY ))
83
+
84
+ if (
85
+ self .__startup_rotation == lv .DISPLAY_ROTATION ._180 or # NOQA
86
+ self .__startup_rotation == lv .DISPLAY_ROTATION ._270 # NOQA
87
+ ):
88
+ x = self ._orig_width - x - 1
89
+ y = self ._orig_height - y - 1
90
+
91
+ if (
92
+ self .__startup_rotation == lv .DISPLAY_ROTATION ._90 or # NOQA
93
+ self .__startup_rotation == lv .DISPLAY_ROTATION ._270 # NOQA
94
+ ):
95
+ x , y = self ._orig_height - y - 1 , x
83
96
84
97
return x , y
85
98
0 commit comments