Gentoo Wiki ArchivesGentoo Wiki


Note: If your using Xorg 7.3 (>=xorg-server-1.4) and newer, follow this guide.





Video Cards

OpenGL Compositing



Logitech G5 Gaming Laser Mouse

This article is outdated. Please update this article with new information to match with the current portage tree and gentoo releases, and remove information about really old versions of software, then remove {{Update}} from this article's source.



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 for more information regarding automatic generation of one.

Monolithic XOrg builds 6.8 and lower have information contained in Legacy Monolithic and Legacy Monolithic/Individual Configurations. See that information for historical purposes only.

The following mice need to be reviewed and added, but will likely work:

This guide is now loosely based on one from the Gentoo Forums written by meowsqueak. Here's a link to that thread.

XOrg 6.9 or Greater, evdev, and USB Mice

Credit to 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


Now run update-modules to commit the changes to /etc/modules.autoload.d/kernel-2.6.

Next, you'll need to have modular XOrg's evdev support installed:

emerge --ask --verbose 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:


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.

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"

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"

Restart XOrg and try things out. Your mouse should now be working!

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:


Upgrading to XOrg 7.3 or higher

The value "AlwaysCore" in Input device is deprecated. The following must now be used in ServerLayout:

File: /etc/X11/xorg.conf
InputDevice "Mouse0" "SendCoreEvents"

For more information, check the Gentoo Forums:

Individual Mouse Configurations

This section has been moved to Individual Configurations. Please post if your mouse requires any special xmodmap, xinput, or other settings to function properly.

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"

Section "InputDevice"
        Identifier  "Mouse1"
        Driver      "evdev"
        Option      "Device" "/dev/input/event1"

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

Restart your X server to use the new configuration.

Button Remapping

evdev Options

FIXME: Explain how to use evdev xorg.conf options to remap buttons.


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


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
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" ]
    /usr/bin/xmodmap "$HOME/.Xmodmap"
Note: Touching files in ${kdedir} may mean merging configuration files on a point release, or copying these changes to new files on a major release.

If you'd rather not touch files in ${kdedir}, then have each user create a ~/.xprofile file containing the following:

File: ~/.xprofile
/usr/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5"


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


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.

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 --ask --verbose 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

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"
Note: This method is found to work with the "mouse" driver and trackballs, however is not known to work with evdev.


Tips & Tricks

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
# opens a new tab at selected URL in mozilla-like browser
# Copyright 2004 David Antliff <>
# This program is distributed under the terms of the GPL version 2.
# Last changed:
# 20041207

# Where to find/open the browser

if test -z "$BROWSER"

# 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"
    echo $BROWSER: opening new tab
    wmctrl -s $SCREEN
    $BROWSER -remote "openURL($URL,new-tab)" &
    echo $BROWSER: starting new session
    wmctrl -s $SCREEN


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
Retrieved from ""

Last modified: Mon, 15 Sep 2008 15:22:00 +1000 Hits: 193,857

Created by, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.