Mercurial > sdl-ios-xcode
comparison src/joystick/bsd/SDL_sysjoystick.c @ 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 | f4ee83767bfd |
children | 1a7b62893c9d |
comparison
equal
deleted
inserted
replaced
4322:a8e5b518e194 | 4323:b3171b7561d8 |
---|---|
75 #include "../SDL_joystick_c.h" | 75 #include "../SDL_joystick_c.h" |
76 | 76 |
77 #define MAX_UHID_JOYS 4 | 77 #define MAX_UHID_JOYS 4 |
78 #define MAX_JOY_JOYS 2 | 78 #define MAX_JOY_JOYS 2 |
79 #define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) | 79 #define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) |
80 | |
81 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) | |
82 struct usb_ctl_report { | |
83 int ucr_report; | |
84 u_char ucr_data[1024]; /* filled data size will vary */ | |
85 }; | |
86 #endif | |
80 | 87 |
81 struct report { | 88 struct report { |
82 struct usb_ctl_report *buf; /* Buffer */ | 89 struct usb_ctl_report *buf; /* Buffer */ |
83 size_t size; /* Buffer size */ | 90 size_t size; /* Buffer size */ |
84 int rid; /* Report ID */ | 91 int rid; /* Report ID */ |
139 static char *joydevnames[MAX_JOYS]; | 146 static char *joydevnames[MAX_JOYS]; |
140 | 147 |
141 static int report_alloc(struct report *, struct report_desc *, int); | 148 static int report_alloc(struct report *, struct report_desc *, int); |
142 static void report_free(struct report *); | 149 static void report_free(struct report *); |
143 | 150 |
144 #ifdef USBHID_UCR_DATA | 151 #if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) |
145 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) | 152 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) |
146 #else | 153 #else |
147 #define REP_BUF_DATA(rep) ((rep)->buf->data) | 154 #define REP_BUF_DATA(rep) ((rep)->buf->data) |
148 #endif | 155 #endif |
149 | 156 |
294 if (hw->repdesc == NULL) { | 301 if (hw->repdesc == NULL) { |
295 SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path, | 302 SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path, |
296 strerror(errno)); | 303 strerror(errno)); |
297 goto usberr; | 304 goto usberr; |
298 } | 305 } |
299 | 306 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) |
307 rep->rid = hid_get_report_id(fd); | |
308 if (rep->rid < 0) { | |
309 #else | |
300 rep = &hw->inreport; | 310 rep = &hw->inreport; |
301 if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) { | 311 if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) { |
312 #endif | |
302 rep->rid = -1; /* XXX */ | 313 rep->rid = -1; /* XXX */ |
303 } | 314 } |
304 if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) { | 315 if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) { |
305 goto usberr; | 316 goto usberr; |
306 } | 317 } |