Notes on the USB keyboard driver in FreeBSD 4.0-CURRENT 24 March 1999. Kazutaka YOKOTA, yokota@FreeBSD.ORG * How to configure the USB keyboard driver ---------------------------- Modify your kernel configuration file as follows: 1) Add the following lines to your kernel configuration file. controller uhci0 # UHCI controller controller usb0 device ukbd options "KBD_INSTALL_CDEV" If you have a OHCI controller rather than UCHI controller, the first line should be: controller ohci0 # OHCI controller See LINT and GENERIC for more details. 2) Go to /dev and make device nodes kbd*. ./MAKEDEV kbd0 kbd1 3) Run `config' and rebuild the kernel. * How to use ---------------------------------------------------------- You can use the USB keyboard together with the AT keyboard or use the USB keyboard alone as the sole console keyboard. Case 1: Using the USB keyboard and the AT keyboard together When the kernel probes devices, the USB keyboard driver should be recognized and attached as /dev/kbd1. /dev/kbd0 will be the AT keyboard. The following command will print brief information about the USB keyboard. kbdcontrol -i < /dev/kbd1 You can load a keymap as you do on the AT keyboard by typing, kbdcontrol -l _a_keymap_file_ < /dev/kbd1 You can change the typematic rate: kbdcontrol -r fast < /dev/kbd1 You can `cat' the USB keyboard cat /dev/kbd1 See letters are echoed, and NumLock/CapsLock/ScrollLock LEDs work correctly. Note that you cannot `cat' or print information about the AT keyboard, /dev/kbd0, in the above way, because it is exclusively used by syscons. But, the following command will work, assuming you are in a vty. kbdcontrol -i or kbdcontrol -i < /dev/tty You can tell syscons to use the USB keyboard and release the AT keyboard. Assuming you are at a vty and typing from the AT keyboard, run kbdcontrol -k /dev/kbd1 Now, your AT keyboard won't echo anything; the USB keyboard is your console keyboard. If you are typing the above command at a serial or network terminal, you have to redirect stdin in order to make the above command to take effect: kbdcontrol -k /dev/kbd1 < /dev/ttyvN Where N is one of vtys. As the AT keyboard has been released by syscons, you can now `cat' it. cat /dev/kbd0 The USB keyboard should provide everything the AT keyboard does. You can change the typematic rate: kbdcontrol -r fast You can switch vtys by hitting Alt-Fn, break to debugger, back scroll the screen buffer,... In order to get the AT keyboard back to syscons, kbdcontrol -k /dev/kbd0 Case 2: Using the USB keyboard as the only keyboard The console driver syscons uses the first available keyboard at start-up. It is usually the AT keyboard. But, you can use the USB keyboard as the sole console keyboard. If you remove the AT keyboard driver atkbd0 from the kernel configuration file, the USB keyboard will become /dev/kbd0 and you can make syscons use it. However, because of the order of device initialization, the USB keyboard will be detected AFTER the console driver initializes itself and you have to explicitly tell the console driver to use the existence of the USB keyboard. This can be done in one of the following two ways: a) Run the following command as a part of system initialization. kbdcontrol -k /dev/kbd0 < /dev/ttyv0 > /dev/null Note that as the USB keyboard is the only keyboard, it is accessed as /dev/kbd0. /etc/rc.i386 is a good place to add the above command. b) Specify a flag to the console driver so that it will periodically look for a keyboard. device sc0 at isa? tty flags 0x100 ~~~~~~~~~~~ With the above flag, the console driver will try to detect any keyboard in the system if it didn't detect one while it was initialized at boot time. * Configuration options. -------------------------------------------- The following options are available for the USB keyboard driver. UKBD_DFLT_KEYMAP Specify a keymap to be used as the default, built-in keymap. For example, options "UKBD_DFLT_KEYMAP" makeoptions "UKBD_DFLT_KEYMAP=fr.iso" The above lines will put the French ISO keymap in the atkbd driver. You can specify any keymap in /usr/share/syscons/keymaps with this option. KBD_DISABLE_KEYMAP_LOADING Don't allow the user to change the keymap. Note that this options also has effect on the AT keyboard driver `atkbd'. Example: options "KBD_DISABLE_KEYMAP_LOADING" * Notes -------------------------------------------------------------- Note 1: The USB keyboard cannot be used in UserConfig at the moment. It MAY be used in the boot loader if the BIOS has the option for "the USB keyboard support" or "legacy keyboard support". I am investigating how this issue should be solved best... Note 2: I expect the USB keyboard "almost" works with the XFree86 servers without any special settings when syscons is using the USB keyboard. Please report any problems you encounter. Note 3: The USB keyboard MAY work with PCVT. But, I haven't tested yet. As kbdcontrol is for syscons, and not for PCVT, you have to make the USB keyboard the sole keyboard in the system by disabling atkbd0 in order to force PCVT to use the USB keyboard. <>