Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › [HOW TO] Set up MX Revolution (and other multi-button mice) under Linux
New Posts  All Forums:Forum Nav:

[HOW TO] Set up MX Revolution (and other multi-button mice) under Linux

post #1 of 16
Thread Starter 
This is my first guide, so be gentle.

This guide will explain how to enable the extra buttons on the MX Revolution mouse, and should work fine for any other multi-button mouse as well. This guide is written for Fedora, but could work for other releases.

This guide is based on a similar guide by Nathan Wood: http://n8wood.wordpress.com/2008/12/...ra-and-centos/

I have an MX Revolution, best mouse I've ever owned, but when I made the jump to Linux it's been a hassle to get all the buttons working in the newer releases. If you do a quick Google search you'll see what I mean. The way it used to be done was with a programs like 'btnx' or 'xvkbd', but neither is supported or in the repositories any more. Then comes the way I've had my mouse working for awhile, with xbindkeys and xmacroplay. Okay, so we're getting better, xbindkeys is in the repository at lease, but if you want xmacro you either need to compile it yourself or find a pre-compiled RPM somewhere. Not to mention the fact that xmacro hasn't been updated since 2001.

Herald in xdotool, a newer program that is both up to date and in the repositories. This along with xbindkeys grants plethora of configuration options. Now let's get on to the guide...


Firstly, install xbindkeys and xdotool:

Code:
sudo yum install xbindkeys xdotool
Once xbindkeys is installed you need to create a config file for it to read from:

Code:
xbindkeys –-defaults > ~/.xbindkeysrc
Open the config file for editing:

Code:
gedit ~/.xbindkeysrc
There is some included example code in the file, you can delete what I have emboldened below:

Code:
# For the benefit of emacs users: -*- shell-script -*-
###########################
# xbindkeys configuration #
###########################
#
# Version: 1.8.2
#
# If you edit this file, do not forget to uncomment any lines
# that you change.
# The pound(#) symbol may be used anywhere for comments.
#
# To specify a key, you can use 'xbindkeys --key' or
# 'xbindkeys --multikey' and put one of the two lines in this file.
#
# The format of a command line is:
#    "command to start"
#       associated key
#
#
# A list of keys is in /usr/include/X11/keysym.h and in
# /usr/include/X11/keysymdef.h
# The XK_ is not needed.
#
# List of modifier:
#   Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock),
#   Mod3 (CapsLock), Mod4, Mod5 (Scroll).
#

# The release modifier is not a standard X modifier, but you can
# use it if you want to catch release events instead of press events

# By defaults, xbindkeys does not pay attention with the modifiers
# NumLock, CapsLock and ScrollLock.
# Uncomment the lines above if you want to pay attention to them.

#keystate_numlock = enable
#keystate_capslock = enable
#keystate_scrolllock= enable

# Examples of commands:

"xbindkeys_show" 
  control+shift + q

# set directly keycode (here control + f with my keyboard)
"xterm"
  c:41 + m:0x4

# specify a mouse button
"xterm"
  control + b:2

#"xterm -geom 50x20+20+20"
#   Shift+Mod2+alt + s
#
## set directly keycode (here control+alt+mod2 + f with my keyboard)
#"xterm"
#  alt + c:0x29 + m:4 + mod2
#
## Control+Shift+a  release event starts rxvt
#"rxvt"
#  release+control+shift + a
#
## Control + mouse button 2 release event starts rxvt
#"rxvt"
#  Control + b:2 + Release

##################################
# End of xbindkeys configuration #
##################################
You can delete the rest of the file above this, but since it is just explaining file configuration I recommend leaving it.

Now we get to the actual configuration. Create a new section of the file called “MX Revolution Config”, or whatever you would like to name it.

Code:
# 'xbindkeys --multikey' and put one of the two lines in this file.
#
# The format of a command line is:
#    "command to start"
#       associated key
#
#
# A list of keys is in /usr/include/X11/keysym.h and in
# /usr/include/X11/keysymdef.h
# The XK_ is not needed.
#
# List of modifier:
#   Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock),
#   Mod3 (CapsLock), Mod4, Mod5 (Scroll).
#

# The release modifier is not a standard X modifier, but you can
# use it if you want to catch release events instead of press events

# By defaults, xbindkeys does not pay attention with the modifiers
# NumLock, CapsLock and ScrollLock.
# Uncomment the lines above if you want to pay attention to them.

#keystate_numlock = enable
#keystate_capslock = enable
#keystate_scrolllock= enable

#MX Revolution Config

##################################
# End of xbindkeys configuration #
##################################
Each button on your mouse is referenced by a specific button code. You can find these codes by running “xev” in console, pressing each button, and seeing what button number is returned. But, to save some time, here are the codes for the MX Revolution:

