comparison src/joystick/bsd/SDL_sysjoystick.c @ 4540:e978b888d87a SDL-1.2

Debian patch: 215_kfreebsd_gnu.diff
author Sam Lantinga <slouken@libsdl.org>
date Sun, 18 Jul 2010 08:12:48 -0700
parents 1a7b62893c9d
children
comparison
equal deleted inserted replaced
4539:d2517c0de52b 4540:e978b888d87a
57 #include <libusb.h> 57 #include <libusb.h>
58 #elif defined(HAVE_LIBUSBHID_H) 58 #elif defined(HAVE_LIBUSBHID_H)
59 #include <libusbhid.h> 59 #include <libusbhid.h>
60 #endif 60 #endif
61 61
62 #ifdef __FREEBSD__ 62 #if defined(__FREEBSD__) || defined(__FreeBSD_kernel__)
63 #ifndef __DragonFly__ 63 #ifndef __DragonFly__
64 #include <osreldate.h> 64 #include <osreldate.h>
65 #endif 65 #endif
66 #include <sys/joystick.h> 66 #include <sys/joystick.h>
67 #endif 67 #endif
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 80
81 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) 81 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) && false
82 struct usb_ctl_report { 82 struct usb_ctl_report {
83 int ucr_report; 83 int ucr_report;
84 u_char ucr_data[1024]; /* filled data size will vary */ 84 u_char ucr_data[1024]; /* filled data size will vary */
85 }; 85 };
86 #endif 86 #endif
146 static char *joydevnames[MAX_JOYS]; 146 static char *joydevnames[MAX_JOYS];
147 147
148 static int report_alloc(struct report *, struct report_desc *, int); 148 static int report_alloc(struct report *, struct report_desc *, int);
149 static void report_free(struct report *); 149 static void report_free(struct report *);
150 150
151 #if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) 151 #if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) || defined(__FreeBSD_kernel__)
152 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) 152 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data)
153 #else 153 #else
154 #define REP_BUF_DATA(rep) ((rep)->buf->data) 154 #define REP_BUF_DATA(rep) ((rep)->buf->data)
155 #endif 155 #endif
156 156
302 SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path, 302 SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path,
303 strerror(errno)); 303 strerror(errno));
304 goto usberr; 304 goto usberr;
305 } 305 }
306 rep = &hw->inreport; 306 rep = &hw->inreport;
307 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) 307 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) || defined(__FreeBSD_kernel__)
308 rep->rid = hid_get_report_id(fd); 308 rep->rid = hid_get_report_id(fd);
309 if (rep->rid < 0) { 309 if (rep->rid < 0) {
310 #else 310 #else
311 if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) { 311 if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) {
312 #endif 312 #endif
319 SDL_SetError("%s: Input report descriptor has invalid length", 319 SDL_SetError("%s: Input report descriptor has invalid length",
320 hw->path); 320 hw->path);
321 goto usberr; 321 goto usberr;
322 } 322 }
323 323
324 #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) 324 #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__)
325 hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid); 325 hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid);
326 #else 326 #else
327 hdata = hid_start_parse(hw->repdesc, 1 << hid_input); 327 hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
328 #endif 328 #endif
329 if (hdata == NULL) { 329 if (hdata == NULL) {
403 struct hid_data *hdata; 403 struct hid_data *hdata;
404 struct report *rep; 404 struct report *rep;
405 int nbutton, naxe = -1; 405 int nbutton, naxe = -1;
406 Sint32 v; 406 Sint32 v;
407 407
408 #if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 408 #if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__)
409 struct joystick gameport; 409 struct joystick gameport;
410 410
411 if (joy->hwdata->type == BSDJOY_JOY) { 411 if (joy->hwdata->type == BSDJOY_JOY) {
412 if (read(joy->hwdata->fd, &gameport, sizeof gameport) != sizeof gameport) 412 if (read(joy->hwdata->fd, &gameport, sizeof gameport) != sizeof gameport)
413 return; 413 return;
458 rep = &joy->hwdata->inreport; 458 rep = &joy->hwdata->inreport;
459 459
460 if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) { 460 if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
461 return; 461 return;
462 } 462 }
463 #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) 463 #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__)
464 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); 464 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
465 #else 465 #else
466 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); 466 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
467 #endif 467 #endif
468 if (hdata == NULL) { 468 if (hdata == NULL) {