The branch main has been updated by wulf:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=67de2db2623a10dc4edec1642b2f8685d5587d7f

commit 67de2db2623a10dc4edec1642b2f8685d5587d7f
Author:     Vladimir Kondratyev <w...@freebsd.org>
AuthorDate: 2020-10-04 22:21:08 +0000
Commit:     Vladimir Kondratyev <w...@freebsd.org>
CommitDate: 2021-01-07 23:18:42 +0000

    Factor-out hardware-independent part of USB HID support to new module
    
    It will be used by the upcoming HID-over-i2C implementation.  Should be
    no-op, except hid.ko module dependency is to be added to affected drivers.
    
    Reviewed by:    hselasky, manu
    Differential revision:  https://reviews.freebsd.org/D27867
---
 etc/mtree/BSD.include.dist    |   2 +
 include/Makefile              |  11 +-
 share/man/man4/atp.4          |   1 +
 share/man/man4/ucycom.4       |   1 +
 share/man/man4/ugold.4        |   1 +
 share/man/man4/uhid.4         |   2 +
 share/man/man4/ukbd.4         |   2 +
 share/man/man4/ums.4          |   1 +
 share/man/man4/wmt.4          |   1 +
 share/man/man4/wsp.4          |   1 +
 sys/amd64/conf/GENERIC        |   3 +
 sys/arm/conf/EFIKA_MX         |   3 +
 sys/arm/conf/GENERIC          |   3 +
 sys/arm/conf/IMX53            |   3 +
 sys/arm/conf/IMX6             |   3 +
 sys/arm/conf/RPI-B            |   3 +
 sys/arm/conf/TEGRA124         |   3 +
 sys/arm/conf/VYBRID           |   3 +
 sys/arm64/conf/GENERIC        |   3 +
 sys/conf/files                |   1 +
 sys/dev/hid/hid.c             |  87 +----
 sys/dev/hid/hid.h             |  43 +--
 sys/dev/hid/hidrdesc.h        |  72 +++-
 sys/dev/sound/usb/uaudio.c    |   1 +
 sys/dev/usb/input/atp.c       |   1 +
 sys/dev/usb/input/uhid.c      |   1 +
 sys/dev/usb/input/ukbd.c      |   1 +
 sys/dev/usb/input/ums.c       |   1 +
 sys/dev/usb/input/usb_rdesc.h | 285 +-------------
 sys/dev/usb/input/wmt.c       |   1 +
 sys/dev/usb/input/wsp.c       |   1 +
 sys/dev/usb/misc/ugold.c      |   1 +
 sys/dev/usb/serial/ucycom.c   |   1 +
 sys/dev/usb/usb_hid.c         | 861 ------------------------------------------
 sys/dev/usb/usbhid.h          | 212 +----------
 sys/i386/conf/GENERIC         |   3 +
 sys/mips/conf/ERL             |   3 +
 sys/mips/conf/JZ4780          |   3 +
 sys/mips/conf/OCTEON1         |   3 +
 sys/modules/Makefile          |   1 +
 sys/modules/hid/Makefile      |   6 +
 sys/modules/hid/hid/Makefile  |   9 +
 sys/powerpc/conf/GENERIC      |   2 +
 sys/powerpc/conf/GENERIC64    |   2 +
 sys/powerpc/conf/GENERIC64LE  |   2 +
 sys/powerpc/conf/MPC85XX      |   3 +
 sys/powerpc/conf/MPC85XXSPE   |   3 +
 sys/powerpc/conf/QORIQ64      |   3 +
 48 files changed, 185 insertions(+), 1478 deletions(-)

diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist
index 071fba7e87ac..e7784cbb0a47 100644
--- a/etc/mtree/BSD.include.dist
+++ b/etc/mtree/BSD.include.dist
@@ -54,6 +54,8 @@
         ..
         firewire
         ..
+        hid
+        ..
         hwpmc
         ..
         hyperv
diff --git a/include/Makefile b/include/Makefile
index d374ce739cf4..7e19f66edf71 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -94,6 +94,10 @@ EVDEV=               input.h \
                uinput.h
 EVDEVDIR=      ${INCLUDEDIR}/dev/evdev
 
+.PATH: ${SRCTOP}/sys/dev/hid
+HID=           hid.h
+HIDDIR=                ${INCLUDEDIR}/dev/hid
+
 .PATH: ${SRCTOP}/sys/dev/hyperv/include ${SRCTOP}/sys/dev/hyperv/utilities
 HYPERV=                hv_snapshot.h \
                hyperv.h
@@ -172,6 +176,7 @@ INCSGROUPS= INCS \
                CRYPTO \
                EVDEV \
                FS9660 \
+               HID \
                HYPERV \
                OPENCRYPTO \
                PCI \
@@ -287,7 +292,7 @@ copies: .PHONY .META
                done; \
        fi
 .endfor
-.for i in ${LDIRS} 
${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/evdev:Ndev/hyperv:Ndev/pci:Ndev/veriexec} 
${LSUBSUBDIRS}
+.for i in ${LDIRS} 
${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/evdev:Ndev/hid:Ndev/hyperv:Ndev/pci:Ndev/veriexec}
 ${LSUBSUBDIRS}
        cd ${SRCTOP}/sys; \
        ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \
            ${SDESTDIR}${INCLUDEDIR}/$i
@@ -323,7 +328,7 @@ symlinks: .PHONY .META
        cd ${SRCTOP}; ${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},dev} \
            $$(printf '../../../%s ' sys/$i/*.h) ${SDESTDIR}${INCLUDEDIR}/$i
 .endfor
-.for i in 
${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/evdev:Ndev/hyperv:Ndev/pci:Ndev/veriexec}
+.for i in 
${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/evdev:Ndev/hid:Ndev/hyperv:Ndev/pci:Ndev/veriexec}
        cd ${SRCTOP}; ${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},dev} \
            $$(printf '../../../../%s ' sys/$i/*.h) ${SDESTDIR}${INCLUDEDIR}/$i
 .endfor
@@ -335,6 +340,8 @@ symlinks: .PHONY .META
        ${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},dev} \
            $$(printf '../../../../sys/dev/evdev/%s ' input.h 
input-event-codes.h uinput.h) \
            ${SDESTDIR}${INCLUDEDIR}/dev/evdev;
+       ${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},dev} 
../../../../sys/dev/hid/hid.h \
+           ${SDESTDIR}${INCLUDEDIR}/dev/hid; \
        ${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},dev} 
../../../../sys/dev/hyperv/include/hyperv.h \
            ${SDESTDIR}${INCLUDEDIR}/dev/hyperv; \
        ${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},dev} 
../../../../sys/dev/hyperv/utilities/hv_snapshot.h \
diff --git a/share/man/man4/atp.4 b/share/man/man4/atp.4
index c32618815d22..b622bb0b6380 100644
--- a/share/man/man4/atp.4
+++ b/share/man/man4/atp.4
@@ -38,6 +38,7 @@ To compile this driver into the kernel, place the following 
lines into
 your kernel configuration file:
 .Bd -ragged -offset indent
 .Cd "device atp"
+.Cd "device hid"
 .Cd "device usb"
 .Ed
 .Pp
diff --git a/share/man/man4/ucycom.4 b/share/man/man4/ucycom.4
index c5764cbe9a58..ec410ab0ff78 100644
--- a/share/man/man4/ucycom.4
+++ b/share/man/man4/ucycom.4
@@ -39,6 +39,7 @@ place the following line in your
 kernel configuration file:
 .Bd -ragged -offset indent
 .Cd "device usb"
+.Cd "device hid"
 .Cd "device ucom"
 .Cd "device ucycom"
 .Ed
diff --git a/share/man/man4/ugold.4 b/share/man/man4/ugold.4
index f75440de2134..79d2e5749f2d 100644
--- a/share/man/man4/ugold.4
+++ b/share/man/man4/ugold.4
@@ -28,6 +28,7 @@ To compile this driver into the kernel, place the following 
lines into
 your kernel configuration file:
 .Bd -ragged -offset indent
 .Cd "device usb"
+.Cd "device hid"
 .Cd "device ugold"
 .Ed
 .Pp
diff --git a/share/man/man4/uhid.4 b/share/man/man4/uhid.4
index bcb1b78fdd12..491a2e871e76 100644
--- a/share/man/man4/uhid.4
+++ b/share/man/man4/uhid.4
@@ -41,6 +41,8 @@ place the following line in your
 kernel configuration file:
 .Bd -ragged -offset indent
 .Cd "device uhid"
+.Cd "device hid"
+.Cd "device usb"
 .Ed
 .Pp
 Alternatively, to load the driver as a
diff --git a/share/man/man4/ukbd.4 b/share/man/man4/ukbd.4
index 0b58446fcb77..f443f51ce8e1 100644
--- a/share/man/man4/ukbd.4
+++ b/share/man/man4/ukbd.4
@@ -36,6 +36,8 @@ place the following line in your
 kernel configuration file:
 .Bd -ragged -offset indent
 .Cd "device ukbd"
+.Cd "device hid"
+.Cd "device usb"
 .Ed
 .Pp
 Alternatively, to load the driver as a
diff --git a/share/man/man4/ums.4 b/share/man/man4/ums.4
index cbc94160b260..b27c55cef738 100644
--- a/share/man/man4/ums.4
+++ b/share/man/man4/ums.4
@@ -36,6 +36,7 @@ place the following lines in your
 kernel configuration file:
 .Bd -ragged -offset indent
 .Cd "device ums"
+.Cd "device hid"
 .Cd "device uhci"
 .Cd "device ohci"
 .Cd "device usb"
diff --git a/share/man/man4/wmt.4 b/share/man/man4/wmt.4
index ddea0a6b45d3..e09fc5286fe2 100644
--- a/share/man/man4/wmt.4
+++ b/share/man/man4/wmt.4
@@ -36,6 +36,7 @@ your kernel configuration file:
 .Bd -ragged -offset indent
 .Cd "device wmt"
 .Cd "device usb"
+.Cd "device hid"
 .Cd "device evdev"
 .Ed
 .Pp
diff --git a/share/man/man4/wsp.4 b/share/man/man4/wsp.4
index 0a8cc0fe410b..70a1219533dc 100644
--- a/share/man/man4/wsp.4
+++ b/share/man/man4/wsp.4
@@ -35,6 +35,7 @@ To compile this driver into the kernel, place the following 
lines into
 your kernel configuration file:
 .Bd -ragged -offset indent
 .Cd "device wsp"
+.Cd "device hid"
 .Cd "device usb"
 .Ed
 .Pp
diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC
index 9b1fb0182e72..c7802969ba4b 100644
--- a/sys/amd64/conf/GENERIC
+++ b/sys/amd64/conf/GENERIC
@@ -380,3 +380,6 @@ device              netmap                  # netmap(4) 
support
 options        EVDEV_SUPPORT           # evdev support in legacy drivers
 device         evdev                   # input event device support
 device         uinput                  # install /dev/uinput cdev
+
+# HID support
+device         hid                     # Generic HID support
diff --git a/sys/arm/conf/EFIKA_MX b/sys/arm/conf/EFIKA_MX
index be5f5f35570d..724d742e03af 100644
--- a/sys/arm/conf/EFIKA_MX
+++ b/sys/arm/conf/EFIKA_MX
@@ -116,6 +116,9 @@ device              wlan_ccmp               # 802.11 CCMP 
support
 device         wlan_tkip               # 802.11 TKIP support
 device         wlan_amrr               # AMRR transmit rate control algorithm
 
+# HID support
+device         hid                     # Generic HID support
+
 # Flattened Device Tree
 options        FDT                     # Configure using FDT/DTB data
 options        FDT_DTB_STATIC
diff --git a/sys/arm/conf/GENERIC b/sys/arm/conf/GENERIC
index 35056f7640dc..0f0522eb9802 100644
--- a/sys/arm/conf/GENERIC
+++ b/sys/arm/conf/GENERIC
@@ -280,6 +280,9 @@ device              aw_sid          # Allwinner Secure ID 
EFUSE
 # Thermal sensors
 device         aw_thermal      # Allwinner Thermal Sensor Controller
 
+# HID support
+device         hid             # Generic HID support
+
 # Flattened Device Tree
 options        FDT                     # Configure using FDT/DTB data
 makeoptions    MODULES_EXTRA+="dtb/allwinner"
diff --git a/sys/arm/conf/IMX53 b/sys/arm/conf/IMX53
index be18afda6094..0372cb62088d 100644
--- a/sys/arm/conf/IMX53
+++ b/sys/arm/conf/IMX53
@@ -113,6 +113,9 @@ device              wlan_amrr               # AMRR transmit 
rate control algorithm
 #device        mmc                     # SD/MMC protocol
 #device        mmcsd                   # SDCard disk device
 
+# HID support
+device         hid                     # Generic HID support
+
 
 # Flattened Device Tree
 options        FDT                     # Configure using FDT/DTB data
diff --git a/sys/arm/conf/IMX6 b/sys/arm/conf/IMX6
index 808dac4bf910..6d8388ff0d60 100644
--- a/sys/arm/conf/IMX6
+++ b/sys/arm/conf/IMX6
@@ -106,6 +106,9 @@ device              u3g                     # USB modems
 #device                wlan_tkip               # 802.11 TKIP support
 #device                wlan_amrr               # AMRR transmit rate control 
algorithm
 
+# HID support
+device         hid                     # Generic HID support
+
 device         vt
 device         kbdmux
 device         ukbd
diff --git a/sys/arm/conf/RPI-B b/sys/arm/conf/RPI-B
index e456d33742b8..36eaff0c0f28 100644
--- a/sys/arm/conf/RPI-B
+++ b/sys/arm/conf/RPI-B
@@ -89,6 +89,9 @@ device                sound
 
 device         fdt_pinctrl
 
+# HID support
+device         hid                     # Generic HID support
+
 # Flattened Device Tree
 options        FDT                     # Configure using FDT/DTB data
 # Note:  DTB is normally loaded and modified by RPi boot loader, then
diff --git a/sys/arm/conf/TEGRA124 b/sys/arm/conf/TEGRA124
index a6c731dedcf2..68d7bf037525 100644
--- a/sys/arm/conf/TEGRA124
+++ b/sys/arm/conf/TEGRA124
@@ -130,6 +130,9 @@ device              drm2
 #device                sound
 #device                snd_hda
 
+# HID support
+device         hid                     # Generic HID support
+
 # Flattened Device Tree
 options        FDT                     # Configure using FDT/DTB data
 device         fdt_pinctrl
diff --git a/sys/arm/conf/VYBRID b/sys/arm/conf/VYBRID
index 856fe41bb3f3..e7ded5f42d82 100644
--- a/sys/arm/conf/VYBRID
+++ b/sys/arm/conf/VYBRID
@@ -103,5 +103,8 @@ device              vt
 device         kbdmux
 device         ukbd
 
+# HID support
+device         hid                     # Generic HID support
+
 # Flattened Device Tree
 options        FDT                     # Configure using FDT/DTB data
diff --git a/sys/arm64/conf/GENERIC b/sys/arm64/conf/GENERIC
index f7f446c6c881..dc9278a998e2 100644
--- a/sys/arm64/conf/GENERIC
+++ b/sys/arm64/conf/GENERIC
@@ -380,3 +380,6 @@ device              acpi
 
 # DTBs
 makeoptions    MODULES_EXTRA="dtb/allwinner dtb/freescale dtb/imx8 dtb/nvidia 
dtb/mv dtb/rockchip dtb/rpi"
+
+# HID support
+device         hid             # Generic HID support
diff --git a/sys/conf/files b/sys/conf/files
index 7cfb32560af6..a192877d1e98 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1815,6 +1815,7 @@ dev/gpio/gpio_if.m                optional gpio
 dev/gpio/gpiobus_if.m          optional gpio
 dev/gpio/gpiopps.c             optional gpiopps fdt
 dev/gpio/ofw_gpiobus.c         optional fdt gpio
+dev/hid/hid.c                  optional hid
 dev/hifn/hifn7751.c            optional hifn
 dev/hptiop/hptiop.c            optional hptiop scbus
 dev/hwpmc/hwpmc_logging.c      optional hwpmc
diff --git a/sys/dev/hid/hid.c b/sys/dev/hid/hid.c
index 22e5fb5446c3..61b7587a6c62 100644
--- a/sys/dev/hid/hid.c
+++ b/sys/dev/hid/hid.c
@@ -779,91 +779,6 @@ hid_is_collection(const void *desc, usb_size_t size, 
int32_t usage)
        return (err);
 }
 
-/*------------------------------------------------------------------------*
- *     hid_get_descriptor_from_usb
- *
- * This function will search for a HID descriptor between two USB
- * interface descriptors.
- *
- * Return values:
- * NULL: No more HID descriptors.
- * Else: Pointer to HID descriptor.
- *------------------------------------------------------------------------*/
-struct usb_hid_descriptor *
-hid_get_descriptor_from_usb(struct usb_config_descriptor *cd,
-    struct usb_interface_descriptor *id)
-{
-       struct usb_descriptor *desc = (void *)id;
-
-       if (desc == NULL) {
-               return (NULL);
-       }
-       while ((desc = usb_desc_foreach(cd, desc))) {
-               if ((desc->bDescriptorType == UDESC_HID) &&
-                   (desc->bLength >= USB_HID_DESCRIPTOR_SIZE(0))) {
-                       return (void *)desc;
-               }
-               if (desc->bDescriptorType == UDESC_INTERFACE) {
-                       break;
-               }
-       }
-       return (NULL);
-}
-
-/*------------------------------------------------------------------------*
- *     usbd_req_get_hid_desc
- *
- * This function will read out an USB report descriptor from the USB
- * device.
- *
- * Return values:
- * NULL: Failure.
- * Else: Success. The pointer should eventually be passed to free().
- *------------------------------------------------------------------------*/
-usb_error_t
-usbd_req_get_hid_desc(struct usb_device *udev, struct mtx *mtx,
-    void **descp, uint16_t *sizep,
-    struct malloc_type *mem, uint8_t iface_index)
-{
-       struct usb_interface *iface = usbd_get_iface(udev, iface_index);
-       struct usb_hid_descriptor *hid;
-       usb_error_t err;
-
-       if ((iface == NULL) || (iface->idesc == NULL)) {
-               return (USB_ERR_INVAL);
-       }
-       hid = hid_get_descriptor_from_usb
-           (usbd_get_config_descriptor(udev), iface->idesc);
-
-       if (hid == NULL) {
-               return (USB_ERR_IOERROR);
-       }
-       *sizep = UGETW(hid->descrs[0].wDescriptorLength);
-       if (*sizep == 0) {
-               return (USB_ERR_IOERROR);
-       }
-       if (mtx)
-               mtx_unlock(mtx);
-
-       *descp = malloc(*sizep, mem, M_ZERO | M_WAITOK);
-
-       if (mtx)
-               mtx_lock(mtx);
-
-       if (*descp == NULL) {
-               return (USB_ERR_NOMEM);
-       }
-       err = usbd_req_get_report_descriptor
-           (udev, mtx, *descp, *sizep, iface_index);
-
-       if (err) {
-               free(*descp, mem);
-               *descp = NULL;
-               return (err);
-       }
-       return (USB_ERR_NORMAL_COMPLETION);
-}
-
 /*------------------------------------------------------------------------*
  * calculate HID item resolution. unit/mm for distances, unit/rad for angles
  *------------------------------------------------------------------------*/
@@ -1013,3 +928,5 @@ hid_is_keyboard(const void *d_ptr, uint16_t d_len)
                return (1);
        return (0);
 }
+
+MODULE_VERSION(hid, 1);
diff --git a/sys/dev/hid/hid.h b/sys/dev/hid/hid.h
index 926c404dca55..b1829318bda1 100644
--- a/sys/dev/hid/hid.h
+++ b/sys/dev/hid/hid.h
@@ -28,38 +28,8 @@
  * SUCH DAMAGE.
  */
 
-#ifndef _USB_HID_H_
-#define        _USB_HID_H_
-
-#ifndef USB_GLOBAL_INCLUDE_FILE
-#include <dev/usb/usb_endian.h>
-#endif
-
-#define        UR_GET_HID_DESCRIPTOR   0x06
-#define        UDESC_HID               0x21
-#define        UDESC_REPORT            0x22
-#define        UDESC_PHYSICAL          0x23
-#define        UR_SET_HID_DESCRIPTOR   0x07
-#define        UR_GET_REPORT           0x01
-#define        UR_SET_REPORT           0x09
-#define        UR_GET_IDLE             0x02
-#define        UR_SET_IDLE             0x0a
-#define        UR_GET_PROTOCOL         0x03
-#define        UR_SET_PROTOCOL         0x0b
-
-struct usb_hid_descriptor {
-       uByte   bLength;
-       uByte   bDescriptorType;
-       uWord   bcdHID;
-       uByte   bCountryCode;
-       uByte   bNumDescriptors;
-       struct {
-               uByte   bDescriptorType;
-               uWord   wDescriptorLength;
-       }       descrs[1];
-} __packed;
-
-#define        USB_HID_DESCRIPTOR_SIZE(n) (9+((n)*3))
+#ifndef _HID_HID_H_
+#define        _HID_HID_H_
 
 /* Usage pages */
 #define        HUP_UNDEFINED           0x0000
