HOWTO Advanced Mouse
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
|
Contents |
[edit] Introduction
This guide will explain how to get newer mice working on XFree86 or Xorg with all the buttons being functional. Older methods of mouse setup will leave buttons mapped incorrectly or not functioning altogether. Certain options must be changed in your xorg.conf (for XOrg Foundation version of X) to use a newer protocol which will recognize those buttons. Also, you may have to compile the mouse driver as a module rather than building it into the kernel to get access to some of the button functions.
An already functional xorg.conf is required to use this guide. Please see http://www.gentoo.org/doc/en/xorg-config.xml for more information regarding automatic generation of one.
Monolithic XOrg builds 6.8 and lower have information contained in HOWTO Advanced Mouse/Legacy Monolithic and HOWTO Advanced Mouse/Legacy Monolithic/Individual Configurations. See that information for historical purposes only.
The following mice need to be reviewed and added, but will likely work:
Logitech MX610 Left-Handed
Logitech MX518
Logitech MX400
Logitech V270 Bluetooth
Logitech V200 Wireless
Logitech V320 Wireless
Logitech V150
Logitech V100
Logitech LX5 Wireless
Logitech Notebook Optical Plus
Logitech Kids Series Mice
Logitech Cordless Mini
Logitech MX Revolution
Logitech VX Revolution
Any Logitech Trackballs
Microsoft Basic Optical
Microsoft Comfort Optical 1000
Microsoft Compact Optical
Microsoft IntellMouse Bluetooth
Microsoft Wheel Mouse Optical 1.1
Microsoft Wireless Laser Mouse 5000 & 6000
Microsoft Wireless Optical 2000, 3000, 5000
Razer Copperhead
Razer Krait
This guide is now loosely based on one from the Gentoo Forums written by meowsqueak. Here's a link to that thread.
[edit] XOrg 6.9 or Greater, evdev, and USB Mice
Credit to linuX-gamers.net for writing an initial howto.
For XOrg 6.9 or greater, you'll want to use the new evdev driver for USB mice. This will allow all the mouse buttons to function, and nine times out of ten, you won't have to remap buttons to get things working properly.
First, make sure your kernel has evdev built into it:
| Linux Kernel Configuration: Kernel Configuration (2.6.16 Example) |
Device Drivers --->
Input Device Support --->
<*> Event Interface
USB Support --->
<*> USB Human Interface Device (full HID) support
[*] HID input layer support
|
If you build evdev as a module, you'll want to have it load on startup by adding the appropriate line in your /etc/modules.autoload.d/kernel-2.6:
| File: /etc/modules.autoload.d/kernel-2.6 |
# /etc/modules.autoload.d/kernel-2.6: kernel modules to load when system boots. # # Note that this file is for 2.6 kernels. # # Add the names of modules that you'd like to load when the system # starts into this file, one per line. Comments begin with # and # are ignored. Read man modules.autoload for additional details. # For example: # 3c59x evdev usbhid |
Now run update-modules to commit the changes to /etc/modules.autoload.d/kernel-2.6:
#update-modules -f
The -f option forces changes to be committed.
Next, you'll need to have modular XOrg's evdev support installed.
#emerge xf86-input-evdev
If you built evdev as a kernel module, let's make sure it's loaded and ready to go:
You can see if the module evdev is loaded by:
#lsmod
If it's not listed, load it with:
#modprobe evdev
Now let's find out the location of your mice by reading the /proc/bus/input/devices file:
#cat /proc/bus/input/devices I: Bus=0003 Vendor=046d Product=c50e Version=2500 N: Name="Logitech USB Receiver" P: Phys=usb-0000:00:1d.0-2/input0 H: Handlers=mouse0 event0 kbd B: EV=120007 B: KEY=ffff0000 10000 0 0 0 0 0 0 0 B: REL=103 B: LED=fc00
This system location information can be added to the /etc/X11/xorg.conf file several ways.
[edit] Option 1: Configure by Device
The first is by using the device address, in this case /dev/input/event0:
| File: /etc/X11/xorg.conf |
Section "InputDevice"
Identifier "Mouse0"
Driver "evdev"
Option "Device" "/dev/input/event0"
EndSection
|
[edit] Option 2: Configure by Autodetection
The second way is to use the evdev driver in the way it was intended to detect a mouse:
| File: /etc/X11/xorg.conf |
Section "InputDevice"
Identifier "Mouse0"
Driver "evdev"
Option "evBits" "+1-2"
Option "keyBits" "~272-287"
Option "relBits" "~0-2 ~6 ~8"
Option "Pass" "3"
EndSection
|
Restart XOrg and try things out. Your mouse should now be working!
[edit] Upgrading From XOrg 7.0 to 7.1 or higher
Previously this HOWTO explained how to use static UDEV device nodes to use mice in XOrg. The evdev driver in XOrg 7.1 no longer supports this method, or any method of altering the original device files. The original device file must be used. Using the old method will cause /dev/input/eventX files to come up missing and will cause errors when XOrg tries to call the mouse either by Name or Device ID. Revert any changes made to /etc/udev/rules.d/010_local.rules by commenting out the added lines or deleting the file, then restart UDEV by:
# udevstart
[edit] Upgrading to XOrg 7.3 or higher
The value "AlwaysCore" in Input device is deprecated. The following must now be used in ServerLayout:
InputDevice "Mouse0" "SendCoreEvents"
For more information, check the Gentoo Forums: http://forums.gentoo.org/viewtopic-t-591248-highlight-mice.html
[edit] Individual Mouse Configurations
This section has been moved to HOWTO Advanced Mouse/Individual Configurations. Please post if your mouse requires any special xmodmap, xinput, or other settings to function properly.
[edit] Multiple Mice Support
For additional mice support you'll have to add another "InputDevice" section. The following is an example of a two mouse setup, with the wireless as the default pointer:
| File: /etc/X11/xorg.conf |
Section "InputDevice"
Identifier "Mouse0"
Driver "evdev"
Option "Device" "/dev/input/event0"
EndSection
Section "InputDevice"
Identifier "Mouse1"
Driver "evdev"
Option "Device" "/dev/input/event1"
EndSection
|
You'll then have to modify your ServerLayout section:
| File: /etc/X11/xorg.conf |
Section "ServerLayout"
#....Rest of serverlayout section
InputDevice "Mouse0" "SendCoreEvents"
InputDevice "Mouse1" "SendCoreEvents"
#....Rest of serverlayout section
EndSection
|
Restart your X server to use the new configuration.
[edit] Button Remapping
[edit] evdev Options
| FIXME: Explain how to use evdev xorg.conf options to remap buttons. |
[edit] Xmodmap
When using the correct configuration in xorg.conf does not produce the desired results, you may have to manually remap the mouse buttons to the correct function. The Xmodmap program will do this for you. Use this only as a last resort when your evdev or mouse driver is not functioning in an expected fashion. The syntax is
#xmodmap -e "pointer = (remapping of mouse buttons)"
For instance, if you want to remap button 2 to button 3 and you have a 12 button mouse, simply
#xmodmap -e "pointer = 1 3 2 4 5 6 7 8 9 10 11 12"
You can test the results of your remapping by running the program xev and pressing the button in question while keeping the cursor inside the black box in the window. It will give you a lot of information you don't need, but it will tell you which button X thinks it is once it's remapped. By default, X does sees all buttons as a 1-to-1 physical mapping with what the mouse driver tells it.
To have X load your mapping each time it's started, simply place it inside the /etc/X11/Xmodmap file. For user-based mappings, you can use ~/.Xmodmap. They are formatted as such:
| File: ~/.Xmodmap or /etc/X11/Xmodmap |
pointer = 1 3 2 4 5 6 7 8 9 10 11 12 |
[edit] KDM and KDE
When using KDM and KDE, your /etc/X11/xinit/xinitrc may be ignored. To automatically call xmodmap (only for yourself), you can use the Autostart folder of kde
| File: ~/.kde/Autostart/Xmodmap |
#!/bin/sh xmodmap /etc/X11/Xmodmap |
Alternatively, you can add the following line to ${kdedir}/share/config/kdm/Xstartup to remap your mouse buttons/wheel for all users of the system:
| File: ${kdedir}/share/config/kdm/Xstartup |
/usr/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5" |
Another way is to add the following lines to ${kdedir}/share/config/kdm/Xsession to fix the .Xmodmap issue for all users:
| File: ${kdedir}/share/config/kdm/Xsession |
/usr/bin/xmodmap -e "pointer = default"
if [ -f "$HOME/.Xmodmap" ]
then
/usr/bin/xmodmap "$HOME/.Xmodmap"
fi
|
If you'd rather not touch files in ${kdedir}, then have each user create a ~/.xprofile containing the following:
| File: ~/.xprofile |
/usr/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5" |
or
| File: ~/.xprofile |
/usr/bin/xmodmap .Xmodmap |
If you don't like this way, there is yet another one: put the xmodmap line in the /etc/xprofile file and make it executable:
| File: /etc/xprofile |
xmodmap /etc/X11/Xmodmap |
[edit] GDM and GNOME
When using GDM your /etc/X11/xinit/xinitrc may be ignored. To fix this, use the .Xmodmap loading feature of gdm:
| File: ~/.Xmodmap |
pointer = 1 2 3 6 7 4 5 |
You will be prompted by gdm at the next login to enable the new mapping.
To apply the setting for all users, place the same line in /etc/X11/Xmodmap.
[edit] Multiple Mice and Xinput
Xmodmap will only affect the first mouse in your xorg.conf ServerLayout section. Your second mouse will not be able to be mapped.
(You may use the "xsetpointer" command to view and change which mouse is considered first. emerge xsetpointer to try it out.
If you want to change the buttons of additional mouse devices, you can use Xinput instead of Xmodmap. Xinput can be simply obtained:
emerge xinput
To rearrange the buttons use
xinput set-button-map <device name> <new button order>
To determine the device name either have a look in your xorg.conf or use:
xinput list or xsetpointer -l
Example: This works quite well:
xinput set-button-map Mouse1 1 2 3 6 7 8 4 5
If you use the "evdev"-driver, you'll notice that xinput has the annoying "feature" of appending the physical address to the Identifier you gave the device in your xorg.conf. You can use a bit of grep and sed magic to tend to this problem (The xorg.conf-Identifier is "Mouse3" in this example):
xinput set-button-map `xinput list | grep -o '"Mouse3.*"'|sed -e 's/"//g'` 1 9 3 4 5 6 7 8 2
[edit] XOrg.conf ButtonMapping
| FIXME: Explain more clearly how ButtonMapping works and why the values entered into the variable do what they do. Also confirm as to whether this variable is specified for the evdev driver. |
Newer versions of XOrg contain a new variable for mapping mouse buttons from within xorg.conf. XOrg 7.0 starts by assigning 11 buttons, taking 4 5 6 7 as scroll buttons and leaving 7 physical buttons. There is no need to use xmodmap to modify what buttons point where as there seems to be a new option for that within xorg.conf, "ButtonMapping". In fact, without any editing xorg.conf seems to have the following default:
Option "ButtonMapping" "1 2 3 8 9 10 11"
The syntax is as follows:
| File: /etc/X11/xorg.conf |
Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option "Device" "/dev/input/mice"
Option "Protocol" "auto"
Option "ButtonMapping" "1 2 3 6 7"
EndSection
|
References:
[edit] CPI Resolution and other mouse control
Some types of mice support different CPI resolutions such as 400, 800, 1200, etc. as well as some other controls. To change cpi resolution for Logitech mice, install the following package: emerge lomoco
and create the following file:
| File: /etc/udev/rules.d/55-lomoco.rules |
BUS=="usb", SYSFS{manufacturer}=="Logitech", SYSFS{product}=="USB-PS/2 Optical Mouse", RUN+="/usr/bin/lomoco -8"
|
It will set matching devices to a resolution of 800cpi every time you plug in a mouse.
[edit] Tips & Tricks
[edit] Open Text In Firefox/Mozilla Tab
Here's a nice little script you can bind to one of your mouse buttons with your window manager. It opens the currently selected text (usually a URL) in a new mozilla or firefox tab. Remove references to wmctrl if you don't like it changing your workspace:
| File: clipurl |
#!/bin/bash
# opens a new tab at selected URL in mozilla-like browser
#
# Copyright 2004 David Antliff <OMITdavid.antliffOMIT@OMITgmail.com>
# This program is distributed under the terms of the GPL version 2.
#
# Last changed:
# 20041207
# Where to find/open the browser
DISPLAY=:0.0
SCREEN=7
if test -z "$BROWSER"
then
BROWSER='/usr/bin/mozilla'
fi
# fix URLs that span multiple lines and may have injected spaces
# (e.g. Pine)
URL=`xclip -o | tr '\n' ' ' | sed 's/\s//g'`
echo clipurl: $URL
PING=`$BROWSER -remote 'ping()' 2>&1`
if test -z "$PING"
then
echo $BROWSER: opening new tab
wmctrl -s $SCREEN
$BROWSER -remote "openURL($URL,new-tab)" &
else
echo $BROWSER: starting new session
wmctrl -s $SCREEN
$BROWSER $URL &
fi
|
[edit] Command Line Mouse Speed
[edit] Change Mouse Hz
[edit] Mouse Cursor Tips
[edit] Other
[edit] Troubleshooting
[edit] Uncontrollable mouse in SDL apps
It seems that with evdev, DGA gets broken in SDL: mouse jumps and moves down-right all the time.
To fix this you have to add this to your xorg.conf :
| File: /etc/X11/xorg.conf |
Section "Module"
...
SubSection "extmod"
Option "omit xfree86-dga" # don't initialise the DGA extension
EndSubSection
...
EndSection
|

