Subject: pkg/30249: SDL does not recognize USB joysticks that use nonzero report IDs
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <svs+pr@grep.ru>
List: pkgsrc-bugs
Date: 05/16/2005 19:45:00
>Number:         30249
>Category:       pkg
>Synopsis:       SDL does not recognize USB joysticks that use nonzero report IDs
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 16 19:45:00 +0000 2005
>Originator:     Sergey Svishchev
>Release:        3.99.1
>Organization:
>Environment:
>Description:
A "WiseGroup MP-8866" PlayStation-to-USB controller adapter presents itself in the following way:

uhidev0: vendor 0x0925 MP-8866 Dual USB Joypad, rev 1.00/2.88, addr 3, iclass 3/0
uhidev0: 2 report ids
uhid0 at uhidev0 reportid 1: input=6, output=3, feature=0
uhid1 at uhidev0 reportid 2: input=6, output=3, feature=0

The code in SDL_sysjoystick.c assumes that all HID devices use report ID 0 and fails to attach this "joystick".
>How-To-Repeat:

>Fix:
--- src/joystick/bsd/SDL_sysjoystick.c.orig
+++ src/joystick/bsd/SDL_sysjoystick.c
@@ -280,7 +281,8 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy)
 	}
 
 	rep = &hw->inreport;
-	rep->rid = 0;
+	if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0)
+		rep->rid = -1; /* XXX */
 	if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) {
 		goto usberr;
 	}