summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorbouyer <bouyer@NetBSD.org>2017-12-10 17:03:07 +0000
committerbouyer <bouyer@NetBSD.org>2017-12-10 17:03:07 +0000
commitdc9bc4742b8923d82c37b257e2f8581d35e2f4f8 (patch)
tree21a99cfe05c01fcaed49463363f8f26796e1fdfa /sys/dev
parent52c1bd9af47066409417ec0463ae41e6cce0b30a (diff)
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.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/bluetooth/bthidev.c6
-rw-r--r--sys/dev/bluetooth/btkbd.c10
-rw-r--r--sys/dev/bluetooth/btmagic.c6
-rw-r--r--sys/dev/bluetooth/btms.c6
-rw-r--r--sys/dev/fdt/gpiokeys.c8
-rw-r--r--sys/dev/hid/files.hid13
-rw-r--r--sys/dev/hid/hid.c (renamed from sys/dev/usb/hid.c)6
-rw-r--r--sys/dev/hid/hid.h422
-rw-r--r--sys/dev/hid/hidkbdmap.c (renamed from sys/dev/usb/ukbdmap.c)106
-rw-r--r--sys/dev/hid/hidms.c290
-rw-r--r--sys/dev/hid/hidms.h63
-rw-r--r--sys/dev/i2c/tcakp.c8
-rw-r--r--sys/dev/usb/files.usb5
-rw-r--r--sys/dev/usb/hid.h89
-rw-r--r--sys/dev/usb/uatp.c6
-rw-r--r--sys/dev/usb/ucycom.c6
-rw-r--r--sys/dev/usb/uhid.c6
-rw-r--r--sys/dev/usb/uhidev.c6
-rw-r--r--sys/dev/usb/ukbd.c10
-rw-r--r--sys/dev/usb/ums.c286
-rw-r--r--sys/dev/usb/usbhid.h130
-rw-r--r--sys/dev/usb/uthum.c6
-rw-r--r--sys/dev/usb/uts.c6
-rw-r--r--sys/dev/usb/uyurex.c6
24 files changed, 923 insertions, 583 deletions
diff --git a/sys/dev/bluetooth/bthidev.c b/sys/dev/bluetooth/bthidev.c
index 9089d821a24..8c01e1e8a75 100644
--- a/sys/dev/bluetooth/bthidev.c
+++ b/sys/dev/bluetooth/bthidev.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bthidev.c,v 1.29 2014/08/05 07:55:31 rtr Exp $ */
+/* $NetBSD: bthidev.c,v 1.30 2017/12/10 17:03:07 bouyer Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.29 2014/08/05 07:55:31 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.30 2017/12/10 17:03:07 bouyer Exp $");
#include <sys/param.h>
#include <sys/condvar.h>
@@ -54,7 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.29 2014/08/05 07:55:31 rtr Exp $");
#include <netbt/bluetooth.h>
#include <netbt/l2cap.h>
-#include <dev/usb/hid.h>
+#include <dev/hid/hid.h>
#include <dev/bluetooth/btdev.h>
#include <dev/bluetooth/bthid.h>
#include <dev/bluetooth/bthidev.h>
diff --git a/sys/dev/bluetooth/btkbd.c b/sys/dev/bluetooth/btkbd.c
index f5a27de8000..ee0c7098d98 100644
--- a/sys/dev/bluetooth/btkbd.c
+++ b/sys/dev/bluetooth/btkbd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: btkbd.c,v 1.17 2014/11/16 16:20:00 ozaki-r Exp $ */
+/* $NetBSD: btkbd.c,v 1.18 2017/12/10 17:03:07 bouyer Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.17 2014/11/16 16:20:00 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.18 2017/12/10 17:03:07 bouyer Exp $");
#include <sys/param.h>
#include <sys/callout.h>
@@ -81,7 +81,7 @@ __KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.17 2014/11/16 16:20:00 ozaki-r Exp $");
#include <dev/bluetooth/bthid.h>
#include <dev/bluetooth/bthidev.h>
-#include <dev/usb/hid.h>
+#include <dev/hid/hid.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
@@ -163,10 +163,10 @@ static const struct wskbd_accessops btkbd_accessops = {
};
/* wskbd(4) keymap data */
-extern const struct wscons_keydesc ukbd_keydesctab[];
+extern const struct wscons_keydesc hidkbd_keydesctab[];
const struct wskbd_mapdata btkbd_keymapdata = {
- ukbd_keydesctab,
+ hidkbd_keydesctab,
#if defined(BTKBD_LAYOUT)
BTKBD_LAYOUT,
#elif defined(PCKBD_LAYOUT)
diff --git a/sys/dev/bluetooth/btmagic.c b/sys/dev/bluetooth/btmagic.c
index e6019007e84..b64ee6d1f01 100644
--- a/sys/dev/bluetooth/btmagic.c
+++ b/sys/dev/bluetooth/btmagic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: btmagic.c,v 1.16 2016/07/07 06:55:41 msaitoh Exp $ */
+/* $NetBSD: btmagic.c,v 1.17 2017/12/10 17:03:07 bouyer Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -85,7 +85,7 @@
*****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.16 2016/07/07 06:55:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.17 2017/12/10 17:03:07 bouyer Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -108,7 +108,7 @@ __KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.16 2016/07/07 06:55:41 msaitoh Exp $")
#include <dev/bluetooth/bthid.h>
#include <dev/bluetooth/bthidev.h>
-#include <dev/usb/hid.h>
+#include <dev/hid/hid.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdevs.h>
diff --git a/sys/dev/bluetooth/btms.c b/sys/dev/bluetooth/btms.c
index 62788164abe..b19d481938a 100644
--- a/sys/dev/bluetooth/btms.c
+++ b/sys/dev/bluetooth/btms.c
@@ -1,4 +1,4 @@
-/* $NetBSD: btms.c,v 1.12 2014/12/13 19:28:55 nonaka Exp $ */
+/* $NetBSD: btms.c,v 1.13 2017/12/10 17:03:07 bouyer Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btms.c,v 1.12 2014/12/13 19:28:55 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btms.c,v 1.13 2017/12/10 17:03:07 bouyer Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -79,7 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: btms.c,v 1.12 2014/12/13 19:28:55 nonaka Exp $");
#include <dev/bluetooth/bthid.h>
#include <dev/bluetooth/bthidev.h>
-#include <dev/usb/hid.h>
+#include <dev/hid/hid.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
diff --git a/sys/dev/fdt/gpiokeys.c b/sys/dev/fdt/gpiokeys.c
index 11033f25016..a77144fc232 100644
--- a/sys/dev/fdt/gpiokeys.c
+++ b/sys/dev/fdt/gpiokeys.c
@@ -1,4 +1,4 @@
-/* $NetBSD: gpiokeys.c,v 1.5 2017/09/23 23:54:30 jmcneill Exp $ */
+/* $NetBSD: gpiokeys.c,v 1.6 2017/12/10 17:03:07 bouyer Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gpiokeys.c,v 1.5 2017/09/23 23:54:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpiokeys.c,v 1.6 2017/12/10 17:03:07 bouyer Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -59,9 +59,9 @@ static void gpiokeys_attach(device_t, device_t, void *);
static void gpiokeys_tick(void *);
static void gpiokeys_task(void *);
-extern const struct wscons_keydesc ukbd_keydesctab[];
+extern const struct wscons_keydesc hidkbd_keydesctab[];
static const struct wskbd_mapdata gpiokeys_keymapdata = {
- ukbd_keydesctab,
+ hidkbd_keydesctab,
KB_US,
};
diff --git a/sys/dev/hid/files.hid b/sys/dev/hid/files.hid
new file mode 100644
index 00000000000..5e7effd80a5
--- /dev/null
+++ b/sys/dev/hid/files.hid
@@ -0,0 +1,13 @@
+# $NetBSD: files.hid,v 1.1 2017/12/10 17:03:07 bouyer Exp $
+
+# Human Interface Devices
+# Used by USB, bluetooth and i2c
+
+# HID processing
+define hid
+file dev/hid/hid.c hid
+
+define hidms
+file dev/hid/hidms.c hidms
+
+file dev/hid/hidkbdmap.c ukbd | btkbd | linux_keymap
diff --git a/sys/dev/usb/hid.c b/sys/dev/hid/hid.c
index a12ab53445a..64c870cdfd2 100644
--- a/sys/dev/usb/hid.c
+++ b/sys/dev/hid/hid.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hid.c,v 1.47 2017/06/01 02:45:11 chs Exp $ */
+/* $NetBSD: hid.c,v 1.1 2017/12/10 17:03:07 bouyer Exp $ */
/* $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.47 2017/06/01 02:45:11 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.1 2017/12/10 17:03:07 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.47 2017/06/01 02:45:11 chs Exp $");
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
-#include <dev/usb/hid.h>
+#include <dev/hid/hid.h>
#ifdef UHIDEV_DEBUG
#define DPRINTF(x) if (uhidevdebug) printf x
diff --git a/sys/dev/hid/hid.h b/sys/dev/hid/hid.h
new file mode 100644
index 00000000000..93cf9c0b9ae
--- /dev/null
+++ b/sys/dev/hid/hid.h
@@ -0,0 +1,422 @@
+/* $NetBSD: hid.h,v 1.1 2017/12/10 17:03:07 bouyer Exp $ */
+/* $FreeBSD: src/sys/dev/usb/hid.h,v 1.7 1999/11/17 22:33:40 n_hibma Exp $ */
+
+/*
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart@augustsson.net) at
+ * Carlstedt Research & Technology.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _HIDHID_H_
+#define _HIDHID_H_
+
+#ifdef _KERNEL
+
+enum hid_kind {
+ hid_input,
+ hid_output,
+ hid_feature,
+ hid_collection,
+ hid_endcollection,
+ hid_none
+};
+
+struct hid_location {
+ uint32_t size;
+ uint32_t count;
+ uint32_t pos;
+};
+
+struct hid_item {
+ /* Global */
+ int32_t _usage_page;
+ int32_t logical_minimum;
+ int32_t logical_maximum;
+ int32_t physical_minimum;
+ int32_t physical_maximum;
+ int32_t unit_exponent;
+ int32_t unit;
+ int32_t report_ID;
+ /* Local */
+ int32_t usage;
+ int32_t usage_minimum;
+ int32_t usage_maximum;
+ int32_t designator_index;
+ int32_t designator_minimum;
+ int32_t designator_maximum;
+ int32_t string_index;
+ int32_t string_minimum;
+ int32_t string_maximum;
+ int32_t set_delimiter;
+ /* Misc */
+ int32_t collection;
+ int collevel;
+ enum hid_kind kind;
+ uint32_t flags;
+ /* Location */
+ struct hid_location loc;
+ /* */
+ struct hid_item *next;
+};
+
+struct hid_data *hid_start_parse(const void *, int, enum hid_kind);
+void hid_end_parse(struct hid_data *);
+int hid_get_item(struct hid_data *, struct hid_item *);
+int hid_report_size(const void *, int, enum hid_kind, uint8_t);
+int hid_locate(const void *, int, uint32_t, uint8_t, enum hid_kind,
+ struct hid_location *, uint32_t *);
+long hid_get_data(const u_char *, const struct hid_location *);
+u_long hid_get_udata(const u_char *, const struct hid_location *);
+int hid_is_collection(const void *, int, uint8_t, uint32_t);
+
+#endif /* _KERNEL */
+
+/* Usage pages */
+#define HUP_UNDEFINED 0x0000
+#define HUP_GENERIC_DESKTOP 0x0001
+#define HUP_SIMULATION 0x0002
+#define HUP_VR_CONTROLS 0x0003
+#define HUP_SPORTS_CONTROLS 0x0004
+#define HUP_GAMING_CONTROLS 0x0005
+#define HUP_KEYBOARD 0x0007
+#define HUP_LEDS 0x0008
+#define HUP_BUTTON 0x0009
+#define HUP_ORDINALS 0x000a
+#define HUP_TELEPHONY 0x000b
+#define HUP_CONSUMER 0x000c
+#define HUP_DIGITIZERS 0x000d
+#define HUP_PHYSICAL_IFACE 0x000e
+#define HUP_UNICODE 0x0010
+#define HUP_ALPHANUM_DISPLAY 0x0014
+#define HUP_MONITOR 0x0080
+#define HUP_MONITOR_ENUM_VAL 0x0081
+#define HUP_VESA_VC 0x0082
+#define HUP_VESA_CMD 0x0083
+#define HUP_POWER 0x0084
+#define HUP_BATTERY 0x0085
+#define HUP_BARCODE_SCANNER 0x008b
+#define HUP_SCALE 0x008c
+#define HUP_CAMERA_CONTROL 0x0090
+#define HUP_ARCADE 0x0091
+#define HUP_VENDOR 0x00ff
+#define HUP_MICROSOFT 0xff00
+/* XXX compat */
+#define HUP_APPLE 0x00ff
+#define HUP_WACOM 0xff00
+
+/* Usages, Power Device */
+#define HUP_INAME 0x0001
+#define HUP_PRESENT_STATUS 0x0002
+#define HUP_CHANGED_STATUS 0x0003
+#define HUP_UPS 0x0004
+#define HUP_POWER_SUPPLY 0x0005
+#define HUP_BATTERY_SYSTEM 0x0010
+#define HUP_BATTERY_SYSTEM_ID 0x0011
+#define HUP_PD_BATTERY 0x0012
+#define HUP_BATTERY_ID 0x0013
+#define HUP_CHARGER 0x0014
+#define HUP_CHARGER_ID 0x0015
+#define HUP_POWER_CONVERTER 0x0016
+#define HUP_POWER_CONVERTER_ID 0x0017
+#define HUP_OUTLET_SYSTEM 0x0018
+#define HUP_OUTLET_SYSTEM_ID 0x0019
+#define HUP_INPUT 0x001a
+#define HUP_INPUT_ID 0x001b
+#define HUP_OUTPUT 0x001c
+#define HUP_OUTPUT_ID 0x001d
+#define HUP_FLOW 0x001e
+#define HUP_FLOW_ID 0x001f
+#define HUP_OUTLET 0x0020
+#define HUP_OUTLET_ID 0x0021
+#define HUP_GANG 0x0022
+#define HUP_GANG_ID 0x0023
+#define HUP_POWER_SUMMARY 0x0024
+#define HUP_POWER_SUMMARY_ID 0x0025
+#define HUP_VOLTAGE 0x0030
+#define HUP_CURRENT 0x0031
+#define HUP_FREQUENCY 0x0032
+#define HUP_APPARENT_POWER 0x0033
+#define HUP_ACTIVE_POWER 0x0034
+#define HUP_PERCENT_LOAD 0x0035
+#define HUP_TEMPERATURE 0x0036
+#define HUP_HUMIDITY 0x0037
+#define HUP_BADCOUNT 0x0038
+#define HUP_CONFIG_VOLTAGE 0x0040
+#define HUP_CONFIG_CURRENT 0x0041
+#define HUP_CONFIG_FREQUENCY 0x0042
+#define HUP_CONFIG_APP_POWER 0x0043
+#define HUP_CONFIG_ACT_POWER 0x0044
+#define HUP_CONFIG_PERCENT_LOAD 0x0045
+#define HUP_CONFIG_TEMPERATURE 0x0046
+#define HUP_CONFIG_HUMIDITY 0x0047
+#define HUP_SWITCHON_CONTROL 0x0050
+#define HUP_SWITCHOFF_CONTROL 0x0051
+#define HUP_TOGGLE_CONTROL 0x0052
+#define HUP_LOW_VOLT_TRANSF 0x0053
+#define HUP_HIGH_VOLT_TRANSF 0x0054
+#define HUP_DELAYBEFORE_REBOOT 0x0055
+#define HUP_DELAYBEFORE_STARTUP 0x0056
+#define HUP_DELAYBEFORE_SHUTDWN 0x0057
+#define HUP_TEST 0x0058
+#define HUP_MODULE_RESET 0x0059
+#define HUP_AUDIBLE_ALRM_CTL 0x005a
+#define HUP_PRESENT 0x0060
+#define HUP_GOOD 0x0061
+#define HUP_INTERNAL_FAILURE 0x0062
+#define HUP_PD_VOLT_OUTOF_RANGE 0x0063
+#define HUP_FREQ_OUTOFRANGE 0x0064
+#define HUP_OVERLOAD 0x0065
+#define HUP_OVERCHARGED 0x0066
+#define HUP_OVERTEMPERATURE 0x0067
+#define HUP_SHUTDOWN_REQUESTED 0x0068
+#define HUP_SHUTDOWN_IMMINENT 0x0069
+#define HUP_SWITCH_ON_OFF 0x006b
+#define HUP_SWITCHABLE 0x006c
+#define HUP_USED 0x006d
+#define HUP_BOOST 0x006e
+#define HUP_BUCK 0x006f
+#define HUP_INITIALIZED 0x0070
+#define HUP_TESTED 0x0071
+#define HUP_AWAITING_POWER 0x0072
+#define HUP_COMMUNICATION_LOST 0x0073
+#define HUP_IMANUFACTURER 0x00fd
+#define HUP_IPRODUCT 0x00fe
+#define HUP_ISERIALNUMBER 0x00ff
+
+/* Usages, Battery */
+#define HUB_SMB_BATTERY_MODE 0x0001
+#define HUB_SMB_BATTERY_STATUS 0x0002
+#define HUB_SMB_ALARM_WARNING 0x0003
+#define HUB_SMB_CHARGER_MODE 0x0004
+#define HUB_SMB_CHARGER_STATUS 0x0005
+#define HUB_SMB_CHARGER_SPECINF 0x0006
+#define HUB_SMB_SELECTR_STATE 0x0007
+#define HUB_SMB_SELECTR_PRESETS 0x0008
+#define HUB_SMB_SELECTR_INFO 0x0009
+#define HUB_SMB_OPT_MFGFUNC1 0x0010
+#define HUB_SMB_OPT_MFGFUNC2 0x0011
+#define HUB_SMB_OPT_MFGFUNC3 0x0012
+#define HUB_SMB_OPT_MFGFUNC4 0x0013
+#define HUB_SMB_OPT_MFGFUNC5 0x0014
+#define HUB_CONNECTIONTOSMBUS 0x0015
+#define HUB_OUTPUT_CONNECTION 0x0016
+#define HUB_CHARGER_CONNECTION 0x0017
+#define HUB_BATTERY_INSERTION 0x0018
+#define HUB_USENEXT 0x0019
+#define HUB_OKTOUSE 0x001a
+#define HUB_BATTERY_SUPPORTED 0x001b
+#define HUB_SELECTOR_REVISION 0x001c
+#define HUB_CHARGING_INDICATOR 0x001d
+#define HUB_MANUFACTURER_ACCESS 0x0028
+#define HUB_REM_CAPACITY_LIM 0x0029
+#define HUB_REM_TIME_LIM 0x002a
+#define HUB_ATRATE 0x002b
+#define HUB_CAPACITY_MODE 0x002c
+#define HUB_BCAST_TO_CHARGER 0x002d
+#define HUB_PRIMARY_BATTERY 0x002e
+#define HUB_CHANGE_CONTROLLER 0x002f
+#define HUB_TERMINATE_CHARGE 0x0040
+#define HUB_TERMINATE_DISCHARGE 0x0041
+#define HUB_BELOW_REM_CAP_LIM 0x0042
+#define HUB_REM_TIME_LIM_EXP 0x0043
+#define HUB_CHARGING 0x0044
+#define HUB_DISCHARGING 0x0045
+#define HUB_FULLY_CHARGED 0x0046
+#define HUB_FULLY_DISCHARGED 0x0047
+#define HUB_CONDITIONING_FLAG 0x0048
+#define HUB_ATRATE_OK 0x0049
+#define HUB_SMB_ERROR_CODE 0x004a
+#define HUB_NEED_REPLACEMENT 0x004b
+#define HUB_ATRATE_TIMETOFULL 0x0060
+#define HUB_ATRATE_TIMETOEMPTY 0x0061
+#define HUB_AVERAGE_CURRENT 0x0062
+#define HUB_MAXERROR 0x0063
+#define HUB_REL_STATEOF_CHARGE 0x0064
+#define HUB_ABS_STATEOF_CHARGE 0x0065
+#define HUB_REM_CAPACITY 0x0066
+#define HUB_FULLCHARGE_CAPACITY 0x0067
+#define HUB_RUNTIMETO_EMPTY 0x0068
+#define HUB_AVERAGETIMETO_EMPTY 0x0069
+#define HUB_AVERAGETIMETO_FULL 0x006a
+#define HUB_CYCLECOUNT 0x006b
+#define HUB_BATTPACKMODEL_LEVEL 0x0080
+#define HUB_INTERNAL_CHARGE_CTL 0x0081
+#define HUB_PRIMARY_BATTERY_SUP 0x0082
+#define HUB_DESIGN_CAPACITY 0x0083
+#define HUB_SPECIFICATION_INFO 0x0084
+#define HUB_MANUFACTURER_DATE 0x0085
+#define HUB_SERIAL_NUMBER 0x0086
+#define HUB_IMANUFACTURERNAME 0x0087
+#define HUB_IDEVICENAME 0x0088
+#define HUB_IDEVICECHEMISTERY 0x0089
+#define HUB_MANUFACTURERDATA 0x008a
+#define HUB_RECHARGABLE 0x008b
+#define HUB_WARN_CAPACITY_LIM 0x008c
+#define HUB_CAPACITY_GRANUL1 0x008d
+#define HUB_CAPACITY_GRANUL2 0x008e
+#define HUB_IOEM_INFORMATION 0x008f
+#define HUB_INHIBIT_CHARGE 0x00c0
+#define HUB_ENABLE_POLLING 0x00c1
+#define HUB_RESTORE_TO_ZERO 0x00c2
+#define HUB_AC_PRESENT 0x00d0
+#define HUB_BATTERY_PRESENT 0x00d1
+#define HUB_POWER_FAIL 0x00d2
+#define HUB_ALARM_INHIBITED 0x00d3
+#define HUB_THERMISTOR_UNDRANGE 0x00d4
+#define HUB_THERMISTOR_HOT 0x00d5
+#define HUB_THERMISTOR_COLD 0x00d6
+#define HUB_THERMISTOR_OVERANGE 0x00d7
+#define HUB_BS_VOLT_OUTOF_RANGE 0x00d8
+#define HUB_BS_CURR_OUTOF_RANGE 0x00d9
+#define HUB_BS_CURR_NOT_REGULTD 0x00da
+#define HUB_BS_VOLT_NOT_REGULTD 0x00db
+#define HUB_MASTER_MODE 0x00dc
+#define HUB_CHARGER_SELECTR_SUP 0x00f0
+#define HUB_CHARGER_SPEC 0x00f1
+#define HUB_LEVEL2 0x00f2
+#define HUB_LEVEL3 0x00f3
+
+/* Usages, generic desktop */
+#define HUG_POINTER 0x0001
+#define HUG_MOUSE 0x0002
+#define HUG_FN_KEY 0x0003
+#define HUG_JOYSTICK 0x0004
+#define HUG_GAME_PAD 0x0005
+#define HUG_KEYBOARD 0x0006
+#define HUG_KEYPAD 0x0007
+#define HUG_X 0x0030
+#define HUG_Y 0x0031
+#define HUG_Z 0x0032
+#define HUG_RX 0x0033
+#define HUG_RY 0x0034
+#define HUG_RZ 0x0035
+#define HUG_SLIDER 0x0036
+#define HUG_DIAL 0x0037
+#define HUG_WHEEL 0x0038
+#define HUG_HAT_SWITCH 0x0039
+#define HUG_COUNTED_BUFFER 0x003a
+#define HUG_BYTE_COUNT 0x003b
+#define HUG_MOTION_WAKEUP 0x003c
+#define HUG_VX 0x0040
+#define HUG_VY 0x0041
+#define HUG_VZ 0x0042
+#define HUG_VBRX 0x0043
+#define HUG_VBRY 0x0044
+#define HUG_VBRZ 0x0045
+#define HUG_VNO 0x0046
+#define HUG_TWHEEL 0x0048
+#define HUG_SYSTEM_CONTROL 0x0080
+#define HUG_SYSTEM_POWER_DOWN 0x0081
+#define HUG_SYSTEM_SLEEP 0x0082
+#define HUG_SYSTEM_WAKEUP 0x0083
+#define HUG_SYSTEM_CONTEXT_MENU 0x0084
+#define HUG_SYSTEM_MAIN_MENU 0x0085
+#define HUG_SYSTEM_APP_MENU 0x0086
+#define HUG_SYSTEM_MENU_HELP 0x0087
+#define HUG_SYSTEM_MENU_EXIT 0x0088
+#define HUG_SYSTEM_MENU_SELECT 0x0089
+#define HUG_SYSTEM_MENU_RIGHT 0x008a
+#define HUG_SYSTEM_MENU_LEFT 0x008b
+#define HUG_SYSTEM_MENU_UP 0x008c
+#define HUG_SYSTEM_MENU_DOWN 0x008d
+
+/* Usages, Digitizers */
+#define HUD_UNDEFINED 0x0000
+#define HUD_DIGITIZER 0x0001
+#define HUD_PEN 0x0002
+#define HUD_TOUCH_SCREEN 0x0004
+#define HUD_TOUCHPAD 0x0005
+#define HUD_CONFIG 0x000e
+#define HUD_FINGER 0x0022
+#define HUD_TIP_PRESSURE 0x0030
+#define HUD_BARREL_PRESSURE 0x0031
+#define HUD_IN_RANGE 0x0032
+#define HUD_TOUCH 0x0033
+#define HUD_UNTOUCH 0x0034
+#define HUD_TAP 0x0035
+#define HUD_QUALITY 0x0036
+#define HUD_DATA_VALID 0x0037
+#define HUD_TRANSDUCER_INDEX 0x0038
+#define HUD_TABLET_FKEYS 0x0039
+#define HUD_PROGRAM_CHANGE_KEYS 0x003a
+#define HUD_BATTERY_STRENGTH 0x003b
+#define HUD_INVERT 0x003c
+#define HUD_X_TILT 0x003d
+#define HUD_Y_TILT 0x003e
+#define HUD_AZIMUTH 0x003f
+#define HUD_ALTITUDE 0x0040
+#define HUD_TWIST 0x0041
+#define HUD_TIP_SWITCH 0x0042
+#define HUD_SEC_TIP_SWITCH 0x0043
+#define HUD_BARREL_SWITCH 0x0044
+#define HUD_ERASER 0x0045
+#define HUD_TABLET_PICK 0x0046
+#define HUD_CONFIDENCE 0x0047
+#define HUD_WIDTH 0x0048
+#define HUD_HEIGHT 0x0049
+#define HUD_CONTACTID 0x0051
+#define HUD_INPUT_MODE 0x0052
+#define HUD_DEVICE_INDEX 0x0053
+#define HUD_CONTACTCOUNT 0x0054
+#define HUD_CONTACT_MAX 0x0055
+#define HUD_SCAN_TIME 0x0056
+#define HUD_BUTTON_TYPE 0x0059
+
+/* Usages, LED */
+#define HUD_LED_NUM_LOCK 0x0001
+#define HUD_LED_CAPS_LOCK 0x0002
+#define HUD_LED_SCROLL_LOCK 0x0003
+#define HUD_LED_COMPOSE 0x0004
+#define HUD_LED_KANA 0x0005
+
+/* Usages, Consumer */
+#define HUC_AC_PAN 0x0238
+
+#define HID_USAGE2(p, u) (((p) << 16) | u)
+#define HID_GET_USAGE(u) ((u) & 0xffff)
+#define HID_GET_USAGE_PAGE(u) (((u) >> 16) & 0xffff)
+
+#define HCOLL_PHYSICAL 0
+#define HCOLL_APPLICATION 1
+#define HCOLL_LOGICAL 2
+
+/* Bits in the input/output/feature items */
+#define HIO_CONST 0x001
+#define HIO_VARIABLE 0x002
+#define HIO_RELATIVE 0x004
+#define HIO_WRAP 0x008
+#define HIO_NONLINEAR 0x010
+#define HIO_NOPREF 0x020
+#define HIO_NULLSTATE 0x040
+#define HIO_VOLATILE 0x080
+#define HIO_BUFBYTES 0x100
+
+/* Valid values for the country codes */
+#define HCC_UNDEFINED 0x00
+#define HCC_MAX 0x23
+
+#endif /* _HIDHID_H_ */
diff --git a/sys/dev/usb/ukbdmap.c b/sys/dev/hid/hidkbdmap.c
index 55d69b9af43..8cb88e83724 100644
--- a/sys/dev/usb/ukbdmap.c
+++ b/sys/dev/hid/hidkbdmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ukbdmap.c,v 1.31 2016/04/23 10:15:32 skrll Exp $ */
+/* $NetBSD: hidkbdmap.c,v 1.1 2017/12/10 17:03:07 bouyer Exp $ */
/*
* Copyright (c) 1999,2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ukbdmap.c,v 1.31 2016/04/23 10:15:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hidkbdmap.c,v 1.1 2017/12/10 17:03:07 bouyer Exp $");
#include <sys/types.h>
#include <dev/wscons/wsksymdef.h>
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: ukbdmap.c,v 1.31 2016/04/23 10:15:32 skrll Exp $");
#define KC(n) KS_KEYCODE(n)
-Static const keysym_t ukbd_keydesc_us[] = {
+Static const keysym_t hidkbd_keydesc_us[] = {
/* pos command normal shifted */
KC(4), KS_a,
KC(5), KS_b,
@@ -159,7 +159,7 @@ Static const keysym_t ukbd_keydesc_us[] = {
KC(231), KS_Meta_R,
};
-Static const keysym_t ukbd_keydesc_jp[] = {
+Static const keysym_t hidkbd_keydesc_jp[] = {
/* pos command normal shifted */
KC(31), KS_2, KS_quotedbl,
KC(35), KS_6, KS_ampersand,
@@ -182,7 +182,7 @@ Static const keysym_t ukbd_keydesc_jp[] = {
KC(139), KS_Muhenkan,
};
-Static const keysym_t ukbd_keydesc_us_dvorak[] = {
+Static const keysym_t hidkbd_keydesc_us_dvorak[] = {
/* pos command normal shifted */
KC(4), KS_a,
KC(5), KS_x,
@@ -221,7 +221,7 @@ Static const keysym_t ukbd_keydesc_us_dvorak[] = {
KC(56), KS_z,
};
-Static const keysym_t ukbd_keydesc_us_colemak[] = {
+Static const keysym_t hidkbd_keydesc_us_colemak[] = {
/* pos command normal shifted */
KC(4), KS_a, KS_A, KS_aacute, KS_Aacute,
KC(5), KS_b, KS_B, KS_asciitilde, KS_asciitilde,
@@ -277,13 +277,13 @@ Static const keysym_t ukbd_keydesc_us_colemak[] = {
KC(230), KS_Mode_switch, KS_Multi_key,
};
-Static const keysym_t ukbd_keydesc_swapctrlcaps[] = {
+Static const keysym_t hidkbd_keydesc_swapctrlcaps[] = {
/* pos command normal shifted */
KC(57), KS_Control_L,
KC(224), KS_Cmd1, KS_Caps_Lock,
};
-Static const keysym_t ukbd_keydesc_de[] = {
+Static const keysym_t hidkbd_keydesc_de[] = {
/* pos normal shifted altgr shift-altgr */
KC(16), KS_m, KS_M, KS_mu,
KC(20), KS_q, KS_Q, KS_at,
@@ -311,14 +311,14 @@ Static const keysym_t ukbd_keydesc_de[] = {
KC(230), KS_Mode_switch, KS_Multi_key,
};
-Static const keysym_t ukbd_keydesc_de_nodead[] = {
+Static const keysym_t hidkbd_keydesc_de_nodead[] = {
/* pos normal shifted altgr shift-altgr */
KC(46), KS_apostrophe, KS_grave,
KC(48), KS_plus, KS_asterisk, KS_asciitilde,
KC(53), KS_asciicircum, KS_degree,
};
-Static const keysym_t ukbd_keydesc_dk[] = {
+Static const keysym_t hidkbd_keydesc_dk[] = {
/* pos normal shifted altgr shift-altgr */
KC(31), KS_2, KS_quotedbl, KS_at,
KC(32), KS_3, KS_numbersign, KS_sterling,
@@ -343,13 +343,13 @@ Static const keysym_t ukbd_keydesc_dk[] = {
KC(230), KS_Mode_switch, KS_Multi_key,
};
-Static const keysym_t ukbd_keydesc_dk_nodead[] = {
+Static const keysym_t hidkbd_keydesc_dk_nodead[] = {
/* pos normal shifted altgr shift-altgr */
KC(46), KS_apostrophe, KS_grave, KS_bar,
KC(48), KS_diaeresis, KS_asciicircum, KS_asciitilde,
};
-Static const keysym_t ukbd_keydesc_sv[] = {
+Static const keysym_t hidkbd_keydesc_sv[] = {
/* pos normal shifted altgr shift-altgr */
KC(45), KS_plus, KS_question, KS_backslash,
KC(48), KS_dead_diaeresis, KS_dead_circumflex, KS_dead_tilde,
@@ -361,13 +361,13 @@ Static const keysym_t ukbd_keydesc_sv[] = {
KC(230), KS_Mode_switch, KS_Multi_key,
};
-Static const keysym_t ukbd_keydesc_sv_nodead[] = {
+Static const keysym_t hidkbd_keydesc_sv_nodead[] = {
/* pos normal shifted altgr shift-altgr */
KC(46), KS_apostrophe, KS_grave, KS_bar,
KC(48), KS_diaeresis, KS_asciicircum, KS_asciitilde,
};
-Static const keysym_t ukbd_keydesc_no[] = {
+Static const keysym_t hidkbd_keydesc_no[] = {
/* pos normal shifted altgr shift-altgr */
KC(46), KS_backslash, KS_dead_grave, KS_dead_acute,
KC(48), KS_dead_diaeresis, KS_dead_circumflex, KS_dead_tilde,
@@ -378,13 +378,13 @@ Static const keysym_t ukbd_keydesc_no[] = {
KC(100), KS_less, KS_greater,
};
-Static const keysym_t ukbd_keydesc_no_nodead[] = {
+Static const keysym_t hidkbd_keydesc_no_nodead[] = {
/* pos normal shifted altgr shift-altgr */
KC(46), KS_backslash, KS_grave, KS_acute,
KC(48), KS_diaeresis, KS_asciicircum, KS_asciitilde,
};
-Static const keysym_t ukbd_keydesc_fr[] = {
+Static const keysym_t hidkbd_keydesc_fr[] = {
/* pos normal shifted altgr shift-altgr */
KC(4), KS_q,
KC(16), KS_comma, KS_question,
@@ -416,7 +416,7 @@ Static const keysym_t ukbd_keydesc_fr[] = {
KC(230), KS_Mode_switch, KS_Multi_key,
};
-Static const keysym_t ukbd_keydesc_be[] = {
+Static const keysym_t hidkbd_keydesc_be[] = {
/* pos normal shifted altgr shift-altgr */
KC(30), KS_ampersand, KS_1, KS_bar,
KC(31), KS_eacute, KS_2, KS_at,
@@ -438,7 +438,7 @@ Static const keysym_t ukbd_keydesc_be[] = {
KC(100), KS_less, KS_greater, KS_backslash,
};
-Static const keysym_t ukbd_keydesc_it[] = {
+Static const keysym_t hidkbd_keydesc_it[] = {
/* pos normal shifted altgr shift-altgr */
KC(31), KS_2, KS_quotedbl, KS_twosuperior,
KC(32), KS_3, KS_sterling, KS_threesuperior,
@@ -464,7 +464,7 @@ Static const keysym_t ukbd_keydesc_it[] = {
KC(230), KS_Mode_switch, KS_Multi_key,
};
-Static const keysym_t ukbd_keydesc_uk[] = {
+Static const keysym_t hidkbd_keydesc_uk[] = {
/* pos normal shifted altgr shift-altgr */
KC(30), KS_1, KS_exclam, KS_plusminus, KS_exclamdown,
KC(31), KS_2, KS_quotedbl, KS_twosuperior, KS_cent,
@@ -485,7 +485,7 @@ Static const keysym_t ukbd_keydesc_uk[] = {
KC(100), KS_backslash, KS_bar, KS_Udiaeresis,
};
-Static const keysym_t ukbd_keydesc_es[] = {
+Static const keysym_t hidkbd_keydesc_es[] = {
/* pos normal shifted altgr shift-altgr */
KC(30), KS_1, KS_exclam, KS_bar,
KC(31), KS_2, KS_quotedbl, KS_at,
@@ -512,7 +512,7 @@ Static const keysym_t ukbd_keydesc_es[] = {
KC(230), KS_Mode_switch, KS_Multi_key,
};
-Static const keysym_t ukbd_keydesc_pt[] = {
+Static const keysym_t hidkbd_keydesc_pt[] = {
/* pos normal shifted altgr shift-altgr */
KC(31), KS_2, KS_quotedbl, KS_at,
KC(32), KS_3, KS_numbersign, KS_sterling,
@@ -538,7 +538,7 @@ Static const keysym_t ukbd_keydesc_pt[] = {
KC(230), KS_Mode_switch, KS_Multi_key,
};
-Static const keysym_t ukbd_keydesc_sg[] = {
+Static const keysym_t hidkbd_keydesc_sg[] = {
/* pos normal shifted altgr shift-altgr */
KC(30), KS_1, KS_plus, KS_bar,
KC(31), KS_2, KS_quotedbl, KS_at,
@@ -567,21 +567,21 @@ Static const keysym_t ukbd_keydesc_sg[] = {
KC(230), KS_Mode_switch, KS_Multi_key,
};
-Static const keysym_t ukbd_keydesc_sg_nodead[] = {
+Static const keysym_t hidkbd_keydesc_sg_nodead[] = {
/* pos normal shifted altgr shift-altgr */
KC(45), KS_apostrophe, KS_question, KS_acute,
KC(46), KS_asciicircum, KS_grave, KS_asciitilde,
KC(48), KS_diaeresis, KS_exclam, KS_bracketright
};
-Static const keysym_t ukbd_keydesc_sf[] = {
+Static const keysym_t hidkbd_keydesc_sf[] = {
/* pos normal shifted altgr shift-altgr */
KC(47), KS_egrave, KS_udiaeresis, KS_bracketleft,
KC(51), KS_eacute, KS_odiaeresis,
KC(52), KS_agrave, KS_adiaeresis, KS_braceleft
};
-static const keysym_t ukbd_keydesc_hu[] = {
+static const keysym_t hidkbd_keydesc_hu[] = {
/* pos normal shifted altgr shift-altgr */
KC(5), KS_b, KS_B, KS_braceleft,
KC(6), KS_c, KS_C, KS_ampersand,
@@ -622,35 +622,35 @@ static const keysym_t ukbd_keydesc_hu[] = {
#define KBD_MAP(name, base, map) \
{ name, base, sizeof(map)/sizeof(keysym_t), map }
-const struct wscons_keydesc ukbd_keydesctab[] = {
- KBD_MAP(KB_US, 0, ukbd_keydesc_us),
- KBD_MAP(KB_US | KB_SWAPCTRLCAPS,KB_US, ukbd_keydesc_swapctrlcaps),
- KBD_MAP(KB_US | KB_DVORAK, KB_US, ukbd_keydesc_us_dvorak),
+const struct wscons_keydesc hidkbd_keydesctab[] = {
+ KBD_MAP(KB_US, 0, hidkbd_keydesc_us),
+ KBD_MAP(KB_US | KB_SWAPCTRLCAPS,KB_US, hidkbd_keydesc_swapctrlcaps),
+ KBD_MAP(KB_US | KB_DVORAK, KB_US, hidkbd_keydesc_us_dvorak),
KBD_MAP(KB_US | KB_DVORAK | KB_SWAPCTRLCAPS, KB_US| KB_DVORAK,
- ukbd_keydesc_swapctrlcaps),
- KBD_MAP(KB_US | KB_COLEMAK, KB_US, ukbd_keydesc_us_colemak),
- KBD_MAP(KB_JP, KB_US, ukbd_keydesc_jp),
- KBD_MAP(KB_JP | KB_SWAPCTRLCAPS,KB_JP, ukbd_keydesc_swapctrlcaps),
- KBD_MAP(KB_DE, KB_US, ukbd_keydesc_de),
- KBD_MAP(KB_DE | KB_NODEAD, KB_DE, ukbd_keydesc_de_nodead),
- KBD_MAP(KB_FR, KB_US, ukbd_keydesc_fr),
- KBD_MAP(KB_FR | KB_SWAPCTRLCAPS,KB_FR, ukbd_keydesc_swapctrlcaps),
- KBD_MAP(KB_BE, KB_FR, ukbd_keydesc_be),
- KBD_MAP(KB_DK, KB_US, ukbd_keydesc_dk),
- KBD_MAP(KB_DK | KB_NODEAD, KB_DK, ukbd_keydesc_dk_nodead),
- KBD_MAP(KB_IT, KB_US, ukbd_keydesc_it),
- KBD_MAP(KB_UK, KB_US, ukbd_keydesc_uk),
- KBD_MAP(KB_SV, KB_DK, ukbd_keydesc_sv),
- KBD_MAP(KB_SV | KB_NODEAD, KB_SV, ukbd_keydesc_sv_nodead),
- KBD_MAP(KB_NO, KB_DK, ukbd_keydesc_no),
- KBD_MAP(KB_NO | KB_NODEAD, KB_NO, ukbd_keydesc_no_nodead),
- KBD_MAP(KB_ES , KB_US, ukbd_keydesc_es),
- KBD_MAP(KB_PT, KB_US, ukbd_keydesc_pt),
- KBD_MAP(KB_SG, KB_US, ukbd_keydesc_sg),
- KBD_MAP(KB_SG | KB_NODEAD, KB_SG, ukbd_keydesc_sg_nodead),
- KBD_MAP(KB_SF, KB_SG, ukbd_keydesc_sf),
- KBD_MAP(KB_SF | KB_NODEAD, KB_SF, ukbd_keydesc_sg_nodead),
- KBD_MAP(KB_HU, KB_US, ukbd_keydesc_hu),
+ hidkbd_keydesc_swapctrlcaps),
+ KBD_MAP(KB_US | KB_COLEMAK, KB_US, hidkbd_keydesc_us_colemak),
+ KBD_MAP(KB_JP, KB_US, hidkbd_keydesc_jp),
+ KBD_MAP(KB_JP | KB_SWAPCTRLCAPS,KB_JP, hidkbd_keydesc_swapctrlcaps),
+ KBD_MAP(KB_DE, KB_US, hidkbd_keydesc_de),
+ KBD_MAP(KB_DE | KB_NODEAD, KB_DE, hidkbd_keydesc_de_nodead),
+ KBD_MAP(KB_FR, KB_US, hidkbd_keydesc_fr),
+ KBD_MAP(KB_FR | KB_SWAPCTRLCAPS,KB_FR, hidkbd_keydesc_swapctrlcaps),
+ KBD_MAP(KB_BE, KB_FR, hidkbd_keydesc_be),
+ KBD_MAP(KB_DK, KB_US, hidkbd_keydesc_dk),
+ KBD_MAP(KB_DK | KB_NODEAD, KB_DK, hidkbd_keydesc_dk_nodead),
+ KBD_MAP(KB_IT, KB_US, hidkbd_keydesc_it),
+ KBD_MAP(KB_UK, KB_US, hidkbd_keydesc_uk),
+ KBD_MAP(KB_SV, KB_DK, hidkbd_keydesc_sv),
+ KBD_MAP(KB_SV | KB_NODEAD, KB_SV, hidkbd_keydesc_sv_nodead),
+ KBD_MAP(KB_NO, KB_DK, hidkbd_keydesc_no),
+ KBD_MAP(KB_NO | KB_NODEAD, KB_NO, hidkbd_keydesc_no_nodead),
+ KBD_MAP(KB_ES , KB_US, hidkbd_keydesc_es),
+ KBD_MAP(KB_PT, KB_US, hidkbd_keydesc_pt),
+ KBD_MAP(KB_SG, KB_US, hidkbd_keydesc_sg),
+ KBD_MAP(KB_SG | KB_NODEAD, KB_SG, hidkbd_keydesc_sg_nodead),
+ KBD_MAP(KB_SF, KB_SG, hidkbd_keydesc_sf),
+ KBD_MAP(KB_SF | KB_NODEAD, KB_SF, hidkbd_keydesc_sg_nodead),
+ KBD_MAP(KB_HU, KB_US, hidkbd_keydesc_hu),
{0, 0, 0, 0}
};
diff --git a/sys/dev/hid/hidms.c b/sys/dev/hid/hidms.c
new file mode 100644
index 00000000000..4133f13a0c4
--- /dev/null
+++ b/sys/dev/hid/hidms.c
@@ -0,0 +1,290 @@
+/* $NetBSD: hidms.c,v 1.1 2017/12/10 17:03:07 bouyer Exp $ */
+
+/*
+ * Copyright (c) 1998, 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart@augustsson.net) at
+ * Carlstedt Research & Technology.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: hidms.c,v 1.1 2017/12/10 17:03:07 bouyer Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <dev/hid/hid.h>
+#include <dev/hid/hidms.h>
+
+#ifdef HIDMS_DEBUG
+#define DPRINTF(x) if (hidmsdebug) printf x
+#define DPRINTFN(n,x) if (hidmsdebug>(n)) printf x
+int hidmsdebug = 0;
+#else
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#endif
+
+#define HIDMS_BUT(i) ((i) == 1 || (i) == 2 ? 3 - (i) : i)
+
+#define PS2LBUTMASK x01
+#define PS2RBUTMASK x02
+#define PS2MBUTMASK x04
+#define PS2BUTMASK 0x0f
+
+static const struct {
+ u_int feature;
+ u_int flag;
+} digbut[] = {
+ { HUD_TIP_SWITCH, HIDMS_TIP_SWITCH },
+ { HUD_SEC_TIP_SWITCH, HIDMS_SEC_TIP_SWITCH },
+ { HUD_BARREL_SWITCH, HIDMS_BARREL_SWITCH },
+ { HUD_ERASER, HIDMS_ERASER },
+};
+
+#define MOUSE_FLAGS_MASK (HIO_CONST|HIO_RELATIVE)
+
+bool
+hidms_setup(device_t self, struct hidms *ms, int id, void *desc, int size)
+{
+ uint32_t flags;
+ struct hid_location *zloc;
+ bool isdigitizer;
+ int i, hl;
+
+ isdigitizer = hid_is_collection(desc, size, id,
+ HID_USAGE2(HUP_DIGITIZERS, 0x0002));
+
+ if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
+ id, hid_input, &ms->hidms_loc_x, &flags)) {
+ aprint_error("\n%s: mouse has no X report\n",
+ device_xname(self));
+ return false;
+ }
+ switch (flags & MOUSE_FLAGS_MASK) {
+ case 0:
+ ms->flags |= HIDMS_ABS;
+ break;
+ case HIO_RELATIVE:
+ break;
+ default:
+ aprint_error("\n%s: X report 0x%04x not supported\n",
+ device_xname(self), flags);
+ return false;
+ }
+
+ if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y),
+ id, hid_input, &ms->hidms_loc_y, &flags)) {
+ aprint_error("\n%s: mouse has no Y report\n",
+ device_xname(self));
+ return false;
+ }
+ switch (flags & MOUSE_FLAGS_MASK) {
+ case 0:
+ ms->flags |= HIDMS_ABS;
+ break;
+ case HIO_RELATIVE:
+ break;
+ default:
+ aprint_error("\n%s: Y report 0x%04x not supported\n",
+ device_xname(self), flags);
+ return false;
+ }
+
+ /* Try the wheel first as the Z activator since it's tradition. */
+ hl = hid_locate(desc,
+ size,
+ HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL),
+ id,
+ hid_input,
+ &ms->hidms_loc_z,
+ &flags);
+
+ zloc = &ms->hidms_loc_z;
+ if (hl) {
+ if ((flags & MOUSE_FLAGS_MASK) != HIO_RELATIVE) {
+ aprint_verbose("\n%s: Wheel report 0x%04x not "
+ "supported\n", device_xname(self),
+ flags);
+ ms->hidms_loc_z.size = 0; /* Bad Z coord, ignore it */
+ } else {
+ ms->flags |= HIDMS_Z;
+ /* Wheels need the Z axis reversed. */
+ ms->flags ^= HIDMS_REVZ;
+ /* Put Z on the W coordinate */
+ zloc = &ms->hidms_loc_w;
+ }
+ }
+
+ hl = hid_locate(desc,
+ size,
+ HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Z),
+ id,
+ hid_input,
+ zloc,
+ &flags);
+
+ /*
+ * The horizontal component of the scrollball can also be given by
+ * Application Control Pan in the Consumer page, so if we didnt see
+ * any Z then check that.
+ */
+ if (!hl) {
+ hl = hid_locate(desc,
+ size,
+ HID_USAGE2(HUP_CONSUMER, HUC_AC_PAN),
+ id,
+ hid_input,
+ zloc,
+ &flags);
+ }
+
+ if (hl) {
+ if ((flags & MOUSE_FLAGS_MASK) != HIO_RELATIVE) {
+ aprint_verbose("\n%s: Z report 0x%04x not supported\n",
+ device_xname(self), flags);
+ zloc->size = 0; /* Bad Z coord, ignore it */
+ } else {
+ if (ms->flags & HIDMS_Z)
+ ms->flags |= HIDMS_W;
+ else
+ ms->flags |= HIDMS_Z;
+ }
+ }
+
+ /* figure out the number of buttons */
+ for (i = 1; i <= MAX_BUTTONS; i++)
+ if (!hid_locate(desc, size, HID_USAGE2(HUP_BUTTON, i),
+ id, hid_input, &ms->hidms_loc_btn[i - 1], 0))
+ break;
+
+ if (isdigitizer) {
+ ms->flags |= HIDMS_DIGITIZER;
+ for (size_t j = 0; j < __arraycount(digbut); j++) {
+ if (hid_locate(desc, size, HID_USAGE2(HUP_DIGITIZERS,
+ digbut[j].feature), id, hid_input,
+ &ms->hidms_loc_btn[i - 1], 0)) {
+ if (i <= MAX_BUTTONS) {
+ i++;
+ ms->flags |= digbut[j].flag;
+ } else
+ aprint_error_dev(self,
+ "ran out of buttons\n");
+ }
+ }
+ }
+ ms->nbuttons = i - 1;
+ return true;
+}
+
+void
+hidms_attach(device_t self, struct hidms *ms,
+ const struct wsmouse_accessops *ops)
+{
+ struct wsmousedev_attach_args a;
+ aprint_normal(": %d button%s%s%s%s%s%s%s%s%s\n",
+ ms->nbuttons, ms->nbuttons == 1 ? "" : "s",
+ ms->flags & HIDMS_W ? ", W" : "",
+ ms->flags & HIDMS_Z ? " and Z dir" : "",
+ ms->flags & HIDMS_W ? "s" : "",
+ ms->flags & HIDMS_DIGITIZER ? " digitizer" : "",
+ ms->flags & HIDMS_TIP_SWITCH ? ", tip" : "",
+ ms->flags & HIDMS_SEC_TIP_SWITCH ? ", sec tip" : "",
+ ms->flags & HIDMS_BARREL_SWITCH ? ", barrel" : "",
+ ms->flags & HIDMS_ERASER ? ", eraser" : "");
+
+#ifdef HIDMS_DEBUG
+ DPRINTF(("hidms_attach: ms=%p\n", ms));
+ DPRINTF(("hidms_attach: X\t%d/%d\n",
+ ms->hidms_loc_x.pos, ms->hidms_loc_x.size));
+ DPRINTF(("hidms_attach: Y\t%d/%d\n",
+ ms->hidms_loc_y.pos, ms->hidms_loc_y.size));
+ if (ms->flags & HIDMS_Z)
+ DPRINTF(("hidms_attach: Z\t%d/%d\n",
+ ms->hidms_loc_z.pos, ms->hidms_loc_z.size));
+ if (ms->flags & HIDMS_W)
+ DPRINTF(("hidms_attach: W\t%d/%d\n",
+ ms->hidms_loc_w.pos, ms->hidms_loc_w.size));
+ for (i = 1; i <= ms->nbuttons; i++) {
+ DPRINTF(("hidms_attach: B%d\t%d/%d\n",
+ i, ms->hidms_loc_btn[i-1].pos,ms->hidms_loc_btn[i-1].size));
+ }
+#endif
+
+ a.accessops = ops;
+ a.accesscookie = device_private(self);
+
+ ms->hidms_wsmousedev = config_found(self, &a, wsmousedevprint);
+
+ return;
+}
+
+
+void
+hidms_intr(struct hidms *ms, void *ibuf, u_int len)
+{
+ int dx, dy, dz, dw;
+ uint32_t buttons = 0;
+ int i, flags, s;
+
+ DPRINTFN(5,("hidms_intr: len=%d\n", len));
+
+ flags = WSMOUSE_INPUT_DELTA; /* equals 0 */
+
+ dx = hid_get_data(ibuf, &ms->hidms_loc_x);
+ if (ms->flags & HIDMS_ABS) {
+ flags |= (WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
+ dy = hid_get_data(ibuf, &ms->hidms_loc_y);
+ } else
+ dy = -hid_get_data(ibuf, &ms->hidms_loc_y);
+ dz = hid_get_data(ibuf, &ms->hidms_loc_z);
+ dw = hid_get_data(ibuf, &ms->hidms_loc_w);
+
+ if (ms->flags & HIDMS_REVZ)
+ dz = -dz;
+ for (i = 0; i < ms->nbuttons; i++)
+ if (hid_get_data(ibuf, &ms->hidms_loc_btn[i]))
+ buttons |= (1 << HIDMS_BUT(i));
+
+ if (dx != 0 || dy != 0 || dz != 0 || dw != 0 ||
+ buttons != ms->hidms_buttons) {
+ DPRINTFN(10, ("hidms_intr: x:%d y:%d z:%d w:%d buttons:0x%x\n",
+ dx, dy, dz, dw, buttons));
+ ms->hidms_buttons = buttons;
+ if (ms->hidms_wsmousedev != NULL) {
+ s = spltty();
+ wsmouse_input(ms->hidms_wsmousedev, buttons, dx, dy, dz,
+ dw, flags);
+ splx(s);
+ }
+ }
+}
diff --git a/sys/dev/hid/hidms.h b/sys/dev/hid/hidms.h
new file mode 100644
index 00000000000..988f57b9367
--- /dev/null
+++ b/sys/dev/hid/hidms.h
@@ -0,0 +1,63 @@
+/* $NetBSD: hidms.h,v 1.1 2017/12/10 17:03:07 bouyer Exp $ */
+
+/*
+ * Copyright (c) 1998, 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart@augustsson.net) at
+ * Carlstedt Research & Technology.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+
+#define MAX_BUTTONS 31 /* must not exceed size of sc_buttons */
+
+struct hidms {
+ struct hid_location hidms_loc_x, hidms_loc_y, hidms_loc_z, hidms_loc_w;
+ struct hid_location hidms_loc_btn[MAX_BUTTONS];
+
+ u_int flags; /* device configuration */
+#define HIDMS_Z 0x001 /* z direction available */
+#define HIDMS_SPUR_BUT_UP 0x002 /* spurious button up events */
+#define HIDMS_REVZ 0x004 /* Z-axis is reversed */
+#define HIDMS_W 0x008 /* w direction/tilt available */
+#define HIDMS_ABS 0x010 /* absolute position, touchpanel */
+#define HIDMS_TIP_SWITCH 0x020 /* digitizer tip switch */
+#define HIDMS_SEC_TIP_SWITCH 0x040 /* digitizer secondary tip switch */
+#define HIDMS_BARREL_SWITCH 0x080 /* digitizer barrel switch */
+#define HIDMS_ERASER 0x100 /* digitizer eraser */
+#define HIDMS_DIGITIZER 0x200 /* digitizer */
+
+ int nbuttons;
+
+ uint32_t hidms_buttons; /* mouse button status */
+ device_t hidms_wsmousedev;
+};
+
+bool hidms_setup(device_t, struct hidms *, int, void *, int);
+void hidms_attach(device_t, struct hidms *, const struct wsmouse_accessops *);
+void hidms_intr(struct hidms *, void *, u_int);
+
diff --git a/sys/dev/i2c/tcakp.c b/sys/dev/i2c/tcakp.c
index b2da262f229..437257f8d22 100644
--- a/sys/dev/i2c/tcakp.c
+++ b/sys/dev/i2c/tcakp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tcakp.c,v 1.4 2017/08/31 19:55:43 jmcneill Exp $ */
+/* $NetBSD: tcakp.c,v 1.5 2017/12/10 17:03:07 bouyer Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca>
@@ -29,7 +29,7 @@
#include "opt_fdt.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcakp.c,v 1.4 2017/08/31 19:55:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcakp.c,v 1.5 2017/12/10 17:03:07 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -306,9 +306,9 @@ static const struct wskbd_consops tcakp_consops = {
};
#endif
-extern const struct wscons_keydesc ukbd_keydesctab[];
+extern const struct wscons_keydesc hidkbd_keydesctab[];
static const struct wskbd_mapdata tcakp_keymapdata = {
- ukbd_keydesctab,
+ hidkbd_keydesctab,
KB_US,
};
diff --git a/sys/dev/usb/files.usb b/sys/dev/usb/files.usb
index ea160959cc6..0b8b69f24d0 100644
--- a/sys/dev/usb/files.usb
+++ b/sys/dev/usb/files.usb
@@ -1,4 +1,4 @@
-# $NetBSD: files.usb,v 1.147 2017/10/19 23:58:41 jmcneill Exp $
+# $NetBSD: files.usb,v 1.148 2017/12/10 17:03:07 bouyer Exp $
#
# Config file and device description for machine-independent USB code.
# Included by ports that need it. Ports that use it must provide
@@ -162,10 +162,9 @@ defflag opt_ukbd.h GDIUM_KEYBOARD_HACK
device ukbd: hid, wskbddev
attach ukbd at uhidbus
file dev/usb/ukbd.c ukbd needs-flag
-file dev/usb/ukbdmap.c ukbd | btkbd | linux_keymap
# Mice
-device ums: hid, wsmousedev
+device ums: hid, hidms, wsmousedev
attach ums at uhidbus
file dev/usb/ums.c ums
diff --git a/sys/dev/usb/hid.h b/sys/dev/usb/hid.h
deleted file mode 100644
index c2ed2344610..00000000000
--- a/sys/dev/usb/hid.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* $NetBSD: hid.h,v 1.14 2016/04/23 10:15:31 skrll Exp $ */
-/* $FreeBSD: src/sys/dev/usb/hid.h,v 1.7 1999/11/17 22:33:40 n_hibma Exp $ */
-
-/*
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Lennart Augustsson (lennart@augustsson.net) at
- * Carlstedt Research & Technology.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-enum hid_kind {
- hid_input,
- hid_output,
- hid_feature,
- hid_collection,
- hid_endcollection,
- hid_none
-};
-
-struct hid_location {
- uint32_t size;
- uint32_t count;
- uint32_t pos;
-};
-
-struct hid_item {
- /* Global */
- int32_t _usage_page;
- int32_t logical_minimum;
- int32_t logical_maximum;
- int32_t physical_minimum;
- int32_t physical_maximum;
- int32_t unit_exponent;
- int32_t unit;
- int32_t report_ID;
- /* Local */
- int32_t usage;
- int32_t usage_minimum;
- int32_t usage_maximum;
- int32_t designator_index;
- int32_t designator_minimum;
- int32_t designator_maximum;
- int32_t string_index;
- int32_t string_minimum;
- int32_t string_maximum;
- int32_t set_delimiter;
- /* Misc */
- int32_t collection;
- int collevel;
- enum hid_kind kind;
- uint32_t flags;
- /* Location */
- struct hid_location loc;
- /* */
- struct hid_item *next;
-};
-
-struct hid_data *hid_start_parse(const void *, int, enum hid_kind);
-void hid_end_parse(struct hid_data *);
-int hid_get_item(struct hid_data *, struct hid_item *);
-int hid_report_size(const void *, int, enum hid_kind, uint8_t);
-int hid_locate(const void *, int, uint32_t, uint8_t, enum hid_kind,
- struct hid_location *, uint32_t *);
-long hid_get_data(const u_char *, const struct hid_location *);
-u_long hid_get_udata(const u_char *, const struct hid_location *);
-int hid_is_collection(const void *, int, uint8_t, uint32_t);
diff --git a/sys/dev/usb/uatp.c b/sys/dev/usb/uatp.c
index 1303c25ff7e..fcbbc6eac23 100644
--- a/sys/dev/usb/uatp.c
+++ b/sys/dev/usb/uatp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uatp.c,v 1.14 2017/04/09 16:40:42 riastradh Exp $ */
+/* $NetBSD: uatp.c,v 1.15 2017/12/10 17:03:07 bouyer Exp $ */
/*-
* Copyright (c) 2011-2014 The NetBSD Foundation, Inc.
@@ -146,7 +146,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uatp.c,v 1.14 2017/04/09 16:40:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uatp.c,v 1.15 2017/12/10 17:03:07 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -170,8 +170,8 @@ __KERNEL_RCSID(0, "$NetBSD: uatp.c,v 1.14 2017/04/09 16:40:42 riastradh Exp $");
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdevs.h>
#include <dev/usb/uhidev.h>
-#include <dev/usb/hid.h>
#include <dev/usb/usbhid.h>
+#include <dev/hid/hid.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsmousevar.h>
diff --git a/sys/dev/usb/ucycom.c b/sys/dev/usb/ucycom.c
index 9c186dd97f6..111cad09246 100644
--- a/sys/dev/usb/ucycom.c
+++ b/sys/dev/usb/ucycom.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ucycom.c,v 1.45 2016/11/25 12:56:29 skrll Exp $ */
+/* $NetBSD: ucycom.c,v 1.46 2017/12/10 17:03:07 bouyer Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ucycom.c,v 1.45 2016/11/25 12:56:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucycom.c,v 1.46 2017/12/10 17:03:07 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -64,7 +64,7 @@ __KERNEL_RCSID(0, "$NetBSD: ucycom.c,v 1.45 2016/11/25 12:56:29 skrll Exp $");
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdevs.h>
#include <dev/usb/uhidev.h>
-#include <dev/usb/hid.h>
+#include <dev/hid/hid.h>
#include "ioconf.h"
diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c
index 8792ca224ca..fccbc64d419 100644
--- a/sys/dev/usb/uhid.c
+++ b/sys/dev/usb/uhid.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uhid.c,v 1.100 2017/10/25 08:12:39 maya Exp $ */
+/* $NetBSD: uhid.c,v 1.101 2017/12/10 17:03:07 bouyer Exp $ */
/*
* Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.100 2017/10/25 08:12:39 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.101 2017/12/10 17:03:07 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -64,8 +64,8 @@ __KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.100 2017/10/25 08:12:39 maya Exp $");
#include <dev/usb/usbdevs.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
-#include <dev/usb/hid.h>
#include <dev/usb/usb_quirks.h>
+#include <dev/hid/hid.h>
#include <dev/usb/uhidev.h>
diff --git a/sys/dev/usb/uhidev.c b/sys/dev/usb/uhidev.c
index 11ea72704ab..1e8e6f363c6 100644
--- a/sys/dev/usb/uhidev.c
+++ b/sys/dev/usb/uhidev.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uhidev.c,v 1.72 2017/09/02 04:35:51 ryoon Exp $ */
+/* $NetBSD: uhidev.c,v 1.73 2017/12/10 17:03:07 bouyer Exp $ */
/*
* Copyright (c) 2001, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.72 2017/09/02 04:35:51 ryoon Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.73 2017/12/10 17:03:07 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -57,10 +57,10 @@ __KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.72 2017/09/02 04:35:51 ryoon Exp $");
#include <dev/usb/usbdevs.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
-#include <dev/usb/hid.h>
#include <dev/usb/usb_quirks.h>
#include <dev/usb/uhidev.h>
+#include <dev/hid/hid.h>
/* Report descriptor for broken Wacom Graphire */
#include <dev/usb/ugraphire_rdesc.h>
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index c2de31e603e..f62f3388173 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ukbd.c,v 1.138 2017/08/13 22:19:56 jakllsch Exp $ */
+/* $NetBSD: ukbd.c,v 1.139 2017/12/10 17:03:07 bouyer Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.138 2017/08/13 22:19:56 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.139 2017/12/10 17:03:07 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -66,8 +66,8 @@ __KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.138 2017/08/13 22:19:56 jakllsch Exp $");
#include <dev/usb/usbdevs.h>
#include <dev/usb/usb_quirks.h>
#include <dev/usb/uhidev.h>
-#include <dev/usb/hid.h>
#include <dev/usb/ukbdvar.h>
+#include <dev/hid/hid.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wskbdvar.h>
@@ -352,10 +352,10 @@ const struct wskbd_accessops ukbd_accessops = {
ukbd_ioctl,
};
-extern const struct wscons_keydesc ukbd_keydesctab[];
+extern const struct wscons_keydesc hidkbd_keydesctab[];
const struct wskbd_mapdata ukbd_keymapdata = {
- ukbd_keydesctab,
+ hidkbd_keydesctab,
#if defined(UKBD_LAYOUT)
UKBD_LAYOUT,
#elif defined(PCKBD_LAYOUT)
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c
index 855648f116e..af6604676fc 100644
--- a/sys/dev/usb/ums.c
+++ b/sys/dev/usb/ums.c
@@ -1,7 +1,7 @@
-/* $NetBSD: ums.c,v 1.90 2016/04/27 19:35:17 jakllsch Exp $ */
+/* $NetBSD: ums.c,v 1.91 2017/12/10 17:03:07 bouyer Exp $ */
/*
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2017 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.90 2016/04/27 19:35:17 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.91 2017/12/10 17:03:07 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -60,10 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.90 2016/04/27 19:35:17 jakllsch Exp $");
#include <dev/usb/usbdevs.h>
#include <dev/usb/usb_quirks.h>
#include <dev/usb/uhidev.h>
-#include <dev/usb/hid.h>
-
-#include <dev/wscons/wsconsio.h>
-#include <dev/wscons/wsmousevar.h>
+#include <dev/hid/hid.h>
+#include <dev/hid/hidms.h>
#ifdef UMS_DEBUG
#define DPRINTF(x) if (umsdebug) printf x
@@ -74,56 +72,16 @@ int umsdebug = 0;
#define DPRINTFN(n,x)
#endif
-#define UMS_BUT(i) ((i) == 1 || (i) == 2 ? 3 - (i) : i)
-
#define UMSUNIT(s) (minor(s))
-#define PS2LBUTMASK x01
-#define PS2RBUTMASK x02
-#define PS2MBUTMASK x04
-#define PS2BUTMASK 0x0f
-
-#define MAX_BUTTONS 31 /* must not exceed size of sc_buttons */
-
struct ums_softc {
struct uhidev sc_hdev;
+ struct hidms sc_ms;
- struct hid_location sc_loc_x, sc_loc_y, sc_loc_z, sc_loc_w;
- struct hid_location sc_loc_btn[MAX_BUTTONS];
-
- int sc_enabled;
-
- u_int flags; /* device configuration */
-#define UMS_Z 0x001 /* z direction available */
-#define UMS_SPUR_BUT_UP 0x002 /* spurious button up events */
-#define UMS_REVZ 0x004 /* Z-axis is reversed */
-#define UMS_W 0x008 /* w direction/tilt available */
-#define UMS_ABS 0x010 /* absolute position, touchpanel */
-#define UMS_TIP_SWITCH 0x020 /* digitizer tip switch */
-#define UMS_SEC_TIP_SWITCH 0x040 /* digitizer secondary tip switch */
-#define UMS_BARREL_SWITCH 0x080 /* digitizer barrel switch */
-#define UMS_ERASER 0x100 /* digitizer eraser */
-
- int nbuttons;
-
- uint32_t sc_buttons; /* mouse button status */
- device_t sc_wsmousedev;
-
- char sc_dying;
-};
-
-static const struct {
- u_int feature;
- u_int flag;
-} digbut[] = {
- { HUD_TIP_SWITCH, UMS_TIP_SWITCH },
- { HUD_SEC_TIP_SWITCH, UMS_SEC_TIP_SWITCH },
- { HUD_BARREL_SWITCH, UMS_BARREL_SWITCH },
- { HUD_ERASER, UMS_ERASER },
+ int sc_enabled;
+ char sc_dying;
};
-#define MOUSE_FLAGS_MASK (HIO_CONST|HIO_RELATIVE)
-
Static void ums_intr(struct uhidev *, void *, u_int);
Static int ums_enable(void *);
@@ -177,13 +135,9 @@ ums_attach(device_t parent, device_t self, void *aux)
{
struct ums_softc *sc = device_private(self);
struct uhidev_attach_arg *uha = aux;
- struct wsmousedev_attach_args a;
int size;
void *desc;
- uint32_t flags, quirks;
- int i, hl;
- struct hid_location *zloc;
- bool isdigitizer;
+ uint32_t quirks;
aprint_naive("\n");
@@ -194,114 +148,17 @@ ums_attach(device_t parent, device_t self, void *aux)
quirks = usbd_get_quirks(uha->parent->sc_udev)->uq_flags;
if (quirks & UQ_MS_REVZ)
- sc->flags |= UMS_REVZ;
+ sc->sc_ms.flags |= HIDMS_REVZ;
if (quirks & UQ_SPUR_BUT_UP)
- sc->flags |= UMS_SPUR_BUT_UP;
-
- uhidev_get_report_desc(uha->parent, &desc, &size);
-
- isdigitizer = hid_is_collection(desc, size, uha->reportid,
- HID_USAGE2(HUP_DIGITIZERS, 0x0002));
+ sc->sc_ms.flags |= HIDMS_SPUR_BUT_UP;
if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "couldn't establish power handler\n");
- if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
- uha->reportid, hid_input, &sc->sc_loc_x, &flags)) {
- aprint_error("\n%s: mouse has no X report\n",
- device_xname(sc->sc_hdev.sc_dev));
- return;
- }
- switch (flags & MOUSE_FLAGS_MASK) {
- case 0:
- sc->flags |= UMS_ABS;
- break;
- case HIO_RELATIVE:
- break;
- default:
- aprint_error("\n%s: X report 0x%04x not supported\n",
- device_xname(sc->sc_hdev.sc_dev), flags);
- return;
- }
+ uhidev_get_report_desc(uha->parent, &desc, &size);
- if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y),
- uha->reportid, hid_input, &sc->sc_loc_y, &flags)) {
- aprint_error("\n%s: mouse has no Y report\n",
- device_xname(sc->sc_hdev.sc_dev));
- return;
- }
- switch (flags & MOUSE_FLAGS_MASK) {
- case 0:
- sc->flags |= UMS_ABS;
- break;
- case HIO_RELATIVE:
- break;
- default:
- aprint_error("\n%s: Y report 0x%04x not supported\n",
- device_xname(sc->sc_hdev.sc_dev), flags);
+ if (!hidms_setup(self, &sc->sc_ms, uha->reportid, desc, size))
return;
- }
-
- /* Try the wheel first as the Z activator since it's tradition. */
- hl = hid_locate(desc,
- size,
- HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL),
- uha->reportid,
- hid_input,
- &sc->sc_loc_z,
- &flags);
-
- zloc = &sc->sc_loc_z;
- if (hl) {
- if ((flags & MOUSE_FLAGS_MASK) != HIO_RELATIVE) {
- aprint_verbose("\n%s: Wheel report 0x%04x not "
- "supported\n", device_xname(sc->sc_hdev.sc_dev),
- flags);
- sc->sc_loc_z.size = 0; /* Bad Z coord, ignore it */
- } else {
- sc->flags |= UMS_Z;
- /* Wheels need the Z axis reversed. */
- sc->flags ^= UMS_REVZ;
- /* Put Z on the W coordinate */
- zloc = &sc->sc_loc_w;
- }
- }
-
- hl = hid_locate(desc,
- size,
- HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Z),
- uha->reportid,
- hid_input,
- zloc,
- &flags);
-
- /*
- * The horizontal component of the scrollball can also be given by
- * Application Control Pan in the Consumer page, so if we didnt see
- * any Z then check that.
- */
- if (!hl) {
- hl = hid_locate(desc,
- size,
- HID_USAGE2(HUP_CONSUMER, HUC_AC_PAN),
- uha->reportid,
- hid_input,
- zloc,
- &flags);
- }
-
- if (hl) {
- if ((flags & MOUSE_FLAGS_MASK) != HIO_RELATIVE) {
- aprint_verbose("\n%s: Z report 0x%04x not supported\n",
- device_xname(sc->sc_hdev.sc_dev), flags);
- zloc->size = 0; /* Bad Z coord, ignore it */
- } else {
- if (sc->flags & UMS_Z)
- sc->flags |= UMS_W;
- else
- sc->flags |= UMS_Z;
- }
- }
if (uha->uiaa->uiaa_vendor == USB_VENDOR_MICROSOFT) {
int fixpos;
@@ -324,70 +181,17 @@ ums_attach(device_t parent, device_t self, void *aux)
break;
}
if (fixpos) {
- if ((sc->flags & UMS_Z) && sc->sc_loc_z.pos == 0)
- sc->sc_loc_z.pos = fixpos;
- if ((sc->flags & UMS_W) && sc->sc_loc_w.pos == 0)
- sc->sc_loc_w.pos = sc->sc_loc_z.pos + 8;
- }
- }
-
- /* figure out the number of buttons */
- for (i = 1; i <= MAX_BUTTONS; i++)
- if (!hid_locate(desc, size, HID_USAGE2(HUP_BUTTON, i),
- uha->reportid, hid_input, &sc->sc_loc_btn[i - 1], 0))
- break;
-
- if (isdigitizer) {
- for (size_t j = 0; j < __arraycount(digbut); j++) {
- if (hid_locate(desc, size, HID_USAGE2(HUP_DIGITIZERS,
- digbut[j].feature), uha->reportid, hid_input,
- &sc->sc_loc_btn[i - 1], 0)) {
- if (i <= MAX_BUTTONS) {
- i++;
- sc->flags |= digbut[j].flag;
- } else
- aprint_error_dev(self,
- "ran out of buttons\n");
- }
+ if ((sc->sc_ms.flags & HIDMS_Z) &&
+ sc->sc_ms.hidms_loc_z.pos == 0)
+ sc->sc_ms.hidms_loc_z.pos = fixpos;
+ if ((sc->sc_ms.flags & HIDMS_W) &&
+ sc->sc_ms.hidms_loc_w.pos == 0)
+ sc->sc_ms.hidms_loc_w.pos =
+ sc->sc_ms.hidms_loc_z.pos + 8;
}
}
- sc->nbuttons = i - 1;
-
- aprint_normal(": %d button%s%s%s%s%s%s%s%s%s\n",
- sc->nbuttons, sc->nbuttons == 1 ? "" : "s",
- sc->flags & UMS_W ? ", W" : "",
- sc->flags & UMS_Z ? " and Z dir" : "",
- sc->flags & UMS_W ? "s" : "",
- isdigitizer ? " digitizer" : "",
- sc->flags & UMS_TIP_SWITCH ? ", tip" : "",
- sc->flags & UMS_SEC_TIP_SWITCH ? ", sec tip" : "",
- sc->flags & UMS_BARREL_SWITCH ? ", barrel" : "",
- sc->flags & UMS_ERASER ? ", eraser" : "");
-
-#ifdef UMS_DEBUG
- DPRINTF(("ums_attach: sc=%p\n", sc));
- DPRINTF(("ums_attach: X\t%d/%d\n",
- sc->sc_loc_x.pos, sc->sc_loc_x.size));
- DPRINTF(("ums_attach: Y\t%d/%d\n",
- sc->sc_loc_y.pos, sc->sc_loc_y.size));
- if (sc->flags & UMS_Z)
- DPRINTF(("ums_attach: Z\t%d/%d\n",
- sc->sc_loc_z.pos, sc->sc_loc_z.size));
- if (sc->flags & UMS_W)
- DPRINTF(("ums_attach: W\t%d/%d\n",
- sc->sc_loc_w.pos, sc->sc_loc_w.size));
- for (i = 1; i <= sc->nbuttons; i++) {
- DPRINTF(("ums_attach: B%d\t%d/%d\n",
- i, sc->sc_loc_btn[i-1].pos,sc->sc_loc_btn[i-1].size));
- }
-#endif
-
- a.accessops = &ums_accessops;
- a.accesscookie = sc;
- sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
-
- return;
+ hidms_attach(self, &sc->sc_ms, &ums_accessops);
}
int
@@ -409,8 +213,8 @@ ums_childdet(device_t self, device_t child)
{
struct ums_softc *sc = device_private(self);
- KASSERT(sc->sc_wsmousedev == child);
- sc->sc_wsmousedev = NULL;
+ KASSERT(sc->sc_ms.hidms_wsmousedev == child);
+ sc->sc_ms.hidms_wsmousedev = NULL;
}
int
@@ -422,8 +226,8 @@ ums_detach(device_t self, int flags)
DPRINTF(("ums_detach: sc=%p flags=%d\n", sc, flags));
/* No need to do reference counting of ums, wsmouse has all the goo. */
- if (sc->sc_wsmousedev != NULL)
- rv = config_detach(sc->sc_wsmousedev, flags);
+ if (sc->sc_ms.hidms_wsmousedev != NULL)
+ rv = config_detach(sc->sc_ms.hidms_wsmousedev, flags);
pmf_device_deregister(self);
@@ -434,41 +238,7 @@ void
ums_intr(struct uhidev *addr, void *ibuf, u_int len)
{
struct ums_softc *sc = (struct ums_softc *)addr;
- int dx, dy, dz, dw;
- uint32_t buttons = 0;
- int i, flags, s;
-
- DPRINTFN(5,("ums_intr: len=%d\n", len));
-
- flags = WSMOUSE_INPUT_DELTA; /* equals 0 */
-
- dx = hid_get_data(ibuf, &sc->sc_loc_x);
- if (sc->flags & UMS_ABS) {
- flags |= (WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
- dy = hid_get_data(ibuf, &sc->sc_loc_y);
- } else
- dy = -hid_get_data(ibuf, &sc->sc_loc_y);
- dz = hid_get_data(ibuf, &sc->sc_loc_z);
- dw = hid_get_data(ibuf, &sc->sc_loc_w);
-
- if (sc->flags & UMS_REVZ)
- dz = -dz;
- for (i = 0; i < sc->nbuttons; i++)
- if (hid_get_data(ibuf, &sc->sc_loc_btn[i]))
- buttons |= (1 << UMS_BUT(i));
-
- if (dx != 0 || dy != 0 || dz != 0 || dw != 0 ||
- buttons != sc->sc_buttons) {
- DPRINTFN(10, ("ums_intr: x:%d y:%d z:%d w:%d buttons:0x%x\n",
- dx, dy, dz, dw, buttons));
- sc->sc_buttons = buttons;
- if (sc->sc_wsmousedev != NULL) {
- s = spltty();
- wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, dz,
- dw, flags);
- splx(s);
- }
- }
+ hidms_intr(&sc->sc_ms, ibuf, len);
}
Static int
@@ -486,7 +256,7 @@ ums_enable(void *v)
return EBUSY;
sc->sc_enabled = 1;
- sc->sc_buttons = 0;
+ sc->sc_ms.hidms_buttons = 0;
error = uhidev_open(&sc->sc_hdev);
if (error)
@@ -523,7 +293,7 @@ ums_ioctl(void *v, u_long cmd, void *data, int flag,
switch (cmd) {
case WSMOUSEIO_GTYPE:
- if (sc->flags & UMS_ABS)
+ if (sc->sc_ms.flags & HIDMS_ABS)
*(u_int *)data = WSMOUSE_TYPE_TPANEL;
else
*(u_int *)data = WSMOUSE_TYPE_USB;
diff --git a/sys/dev/usb/usbhid.h b/sys/dev/usb/usbhid.h
index 9e01308b233..0be7727eeff 100644
--- a/sys/dev/usb/usbhid.h
+++ b/sys/dev/usb/usbhid.h
@@ -1,4 +1,4 @@
-/* $NetBSD: usbhid.h,v 1.16 2016/04/23 10:15:32 skrll Exp $ */
+/* $NetBSD: usbhid.h,v 1.17 2017/12/10 17:03:07 bouyer Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbhid.h,v 1.7 1999/11/17 22:33:51 n_hibma Exp $ */
/*
@@ -60,136 +60,8 @@ typedef struct usb_hid_descriptor {
} UPACKED usb_hid_descriptor_t;
#define USB_HID_DESCRIPTOR_SIZE(n) (9+(n)*3)
-/* Usage pages */
-#define HUP_UNDEFINED 0x0000
-#define HUP_GENERIC_DESKTOP 0x0001
-#define HUP_SIMULATION 0x0002
-#define HUP_VR_CONTROLS 0x0003
-#define HUP_SPORTS_CONTROLS 0x0004
-#define HUP_GAMING_CONTROLS 0x0005
-#define HUP_KEYBOARD 0x0007
-#define HUP_LEDS 0x0008
-#define HUP_BUTTON 0x0009
-#define HUP_ORDINALS 0x000a
-#define HUP_TELEPHONY 0x000b
-#define HUP_CONSUMER 0x000c
-#define HUP_DIGITIZERS 0x000d
-#define HUP_PHYSICAL_IFACE 0x000e
-#define HUP_UNICODE 0x0010
-#define HUP_ALPHANUM_DISPLAY 0x0014
-#define HUP_MONITOR 0x0080
-#define HUP_MONITOR_ENUM_VAL 0x0081
-#define HUP_VESA_VC 0x0082
-#define HUP_VESA_CMD 0x0083
-#define HUP_POWER 0x0084
-#define HUP_BATTERY_SYSTEM 0x0085
-#define HUP_BARCODE_SCANNER 0x008b
-#define HUP_SCALE 0x008c
-#define HUP_CAMERA_CONTROL 0x0090
-#define HUP_ARCADE 0x0091
-#define HUP_MICROSOFT 0xff00
-
-/* Usages, generic desktop */
-#define HUG_POINTER 0x0001
-#define HUG_MOUSE 0x0002
-#define HUG_JOYSTICK 0x0004
-#define HUG_GAME_PAD 0x0005
-#define HUG_KEYBOARD 0x0006
-#define HUG_KEYPAD 0x0007
-#define HUG_X 0x0030
-#define HUG_Y 0x0031
-#define HUG_Z 0x0032
-#define HUG_RX 0x0033
-#define HUG_RY 0x0034
-#define HUG_RZ 0x0035
-#define HUG_SLIDER 0x0036
-#define HUG_DIAL 0x0037
-#define HUG_WHEEL 0x0038
-#define HUG_HAT_SWITCH 0x0039
-#define HUG_COUNTED_BUFFER 0x003a
-#define HUG_BYTE_COUNT 0x003b
-#define HUG_MOTION_WAKEUP 0x003c
-#define HUG_VX 0x0040
-#define HUG_VY 0x0041
-#define HUG_VZ 0x0042
-#define HUG_VBRX 0x0043
-#define HUG_VBRY 0x0044
-#define HUG_VBRZ 0x0045
-#define HUG_VNO 0x0046
-#define HUG_SYSTEM_CONTROL 0x0080
-#define HUG_SYSTEM_POWER_DOWN 0x0081
-#define HUG_SYSTEM_SLEEP 0x0082
-#define HUG_SYSTEM_WAKEUP 0x0083
-#define HUG_SYSTEM_CONTEXT_MENU 0x0084
-#define HUG_SYSTEM_MAIN_MENU 0x0085
-#define HUG_SYSTEM_APP_MENU 0x0086
-#define HUG_SYSTEM_MENU_HELP 0x0087
-#define HUG_SYSTEM_MENU_EXIT 0x0088
-#define HUG_SYSTEM_MENU_SELECT 0x0089
-#define HUG_SYSTEM_MENU_RIGHT 0x008a
-#define HUG_SYSTEM_MENU_LEFT 0x008b
-#define HUG_SYSTEM_MENU_UP 0x008c
-#define HUG_SYSTEM_MENU_DOWN 0x008d
-
-/* Usages Digitizers */
-#define HUD_UNDEFINED 0x0000
-#define HUD_TOUCH_SCREEN 0x0004
-#define HUD_FINGER 0x0022
-#define HUD_TIP_PRESSURE 0x0030
-#define HUD_BARREL_PRESSURE 0x0031
-#define HUD_IN_RANGE 0x0032
-#define HUD_TOUCH 0x0033
-#define HUD_UNTOUCH 0x0034
-#define HUD_TAP 0x0035
-#define HUD_QUALITY 0x0036
-#define HUD_DATA_VALID 0x0037
-#define HUD_TRANSDUCER_INDEX 0x0038
-#define HUD_TABLET_FKEYS 0x0039
-#define HUD_PROGRAM_CHANGE_KEYS 0x003a
-#define HUD_BATTERY_STRENGTH 0x003b
-#define HUD_INVERT 0x003c
-#define HUD_X_TILT 0x003d
-#define HUD_Y_TILT 0x003e
-#define HUD_AZIMUTH 0x003f
-#define HUD_ALTITUDE 0x0040
-#define HUD_TWIST 0x0041
-#define HUD_TIP_SWITCH 0x0042
-#define HUD_SEC_TIP_SWITCH 0x0043
-#define HUD_BARREL_SWITCH 0x0044
-#define HUD_ERASER 0x0045
-#define HUD_TABLET_PICK 0x0046
-
-/* Usages LEDs */
-#define HUD_LED_NUM_LOCK 0x0001
-#define HUD_LED_CAPS_LOCK 0x0002
-#define HUD_LED_SCROLL_LOCK 0x0003
-#define HUD_LED_COMPOSE 0x0004
-#define HUD_LED_KANA 0x0005
-
-/* Usages, Consumer */
-#define HUC_AC_PAN 0x0238
-
-#define HID_USAGE2(p, u) (((p) << 16) | u)
-#define HID_GET_USAGE(u) ((u) & 0xffff)
-#define HID_GET_USAGE_PAGE(u) (((u) >> 16) & 0xffff)
-
#define UHID_INPUT_REPORT 0x01
#define UHID_OUTPUT_REPORT 0x02
#define UHID_FEATURE_REPORT 0x03
-#define HCOLL_PHYSICAL 0
-#define HCOLL_APPLICATION 1
-#define HCOLL_LOGICAL 2
-
-/* Bits in the input/output/feature items */
-#define HIO_CONST 0x001
-#define HIO_VARIABLE 0x002
-#define HIO_RELATIVE 0x004
-#define HIO_WRAP 0x008
-#define HIO_NONLINEAR 0x010
-#define HIO_NOPREF 0x020
-#define HIO_NULLSTATE 0x040
-#define HIO_VOLATILE 0x080
-#define HIO_BUFBYTES 0x100
-
#endif /* _DEV_USB_USBHID_H_ */
diff --git a/sys/dev/usb/uthum.c b/sys/dev/usb/uthum.c
index d389b540c32..b1da54702d2 100644
--- a/sys/dev/usb/uthum.c
+++ b/sys/dev/usb/uthum.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uthum.c,v 1.13 2016/11/25 12:56:29 skrll Exp $ */
+/* $NetBSD: uthum.c,v 1.14 2017/12/10 17:03:07 bouyer Exp $ */
/* $OpenBSD: uthum.c,v 1.6 2010/01/03 18:43:02 deraadt Exp $ */
/*
@@ -22,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.13 2016/11/25 12:56:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.14 2017/12/10 17:03:07 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.13 2016/11/25 12:56:29 skrll Exp $");
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdevs.h>
#include <dev/usb/uhidev.h>
-#include <dev/usb/hid.h>
+#include <dev/hid/hid.h>
#ifdef UTHUM_DEBUG
int uthumdebug = 0;
diff --git a/sys/dev/usb/uts.c b/sys/dev/usb/uts.c
index 106ddbefde1..8cc695c6fdf 100644
--- a/sys/dev/usb/uts.c
+++ b/sys/dev/usb/uts.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uts.c,v 1.7 2017/05/17 14:15:29 macallan Exp $ */
+/* $NetBSD: uts.c,v 1.8 2017/12/10 17:03:07 bouyer Exp $ */
/*
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uts.c,v 1.7 2017/05/17 14:15:29 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uts.c,v 1.8 2017/12/10 17:03:07 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -55,7 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: uts.c,v 1.7 2017/05/17 14:15:29 macallan Exp $");
#include <dev/usb/usbdevs.h>
#include <dev/usb/usb_quirks.h>
#include <dev/usb/uhidev.h>
-#include <dev/usb/hid.h>
+#include <dev/hid/hid.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsmousevar.h>
diff --git a/sys/dev/usb/uyurex.c b/sys/dev/usb/uyurex.c
index 48af6a82121..d8c1bb86f51 100644
--- a/sys/dev/usb/uyurex.c
+++ b/sys/dev/usb/uyurex.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uyurex.c,v 1.12 2016/11/25 12:56:29 skrll Exp $ */
+/* $NetBSD: uyurex.c,v 1.13 2017/12/10 17:03:07 bouyer Exp $ */
/* $OpenBSD: uyurex.c,v 1.3 2010/03/04 03:47:22 deraadt Exp $ */
/*
@@ -22,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uyurex.c,v 1.12 2016/11/25 12:56:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uyurex.c,v 1.13 2017/12/10 17:03:07 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: uyurex.c,v 1.12 2016/11/25 12:56:29 skrll Exp $");
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdevs.h>
#include <dev/usb/uhidev.h>
-#include <dev/usb/hid.h>
+#include <dev/hid/hid.h>
#define CMD_NONE 0xf0
#define CMD_EOF 0x0d