Bug 86420 - Mouse buttons cannot be mapped with KEYBOARD_KEY
Summary: Mouse buttons cannot be mapped with KEYBOARD_KEY
Status: RESOLVED NOTABUG
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-18 01:13 UTC by bugzilla
Modified: 2014-12-11 14:38 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description bugzilla 2014-11-18 01:13:58 UTC
Hi,

My remote presents itself (via an attached USB receiver dongle) as two devices,
a mouse and a keyboard. I'd like to map the mouse buttons to keyboard keys, but
have been unable to do so. Is this a bug, a missing feature, or a configuration
error on my part?

This is my remote:

http://www.amazon.com/Aerb-Multifunction-Wireless-Keyboard-3-Gsensor/dp/B00K768DHY

This is what the kernel logs when I attach the dongle:

[22989.504209] usb 3-1: USB disconnect, device number 3
[22990.628131] usb 3-1: new full-speed USB device number 4 using uhci_hcd
[22990.787132] usb 3-1: New USB device found, idVendor=0c45, idProduct=2b02
[22990.787136] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[22990.787139] usb 3-1: Product: 2.4G Wireless Device
[22990.787141] usb 3-1: Manufacturer: 2.4G
[22990.829719] input: 2.4G 2.4G Wireless Device as /devices/pci0000:00/0000:00:1a.1/usb3/3-1/3-1:1.2/0003:0C45:2B02.0005/input/input27
[22990.830459] hid-generic 0003:0C45:2B02.0005: input,hiddev0,hidraw0: USB HID v1.10 Mouse [2.4G 2.4G Wireless Device] on usb-0000:00:1a.1-1/input2
[22990.835287] input: 2.4G 2.4G Wireless Device as /devices/pci0000:00/0000:00:1a.1/usb3/3-1/3-1:1.3/0003:0C45:2B02.0006/input/input28
[22990.835519] hid-generic 0003:0C45:2B02.0006: input,hidraw1: USB HID v1.10 Keyboard [2.4G 2.4G Wireless Device] on usb-0000:00:1a.1-1/input3

This is what evtest tells me about the mouse buttons when I click them:

No device specified, trying to scan all of /dev/input/event*
Available devices:
[SNIP]
/dev/input/event16:     2.4G 2.4G Wireless Device
/dev/input/event17:     2.4G 2.4G Wireless Device
Select the device event number [0-17]: 16
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0xc45 product 0x2b02 version 0x110
Input device name: "2.4G 2.4G Wireless Device"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 272 (BTN_LEFT)
    Event code 273 (BTN_RIGHT)
    Event code 274 (BTN_MIDDLE)
    Event code 275 (BTN_SIDE)
    Event code 276 (BTN_EXTRA)
  Event type 2 (EV_REL)
    Event code 0 (REL_X)
    Event code 1 (REL_Y)
    Event code 8 (REL_WHEEL)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1416264046.211254, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1416264046.211254, type 1 (EV_KEY), code 272 (BTN_LEFT), value 1
Event: time 1416264046.211254, -------------- EV_SYN ------------
Event: time 1416264046.271254, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1416264046.271254, type 1 (EV_KEY), code 272 (BTN_LEFT), value 0
Event: time 1416264046.271254, -------------- EV_SYN ------------
Event: time 1416264051.295253, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1416264051.295253, type 1 (EV_KEY), code 273 (BTN_RIGHT), value 1
Event: time 1416264051.295253, -------------- EV_SYN ------------
Event: time 1416264051.419273, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1416264051.419273, type 1 (EV_KEY), code 273 (BTN_RIGHT), value 0
Event: time 1416264051.419273, -------------- EV_SYN ------------

This is what I've added to /etc/udev/hwdb.d/99-local.hwdb:

keyboard:usb:v0C45p2B02*
 KEYBOARD_KEY_90001=select
 KEYBOARD_KEY_90002=back

To make my changes to /etc/udev/hwdb.d/99-local.hwdb stick I run

# udevadm hwdb --update
# udevadm trigger

The original scancode/keycode mappings remain in effect, however.

I've tried replugging the receiver dongle and even rebooting, and I've also
tested with a bog-standard, three-button (wheeled) mouse, all to no avail.

This is what /proc/bus/input/devices has to say about the devices:

I: Bus=0003 Vendor=0c45 Product=2b02 Version=0110
N: Name="2.4G 2.4G Wireless Device"
P: Phys=usb-0000:00:1a.1-1/input2
S: Sysfs=/devices/pci0000:00/0000:00:1a.1/usb3/3-1/3-1:1.2/0003:0C45:2B02.0005/input/input27
U: Uniq=
H: Handlers=mouse1 event16
B: PROP=0
B: EV=17
B: KEY=1f0000 0 0 0 0
B: REL=103
B: MSC=10

I: Bus=0003 Vendor=0c45 Product=2b02 Version=0110
N: Name="2.4G 2.4G Wireless Device"
P: Phys=usb-0000:00:1a.1-1/input3
S: Sysfs=/devices/pci0000:00/0000:00:1a.1/usb3/3-1/3-1:1.3/0003:0C45:2B02.0006/input/input28
U: Uniq=
H: Handlers=sysrq kbd event17
B: PROP=0
B: EV=12001f
B: KEY=3007f 0 0 4c3ffff17aff32d bf54444600000000 1 130f938b17c007 ffff7bfad951dfff febeffdfffefffff fffffffffffffffe
B: REL=40
B: ABS=100000000
B: MSC=10
B: LED=1f

Now, since mapping works perfectly with the keyboard device part of my
remote and another air mouse

http://forum.kodi.tv/showthread.php?tid=143571&pid=1499166#pid1499166

has been reported to work with a hwdb addition similar to mine

http://openelec.tv/forum/104-bluetooth-remotes/66542-help-configuring-keyboard-mapping-starting-3-1-6?start=15#90824

I'm inclined to believe that (currently) for mapping to work for a particular
device, "kbd" has to be listed as a handler for that device. Is this correct?
If so, what can be done about it?

If you need more logs I can provide them. If you need me to test something I
can do that too.

My systemd is version 215 with various Debian (unstable) patches. I suspect
that does not make much of a difference.
Comment 1 Lennart Poettering 2014-12-09 00:25:31 UTC
The Linux input layer distinguishes "keys", "buttons", "switches". You can map buttons to buttons, and key to keys, and switches to switches, but not keys to buttons. Sorry.

They have different semantics generally. Keys usually a pressed for a short time, and have typematic rates. Buttons are the kind that can be used for double clicks, and have no typematic rates. Switches are continously on or off. 

If you want to map between keys and buttons, then the kernel doesn't suport that. Sorry! Please bring this up with the kernel guys if you think this should be supported.
Comment 2 bugzilla 2014-12-11 14:38:30 UTC
Thank you for the explanation. I guess it makes sense that mapping across semantically different types of input devices is not something that is supported by the kernel. Fortunately, there are userspace solutions. :-)


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.