2

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.

  • 1
    Please don't vote down, it seems a good question. – peterh Feb 24 '15 at 19:34
5

I have a Logitech M325, which also uses button 8 and 9 for left and right tilting of the scroll wheel. I use this script to disable them:

#!/bin/bash

set -eu

MOUSE_ID=$(xinput --list | grep Logitech | sed -r 's/.*id=([0-9]+).*/\1/')

if [ -n "$MOUSE_ID" ]; then
    xinput set-button-map $MOUSE_ID 1 2 3 4 5 6 7 0 0
fi
  • Thanks, exactly what I was looking for. I just had to adjust the last line as for my mouse the critical buttons are 6 and 7. Sad that they don't build their mouses better so that we have to disable a theoretically nice feature... – luator Jan 30 '17 at 13:03
  • I tried the same for Logitech MX Master 2S. The button in question is 6, but setting it to zero has no effect. I tried setting basically everything to 0, but it only seems to have an effect for left and right click, I can't disable either scroll wheel this way. Any ideas why? – Andreas Mueller Sep 27 '18 at 19:48
  • Btw @Carsten Calsohom your solution is a bit dangerous as there might be multiple logitech devices. The MX Master registers two. Running your script on my machine disabled the left click (because it was assigned 10, the second id matching Logitech). – Andreas Mueller Sep 27 '18 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.