2

I have an old USB RF remote that I'd like to use with Kodi. The remote is a non-keyboard input device which generates keycodes. I'd like to do some remapping, but I haven't done that since the days of /usr/lib/keymap, which has been retired in favour of evtest and udev's hwdb files.

An HWDB rule (for my purpose) consists of a hardware identifying header, and then bunch of key mappings. I've found several examples of doing this for a keyboard, but none for my non-keyboard input device, and none that explain how to construct the hwdb header.

Generally speaking, how do I construct the hwdb header? Here's the output of udevadm info /dev/input/eventX.

P: /devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.0/rc/rc0/input8/event4
N: input/event4
S: input/by-id/usb-X10_Wireless_Technology_Inc_USB_Transceiver-event-if00
S: input/by-path/pci-0000:00:02.0-usb-0:1:1.0-event
E: BACKSPACE=guess
E: DEVLINKS=/dev/input/by-path/pci-0000:00:02.0-usb-0:1:1.0-event /dev/input/by-id/usb-X10_Wireless_Technology_Inc_USB_Transceiver-event-if00
E: DEVNAME=/dev/input/event4
E: DEVPATH=/devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.0/rc/rc0/input8/event4
E: ID_BUS=usb
E: ID_INPUT=1
E: ID_INPUT_KEY=1
E: ID_MODEL=USB_Transceiver
E: ID_MODEL_ENC=USB\x20Transceiver
E: ID_MODEL_ID=0002
E: ID_PATH=pci-0000:00:02.0-usb-0:1:1.0
E: ID_PATH_TAG=pci-0000_00_02_0-usb-0_1_1_0
E: ID_REVISION=0100
E: ID_SERIAL=X10_Wireless_Technology_Inc_USB_Transceiver
E: ID_TYPE=generic
E: ID_USB_DRIVER=ati_remote
E: ID_USB_INTERFACES=:ff0000:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=X10_Wireless_Technology_Inc
E: ID_VENDOR_ENC=X10\x20Wireless\x20Technology\x20Inc
E: ID_VENDOR_ID=0bc7
E: MAJOR=13
E: MINOR=68
E: SUBSYSTEM=input
E: USEC_INITIALIZED=8383075
E: XKBLAYOUT=us
E: XKBMODEL=pc105

1 Answer 1

4

This turned out to be easier than I thought. Mostly I just had to read the (gasp) man page, and figure out that it's OK to use an abbreviated (and wildcarded) version of the USB device's modalias for a match string.

Steps:

  1. find the device vendor with lsusb. Mine was 0BC7.

  2. Find all the device's modalias files with

    find /sys -name *modalias | xargs grep -i 0BC7
    
  3. There will be several. Use the one that has a single string. Mine was the file at

    /sys/devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.0/modalias
    

My modalias string looks like this. We want everything before the 'e', because we want it to apply to all versions.

    input:b0003v0BC7p0002e0100-e0,1,2,k110,111,113,114,r0,1,amlsfw
  1. I use evtest to find a scan code for a button on my remote. It's the "value" after an MSC_SCAN. In my case, I'm using the key with value 0b. I'm going to map it to a keycode that's easy to observe: mute.

  2. Using heavy reference to this Arch wiki page, I create a hwdb file in /etc/udev/hwdb.d/10-x10.hwdb. It contains:

    evdev:input:b0003v0BC7p0002*
     KEYBOARD_KEY_0b=mute
    
  3. The following commands update and use my new hwdb file.

    udevadm hwdb --update
    udevadm trigger
    udevadm info /dev/input/event4 | grep KEYB
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .