From 5734ff601eadae2d2d995244696191fc044b55f6 Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Mon, 5 Oct 2026 23:29:55 +1300 Subject: basic action mapping --- main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'main.py') diff --git a/main.py b/main.py index 27066e2..b0de076 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,14 @@ from evdev import InputDevice, list_devices, ecodes +SCANCODES = {0x11A: "up", 0x148: "down", 0x147: "left", 0x107: "right", 0x106: "ok"} + device = None last = 0x00 +def do_action(action: str): + if action == "ok": + print("ok") + for path in list_devices(): candidate = InputDevice(path) @@ -21,7 +27,9 @@ try: if (event.value != last): print(f"scancode {event.value:#x}") last = event.value - # Do logic here + action = SCANCODES.get(event.value) + if action: + do_action(action) else: print(f"repeat scancode {event.value:#x}") last = 0x00 -- cgit v1.2.3