more fireworks
Andi playing some Wii
Sylvia
HPIM0614.JPG
PB120078.JPG
Weird sculpture
Sylvia and Luke in the shower
HPIM0838.JPG

 

May 2009
M T W T F S S
« Apr   Jun »
 123
45678910
11121314151617
18192021222324
252627282930  

modifying multimedia keys

TUX logoThis is a quick post because it's taken me the better part of 3 days to work out how to remap multimedia keys under linux. The problem that I encountered (and very quickly) was that keys such as the mute or volume up/down keys would trigger the correct event in gnome (volume would mute or raise and lower) but all of the descriptions of how to remap keys using xev didn't seem to remap the keys. Following the directions on http://dev-loki.blogspot.com/2006/04/mapping-unsupported-keys-with-xmodmap.html resulted in the following:
Using xev, determine the keycode:

andrewb@yivo:~$ xev
# press 'a' key
KeyRelease event, serial 35, synthetic NO, window 0x3c00001,
    root 0x13c, subw 0x0, time 7645167, (723,347), root:(730,398),
    state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False
# press 'mute' button
KeymapNotify event, serial 35, synthetic NO, window 0x0,
    keys:  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
          0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
andrewb@yivo:~$


As you can see from the above example, the 'a' key generates a keycode (38 in this case) and the mute button triggers an event but no keycode. After much reading, I discovered that the input could be triggered by hal events and I proved that this was the case by:

andrewb@yivo:~$ lshal -m
Start monitoring devicelist:
-------------------------------------------------
11:45:46.614: platform_i8042_i8042_KBD_port_logicaldev_input condition ButtonPressed = mute
11:45:53.173: platform_i8042_i8042_KBD_port_logicaldev_input condition ButtonPressed = mute
11:46:06.379: platform_i8042_i8042_KBD_port_logicaldev_input condition ButtonPressed = volume-up
11:46:12.939: platform_i8042_i8042_KBD_port_logicaldev_input condition ButtonPressed = volume-up
^C
andrewb@yivo:~$

Some of the multimedia keys trigger a message in syslog:

andrewb@yivo:~$ tail -f /var/log/syslog
May 31 11:58:10 yivo kernel: [ 8885.299884] atkbd.c: Unknown key pressed (translated set 2, code 0x89 on isa0060/serio0).
May 31 11:58:10 yivo kernel: [ 8885.299892] atkbd.c: Use 'setkeycodes e009 <keycode>' to make it known.
May 31 11:58:10 yivo kernel: [ 8885.310803] atkbd.c: Unknown key released (translated set 2, code 0x89 on isa0060/serio0).
May 31 11:58:10 yivo kernel: [ 8885.310812] atkbd.c: Use 'setkeycodes e009 <keycode>' to make it known.
^C
andrewb@yivo:~$

After beating my head against this particular brickwall for a while, I stumbled from thinkwiki to quirk keymap which contained a fairly succinct description of how to remap this. If you want a full description of what the problem is and how to fix it, head over there. For this post I'll describe how to remap the keys that don't work on my Acer Aspire 6920.

Step 1

The first thing to do is to determine what file your particular machine is using:

root@yivo:/usr/share/hal/fdi/information/10freedesktop# lshal | grep system.hardware
  system.hardware.primary_video.product = 1029  (0x405)  (int)
  system.hardware.primary_video.vendor = 4318  (0x10de)  (int)
  system.hardware.product = 'Aspire 6920'  (string)
  system.hardware.serial = 'xxxxxxxxxxxxxxxxxxxxxxx'  (string)
  system.hardware.uuid = 'xxxxxxxxxxxxxxxxxxxxxxxx'  (string)
  system.hardware.vendor = 'Acer'  (string)
  system.hardware.version = 'Aspire 6920'  (string)
root@yivo:/usr/share/hal/fdi/information/10freedesktop#

The two important parts in this guff are the vendor (acer) and the version (aspire 6920).

Step 2

Now, determine what keys don't have keycodes mapped to them by tailing a log file:

