eudev-project / eudev

Repository for eudev development
GNU General Public License v2.0
529 stars 144 forks source link

BTN_ Key code names not supported #283

Open vicencb opened 5 months ago

vicencb commented 5 months ago

From the file 60-keyboard.hwdb:

# Keycodes are either KEY_* defines in lowercase with the key_ prefix
# optionally removed or BTN_ defines in lowercase with btn_ preserved.

The implementation doesn't follow the documentation because BTN_ key codes are not supported at all.

I've made an attempt at fixing this, but it did not work. Here it is for reference:

--- a/src/udev/Makefile.am
+++ b/src/udev/Makefile.am
@@ -114,10 +114,10 @@ nodist_libudev_core_la_SOURCES = \

 keyboard-keys.txt: Makefile
    $(AM_V_at)f="$@"; case $$f in */*) $(MKDIR_P) "$${f%/*}"; esac
-   $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include linux/input.h - < /dev/null | $(AWK) '/^#define[ \t]+KEY_[^ ]+[ \t]+[0-9]/ { if ($$2 != "KEY_MAX") { print $$2 } }' | sed 's/^KEY_COFFEE$$/KEY_SCREENLOCK/' > $@
+   $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include linux/input.h - < /dev/null | $(AWK) '/^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9]/ { if ($$2 != "KEY_MAX") { print $$2 } }' | sed 's/^KEY_COFFEE$$/KEY_SCREENLOCK/' > $@

 keyboard-keys-from-name.gperf: keyboard-keys.txt Makefile
-   $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct key { const char* name; unsigned short id; };"; print "%null-strings"; print "%%";} { print tolower(substr($$1 ,5)) ", " $$1 }' keyboard-keys.txt > $@
+   $(AM_V_GEN)$(AWK) 'BEGIN{ print "struct key { const char* name; unsigned short id; };"; print "%null-strings"; print "%%";} /^BTN_/{ print tolower($$1) ", " $$1 } !/^BTN_/{ print tolower(substr($$1 ,5)) ", " $$1 }' keyboard-keys.txt > $@

 keyboard-keys-from-name.h: keyboard-keys-from-name.gperf Makefile
    $(AM_V_GPERF)$(GPERF) -L ANSI-C -t -N keyboard_lookup_key -H hash_key_name -p -C < keyboard-keys-from-name.gperf > $@

The error messages, before and after my attempt at fixing it, are:

Unknown key identifier 'btn_left'
Unknown key identifier 'btn_middle'

In order to test it, i am using this:

evdev:input:b0003v047Dp2041*
 KEYBOARD_KEY_ff000002=btn_middle
 KEYBOARD_KEY_ff000001=btn_left

For now, as a workaround, i am using this:

evdev:input:b0003v047Dp2041*
 KEYBOARD_KEY_ff000002=0x112
 KEYBOARD_KEY_ff000001=0x110
vicencb commented 5 months ago

My attempt at fixing the issue does indeed work. I replaced the udevd file, but didn't restart the service.