aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rw-r--r--main.py10
1 files changed, 9 insertions, 1 deletions
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