Bug 20122

Summary: evdev, xmodmap mouse button map applied twice?
Product: xorg Reporter: Pekka Paalanen <ppaalanen>
Component: Input/evdevAssignee: Peter Hutterer <peter.hutterer>
Status: CLOSED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium Keywords: patch
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
0001-dix-don-t-apply-button-mappings-to-SDs-or-the-devi.patch none

Description Pekka Paalanen 2009-02-15 03:55:04 UTC
I'm not sure if this is an xorg-server, evdev or xmodmap bug.

I have Logitech MX510, with one wheel, two thumb buttons and three extra buttons. I want to map the event 2 (e.g. paste) from one of the extra buttons, since pressing the wheel is inconvinient. With identity mapping, the extra button sends event 11, and the wheel sends event 2.

This is what I had working before:
xmodmap -e 'pointer = 1 11 3 4 5 9 8 6 7 10 2 12'
which means that the extra button sent event 2, and wheel press sent event 11.

After updating xorg-server and evdev, the extra button now sends event 11 and wheel press sends event 2. So I try:
xmodmap -e 'pointer = 1 2 3 4 5 9 8 6 7 10 11 12'

No change! Still events 2 and 11 are the wrong way around.

Then I try something funny:
xmodmap -e 'pointer = 2 11  3  4  5  9  8  6  7 10  1 12'

Now wheel press sends event 1, the extra button sends event 2, and the left mouse button sends event 11.

Hmm, it is almost as if the mapping is applied twice. That makes configuring the buttons a tiny bit more... interesting.

xf86-input-evdev is from git master as of Feb 10, 2009.
xorg-server is from git master as of Feb 11, 2009.
xmodmap is version 1.0.3.
All built and installed in Gentoo using ebuilds.

HAL is used to configure input devices, xorg.conf has nothing about input. I have no personal settings in HAL for the mouse.
Comment 1 Peter Hutterer 2009-02-19 17:49:48 UTC
git master has double button mapping. One applies to the virtual core pointer
(i.e. the cursor) and one applies to specific devices. The button mappings are
chained, so you can have  the mapping on a device and have a different mapping
on the VCP and the final is the combination of both mappings.

I think that's what's hitting you, though I got a bit confused with the
definitions of "wrong way round" in your report.

try xinput --set-button-map "device name" 1 11 3 4 5 etc.
(device name as listed by "xinput --list --short"). Does that work?
Comment 2 Pekka Paalanen 2009-02-20 12:30:50 UTC
"Wrong way around" just means that I want the buttons 2 and 11 swapped, when they are not.

Um, this is what happens, and it doesn't look right to me.

First I have my old settings in my Xorg session's Xmodmap:
pointer = 1 11  3  4  5  9  8  6  7 10  2 12

Then I run these commands:

$ xinput --list --short
"Virtual core pointer"  id=0    [XPointer]
"Virtual core keyboard" id=1    [XKeyboard]
"AT Translated Set 2 keyboard"  id=2    [XExtensionKeyboard]
"Logitech USB-PS/2 Optical Mouse"       id=3    [XExtensionPointer]
$ xinput get-button-map "Virtual core pointer"
1 11 3 4 5 9 8 6 7 10 2 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 
$ xinput get-button-map "Logitech USB-PS/2 Optical Mouse"
1 11 3 4 5 9 8 6 7 10 2 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 
$ xinput set-button-map "Virtual core pointer" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
$ xinput get-button-map "Logitech USB-PS/2 Optical Mouse"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 
$ xinput get-button-map "Virtual core pointer"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 

Setting the button map seems to set both maps at the same time.
Should I update xorg-server or xf86-input-evdev from git/master just to be sure?
Comment 3 Peter Hutterer 2009-02-20 14:14:11 UTC
Created attachment 23143 [details] [review]
0001-dix-don-t-apply-button-mappings-to-SDs-or-the-devi.patch

Yeah, you're right - this is wrong. This behaviour got
changed in bc909f71367a02297e725bb5769c2bcadab22395, and IMO I don't think
it's the right thing to do, we should only change the device we're interested in.

Please try this (untested) patch on your xserver, it should revert to the old behaviour.
Comment 4 Pekka Paalanen 2009-02-21 04:36:47 UTC
(In reply to comment #3)
> Created an attachment (id=23143) [details]
> 0001-dix-don-t-apply-button-mappings-to-SDs-or-the-devi.patch

That patch indeed fixes it. Now everything works as I would expect: xmodmap changes the virtual core pointer button mapping, and I can use xinput to change the mapping on the specific device.

As a bonus, now I know how I can change the mapping on *this* mouse instead of all mice :-) But one question here remains: is it possible to configure this automatically, if I plug this mouse in in the middle of my X session?
I could put the button mapping in HAL config, so it would (I guess) be applied on device discovery, but this is a global setting, not per user. Right?
It is my personal preference on this particular mouse to swap those buttons. Can that configuration be automated? (Just thinking out loud here.)

Thanks. When I see this patch hit xorg-server git, I'll retest and mark as fixed.
Comment 5 Peter Hutterer 2009-02-23 00:57:14 UTC
Patch pushed as a50c40be1f28467bcef7dc71fab54ebdddacffdf.
Comment 6 Julien Cristau 2009-02-23 06:38:30 UTC
> --- Comment #4 from Pekka Paalanen <pq@iki.fi>  2009-02-21 04:36:47 PST ---
> But one question here remains: is it possible to configure this
> automatically, if I plug this mouse in in the middle of my X session?
> I could put the button mapping in HAL config, so it would (I guess) be applied
> on device discovery, but this is a global setting, not per user. Right?
> It is my personal preference on this particular mouse to swap those buttons.
> Can that configuration be automated? (Just thinking out loud here.)

I guess the desktop environment could provide an ui for this, listen to
notifications for when new devices appear, and apply the user's
settings.
Comment 7 Pekka Paalanen 2009-02-25 12:50:25 UTC
Re-tested on xorg-server master branch, is fixed. Closing.

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.