Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1553 - Fix USB joystick input for FreeBSD 9.0+
Browse files Browse the repository at this point in the history
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
slouken committed Mar 5, 2013
1 parent 2ab00b1 commit 6e6ce9e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/joystick/bsd/SDL_sysjoystick.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6e6ce9e

Please sign in to comment.