diff --git a/remarkable_mouse/pynput.py b/remarkable_mouse/pynput.py index dbffa8a..84d5222 100644 --- a/remarkable_mouse/pynput.py +++ b/remarkable_mouse/pynput.py @@ -29,6 +29,7 @@ wacom_height = 20967 finger_width = 767 finger_height = 1023 +stylus_present = 0 # remap wacom coordinates to screen coordinates def remap(x, y, wacom_width, wacom_height, monitor_width, @@ -73,9 +74,15 @@ def read_tablet(args, remote_device): monitor = get_monitors()[args.monitor] log.debug('Chose monitor: {}'.format(monitor)) + global stylus_present + while True: _, _, e_type, e_code, e_value = struct.unpack('2IHHi', remote_device.read(16)) + + if e_type == 0x01 and e_code == 0x140: + stylus_present = e_value + if e_type == e_type_abs: # handle x direction @@ -143,10 +150,12 @@ def read_finger(args, remote_device): mt_list = {} mt_slot = 0 + global stylus_present + while True: _, _, e_type, e_code, e_value = struct.unpack('2IHHi', remote_device.read(16)) - if e_type == e_type_abs: + if e_type == e_type_abs and stylus_present == 0: if e_code == evcode_finger_mv_slot: mt_slot = e_value