# USB Keyboard not working properly (10.2)



## ajohnl (Apr 3, 2016)

I'm interested in using FreeBSD on my desktop, but the keyboard might be a problem. During installation I thought the keyboard wasn't detected at all but after some testing through virtual machines and connecting the keyboard to a FreeBSD laptop, I've found out that 95% of the keys don't do anything, and the ones that do input wrong keys (w=a, r=3, etc).


The keyboard works perfectly on the latest Linux kernels (however, older distros wouldn't make use of the caps lock and num lock lights), and right now I'm on Funtoo Linux, with kernel version 4.5. The keyboard is a "keep out f85", but registers as "Holtec USB gaming keyboard".

Thanks in advance.


----------



## wblock@ (Apr 3, 2016)

Use usbconfig(8) to determine the device number of the keyboard, ugen_X_._Y_.

Then add a quirk for that device:
`usbconfig -d ugen[I]0[/I].[I]3[/I] add_quirk UQ_KBD_BOOTPROTO`

Adapted from the quirk for a Corsair gaming keyboard in PR 193279.  If it works, it can be added permanently.


----------



## ajohnl (Apr 3, 2016)

wblock@ said:


> Use usbconfig(8) to determine the device number of the keyboard, ugen_X_._Y_.
> 
> Then add a quirk for that device:
> `usbconfig -d ugen[I]0[/I].[I]3[/I] add_quirk UQ_KBD_BOOTPROTO`
> ...



Ok, I tested it in a virtual machine and input the command with my phone over ssh, after unplugging the keyboard and plugging it back in it works perfectly. Now, how would I go about adding this permanently? To install it on my desktop I'll see if I can borrow a keyboard, but I wouldn't want to borrow it every time I boot 

Thanks


----------



## wblock@ (Apr 3, 2016)

Please show the output of `usbconfig -d ugen[I]0[/I].[I]3[/I] dump_device_desc`.

Short-term, the quirk can be set in /boot/loader.conf.  Longer-term, it can be added to the operating system.


----------



## ajohnl (Apr 3, 2016)

wblock@ said:


> Please show the output of `usbconfig -d ugen[I]0[/I].[I]3[/I] dump_device_desc`.
> 
> Short-term, the quirk can be set in /boot/loader.conf.  Longer-term, it can be added to the operating system.



http://imgur.com/EziXwF4


----------



## wblock@ (Apr 3, 2016)

This line is the equivalent when placed in /boot/loader.conf:

```
hw.usb.quirk.0="0x04d9 0xa030 0 0xffff UQ_KBD_BOOTPROTO"
```

Test that.  If it works, please enter a new bug report with that information, just like PR 193279, and please add me to the Cc list on that bug.


----------



## ajohnl (Apr 4, 2016)

wblock@ said:


> This line is the equivalent when placed in /boot/loader.conf:
> 
> ```
> hw.usb.quirk.0="0x04d9 0xa030 0 0xffff UQ_KBD_BOOTPROTO"
> ...



The problem still persists even with the the loader.conf modification, I have loader.rc set to use loader.conf (as the man page for loader.conf() said). The loader.conf is basically an empty file with the line you told me to use, not sure if it's supposed to look like that.

Also, I've been looking into the corsair solution, they mention something about editing these files:
/sys/dev/usb/quirk/usb_quirk.c
/sys/dev/usb/usbdevs

But I don't really understand how, I tried adding

```
USB_QUIRK(HOLTEK, F85, 0x0000, 0xffff, UQ_KBD_BOOTPROTO),
```
 to the former, and 
	
	



```
product HOLTEK F85     0xa030 Holtek keyboard
```
 to the latter without success.

Lastly, not sure if it's relevant but on boot the keyboard is detected as "HOLTEK USB GAMING KEYBOARD", and it makes me wonder if it has "product" and "vendor" set somewhere else than the files I mentioned.


----------



## Phishfry (Apr 4, 2016)

I don't mean to interrupt the excellent support of Mr. Block...

But any changes to those two files will require a kernel recompile to take effect. They are source files.
https://www.freebsd.org/doc/handbook/kernelconfig-building.html


----------



## ajohnl (Apr 4, 2016)

Phishfry said:


> I don't mean to interrupt the excellent support of Mr. Block...
> 
> But any changes to those two files will require a kernel recompile to take effect. They are source files.
> https://www.freebsd.org/doc/handbook/kernelconfig-building.html



OK, so I can just follow normal commands and it will automatically include my new configuration?


----------



## Phishfry (Apr 4, 2016)

Yes. I usually backup the original source file (usbdev ect...) before editing..


----------



## wblock@ (Apr 4, 2016)

ajohnl said:


> The problem still persists even with the the loader.conf modification, I have loader.rc set to use loader.conf (as the man page for loader.conf() said).


There is no reason to modify or touch loader.rc for this.  If you changed that file, please restore it.

I would find out what the problem is with the dynamic setting before modifying the source.


----------



## ajohnl (Apr 4, 2016)

Phishfry said:


> Yes. I usually backup the original source file (usbdev ect...) before editing..



Tested it in a virtual machine and it works perfectly now 
Also, FreeBSD kernel configuration is a lot less tedious than in Gentoo, I'm very interested in using it, since after Gentoo I'm in love with building from source and while Gentoo gives me that it feels like it's more native to the BSDs.


----------



## ajohnl (Apr 4, 2016)

wblock@ said:


> There is no reason to modify or touch loader.rc for this.  If you changed that file, please restore it.
> 
> I would find out what the problem is with the dynamic setting before modifying the source.



Anyways, thanks for excellent support. And should I still file a bug report? I've never done one before...


----------



## wblock@ (Apr 5, 2016)

Yes, definitely file a bug report.  Not only will this help others with similar keyboards, it will help you when you install FreeBSD on some new system.

Go to https://bugs.freebsd.org/bugzilla/enter_bug.cgi?product=Base System.  Set Component to USB.  Use Add support for Holtec/Keep Out F85 USB gaming keyboard for a summary, and describe the problem in the Description.

The usb_quirk(4) man page has very few examples, so I'm going to add this as a real-life useful one.


----------



## ethoms (Jun 3, 2021)

wblock@ said:


> This line is the equivalent when placed in /boot/loader.conf:
> 
> ```
> hw.usb.quirk.0="0x04d9 0xa030 0 0xffff UQ_KBD_BOOTPROTO"
> ...



Thanks for this, it fixed my *Velocifire TKL02WS *wireless keyboard when using a USB-C cable into a USB 2.0 slot on my laptop. I was not getting any modifier keys working (Shift, Alt), so no capital letters without using CapsLock.

For the sake of others, this is the line in my /boot/loader.conf for this model of keyboard:


```
hw.usb.quirk.0="0x062a 0x8503 0 0xffff UQ_KBD_BOOTPROTO"
```


I will try to remember to make a bug report as described above when I get time.


----------

