Difference between revisions of "Logitech MX Revolution"

From ArchWiki
Jump to: navigation, search
(20 intermediate revisions by 11 users not shown)
Line 1: Line 1:
----
+
[[ru:Logitech MX Revolution]]
'''Originally Posted by NobodySpecial on the forums''' April 12, 2007:
+
[[Category:Mice]]
  
Many of us were using BTNX to run the buttons on the MX Revolution. But BTNX is now broken with the new XORG.  The good news is, the new XORG is good enough that you don't really need BTNX, for the most part.
+
Xorg is able to auto-detect this mouse just fine. However, it has a 17 key mapping:
  
Here's how I use mine.
+
  $ nano /etc/X11/xorg.conf
First, I'm not even using the evdev driver - I guess you could. But "mouse" works fine:
+
 
/etc/X11/xorg.conf
+
Edit your mouse section to say something like:
  
 
     Section "InputDevice"
 
     Section "InputDevice"
    Identifier   "MX Rev"
+
        Identifier "Mouse0"
    Driver       "mouse"
+
        Driver     "mouse"
    Option       "CorePointer"
+
        Option     "Protocol" "auto"
    Option       "Device"       "/dev/input/mice"
+
        Option     "Device" "/dev/input/mice"
    Option       "Protocol"        "auto"
+
        Option     "ZAxisMapping" "4 5"
    Option        "ZAxisMapping"       "4 5"
+
        #Option     "XAxisMapping" "6 7" #uncomment if you want horizontal scrolling with mouse wheel
    Option       "Emulate3Buttons"   "no"
+
        Option     "Buttons"   "17"
    Option       "Buttons"       "3"
+
 
     EndSection
 
     EndSection
  
To start, install a couple packages:
+
Next install the following packages
  
     sudo pacman -S xbindkeys xvkbd
+
     pacman -S xbindkeys xvkbd
  
Then find the buttons you want with xev and enter in ~/.xbindkeysrc
+
We'll put all of the settings into ~/.xbindkeysrc
My code under ~/.xbindkeysrc makes the thumb buttons go forward/back and also the middle mouse wheel rock left/right will change tabs in firefox:
+
  
 +
    touch ~/.xbindkeysrc
 +
    nano ~/.xbindkeysrc
  
     "/usr/bin/xvkbd -xsendevent -text "\[Alt_L]\[Left]""
+
 
 +
You'll want to put in ~/.xbindkeysrc events to send to xvkbd. Here is a sample:
 +
 
 +
     "/usr/bin/xvkbd -text "\[Alt_L]\[Left]""
 
       m:0x0 + b:8
 
       m:0x0 + b:8
     "/usr/bin/xvkbd -xsendevent -text "\[Alt_L]\[Right]""
+
     "/usr/bin/xvkbd -text "\[Alt_L]\[Right]""
 
       m:0x0 + b:9
 
       m:0x0 + b:9
     "/usr/bin/xvkbd -xsendevent -text "\[Control_L]\[Page_Up]""
+
     "/usr/bin/xvkbd -text "\[Control_L]\[Page_Up]""
 
       m:0x0 + b:6
 
       m:0x0 + b:6
     "/usr/bin/xvkbd -xsendevent -text "\[Control_L]\[Page_Down]""
+
     "/usr/bin/xvkbd -text "\[Control_L]\[Page_Down]""
 
       m:0x0 + b:7
 
       m:0x0 + b:7
  
To automate, add /usr/bin/xbindkeys to System -> Pref -> Sessions.
+
For some reason some combinations of keyboard events refuse to work with certain buttons for me.
Next, I like the left-sided wheel to rotate the desktop in compiz:
+
Compiz Settings -> Desktop -> Rotate Cube -> Bindings -> Initate "Button17", Rotate Left "Button13", Rotate Right "Button15"
+
Finally, its annoying to me that the middle button below the scroll wheel is set to "search".  Its far handier to have it as the middle mouse click.  The only way I found to do this is through Xmodmap, which isn't ideal, but works (PLEASE post here if you know a better way).
+
To list xmodmap keys: xmodmap -pk  OR  xmodmap -pke
+
Under xev above, my button gives "keycode 225", so I do this:
+
  
    echo "keycode 225 = Pointer_Button2" >> ~/.xmodmaprc
+
m:0x0 refers to your first mouse. The "+b:8" refers to the button you push. Here is a list of all the buttons:
 
