# USB Mouse and Keyboard How-To

## Vlad

Installing a USB Mouse and/or Keyboard in Gentoo

Forward: The following document assumes that you are using at least a USB Mouse or Keyboard and have the ability to recompile the gentoo-sources kernel.  This document presents the installation of USB drivers in a "modular" form to better diagnose any problems that you may encounter.  When using a USB mouse and keyboard, however, it may be preferable to compile the USB drivers statically into the kernel.  If you have any further questions or problems, you may wish to read over the USB HID Configuration Guide from www.linux-usb.org before posting a question.

This document is broken down into three sections: 

1.	USB Mouse (only)

2.	USB Keyboard (only)

3.	USB Mouse & Keyboard

USB Mouse Howto:

1.  Enter your kernel configuration

```
cd /usr/src/linux

make menuconfig 
```

2.  Once in the configuration screen, scroll down to Input Core Support, and 

hit enter.

3.  Hit "m" for Input Core Support.  Scroll down to Mouse Support, and hit m.  Exit from this menu.

4.  Scroll down to USB support and hit enter.

5.  In USB Support, hit y at Support for USB.  Scroll down to "Preliminary USB device filesystem" and hit y.  Include either "UHCI (Intel PIIX4, VIA, ...) support" or "UHCI Alternate Driver (JE) Support" as modules (m).  Finally, include "USB Human Interface Device (full HID) support" as a module (m).  Include HID input layer support with y.

6.  Exit USB Support, then exit the menuconfig.  Now do "make dep && make clean bzImage modules modules_install".

7.  The following new modules will be created:

Modules Name..................................Path to modules

1a. UHCI (Intel PIIX4, VIA,...)............ /lib/modules/kernel-version/kernel/drivers/usb/usb-uhci.o

or

1b. UHCI Alternate Driver (JE) support      /lib/modules/kernel-version/kernel/drivers/usb/uhci.o

2.  USB Human Interface Device....... /lib/modules/kernel-3.  version/kernel/drivers/usb/hid.o

3.  Input Core Support..................... /lib/modules/kernel-version/kernel/drivers/input/input.o

4.  Mouse Support............................ /lib/modules/kernel-version/kernel/drivers/input/mousedev.o

8.  Be sure to mount your /boot partition and copy over the new kernel image!

9.  Edit your /etc/modules.autoload file and add the following lines:

```
input

mousedev

hid

usb-uhci (or uhci)
```

10.  Reboot your machine to test your new drivers.

11.  If everything goes well, your modules should all load ok.

12.  To ensure your mouse works in X, be sure to edit /etc/X11/XF86Config.  Here is an example:

```
Section "InputDevice"

# Identifier and driver

    Identifier  "Mouse1"

    Driver      "mouse"

    Option "Protocol"    "IMPS/2"

    Option "Device"      "/dev/input/mice"

    Option "ZAxisMapping"       "4 5"
```

Note: If /dev/input/mice doesn't work, try using /dev/usbmouse.  Thanks to rac for bringing this to my attention. :)

USB Keyboard Howto:

Note: When using a USB keyboard there are two things you should be aware of: First, if something goes wrong with loading your modules, your keyboard will not function. This is why I do NOT recommend loading your USB keyboard in modular form.  Secondly, many newer BIOS's include automatic support for USB keyboards (so you don't technically need to to build support for them).  Either way, BE SURE TO READ THIS DOCUMENT BEFORE PROCEEDING: http://www.linux-usb.org/USB-guide/x194.html

1.  Enter your kernel configuration

```
cd /usr/src/linux

make menuconfig 
```

2.  Once in the configuration screen, scroll down to Input Core Support, and hit enter.

3.  Hit "y" for Input Core Support.  Scroll down to Keyboard Support, and hit y.  Exit from this menu.

4.  Scroll down to USB support and hit enter.

5.  In USB Support, hit y at Support for USB.  Scroll down to "Preliminary USB device filesystem" and hit y.  Include "USB Human Interface Device (full HID) support" as a module (y).  Include HID input layer support with y.

6.  Exit USB Support, then exit the menuconfig.  Now do "make dep && make clean bzImage modules modules_install".

7.  No modules need to be loaded for your USB keyboard.

8.  Be sure to mount your /boot partition and copy over the new kernel image!

9.  Reboot your machine to test your new drivers.

USB Mouse and Keyboard Howto:

Note: When using a USB keyboard there are two things you should be aware of: First, if something goes wrong with loading your modules, your keyboard will not function. This is why I do NOT recommend loading your USB keyboard in modular form.  Secondly, many newer BIOS's include support for USB keyboards.  But this BIOS support is overridden when you load usb HID support. So you can start with keyboard support and lose it when loading one of the uhci modules or when loading a kernel with HID support built in. Better to build keyboard support into the kernel to be safe, since you can work without a mouse but not without a keyboard.  Either way, BE SURE TO READ THIS DOCUMENT BEFORE PROCEEDING: http://www.linux-usb.org/USB-guide/x194.html

1.  Enter your kernel configuration

```
cd /usr/src/linux

make menuconfig 
```

2.  Once in the configuration screen, scroll down to Input Core Support, and hit enter.

3.  Hit "y" for Input Core Support.  Scroll down to Keyboard Support and hit y.  Scroll down to Mouse Support and hit y.  Exit from this menu.

4.  Scroll down to USB support and hit enter.

5.  In USB Support, hit y at Support for USB.  Scroll down to "Preliminary USB device filesystem" and hit y.  Hit y at UHCI (Intel PIIX4, VIA, ...) support or UHCI Alternate Driver (JE) support, whichever you prefer.  Include "USB Human Interface Device (full HID) support" by hitting y.  Finally, hit y at HID input layer support.

6.  Exit USB Support, then exit the menuconfig.  Now do "make dep && make clean bzImage modules modules_install".

7.  No modules will be created during this installation; instead, everything will be statically compiled into the kernel.

8.  Be sure to mount your /boot partition and copy over the new kernel image!

9.  Reboot your machine to test your new drivers.

10.  If everything goes well, your USB mouse and keyboard should work flawlessly.

----------

## duff

Great little HOWTO! Now I can throw any my PS/2 to USB converter.   :Very Happy: 

Since this was dead last in the forum...upping for anyone who's yet to see this.

----------

## wing

if you look, /dev/usbmouse is a symlink to /dev/input/mice ...

----------

## zenhonky

bump

This guide is awesome.  Thank you very much.

----------

## rafeco

Thanks for the HOWTO, very useful indeed.

----------

## carl67lp

Thank you for an excellent HOW-TO.  I realized that I had my kernel properly configured but the modules were not loaded.  I loaded them up, and now am installing Mozilla on my Linux box as I type.

Thanks!

----------

## rac

The discussion that started with Youda's post about the intellimouse explorer has gone to Trouble with Intellimouse Explorer.  Please don't post support questions to threads in Documentation, TIps and Tricks.

----------

## rac

mawst's question about gpm has gone to GPM + USB Mouse.  Please don't post support questions to threads in Documentation, Tips and Tricks.

----------

## TilTNimpuS

thks guy !

----------

## Kreek

Wish I'd read this post about a week ago!  :Wink: 

Oh well! I learned a lot doing it on my own!!!   :Very Happy:   :Smile:   :Very Happy: 

----------

## Nakke

Now tell me how to use a usb keyboard in Grub/Lilo.   :Confused: 

----------

## duff

 *Nakke wrote:*   

> Now tell me how to use a usb keyboard in Grub/Lilo.  

 

Check your BIOS.  That has nothing to do with Linux.

----------

## Scorp

LILO sees my keyboard, I think my BIOS sees my keyboard, yet linux doesn't.... I'm compiling support in now. Thanks for the great how-to.

----------

## static

 :Cool: 

Just re-reading this for the first time in about 8 months (it's been reworked nicely) and I was curious - did gentoo do something to fix usb mice working when support is compiled right into the kernel?? 'Cause the mouse only section still says to use modules as it used to, but the keyboard & mouse section implies the mouse will work if its all compiled right in, which never used to work.

----------

## se-reeh

Thanks! It works with my Logitech Optical Mouse (M-BJ58) connected via USB. Great HowTo. Thanks a lot!  :D

----------

## Joe_Bogarde

Delightful, wonderful, very helpful.

----------

## genttoo_ed

I have recently installed the Stage 3 , binary version of Gentoo 1.4.

Some of this information on the mouse is not correct with my installation.

There were no /lib/modules/dirvers//input/* modules. Just the joystick, nevertheless the mouse worked.

----------

## AsianInvasion

I am trying to get Mandrake 9.1 to recognize my USB keyboard.  I opened a terminal(Gnome) and typed:

cd /usr/src/linux-2.4.x

make menuconfig

After i type that i get a message that says "No rule to make target 'menuconfig'. Stop.  what does that mean? and how can i fix it and run menuconfig.

Thanks Alot.

----------

## AsianInvasion

I fixed the error i posted before, by installing the kernel-source-2.4.21-0.13mdk.i586.rpm.

but it still didn't work. I'm thinking i didn't mount the /boot correctly. or i didn't copy the kernel image. can someone explain how to do these to in depth? thank you.

as you can tell i am a newbie. thanks again

----------

## AsianInvasion

I fixed the error i posted before, by installing the kernel-source-2.4.21-0.13mdk.i586.rpm.

but it still didn't work. I'm thinking i didn't mount the /boot correctly. or i didn't copy the kernel image. can someone explain how to do these to in depth? thank you.

as you can tell i am a newbie. thanks again

----------

## AsianInvasion

I did what the first person said to do, and now i get the num lock light to come on, on my usb keyboard, but it still won't type. so i know i'm making progress, but does anybody know what else to do? thanks

----------

## xjumper84

this did not work, and now my laptop doesn't work

----------

## Jazz

DOH !!! SUCH A BEA-AA-U-TIFUL guide !!!!

Why is it not in the Gentoo official Guides ???? (*hint*)

Well looking forward to it !!

Bye,

Jassi

----------

## To

Great how-too, thanx  :Wink: 

I only had a problem cause my nforce2 motherboard uses ohci instead of uhci. Maybe ppl should try both options ( without having the other one selected, not even has a module... ).

Tó

----------

## dredd

hi

nice little how-to.... I've did all the steps as described, but it won't load the modules input, mousedev and usb-uhci. seems like i cannot find them in /lib/modules/linux-2.4.20-gentoo-r8/drivers/input/

what the hell am I doing wrong? when I do a locate for those modules I can find them in 

/usr/src/linux-2.4.20-gentoo-r8/drivers/input/ but well.... that doesnt help me...

any hints what I have to do?

thanks in advance...

----------

## castra

I'm runing gentoo on my laptop Fujitsu-Siemens Amilo and keyboard

not working after I boot woth my kernel which is 2.4.23 stable.

Works OK with LIVECD but not ( as I said ) with build kernel.

Added suport as you wrote but same results. Any ideas guys ?

----------

## dkaplowitz

Great thread! Thank you so much for posting it, Vlad. You've really helped me.

----------

## juliancoccia

dredd, have you done steps 2 to 5 exactly as explained ? Then, have you done make modules modules_install as explained on step 6 ?

----------

## juliancoccia

Quick comment/questions:

/etc/modules.autoload does not exist. Instead there is a /etc/autoload.d directory containing subdirs for different kernel families.

I added the modules to the kernel-2.4 as it is the one I am using. 

The questions are. 

Do I have to run modules-update afterwards ? Or this only take effect on bootup ? 

Do I also have to add the modules to /etc/modules.conf ?

Thanks

Julian

----------

## dredd

well, as fas as i can remember yes.. but in the meantime I have upgraded to a test kernel 2.6 and there it works fine.... waiting for official 2.6 gentoo sources...  :Smile: 

phil

----------

## juliancoccia

Well, I am having a different problem. I can't laod usb-uhci. This is what i get:

```
# modprobe usb-uhci

/lib/modules/2.4.22-gentoo-r2/kernel/drivers/usb/usb-uhci.o: init_module: No such device

Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters.

You may find more information in syslog or the output from dmesg

/lib/modules/2.4.22-gentoo-r2/kernel/drivers/usb/usb-uhci.o: insmod /lib/modules/2.4.22-gentoo-r2/kernel/drivers/usb/usb-uhci.o failed

/lib/modules/2.4.22-gentoo-r2/kernel/drivers/usb/usb-uhci.o: insmod usb-uhci failed
```

I tried disabling input, using usbcore as a module and got the same error. I previously had debian running on this machine with usbcore, usb-uhci hid and mousedev (no input) and did not have any problems.

There is another user having a similar problem here:

https://forums.gentoo.org/viewtopic.php?t=53537

How do I configure the IO an IRQ parameters ?

----------

## juliancoccia

Finally decided to give it another shot and this time it worked ! Here is my recipe:

This time I went with the UHCI Alternate Driver (JE) (which generates uhci.o instead of usb-uhci.o). 

Do not add "uhci" to /etc/modules.autoload.d/kernel-2.4 and reboot, otherwise I get e segfault on boot up.

Mouse connects to /dev/input/mice automatically. 

I am running on an IBM Thinkpad i Series 1300 model 1171 370. Here is my lsmod result:

```
# lsmod

Module                  Size  Used by    Not tainted

usb-storage            24184   0  (unused)

prism2_usb             68360   2

p80211                 18904   0  [prism2_usb]

usbmouse                2076   0  (unused)

soundcore               4580   0  (unused)

ac97_codec             13420   0  (unused)

i810_audio             27240   1

hid                    14920   0  (unused)

mousedev                4344   1

input                   3904   0  [usbmouse hid mousedev]

```

----------

## Phant0m51

Alright, finally got my mouse set up after rebuilding the kernel close to 10 times...

Tip for nForce 2 users, use OHCI instead of UHCI to save yourself alot of trouble.

Vlad:  Maybe you should edit your How-To and tell the nForce 2 users to enable EHCI and OHCI instead of UHCI.  I know I'm not the first person to say that nForce 2 uses OHCI, but you didn't reflect in your How-To that we should use OHCI.

----------

## sofcik

I have USB Logitech pilot mouse , i uses kernel 2.6.3  and my mouse works but the scroll not, i did ZAxisMapping "5 6" in xf86config file but it doesnt work ,testing with   cat /dev/input/mice gives positive result -  every buuton and scroll give me an answer at console  :Sad: 

----------

## mathboy

 :Smile:  Nice guide, thank you!

My mouse is now working well on my laptop, together with the little pointing device.  :Smile:  I was unable to get my PS/2 keyboard (connected via a PS/2 to USB converter) to work though. It shows up in my system logs when I plug it in (see below), and I've got the kernel configured correctly I think. Anything else I can check? It worked from the LiveCD.   :Confused: 

May  4 08:58:07 greensong hub.c: new USB device 00:07.2-1, assigned 

address 7

May  4 08:58:07 greensong input: USB HID v1.10 Keyboard [Composite USB 

PS2 Converter USB to PS2 Adaptor  v1.12] on usb1:7.0

May  4 08:58:07 greensong input: USB HID v1.10 Mouse [Composite USB PS2 

Converter USB to PS2 Adaptor  v1.12] on usb1:7.1

----------

## Kaboosh

Just a heads-up that the "uhci" module (not usb-uhci) is experimental and less thoroughly tested.  I personally had problems when using high bandwidth devices (such as a printer/scanner) and the mouse would jump around the screen and finally stop working.

If any of this sounds familiar use usb-uhci.

Cheers!

----------

## loxety

this should be in the docs section.. not just the forums

----------

## DeftEp

I realize this is a really old post but i just tried it now..  i am running gentoox on my xbox and was wanting mouse/keyboard support.. i did all of this but im not sure i did it all right.. since i am not familiar with linux (took some minor courses) i think i need help..  i copyied the bzImage from the /usr/src/linux and put it into my /boot partition changed the boot loader and it all seems to load.. but the problem is things are failing to load now..  my xpad (the xbox controller) fails to load and all the things i added into the kernel fail to load aswell.. i think anyway.. i could only catch a few as the screen scrolls so fast.. any suggestions?..

----------

## DeftEp

i get a make dep error now when i am trying to re do this.

make[3]: *** [_sfdep_atm] Error 2 

> > make[3]: Leaving directory `/usr/src/linux-2.4.0-test10/drivers' 

> > make[2]: *** [fastdep] Error 2 

> > make[2]: Leaving directory `/usr/src/linux-2.4.0-test10/drivers' 

> > make[1]: *** [_sfdep_drivers] Error 2 

> > make[1]: Leaving directory `/usr/src/linux-2.4.0-test10' 

> > make: *** [dep-files] Error 2 

this isnt my print screen but the error lines are what i am getting.. what can i do to fix this?

----------

## prvkd

Just a little fyi... I was having a similar problem, which is why i read this forum. and it turned out that the 1.1 usb was working fine.. but my ports were 2.0 so... you can also do this:

In your kernel makeconfig menu under USB Support there is an option to enable EHCI-HCD (USB 2.0) Support. Enable this as a module by hitting M, then..

```
make dep && make modules modules_install

modprobe ehci-hcd

```

----------

## cj5

I have a Logitech IFeel USB mouse, and I have followed these instructions to the tee, or at least tried my best. First off, these instruction are not in compliance with other kernel releases (other than the one used in this tutorial, of which we have no idea what it is). Half the menu options in the 'make menuconfig' session don't even exist in my kernel config (2.6.12-gentoo-r6). I am at my wits end with this dammed mouse. I have everything else working except it. Any detailed or corrected information would be greatly appreciated.

CJ...

----------

## Headrush

 *cj5 wrote:*   

> First off, these instruction are not in compliance with other kernel releases (other than the one used in this tutorial, of which we have no idea what it is). Half the menu options in the 'make menuconfig' session don't even exist in my kernel config (2.6.12-gentoo-r6).CJ...

 

I have this kernel also and they all exist. You probably have a another option disabled that is blocking some of the options in the how-to. Is plug and play support enabled?

----------

## Kaboosh

 *cj5 wrote:*   

> I have a Logitech IFeel USB mouse, and I have followed these instructions to the tee, or at least tried my best. First off, these instruction are not in compliance with other kernel releases (other than the one used in this tutorial, of which we have no idea what it is). Half the menu options in the 'make menuconfig' session don't even exist in my kernel config (2.6.12-gentoo-r6). I am at my wits end with this dammed mouse. I have everything else working except it. Any detailed or corrected information would be greatly appreciated.
> 
> CJ...

 

I have the exact same mouse and have no problems (other than the useless "iFeel" functions not working).  If you need any info about my kernel setup, hotplug config, etc... just message me.

Cheers!

----------

## Parasietje

Can anybody help me with the following?

I use an USB keyboard and mouse. As such, I have USBHID compiled into my kernel. But some events from my remote control are also mapped as buttons. The multimedia buttons on my keyboard are mapped as mouse clicks.

Now, is it possible to exclude some devices from USBHID? I used the event interface for interacting with the multimedia buttons and the remote.

If not, then I'll switch to evdev support for my X-Windows. Not being able to use console is only a small pain.

No, I cannot use BIOS support, because my motherboard USB ports are broken and I use a seperate PCI card.

----------

## cp_tar

OK, can anyone help me here:

I'm installing Gentoo on my father's laptop (Acer Aspire 3002) and he and his gf rely heavily on their USB mouse, which I cannot get to work.

It worked in the installation (gpm recognized both the mouse and the trackpad); I compiled USB support in the kernel (not as a module), everything seems to be in order; however, /dev/input/mice seems only to point to the trackpad, and I don't really know what to do.

If the mouse doesn't work, neither will the mp3 player and the camera...

Especially since usbview doesn't seem to see the mouse when I connect it, so I guess I did make a mistake somewhere...

----------

