|
|
|
@ -336,97 +336,3 @@ def read_tablet(rm_inputs, *, orientation, monitor, threshold, mode):
@@ -336,97 +336,3 @@ def read_tablet(rm_inputs, *, orientation, monitor, threshold, mode):
|
|
|
|
|
else: |
|
|
|
|
pending_events.append(event) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_handler(*, orientation, monitor, threshold, mode): |
|
|
|
|
import libevdev |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
local_device = create_local_device() |
|
|
|
|
log.info("Created virtual input device '{}'".format(local_device.devnode)) |
|
|
|
|
except PermissionError: |
|
|
|
|
log.error('Insufficient permissions for creating a virtual input device') |
|
|
|
|
log.error('Make sure you run this program as root') |
|
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
configure_xinput( |
|
|
|
|
orientation=orientation, |
|
|
|
|
monitor=monitor, |
|
|
|
|
threshold=threshold, |
|
|
|
|
mode=mode, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
pending_events = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handler(e_time, e_millis, e_type, e_code, e_value): |
|
|
|
|
|
|
|
|
|
e_bit = libevdev.evbit(e_type, e_code) |
|
|
|
|
event = libevdev.InputEvent(e_bit, value=e_value) |
|
|
|
|
local_device.send_events([event]) |
|
|
|
|
|
|
|
|
|
# While debug mode is active, we log events grouped together between |
|
|
|
|
# SYN_REPORT events. Pending events for the next log are stored here |
|
|
|
|
# if log.level == logging.DEBUG: |
|
|
|
|
# if e_bit == libevdev.EV_SYN.SYN_REPORT: |
|
|
|
|
# event_repr = ', '.join( |
|
|
|
|
# '{} = {}'.format( |
|
|
|
|
# event.code.name, |
|
|
|
|
# event.value |
|
|
|
|
# ) for event in pending_events |
|
|
|
|
# ) |
|
|
|
|
# log.debug('{}.{:0>6} - {}'.format(e_time, e_millis, event_repr)) |
|
|
|
|
# pending_events = [] |
|
|
|
|
# else: |
|
|
|
|
# pending_events.append(event) |
|
|
|
|
|
|
|
|
|
return handler |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# pen_down = 0 |
|
|
|
|
|
|
|
|
|
# while True: |
|
|
|
|
# for device in rm_inputs: |
|
|
|
|
# try: |
|
|
|
|
# e_time, e_millis, e_type, e_code, e_value = struct.unpack('2IHHi', ev.read(16)) |
|
|
|
|
# e_bit = libevdev.evbit(e_type, e_code) |
|
|
|
|
# except timeout: |
|
|
|
|
# continue |
|
|
|
|
|
|
|
|
|
# if e_bit == libevdev.EV_KEY.KEY_LEFT: |
|
|
|
|
# e_bit = libevdev.EV_KEY.BTN_0 |
|
|
|
|
# if e_bit == libevdev.EV_KEY.KEY_HOME: |
|
|
|
|
# e_bit = libevdev.EV_KEY.BTN_1 |
|
|
|
|
# if e_bit == libevdev.EV_KEY.KEY_RIGHT: |
|
|
|
|
# e_bit = libevdev.EV_KEY.BTN_2 |
|
|
|
|
|
|
|
|
|
# event = libevdev.InputEvent(e_bit, value=e_value) |
|
|
|
|
|
|
|
|
|
# if e_bit == libevdev.EV_KEY.BTN_TOOL_PEN: |
|
|
|
|
# pen_down = e_value |
|
|
|
|
|
|
|
|
|
# if pen_down and 'ABS_MT' in event.code.name: # Palm rejection |
|
|
|
|
# pass |
|
|
|
|
# else: |
|
|
|
|
# local_device.send_events([event]) |
|
|
|
|
|
|
|
|
|
# if args.debug: |
|
|
|
|
# if e_bit == libevdev.EV_SYN.SYN_REPORT: |
|
|
|
|
# event_repr = ', '.join( |
|
|
|
|
# '{} = {}'.format( |
|
|
|
|
# event.code.name, |
|
|
|
|
# event.value |
|
|
|
|
# ) for event in pending_events |
|
|
|
|
# ) |
|
|
|
|
# log.debug('{}.{:0>6} - {}'.format(e_time, e_millis, event_repr)) |
|
|
|
|
# pending_events = [] |
|
|
|
|
# else: |
|
|
|
|
# pending_events += [event] |
|
|
|
|