Dell Inspiron 14z - Shortcut buttons

Dell Inspiron 14z (N411z) has three small shortcut buttons above the keyboard.

First button

First one with small gears on it can be used out of the box in KDE or GNOME.

xev output:

KeyPress event, serial 35, synthetic NO, window 0x6000001,
    root 0xb1, subw 0x0, time 137282557, (-94,112), root:(1047,135),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 35, synthetic NO, window 0x6000001,
    root 0xb1, subw 0x0, time 137282558, (-94,112), root:(1047,135),
    state 0x40, keycode 53 (keysym 0x78, x), same_screen YES,
    XLookupString gives 1 bytes: (78) "x"
    XmbLookupString gives 1 bytes: (78) "x"
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6000001,
    root 0xb1, subw 0x0, time 137282560, (-94,112), root:(1047,135),
    state 0x40, keycode 53 (keysym 0x78, x), same_screen YES,
    XLookupString gives 1 bytes: (78) "x"
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6000001,
    root 0xb1, subw 0x0, time 137282563, (-94,112), root:(1047,135),
    state 0x40, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Second button

Second button with a small wrench on it does not work. I tried xev, showkey, evtest and messed around with the source code but without any success. I lost all hope here.

Third button - this is where adventure begins

Third one with a small star on it needs a little work to be usable.

dmesg output shows:

atkbd serio0: Unknown key pressed (translated set 2, code 0x60 on isa0060/serio0).
atkbd serio0: Use 'setkeycodes 60 ' to make it known.

Execute as root in console (use /etc/rc.local file for persistent change):

# setkeycodes 60 222

Now showkey shows key press:

# showkey
kb mode was UNICODE
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)...
keycode  28 release
keycode 222 press

evtest shows value 1 after pressing it first time, value 2 afterwards:

Event: time 1331065738.017054, -------------- SYN_REPORT ------------
Event: time 1331065748.872962, type 4 (EV_MSC), code 4 (MSC_SCAN), value 60
Event: time 1331065748.872988, type 1 (EV_KEY), code 222 (KEY_ALTERASE), value 1
Event: time 1331065748.872990, -------------- SYN_REPORT ------------
Event: time 1331065750.573239, type 4 (EV_MSC), code 4 (MSC_SCAN), value 60
Event: time 1331065750.573260, type 1 (EV_KEY), code 222 (KEY_ALTERASE), value 2
Event: time 1331065750.573262, -------------- SYN_REPORT ------------

To use this button you need to modify xserver-xorg-input-evdev package so create build directory and grab the source code:

$ mkdir ~/build
$ cd ~/build
$ apt-get source xserver-xorg-input-evdev

Directory listing:

$ ls
xserver-xorg-input-evdev-2.6.0  
xserver-xorg-input-evdev_2.6.0-1ubuntu13.diff.gz  
xserver-xorg-input-evdev_2.6.0-1ubuntu13.dsc  
xserver-xorg-input-evdev_2.6.0.orig.tar.gz

Directory xserver-xorg-input-evdev-2.6.0 can be safely deleted:

$ rm -rf xserver-xorg-input-evdev-2.6.0 

Now save patch as evdev.patch file:

--- xserver-xorg-input-evdev-2.6.0.orig/src/evdev.c
+++ xserver-xorg-input-evdev-2.6.0/src/evdev.c
@@ -908,6 +908,18 @@
 
 }
 
+
+static void
+EvdevEmulateKey(InputInfoPtr pInfo, struct input_event *ev, int key, int state)
+{
+  ev->type = EV_KEY;
+  ev->code = key;
+  ev->value = state;
+  EvdevQueueKbdEvent(pInfo, ev, state);
+}
+
+
+
 /**
  * Process the events from the device; nothing is actually posted to the server
  * until an EV_SYN event is received.
@@ -923,7 +935,14 @@
             EvdevProcessAbsoluteMotionEvent(pInfo, ev);
             break;
         case EV_KEY:
-            EvdevProcessKeyEvent(pInfo, ev);
+           if (ev->code == 222) {
+               EvdevEmulateKey(pInfo, ev, KEY_LEFTCTRL, 1);
+               EvdevEmulateKey(pInfo, ev, KEY_O, 1);
+               EvdevEmulateKey(pInfo, ev, KEY_O, 0);
+               EvdevEmulateKey(pInfo, ev, KEY_LEFTCTRL, 0);
+           } else {
+               EvdevProcessKeyEvent(pInfo, ev);
+           }
             break;
         case EV_SYN:
             EvdevProcessSyncEvent(pInfo, ev);

This solution is directly taken from maxter-plus-linux (Patched evdev driver supporting Elmak Maxter Plus remote control) by dgolda.

I used CTRL+O as an emulated shortcut after pressing button so it is clear how to define own key presses and releases.

Compress it and add to other patches (as an alternative you can check xserver-xorg-input-evdev-2.6.0/debian/patches/ directory as it looks like better idea):

$ gzip evdev.patch
$ cat evdev.patch.gz >> xserver-xorg-input-evdev_2.6.0-1ubuntu13.diff.gz

Prepare source code:

$ dpkg-source --no-check -x xserver-xorg-input-evdev_2.6.0-1ubuntu13.dsc 
dpkg-source: info: extracting xserver-xorg-input-evdev in xserver-xorg-input-evdev-2.6.0
dpkg-source: info: unpacking xserver-xorg-input-evdev_2.6.0.orig.tar.gz
dpkg-source: info: applying xserver-xorg-input-evdev_2.6.0-1ubuntu13.diff.gz
dpkg-source: info: upstream files that have been modified: 
 xserver-xorg-input-evdev-2.6.0/autogen.sh
 xserver-xorg-input-evdev-2.6.0/src/evdev.c

Enter xserver-xorg-input-evdev-2.6.0 directory:

$ cd xserver-xorg-input-evdev-2.6.0

Build package:

$ dpkg-buildpackage -rfakeroot

Install package:

$ cd ..
$ ls *.deb
xserver-xorg-input-evdev_2.6.0-1ubuntu13_amd64.deb  
xserver-xorg-input-evdev-dev_2.6.0-1ubuntu13_all.deb
$ sudo dpkg -i xserver-xorg-input-evdev_2.6.0-1ubuntu13_amd64.deb 

Restart X server and check button. For testing purposes it is good idea to use xf86Msg function and monitor Xorg log in realtime.

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a system administrator working for a successful Polish company and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland https://sleeplessbeastie.eu