Joystick patch from FreeBSD ports system SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Mon, 12 Oct 2009 09:32:55 +0000
branchSDL-1.2
changeset 4323b3171b7561d8
parent 4322 a8e5b518e194
child 4324 1496aa09e41e
Joystick patch from FreeBSD ports system
src/joystick/bsd/SDL_sysjoystick.c
     1.1 --- a/src/joystick/bsd/SDL_sysjoystick.c	Mon Oct 12 08:58:12 2009 +0000
     1.2 +++ b/src/joystick/bsd/SDL_sysjoystick.c	Mon Oct 12 09:32:55 2009 +0000
     1.3 @@ -78,6 +78,13 @@
     1.4  #define MAX_JOY_JOYS	2
     1.5  #define MAX_JOYS	(MAX_UHID_JOYS + MAX_JOY_JOYS)
     1.6  
     1.7 +#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)
     1.8 +struct usb_ctl_report {
     1.9 +	int	ucr_report;
    1.10 +	u_char	ucr_data[1024]; /* filled data size will vary */
    1.11 +};
    1.12 +#endif
    1.13 +
    1.14  struct report {
    1.15  	struct	usb_ctl_report *buf;	/* Buffer */
    1.16  	size_t	size;			/* Buffer size */
    1.17 @@ -141,7 +148,7 @@
    1.18  static int	report_alloc(struct report *, struct report_desc *, int);
    1.19  static void	report_free(struct report *);
    1.20  
    1.21 -#ifdef USBHID_UCR_DATA
    1.22 +#if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063))
    1.23  #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data)
    1.24  #else
    1.25  #define REP_BUF_DATA(rep) ((rep)->buf->data)
    1.26 @@ -296,9 +303,13 @@
    1.27  		    strerror(errno));
    1.28  		goto usberr;
    1.29  	}
    1.30 -
    1.31 +#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)
    1.32 +       rep->rid = hid_get_report_id(fd);
    1.33 +       if (rep->rid < 0) {
    1.34 +#else
    1.35  	rep = &hw->inreport;
    1.36  	if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) {
    1.37 +#endif
    1.38  		rep->rid = -1; /* XXX */
    1.39  	}
    1.40  	if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) {