git: 9front

Download patch

ref: 56b5223ad352fcef003925e8400a3ce1e49c3fbd
parent: 6a7cee187547ca586ed1c4e137c77f18daf21140
author: Arne <cgnarne@netcologne.de>
date: Fri Oct 31 13:48:02 EDT 2025

nusb/joy: support shanwan controllers in xbox360 mode

usb controllers made by shanwan need some extra initialization to work in
xbox360 mode. the linux xpad driver does the same. this was tested by
user hardkorebob on irc.

--- a/sys/src/cmd/nusb/joy/joy.c
+++ b/sys/src/cmd/nusb/joy/joy.c
@@ -453,7 +453,14 @@
 		0xc0,
 	};
 	static uchar ledcmd[] = {1,3,0};
+	uchar b[20];
 	Dev *d = kd->dev;
+
+	if(cistrcmp("shanwan", d->usb->vendor) == 0){
+		usbcmd(d, Rd2h|Rvendor|Riface, 0x01, 0x100, 0, b, 20);
+		usbcmd(d, Rd2h|Rvendor|Riface, 0x01, 0, 0, b, 8);
+		usbcmd(d, Rd2h|Rvendor|Rdev, 0x01, 0, 0, b, 4);
+	}
 
 	memcpy(kd->rep, descr, kd->nrep = sizeof(descr));
 	/* no blinken lights */
--