+
Log out and in again - gnome should autodetect the ~/.xmodmaprc file.
+
The trick only works when "mousekeys" are on.
+
So either gnome-keyboard-properties -> Mousekeys -> Enable pointer OR toggle with SHIFT-ALT-NUMLOCK (you want to be able to toggle so you can use the numeric keypad at times).
+
However, the xmodmap trick has one more issue - it messes up keybindings in vmware.  This solved it for me:
+
 
+
    su
+
    echo "xkeymap.nokeycodeMap = true" >> /etc/vmware/config
+
 
+
----
+
 
+
'''Originally Posted by WCentauri on the forums''' August 14, 2008:
+
 
+
I suggest a slightly different way to handle the mapping of the search button to middle click. The output from xev lists the button as XF86Search, and it can also be referenced as c:0xE1.  It should be possible to map the search button with xbindkeys by referring to c:0xE1 or XF86Search and using the xmacro package available in the AUR.  The corresponding entry for xbindkeys is
+
 
+
    "echo 'ButtonPress 2 ButtonRelease 2' | xmacroplay :0"
+
      c:0xE1
+
 
+
I'm not sure that xvkbd can remap mouse buttons.  Perhaps this is why xmodmap was used in the first place. xmacro can handle keyboard and mouse buttons, so the other entries in .xbindkeysrc could be transformed to xmacroplay calls.  I don't have a compelling reason (besides aesthetics) for doing so, other than anecdotal claims that xmacro has less overhead than xmacro.  This may or may not be true, and it may not matter for practical purposes anyway.
+
 
+
There is a big thread ([http://ubuntuforums.org/showthread.php?t=968530&highlight=btnx]) brewing on the Ubuntu forums about the death of btnx, and that is where this technique comes from.
+
 
+
----
+
 
+
'''Post from the above link to the Ubuntu Forums:'''
+
 
+
With the release of Ubuntu 8.10, BTNX has been broken. As such, I figured I'd write up a small, hopefully as clear as possible tutorial on how to 'replace' it with a few other simple utilities.
+
 
+
There have been a few others posts on this, and I've found them helpful after some head scratching. I figured I'd try to make a simple, unified post.
+
 
+
So here is how I got my Logitech MX Revolution working again.
+
 
+
1) Install 2 utilities: xmacroplay and xbindkeys
+
 
+
    sudo apt-get install xbindkeys xmacro
+
 
+
Note: For arch, this would be
+
 
+
    pacman -S xbindkeys xmacro
+
 
+
xbindkeys runs commands when certain keyboard key presses or mouse button presses are detected. xmacro is a program for playing, shocker, macros. It can be used to generate, amongst other things, keypresses in an X window
+
 
+
2) Go through the (painful) button discovery process. To do this:
+
 
+
a) edit the configuration file for xbindkeys
+
 
+
gedit ~/.xbindkeysrc
+
 
+
delete the full contents of this file and add the following lines:
+
 
+
    "echo 'KeyStrPress Enter KeyStrRelease Enter' | xmacroplay :0"
+
    b:1
+
 
+
This will echo a very simple macro to the macro player which will direct the results of said macro to the default X display. In this case, it will generate a press of the 'enter' key.
+
 
+
b) launch a text editor window. We will use this to see the results of the macro running
+
 
+
c) run the following command in the terminal window:
+
 
+
    xbindkeys -n -v
+
 
+
Note: This will likely prevent the normal functioning of whatever button you are looking for.
+
 
+
d) select the text editor and start pressing mouse buttons until you get an 'enter' that will be button b:1 for your mouse. Once you find the button, reselect the terminal and Ctrl+C the process to stop it.
+
 
+
Repeat the whole process for different b:#'s (i.e. b:2). Make sure to note what button codes correspond to which buttons. Also, try multi button presses if no single button generates an event. For instance on my Revo, pressing the left and right buttons together is b:3
+
 
+
You should be able to find the button codes for most buttons using this process. On my mouse, the only button I couldn't find was the search button (which is handled differently by the OS for some odd reason).
+
 
+
For my mouse, the list looked like this:
+
  
 
     # Mappings for keys for MX Revo
 
     # Mappings for keys for MX Revo
Line 134: Line 62:
 
     # b:17 - media wheel press
 
     # b:17 - media wheel press
  
this list is only for your refrence when you start binding button presses to macros. You don't need to have it anywhere in any file (but it dosen't hurt to note them as comments in the ~/.xbindkeysrc file.
+
To remap the seach button to something instead of search, put something along the lines of the following into ~/.xbindkeysrc
 
+
Example here is to remap it to alt+f4 to close a window.
3) Figure out the Xmacro names for the keys you want to simulate
+
 
