changeset 4323:b3171b7561d8 SDL-1.2

Joystick patch from FreeBSD ports system
author Sam Lantinga <slouken@libsdl.org>
date Mon, 12 Oct 2009 09:32:55 +0000
parents a8e5b518e194
children 1496aa09e41e
files src/joystick/bsd/SDL_sysjoystick.c
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/joystick/bsd/SDL_sysjoystick.c	Mon Oct 12 08:58:12 2009 +0000
+++ b/src/joystick/bsd/SDL_sysjoystick.c	Mon Oct 12 09:32:55 2009 +0000
@@ -78,6 +78,13 @@
 #define MAX_JOY_JOYS	2
 #define MAX_JOYS	(MAX_UHID_JOYS + MAX_JOY_JOYS)
 
+#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)
+struct usb_ctl_report {
+	int	ucr_report;
+	u_char	ucr_data[1024]; /* filled data size will vary */
+};
+#endif
+
 struct report {
 	struct	usb_ctl_report *buf;	/* Buffer */
 	size_t	size;			/* Buffer size */
@@ -141,7 +148,7 @@
 static int	report_alloc(struct report *, struct report_desc *, int);
 static void	report_free(struct report *);
 
-#ifdef USBHID_UCR_DATA
+#if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063))
 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data)
 #else
 #define REP_BUF_DATA(rep) ((rep)->buf->data)
@@ -296,9 +303,13 @@
 		    strerror(errno));
 		goto usberr;
 	}
-
+#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)
+       rep->rid = hid_get_report_id(fd);
+       if (rep->rid < 0) {
+#else
 	rep = &hw->inreport;
 	if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) {
+#endif
 		rep->rid = -1; /* XXX */
 	}
 	if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) {