From 8828395399ab1c7ff5f2b872c8cb646a90f41be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Tue, 5 Nov 2024 13:11:54 +0100 Subject: [PATCH 1/3] Add `syn()` convenience method to InputDevice This one mimicks the `syn()` method found in UInput class and just makes it easier to inject `EV_SYNC` events. It's easier to parse event blocks visually. --- evdev/device.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/evdev/device.py b/evdev/device.py index cde168e..d32d87e 100644 --- a/evdev/device.py +++ b/evdev/device.py @@ -434,3 +434,12 @@ def set_absinfo(self, axis_num, value=None, min=None, max=None, fuzz=None, flat= resolution if resolution is not None else cur_absinfo.resolution, ) _input.ioctl_EVIOCSABS(self.fd, axis_num, new_absinfo) + + def syn(self): + """ + Inject a ``SYN_REPORT`` event into the device. Events queued + by :func:`write()` will be fired. If possible, events will + be merged into an 'atomic' event. + """ + + self.write(ecodes.EV_SYN, ecodes.SYN_REPORT, 0) From 26d00f8bb9f5660c515d14299d92e3580cb8cb50 Mon Sep 17 00:00:00 2001 From: Lawstorant Date: Sat, 9 Nov 2024 19:04:24 +0100 Subject: [PATCH 2/3] Revert "Add `syn()` convenience method to InputDevice" This reverts commit 8828395399ab1c7ff5f2b872c8cb646a90f41be3. --- evdev/device.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/evdev/device.py b/evdev/device.py index d32d87e..cde168e 100644 --- a/evdev/device.py +++ b/evdev/device.py @@ -434,12 +434,3 @@ def set_absinfo(self, axis_num, value=None, min=None, max=None, fuzz=None, flat= resolution if resolution is not None else cur_absinfo.resolution, ) _input.ioctl_EVIOCSABS(self.fd, axis_num, new_absinfo) - - def syn(self): - """ - Inject a ``SYN_REPORT`` event into the device. Events queued - by :func:`write()` will be fired. If possible, events will - be merged into an 'atomic' event. - """ - - self.write(ecodes.EV_SYN, ecodes.SYN_REPORT, 0) From 246e4a9dadeb0fb976bdb459818995d7281972cf Mon Sep 17 00:00:00 2001 From: Lawstorant Date: Sat, 9 Nov 2024 19:05:14 +0100 Subject: [PATCH 3/3] Move `syn()` method from `UInput` to `EventIO` Makes it possible to use it with `InputDevice` as well --- evdev/eventio.py | 9 +++++++++ evdev/uinput.py | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/evdev/eventio.py b/evdev/eventio.py index 1b0e5cc..415e2e8 100644 --- a/evdev/eventio.py +++ b/evdev/eventio.py @@ -136,5 +136,14 @@ def write(self, etype, code, value): _uinput.write(self.fd, etype, code, value) + def syn(self): + """ + Inject a ``SYN_REPORT`` event into the input subsystem. Events + queued by :func:`write()` will be fired. If possible, events + will be merged into an 'atomic' event. + """ + + self.write(ecodes.EV_SYN, ecodes.SYN_REPORT, 0) + def close(self): pass diff --git a/evdev/uinput.py b/evdev/uinput.py index 476a84a..c4225d8 100644 --- a/evdev/uinput.py +++ b/evdev/uinput.py @@ -227,15 +227,6 @@ def close(self): _uinput.close(self.fd) self.fd = -1 - def syn(self): - """ - Inject a ``SYN_REPORT`` event into the input subsystem. Events - queued by :func:`write()` will be fired. If possible, events - will be merged into an 'atomic' event. - """ - - _uinput.write(self.fd, ecodes.EV_SYN, ecodes.SYN_REPORT, 0) - def capabilities(self, verbose=False, absinfo=True): """See :func:`capabilities `.""" if self.device is None: