summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/usb/ums.c55
-rw-r--r--sys/dev/usb/usbdevs9
-rw-r--r--sys/dev/usb/usbdevs.h9
-rw-r--r--sys/dev/usb/usbdevs_data.h30
4 files changed, 99 insertions, 4 deletions
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c
index f9cd4ac6cc5..ed94ef7c220 100644
--- a/sys/dev/usb/ums.c
+++ b/sys/dev/usb/ums.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ums.c,v 1.43 2016/01/12 19:16:21 jcs Exp $ */
+/* $OpenBSD: ums.c,v 1.44 2020/06/17 23:43:08 bru Exp $ */
/* $NetBSD: ums.c,v 1.60 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -65,6 +65,7 @@ void ums_intr(struct uhidev *addr, void *ibuf, u_int len);
int ums_enable(void *);
void ums_disable(void *);
int ums_ioctl(void *, u_long, caddr_t, int, struct proc *);
+void ums_fix_elecom_descriptor(struct ums_softc *, void *, int, int);
const struct wsmouse_accessops ums_accessops = {
ums_enable,
@@ -130,6 +131,10 @@ ums_attach(struct device *parent, struct device *self, void *aux)
quirks = usbd_get_quirks(sc->sc_hdev.sc_udev)->uq_flags;
uhidev_get_report_desc(uha->parent, &desc, &size);
+
+ if (uaa->vendor == USB_VENDOR_ELECOM)
+ ums_fix_elecom_descriptor(sc, desc, size, uaa->product);
+
repid = uha->reportid;
sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
@@ -237,3 +242,51 @@ ums_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
return -1;
}
}
+
+/*
+ * Some ELECOM devices present flawed report descriptors. Instead of a 5-bit
+ * field and a 3-bit padding as defined by the descriptor they actually use
+ * 6 or 8 Bits to report button states, see
+ * https://flameeyes.blog/2017/04/24/elecom-deft-and-the-broken-descriptor
+ * This function adapts the Report Count value for the button page, its Usage
+ * Maximum and the report size for the padding bits (at offset 31).
+ */
+void
+ums_fix_elecom_descriptor(struct ums_softc *sc, void *desc, int size,
+ int product)
+{
+ static uByte match[] = { /* a descriptor fragment, offset: 12 */
+ 0x95, 0x05, 0x75, 0x01, /* Report Count (5), Report Size (1) */
+ 0x05, 0x09, 0x19, 0x01, /* Usage Page (Button), Usage Minimum (1) */
+ 0x29, 0x05, /* Usage Maximum (5) */
+ };
+ uByte *udesc = desc;
+ int nbuttons;
+
+ switch (product) {
+ case USB_PRODUCT_ELECOM_MXT3URBK: /* EX-G Trackballs */
+ case USB_PRODUCT_ELECOM_MXT3DRBK:
+ case USB_PRODUCT_ELECOM_MXT4DRBK:
+ nbuttons = 6;
+ break;
+ case USB_PRODUCT_ELECOM_MDT1URBK: /* DEFT Trackballs */
+ case USB_PRODUCT_ELECOM_MDT1DRBK:
+ case USB_PRODUCT_ELECOM_MHT1URBK: /* HUGE Trackballs */
+ case USB_PRODUCT_ELECOM_MHT1DRBK:
+ nbuttons = 8;
+ break;
+ default:
+ return;
+ }
+
+ if (udesc == NULL || size < 32
+ || memcmp(&udesc[12], match, sizeof(match))
+ || udesc[30] != 0x75 || udesc[31] != 3)
+ return;
+
+ printf("%s: fixing Elecom report descriptor (buttons: %d)\n",
+ sc->sc_hdev.sc_dev.dv_xname, nbuttons);
+ udesc[13] = nbuttons;
+ udesc[21] = nbuttons;
+ udesc[31] = 8 - nbuttons;
+}
diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs
index 9cf6d7eac15..6a1d20ded81 100644
--- a/sys/dev/usb/usbdevs
+++ b/sys/dev/usb/usbdevs
@@ -1,4 +1,4 @@
-$OpenBSD: usbdevs,v 1.715 2020/05/31 18:12:04 jcs Exp $
+$OpenBSD: usbdevs,v 1.716 2020/06/17 23:43:08 bru Exp $
/* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */
/*
@@ -1701,6 +1701,13 @@ product ELECOM LDUSB20 0x4010 LD-USB20
product ELECOM UCSGT 0x5003 UC-SGT Serial
product ELECOM UCSGT0 0x5004 UC-SGT0 Serial
product ELECOM LDUSBTX3 0xabc1 LD-USB/TX
+product ELECOM MXT3URBK 0x00fb M-XT3UR BK
+product ELECOM MXT3DRBK 0x00fc M-XT3DR BK
+product ELECOM MXT4DRBK 0x00fd M-XT4DR BK
+product ELECOM MDT1URBK 0x00fe M-DT1UR BK
+product ELECOM MDT1DRBK 0x00ff M-DT1DR BK
+product ELECOM MHT1URBK 0x010c M-HT1UR BK
+product ELECOM MHT1DRBK 0x010d M-HT1DR BK
/* Elektor Electronics products */
product ELEKTOR FT323R 0x0005 FT323R
diff --git a/sys/dev/usb/usbdevs.h b/sys/dev/usb/usbdevs.h
index 1d0de8cce97..45fda88512f 100644
--- a/sys/dev/usb/usbdevs.h
+++ b/sys/dev/usb/usbdevs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs.h,v 1.727 2020/05/31 18:12:28 jcs Exp $ */
+/* $OpenBSD: usbdevs.h,v 1.728 2020/06/17 23:43:08 bru Exp $ */
/*
* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
@@ -1708,6 +1708,13 @@
#define USB_PRODUCT_ELECOM_UCSGT 0x5003 /* UC-SGT Serial */
#define USB_PRODUCT_ELECOM_UCSGT0 0x5004 /* UC-SGT0 Serial */
#define USB_PRODUCT_ELECOM_LDUSBTX3 0xabc1 /* LD-USB/TX */
+#define USB_PRODUCT_ELECOM_MXT3URBK 0x00fb /* M-XT3UR BK */
+#define USB_PRODUCT_ELECOM_MXT3DRBK 0x00fc /* M-XT3DR BK */
+#define USB_PRODUCT_ELECOM_MXT4DRBK 0x00fd /* M-XT4DR BK */
+#define USB_PRODUCT_ELECOM_MDT1URBK 0x00fe /* M-DT1UR BK */
+#define USB_PRODUCT_ELECOM_MDT1DRBK 0x00ff /* M-DT1DR BK */
+#define USB_PRODUCT_ELECOM_MHT1URBK 0x010c /* M-HT1UR BK */
+#define USB_PRODUCT_ELECOM_MHT1DRBK 0x010d /* M-HT1DR BK */
/* Elektor Electronics products */
#define USB_PRODUCT_ELEKTOR_FT323R 0x0005 /* FT323R */
diff --git a/sys/dev/usb/usbdevs_data.h b/sys/dev/usb/usbdevs_data.h
index e877c5c12b3..5f99654dda1 100644
--- a/sys/dev/usb/usbdevs_data.h
+++ b/sys/dev/usb/usbdevs_data.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs_data.h,v 1.721 2020/05/31 18:12:28 jcs Exp $ */
+/* $OpenBSD: usbdevs_data.h,v 1.722 2020/06/17 23:43:08 bru Exp $ */
/*
* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
@@ -3030,6 +3030,34 @@ const struct usb_known_product usb_known_products[] = {
"LD-USB/TX",
},
{
+ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_MXT3URBK,
+ "M-XT3UR BK",
+ },
+ {
+ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_MXT3DRBK,
+ "M-XT3DR BK",
+ },
+ {
+ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_MXT4DRBK,
+ "M-XT4DR BK",
+ },
+ {
+ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_MDT1URBK,
+ "M-DT1UR BK",
+ },
+ {
+ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_MDT1DRBK,
+ "M-DT1DR BK",
+ },
+ {
+ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_MHT1URBK,
+ "M-HT1UR BK",
+ },
+ {
+ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_MHT1DRBK,
+ "M-HT1DR BK",
+ },
+ {
USB_VENDOR_ELEKTOR, USB_PRODUCT_ELEKTOR_FT323R,
"FT323R",
},