-
install libevdev:
pip install libevdev
-
open rnote (or xournal++)
-
run
python ./run.py
-
Cursor should move the the rnote window and the rnote window will be killed.
- If the cursor doesn't end up on the rnote window, tweak the
ABS_X
andABS_Y
values in the code until you hit the right spot.
- If the cursor doesn't end up on the rnote window, tweak the
-
If you get a permission error try running as root. It needs write access to
/dev/uinput
to send the input events
Created
June 24, 2024 13:46
-
-
Save mrWinston/b013ce564465ac164a6a1ffc6c1536c2 to your computer and use it in GitHub Desktop.
hyprland tablet crash reproducing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import libevdev | |
import time | |
def create_local_device(): | |
""" | |
Create a virtual input device on this host that has the same | |
characteristics as a Wacom tablet. | |
Returns: | |
virtual input device | |
""" | |
import libevdev | |
device = libevdev.Device() | |
# Set device properties to emulate those of Wacom tablets | |
device.name = 'reMarkable pen' | |
device.id = { | |
'bustype': 0x03, # usb | |
'vendor': 0x056a, # wacom | |
'product': 0, | |
'version': 54 | |
} | |
# Enable buttons supported by the digitizer | |
device.enable(libevdev.EV_KEY.BTN_TOOL_PEN) | |
device.enable(libevdev.EV_KEY.BTN_TOOL_RUBBER) | |
device.enable(libevdev.EV_KEY.BTN_TOUCH) | |
device.enable(libevdev.EV_KEY.BTN_STYLUS) | |
device.enable(libevdev.EV_KEY.BTN_STYLUS2) | |
device.enable(libevdev.EV_KEY.BTN_0) | |
device.enable(libevdev.EV_KEY.BTN_1) | |
device.enable(libevdev.EV_KEY.BTN_2) | |
inputs = ( | |
# touch inputs | |
(libevdev.EV_ABS.ABS_MT_POSITION_X, 0, 20967, 100), | |
(libevdev.EV_ABS.ABS_MT_POSITION_Y, 0, 15725, 100), | |
(libevdev.EV_ABS.ABS_MT_PRESSURE, 0, 4095, None), | |
(libevdev.EV_ABS.ABS_MT_TOUCH_MAJOR, 0, 255, None), | |
(libevdev.EV_ABS.ABS_MT_TOUCH_MINOR, 0, 255, None), | |
(libevdev.EV_ABS.ABS_MT_ORIENTATION, -127, 127, None), | |
(libevdev.EV_ABS.ABS_MT_SLOT, 0, 31, None), | |
(libevdev.EV_ABS.ABS_MT_TOOL_TYPE, 0, 1, None), | |
(libevdev.EV_ABS.ABS_MT_TRACKING_ID, 0, 65535, None), | |
# pen inputs | |
(libevdev.EV_ABS.ABS_X, 0, 20967, 100), # cyttps5_mt driver | |
(libevdev.EV_ABS.ABS_Y, 0, 15725, 100), # cyttsp5_mt | |
(libevdev.EV_ABS.ABS_PRESSURE, 0, 4095, None), | |
(libevdev.EV_ABS.ABS_DISTANCE, 0, 255, None), | |
(libevdev.EV_ABS.ABS_TILT_X, -6400, 6400, 6400), | |
(libevdev.EV_ABS.ABS_TILT_Y, -6400, 6400, 6400) | |
) | |
for code, minimum, maximum, resolution in inputs: | |
device.enable( | |
code, | |
libevdev.InputAbsInfo( | |
minimum=minimum, maximum=maximum, resolution=resolution | |
) | |
) | |
return device.create_uinput_device() | |
def main(): | |
local_device = create_local_device() | |
events = [ | |
[1, 320, 1], # BTN TOOL PEN | |
[3, 0, 4974], # ABS_X , between 0 and 20967 | |
[3, 1, 6869], # ABS_Y, between 0 and 15725 | |
[3, 24, 1973], # ABS_PRESSURE | |
[0, 0, 0], # SYN | |
] | |
for rawev in events: | |
print(f"sending event: {rawev}") | |
e_bit = libevdev.evbit(rawev[0], rawev[1]) | |
e = libevdev.InputEvent(e_bit, value=rawev[2]) | |
local_device.send_events([e]) | |
time.sleep(0.1) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment