Taming the Cyborg R.A.T. 7 mouse under Linux

Finally it is here! My new and shiny gaming mouse is everything I ever hoped for…except if I try using it under Linux. Somehow it gets “stuck” in the first window, and I can’t use it without restarting X. At the moment of writing this post, there is still no official patch, even though the mouse has been out for more than half an year.

Anyway, to get it to play nice under Linux, all you have to do is to add this section to you xorg.conf file. You can do it by typing this in a terminal: sudo gedit /etc/X11/xorg.conf, and then pasting the following block of text at the bottom of the file.

Section "InputClass"
        Identifier "Mouse Remap"
        MatchProduct "Saitek Cyborg R.A.T.7 Mouse"
        MatchDevicePath "/dev/input/event*"
        Option "ButtonMapping" "1 2 3 4 5 6 7 2 9 10 11 12 0 0 0"
EndSection

Until an official patch is released, this hack should get your Cyborg RAT 7 to work under Linux.

Andrei

35 comments

  1. So, I had the same problems for my Mad Catz R.A.T.5, and after cross-referencing the results from xinput and xev, the following works for me on Ubuntu 13.10 (/etc/X11/xorg.conf.d/20-rat5.conf):


    Section "InputClass"
    Identifier "Mad Catz R.A.T. 5"
    MatchProduct "Mad Catz Mad Catz R.A.T.5 Mouse"
    MatchDevicePath "/dev/input/event*"
    Option "Buttons" "21"
    Option "ButtonMapping" "1 2 3 4 5 0 0 11 10 7 6 8 0 0 0 0 0 0 0 0 0"
    Option "ZAxisMapping" "4 5 11 10"
    Option "AutoReleaseButtons" "13 14 15"
    EndSection

    I logged in and out again to restart X. Stupid freezing of focus to one window only is no longer an issue, and horizontal scroll is working!
    The following is the mapping of the buttons:
    1. Left click
    2. Middle click
    3. Right click
    4. Mouse wheel up
    5. Mouse wheel down
    8. Back
    9. Forward
    10. Horizontal wheel right
    11. Horizontal wheel left
    12. Precision aim

    Good luck.

    If you are having problems, look at the output of sudo xinput -list, find the id of the mouse (this can change when you restart X), then run sudo xinput watch-props 11 (replace the number with the id of the mouse). Under “Button Labels” you will see the different buttons. Count them, and write them down in numbered order.

    Then run xev. A little window will appear. Click in the square with the different buttons (careful not to move the mouse), and in the console you will see the button number that was clicked. Probably there will be buttons numbers missing.

    The button numbers from xinput and xev do not necessarily match up. Write the xev button numbers and which buttons you clicked in another list.

    Then make the button mapping string by using the numbered order from xev, including buttons that don’t exist as 0. E.g. I had:
    1. left
    2. middle
    3. right
    4. wheel up
    5. wheel left
    6.
    7.
    8. back
    9. forward
    10. wheel right
    11. wheel left
    12. side button

    This initially gives me:
    1 2 3 4 5 0 0 8 9 10 11 12 0 0 0 0 0 0 0 0 0

    Now I change the numbers for the buttons with the numbers of the buttons I got from xinput. E.g. I had:
    1. left
    2. middle
    3. right
    4. wheel up
    5. wheel down
    6. wheel left
    7. wheel right
    8. side button
    9. extra button
    10. forward
    11. back
    12. task button
    13. unknown
    14. unknown
    15. unknown
    16. unknown
    17. unknown
    18. unknown
    19. unknown
    20. unknown
    21. unknown

    This gives me:
    1 2 3 4 5 0 0 11 10 7 6 8 0 0 0 0 0 0 0 0 0

    Restart X by loggin in and out and it should work, although I must say I don’t know exactly why or how it does.

  2. For all the people who have a RAT 5 or 9 or something else and this doesn’t work, you need to change the MatchProduct line to suit your mouse. Find the name of your mouse in this list:

    cat /proc/bus/input/devices | grep Name=

    For example, mine was not listed as a Saitek, but as a Mad Catz.
    Finally, for everyone who wants to get horizontal scrolling working – the default in most apps for horizontal scroll seems to be buttons 6 and 7 for left and right, so you want to assign the horizontal wheel those buttons and set the mapping as follows:

    Section “InputClass”
    Identifier “R.A.T.7 Mouse Remap”
    MatchProduct “R.A.T.7 Mouse”
    MatchDevicePath “/dev/input/event*”
    Option “ButtonMapping” “1 2 3 4 5 0 0 8 9 7 6 12 0 0 0 16 17″
    Option “ZAxisMapping” “4 5 6 7″
    Option “AutoReleaseButtons” “13 14 15″
    EndSection

    This gives me horizontal scroll in firefox and libreoffice out of the box (haven’t tested anything else).

  3. For RAT 7 this worked for me, and horizontal scroll does it’s job too.
    Put it into /etc/X11/xorg.conf.d/rat-7.conf (create the dir if not there)

    Section “InputClass”
    Identifier “Mouse Remap”
    MatchProduct “Saitek Cyborg R.A.T.7 Mouse”
    MatchDevicePath “/dev/input/event*”
    Option “ButtonMapping” “1 2 3 4 5 0 0 9 8 7 6 0 0 0 0″
    EndSection

  4. This psudo worked for me. xorg.config did not exist for me and attempting to generate the file as mentioned above did not properly work. That being said, I managed to get it to work using the following method:

    mk /etc/X11/xorg.conf.d/
    cd /etc/X11/xorg.conf.d
    sudo gedit 910-rat.conf

    now put the following lines in the new file:

    Section “InputClass”
    Identifier “R.A.T.”
    MatchProduct “R.A.T.7|R.A.T.9″
    MatchDevicePath “/dev/input/event*”
    Option “Buttons” “17”
    Option “ButtonMapping” “1 2 3 4 5 0 0 8 9 7 6 12 0 0 0 16 17″
    Option “AutoReleaseButtons” “13 14 15″
    Option “ZAxisMapping” “4 5 6 7″
    EndSection

    now save the file and restart the computer. My mouse has been working for 5 hours without a problem and the z-axis scroll wheel works fine.

    My OS is Linux Mint 14 64-bit with the Cinnamon interface.

    If you want to take the -config route to generate a file, you need to kill the window manager like mentioned above. In Mint 14 this is accomplished by:

    CTRL-ALT-
    Login
    service mdm stop

    now follow the above instructions mentioned by Andrei to generate the file (mine failed, but it may work for you).

    Here is a list of the sources I used to get my procedures:
    http://community.linuxmint.com/tutorial/view/813
    http://forum.xbmc.org/showthread.php?tid=56006
    http://askubuntu.com/questions/4662/where-is-the-x-org-config-file-how-do-i-configure-x-there
    And the article on this page.

    Thanks for the tutorial! You pushed me in the right direction, without this guide I probably would have never gotten my mouse to work!.

  5. I was trying this on my Rat 9 on Fedora 18 and couldn’t figure out why it worked in Fedora 16 but not 18. I found that I just had the name incorrect which was causing random chaos. Also with the Authors button mapping my back button became the middle mouse click. I tried modifying the button mapping in order 1 through 12 followed by the three zeros but strangely after restarting x (log out / in) the 8th placement automatically changed to “88888888”. I’m not entirely sure why that happened.. but its working now so I’m going to go with the “If its not broke, don’t fix it” attitude.

    Also while digging around in the web for a fix I stumbled across this web page that offers a program that will bind mouse buttons to commands such as volume control, launching programs, whatever. I haven’t tried it yet but it looks interesting. http://www.nongnu.org/xbindkeys/xbindkeys.html

    # Find the proper name
    egrep “Name|Handlers” /proc/bus/input/devices

    # Create xorg.conf or modify as root (file did not exists in a new Fedora 18 install), paste in the original authors fix
    # NB I use vi from a shell (konsole or terminal), for those new to it here is some info. Log in as root by typing su if needed. Use arrows to place cursor on the desired line, press capital D to delete text, highlight text from this web page, hit lower case i in your shell to go into insert mode, center click to paste the highlighted section, hit escape to go back into command mode so you can save, use :wq! to save. If you screw it up just use :q! to exit without saving and try again.

    su
    vi /etc/X11/xorg.conf

    # Modify the Match Product line
    MatchProduct “Mad Catz Mad Catz R.A.T.9 Wireless Mouse”

    # Modify the ButtonMapping line
    Option “ButtonMapping” “1 2 3 4 5 6 7 8 9 10 11 12 0 0 0″

    # log out / in to restart x and check the xorg.conf file
    cat /etc/X11/xorg.conf

    # Notice that it looks odd, test, fix, care or not depending on how curious or daring you are
    Option “ButtonMapping” “1 2 3 4 5 6 7 88888888 9 10 11 12 0 0 0″

  6. Heh, what a coincidence that the solution to my mouse problems under Fedora is supplied by someone I ran into on SWTOR. ;) Thanks for the solution Andrei.

  7. I ran into a few issues using my Cyborg RAT5. Same kind of issues described here: oddly getting stuck, things like that. So, I added a nice little 20-cyborgrat5.conf in /etx/X11/xorg.conf.d with the supplied settings, with the MatchProduct changed to “Saitek”, since I only have the one Saitek peripheral.

    It all worked, until I realised that the back mouse button was being detected as button 2 (scroll wheel click) with xev. After hours of digging around confused, I finally realised the problem. The ButtomMapping option in the solution on this site purposely remaps button 8 (back) to button 2. Figuring this was done because of some oddity with the way the RAT7’s buttons are mapped internally, I changed it back to 8, restarted X, and it works! No more getting stuck, and the back/forward buttons work as they should.

    I just hope this helps anyone else with a RAT5 running into similar problems.

    For reference, here’s my 20-cyborgrat5.conf:

    Section “InputClass”
    Identifier “Mouse Remap”
    MatchProduct “Saitek”
    MatchDevicePath “/dev/input/event*”
    Option “ButtonMapping” “1 2 3 4 5 6 7 8 9 10 11 12 0 0 0″
    # CHANGFE THE 8 AFTER 7 BACK INTO A 2 IF IT BREAKS.
    EndSection

  8. RAT9 in Debian Squeeze. This should work with horizontal scroll, but horizontal scroll doesn’t work because of Xorg. They list it as one of the common issues in the ZAxisMapping section.
    “horizontal movement may not always be detected by the current version of the XFree86 X servers, because there appears to be no accepted standard as to how the horizontal direction is encoded in mouse data.”

    Section “InputClass”
    Identifier “Saitek Cyborg R.A.T.9 Mouse”
    MatchIsPointer “on”
    MatchProduct “R.A.T.9|Saitek Cyborg R.A.T.9 Mouse”
    MatchVendor “Saitek|SAITEK”
    MatchDevicePath “/dev/input/event*”
    Option “Protocol” “auto”
    Option “Buttons” “17”
    Option “ButtonMapping” “1 2 3 4 5 6 7 8 9 10 11 12 0 0 0 16 17″
    Option “ZAxisMapping” “4 5 10 11″
    Option “AutoReleaseButtons” “13 14 15″
    EndSection

  9. Silly me, looks like “ZAxisMapping” is for scroll wheels and “XAxisMapping” and “YAxisMapping” are for touchpads. I’ll tinker with it a bit more and see if I can make horizontal scroll work.

  10. Hey guys. For those who are trying to use the RAT9, not the RAT7, I just wrote this for Debian Squeeze 6.0.4. It seems to work fine, but still no horizontal scrolling. I checked the button map with xev and 10 and 11 are the horizontal scroll ones; 10 is right, 11 is leg, so I’m stumped as to why it doesn’t work. The rest is fine though. Enjoy

    Section “InputClass”
    Identifier “Saitek Cyborg R.A.T.9 Mouse”
    MatchIsPointer “on”
    MatchProduct “R.A.T.9|Saitek Cyborg R.A.T.9 Mouse”
    MatchVendor “Saitek|SAITEK”
    MatchDevicePath “/dev/input/event*”
    Option “Protocol” “auto”
    Option “Buttons” “21”
    Option “ButtonMapping” “1 2 3 4 5 6 7 8 9 10 11 12 0 0 0 0 0 0 0 0 0″
    Option “ZAxisMapping” “4 5″
    Option “YAxisMapping” “10 11″
    Option “AutoReleaseButtons” “13 14 15″
    EndSection

  11. For debian squeeze and RAT7 Contagion:

    Section “InputDevice”
    Identifier “Saitek Cyborg R.A.T.7 Contagion”
    Driver “mouse”
    Option “Protocol” “auto”
    Option “Buttons” “17”
    Option “ButtonMapping” “1 2 3 4 5 6 7 8 9 10 11 12 0 0 0 16 17″
    Option “ZAxisMapping” “4 5 6 7″
    Option “YAxisMapping” “10 11″
    EndSection

    But horizontal scrolling still dont working.

  12. A couple updates to this saga.

    “AutoReleaseButtons” has been added to xorg’s input class. For a fix that will survive dist upgrades, do the following:

    sudo mkdir /etc/X11/xorg.conf.d/
    cd /etc/X11/xorg.conf.d/
    sudo nano 910-rat.conf

    # add the following to the file

    Section “InputClass”
    Identifier “R.A.T.”
    MatchProduct “R.A.T.7|R.A.T.9″
    MatchDevicePath “/dev/input/event*”
    Option “Buttons” “17”
    Option “ButtonMapping” “1 2 3 4 5 0 0 8 9 7 6 12 0 0 0 16 17″
    Option “AutoReleaseButtons” “13 14 15″
    Option “ZAxisMapping” “4 5 6 7″
    EndSection

    https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-evdev/+bug/615892

  13. Wow, Thank you. Just bought this mouse (mainly for comfort) and was surprised that it didn’t work smoothly out of the box with Ubuntu 11.10 today 11 Nov 2011. Your fix above, got it going for me though!

    Thank you very much!,
    Mike

  14. Hi,

    Let me see if I understand this correctly. First, you’re creating the xorg.conf file in your home dir. Then you add the InputClass section for the mouse in that file. Last, you try to copy the conf file into the appropriate dir in /etc. Is this correct?

    Why not follow the example I’ve provided and modify an existing xorg.conf file? For Debian/Ubuntu you could use: sudo dpkg-reconfigure xserver-xorg. In Fedora/Red Hat, you can try: Xorg -configure :1. For other Linux distros there should be a similar command (google your distro name and xorg configuration).

    Any way, I’d love to help but I need more information. Maybe you could describe what you’re doing step by step? Also, what distribution do you use (Debian/Ubuntu/Fedora/Gentoo…)?

  15. > sudo cp ~/xorg.conf.new /etc/X11/xorg.conf

    fails for me, it says the file doesn’t exist. I’ve been trying to get this working for a week. but i’m far from a linux pro so i’ve just been stumbling blindly. Any suggestions?

  16. Thanks man – I was about to whip out the ps2 roller mouse, lol.
    Works perfectly. Do you know how I can program the buttons – for media control.

  17. hey, I just installed Linux a couple of hours ago, so bear with me please.
    I typed in the command but the file was empty. I typed in the code anyway and saved it but it didn’t work. What should I do?

    (Bear in mind I’ve had Ubuntu a good 3 or so hours and only just managed to figure out how to open the Terminal)

    1. I think you might be missing the xorg.conf file, which in some cases is not uncommon. You just have to generate a new one. To do so, try these steps and follow the eventual instructions you see:

      1. Press Ctrl+Alt+F1 or Ctrl+Alt+F2.
      2. Login with your username and password.
      3. sudo /etc/init.d/gdm stop (this will stop the X server)
      4. cd /etc/X11
      5. sudo mv xorg.conf xorg.conf.notworking (this line might not apply in your case, but try it anyway)
      6. sudo X -configure
      7. sudo cp ~/xorg.conf.new /etc/X11/xorg.conf
      8. sudo /etc/init.d/gdm start

    1. Hi, unfortunately it seems that there won’t be any official patch coming any time soon. Let me know if this fix worked for your RAT 3.

      Andrei

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *

     

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>