comparison src/joystick/bsd/SDL_sysjoystick.c @ 4537:cd344ebc14e9

Debian patch: 215_kfreebsd_gnu.diff
author Sam Lantinga <slouken@libsdl.org>
date Sun, 18 Jul 2010 08:12:28 -0700
parents df65ae8f32e8
children 921637675f2c
comparison
equal deleted inserted replaced
4536:743930106dd7 4537:cd344ebc14e9
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 #ifdef 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
147 static char *joydevnames[MAX_JOYS]; 147 static char *joydevnames[MAX_JOYS];
148 148
149 static int report_alloc(struct report *, struct report_desc *, int); 149 static int report_alloc(struct report *, struct report_desc *, int);
150 static void report_free(struct report *); 150 static void report_free(struct report *);
151 151
152 #if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) 152 #if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) || defined(__FreeBSD_kernel__)
153 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) 153 #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data)
154 #else 154 #else
155 #define REP_BUF_DATA(rep) ((rep)->buf->data) 155 #define REP_BUF_DATA(rep) ((rep)->buf->data)
156 #endif 156 #endif
157 157
306 SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path, 306 SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path,
307 strerror(errno)); 307 strerror(errno));
308 goto usberr; 308 goto usberr;
309 } 309 }
310 rep = &hw->inreport; 310 rep = &hw->inreport;
311 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) 311 #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) || defined(__FreeBSD_kernel__)
312 rep->rid = hid_get_report_id(fd); 312 rep->rid = hid_get_report_id(fd);
313 if (rep->rid < 0) { 313 if (rep->rid < 0) {
314 #else 314 #else
315 if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) { 315 if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) {
316 #endif 316 #endif
322 if (rep->size <= 0) { 322 if (rep->size <= 0) {
323 SDL_SetError("%s: Input report descriptor has invalid length", 323 SDL_SetError("%s: Input report descriptor has invalid length",
324 hw->path); 324 hw->path);
325 goto usberr; 325 goto usberr;
326 } 326 }
327 #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) 327 #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__)
328 hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid); 328 hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid);
329 #else 329 #else
330 hdata = hid_start_parse(hw->repdesc, 1 << hid_input); 330 hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
331 #endif 331 #endif
332 if (hdata == NULL) { 332 if (hdata == NULL) {
407 struct hid_data *hdata; 407 struct hid_data *hdata;
408 struct report *rep; 408 struct report *rep;
409 int nbutton, naxe = -1; 409 int nbutton, naxe = -1;
410 Sint32 v; 410 Sint32 v;
411 411
412 #if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 412 #if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__)
413 struct joystick gameport; 413 struct joystick gameport;
414 static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0; 414 static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0;
415 415
416 if (joy->hwdata->type == BSDJOY_JOY) { 416 if (joy->hwdata->type == BSDJOY_JOY) {
417 if (read(joy->hwdata->fd, &gameport, sizeof gameport) != 417 if (read(joy->hwdata->fd, &gameport, sizeof gameport) !=
464 rep = &joy->hwdata->inreport; 464 rep = &joy->hwdata->inreport;
465 465
466 if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) { 466 if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
467 return; 467 return;
468 } 468 }
469 #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) 469 #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__)
470 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); 470 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
471 #else 471 #else
472 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); 472 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
473 #endif 473 #endif
474 if (hdata == NULL) { 474 if (hdata == NULL) {