Skip to content

BTN_ Key code names not supported #283

@vicencb

Description

@vicencb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions