[keymap] hwdb keymaps don't support numeric keycodes

Bug #1247584 reported by Filiprino
32
This bug affects 5 people
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Fix Released
Undecided
Martin Pitt

Bug Description

On Ubuntu 13.04 I had the middle mouse button of my Logitech T400 mapped correctly, but after upgrading to 13.10 the /lib/udev/kemap utility has disappeared and now I can no longer assign the middle button to the middle button function. This mouse has assigned by default the middle button to the left_meta keyboard key (super key). That's very annoying because I can't do middle clicking with this mouse. This mouse has two middle buttons, in the trackpad that serves as middle wheel, but the button that currently serves as middle click it's in a very uncomfortable position, and the button with the left_meta functionality is the one I'd like to use as middle button.

I tried modifying the file at /lib/udev/hwdb.d/60-keyboard.hwdb with this rule:

keyboard:usb:v046DpC52B*
 KEYBOARD_KEY_700E3=middle

and also with

keyboard:usb:v046DpC52B*
 KEYBOARD_KEY_700E3=274

evtest returns the following results and codes:

BUTTON I WANT TO ASSIGN:
Event: time 1383485540.705610, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e3
Event: time 1383485540.705610, type 1 (EV_KEY), code 125 (KEY_LEFTMETA), value 1
Event: time 1383485540.705610, -------------- SYN_REPORT ------------
Event: time 1383485540.809618, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e3
Event: time 1383485540.809618, type 1 (EV_KEY), code 125 (KEY_LEFTMETA), value 0
Event: time 1383485540.809618, -------------- SYN_REPORT ------------

THE BUTTON IN UNCOMFORTABLE POSITION
Event: time 1383485765.956075, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1383485765.956075, type 1 (EV_KEY), code 274 (BTN_MIDDLE), value 1
Event: time 1383485765.956075, -------------- SYN_REPORT ------------
Event: time 1383485766.173978, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1383485766.173978, type 1 (EV_KEY), code 274 (BTN_MIDDLE), value 0
Event: time 1383485766.173978, -------------- SYN_REPORT ------------

So, I would like to assign the BTN_MIDDLE function to the 700e3 scancode, but it does not work. With the previous utility included in Ubuntu I could do this, but now with this SystemD way I can't do the assignment.

I have not rebooted, but I did rebuild the hwdb database with the "udevadm hwdb --update", and replugged the mouse.

ProblemType: Bug
DistroRelease: Ubuntu 13.10
Package: udev 204-0ubuntu19 [modified: lib/udev/hwdb.d/60-keyboard.hwdb]
ProcVersionSignature: Ubuntu 3.11.0-12.19-generic 3.11.3
Uname: Linux 3.11.0-12-generic x86_64
ApportVersion: 2.12.5-0ubuntu2.1
Architecture: amd64
CustomUdevRuleFiles: 60-android-devices.rules
Date: Sun Nov 3 14:23:16 2013
InstallationDate: Installed on 2011-12-24 (680 days ago)
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111011)
MachineType: ASUSTeK Computer Inc. N53SN
MarkForUpload: True
ProcKernelCmdLine: BOOT_IMAGE=/vmlinuz-3.11.0-12-generic root=/dev/mapper/ubunturoot-raiz ro quiet splash audit=1
SourcePackage: systemd
UpgradeStatus: Upgraded to saucy on 2013-10-28 (5 days ago)
dmi.bios.date: 01/10/2012
dmi.bios.vendor: American Megatrends Inc.
dmi.bios.version: N53SN.209
dmi.board.asset.tag: ATN12345678901234567
dmi.board.name: N53SN
dmi.board.vendor: ASUSTeK Computer Inc.
dmi.board.version: 1.0
dmi.chassis.asset.tag: No Asset Tag
dmi.chassis.type: 10
dmi.chassis.vendor: ASUSTeK Computer Inc.
dmi.chassis.version: 1.0
dmi.modalias: dmi:bvnAmericanMegatrendsInc.:bvrN53SN.209:bd01/10/2012:svnASUSTeKComputerInc.:pnN53SN:pvr1.0:rvnASUSTeKComputerInc.:rnN53SN:rvr1.0:cvnASUSTeKComputerInc.:ct10:cvr1.0:
dmi.product.name: N53SN
dmi.product.version: 1.0
dmi.sys.vendor: ASUSTeK Computer Inc.

Revision history for this message
Filiprino (filiprino) wrote :
affects: systemd (Ubuntu) → udev (Ubuntu)
Martin Pitt (pitti)
summary: - Since upgrade to Ubuntu 13.10, udev doesn't map middle mouse button.
+ [keymap] Since upgrade to Ubuntu 13.10, udev doesn't map middle mouse
+ button.
affects: udev (Ubuntu) → systemd (Ubuntu)
Revision history for this message
Martin Pitt (pitti) wrote : Re: [keymap] Since upgrade to Ubuntu 13.10, udev doesn't map middle mouse button.

Your UdevDb.txt shows that you did the hwdb mangling successfully, i. e. your input/event12 has "E: KEYBOARD_KEY_700E3=middle". However, "middle" will definitively not work, as udev only knows about "KEY_*" constants, not "BTN_* constants" (admittedly this is the first time I head that someone remaps buttons).

I assume in Ubuntu 13.04 and earlier you had an udev rule which assigned the key code (274) directly, not the key name? Please confirm this.

So I suppose what broke is that you are not able to directly specify a key code any more, only a name?

Revision history for this message
Martin Pitt (pitti) wrote :

It might be best if you could just copy&paste the old udev rule which called "keymap"? The code there wasn't really different, so I wonder how using a key code worked back then.

Changed in systemd (Ubuntu):
status: New → Incomplete
Revision history for this message
Filiprino (filiprino) wrote : Re: [Bug 1247584] Re: [keymap] Since upgrade to Ubuntu 13.10, udev doesn't map middle mouse button.
Download full text (5.4 KiB)

Ok, first of all, the keymap which I had stored in /lib/udev/keymaps in a
file named logitech-t400 is like follows:

0x700E3 0x112

And here is my old udev rule which used the keymap program:

ACTION=="remove", GOTO="mouse_end"
KERNEL!="event*", GOTO="mouse_end"
ENV{ID_INPUT_KEY}=="", GOTO="mouse_end"
SUBSYSTEMS=="bluetooth", GOTO="mouse_end"

SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"
SUBSYSTEMS=="usb", GOTO="mouse_usbcheck"

LABEL="mouse_usbcheck"

SUBSYSTEM=="input", ENV{ID_VENDOR}=="Logitech*", ATTRS{name}=="Logitech
Unifying Device*", RUN+="keymap $name logitech-t400"

LABEL="mouse_end"

LABEL="mouse_modulecheck"

2013/11/4 Martin Pitt <email address hidden>

