Home | History | Annotate | only in /src/sys/dev/hid
History log of /src/sys/dev/hid
RevisionDateAuthorComments
 1.1 10-Dec-2017  bouyer Fix fallout from hid factorisation:
- need to install sys/dev/hid/hid.h for userland
- include it where needed - most of the time in place if usb/usbhid.h
 1.3 09-Dec-2024  jmcneill Import hidkbd support from OpenBSD.
 1.2 10-Jul-2019  martin branches: 1.2.34;
hidms depends on tpcalib now
 1.1 10-Dec-2017  bouyer branches: 1.1.4;
Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.1.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.34.1 02-Aug-2025  perseant Sync with HEAD
 1.8 19-Dec-2024  jmcneill fixup! Fix parsing keyboard HID descriptor on ThinkPad T14s Gen6.

The previous change broke detection of some devices. Rework the change
in hopes to fix this.
 1.7 09-Dec-2024  jmcneill Fix parsing keyboard HID descriptor on ThinkPad T14s Gen6.

Undo a change made 18 years ago when the bluetooth stack was imported. The
commit message didn't describe why the change was made, and it breaks
detection of the keyboard device on this laptop.

OpenBSD's hid parser looks like the original code here.
 1.6 17-Oct-2023  nat branches: 1.6.6;
Improve hid matching.

It now matches all kinds (application/physical/logical) in the hid
collection.

Patch from PR applied.

Addresses PR/46868.

Ok skrll@
 1.5 13-Mar-2022  riastradh hid: Avoid arithmetic overflow by rearranging inequalities.
 1.4 01-Jan-2020  maxv Fix small read overflows when parsing HID tables. Noticed by kASan the
other day while I was playing with vHCI.
 1.3 15-Nov-2018  jakllsch branches: 1.3.4;
Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.
 1.2 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.1 10-Dec-2017  bouyer branches: 1.1.2; 1.1.4;
Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.1.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.4.1 10-Jun-2019  christos Sync with HEAD
 1.1.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.3.4.1 05-Jan-2020  martin Pull up following revision(s) (requested by maxv in ticket #605):

sys/dev/hid/hid.c: revision 1.4

Fix small read overflows when parsing HID tables. Noticed by kASan the
other day while I was playing with vHCI.
 1.6.6.1 02-Aug-2025  perseant Sync with HEAD
 1.6 11-Mar-2020  msaitoh Use unsgined more.
 1.5 08-Mar-2020  msaitoh Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.4 02-Mar-2020  christos Add fido constants, and turn hid "raw" mode for fido devices.
 1.3 15-Nov-2018  jakllsch branches: 1.3.4;
Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.
 1.2 10-Dec-2017  bouyer branches: 1.2.2; 1.2.4;
Fix fallout from hid factorisation:
- need to install sys/dev/hid/hid.h for userland
- include it where needed - most of the time in place if usb/usbhid.h
 1.1 10-Dec-2017  bouyer Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.2.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.4.1 10-Jun-2019  christos Sync with HEAD
 1.2.2.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.3.4.1 15-Jul-2020  martin Pull up following revision(s) (requested by riastradh in ticket #1010):

sys/dev/usb/uhid.c: revision 1.112
sys/dev/usb/uhid.c: revision 1.113
sys/dev/hid/hid.h: revision 1.4
sys/dev/hid/hid.h: revision 1.5
sys/dev/usb/usbhid.h: revision 1.19

Add fido constants, and turn hid "raw" mode for fido devices.

Add ioctls to get and set raw mode.

Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.1 09-Dec-2024  jmcneill branches: 1.1.4;
Import hidkbd support from OpenBSD.
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 09-Dec-2024  perseant file hidkbd.c was added on branch perseant-exfatfs on 2025-08-02 05:56:38 +0000
 1.16 24-May-2025  nia wskbd(4): Define USB and PS/2 keymaps for KB_PL

This is the de-facto standard "Polish programmers" QWERTY keyboard,
what X11 simply calls "Polish". It's a simple variation of US QWERTY
with some extra characters when right alt is pressed.

Defining this layout is slightly optimistic, since even with latin-2
fonts loaded and the appropriate locale set, wscons seems to struggle
to input most of these characters.

Regardless, this allows the supposedly supported "pl" encoding
to not fail loading with an error message, and allows X11 to
auto-detect the keyboard layout (defining KB_PL and as an alias of
KB_US also accomplishes this goal), with room for proper UTF-8
support in the future.

PR port-amd64/57234 "# wsconsctl -k -w encoding=pl" *should* work.
PR kern/57844 wscons doesn't support encoding=pl contrary to wskbd(4) man page
PR install/58405 Selecting Polish keyboard type in sysinst is useless
 1.15 22-Sep-2021  nia branches: 1.15.4; 1.15.10;
wscons: add definitions for BÉPO, a standardized, Dvorak-style optimized
keyboard layout for French
 1.14 21-Jul-2021  skrll need <sys/param.h> for COHERENCY_UNIT

Minor KNF along the way.
 1.13 11-May-2021  nia wscons: add support for the Neo 2 German keyboard layout

Neo is an optimized layout for German and English, similar to
Dvorak for English. It can be used to type most Latin-based languages
and has separate layers for symbols and directional commands.
 1.12 29-Aug-2020  macallan branches: 1.12.6; 1.12.8;
provide KB_APPLE layout variant which uses Command-F* to switch console screens
mostly for consistent behaviour across *Books which may have ADB or USB
keyboards
 1.11 26-Aug-2020  jdolecek for jp keymap map also scan code 49 to right bracket to handle ARCHISS model

PR kern/55608 by Shinichi Doyashiki
 1.10 13-Jul-2020  nia Canadian French keyboard layout for ukbd/pckbd
 1.9 13-Jul-2020  nia Add keyboard layout for Latin American Spanish to ukbd/pckbd
 1.8 12-Jul-2020  nia Add Icelandic keyboard layout to ukbd/pckbd.
 1.7 12-Jul-2020  nia Add KB_TR for uhid keyboards (it was PS/2 only, this seems wrong)
 1.6 12-Jul-2020  nia Add Estonian layout as a variation of Swedish for ukbd and pckbd
 1.5 12-Jul-2020  nia Bring br.nodead closer to X11
 1.4 12-Jul-2020  nia Add support for the Brazilian keyboard layout to pckbd and ukbd.

This is significantly different from the European Portugese layout,
and was pieced together from Wikipedia, X11 layout files, and to
some extent with trial and error.

Thanks to lun-4 for helping test this.

PR kern/44570
 1.3 24-Apr-2020  rhialto For usb keyboards with encoding *.swapctrlcaps, keep KS_Cmd1 on the same
key as KS_Control_L. This brings them in line with wskbdmap_mfii.c.
 1.2 11-Jan-2020  nia branches: 1.2.4;
Support the combination of KB_SWAPCTRLCAPS and UK layout.
 1.1 10-Dec-2017  bouyer branches: 1.1.4; 1.1.10; 1.1.12;
Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.1.12.1 17-Jan-2020  ad Sync with head.
 1.1.10.3 19-Sep-2020  martin Pull up following revision(s) (requested by nonaka in ticket #1086):

sys/dev/hid/hidkbdmap.c: revision 1.11

for jp keymap map also scan code 49 to right bracket to handle ARCHISS model
PR kern/55608 by Shinichi Doyashiki
 1.1.10.2 13-Jul-2020  martin Pull up following revision(s) (requested by nia in ticket #1002):

sys/dev/wscons/wsksymdef.h: revision 1.68
sys/dev/wscons/wsksymdef.h: revision 1.69
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.28
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.29
sys/dev/hid/hidkbdmap.c: revision 1.10
share/man/man4/pckbd.4: revision 1.23
share/man/man4/wskbd.4: revision 1.18
share/man/man4/wskbd.4: revision 1.19
share/man/man4/pckbd.4: revision 1.25
sys/dev/wscons/wsksymdef.h: revision 1.70
sys/dev/wscons/wsksymdef.h: revision 1.71
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.30
sys/dev/wscons/wsksymdef.h: revision 1.72
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.31
sys/dev/wscons/wsksymdef.h: revision 1.73
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.32
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.33
sys/dev/hid/hidkbdmap.c: revision 1.4
sbin/wsconsctl/wsconsctl.8: revision 1.30
sys/dev/hid/hidkbdmap.c: revision 1.5
etc/wscons.conf: revision 1.20
sys/dev/hid/hidkbdmap.c: revision 1.6
etc/wscons.conf: revision 1.21
sys/dev/hid/hidkbdmap.c: revision 1.7
sys/dev/hid/hidkbdmap.c: revision 1.8
sys/dev/hid/hidkbdmap.c: revision 1.9

Add support for the Brazilian keyboard layout to pckbd and ukbd.

This is significantly different from the European Portugese layout,
and was pieced together from Wikipedia, X11 layout files, and to
some extent with trial and error.

Thanks to lun-4 for helping test this.

PR kern/44570
Update lists of keyboard layouts to add Turkish and Brazilian

Bring br.nodead closer to X11

Add Estonian layout as a variation of Swedish for ukbd and pckbd

Add KB_TR for uhid keyboards (it was PS/2 only, this seems wrong)

Add Icelandic keyboard layout to ukbd/pckbd.

Add keyboard layout for Latin American Spanish to ukbd/pckbd

Canadian French keyboard layout for ukbd/pckbd

Clarify that KB_TR is the "Q" layout - there's two standards for Turkish.

Move description of keyboard layouts to wskbd.4, add newer layouts

Previously, the best reference was pckbd.4. This does not make much
sense to read if you are on, say, an evbarm device with only USB.
wsconsctl.8 contained a vaguer description of supported language names,
which isn't very useful because you can't pass full language names
to the command. Point readers to wskbd.4 instead.

Note in the wskbd.4 page that while all layouts are generally supported
by pckbd(4) and ukbd(4), older keyboard interfaces might only support
a subset.

wskbd.4: Add KB_LA

Point readers at wskbd.4
 1.1.10.1 21-Jan-2020  martin Pull up following revision(s) (requested by nia in ticket #635):

sys/dev/pckbport/wskbdmap_mfii.c: revision 1.27
share/man/man4/pckbd.4: revision 1.22
sys/dev/hid/hidkbdmap.c: revision 1.2

Support the combination of KB_SWAPCTRLCAPS and UK layout.
Note some more layouts that work with KB_SWAPCTRLCAPS.
 1.1.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.4.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.12.8.1 31-May-2021  cjep sync with head
 1.12.6.2 01-Aug-2021  thorpej Sync with HEAD.
 1.12.6.1 13-May-2021  thorpej Sync with HEAD.
 1.15.10.1 02-Aug-2025  perseant Sync with HEAD
 1.15.4.1 20-Oct-2025  martin Pull up following revision(s) (requested by nia in ticket #1180):

sys/dev/hid/hidkbdmap.c: revision 1.16
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.36

wskbd(4): Define USB and PS/2 keymaps for KB_PL

This is the de-facto standard "Polish programmers" QWERTY keyboard,
what X11 simply calls "Polish". It's a simple variation of US QWERTY
with some extra characters when right alt is pressed.

Defining this layout is slightly optimistic, since even with latin-2
fonts loaded and the appropriate locale set, wscons seems to struggle
to input most of these characters.

Regardless, this allows the supposedly supported "pl" encoding
to not fail loading with an error message, and allows X11 to
auto-detect the keyboard layout (defining KB_PL and as an alias of
KB_US also accomplishes this goal), with room for proper UTF-8
support in the future.

PR port-amd64/57234 "# wsconsctl -k -w encoding=pl" *should* work.
PR kern/57844 wscons doesn't support encoding=pl contrary to wskbd(4) man page
PR install/58405 Selecting Polish keyboard type in sysinst is useless
 1.1 09-Dec-2024  jmcneill branches: 1.1.4;
Import hidkbd support from OpenBSD.
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 09-Dec-2024  perseant file hidkbdsc.h was added on branch perseant-exfatfs on 2025-08-02 05:56:38 +0000
 1.6 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.5 24-Apr-2021  thorpej branches: 1.5.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.4 09-Jul-2019  ryoon branches: 1.4.12;
Enable finger touch panel of HP Spectre x360 13-inch ae019TU
 1.3 09-Jul-2019  ryoon Add tpcalib, touch panel calibration to ims(4)

Suggested by ryo@ at Japan NetBSD Users' Group BOF 2019-07-06.
 1.2 25-May-2018  ryoon branches: 1.2.2;
Fix HIDMS_DEBUG build
 1.1 10-Dec-2017  bouyer branches: 1.1.2;
Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.1.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.2.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.12.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.5.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 09-Jul-2019  ryoon Add tpcalib, touch panel calibration to ims(4)

Suggested by ryo@ at Japan NetBSD Users' Group BOF 2019-07-06.
 1.1 10-Dec-2017  bouyer branches: 1.1.4;
Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
 1.1.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411

RSS XML Feed