i got my hands on a nox krom khanda mouse. It's kinda nice, but i'm still trying it out. While playing quake 4 on linux ( debian jessie) , i noticed that one of the left side buttons isn't recognized, and the right side button kinda shoots only one shot.

After using xev to check out the mouse events, i found that the left mouse button that does not seem to work is mapped to button9, and the right side one, is basically button1 on repeat. while pressed, it keeps sending button press and release for button 1.

So, it's basically useless. Now, while on windows, this mouse brings a cd with a software to reprogram the buttons. It's lousy, ok, but i just wanted to take off that damn "auto-fire" from that button. It seemed to work, but as i reboot to linux, all is back again.

I tried running that software using wine, but it does not detect the mouse, and neither does virtualbox ( they both detect a generic mouse ). Is there some way to reprogram this in linux, or do i need another mouse? Thanks.

  • My first guess would be to use xmodmap, as dangerous as that can be.
    – Joe Sewell
    Mar 9, 2015 at 20:48
  • @JoeSewell That can reassign the left-side button to a button number other than 9, but it won't help with the peculiar behavior of the right-side button. Mar 9, 2015 at 23:18
  • Oops. Missed the "on repeat."
    – Joe Sewell
    Mar 10, 2015 at 11:48

1 Answer 1


first step is to find out what the physical buttons are. I will describe the process of remapping a generic gaming mouse, in my case a saitek RAT3, but the general steps will apply to any mouse.

  1. xinput list to find out the ID of your mouse, and it's name
  2. xinput query-state {id} to find out the state of all buttons. Use this opportunity to count your mouses buttons. To help this process, run watch -n0 xinput query-state {id} to keep querying.
  3. Identify any buttons with special behaviour.
  4. take note of which button has which button ID.
  5. add a file called 50-mousename to /usr/share/X11/xorg.conf.d/ and open it with your favorite editor. insert this template:

    Section "InputClass"
        Identifier     "Mouse Remap"
        MatchProduct   "{mouse name}"
        MatchDevicePath "/dev/input/event*"
        Option         "ZAxisMapping" "4 5"
        Option         "ButtonMapping" "1 2 3 4 5 6 7 8 9 0 0 0 0 0"
        Option         "Resolution" "3200" #you will probably have to change this!

    the important line is this one: Option "ButtonMapping" "1 2 3"... remember that list of buttons you made earlier? This option decides which physical buttons correspond to which button events.

    "1 2 3" would mean that "physical button 1" is "button event 1", "physical button 2" is "button event 2" and so on. If you wanted to, say, switch the scroll wheel and right mouse buttons, you would change it to "3 2 1". If that makes no sense, have a look at this table:

    | Physical Button | Button Event | normal action |
    |Left             |            1 |        select |
    |Middle           |            2 | paste/depends |
    |Right            |            3 |  context menu |
    |Scroll Up        |            4 |  context menu |
    |Scroll Down      |            5 |  context menu |
    |Custom           |           6+ |       depends |

    to deactivate a button, put 0 in its place, e.g. to deactivate the middle mouse button "1 0 3 4 5 6 7 8 9 ..."

You will have to log in and out for this to take effect.

Since I felt I made little sense, let me show you the process for me.

username@hostname ~> xinput list
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Saitek Cyborg R.A.T.3 Mouse               id=12   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Power Button                              id=8    [slave  keyboard (3)]
    ↳ Sleep Button                              id=9    [slave  keyboard (3)]
    ↳   USB Keyboard                            id=10   [slave  keyboard (3)]
    ↳   USB Keyboard                            id=11   [slave  keyboard (3)]

okay, so my device name is Saitek Cyborg R.A.T.3 Mouse with an ID of 12

notafile@notapc ~> xinput query-state 12
2 classes :
ValuatorClass Mode=Relative Proximity=In

So my mouse has a total of 18 buttons. Here is the mappings I discovered:

| Number | Button      |
| 1      | Left        |
| 2      | Middle      |
| 3      | Right       |
| 4      | scroll up   |
| 5      | scroll down |
| 8      | upper thumb |
| 9      | lower thumb |
| 10     | mode red    |
| 11     | mode blue   |
| 12     | mode purple |
| 13     | DPI up      |
| 14     | DPI down    |

with this mouse we have some buttons with special behavior. Buttons 10-12 are always pressed and not released until the mode button is pressed again. This can be fixed with the "AutoRelease" option which I won't go into now, unless this is a problem for you.

So our mapping should be pretty straight forward. Buttons 1-5 are normal, 8 and 9 are our custom buttons, and 6-7 and 10+ are buttons we don't really need. The resulting map is: "1 2 3 4 5 0 0 0 8 9 0 0 0 0 0 0 0 0 0". Be sure to pad the end with 0s so the amount of items is the same as the buttons, in this case 18.

I'm done! Now I just have to insert this into the config file at /usr/share/X11/xorg.conf.d/50-saitek-rat3, and log out and back in!

Here is my final config:

Section "InputClass"
    Identifier     "Mouse Remap"
    MatchProduct   "Saitek Cyborg R.A.T.3 Mouse"
    MatchDevicePath "/dev/input/event*"
    Option         "ZAxisMapping" "4 5"
    Option         "ButtonMapping" "1 2 3 4 5 0 0 0 8 9 0 0 0 0 0 0 0 0 0"
    Option         "Resolution" "3200"
  • That was pretty understandable. I've been using linux for some time now, don't worry. My problem, is that the right side button identifies itself as button1 too, but only on linux. On windows,i can use the software to change the light color on the mouse, and reassign that right button. all is ok. on linux, color ok, but the right button keeps identifying itself as button1, alternating pressed and released. I even thought of trying to capture the usb packets when using the software, so i could code something in linux to reprogram the freaking mouse. Mar 11, 2015 at 9:49
  • @RhiakathFlanders That's weird. I was assuming you had come to linux/bought a mouse and then realized it didn't work, so I guess my post was kind of useless for you. The mouse button alternating makes absolutely 0% sense, Assuming the programs don't get stored on the mouse itself. How fast does the button alternate, and are there any other buttons that do this? The only possible thing I could think of is that this is some kind of hacky attempt at multiplexing.
    – Azsgy
    Mar 11, 2015 at 20:57
  • 1
    I had the same issue(s) with the same mouse (RAT3) exhibiting odd behaviour on Debian Stretch. Following your instructions helped me to get it working/behaving as expected. Jun 12, 2021 at 11:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .