Score:0

How to reprogram mouse button

de flag

Running 20.04.2 LTS, using a Microsoft Comfort Optical Mouse 3000. The thumb button (left edge of mouse) functions as "forward" and I want to change it to "back". Any tips?

Pedro Maimere avatar
ax flag
Have you tried `xev` to identify the button and then remapping it?
Ancient avatar
de flag
Pedro: Not until you just mentioned it. I'm new to this. I used xev -event mouse and found that it's button 9. Now what?
Score:0
ax flag

First, identify your mouse's id through the command xinput. In this example, what we are looking for is the id=9:

$ xinput
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ PIXART USB OPTICAL MOUSE                  id=9    [slave  pointer  (2)]

Now, let's discover all the buttons available on your mouse and their order, using the command xinput --list <id>, substituting <id> for your mouse's id found earlier:

$ xinput --list 9
PIXART USB OPTICAL MOUSE                    id=9    [slave  pointer  (2)]
    Reporting 7 classes:
        Class originated from: 9. Type: XIButtonClass
        Buttons supported: 7
        Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right"

Now we know how many buttons are supported, and their order, given by "Button labels". In the example, "Button Left" is 1, "Button Middle" is 2, and so on.

I don't know the exact order of the buttons of your mouse, as you should discover it as described above. But suppose your "Back button"'s number is 6 and "Forward button"'s number is 7, and there are 11 buttons supported. Run this command, substituting <id> for your mouse's id:

xinput set-button-map <id> 1 2 3 4 5 7 6 8 9 10 11
Ancient avatar
de flag
Here's the output I got after running xinput as suggested. No button labels! Microsoft Microsoft Optical Mouse with Tilt Wheel Consumer Control id=16 [slave keyboard (3)] Reporting 1 classes: Class originated from: 16. Type: XIKeyClass Keycodes supported: 248
Pedro Maimere avatar
ax flag
@Ancient it seems the mouse also creates a slave keyboard, however you found out before with `xev` that it also returned a ButtonPress event, and not a KeyPress event, so, there must be a slave pointer linked to this mouse. Please run `xinput list --long | awk '/master keyboard/{exit}1'` and edit your question with the output. This will allow us to check all your pointers.
Ancient avatar
de flag
I tried to paste the entire output, but this system is saying it's too long by 5686 characters. Is there another way to share it here?
Pedro Maimere avatar
ax flag
@Ancient You may use [Pastebin](http://pastebin.com) or [Paste Ubuntu](http://paste.ubuntu.com).
Ancient avatar
de flag
Thanks. I'm away from the computer for a day or two. To be continued!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.