Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BTN_ Key code names not supported #283

Open
vicencb opened this issue May 28, 2024 · 1 comment · May be fixed by #284
Open

BTN_ Key code names not supported #283

vicencb opened this issue May 28, 2024 · 1 comment · May be fixed by #284

Comments

@vicencb
Copy link

vicencb commented May 28, 2024

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
Copy link
Author

vicencb commented May 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant