# Almost a Dozen Keys Missing from Sun Type 6 Keyboard



## David Paigen (Jul 21, 2020)

1. Objective: get an old sun keyboard (usb) working under FreeBSD 12.1

2. Expected: xev sees all keypresses on keyboard
3. Observed: 8 of 12 left side function keys fail to register anything.
The remainder of the keys operate normally.

Note: the keyboard operates as expected under unix, all keys generate
the expected keycodes and scancodes.

4. Details: The Sun keyboard has 4 media keys above the numeric keypad
and another 12 function keys on the left side (in addition to the 12
at the top of the keyboard).  On the left, the keys are labeled: Help,
(blank), Stop, Again, Props, Undo, Front, Copy, Open, Paste, Find,
and Cut.

5. Investigation:

5A. Xev shows that four keys generate scan codes:
  Help 136
  Copy 151
  Find 164
  Cut  181

Three keys generate X-Notify events (Stop, Again, Paste) but xev
does not report enough details to differentiate the keys.  The remaining
keys have no effect.

Note: I tried this again in an empty X instance with only xterm and xev
running.  No window manager, no display manager.  Same results.

5B. I used usbdump to examine the raw data coming from the keyboard.
I was able to verify that all 16 extra keys DO SEND KEYCODES.  They
range from 0x74-0x81 and 0x66 (116-129 & 102).  They are arranged in
this order: sleep=0x66, open=0x74, help=0x75, props, front, stop,
again, undo, cut, copy, paste, find, mute, vol+, vol-=0x81.

5C. In the kernel I found the file src/sys/dev/usb/input/ukbd.c
In lines 310-312, in the data structure ukbd_trtab, I find translations
to convert these keycodes into scancodes (ranging 108-130, decimal).

Farther down, in the function ukbd_key2scan, I see these numbers get
converted again into the ranges 0x11e-0x120, 0x125, and 0x15e-0x168
on lines 2204-2221.  The comments even say these scan codes are for
the Sun Type 6 USB Keyboard.

However, somewhere between the usb device and the tty driver, most of
these keys are getting dropped or consumed and I can't figure out why.

6. Questions

6A. Do I have to tell the kernel this is a sun keyboard?  I do not find
any sun specific files in either the syscons or the vt files.

6B. How can I tell if I am running syscons or vt?

6C. What other software sit between the usb hardware and the tty interface?
Where else can I look for code that is either consuming or dropping these
keys?

6D. How do I make the Sun 6 keyboard work under FreeBSD 12.1-RELEASE?

Thanks for your help,
-David


----------



## T-Daemon (Jul 21, 2020)

Try setting in /etc/sysctl.conf:

```
kern.evdev.rcpt_mask=12
```

For immediate effect run as root `sysctl kern.evdev.rcpt_mask=12` before starting xorg.

Background information:





						247465 – base system/kern after update to xorg-server-1.20, Sun keys are > not recognized
					






					bugs.freebsd.org


----------



## Mjölnir (Jul 21, 2020)

David Paigen said:


> 6B. How can I tell if I am running syscons or vt?


`sysctl kern.vty` is either _vt_ or _sc_ (_syscons_)
EDIT I have a virtual keyboard /usr/local/bin/tastenbrett (that's german slang) from x11/plasma5-plasma-desktop. You could check if it works with X11.  Better than nothing.


----------