root@yivo:/usr/share/hal/fdi/information/10freedesktop# tail -f /var/log/syslog | grep atkbd
#press jump key
May 31 12:15:55 yivo kernel: [ 9950.770680] atkbd.c: Use 'setkeycodes e012 <keycode>' to make it known.
....
# press back key
May 31 12:16:30 yivo kernel: [ 9985.779479] atkbd.c: Use 'setkeycodes e01e <keycode>' to make it known.
....
# press rewind key
May 31 12:26:01 yivo kernel: [  125.886901] atkbd.c: Use 'setkeycodes e003 <keycode>' to make it known.
....
# press fforward key
May 31 12:17:28 yivo kernel: [10043.465506] atkbd.c: Use 'setkeycodes e009 <keycode>' to make it known.
....

Step 3

Now, to determine the file that your machine is using to determine the hal events, head to:

root@yivo:~# cd /usr/share/hal/fdi/information/10freedesktop
root@yivo:/usr/share/hal/fdi/information/10freedesktop#

The file should start with 30-keymap-*.fdi In my case, the filename is 30-keymap-acer.fdi (30-keymap-.fdi). You can specify the product type using: system.hardware.product. In addition, you can keymap to any code in /usr/include/linux/input.h (use the lowercase version and drop the KEY_ part - eg. KEY_HOMEPAGE becomes the keymap homepage).
I chose the following:

root@yivo:~# vi /usr/share/hal/fdi/information/10freedesktop/30-keymap-acer.fdi
...
        <match key="/org/freedesktop/Hal/devices/computer:system.hardware.product" prefix="Aspire">
            <match key="/org/freedesktop/Hal/devices/computer:system.hardware.product" contains="6920">
                <append key="input.keymap.data" type="strlist">e012:f13</append><!-- jump key -->
                <append key="input.keymap.data" type="strlist">e01e:back</append><!-- back key -->
                <append key="input.keymap.data" type="strlist">e003:rewind</append><!-- rewind key -->
                <append key="input.keymap.data" type="strlist">e009:forward</append><!-- fastforward key -->
            </match>
        </match>
...
root@yivo:~#

Now, restart the hal service:

root@yivo:~# /etc/init.d/hal restart
* Restarting Hardware abstraction layer hald                                                                              [ OK ]
root@yivo:~#

Step 4

Now it's time to test using xev (which you'll remember didn't work previously):

root@yivo:~# xev
# press jump key
KeyRelease event, serial 35, synthetic NO, window 0x3c00001,
    root 0x13c, subw 0x0, time 3227707, (229,537), root:(236,588),
    state 0x0, keycode 191 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
# press back key
KeyRelease event, serial 35, synthetic NO, window 0x3c00001,
    root 0x13c, subw 0x0, time 3293030, (118,358), root:(125,409),
    state 0x0, keycode 166 (keysym 0x1008ff26, XF86Back), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
# press rewind key
KeyRelease event, serial 35, synthetic NO, window 0x3c00001,
    root 0x13c, subw 0x0, time 3314702, (539,211), root:(546,262),
    state 0x0, keycode 176 (keysym 0x1008ff3e, XF86AudioRewind), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
# press fforward key
KeyRelease event, serial 35, synthetic NO, window 0x3c00001,
    root 0x13c, subw 0x0, time 3346988, (501,366), root:(508,417),
    state 0x0, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
^C
root@yivo:~#

This worked for me and it's only a tiny step to change from this to modifying your input keys (which was my initial intention). I hope that this helps someone else struggling with this but keep in mind that YMMV and the only guarantee is that if you break it you get to keep all of the pieces.

Popularity: 26% [?]

Everybody's a critic WTF?? Nothing about this made senseas useful as a blindfolded monkey throwing dartsmediocre ... at bestsolved my problem but needed modificationspectacular.  \'Nuff said (2 votes, average: 5.00 out of 5)
Loading ... Loading ...

1 comment to modifying multimedia keys

  • Narko

    Very helpful how to. Step 2 did the trick for me. It somehow woke up sleepy buttons :) . Thank you. Btw I have logitech cordless internet pro keyboard.

    Narko ratings for this post: Narko gives a rating of 5Narko gives a rating of 5Narko gives a rating of 5Narko gives a rating of 5Narko gives a rating of 5

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>