diff options
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -15,12 +15,17 @@ if device is None: print(f"Listening on {device.path}: {device.name}") -for event in device.read_loop(): - if event.type == ecodes.EV_MSC and event.code == ecodes.MSC_SCAN: - if (event.value != last): - print(f"scancode {event.value:#x}") - last = event.value - # Do logic here - else: - print(f"repeat scancode {event.value:#x}") - last = 0x00 +try: + for event in device.read_loop(): + if event.type == ecodes.EV_MSC and event.code == ecodes.MSC_SCAN: + if (event.value != last): + print(f"scancode {event.value:#x}") + last = event.value + # Do logic here + else: + print(f"repeat scancode {event.value:#x}") + last = 0x00 +except KeyboardInterrupt: + print("\nExiting...") +finally: + device.close() |
