I wrote a simple evdev program to read from a Nintendo Switch JoyCon and print out any buttons pressed. ``` from evdev import InputDevice, categorize, ecodes, KeyEvent device = InputDevice("/dev/input/event17") for event in device.read_loop(): if event.type == ecodes.EV_KEY: keyevent = categorize(event) if keyevent.keystate == KeyEvent.key_down: print(keyevent.keycode) ``` And when I run the program it has an output like this ``` ['BTN_A', 'BTN_GAMEPAD', 'BTN_SOUTH'] BTN_C ['BTN_NORTH', 'BTN_X'] ['BTN_B', 'BTN_EAST'] BTN_THUMBR BTN_TR2 BTN_Z ['BTN_WEST', 'BTN_Y'] BTN_START BTN_MODE ``` But when I pressed the ZR button this happens ``` Traceback (most recent call last): File "test/button_lister.py", line 7, in <module> keyevent = categorize(event) File "/usr/lib/python3/dist-packages/evdev/util.py", line 46, in categorize return event_factory[event.type](event) File "/usr/lib/python3/dist-packages/evdev/events.py", line 97, in __init__ self.keycode = keys[event.code] # :todo: KeyError: 319 ``` I am using Python version 3.5.2.
Activity
foxsam21 commentedon May 20, 2019
This was mentioned with a suggested fix (and a pull request) in #75 (comment) maybe it can be merged one day.
Merge pull request #109 from TheMadScientist1234/master