KarsMulder / evsieve

A utility for mapping events from Linux event devices.
GNU General Public License v2.0
220 stars 12 forks source link

Unknown event code mapping/copy issue #25

Closed jettdc closed 1 year ago

jettdc commented 1 year ago

I believe there is an issue when trying to process arbitrary event codes. I have a joystick controller which is sending a 1:300 (key:300) event, and I believe because 300 is not a standard event code, issues are arising:

Full script:

sudo evsieve --input /dev/input/by-id/usb-GGG_GPWiz49-2-event-joystick grab=force persist=reopen \
        --input /dev/input/by-id/usb-GGG_GPWiz49-event-joystick grab=force persist=reopen \
        --map "key:300" "key:up" \
        --print \
        --output name="joysticks" \
While parsing the arguments "--map key:300 key:up":
    While parsing the key "key:300"
        invalid argument: unknown event code "300"

evtest output:

Event: time 1669313468.400824, type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000d
Event: time 1669313468.400824, type 1 (EV_KEY), code 300 (?), value 0

Any ideas for workarounds?

KarsMulder commented 1 year ago

Related issue: #20

This is possible on the main branch but not the latest stable version. You need to build evsieve from the main branch and then refer to your desired key as key:%300 or btn:%300. The reason that this % character is necessary is to avoid amiguities/inconsisencies like key:1, which can already be interpreted as (EV_KEY, KEY_1).

sudo evsieve --input /dev/input/by-id/usb-GGG_GPWiz49-2-event-joystick grab=force persist=reopen \
        --input /dev/input/by-id/usb-GGG_GPWiz49-event-joystick grab=force persist=reopen \
        --map "key:%300" "key:up" \
        --print \
        --output name="joysticks" \
jettdc commented 1 year ago

Thanks for the quick reply! Yeah, I was confused since I saw that functionality in the source code but couldn't get it to work on my machine. Didn't even occur to me that I didn't have the main branch built. Doh. I'll make sure to rebuild from main then.

My temporary workaround, just to throw it out there for anyone who may not want to/be able to use that functionality:

evtest /dev/input/by-id/joystick-x EV_KEY 300 \
        | grep "300.*value" --line-buffered \
        | grep --line-buffered -o "[01]$" \
        | while read x ; do evemu-event /dev/input/eventX --type EV_KEY --code BTN_X --value $x ; done

Just monitors for those erroneous events, extracts the value from it, and emits a virtual event from the same joystick (or whatever device you want it to emit from I suppose)