+
xmacro uses special codes to represent key presses and button clicks. The simplest way to figure out what codes to use for what you want to do is by using the xmacrorec2 utility.
+
 
+
To do this, start xmacrorec2 in a terminal and redirect the output to a reference file.
+
 
+
    xmacrorec2 > dump.txt
+
 
+
After starting xmacrorec2, press the scroll lock key to start recording actions. Then press any key or button you'd like to know the code of. When done, press scroll lock again to stop recording. Then look in the dump.txt file:
+
 
+
    cat dump.txt
+
 
+
You should see things like this:
+
 
+
    MotionNotify 378 241
+
    KeyStrPress XF86AudioMute
+
    KeyStrRelease XF86AudioMute
+
    KeyStrPress XF86AudioMute
+
    KeyStrPress XF86AudioLowerVolume
+
    KeyStrRelease XF86AudioMute
+
    KeyStrRelease XF86AudioLowerVolume
+
    KeyStrPress XF86AudioLowerVolume
+
    KeyStrRelease XF86AudioLowerVolume
+
    KeyStrPress XF86AudioLowerVolume
+
    KeyStrPress XF86AudioRaiseVolume
+
    KeyStrRelease XF86AudioLowerVolume
+
    KeyStrRelease XF86AudioRaiseVolume
+
 
+
4) Create your configuration file
+
 
+
Using the button codes from step 2 and the xmacro codes from step three, form your configuration file. Use the following format:
+
  
    # Example for a key press
+
     "/usr/bin/xvkbd -text "\[Alt_L]\[F4]""
     "echo 'KeyStrPress <xmacro code> KeyStrRelease <xmacro code>' | xmacroplay :0"
+
     c:0xE1
     <mouse button code>
+
  
where <xmacro code> is replaced (including carrots) with the keyboard code from step three and where <mouse button code> is replaced with a button code from step two.
+
Alternatively, Gnome will recognize the small middle search button as a keyboard event. Thus, you just have to go into keyboard shortcuts and remap that to something. This is probably the most reliable way to go about using this key.
  
Simulating mouse button presses is a bit different, but follows the same idea.
+
It is possible to use xmodmap to register the button press as a middle click. Begin by assigning the key event to Pointer_Button 2.
  
The above example will simulate a key press followed by an immediate key release. To configure multi-key presses, simply list all the keys, first as presses, then as releases, in a list seperated by spaces.
+
    echo "keycode 225 = Pointer_Button2" >> ~/.Xmodmap
  
My final simple configuration file ended up looking like this:
+
Now, just create a startup script that feeds that input into xmodmap when your window manager starts. In KDE4 create ~/.kde4/Autostart/middleclick with the following contents.
  
     # Mapping enter key to mousewheel right
+
     #!/bin/sh
     "echo 'KeyStrPress Return KeyStrRelease Return' | xmacroplay :0"
+
     xmodmap ~/.Xmodmap
    b:7
+
  
    # Mappings for media wheel
+
And do not forget to give it execute permissions.
    "echo 'KeyStrPress XF86AudioNext KeyStrRelease XF86AudioNext' | xmacroplay :0"
+
    b:13
+
    "echo 'KeyStrPress XF86AudioPrev KeyStrRelease XF86AudioPrev' | xmacroplay :0"
+
    b:15
+
    "echo 'KeyStrPress XF86AudioPlay KeyStrRelease XF86AudioPlay' | xmacroplay :0"
+
    b:17
+
  
 +
    chmod +x ~/.kde4/Autostart/middleclick
  
5) Test your configuration
+
The trick only works when "mousekeys" are on. So either gnome-keyboard-properties -> Mousekeys -> Enable pointer OR toggle with SHIFT-ALT-NUMLOCK (you want to be able to toggle so you can use the numeric keypad at times). Or in KDE System Settings -> Keyboard & Mouse -> Mouse -> Mouse Navigation -> Check "Move pointer with keyboard (using the num pad)"
  
Once all of the above is setup, test your configuration by running:
+
Lastly, add xbindkeys to your startup and you should be good to go.
  
    xbindkeys -n -v
 
  
in a terminal window. Leave the terminal up and let the code run and try out your mappings. When you are satisfied everything is working correctly, close the terminal window, and add a strait call to xbindkeys with no flags to your session. For gnome, this involves opening the System->Prefrences->Sessions, click on Add, then put any name (i.e: xbindkeys) and put xbindkeys in the command box (without the -n (not daemon) and -v (verbose) options), just xbindkeys. The next time you restart you system xbindkeys will run automatically.
+
The best way to map the search button to middle click is to add the following two lines to /etc/sysctl.conf:
 +
