Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
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
slouken committed Mar 5, 2013
1 parent 2ab00b1 commit 6e6ce9ea1f446e61acf5cc315344520f5d94071b
Showing with 10 additions and 2 deletions.
  1. +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);

0 comments on commit 6e6ce9e

Please sign in to comment.