git: 9front

Download patch

ref: c060df4a74bdd97774b96ecf734de946efefd022
parent: ec44cf66cd974620a994cd0c784e249bbf5a2622
author: mischief <mischief@offblast.org>
date: Sat Nov 21 07:31:54 EST 2020

nusb/kb, nusb/joy: dont try to set protocol on nonboot devices

the hid 1.11 specification says that for hid devices which arent in
the boot subclass (subclass 1), it is only optional to support the set
protocol command.  for my devices, trying to set protocol results in a
stall error and unusable devices.

fixes my Tex Shinobi keyboard and Playstation 4 controller.

--- a/sys/src/cmd/nusb/joy/joy.c
+++ b/sys/src/cmd/nusb/joy/joy.c
@@ -222,6 +222,14 @@
 		proto = Reportproto;
 	}else
 		kbfatal(f, "no report");
+
+	/*
+	 * if a HID's subclass code is 1 (boot mode), it will support
+	 * setproto, otherwise it is not guaranteed to.
+	 */
+	if(Subclass(f->dev->usb->ep[eid]->iface->csp) != 1)
+		return 0;
+
 	return usbcmd(f->dev, Rh2d|Rclass|Riface, Setproto, proto, id, nil, 0);
 }
 
--- a/sys/src/cmd/nusb/kb/kb.c
+++ b/sys/src/cmd/nusb/kb/kb.c
@@ -368,6 +368,14 @@
 		}
 		proto = Bootproto;
 	}
+
+	/*
+	 * if a HID's subclass code is 1 (boot mode), it will support
+	 * setproto, otherwise it is not guaranteed to.
+	 */
+	if(Subclass(iface->csp) != 1)
+		return 0;
+ 
 	return usbcmd(f->dev, Rh2d|Rclass|Riface, Setproto, proto, iface->id, nil, 0);
 }
 
--