shithub: riscv

Download patch

ref: 7af5442d3b031a3f81ea5c25c88f99692fb16822
parent: 67e14807e960d99d34ba1fc28fb3d2d656830249
author: mischief <mischief@offblast.org>
date: Wed Oct 10 09:56:28 EDT 2018

nusb/joy: send magic packet to enable playstation controller events

--- a/sys/src/cmd/nusb/joy/joy.c
+++ b/sys/src/cmd/nusb/joy/joy.c
@@ -359,7 +359,22 @@
 	}
 }
 
+/* apply quirks for special devices */
 static void
+quirks(Dev *d)
+{
+	int ret;
+	uchar buf[17];
+
+	/* sony dualshock 3 (ps3) controller requires special enable command */
+	if(d->usb->vid == 0x054c && d->usb->did == 0x0268){
+		ret = usbcmd(d, Rd2h|Rclass|Riface, Getreport, (0x3<<8) | 0xF2, 0, buf, sizeof(buf));
+		if(ret < 0)
+			sysfatal("failed to enable ps3 controller: %r");
+	}
+}
+
+static void
 kbstart(Dev *d, Ep *ep, void (*f)(void*))
 {
 	KDev *kd;
@@ -380,6 +395,7 @@
 		fprint(2, "%s: %s: opendevdata: %r\n", argv0, kd->ep->dir);
 		goto Err;
 	}
+	quirks(kd->dev);
 	f(kd);
 	return;
 Err: