Skip to content

Commit 1a5da90

Browse files
author
gabriel pettier
committed
possible fix for kivy#2656
1 parent bd3cbbb commit 1a5da90

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

kivy/input/providers/hidinput.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class HIDInputMotionEventProvider(MotionEventProvider):
284284
options = ('min_position_x', 'max_position_x',
285285
'min_position_y', 'max_position_y',
286286
'min_pressure', 'max_pressure',
287-
'invert_x', 'invert_y')
287+
'invert_x', 'invert_y', 'rotate')
288288

289289
def __init__(self, device, args):
290290
super(HIDInputMotionEventProvider, self).__init__(device, args)
@@ -374,6 +374,7 @@ def _thread_run(self, **kwargs):
374374
range_max_pressure = 255
375375
invert_x = int(bool(drs('invert_x', 0)))
376376
invert_y = int(bool(drs('invert_y', 0)))
377+
rotate = int(drs('invert_y', 0)) % 360
377378

378379
def process_as_multitouch(tv_sec, tv_usec, ev_type,
379380
ev_code, ev_value):
@@ -401,14 +402,24 @@ def process_as_multitouch(tv_sec, tv_usec, ev_type,
401402
range_max_position_x)
402403
if invert_x:
403404
val = 1. - val
404-
point['x'] = val
405+
if rotate == 90:
406+
point['y'] = val
407+
elif rotate == 270:
408+
point['y'] = -val
409+
else:
410+
point['x'] = val
405411
elif ev_code == ABS_MT_POSITION_Y:
406412
val = 1. - normalize(ev_value,
407413
range_min_position_y,
408414
range_max_position_y)
409415
if invert_y:
410416
val = 1. - val
411-
point['y'] = val
417+
if rotate == 90:
418+
point['x'] = -val
419+
elif rotate == 270:
420+
point['x'] = val
421+
else:
422+
point['y'] = val
412423
elif ev_code == ABS_MT_ORIENTATION:
413424
point['orientation'] = ev_value
414425
elif ev_code == ABS_MT_BLOB_ID:

0 commit comments

Comments
 (0)