Verified Commit 451cfb8d authored by Jakob Moser's avatar Jakob Moser
Browse files

Add touch test event

parent 2830748b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2,3 +2,5 @@
    - Copied from https://stackoverflow.com/a/54986161/ by Attila (https://stackoverflow.com/users/1327762/attila),
    - CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
    - This is also what powers the display code in `poolpay/display`, however, this is the original version of the script
- `test_touch.py`
    - Use `evdev` to get touch events, prints many of them (including coordinates)

scripts/test_touch.py

0 → 100644
+15 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
import evdev

touch = evdev.InputDevice('/dev/input/event0')
touch.grab()

coords = {}

for raw_event in touch.read_loop():
    if raw_event.type == evdev.ecodes.EV_ABS:
        coords[evdev.ecodes.ABS[raw_event.code]] = raw_event.value
    elif raw_event.type == evdev.ecodes.EV_SYN:
        print(coords["ABS_X"], coords["ABS_Y"], end="                \r")
    elif raw_event.type == evdev.ecodes.EV_KEY:
        print(evdev.ecodes.keys[raw_event.code], raw_event.value)