Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My Logitech R400 presenter sends the following key codes:

keycode 112 (keysym 0xff55,  Prior) [page up]
keycode 117 (keysym 0xff56,   Next) [page down]
keycode  60 (keysym   0x2e, period)
keycode  71 (keysym 0xffc2,     F5)
keycode   9 (keysym 0xff1b, Escape)

Basically, I want to use this presenter to remotely control Banshee, so I'd like to remap Prior to B, Next to N, and so on.

How can I change the keymap for this device only (as I certainly don't want to remap those key codes globally)?

share|improve this question
    
AFAIU "slave pointer" means it's a mouse, not a keyboard. You can't load a keymap onto a mouse. Are those really the only devices present in xinput list? –  Marius Gedminas Oct 22 '11 at 19:01
    
@MariusGedminas I had to go through the /dev/input/eventX devices and event5 was the presenter, so it seems to be a "keyboard" after all. –  htorque Oct 22 '11 at 19:25

1 Answer 1

up vote 14 down vote accepted

I never did that but I think you need to create a keymap file in /lib/udev/keymaps/ and add a rule for your device to /lib/udev/rules.d/95-keymap.rules


Details:

  • An udev keymap maps scan codes to key codes, so you need to find both to create the keymap file. To find the scan codes run the following and press the buttons on the device:

    sudo /lib/udev/keymap -i input/event5
    

    You might need to try different numbers for event*. The output should look like this:

    scan code: 0x70037   key code: dot
    scan code: 0x70029   key code: esc
    scan code: 0x7003E   key code: f5
    scan code: 0x7004B   key code: pageup
    scan code: 0x7004E   key code: pagedown
    

    A list of key codes can be found here.

    Now create the keymap file (I'm storing it as /lib/udev/keymaps/logitech-r400):

    0x70037 brightnessdown
    0x70029 brightnessup
    0x7003E brightnessdown
    0x7004B brightnessup
    0x7004E brightnessdown
    

    Doesn't do anything useful - just a test to easily see if it works.

  • To test the new keymap temporarily, run:

    sudo /lib/udev/keymap input/event5 /lib/udev/keymaps/logitech-r400
    

    which should result in output like this:

    Remapped scancode 0x70037 to 0xe0 (prior: 0x34)
    Remapped scancode 0x70029 to 0xe1 (prior: 0x01)
    Remapped scancode 0x7003e to 0xe0 (prior: 0x3f)
    Remapped scancode 0x7004b to 0xe1 (prior: 0x68)
    Remapped scancode 0x7004e to 0xe0 (prior: 0x6d)
    

    The buttons should now change the brightness.

  • If you want to make that change permanent, you need to add an udev rule to /lib/udev/rules.d/95-keymap.rules that applies the keymap file to the device.

    1. Open the file: gksudo gedit /lib/udev/rules.d/95-keymap.rules
    2. At the bottom of the file, but before the LABEL="keyboard_end" line, add:

      ENV{ID_VENDOR}=="Logitech*", ATTRS{idProduct}=="c52d", RUN+="keymap $name logitech-r400"
      
    3. Save, close, and after a reboot the buttons should change the brightness.

share|improve this answer
    
Oh how could I forget about that (/lib/udev/keymaps/zepto-znote was contributed by me :D). I will later add more about how I made it work to your answer. –  htorque Oct 22 '11 at 19:24
    
Just wanted to add to this answer that you can zero in on what "eventX" your keyboard might be by running /lib/udev/findkeyboards. That will list all the currently attached keyboards so you don't have to try so many. The logitech r400 showed up as "USB keyboard: input/event11" for me. –  jat255 Aug 15 '12 at 19:26
    
Nice answer, but how do I discover the ID_VENDOR and idProduct to use? I tried /sys/class/dmi/id/sys_vendor and /sys/class/dmi/id/product_name but it didn't work. –  PutzKipa Oct 25 '12 at 13:22
1  
/lib/udev/keymap and /lib/udev/findkeyboards no longer exist on 13.10. forum.ubuntu-fr.org/viewtopic.php?id=1395051 says to use evtest instead. –  Stéphane Gourichon Nov 4 '13 at 10:07
2  
Hello @htorque, could you update the answer to the new way ? In Ubuntu Trusty all these files don't exist anymore. You are the only one I have seen on the net having the same isue. –  londumas Mar 31 at 21:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.