Code:
# Mappings for keys for MX Revo
# b:1 - left mouse button
# b:2 - left and right mouse button together
# b:3  - right mouse button
# b:4 - mouse wheel up
# b:5 - mouse wheel down
# b:6 - mouse wheel left
# b:7 - mouse wheel right
# b:8 - back button
# b:9 - forward button
# b:10 - -none-
# b:11 - -none-
# b:12 - -none-
# b:13 - media wheel up
# b:14 - -none-
# b:15 - media wheel down
# b:16 - -none-
# b:17 - media wheel press

#c:225 or XF86Search – search button
Note: I have included the keycode for the search button, however, I have not yet successfully been able to issue a command when pressed. If you would like to try, you first need to enter your system config and unbind it from the “Search” command in shortcuts.

You can paste this list into your xbindkeysrc for easy reference if you like, just be sure to leave it commented.

Keypress commands in xdotool are issued in the following manner: keydown [key] keyup [key]. Or for nested commands: keydown [key1] keydown [key2] keyup [key2] keyup [key1].

Example:
Code:
#Find
“echo 'keydown Control_L keydown f keyup f keydown Control_L' | xdotool - :0”
b:8
That should give you a basic idea of the syntax of the commands. A list of modifier keys is present in the default xbindkeysrc file. The first line issues your keystroke commands and pipes them into xdotool. The second line is the number of the botton and/or keycode you wish to assign that command to.

If you need to find out the keycode of a certain key, you can run the following command:

Code:
xbindkeys -mk
While running, you can press any key and it will display the keycode along with any other name the key may have such as “Control_L” seen above.

Here is a simple xbindkeysrc to give you a better example:
Code:
# 'xbindkeys --multikey' and put one of the two lines in this file.
#
# The format of a command line is:
#    "command to start"
#       associated key
#
#
# A list of keys is in /usr/include/X11/keysym.h and in
# /usr/include/X11/keysymdef.h
# The XK_ is not needed.
#
# List of modifier:
#   Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock),
#   Mod3 (CapsLock), Mod4, Mod5 (Scroll).
#

# The release modifier is not a standard X modifier, but you can
# use it if you want to catch release events instead of press events

# By defaults, xbindkeys does not pay attention with the modifiers
# NumLock, CapsLock and ScrollLock.
# Uncomment the lines above if you want to pay attention to them.

#keystate_numlock = enable
#keystate_capslock = enable
#keystate_scrolllock= enable

#MX Revolution Config

#Application Switching
“echo 'keydown Alt_L keydown Tab keyup Tab keyup Alt_L' | xdotool - :0”
b:13

“echo 'keydown Alt_L keydown Shift_L keydown Tab keyup Tab keyup Shift_L keyup Alt_L' | xdotool - :0”
b:15

#Navigate Back/Forward
“echo 'keydown Alt_L keydown Left keyup Left keyup Alt_L' | xdotool - :0”
b:8

“echo 'keydown Alt_L keydown Right keyup Right keyup Alt_L' | xdotool - :0”
b:9

##################################
# End of xbindkeys configuration #
##################################
Now, to test out your new xbindkeysrc just run the following command:

Code:
xbindkey -n -v
While this is running, the config you just created will be running, so your buttons should be working. If they're not, review the output of in the console when pressing the buttons and double check the config file.

If everything is working fine, just add the command “xbindkeys” to your system startup (without quotations), and you're good to go!

This is a very simple application for xdotool, it has many more options including specifying which window a command is executed in. For more info regarding xdotool's commands, check up the xdotool documentation: http://www.semicomplete.com/projects.../xdotool.xhtml


Well, there you have it! A working means of getting the MX Revolution (and hopefully other multi-button mice) working under Linux!

I hope this guide has helped you you, thanks for reading!
Edited by 31337 - 7/20/11 at 7:03pm
Ganymede
(7 items)
 
  
CPUGraphicsRAMHard Drive
i7 4790T Nvidia GTX 860m 2GB 16GB Corsair DDR3L 1600Mhz 500GB Samsung 850 EVO 
OSCaseAudio
Windows 10 Pro x64 Alienware Steam Machine Creative Sound Blaster Omni 
  hide details  
Reply
Ganymede
(7 items)
 
  
CPUGraphicsRAMHard Drive
i7 4790T Nvidia GTX 860m 2GB 16GB Corsair DDR3L 1600Mhz 500GB Samsung 850 EVO 
OSCaseAudio
Windows 10 Pro x64 Alienware Steam Machine Creative Sound Blaster Omni 
  hide details  
