Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fixed bug 1553 - Fix USB joystick input for FreeBSD 9.0+
Marcus von Appen
Receiving input from USB joysticks on FreeBSD 9.0 or newer is broken at the moment. The attached patch fixes this.
- Loading branch information
Showing
with
10 additions
and
2 deletions.
-
+10
−2
src/joystick/bsd/SDL_sysjoystick.c
|
@@ -83,7 +83,9 @@ |
|
|
|
|
|
struct report |
|
|
{ |
|
|
#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) |
|
|
#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000) |
|
|
void *buf; /* Buffer */ |
|
|
#elif defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) |
|
|
struct usb_gen_descriptor *buf; /* Buffer */ |
|
|
#else |
|
|
struct usb_ctl_report *buf; /* Buffer */ |
|
@@ -149,8 +151,10 @@ static char *joydevnames[MAX_JOYS]; |
|
|
static int report_alloc(struct report *, struct report_desc *, int); |
|
|
static void report_free(struct report *); |
|
|
|
|
|
#if defined(USBHID_UCR_DATA) |
|
|
#if defined(USBHID_UCR_DATA) || (defined(__FreeBSD_kernel__) && __FreeBSD_kernel_version <= 800063) |
|
|
#define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) |
|
|
#elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000)) |
|
|
#define REP_BUF_DATA(rep) ((rep)->buf) |
|
|
#elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) |
|
|
#define REP_BUF_DATA(rep) ((rep)->buf->ugd_data) |
|
|
#else |
|
@@ -636,8 +640,12 @@ report_alloc(struct report *r, struct report_desc *rd, int repind) |
|
|
r->size = len; |
|
|
|
|
|
if (r->size > 0) { |
|
|
#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000) |
|
|
r->buf = SDL_malloc(r->size); |
|
|
#else |
|
|
r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) + |
|
|
r->size); |
|
|
#endif |
|
|
if (r->buf == NULL) { |
|
|
SDL_OutOfMemory(); |
|
|
return (-1); |
|
|