> It might be best if you could just copy&paste the old udev rule which
> called "keymap"? The code there wasn't really different, so I wonder how
> using a key code worked back then.
>
> ** Changed in: systemd (Ubuntu)
> Status: New => Incomplete
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1247584
>
> Title:
> [keymap] Since upgrade to Ubuntu 13.10, udev doesn't map middle mouse
> button.
>
> Status in “systemd” package in Ubuntu:
> Incomplete
>
> Bug description:
> On Ubuntu 13.04 I had the middle mouse button of my Logitech T400
> mapped correctly, but after upgrading to 13.10 the /lib/udev/kemap
> utility has disappeared and now I can no longer assign the middle
> button to the middle button function. This mouse has assigned by
> default the middle button to the left_meta keyboard key (super key).
> That's very annoying because I can't do middle clicking with this
> mouse. This mouse has two middle buttons, in the trackpad that serves
> as middle wheel, but the button that currently serves as middle click
> it's in a very uncomfortable position, and the button with the
> left_meta functionality is the one I'd like to use as middle button.
>
> I tried modifying the file at /lib/udev/hwdb.d/60-keyboard.hwdb with
> this rule:
>
> keyboard:usb:v046DpC52B*
> KEYBOARD_KEY_700E3=middle
>
> and also with
>
> keyboard:usb:v046DpC52B*
> KEYBOARD_KEY_700E3=274
>
> evtest returns the following results and codes:
>
> BUTTON I WANT TO ASSIGN:
> Event: time 1383485540.705610, type 4 (EV_MSC), code 4 (MSC_SCAN), value
> 700e3
> Event: time 1383485540.705610, type 1 (EV_KEY), code 125 (KEY_LEFTMETA),
> value 1
> Event: time 1383485540.705610, -------------- SYN_REPORT ------------
> Event: time 1383485540.809618, type 4 (EV_MSC), code 4 (MSC_SCAN), value
> 700e3
> Event: time 1383485540.809618, type 1 (EV_KEY), code 125 (KEY_LEFTMETA),
> value 0
> Event: time 1383485540.809618, -------------- SYN_REPORT ------------
>
> THE BUTTON IN UNCOMFORTABLE POSITION
> Event: time 1383485765.956075, type 4 (EV_MSC), code 4 (MSC_SCAN), value
> 90003
> Event: time 1383485765.956075, type 1 (EV_KEY), code 274 (BTN_MIDDLE),
> value 1
> Event: time 1383485765.956075, -------------- SYN_REPORT ------------
> Event: time 1383485766.173978, type 4 (EV_MSC), code 4 (MSC_SCAN), value
> 90003
> Event: time 1383485766.173978, type 1 (EV_KEY), code 274 (BTN...

Read more...

Revision history for this message
Dmitry Pashkevich (dipish) wrote : Re: [keymap] Since upgrade to Ubuntu 13.10, udev doesn't map middle mouse button.

I'm not sure if this is the same issue, but my middle click also stopped working after 13.10 upgrade.
I'm using Lenovo X1 Carbon and it has a hardware middle mouse button. Here's the xev output when I press that button:

KeymapNotify event, serial 37, synthetic NO, window 0x0,
    keys: 4294967198 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
           0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

ButtonPress event, serial 37, synthetic NO, window 0x5c00001,
    root 0x9e, subw 0x0, time 4160630, (19,6), root:(127,1108),
    state 0x0, button 2, same_screen YES

ButtonRelease event, serial 37, synthetic NO, window 0x5c00001,
    root 0x9e, subw 0x0, time 4160630, (19,6), root:(127,1108),
    state 0x200, button 2, same_screen YES

So it gets recognized as "button 2" but for some reason the middle click action never happens.
However if I connect a USB mouse with a scroll wheel, the middle click action works. Here's xev output for USB mouse middle click:

KeymapNotify event, serial 37, synthetic NO, window 0x0,
    keys: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
           0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

ButtonPress event, serial 37, synthetic NO, window 0x5c00001,
    root 0x9e, subw 0x0, time 4248704, (146,11), root:(254,1113),
    state 0x0, button 2, same_screen YES

ButtonRelease event, serial 37, synthetic NO, window 0x5c00001,
    root 0x9e, subw 0x0, time 4248959, (146,11), root:(254,1113),
    state 0x200, button 2, same_screen YES

The only difference that I see is the weird value in the KeymapNotify event but it doesn't make any sense to me. Somebody please help, I'm so used to my middle button!

Revision history for this message
Dmitry Pashkevich (dipish) wrote :

Ok this is weird, but now that I have posted this comment and checked again it works. It may be a specific program blocking intercepting the key. I'll write back if the issue persists for me.

Revision history for this message
Martin Pitt (pitti) wrote :

> Ok, first of all, the keymap which I had stored in /lib/udev/keymaps in a file named logitech-t400 is like follows:
> 0x700E3 0x112

Right. So what happens if you do the same in the hwdb file, i. e.

keyboard:usb:v046DpC52B*
 KEYBOARD_KEY_700E3=274

Do you see the numeric value in "udevadm info --export-db" then?

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for systemd (Ubuntu) because there has been no activity for 60 days.]

Changed in systemd (Ubuntu):
status: Incomplete → Expired
Shock (mmiron)
Changed in systemd (Ubuntu):
status: Expired → Confirmed
Revision history for this message
Shock (mmiron) wrote :

I have the exact same issue while running 14.04 with the Logitech Zone Touch T400 mouse.

I can remap the button using udev to another key but udev won't remap to the middle button.

$ sudo udevadm --debug test-builtin keyboard /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.2/0003:046D:C52B.0030/input/input41/event6
calling: test-builtin
=== trie on-disk ===
tool version: 204
file size: 5771951 bytes
header size 80 bytes
strings 1271231 bytes
nodes 4500640 bytes
load module index
device 0xa8b860 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.2/0003:046D:C52B.0030/input/input41/event6'
device 0xa8b860 filled with db file data
Error, unknown key identifier 'middle'
keyboard: mapping scan code 786616 (0xc00b8) to key code 161 (0xa1)
keyboard: mapping scan code 786819 (0xc0183) to key code 226 (0xe2)
keyboard: mapping scan code 786820 (0xc0184) to key code 421 (0x1a5)
keyboard: mapping scan code 786822 (0xc0186) to key code 423 (0x1a7)
keyboard: mapping scan code 786826 (0xc018a) to key code 155 (0x9b)
keyboard: mapping scan code 786830 (0xc018e) to key code 397 (0x18d)
keyboard: mapping scan code 786870 (0xc01b6) to key code 212 (0xd4)
keyboard: mapping scan code 786876 (0xc01bc) to key code 430 (0x1ae)
keyboard: mapping scan code 786977 (0xc0221) to key code 217 (0xd9)
keyboard: mapping scan code 786979 (0xc0223) to key code 172 (0xac)
keyboard: mapping scan code 786989 (0xc022d) to key code 418 (0x1a2)
keyboard: mapping scan code 786990 (0xc022e) to key code 419 (0x1a3)

Notice the line "Error, unknown key identifier 'middle'", I get the same error no matter if I use "middle", "274" or "0x112" (as suggested above by Martin)

This is a regression from the older udev (which used keymaps), which allowed specifying numeric values for the mappings.

I posted here in order not to lose context but I see that the last activity in the bug is from 2013 so if I should open a new bug let me know.

Thanks!

Revision history for this message
Shock (mmiron) wrote :

I've written a small patch to allow specifying key codes as numeric values (decimal, octal and hex). I'm attachind the debdiff.

Revision history for this message
Martin Pitt (pitti) wrote :

Unsubscribing sponsors, I'd like to handle this via upstream and the Debian packaging git.

Changed in systemd (Ubuntu):
assignee: nobody → Martin Pitt (pitti)
status: Confirmed → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

I fixed this upstream in http://cgit.freedesktop.org/systemd/systemd/commit/?id=7925709c9, loosely based on Mircea's patch. Thanks!

Changed in systemd (Ubuntu):
status: In Progress → Fix Committed
summary: - [keymap] Since upgrade to Ubuntu 13.10, udev doesn't map middle mouse
- button.
+ [keymap] hwdb keymaps don't support numeric keycodes
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package systemd - 208-8ubuntu2

---------------
systemd (208-8ubuntu2) utopic; urgency=medium

  [ Ben Howard ]
  * 75-persistent-net-generator.rules: Fix matches of HyperV. (LP: #1361272)

  [ Martin Pitt ]
  * Add new autopkgtest boot_and_services which reboots the testbed with
    systemd as init and verifies that the most critical services like lightdm,
    D-BUS, NetworkManager, and cron work. (To be extended in the future)
  * Fix udev path in udev(7). (LP: #1357782)
  * path_id: suppress ID_PATH for devices with an unknown parent device type.
    (LP: #1321816)
  * udev-builtin-keyboard: Allow numeric key codes. (LP: #1247584)
 -- Martin Pitt <email address hidden> Mon, 08 Sep 2014 14:44:35 +0200

Changed in systemd (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.