Custom mappings for the Logitech R400 under Fedora 20
I wanted to use a Logitech R400 that a friend loaned my in a presentation, but I wanted to tweak the mappings for the buttons a bit. My presentation is done using Reveal.js and uses both left/right and up/down. The R400 has four buttons but two of them are mapped to "go to black screen" and "slideshow mode" neither of which is useful to me. Here is how I fixed it in Fedora 20.
-
Create the directory
/etc/udev/hwdb.d
-
Write the following out to
/etc/udev/hwdb.d/99-logitech-r400.hwdb
<code>
# The lower left button actually emits two
# different scancodes depending on the state of
# the "presentation".
# E.g. one code to start and one to stop.
keyboard:usb:v046DpC538
KEYBOARD_KEY_70029=up
KEYBOARD_KEY_7003E=up
KEYBOARD_KEY_70037=down
KEYBOARD_KEY_7004B=left
KEYBOARD_KEY_7004E=right
</code>
This maps the left and right buttons to left and right, the both states of the slideshow button to up, and the blank screen button to down. The 046D
is the Logitech vendor code and the C538
is the model number. Those magic numbers after "KEYBOARD_KEY" are the scancodes associated with the button. Supposedly showkey --scancodes
will display them but I couldn't get that to work and ended up taking them from another blog post.
- Now we need to load this information.
<code>
# udevadm hwdb --update && udevadm trigger
</code>
- We can test by running the command below and pushing the buttons
<code>
# xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'
</code>
-
Everything should work now, but if we unplug the USB receiver everything gets reset. That's annoying so we will fix it
-
Write the following to
/etc/udev/rules.d/99-logitech-r400.rules
<code>
SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c538", IMPORT{builtin}="hwdb 'keyboard:usb:v046DpC538'", RUN{builtin}+="keyboard"
</code>
That will import our custom mapping when the USB receiver is plugged in.
Thanks to the following who helped me figure all this out: