evdevremapkeys icon indicating copy to clipboard operation
evdevremapkeys copied to clipboard

Device fails to load if no EV_KEY entries

Open parkerlreed opened this issue 10 months ago • 1 comments

I have a rotary encoder that only has a REL_X with -1 and 1 as values

Trying to use it with the remapper crashes because this doens't have any "keys"

[parker@parker-framework build]$ evdevremapkeys -f config.yaml 
Traceback (most recent call last):
  File "/usr/bin/evdevremapkeys", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/lib/python3.13/site-packages/evdevremapkeys/evdevremapkeys.py", line 438, in main
    run_loop(args)
    ~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/site-packages/evdevremapkeys/evdevremapkeys.py", line 364, in run_loop
    task = register_device(device, loop)
  File "/usr/lib/python3.13/site-packages/evdevremapkeys/evdevremapkeys.py", line 295, in register_device
    extended = set(caps[ecodes.EV_KEY])
                   ~~~~^^^^^^^^^^^^^^^
KeyError: 1
[parker@parker-framework build]$ evtest /dev/input/event21
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x0 product 0x0 version 0x1
Input device name: "rotary-encoder (via input-over-ssh)"
Supported events:
  Event type 0 (EV_SYN)
  Event type 2 (EV_REL)
    Event code 0 (REL_X)
  Event type 21 (EV_FF)
Properties:
Testing ... (interrupt to exit)
Event: time 1740694902.698721, type 2 (EV_REL), code 0 (REL_X), value -1
Event: time 1740694902.698721, -------------- SYN_REPORT ------------
Event: time 1740694902.874516, type 2 (EV_REL), code 0 (REL_X), value -1
Event: time 1740694902.874516, -------------- SYN_REPORT ------------
Event: time 1740694903.083352, type 2 (EV_REL), code 0 (REL_X), value 1
Event: time 1740694903.083352, -------------- SYN_REPORT ------------
Event: time 1740694903.299527, type 2 (EV_REL), code 0 (REL_X), value 1
Event: time 1740694903.299527, -------------- SYN_REPORT ------------
^C
[parker@parker-framework build]$ cat config.yaml 
devices:
- input_name: 'rotary-encoder (via input-over-ssh)'
  output_name: remap-rotary
  remappings:
    REL_X:
    - code: BTN_RIGHT
      delay: true
      count: 4   # send BTN_RIGHT and then skip the next 4 events

parkerlreed avatar Feb 27 '25 22:02 parkerlreed

I made a PR for this: https://github.com/philipl/evdevremapkeys/pull/49

bonkzwonil avatar May 05 '25 07:05 bonkzwonil