Thursday, March 31, 2011

Cyborg RAT 7 in Arch Linux

Earlier, I had written a guide to getting the Logitech MX Revolution working in 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 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"
EndSection

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 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 (in bold). 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


5 comments:

Leon said...
This comment has been removed by the author.
Leon said...
This comment has been removed by the author.
Leon said...

Do you have any binds for the middle mouse button to quick scroll on firefox like in windows ?

Nate said...

Do you have any advice for a complete n00b as to how to make this work? I thought I did everything correctly, I got the mouse working OK with editing xorg.conf, but when I tried to use your button mappings nothing happened. I'm sure that there's something dumb that I'm missing, but I'm not sure what. I did run xbindkeys after saving the file, I know that much...

Nate said...

never mind... I restarted X (after having restarted X subsequent to editing xorg.conf and but prior to creating the xbindkeys.rc, so I'm not sure what difference that would make) now when I run xbindkeys everything works. Thanks for figuring this out for us!

Tags

linux (4) software (4) hardware (3) musings (3) osmium (3) projects (3) science (1) typography (1)