shithub: fork

Download patch

ref: 738cfd74ecbbce953831e979b3f3773f244f28a9
parent: b5629237426958752481c832c207f4a927de5dd8
author: qwx <qwx@sciops.net>
date: Sat Mar 15 09:59:42 EDT 2025

slightly more robust joystick parsing

--- a/sys/src/games/eui.c
+++ b/sys/src/games/eui.c
@@ -68,7 +68,6 @@
 	Kfn *kp;
 
 	j = 1;
-
 	for(;;){
 		n = read(0, buf, sizeof(buf) - 1);
 		if(n <= 0)
@@ -75,13 +74,18 @@
 			sysfatal("read: %r");
 		buf[n] = 0;
 		n = getfields(buf, down, nelem(down), 1, " ");
+		if(n <= 0)
+			continue;
 		k = 0;
 		for(n--; n >= 0; n--){
 			s = down[n];
-			if(strcmp(s, "joy1") == 0)
-				j = 1;
-			else if(strcmp(s, "joy2") == 0)
-				j = 2;
+			if(strncmp(s, "joy", 3) == 0){
+				if(strcmp(s, "2 ") == 0)
+					j = 2;
+				else
+					j = 1;
+				continue;
+			}
 			for(kp=kkn.n; kp!=nil; kp=kp->n){
 				if(strcmp(kp->joyk, s) == 0)
 					k |= kp->k;