Technitribe

interesting problems (and a few solutions, too)

Technitribe
  • About the Authors
  • Log In
  • Log Out
  • Lost Password
  • Register
  • Reset Password
    • 2 Mar 2015

      Custom mappings for the Logitech R400 under Fedora 20

      Written by Alex Wood

      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.
        keyboard:usb:v046DpC538
          KEYBOARD_KEY_70029=up
          KEYBOARD_KEY_7003E=up
          KEYBOARD_KEY_70037=down
          KEYBOARD_KEY_7004B=left
          KEYBOARD_KEY_7004E=right   
        

        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.

      3. Now we need to load this information.
        
        # udevadm hwdb --update && udevadm trigger
           
      4. 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'
        
      5. Everything should work now, but if we unplug the USB receiver everything gets reset. That’s annoying so we will fix it
      6. 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:

      • Tweaking the Logitech R400 presenter tool on Linux by Derrick Rethams
      • udevadm
      • Udev – Crashcourse Wiki
      • How to create custom keymaps now that libudevkeymap is gone
      • Writing Udev Rules by Daniel Drake
      • Tags »
      • logitech presentation r400 scancodes udev

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    • The Authors
    • Virtual Disk Guide

      Interested in virtualization? Do QCOWs rule your filesystem? Are you a libvirt or KVM+QEMU wizard? I wrote a book about virtual disk management. Check out the The Linux Sysadmin's Guide to Virtual Disks online for free at ScribesGuides.com.


      Consider supporting the author by purchasing a hard copy of the first edition for just $10.00 on Lulu.com.

    • bitmath

      bitmath is a Python library for dealing with file size units (GiB's, kB's, etc) in a sane way. bitmath supports arithmetic, rich comparison, conversion, automatic best human-readable representation, and many other utility functions. Read some examples on the docs site or check out the source on GitHub.

    • latest posts

      • Querying block device sizes in Python on Linux and Mac OS X February 4, 2023
      • Using jq to filter an array of objects from JSON September 9, 2019
      • Two Year Break — And we’re back! November 16, 2018
    • tags

      bitmath blog conference css dblatex DNS DocBook eclipse Emacs Erlang Fedora fedora 22 filter GNU Screen Haiku Introduction java jboss LCSEE Linux locale locales fix slicehost ubuntu Macports module nist nXML-Mode opengl open source OS X package packaging pki prefix units presentation project pypi Python scholarship si summit Tutorial ubuntu xcode XML XMPP
    • h4ck teh world

      tbielawatbielawa
      • Issue Comment
        bitmath
        February 6, 2023 - 12:55 am UTC
      • Issue Comment
        bitmath
        February 6, 2023 - 12:54 am UTC
      • Push
        bitmath
        February 6, 2023 - 12:51 am UTC
      • Issue Comment
        bitmath
        February 6, 2023 - 12:36 am UTC
      • Push
        bitmath
        February 6, 2023 - 12:30 am UTC

Creative Commons License
Technitribe by Tim Bielawa is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.