@@ -206,7 +176,6 @@ struct usb_hid_descriptor {
 #define        HUM_DEGREE      0x14
 
 #if defined(_KERNEL) || defined(_STANDALONE)
-struct usb_config_descriptor;
 
 #define        HID_ITEM_MAXUSAGE       4
 
@@ -271,14 +240,8 @@ uint32_t hid_get_data_unsigned(const uint8_t *buf, 
usb_size_t len,
 void hid_put_data_unsigned(uint8_t *buf, usb_size_t len,
            struct hid_location *loc, unsigned int value);
 int    hid_is_collection(const void *desc, usb_size_t size, int32_t usage);
-struct usb_hid_descriptor *hid_get_descriptor_from_usb(
-           struct usb_config_descriptor *cd,
-           struct usb_interface_descriptor *id);
-usb_error_t usbd_req_get_hid_desc(struct usb_device *udev, struct mtx *mtx,
-           void **descp, uint16_t *sizep, struct malloc_type *mem,
-           uint8_t iface_index);
 int32_t        hid_item_resolution(struct hid_item *hi);
 int    hid_is_mouse(const void *d_ptr, uint16_t d_len);
 int    hid_is_keyboard(const void *d_ptr, uint16_t d_len);
 #endif /* _KERNEL || _STANDALONE */
-#endif /* _USB_HID_H_ */
+#endif /* _HID_HID_H_ */
diff --git a/sys/dev/hid/hidrdesc.h b/sys/dev/hid/hidrdesc.h
index 889381e82c15..f6cbb755cd24 100644
--- a/sys/dev/hid/hidrdesc.h
+++ b/sys/dev/hid/hidrdesc.h
@@ -33,7 +33,7 @@
  * This file contains replacements for broken HID report descriptors.
  */
 
-#define        UHID_GRAPHIRE_REPORT_DESCR(...) \
+#define        HID_GRAPHIRE_REPORT_DESCR(...) \
     0x05, 0x0d,                    /*  USAGE_PAGE (Digitizers)         */\
     0x09, 0x01,                    /*  USAGE (Digitizer)               */\
     0xa1, 0x01,                    /*  COLLECTION (Application)                
*/\
@@ -97,7 +97,7 @@
     0xb1, 0x02,                    /*    FEATURE (Data,Var,Abs)                
*/\
     0xc0,                          /*  END_COLLECTION                  */\
 
-#define        UHID_GRAPHIRE3_4X5_REPORT_DESCR(...) \
+#define        HID_GRAPHIRE3_4X5_REPORT_DESCR(...) \
     0x05, 0x01,                    /* USAGE_PAGE (Generic Desktop)     */\
     0x09, 0x02,                    /* USAGE (Mouse)                    */\
     0xa1, 0x01,                    /* COLLECTION (Application)         */\
@@ -184,7 +184,7 @@
  * The descriptor has no output report format, thus preventing you from
  * controlling the LEDs and the built-in rumblers.
  */
-#define        UHID_XB360GP_REPORT_DESCR(...) \
+#define        HID_XB360GP_REPORT_DESCR(...) \
     0x05, 0x01,                /* USAGE PAGE (Generic Desktop)         */\
     0x09, 0x05,                /* USAGE (Gamepad)                      */\
     0xa1, 0x01,                /* COLLECTION (Application)             */\
@@ -277,7 +277,7 @@
     0xc0               /* END COLLECTION                       */\
 
 /* Fixed report descriptor for Super Nintendo gamepads */
-#define        UHID_SNES_REPORT_DESCR(...) \
+#define        HID_SNES_REPORT_DESCR(...) \
     0x05, 0x01,         /*  Usage Page (Desktop),           */\
     0x09, 0x04,         /*  Usage (Joystik),                */\
     0xA1, 0x01,         /*  Collection (Application),       */\
@@ -304,3 +304,67 @@
     0x81, 0x01,         /*          Input (Constant),       */\
     0xC0,               /*      End Collection,             */\
     0xC0                /*  End Collection                  */
+
+/* HID mouse boot protocol descriptor */
+#define        HID_MOUSE_BOOTPROTO_DESCR(...) \
+    0x05, 0x01,                /* Usage Page (Generic Desktop Ctrls)   */\
+    0x09, 0x02,                /* Usage (Mouse)                        */\
+    0xA1, 0x01,                /* Collection (Application)             */\
+    0x09, 0x01,                /*   Usage (Pointer)                    */\
+    0xA1, 0x00,                /*   Collection (Physical)              */\
+    0x95, 0x03,                /*     Report Count (3)                 */\
+    0x75, 0x01,                /*     Report Size (1)                  */\
+    0x05, 0x09,                /*     Usage Page (Button)              */\
+    0x19, 0x01,                /*     Usage Minimum (0x01)             */\
+    0x29, 0x03,                /*     Usage Maximum (0x03)             */\
+    0x15, 0x00,                /*     Logical Minimum (0)              */\
+    0x25, 0x01,                /*     Logical Maximum (1)              */\
+    0x81, 0x02,                /*     Input (Data,Var,Abs)             */\
+    0x95, 0x01,                /*     Report Count (1)                 */\
+    0x75, 0x05,                /*     Report Size (5)                  */\
+    0x81, 0x03,                /*     Input (Const)                    */\
+    0x75, 0x08,                /*     Report Size (8)                  */\
+    0x95, 0x02,                /*     Report Count (2)                 */\
+    0x05, 0x01,                /*     Usage Page (Generic Desktop Ctrls) */\
+    0x09, 0x30,                /*     Usage (X)                        */\
+    0x09, 0x31,                /*     Usage (Y)                        */\
+    0x15, 0x81,                /*     Logical Minimum (-127)           */\
+    0x25, 0x7F,                /*     Logical Maximum (127)            */\
+    0x81, 0x06,                /*     Input (Data,Var,Rel)             */\
+    0xC0,                      /*   End Collection                     */\
+    0xC0,                      /* End Collection                       */
+
+/* HID keyboard boot protocol descriptor */
+#define        HID_KBD_BOOTPROTO_DESCR(...) \
+    0x05, 0x01,                /* Usage Page (Generic Desktop Ctrls)   */\
+    0x09, 0x06,                /* Usage (Keyboard)                     */\
+    0xA1, 0x01,                /* Collection (Application)             */\
+    0x05, 0x07,                /*   Usage Page (Kbrd/Keypad)           */\
+    0x19, 0xE0,                /*   Usage Minimum (0xE0)               */\
+    0x29, 0xE7,                /*   Usage Maximum (0xE7)               */\
+    0x15, 0x00,                /*   Logical Minimum (0)                */\
+    0x25, 0x01,                /*   Logical Maximum (1)                */\
+    0x75, 0x01,                /*   Report Size (1)                    */\
+    0x95, 0x08,                /*   Report Count (8)                   */\
+    0x81, 0x02,                /*   Input (Data,Var,Abs)               */\
+    0x95, 0x01,                /*   Report Count (1)                   */\
+    0x75, 0x08,                /*   Report Size (8)                    */\
+    0x81, 0x01,                /*   Input (Const,Array,Abs)            */\
+    0x95, 0x03,                /*   Report Count (3)                   */\
+    0x75, 0x01,                /*   Report Size (1)                    */\
+    0x05, 0x08,                /*   Usage Page (LEDs)                  */\
+    0x19, 0x01,                /*   Usage Minimum (Num Lock)           */\
+    0x29, 0x03,                /*   Usage Maximum (Scroll Lock)        */\
+    0x91, 0x02,                /*   Output (Data,Var,Abs)              */\
+    0x95, 0x05,                /*   Report Count (5)                   */\
+    0x75, 0x01,                /*   Report Size (1)                    */\
+    0x91, 0x01,                /*   Output (Const,Array,Abs)           */\
+    0x95, 0x06,                /*   Report Count (6)                   */\
+    0x75, 0x08,                /*   Report Size (8)                    */\
+    0x15, 0x00,                /*   Logical Minimum (0)                */\
+    0x26, 0xFF, 0x00,  /*   Logical Maximum (255)              */\
+    0x05, 0x07,                /*   Usage Page (Kbrd/Keypad)           */\
+    0x19, 0x00,                /*   Usage Minimum (0x00)               */\
+    0x2A, 0xFF, 0x00,  /*   Usage Maximum (0xFF)               */\
+    0x81, 0x00,                /*   Input (Data,Array,Abs)             */\
+    0xC0,              /* End Collection                       */
diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index cfad299dc313..126f0494bac2 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -6210,6 +6210,7 @@ uaudio_hid_detach(struct uaudio_softc *sc)
 DRIVER_MODULE_ORDERED(uaudio, uhub, uaudio_driver, uaudio_devclass, NULL, 0, 
SI_ORDER_ANY);
 MODULE_DEPEND(uaudio, usb, 1, 1, 1);
 MODULE_DEPEND(uaudio, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
+MODULE_DEPEND(uaudio, hid, 1, 1, 1);
 MODULE_VERSION(uaudio, 1);
 USB_PNP_HOST_INFO(uaudio_devs);
 USB_PNP_HOST_INFO(uaudio_vendor_midi);
diff --git a/sys/dev/usb/input/atp.c b/sys/dev/usb/input/atp.c
index 4fbdb06dd167..7b9b1eb04c9c 100644
--- a/sys/dev/usb/input/atp.c
+++ b/sys/dev/usb/input/atp.c
@@ -2633,6 +2633,7 @@ static driver_t atp_driver = {
 
 DRIVER_MODULE(atp, uhub, atp_driver, atp_devclass, NULL, 0);
 MODULE_DEPEND(atp, usb, 1, 1, 1);
+MODULE_DEPEND(atp, hid, 1, 1, 1);
 MODULE_VERSION(atp, 1);
 USB_PNP_HOST_INFO(fg_devs);
 USB_PNP_HOST_INFO(wsp_devs);
diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c
index a8a3bcb2f6c2..97c27608049c 100644
--- a/sys/dev/usb/input/uhid.c
+++ b/sys/dev/usb/input/uhid.c
@@ -907,5 +907,6 @@ static driver_t uhid_driver = {
 
 DRIVER_MODULE(uhid, uhub, uhid_driver, uhid_devclass, NULL, 0);
 MODULE_DEPEND(uhid, usb, 1, 1, 1);
+MODULE_DEPEND(uhid, hid, 1, 1, 1);
 MODULE_VERSION(uhid, 1);
 USB_PNP_HOST_INFO(uhid_devs);
diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c
index 4f27bf95b948..261a4b5aef95 100644
--- a/sys/dev/usb/input/ukbd.c
+++ b/sys/dev/usb/input/ukbd.c
@@ -2185,6 +2185,7 @@ static driver_t ukbd_driver = {
 
 DRIVER_MODULE(ukbd, uhub, ukbd_driver, ukbd_devclass, ukbd_driver_load, 0);
 MODULE_DEPEND(ukbd, usb, 1, 1, 1);
+MODULE_DEPEND(ukbd, hid, 1, 1, 1);
 #ifdef EVDEV_SUPPORT
 MODULE_DEPEND(ukbd, evdev, 1, 1, 1);
 #endif
diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c
index 69d177d62bc4..038ed8121df1 100644
--- a/sys/dev/usb/input/ums.c
+++ b/sys/dev/usb/input/ums.c
@@ -1213,6 +1213,7 @@ static driver_t ums_driver = {
 
 DRIVER_MODULE(ums, uhub, ums_driver, ums_devclass, NULL, 0);
 MODULE_DEPEND(ums, usb, 1, 1, 1);
+MODULE_DEPEND(ums, hid, 1, 1, 1);
 #ifdef EVDEV_SUPPORT
 MODULE_DEPEND(ums, evdev, 1, 1, 1);
 #endif
diff --git a/sys/dev/usb/input/usb_rdesc.h b/sys/dev/usb/input/usb_rdesc.h
index 889381e82c15..5dbfdb91f3f2 100644
--- a/sys/dev/usb/input/usb_rdesc.h
+++ b/sys/dev/usb/input/usb_rdesc.h
@@ -1,11 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
- * Copyright (c) 2000 Nick Hibma <n_hi...@freebsd.org>
- * All rights reserved.
- *
- * Copyright (c) 2005 Ed Schouten <e...@freebsd.org>
- * All rights reserved.
+ * Copyright (c) 2020 Vladimir Kondratyev <w...@freebsd.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,277 +26,14 @@
  *
  * $FreeBSD$
  *
- * This file contains replacements for broken HID report descriptors.
+ * This a proxy file for replacements for broken HID report descriptors.
  */
 
-#define        UHID_GRAPHIRE_REPORT_DESCR(...) \
-    0x05, 0x0d,                    /*  USAGE_PAGE (Digitizers)         */\
-    0x09, 0x01,                    /*  USAGE (Digitizer)               */\
-    0xa1, 0x01,                    /*  COLLECTION (Application)                
*/\
-    0x85, 0x02,                    /*    REPORT_ID (2)                 */\
-    0x05, 0x0d,                    /*    USAGE_PAGE (Digitizers)       */\
-    0x09, 0x01,                    /*    USAGE (Digitizer)             */\
-    0xa1, 0x00,                    /*    COLLECTION (Physical)         */\
-    0x15, 0x00,                    /*      LOGICAL_MINIMUM (0)         */\
-    0x25, 0x01,                    /*      LOGICAL_MAXIMUM (1)         */\
-    0x09, 0x33,                    /*      USAGE (Touch)               */\
-    0x95, 0x01,                    /*      REPORT_COUNT (1)            */\
-    0x75, 0x01,                    /*      REPORT_SIZE (1)             */\
-    0x81, 0x02,                    /*      INPUT (Data,Var,Abs)                
*/\
-    0x09, 0x44,                    /*      USAGE (Barrel Switch)       */\
-    0x95, 0x02,                    /*      REPORT_COUNT (2)            */\
-    0x75, 0x01,                    /*      REPORT_SIZE (1)             */\
-    0x81, 0x02,                    /*      INPUT (Data,Var,Abs)                
*/\
-    0x09, 0x00,                    /*      USAGE (Undefined)           */\
-    0x95, 0x02,                    /*      REPORT_COUNT (2)            */\
-    0x75, 0x01,                    /*      REPORT_SIZE (1)             */\
-    0x81, 0x03,                    /*      INPUT (Cnst,Var,Abs)                
*/\
-    0x09, 0x3c,                    /*      USAGE (Invert)              */\
-    0x95, 0x01,                    /*      REPORT_COUNT (1)            */\
-    0x75, 0x01,                    /*      REPORT_SIZE (1)             */\
-    0x81, 0x02,                    /*      INPUT (Data,Var,Abs)                
*/\
-    0x09, 0x38,                    /*      USAGE (Transducer Index)    */\
-    0x95, 0x01,                    /*      REPORT_COUNT (1)            */\
-    0x75, 0x01,                    /*      REPORT_SIZE (1)             */\
-    0x81, 0x02,                    /*      INPUT (Data,Var,Abs)                
*/\
-    0x09, 0x32,                    /*      USAGE (In Range)            */\
-    0x95, 0x01,                    /*      REPORT_COUNT (1)            */\
-    0x75, 0x01,                    /*      REPORT_SIZE (1)             */\
-    0x81, 0x02,                    /*      INPUT (Data,Var,Abs)                
*/\
-    0x05, 0x01,                    /*      USAGE_PAGE (Generic Desktop)        
*/\
-    0x09, 0x30,                    /*      USAGE (X)                   */\
-    0x15, 0x00,                    /*      LOGICAL_MINIMUM (0)         */\
-    0x26, 0xde, 0x27,              /*      LOGICAL_MAXIMUM (10206)     */\
-    0x95, 0x01,                    /*      REPORT_COUNT (1)            */\
-    0x75, 0x10,                    /*      REPORT_SIZE (16)            */\
-    0x81, 0x02,                    /*      INPUT (Data,Var,Abs)                
*/\
-    0x09, 0x31,                    /*      USAGE (Y)                   */\
-    0x26, 0xfe, 0x1c,              /*      LOGICAL_MAXIMUM (7422)      */\
-    0x95, 0x01,                    /*      REPORT_COUNT (1)            */\
-    0x75, 0x10,                    /*      REPORT_SIZE (16)            */\
-    0x81, 0x02,                    /*      INPUT (Data,Var,Abs)                
*/\
-    0x05, 0x0d,                    /*      USAGE_PAGE (Digitizers)     */\
-    0x09, 0x30,                    /*      USAGE (Tip Pressure)                
*/\
-    0x26, 0xff, 0x01,              /*      LOGICAL_MAXIMUM (511)       */\
-    0x95, 0x01,                    /*      REPORT_COUNT (1)            */\
-    0x75, 0x10,                    /*      REPORT_SIZE (16)            */\
-    0x81, 0x02,                    /*      INPUT (Data,Var,Abs)                
*/\
-    0xc0,                          /*    END_COLLECTION                        
*/\
-    0x05, 0x0d,                    /*    USAGE_PAGE (Digitizers)       */\
-    0x09, 0x00,                    /*    USAGE (Undefined)             */\
-    0x85, 0x02,                    /*    REPORT_ID (2)                 */\
-    0x95, 0x01,                    /*    REPORT_COUNT (1)              */\
-    0xb1, 0x02,                    /*    FEATURE (Data,Var,Abs)                
*/\
-    0x09, 0x00,                    /*    USAGE (Undefined)             */\
-    0x85, 0x03,                    /*    REPORT_ID (3)                 */\
-    0x95, 0x01,                    /*    REPORT_COUNT (1)              */\
-    0xb1, 0x02,                    /*    FEATURE (Data,Var,Abs)                
*/\
-    0xc0,                          /*  END_COLLECTION                  */\
-
-#define        UHID_GRAPHIRE3_4X5_REPORT_DESCR(...) \
-    0x05, 0x01,                    /* USAGE_PAGE (Generic Desktop)     */\
-    0x09, 0x02,                    /* USAGE (Mouse)                    */\
-    0xa1, 0x01,                    /* COLLECTION (Application)         */\
-    0x85, 0x01,                    /*   REPORT_ID (1)                  */\
-    0x09, 0x01,                    /*   USAGE (Pointer)                        
*/\
-    0xa1, 0x00,                    /*   COLLECTION (Physical)          */\
-    0x05, 0x09,                    /*     USAGE_PAGE (Button)          */\
-    0x19, 0x01,                    /*     USAGE_MINIMUM (Button 1)     */\
-    0x29, 0x03,                    /*     USAGE_MAXIMUM (Button 3)     */\
-    0x15, 0x00,                    /*     LOGICAL_MINIMUM (0)          */\
-    0x25, 0x01,                    /*     LOGICAL_MAXIMUM (1)          */\
-    0x95, 0x03,                    /*     REPORT_COUNT (3)             */\
-    0x75, 0x01,                    /*     REPORT_SIZE (1)              */\
-    0x81, 0x02,                    /*     INPUT (Data,Var,Abs)         */\
-    0x95, 0x01,                    /*     REPORT_COUNT (1)             */\
-    0x75, 0x05,                    /*     REPORT_SIZE (5)              */\
-    0x81, 0x01,                    /*     INPUT (Cnst,Ary,Abs)         */\
-    0x05, 0x01,                    /*     USAGE_PAGE (Generic Desktop) */\
-    0x09, 0x30,                    /*     USAGE (X)                    */\
-    0x09, 0x31,                    /*     USAGE (Y)                    */\
-    0x09, 0x38,                    /*     USAGE (Wheel)                        
*/\
-    0x15, 0x81,                    /*     LOGICAL_MINIMUM (-127)       */\
-    0x25, 0x7f,                    /*     LOGICAL_MAXIMUM (127)                
*/\
-    0x75, 0x08,                    /*     REPORT_SIZE (8)              */\
-    0x95, 0x03,                    /*     REPORT_COUNT (3)             */\
-    0x81, 0x06,                    /*     INPUT (Data,Var,Rel)         */\
-    0xc0,                          /*   END_COLLECTION                 */\
-    0xc0,                          /* END_COLLECTION                   */\
-    0x05, 0x0d,                    /* USAGE_PAGE (Digitizers)          */\
-    0x09, 0x01,                    /* USAGE (Pointer)                  */\
-    0xa1, 0x01,                    /* COLLECTION (Applicaption)                
*/\
-    0x85, 0x02,                    /*   REPORT_ID (2)                  */\
-    0x05, 0x0d,                    /*   USAGE_PAGE (Digitizers)                
*/\
-    0x09, 0x01,                    /*   USAGE (Digitizer)              */\
-    0xa1, 0x00,                    /*   COLLECTION (Physical)          */\
-    0x09, 0x33,                    /*     USAGE (Touch)                        
*/\
-    0x09, 0x44,                    /*     USAGE (Barrel Switch)                
*/\
-    0x09, 0x44,                    /*     USAGE (Barrel Switch)                
*/\
-    0x15, 0x00,                    /*     LOGICAL_MINIMUM (0)          */\
-    0x25, 0x01,                    /*     LOGICAL_MAXIMUM (1)          */\
-    0x75, 0x01,                    /*     REPORT_SIZE (1)              */\
-    0x95, 0x03,                    /*     REPORT_COUNT (3)             */\
-    0x81, 0x02,                    /*     INPUT (Data,Var,Abs)         */\
-    0x75, 0x01,                    /*     REPORT_SIZE (1)              */\
-    0x95, 0x02,                    /*     REPORT_COUNT (2)             */\
-    0x81, 0x01,                    /*     INPUT (Cnst,Ary,Abs)         */\
-    0x09, 0x3c,                    /*     USAGE (Invert)               */\
-    0x09, 0x38,                    /*     USAGE (Transducer Index)     */\
-    0x09, 0x32,                    /*     USAGE (In Range)             */\
-    0x75, 0x01,                    /*     REPORT_SIZE (1)              */\
-    0x95, 0x03,                    /*     REPORT_COUNT (3)             */\
-    0x81, 0x02,                    /*     INPUT (Data,Var,Abs)         */\
-    0x05, 0x01,                    /*     USAGE_PAGE (Generic Desktop) */\
-    0x09, 0x30,                    /*     USAGE (X)                    */\
-    0x15, 0x00,                    /*     LOGICAL_MINIMUM (0)          */\
-    0x26, 0xde, 0x27,              /*     LOGICAL_MAXIMUM (10206)      */\
-    0x75, 0x10,                    /*     REPORT_SIZE (16)             */\
-    0x95, 0x01,                    /*     REPORT_COUNT (1)             */\
-    0x81, 0x02,                    /*     INPUT (Data,Var,Abs)         */\
-    0x09, 0x31,                    /*     USAGE (Y)                    */\
-    0x26, 0xfe, 0x1c,              /*     LOGICAL_MAXIMUM (7422)       */\
-    0x75, 0x10,                    /*     REPORT_SIZE (16)             */\
-    0x95, 0x01,                    /*     REPORT_COUNT (1)             */\
-    0x81, 0x02,                    /*     INPUT (Data,Var,Abs)         */\
-    0x05, 0x0d,                    /*     USAGE_PAGE (Digitizers)      */\
-    0x09, 0x30,                    /*     USAGE (Tip Pressure)         */\
-    0x26, 0xff, 0x01,              /*     LOGICAL_MAXIMUM (511)                
*/\
-    0x75, 0x10,                    /*     REPORT_SIZE (16)             */\
-    0x95, 0x01,                    /*     REPORT_COUNT (1)             */\
-    0x81, 0x02,                    /*     INPUT (Data,Var,Abs)         */\
-    0xc0,                          /*   END_COLLECTION                 */\
-    0x05, 0x0d,                    /*   USAGE_PAGE (Digitizers)                
*/\
-    0x09, 0x00,                    /*   USAGE (Undefined)              */\
-    0x85, 0x02,                    /*   REPORT_ID (2)                  */\
-    0x95, 0x01,                    /*   REPORT_COUNT (1)               */\
-    0xb1, 0x02,                    /*   FEATURE (Data,Var,Abs)         */\
-    0x09, 0x00,                    /*   USAGE (Undefined)              */\
-    0x85, 0x03,                    /*   REPORT_ID (3)                  */\
-    0x95, 0x01,                    /*   REPORT_COUNT (1)               */\
-    0xb1, 0x02,                    /*   FEATURE (Data,Var,Abs)         */\
-    0xc0                           /* END_COLLECTION                   */\
-
-/*
- * The descriptor has no output report format, thus preventing you from
- * controlling the LEDs and the built-in rumblers.
- */
-#define        UHID_XB360GP_REPORT_DESCR(...) \
-    0x05, 0x01,                /* USAGE PAGE (Generic Desktop)         */\
-    0x09, 0x05,                /* USAGE (Gamepad)                      */\
-    0xa1, 0x01,                /* COLLECTION (Application)             */\
-    /* Unused */\
-    0x75, 0x08,                /*  REPORT SIZE (8)                     */\
-    0x95, 0x01,                /*  REPORT COUNT (1)                    */\
-    0x81, 0x01,                /*  INPUT (Constant)                    */\
-    /* Byte count */\
-    0x75, 0x08,                /*  REPORT SIZE (8)                     */\
-    0x95, 0x01,                /*  REPORT COUNT (1)                    */\
-    0x05, 0x01,                /*  USAGE PAGE (Generic Desktop)        */\
-    0x09, 0x3b,                /*  USAGE (Byte Count)                  */\
-    0x81, 0x01,                /*  INPUT (Constant)                    */\
-    /* D-Pad */\
-    0x05, 0x01,                /*  USAGE PAGE (Generic Desktop)        */\
-    0x09, 0x01,                /*  USAGE (Pointer)                     */\
-    0xa1, 0x00,                /*  COLLECTION (Physical)               */\
-    0x75, 0x01,                /*   REPORT SIZE (1)                    */\
-    0x15, 0x00,                /*   LOGICAL MINIMUM (0)                */\
-    0x25, 0x01,                /*   LOGICAL MAXIMUM (1)                */\
-    0x35, 0x00,                /*   PHYSICAL MINIMUM (0)               */\
-    0x45, 0x01,                /*   PHYSICAL MAXIMUM (1)               */\
-    0x95, 0x04,                /*   REPORT COUNT (4)                   */\
-    0x05, 0x01,                /*   USAGE PAGE (Generic Desktop)       */\
-    0x09, 0x90,                /*   USAGE (D-Pad Up)                   */\
-    0x09, 0x91,                /*   USAGE (D-Pad Down)                 */\
-    0x09, 0x93,                /*   USAGE (D-Pad Left)                 */\
-    0x09, 0x92,                /*   USAGE (D-Pad Right)                */\
-    0x81, 0x02,                /*   INPUT (Data, Variable, Absolute)   */\
-    0xc0,              /*  END COLLECTION                      */\
-    /* Buttons 5-11 */\
-    0x75, 0x01,                /*  REPORT SIZE (1)                     */\
-    0x15, 0x00,                /*  LOGICAL MINIMUM (0)                 */\
-    0x25, 0x01,                /*  LOGICAL MAXIMUM (1)                 */\
-    0x35, 0x00,                /*  PHYSICAL MINIMUM (0)                */\
-    0x45, 0x01,                /*  PHYSICAL MAXIMUM (1)                */\
-    0x95, 0x07,                /*  REPORT COUNT (7)                    */\
-    0x05, 0x09,                /*  USAGE PAGE (Button)                 */\
-    0x09, 0x08,                /*  USAGE (Button 8)                    */\
-    0x09, 0x07,                /*  USAGE (Button 7)                    */\
-    0x09, 0x09,                /*  USAGE (Button 9)                    */\
-    0x09, 0x0a,                /*  USAGE (Button 10)                   */\
-    0x09, 0x05,                /*  USAGE (Button 5)                    */\
-    0x09, 0x06,                /*  USAGE (Button 6)                    */\
-    0x09, 0x0b,                /*  USAGE (Button 11)                   */\
-    0x81, 0x02,                /*  INPUT (Data, Variable, Absolute)    */\
-    /* Unused */\
-    0x75, 0x01,                /*  REPORT SIZE (1)                     */\
-    0x95, 0x01,                /*  REPORT COUNT (1)                    */\
-    0x81, 0x01,                /*  INPUT (Constant)                    */\
-    /* Buttons 1-4 */\
-    0x75, 0x01,                /*  REPORT SIZE (1)                     */\
-    0x15, 0x00,                /*  LOGICAL MINIMUM (0)                 */\
-    0x25, 0x01,                /*  LOGICAL MAXIMUM (1)                 */\
-    0x35, 0x00,                /*  PHYSICAL MINIMUM (0)                */\
-    0x45, 0x01,                /*  PHYSICAL MAXIMUM (1)                */\
-    0x95, 0x04,                /*  REPORT COUNT (4)                    */\
-    0x05, 0x09,                /*  USAGE PAGE (Button)                 */\
-    0x19, 0x01,                /*  USAGE MINIMUM (Button 1)            */\
-    0x29, 0x04,                /*  USAGE MAXIMUM (Button 4)            */\
-    0x81, 0x02,                /*  INPUT (Data, Variable, Absolute)    */\
-    /* Triggers */\
-    0x75, 0x08,                /*  REPORT SIZE (8)                     */\
-    0x15, 0x00,                /*  LOGICAL MINIMUM (0)                 */\
-    0x26, 0xff, 0x00,  /*  LOGICAL MAXIMUM (255)               */\
-    0x35, 0x00,                /*  PHYSICAL MINIMUM (0)                */\
-    0x46, 0xff, 0x00,  /*  PHYSICAL MAXIMUM (255)              */\
-    0x95, 0x02,                /*  REPORT SIZE (2)                     */\
-    0x05, 0x01,                /*  USAGE PAGE (Generic Desktop)        */\
-    0x09, 0x32,                /*  USAGE (Z)                           */\
-    0x09, 0x35,                /*  USAGE (Rz)                          */\
-    0x81, 0x02,                /*  INPUT (Data, Variable, Absolute)    */\
-    /* Sticks */\
-    0x75, 0x10,                /*  REPORT SIZE (16)                    */\
-    0x16, 0x00, 0x80,  /*  LOGICAL MINIMUM (-32768)            */\
-    0x26, 0xff, 0x7f,  /*  LOGICAL MAXIMUM (32767)             */\
-    0x36, 0x00, 0x80,  /*  PHYSICAL MINIMUM (-32768)           */\
-    0x46, 0xff, 0x7f,  /*  PHYSICAL MAXIMUM (32767)            */\
-    0x95, 0x04,                /*  REPORT COUNT (4)                    */\
-    0x05, 0x01,                /*  USAGE PAGE (Generic Desktop)        */\
-    0x09, 0x30,                /*  USAGE (X)                           */\
-    0x09, 0x31,                /*  USAGE (Y)                           */\
-    0x09, 0x33,                /*  USAGE (Rx)                          */\
-    0x09, 0x34,                /*  USAGE (Ry)                          */\
-    0x81, 0x02,                /*  INPUT (Data, Variable, Absolute)    */\
-    /* Unused */\
-    0x75, 0x30,                /*  REPORT SIZE (48)                    */\
-    0x95, 0x01,                /*  REPORT COUNT (1)                    */\
-    0x81, 0x01,                /*  INPUT (Constant)                    */\
-    0xc0               /* END COLLECTION                       */\
+#include <dev/hid/hidrdesc.h>
 
-/* Fixed report descriptor for Super Nintendo gamepads */
-#define        UHID_SNES_REPORT_DESCR(...) \
-    0x05, 0x01,         /*  Usage Page (Desktop),           */\
-    0x09, 0x04,         /*  Usage (Joystik),                */\
-    0xA1, 0x01,         /*  Collection (Application),       */\
-    0xA1, 0x02,         /*      Collection (Logical),       */\
-    0x14,               /*          Logical Minimum (0),    */\
-    0x75, 0x08,         /*          Report Size (8),        */\
-    0x95, 0x03,         /*          Report Count (3),       */\
-    0x81, 0x01,         /*          Input (Constant),       */\
-    0x26, 0xFF, 0x00,   /*          Logical Maximum (255),  */\
-    0x95, 0x02,         /*          Report Count (2),       */\
-    0x09, 0x30,         /*          Usage (X),              */\
-    0x09, 0x31,         /*          Usage (Y),              */\
-    0x81, 0x02,         /*          Input (Variable),       */\
-    0x75, 0x01,         /*          Report Size (1),        */\
-    0x95, 0x04,         /*          Report Count (4),       */\
-    0x81, 0x01,         /*          Input (Constant),       */\
-    0x25, 0x01,         /*          Logical Maximum (1),    */\
-    0x95, 0x0A,         /*          Report Count (10),      */\
*** 1323 LINES SKIPPED ***
_______________________________________________
dev-commits-src-main@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"

Reply via email to