Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Cyborg RAT 7 in Linux
Earlier, I had written [a guide to getting the Logitech MX Revolution working in Linux](http://writoscope.me/2010/02/06/logitech-mx-revolution-in-arch-linux/ "Logitech MX Revolution in Arch Linux"). Some time ago the friction-free scroll mode broke down on me, so I decided to switch to a new mouse: the RAT 7 (this happened quite some time ago; I just got lazy in writing this). I won’t argue my purchase decision — you either like it or you don’t — but if you have one and want to get it working, then read on.
Details of how to use `xbindkeys` and `xmacro` are detailed in the above-linked guide, and I will not repeat it here.
#### The cursor doesn’t respond!
From [a very informative bug report](https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-evdev/+bug/615892/comments/13 "Bug #615892 “Madcatz Cyborg R.A.T. 7 focus issues” : Bugs : “xserver-xorg-input-evdev” package : Ubuntu") on `xorg-xserver-input-mouse`, the problem was tracked down to the mode selection button next to the left-click button. Apparently, it sends a release event for button 13, followed by a click event for button 14, each time you press it. In this manner, it cycles through buttons 13, 14 and 15 with repeated presses. X server jams during the start-up process when the mouse does this, and the only fix I know of now is to disable those 3 buttons. This can be done with xinput (detailed in the bug report, but session-specific), or in `/etc/X11/xorg.conf`. Edit the InputDevice section to look something like this:
```
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSectionSection "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 8 9 10 11 12 0 0 0 16 17 18 19 20 21"
EndSection
```
`ZAxisMapping` sets the scroll directions for the scroll wheel, and is not needed to un-jam the mouse. the important line here is `Option "ButtonMapping"`, which disables buttons 13–15. Reboot X server (or your system), and that’s all there is to it.
The MatchProduct string is obtained using `xinput --list`, and should match exactly.
#### Custom key mappings
For those who want custom button mappings as well, this is the `.xbindkeysrc` I use for the RAT 7:
```
###########################
# xbindkeys configuration # For Cyborg RAT 7 Mouse
###########################
##Ctrl-PgDn: Thumbwheel right
#using xte (old version): #"xte 'keydown Control_L' 'key Page_Down' 'keyup Control_L'"
"echo 'KeyStrPress Control_L KeyStrPress Page_Down KeyStrRelease Page_Down KeyStrRelease Control_L' | xmacroplay :0"
m:0x0 + b:10#Ctrl-PgUp: Thumbwheel left
#using xte (old version): "xte 'keydown Control_L' 'key Page_Up' 'keyup Control_L'"
"echo 'KeyStrPress Control_L KeyStrPress Page_Up KeyStrRelease Page_Up KeyStrRelease Control_L' | xmacroplay :0"
m:0x0 + b:11#Ctrl-F4: Red "Snipe" button
#using xte (old version): "xte 'keydown Control_L' 'key F4' 'keyup Control_L'"
"echo 'KeyStrPress Control_L KeyStrPress F4 KeyStrRelease F4 KeyStrRelease Control_L' | xmacroplay :0"
m:0x0 + b:12#Alt-Left: Rear thumb button
"echo 'KeyStrPress Alt_L KeyStrPress Left KeyStrRelease Left KeyStrRelease Alt_L' | xmacroplay :0"
m:0x0 + b:8#Alt-Right: Front thumb button
"echo 'KeyStrPress Alt_L KeyStrPress Right KeyStrRelease Right KeyStrRelease Alt_L' | xmacroplay :0"
m:0x0 + b:9#
# End of xbindkeys configuration
```
**Addendum (22/08/11):** Here’s an alternate `.xbindkeyrc` using `xdotool` in place of `xmacro`:
```
###########################
# xbindkeys configuration # For Cyborg RAT 7 Mouse
###########################
#
# Version: 0.1.3
#
#Ctrl-PgDn: Thumbwheel right
"xdotool key ctrl+Next"
m:0x0 + b:10
Control+Mod2 + Next#Ctrl-PgUp: Thumbwheel left
"xdotool key ctrl+Prior"
m:0x0 + b:11
Control+Mod2 + Prior#Ctrl-F4: Red "Snipe" button
"xdotool key ctrl+F4"
m:0x0 + b:12
Control+Mod2 + F4#Alt-Left: Rear thumb button
"xdotool key alt+Left"
m:0x0 + b:8
Alt+Mod2 + Left#Alt-Right: Front thumb button
"xdotool key alt+Right"
m:0x0 + b:9
Alt+Mod2 + Right#
# End of xbindkeys configuration</div>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment