I recently got a Logitech M500:
Bus 002 Device 004: ID 046d:c069 Logitech, Inc. M500 Laser Mouse
It has nine buttons that I can identify:
- Two on the left side
- Left, right
- Wheel press
- Wheel scroll up, wheel scroll down
- Wheel press left, wheel press right
The last two are driving me insane. Every time I try to click the wheel, I accidently hit the "wheel press left" button and Firefox goes to the last visited page. It is very annoying.
Easy enough, right? Just find out which buttons xev shows and disable them. Wrong! xev does not generate "ButtonPress/ButtonRelease" events, but strange "LeaveNotify/EnterNotify/KeymapNotify" pairs:
LeaveNotify event, serial 40, synthetic NO, window 0x4a00001, root 0x94, subw 0x0, time 2344319, (104,86), root:(113,207), mode NotifyGrab, detail NotifyAncestor, same_screen YES, focus YES, state 0 EnterNotify event, serial 40, synthetic NO, window 0x4a00001, root 0x94, subw 0x0, time 2344319, (104,86), root:(113,207), mode NotifyUngrab, detail NotifyAncestor, same_screen YES, focus YES, state 0 KeymapNotify event, serial 40, synthetic NO, window 0x0, keys: 4294967188 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
Now surely, the 4294967188 (-108 in twos complement as 32 bit integer if that helps) will be the keycode, right? Wrong again! It's the same number for both the horizontal wheel left/right and the side back/front buttons.
Here's my xinput list of the device:
Logitech USB Laser Mouse id=15 [slave pointer (2)] Reporting 7 classes: Class originated from: 15. Type: XIButtonClass Buttons supported: 16 Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right" "Button Side" "Button Extra" "Button Forward" "Button Back" "Button Task" "Button Unknown" "Button Unknown" "Button Unknown" "Button Unknown" Button state: Class originated from: 15. Type: XIValuatorClass Detail for Valuator 0: Label: Rel X Range: -1.000000 - -1.000000 Resolution: 1 units/m Mode: relative Class originated from: 15. Type: XIValuatorClass Detail for Valuator 1: Label: Rel Y Range: -1.000000 - -1.000000 Resolution: 1 units/m Mode: relative Class originated from: 15. Type: XIValuatorClass Detail for Valuator 2: Label: Rel Horiz Wheel Range: -1.000000 - -1.000000 Resolution: 1 units/m Mode: relative Class originated from: 15. Type: XIValuatorClass Detail for Valuator 3: Label: Rel Vert Wheel Range: -1.000000 - -1.000000 Resolution: 1 units/m Mode: relative Class originated from: 15. Type: XIScrollClass Scroll info for Valuator 2 type: 2 (horizontal) increment: 1.000000 flags: 0x0 Class originated from: 15. Type: XIScrollClass Scroll info for Valuator 3 type: 1 (vertical) increment: -1.000000 flags: 0x2 ( preferred )
It appears to map the buttons just as they normally would be. So what happens when I write a small script that calls "xinput query-state $DEVNO" in a loop and press the horrible buttons? You guessed it:
2 classes : ButtonClass button[1]=up button[2]=up button[3]=up button[4]=up button[5]=up button[6]=up button[7]=up button[8]=up button[9]=up button[10]=up button[11]=up button[12]=up button[13]=up button[14]=up button[15]=up button[16]=up ValuatorClass Mode=Relative Proximity=In valuator[0]=538 valuator[1]=456 valuator[2]=-2 valuator[3]=-464
They always show up as "up" although they're clearly "down". Mouse buttons that do generate proper ButtonPress events (left/right for example) do show up ad "down" like they should.