# Odd behavior with USB keyboard



## `Orum (Feb 23, 2017)

I'm having some strange behavior with my USB keyboard in FreeBSD.  After booting, slim loads, and when I try to enter my user name, one of two things happens; either the pressed key doesn't appear, or it will act as though the key is being held down and repeat that character several times, even though the key isn't being held down.

I normally would be suspicious of the hardware, but in this case, I think the hardware is good.  Why?  I have no issues with the keyboard when booting to Windows 7 (the machine dual-boots), or using the keyboard in the BIOS or the FreeBSD boot loader.  I also have no problems with the keyboard when booting to single-user mode, which makes me suspicious that this problem is somehow related to xorg or dbus.  However, I'm far from an expert when it comes to those topics, so I'll dump as much information as I can here, and wait for your suggestions.

First of, the relevant parts of the machine and dmesg:

```
# uname -a
FreeBSD ruby 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64

# dmesg|grep ^acpi0
acpi0: <DELL PE_SC3> on motherboard
acpi0: Power Button (fixed)

# dmesg|grep ^pcib0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pcib0: _OSC returned error 0x10

# dmesg|grep ^pci0
pci0: <ACPI PCI bus> on pcib0
pci0: <simple comms> at device 22.0 (no driver attached)

# dmesg|grep ^ehci1
ehci1: <EHCI (generic) USB 2.0 controller> mem 0xf7207000-0xf72073ff irq 23 at device 29.0 on pci0

# dmesg|grep ^usbus2
usbus2: EHCI version 1.0
usbus2 on ehci1
usbus2: 480Mbps High Speed USB v2.0

# dmesg|grep "CM Storm"
ugen2.5: <CM Storm> at usbus2
ukbd1: <CM Storm QuickFire Rapid keyboard, class 0/0, rev 1.10/0.01, addr 5> on usbus2
ums1: <CM Storm QuickFire Rapid keyboard, class 0/0, rev 1.10/0.01, addr 5> on usbus2
```
The only odd thing there is I see it's being attached to the ums(4) driver, which I thought was for mice, not keyboards.  Other things that might be relevant:

```
# pciconf -lcbv ehci1
ehci1@pci0:0:29:0:      class=0x0c0320 card=0x844d1043 chip=0x1c268086 rev=0x05 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '6 Series/C200 Series Chipset Family USB Enhanced Host Controller'
    class      = serial bus
    subclass   = USB
    bar   [10] = type Memory, range 32, base 0xf7207000, size 1024, enabled
    cap 01[50] = powerspec 2  supports D0 D3  current D0
    cap 0a[58] = EHCI Debug Port at offset 0xa0 in map 0x14
    cap 13[98] = PCI Advanced Features: FLR TP

# usbconfig -d ugen2.5 dump_curr_config_desc
ugen2.5: <QuickFire Rapid keyboard CM Storm> at usbus2, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)


 Configuration index 0

    bLength = 0x0009
    bDescriptorType = 0x0002
    wTotalLength = 0x003b
    bNumInterfaces = 0x0002
    bConfigurationValue = 0x0001
    iConfiguration = 0x0000  <no string>
    bmAttributes = 0x00a0
    bMaxPower = 0x0032

    Interface 0
      bLength = 0x0009
      bDescriptorType = 0x0004
      bInterfaceNumber = 0x0000
      bAlternateSetting = 0x0000
      bNumEndpoints = 0x0001
      bInterfaceClass = 0x0003  <HID device>
      bInterfaceSubClass = 0x0001
      bInterfaceProtocol = 0x0001
      iInterface = 0x0000  <no string>

      Additional Descriptor

      bLength = 0x09
      bDescriptorType = 0x21
      bDescriptorSubType = 0x10
       RAW dump:
       0x00 | 0x09, 0x21, 0x10, 0x01, 0x00, 0x01, 0x22, 0x3e,
       0x08 | 0x00

     Endpoint 0
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0081  <IN>
        bmAttributes = 0x0003  <INTERRUPT>
        wMaxPacketSize = 0x0008
        bInterval = 0x0001
        bRefresh = 0x0000
        bSynchAddress = 0x0000


    Interface 1
      bLength = 0x0009
      bDescriptorType = 0x0004
      bInterfaceNumber = 0x0001
      bAlternateSetting = 0x0000
      bNumEndpoints = 0x0001
      bInterfaceClass = 0x0003  <HID device>
      bInterfaceSubClass = 0x0001
      bInterfaceProtocol = 0x0002
      iInterface = 0x0000  <no string>

      Additional Descriptor

      bLength = 0x09
      bDescriptorType = 0x21
      bDescriptorSubType = 0x10
       RAW dump:
       0x00 | 0x09, 0x21, 0x10, 0x01, 0x00, 0x01, 0x22, 0xa6,
       0x08 | 0x00

     Endpoint 0
        bLength = 0x0007
        bDescriptorType = 0x0005
        bEndpointAddress = 0x0082  <IN>
        bmAttributes = 0x0003  <INTERRUPT>
        wMaxPacketSize = 0x0008
        bInterval = 0x0001
        bRefresh = 0x0000
        bSynchAddress = 0x0000
```
And last but not least, my rc.conf on that machine.  Note I am *not* running hald as I believe dbus is sufficient.  If you think otherwise, I'll defer to your judgement.

```
# rc.conf
hostname="ruby"
zfs_enable="YES"

kld_list="nvidia-modeset"

sendmail_enable="NONE"
dumpdev="NO"
syslogd_flags="-ss"
clear_tmp_enable="YES"

ifconfig_re0="DHCP"

powerd_enable="YES"
dbus_enable="YES"
slim_enable="YES"

sshd_enable="YES"
```
Edit:  Whoops, forgot to include the relevant parts of Xorg.0.log

```
[    38.326] (II) config/devd: probing input devices...
[    38.326] (II) config/devd: adding input device (null) (/dev/kbdmux)
[    38.326] (II) LoadModule: "kbd"
[    38.326] (II) Loading /usr/local/lib/xorg/modules/input/kbd_drv.so
[    38.335] (II) Module kbd: vendor="X.Org Foundation"
[    38.335]    compiled for 1.18.4, module version = 1.9.0
[    38.335]    Module class: X.Org XInput Driver
[    38.335]    ABI class: X.Org XInput driver, version 22.1
[    38.335] (II) Using input driver 'kbd' for 'kbdmux'
[    38.336] (**) kbdmux: always reports core events
[    38.336] (**) kbdmux: always reports core events
[    38.336] (**) Option "Protocol" "standard"
[    38.336] (**) Option "XkbRules" "base"
[    38.336] (**) Option "XkbModel" "pc105"
[    38.336] (**) Option "XkbLayout" "us"
[    38.336] (**) Option "config_info" "devd:kbdmux"
[    38.336] (II) XINPUT: Adding extended input device "kbdmux" (type: KEYBOARD,
 id 6)
[    38.336] (II) config/devd: kbdmux is enabled, ignoring device ukbd0
[    38.336] (II) config/devd: kbdmux is enabled, ignoring device ukbd1
[    38.336] (II) config/devd: kbdmux is enabled, ignoring device atkbd0
```


----------

