tuxmark5 / ApexCtl

An utility to enable extra macro keys on Steelseries Apex keyboards
GNU Lesser General Public License v3.0
101 stars 19 forks source link

How to assign keycodes to up/left ↖ and up/right ↗ arrow keys? #59

Closed madivad closed 5 years ago

madivad commented 5 years ago

I raised a new issue since i made a mess of the old one

The keyboard arrow keys with the inverted T arrow keys, being the up/left and up/right arrow keys, have scancodes of 0x700ac and 0x700ad

These scancodes do not appear in the /etc/udev/hwdb.d/90-apex.hwdb file and adding them there does not do anything.

for the purposes of this I am only going to deal with the up/left arrow key:

upon a reboot of the keyboard (and the driver hasn't been run),

upon keyboard reboot

xev

KeyPress event, serial 30, synthetic NO, window 0x4400001,
    root 0x1e5, subw 0x0, time 164253920, (466,290), root:(512,1508),
    state 0x10, keycode 113 (keysym 0xff51, Left), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 30, synthetic NO, window 0x4400001,
    root 0x1e5, subw 0x0, time 164253920, (466,290), root:(512,1508),
    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 0x4400001,
    root 0x1e5, subw 0x0, time 164253976, (466,290), root:(512,1508),
    state 0x10, keycode 113 (keysym 0xff51, Left), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x4400001,
    root 0x1e5, subw 0x0, time 164253976, (466,290), root:(512,1508),
    state 0x10, keycode 111 (keysym 0xff52, Up), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

evetest

Event: time 1565522394.790925, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70050
Event: time 1565522394.790925, type 1 (EV_KEY), code 105 (KEY_LEFT), value 1
Event: time 1565522394.790925, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70052
Event: time 1565522394.790925, type 1 (EV_KEY), code 103 (KEY_UP), value 1
Event: time 1565522394.790925, -------------- SYN_REPORT ------------

Up/left produced keycodes 105 and 103 as determined by the keyboards internal and default settings.

upon driver initialisation

xev

KeyPress event, serial 29, synthetic NO, window 0x4400001,
    root 0x1e5, subw 0x0, time 164510143, (637,406), root:(683,1624),
    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 0x4400001,
    root 0x1e5, subw 0x0, time 164510187, (637,406), root:(683,1624),
    state 0x10, keycode 248 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

note: keycode 248

evtest

Event: time 1565522600.186403, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700ac Event: time 1565522600.186403, type 1 (EV_KEY), code 240 (KEY_UNKNOWN), value 1 Event: time 1565522600.186403, -------------- SYN_REPORT ------------ Event: time 1565522600.250347, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700ac Event: time 1565522600.250347, type 1 (EV_KEY), code 240 (KEY_UNKNOWN), value 0 Event: time 1565522600.250347, -------------- SYN_REPORT ------------ node: ccode 240

note the different codes as output by the event testing apps. Either way, I have set actions for those scancodes in /etc/udev/hwdb.d/90-apex.hwdb

cat /etc/udev/hwdb.d/90-apex.hwdb 
# 1) Place this to /etc/udev/hwdb.d/90-apex.hwdb
# 2) sudo udevadm hwdb --update
# 3) sudo udevadm control --reload

keyboard:usb:v1038p120[02]*
 KEYBOARD_KEY_0700a8=prog1
 KEYBOARD_KEY_0700a9=prog2
 KEYBOARD_KEY_0700aa=prog3
 KEYBOARD_KEY_0700ab=prog4
 KEYBOARD_KEY_0700ac=help
 KEYBOARD_KEY_0700ad=info
 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

You can see here I've associated help and info here, but I've tried all myriad of things, I have run the associated commands and rebooted several times. In fact I have created a script that runs (this should cover everything!):

sudo udevadm hwdb --update
sudo udevadm control --reload
sudo udevadm control --reload-rules && udevadm trigger

How do I assign keycodes to these keys?

madivad commented 5 years ago

I worked out you need to research the keycodes you give it, you can't just arbitrarily assign any value as some get consumed by the system.

Once you do this, you can use them in software.

In the end I gave them codes 221 and 220 and that worked