On 2021 Jan 09 (Sat) at 07:00:29 -0700 (-0700), Thomas Frohwein wrote:
:On Sat, Nov 21, 2020 at 08:10:03AM +0200, Timo Myyrä wrote:
:> Hi,
:>
:> The last attempt at adding Kensington Slimblade trackball support seems
:> to have stalled:
:> https://marc.info/?l=openbsd-tech&m=147444999319756&w=2
:>
:> I tested the diff and it still seems apply with little fuzz and works
:> with my slimblade. It would be nice to have this included so I can paste
:> with mouse.
:>
:> Here's cleaned up patch for reference.
:>
:> timo
:
:I've been running with this diff through several snapshot upgrades
:without issues. Would be interested to hear if there are concerns about
:this diff or if I can get another ok? As far as quirks go, it's not
:much code and relatively simple...
:
this makes sense to have a quirk for, OK
:>
:>
:> Index: sys/dev/usb/ums.c
:> ===================================================================
:> RCS file: /cvs/src/sys/dev/usb/ums.c,v
:> retrieving revision 1.45
:> diff -u -p -u -p -r1.45 ums.c
:> --- sys/dev/usb/ums.c 23 Aug 2020 11:08:02 -0000 1.45
:> +++ sys/dev/usb/ums.c 20 Nov 2020 20:22:11 -0000
:> @@ -150,6 +150,8 @@ ums_attach(struct device *parent, struct
:> qflags |= HIDMS_MS_BAD_CLASS;
:> if (quirks & UQ_MS_LEADING_BYTE)
:> qflags |= HIDMS_LEADINGBYTE;
:> + if (quirks & UQ_MS_VENDOR_BUTTONS)
:> + qflags |= HIDMS_VENDOR_BUTTONS;
:>
:> if (hidms_setup(self, ms, qflags, uha->reportid, desc, size) != 0)
:> return;
:> Index: sys/dev/usb/usb_quirks.c
:> ===================================================================
:> RCS file: /cvs/src/sys/dev/usb/usb_quirks.c,v
:> retrieving revision 1.76
:> diff -u -p -u -p -r1.76 usb_quirks.c
:> --- sys/dev/usb/usb_quirks.c 5 Jan 2020 00:54:13 -0000 1.76
:> +++ sys/dev/usb/usb_quirks.c 20 Nov 2020 20:22:11 -0000
:> @@ -150,6 +150,9 @@ const struct usbd_quirk_entry {
:> { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLNOTEBOOK2,
:> ANY, { UQ_MS_BAD_CLASS | UQ_MS_LEADING_BYTE }},
:>
:> + { USB_VENDOR_KENSINGTON, USB_PRODUCT_KENSINGTON_SLIMBLADE,
:> + ANY, { UQ_MS_VENDOR_BUTTONS }},
:> +
:> { 0, 0, 0, { 0 } }
:> };
:>
:> Index: sys/dev/usb/usb_quirks.h
:> ===================================================================
:> RCS file: /cvs/src/sys/dev/usb/usb_quirks.h,v
:> retrieving revision 1.16
:> diff -u -p -u -p -r1.16 usb_quirks.h
:> --- sys/dev/usb/usb_quirks.h 19 Jul 2010 05:08:37 -0000 1.16
:> +++ sys/dev/usb/usb_quirks.h 20 Nov 2020 20:22:11 -0000
:> @@ -49,6 +49,8 @@ struct usbd_quirks {
:> #define UQ_MS_LEADING_BYTE 0x00010000 /* mouse sends unknown leading byte
*/
:> #define UQ_EHCI_NEEDTO_DISOWN 0x00020000 /* must hand device over to
USB 1.1
:> if attached to EHCI */
:> +#define UQ_MS_VENDOR_BUTTONS 0x00040000 /* mouse reports extra
buttons in
:> + vendor page */
:> };
:>
:> extern const struct usbd_quirks usbd_no_quirk;
:> Index: sys/dev/usb/usbdevs
:> ===================================================================
:> RCS file: /cvs/src/sys/dev/usb/usbdevs,v
:> retrieving revision 1.728
:> diff -u -p -u -p -r1.728 usbdevs
:> --- sys/dev/usb/usbdevs 16 Nov 2020 09:49:10 -0000 1.728
:> +++ sys/dev/usb/usbdevs 20 Nov 2020 20:22:11 -0000
:> @@ -2491,6 +2491,7 @@ product KENSINGTON TURBOBALL 0x1005 Turb
:> product KENSINGTON ORBIT_MAC 0x1009 Orbit trackball for Mac
:> product KENSINGTON BT_EDR 0x105e Bluetooth
:> product KENSINGTON VIDEOCAM_VGA 0x5002 VideoCAM VGA
:> +product KENSINGTON SLIMBLADE 0x2041 Slimblade Trackball
:>
:> /* Keyspan products */
:> product KEYSPAN USA28_NF 0x0101 USA-28 serial
:> Index: sys/dev/usb/usbdevs.h
:> ===================================================================
:> RCS file: /cvs/src/sys/dev/usb/usbdevs.h,v
:> retrieving revision 1.740
:> diff -u -p -u -p -r1.740 usbdevs.h
:> --- sys/dev/usb/usbdevs.h 16 Nov 2020 09:49:40 -0000 1.740
:> +++ sys/dev/usb/usbdevs.h 20 Nov 2020 20:22:11 -0000
:> @@ -2498,6 +2498,7 @@
:> #define USB_PRODUCT_KENSINGTON_ORBIT_MAC 0x1009 /*
Orbit trackball for Mac */
:> #define USB_PRODUCT_KENSINGTON_BT_EDR 0x105e /* Bluetooth */
:> #define USB_PRODUCT_KENSINGTON_VIDEOCAM_VGA 0x5002 /*
VideoCAM VGA */
:> +#define USB_PRODUCT_KENSINGTON_SLIMBLADE 0x2041 /*
Slimblade Trackball */
:>
:> /* Keyspan products */
:> #define USB_PRODUCT_KEYSPAN_USA28_NF 0x0101 /* USA-28
serial */
:> Index: sys/dev/usb/usbdevs_data.h
:> ===================================================================
:> RCS file: /cvs/src/sys/dev/usb/usbdevs_data.h,v
:> retrieving revision 1.734
:> diff -u -p -u -p -r1.734 usbdevs_data.h
:> --- sys/dev/usb/usbdevs_data.h 16 Nov 2020 09:49:40 -0000 1.734
:> +++ sys/dev/usb/usbdevs_data.h 20 Nov 2020 20:22:11 -0000
:> @@ -5402,6 +5402,10 @@ const struct usb_known_product usb_known
:> "VideoCAM VGA",
:> },
:> {
:> + USB_VENDOR_KENSINGTON, USB_PRODUCT_KENSINGTON_SLIMBLADE,
:> + "Slimblade Trackball",
:> + },
:> + {
:> USB_VENDOR_KEYSPAN, USB_PRODUCT_KEYSPAN_USA28_NF,
:> "USA-28 serial",
:> },
:> Index: sys/dev/hid/hidms.c
:> ===================================================================
:> RCS file: /cvs/src/sys/dev/hid/hidms.c,v
:> retrieving revision 1.5
:> diff -u -p -u -p -r1.5 hidms.c
:> --- sys/dev/hid/hidms.c 5 Sep 2018 16:34:58 -0000 1.5
:> +++ sys/dev/hid/hidms.c 20 Nov 2020 20:22:11 -0000
:> @@ -191,6 +191,21 @@ hidms_setup(struct device *self, struct
:> break;
:> ms->sc_num_buttons = i - 1;
:>
:> + /*
:> + * The Kensington Slimblade reports some of its buttons as binary
:> + * inputs in the first vendor usage page (0xff00). Add such inputs
:> + * as buttons if the device has this quirk.
:> + */
:> + if (ms->sc_flags & HIDMS_VENDOR_BUTTONS) {
:> + const int b = ms->sc_num_buttons;
:> + for (i = 1; b + i <= MAX_BUTTONS; i++)
:> + if (!hid_locate(desc, dlen,
:> + HID_USAGE2(HUP_MICROSOFT, i),
:> + id, hid_input, &ms->sc_loc_btn[b + i - 1], NULL))
:> + break;
:> + ms->sc_num_buttons += i;
:> + }
:> +
:> if (hid_locate(desc, dlen, HID_USAGE2(HUP_DIGITIZERS,
:> HUD_TIP_SWITCH), id, hid_input,
:> &ms->sc_loc_btn[ms->sc_num_buttons], NULL)){
:> Index: sys/dev/hid/hidmsvar.h
:> ===================================================================
:> RCS file: /cvs/src/sys/dev/hid/hidmsvar.h,v
:> retrieving revision 1.1
:> diff -u -p -u -p -r1.1 hidmsvar.h
:> --- sys/dev/hid/hidmsvar.h 8 Jan 2016 15:54:13 -0000 1.1
:> +++ sys/dev/hid/hidmsvar.h 20 Nov 2020 20:22:11 -0000
:> @@ -43,18 +43,19 @@ struct tsscale {
:> struct hidms {
:> int sc_enabled;
:> int sc_flags; /* device configuration */
:> -#define HIDMS_SPUR_BUT_UP 0x001 /* spurious button up events */
:> -#define HIDMS_Z 0x002 /* Z direction available */
:> -#define HIDMS_REVZ 0x004 /* Z-axis is reversed */
:> -#define HIDMS_W 0x008 /* W direction available */
:> -#define HIDMS_REVW 0x010 /* W-axis is reversed */
:> -#define HIDMS_LEADINGBYTE 0x020 /* Unknown leading byte */
:> -#define HIDMS_ABSX 0x040 /* X-axis is absolute */
:> -#define HIDMS_ABSY 0x080 /* Y-axis is absolute */
:> -#define HIDMS_TIP 0x100 /* Tip switch on a digitiser pen */
:> -#define HIDMS_BARREL 0x200 /* Barrel switch on a digitiser
pen */
:> -#define HIDMS_ERASER 0x400 /* Eraser switch on a digitiser
pen */
:> -#define HIDMS_MS_BAD_CLASS 0x800 /* Mouse doesn't identify properly */
:> +#define HIDMS_SPUR_BUT_UP 0x0001 /* spurious button up events */
:> +#define HIDMS_Z 0x0002 /* Z direction available */
:> +#define HIDMS_REVZ 0x0004 /* Z-axis is reversed */
:> +#define HIDMS_W 0x0008 /* W direction available */
:> +#define HIDMS_REVW 0x0010 /* W-axis is reversed */
:> +#define HIDMS_LEADINGBYTE 0x0020 /* Unknown leading byte */
:> +#define HIDMS_ABSX 0x0040 /* X-axis is absolute */
:> +#define HIDMS_ABSY 0x0080 /* Y-axis is absolute */
:> +#define HIDMS_TIP 0x0100 /* Tip switch on a digitiser pen */
:> +#define HIDMS_BARREL 0x0200 /* Barrel switch on a digitiser
pen */
:> +#define HIDMS_ERASER 0x0400 /* Eraser switch on a
digitiser pen */
:> +#define HIDMS_MS_BAD_CLASS 0x0800 /* Mouse doesn't identify properly */
:> +#define HIDMS_VENDOR_BUTTONS 0x1000 /* extra buttons in vendor page
*/
:>
:> int sc_num_buttons;
:> u_int32_t sc_buttons; /* mouse button status */
:>