# Enable mouse button emulation
 +
dev.mac_hid.mouse_button_emulation = 1
 +
# Set 2nd button to 217 - the middle button of MX Revolution mouse.
 +
dev.mac_hid.mouse_button2_keycode = 217
  
Please let me know if anything here is unclear. Also, feel free to post your button mappings for others to use!
+
== Mouse Wheel Mode ==
----
+
In order to enable or disable mouse wheel's free spinning, you can use [https://aur.archlinux.org/packages.php?ID=8436 revoco]. Giving the following command from shell, or, alternatively, putting it in a script executed at the startup should enable/disable free spinning.
 +
# revoco free # in order to enable free spinning
 +
# revoco click # in order to disable free spinning
 +
More Info can be found [http://www.toosweettobesour.com/2009/05/13/logitech-mx-revolution-revoco-in-ubuntu-904-jaunty-click-to-click-even-after-a-resumewakeup/ here]

Revision as of 16:23, 19 February 2013


Xorg is able to auto-detect this mouse just fine. However, it has a 17 key mapping:

$ nano /etc/X11/xorg.conf

Edit your mouse section to say something like:

   Section "InputDevice"
       Identifier  "Mouse0"
       Driver      "mouse"
       Option      "Protocol" "auto"
       Option      "Device" "/dev/input/mice"
       Option      "ZAxisMapping" "4 5"
       #Option      "XAxisMapping" "6 7"  #uncomment if you want horizontal scrolling with mouse wheel
       Option      "Buttons"    "17"
   EndSection

Next install the following packages

   pacman -S xbindkeys xvkbd

We'll put all of the settings into ~/.xbindkeysrc

   touch ~/.xbindkeysrc
   nano ~/.xbindkeysrc


You'll want to put in ~/.xbindkeysrc events to send to xvkbd. Here is a sample:

   "/usr/bin/xvkbd -text "\[Alt_L]\[Left]""
     m:0x0 + b:8
   "/usr/bin/xvkbd -text "\[Alt_L]\[Right]""
     m:0x0 + b:9
   "/usr/bin/xvkbd -text "\[Control_L]\[Page_Up]""
     m:0x0 + b:6
   "/usr/bin/xvkbd -text "\[Control_L]\[Page_Down]""
     m:0x0 + b:7

For some reason some combinations of keyboard events refuse to work with certain buttons for me.

m:0x0 refers to your first mouse. The "+b:8" refers to the button you push. Here is a list of all the buttons:

   # 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

To remap the seach button to something instead of search, put something along the lines of the following into ~/.xbindkeysrc Example here is to remap it to alt+f4 to close a window.

   "/usr/bin/xvkbd -text "\[Alt_L]\[F4]""
   c:0xE1

Alternatively, Gnome will recognize the small middle search button as a keyboard event. Thus, you just have to go into keyboard shortcuts and remap that to something. This is probably the most reliable way to go about using this key.

It is possible to use xmodmap to register the button press as a middle click. Begin by assigning the key event to Pointer_Button 2.

   echo "keycode 225 = Pointer_Button2" >> ~/.Xmodmap

Now, just create a startup script that feeds that input into xmodmap when your window manager starts. In KDE4 create ~/.kde4/Autostart/middleclick with the following contents.

   #!/bin/sh 
   xmodmap ~/.Xmodmap

And do not forget to give it execute permissions.

   chmod +x ~/.kde4/Autostart/middleclick

The trick only works when "mousekeys" are on. So either gnome-keyboard-properties -> Mousekeys -> Enable pointer OR toggle with SHIFT-ALT-NUMLOCK (you want to be able to toggle so you can use the numeric keypad at times). Or in KDE System Settings -> Keyboard & Mouse -> Mouse -> Mouse Navigation -> Check "Move pointer with keyboard (using the num pad)"

Lastly, add xbindkeys to your startup and you should be good to go.


The best way to map the search button to middle click is to add the following two lines to /etc/sysctl.conf:

# Enable mouse button emulation
dev.mac_hid.mouse_button_emulation = 1
# Set 2nd button to 217 - the middle button of MX Revolution mouse.
dev.mac_hid.mouse_button2_keycode = 217

Mouse Wheel Mode

In order to enable or disable mouse wheel's free spinning, you can use revoco. Giving the following command from shell, or, alternatively, putting it in a script executed at the startup should enable/disable free spinning.

# revoco free  # in order to enable free spinning
# revoco click # in order to disable free spinning

More Info can be found here