Reply
post #2 of 16
You should also learn to properly map xinput as it is the defacto for inputs now. Xinput is extremely powerful and should be able to re-map those buttons so the OS sees them as mouse1/2/3/4/5 ect...
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
post #3 of 16
Thread Starter 
Quote:
Originally Posted by mushroomboy View Post
You should also learn to properly map xinput as it is the defacto for inputs now. Xinput is extremely powerful and should be able to re-map those buttons so the OS sees them as mouse1/2/3/4/5 ect...
Can you use xinput to link button presses to a string of commands and/or keyboard inputs?
Ganymede
(7 items)
 
  
CPUGraphicsRAMHard Drive
i7 4790T Nvidia GTX 860m 2GB 16GB Corsair DDR3L 1600Mhz 500GB Samsung 850 EVO 
OSCaseAudio
Windows 10 Pro x64 Alienware Steam Machine Creative Sound Blaster Omni 
  hide details  
Reply
Ganymede
(7 items)
 
  
CPUGraphicsRAMHard Drive
i7 4790T Nvidia GTX 860m 2GB 16GB Corsair DDR3L 1600Mhz 500GB Samsung 850 EVO 
OSCaseAudio
Windows 10 Pro x64 Alienware Steam Machine Creative Sound Blaster Omni 
  hide details  
Reply
post #4 of 16
Quote:
Originally Posted by 31337 View Post
Can you use xinput to link button presses to a string of commands and/or keyboard inputs?
I'm not sure, xinput is rather new in terms of full adoption. I'm pretty sure you can, though I've got class in 13 so I can't really do any extensive research. It is still a good article though!
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
post #5 of 16
For your xbindkeys, it should be xbindkeys --defaults > ~/.xbindkeysrc rather than xbindkeys -defaults > ~/.xbindkeysrc
#well
(19 items)
 
