Mercurial > sdl-ios-xcode
comparison src/joystick/bsd/SDL_sysjoystick.c @ 3385:45d7f0f70b27
Joystick patch from FreeBSD ports system
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 12 Oct 2009 09:42:50 +0000 |
parents | 7a7a61a1484d |
children | f7b03b6838cb |
comparison
equal
deleted
inserted
replaced
3384:04af265172f9 | 3385:45d7f0f70b27 |
---|---|
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 { | 89 { |
83 struct usb_ctl_report *buf; /* Buffer */ | 90 struct usb_ctl_report *buf; /* Buffer */ |
84 size_t size; /* Buffer size */ | 91 size_t size; /* Buffer size */ |
140 static char *joydevnames[MAX_JOYS]; | 147 static char *joydevnames[MAX_JOYS]; |
141 | 148 |
142 static int report_alloc(struct report *, struct report_desc *, int); | 149 static int report_alloc(struct report *, struct report_desc *, int); |
143 static void report_free(struct report *); | 150 static void report_free(struct report *); |
144 | 151 |
145 #ifdef USBHID_UCR_DATA | 152 #if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) |
146 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) | 153 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) |
147 #else | 154 #else |
148 #define REP_BUF_DATA(rep) ((rep)->buf->data) | 155 #define REP_BUF_DATA(rep) ((rep)->buf->data) |
149 #endif | 156 #endif |
150 | 157 |
298 if (hw->repdesc == NULL) { | 305 if (hw->repdesc == NULL) { |
299 SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path, | 306 SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path, |
300 strerror(errno)); | 307 strerror(errno)); |
301 goto usberr; | 308 goto usberr; |
302 } | 309 } |
303 | 310 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) |
311 rep->rid = hid_get_report_id(fd); | |
312 if (rep->rid < 0) { | |
313 #else | |
304 rep = &hw->inreport; | 314 rep = &hw->inreport; |
305 if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) { | 315 if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) { |
316 #endif | |
306 rep->rid = -1; /* XXX */ | 317 rep->rid = -1; /* XXX */ |
307 } | 318 } |
308 if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) { | 319 if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) { |
309 goto usberr; | 320 goto usberr; |
310 } | 321 } |