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.

  1. Create the directory /etc/udev/hwdb.d

  2. Write the following out to /etc/udev/hwdb.d/99-logitech-r400.hwdb

# 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.

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.

  1. Now we need to load this information.
# udevadm hwdb --update && udevadm trigger
  1. We can test by running the command below and pushing the buttons
# xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'
  1. Everything should work now, but if we unplug the USB receiver everything gets reset. That’s annoying so we will fix it

  2. Write the following to /etc/udev/rules.d/99-logitech-r400.rules

SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c538", IMPORT{builtin}="hwdb 'keyboard:usb:v046DpC538'", RUN{builtin}+="keyboard"

That will import our custom mapping when the USB receiver is plugged in.

Thanks to the following who helped me figure all this out: