4.4 Keyboards and mice

4.4.1. Does FreeBSD support my USB keyboard?
4.4.2. I have an unusual bus mouse. How do I set it up?
4.4.3. How do I use my PS/2 (“mouse port” or “keyboard”) mouse?
4.4.4. Is it possible to use a mouse in any way outside the X Window system?
4.4.5. How do I cut and paste text with a mouse in the text console?
4.4.6. My mouse has a fancy wheel and buttons. Can I use them in FreeBSD?
4.4.7. How do I use the mouse/trackball/touchpad on my laptop?
4.4.8. How do I use my delete key in sh and csh?

4.4.1. Does FreeBSD support my USB keyboard?

FreeBSD supports USB keyboards out-of-the-box. Enable USB support in /etc/rc.conf.

Once you have USB keyboard support enabled on your system, the AT keyboard becomes /dev/kbd0 and the USB keyboard becomes /dev/kbd1, if both are connected to the system. If there is the USB keyboard only, it will be /dev/ukbd0.

If you want to use the USB keyboard in the console, you have to explicitly tell the console driver to use the existing USB keyboard. This can be done by running the following command as a part of system initialization.

# kbdcontrol -k /dev/kbd1 < /dev/ttyv0 > /dev/null

Note that if the USB keyboard is the only keyboard, it is accessed as /dev/ukbd0, thus, the command should look like:

# kbdcontrol -k /dev/ukbd0 < /dev/ttyv0 > /dev/null

/etc/rc.i386 is a good place to add the above command.

Once this is done, the USB keyboard should work in the X environment as well without any special settings.

Hot-plugging and unplugging of the USB keyboard may not work quite right yet. We recommend connecting the keyboard before starting the system and leaving it connected until the system is shutdown to avoid troubles.

See the ukbd(4) manual page for more information.

4.4.2. I have an unusual bus mouse. How do I set it up?

FreeBSD supports the bus mouse and the InPort bus mouse from such manufacturers as Microsoft, Logitech and ATI. The GENERIC kernel does not include the device driver. To build a custom kernel with the bus mouse driver, add the following line to the kernel config file:

device mse0 at isa? port 0x23c irq5

Bus mice usually come with dedicated interface cards. These cards may allow you to set the port address and the IRQ number other than shown above. Refer to the manual of your mouse and the mse(4) manual page for more information.

4.4.3. How do I use my PS/2 (“mouse port” or “keyboard”) mouse?

The PS/2 mouse is supported out-of-the-box. The necessary device driver, psm, is included in the kernel.

If your custom kernel does not have this, add the following line to your kernel configuration and compile a new kernel.

device psm0 at atkbdc? irq 12

Once the kernel detects psm0 correctly at boot time, make sure that an entry for psm0 exists in /dev. You can create this entry by typing:

# cd /dev; sh MAKEDEV psm0

when logged in as root.

Note: You can omit this step if you are running FreeBSD 5.0-RELEASE or newer with devfs(5) enabled, since the proper device nodes will be created automatically under /dev.

4.4.4. Is it possible to use a mouse in any way outside the X Window system?

If you are using the default console driver, syscons(4), you can use a mouse pointer in text consoles to cut & paste text. Run the mouse daemon, moused(8), and turn on the mouse pointer in the virtual console:

# moused -p /dev/xxxx -t yyyy
# vidcontrol -m on

Where xxxx is the mouse device name and yyyy is a protocol type for the mouse. The mouse daemon can automatically determine the protocol type of most mice, except old serial mice. Specify the auto protocol to invoke automatic detection. If automatic detection does not work, see the moused(8) manual page for a list of supported protocol types.

If you have a PS/2 mouse, just add moused_enable="YES" to /etc/rc.conf to start the mouse daemon at boot-time. Additionally, if you would like to use the mouse daemon on all virtual terminals instead of just the console, add allscreens_flags="-m on" to /etc/rc.conf.

When the mouse daemon is running, access to the mouse must be coordinated between the mouse daemon and other programs such as X Windows. Refer to the FAQ Why does my mouse not work with X? for more details on this issue.

4.4.5. How do I cut and paste text with a mouse in the text console?

Once you get the mouse daemon running (see the previous section), hold down the button 1 (left button) and move the mouse to select a region of text. Then, press the button 2 (middle button) to paste it at the text cursor. Pressing button 3 (right button) will “extend” the selected region of text.

If your mouse does not have a middle button, you may wish to emulate one or remap buttons using mouse daemon options. See the moused(8) manual page for details.

4.4.6. My mouse has a fancy wheel and buttons. Can I use them in FreeBSD?

The answer is, unfortunately, “It depends”. These mice with additional features require specialized driver in most cases. Unless the mouse device driver or the user program has specific support for the mouse, it will act just like a standard two, or three button mouse.

For the possible usage of wheels in the X Window environment, refer to that section.

4.4.7. How do I use the mouse/trackball/touchpad on my laptop?

4.4.8. How do I use my delete key in sh and csh?

For the Bourne Shell, add the following lines to your .shrc. See sh(1) and editrc(5).

bind ^? ed-delete-next-char # for console
bind ^[[3~ ed-delete-next-char # for xterm

For the C Shell, add the following lines to your .cshrc. See csh(1).

bindkey ^? delete-char # for console
bindkey ^[[3~ delete-char # for xterm

For more information, see this page.

This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.