ApexCtl
ApexCtl copied to clipboard
where best to assign the keyboard keycodes for the MX, M and media keys?
I'm using ubuntu 18.04 LTS and I want to map keys on a keyboard, but not every keyboard, just this one specific one, and other keys on other keyboards, but that's another issue.
I'm having a lot of trouble understanding the ins and outs of the whole process and have debugged a few issues in getting this right.
Now that I have my Apex350 setup to basic with keys outputting keycodes 179 thru 202 I have a problem that some keys are already used, ie, 179 and 191 (both open the settings dialog) and some keys don't output anything in xev
but they do in evtest
(notably MX1, M1 and M8 thru M11).
Why do some keys not present in xev
?? notably 179 and 191 (M1 and MX1)?
- Are we using xmodmap or xkbd to map the keys (or what tool is best for it? I am on ubuntu 18.04)**
- are we best editing the KEYBOARD__KEY07nnnn codes and mapping those keys to unused codes? (I'm liking this idea, then I can use AutoHotkey to make the required macros)
**I ask this question because the underlying system seems to use anything and everything and I don't want patch upon patch, I want to use the best tool for the job, the tool the underlying gnome or ubuntu desktop uses, and little to nothing else. I'm obviously using ApexCtl to get the macro keys to function, but what should I be doing next to get absolute control of what keypress results in what keycode for my system?
The way this works is this:
- The apexctl utility itself only enables those extra keys, so they could be seen in evtest
- udev then translates those raw scancodes into something that Xorg can use (keycodes; you can customize the translation with 90-apex.hwdb or similar)
- Xorg then applies it's own mappings on top (you can customize this translation using xmodmap)
As you might have guessed, you need to use udev aka KEYBOARD__KEY07nnnn to give each of those keys an unique id. From what you have described, it seems that 90-apex.hwdb is being ignored altogether.
It is possible that the first line in 90-apex.hwdb (keyboard:usb:v1038p120[02]*
) fails to identify your keyboard and apply the proper mappings. Therefore you should ensure that the vendor & device id combo matches the regexp v1038p120[02]*
. If not, then modify the hwdb file accordingly. USB devices and their vendor/product ids can be seen using lsusb
utility.
Essentially you need to follow the map scancodes to keycodes tutorial. As a quick glance it seems that the way input devices are matched in hwdb rules has been changed over recent-ish updates. So the hwdb file should seemingly start now with evdev:input:b0003v1038p120[02]*
I don't use any of the Apex keyboards anymore, so I can't really test this stuff myself unfortunately.
I actually believed I was getting a hold of this. Thanks for the links of the scancode/keycode tutorial, very good!
I want to go back to the /etc/udev/hwdb.d/90-apex.hwdb
which has the content:
# 1) Place this to /etc/udev/hwdb.d/90-apex.hwdb
# 2) sudo udevadm hwdb --update
# 3) sudo udevadm control --reload
evdev:input:b0003v1038p120[02]*
KEYBOARD_KEY_0700a8=prog1
KEYBOARD_KEY_0700a9=prog2
KEYBOARD_KEY_0700aa=prog3
KEYBOARD_KEY_0700ab=prog4
KEYBOARD_KEY_0700e8=config
KEYBOARD_KEY_0700e9=homepage
KEYBOARD_KEY_0700ea=refresh
KEYBOARD_KEY_0700eb=exit
KEYBOARD_KEY_0700ec=move
KEYBOARD_KEY_0700ed=edit
KEYBOARD_KEY_0700ee=scrollup
KEYBOARD_KEY_0700ef=scrolldown
KEYBOARD_KEY_0700f0=kpleftparen
KEYBOARD_KEY_0700f1=kprightparen
KEYBOARD_KEY_0700f4=f13
KEYBOARD_KEY_0700f5=f14
KEYBOARD_KEY_0700f6=f15
KEYBOARD_KEY_0700f7=f16
KEYBOARD_KEY_0700f8=f17
KEYBOARD_KEY_0700f9=f18
KEYBOARD_KEY_0700fa=f19
KEYBOARD_KEY_0700fb=f20
KEYBOARD_KEY_0700fc=f21
KEYBOARD_KEY_0700fd=f22
KEYBOARD_KEY_0700fe=f23
KEYBOARD_KEY_0700ff=f24
KEYBOARD_KEY_0c00e2=mute
KEYBOARD_KEY_0c00b6=previoussong
KEYBOARD_KEY_0c00b5=nextsong
KEYBOARD_KEY_0c00cd=playpause
I have added two lines for the keys next to the inverted-T arrow keys, the up-left and the up-right arrows.
KEYBOARD_KEY_0700ad=f26
but when I do an evtest or xev they are still unrecognised.
Yes, I've run those commands, and even rebooted.
Pressing the three keys, up/left, up, up/right returns:
evtest:
Event: time 1565356477.622015, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700ac
Event: time 1565356477.622015, type 1 (EV_KEY), code 240 (KEY_UNKNOWN), value 1
Event: time 1565356477.622015, -------------- SYN_REPORT ------------
Event: time 1565356477.710006, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700ac
Event: time 1565356477.710006, type 1 (EV_KEY), code 240 (KEY_UNKNOWN), value 0
Event: time 1565356477.710006, -------------- SYN_REPORT ------------
Event: time 1565356477.969958, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70052
Event: time 1565356477.969958, type 1 (EV_KEY), code 103 (KEY_UP), value 1
Event: time 1565356477.969958, -------------- SYN_REPORT ------------
^[[AEvent: time 1565356478.057996, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70052
Event: time 1565356478.057996, type 1 (EV_KEY), code 103 (KEY_UP), value 0
Event: time 1565356478.057996, -------------- SYN_REPORT ------------
Event: time 1565356478.257985, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700ad
Event: time 1565356478.257985, type 1 (EV_KEY), code 240 (KEY_UNKNOWN), value 1
Event: time 1565356478.257985, -------------- SYN_REPORT ------------
Event: time 1565356478.361955, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700ad
Event: time 1565356478.361955, type 1 (EV_KEY), code 240 (KEY_UNKNOWN), value 0
Event: time 1565356478.361955, -------------- SYN_REPORT ------------
xev
KeyPress event, serial 29, synthetic NO, window 0x3e00001,
root 0x1e5, subw 0x0, time 775216, (240,110), root:(1615,482),
state 0x10, keycode 248 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x3e00001,
root 0x1e5, subw 0x0, time 775292, (240,110), root:(1615,482),
state 0x10, keycode 248 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 30, synthetic NO, window 0x3e00001,
root 0x1e5, subw 0x0, time 776588, (240,110), root:(1615,482),
state 0x10, keycode 111 (keysym 0xff52, Up), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x3e00001,
root 0x1e5, subw 0x0, time 776664, (240,110), root:(1615,482),
state 0x10, keycode 111 (keysym 0xff52, Up), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 30, synthetic NO, window 0x3e00001,
root 0x1e5, subw 0x0, time 777020, (240,110), root:(1615,482),
state 0x10, keycode 248 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x3e00001,
root 0x1e5, subw 0x0, time 777100, (240,110), root:(1615,482),
state 0x10, keycode 248 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
I really thought by adding the hwdb
scancodes, I'd be able to utilise them