Lenovo L530
(8 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i7 4770k Gigabyte Z87X-UD4H XFX Radeon HD 6950 Corsair CMX8GX3M2A2000C9 
Hard DriveHard DriveOptical DriveCooling
Samsung EVO 840 Hitachi HDS722020ALA330 Generic DVD±RW Burner Noctua NH-D14 
OSMonitorMonitorKeyboard
Windows 8.1 Dell U2711 LG W2453 Ducky DK9008 Overclock.net Edition, Cherry MX B... 
PowerCaseMouseMouse Pad
Corsair TX850 Antec Three Hundred Corsair Raptor M40 QPAD HeatoN M 
AudioAudioAudio
E-MU Tracker|pre Beyerdynamic DT-770 250 Ohm AntLion ModMIc 
CPUGraphicsRAMRAM
Intel Ivy Bridge 3210M Intel HD 4000 Graphics Soldered Corsair Vengeance  
Hard DriveOptical DriveOSMonitor
500GB DVD-+RW Windows 7 Professional 1600x900 
  hide details  
Reply
#well
(19 items)
 
Lenovo L530
(8 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i7 4770k Gigabyte Z87X-UD4H XFX Radeon HD 6950 Corsair CMX8GX3M2A2000C9 
Hard DriveHard DriveOptical DriveCooling
Samsung EVO 840 Hitachi HDS722020ALA330 Generic DVD±RW Burner Noctua NH-D14 
OSMonitorMonitorKeyboard
Windows 8.1 Dell U2711 LG W2453 Ducky DK9008 Overclock.net Edition, Cherry MX B... 
PowerCaseMouseMouse Pad
Corsair TX850 Antec Three Hundred Corsair Raptor M40 QPAD HeatoN M 
AudioAudioAudio
E-MU Tracker|pre Beyerdynamic DT-770 250 Ohm AntLion ModMIc 
CPUGraphicsRAMRAM
Intel Ivy Bridge 3210M Intel HD 4000 Graphics Soldered Corsair Vengeance  
Hard DriveOptical DriveOSMonitor
500GB DVD-+RW Windows 7 Professional 1600x900 
  hide details  
Reply
post #6 of 16
Also, forgot to mention, but this guide is AWESOME Amazing to have macros on my mouse again.
#well
(19 items)
 
Lenovo L530
(8 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i7 4770k Gigabyte Z87X-UD4H XFX Radeon HD 6950 Corsair CMX8GX3M2A2000C9 
Hard DriveHard DriveOptical DriveCooling
Samsung EVO 840 Hitachi HDS722020ALA330 Generic DVD±RW Burner Noctua NH-D14 
OSMonitorMonitorKeyboard
Windows 8.1 Dell U2711 LG W2453 Ducky DK9008 Overclock.net Edition, Cherry MX B... 
PowerCaseMouseMouse Pad
Corsair TX850 Antec Three Hundred Corsair Raptor M40 QPAD HeatoN M 
AudioAudioAudio
E-MU Tracker|pre Beyerdynamic DT-770 250 Ohm AntLion ModMIc 
CPUGraphicsRAMRAM
Intel Ivy Bridge 3210M Intel HD 4000 Graphics Soldered Corsair Vengeance  
Hard DriveOptical DriveOSMonitor
500GB DVD-+RW Windows 7 Professional 1600x900 
  hide details  
Reply
#well
(19 items)
 
Lenovo L530
(8 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i7 4770k Gigabyte Z87X-UD4H XFX Radeon HD 6950 Corsair CMX8GX3M2A2000C9 
Hard DriveHard DriveOptical DriveCooling
Samsung EVO 840 Hitachi HDS722020ALA330 Generic DVD±RW Burner Noctua NH-D14 
OSMonitorMonitorKeyboard
Windows 8.1 Dell U2711 LG W2453 Ducky DK9008 Overclock.net Edition, Cherry MX B... 
PowerCaseMouseMouse Pad
Corsair TX850 Antec Three Hundred Corsair Raptor M40 QPAD HeatoN M 
AudioAudioAudio
E-MU Tracker|pre Beyerdynamic DT-770 250 Ohm AntLion ModMIc 
CPUGraphicsRAMRAM
Intel Ivy Bridge 3210M Intel HD 4000 Graphics Soldered Corsair Vengeance  
Hard DriveOptical DriveOSMonitor
500GB DVD-+RW Windows 7 Professional 1600x900 
  hide details  
Reply
post #7 of 16
i will have to try this when i redo all the software on my computer (switchin to 32bit #! over 64 as 64 hates my quake )

been really irritating i couldnt use my complex configs for tdm in quake that involve my side mouse buttons xD
Kinda meh now...
(13 items)
 
  
CPUMotherboardGraphicsRAM
PhII 940 BE asus M4N82 Deluxe 2x 8800gts(g92) 2x 1g ocz ddr2 1066 
Hard DriveOptical DriveOSMonitor
/dev/sd[abc] /dev/sr0 WinXP/Linux 22in acer 
PowerCaseMouseMouse Pad
950w rosewill timebomb Antec 900 (2small) Voodoo Deathadder (RED!) X-Trac Pads Ripper XL 
  hide details  
Reply
Kinda meh now...
(13 items)
 
  
CPUMotherboardGraphicsRAM
PhII 940 BE asus M4N82 Deluxe 2x 8800gts(g92) 2x 1g ocz ddr2 1066 
Hard DriveOptical DriveOSMonitor
/dev/sd[abc] /dev/sr0 WinXP/Linux 22in acer 
PowerCaseMouseMouse Pad
950w rosewill timebomb Antec 900 (2small) Voodoo Deathadder (RED!) X-Trac Pads Ripper XL 
  hide details  
Reply
post #8 of 16
I guess xbindkeys is the easiest for scripting/commands. I'm sure you could set up HAL/udev rules, not sure about scripting though.
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
post #9 of 16
Thread Starter 
Quote:
Originally Posted by gonX View Post
For your xbindkeys, it should be xbindkeys --defaults > ~/.xbindkeysrc rather than xbindkeys -defaults > ~/.xbindkeysrc
Ah, yep, thanks for catching that.

Quote:
Originally Posted by mushroomboy View Post
I guess xbindkeys is the easiest for scripting/commands. I'm sure you could set up HAL/udev rules, not sure about scripting though.
There was a way to set up some rudimentary support via xorg.conf, but if you wanted to bind key commands good luck. Since xorg.conf is essentially depreciated now, it's not really even worth mentioning.
Ganymede
(7 items)
 
  
CPUGraphicsRAMHard Drive
i7 4790T Nvidia GTX 860m 2GB 16GB Corsair DDR3L 1600Mhz 500GB Samsung 850 EVO 
OSCaseAudio
Windows 10 Pro x64 Alienware Steam Machine Creative Sound Blaster Omni 
  hide details  
Reply
Ganymede
(7 items)
 
  
CPUGraphicsRAMHard Drive
i7 4790T Nvidia GTX 860m 2GB 16GB Corsair DDR3L 1600Mhz 500GB Samsung 850 EVO 
OSCaseAudio
Windows 10 Pro x64 Alienware Steam Machine Creative Sound Blaster Omni 
  hide details  
Reply
post #10 of 16
Quote:
Originally Posted by 31337 View Post
Ah, yep, thanks for catching that.



There was a way to set up some rudimentary support via xorg.conf, but if you wanted to bind key commands good luck. Since xorg.conf is essentially depreciated now, it's not really even worth mentioning.
That's moved to xinput/udev stuff. I know you can set the keys to work there but you can't do it as easy or with the ability to run commands/scripts.
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › [HOW TO] Set up MX Revolution (and other multi-button mice) under Linux