comparison src/joystick/bsd/SDL_sysjoystick.c @ 611:0a2ef9e8ca41

Date: Wed, 9 Apr 2003 01:03:25 -0400 (EDT) From: "Matthew N. Dodd" Subject: SDL patch: FreeBSD joystick support. This patch deals with the recent changes in FreeBSD. We're making an effort not to diverge our libusbhid from NetBSD's.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 15 Apr 2003 16:02:08 +0000
parents 639d58d32471
children 85e104fe14c2
comparison
equal deleted inserted replaced
610:95433459fbd2 611:0a2ef9e8ca41
51 #include <usbhid.h> 51 #include <usbhid.h>
52 #elif defined(HAVE_LIBUSB_H) 52 #elif defined(HAVE_LIBUSB_H)
53 #include <libusb.h> 53 #include <libusb.h>
54 #elif defined(HAVE_LIBUSBHID_H) 54 #elif defined(HAVE_LIBUSBHID_H)
55 #include <libusbhid.h> 55 #include <libusbhid.h>
56 #endif
57
58 #ifdef __FreeBSD__
59 #include <osreldate.h>
56 #endif 60 #endif
57 61
58 #include "SDL_error.h" 62 #include "SDL_error.h"
59 #include "SDL_joystick.h" 63 #include "SDL_joystick.h"
60 #include "SDL_sysjoystick.h" 64 #include "SDL_sysjoystick.h"
208 strerror(errno)); 212 strerror(errno));
209 goto usberr; 213 goto usberr;
210 } 214 }
211 215
212 rep = &hw->inreport; 216 rep = &hw->inreport;
217 rep->rid = 0;
213 if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) { 218 if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) {
214 goto usberr; 219 goto usberr;
215 } 220 }
216 if (rep->size <= 0) { 221 if (rep->size <= 0) {
217 SDL_SetError("%s: Input report descriptor has invalid length", 222 SDL_SetError("%s: Input report descriptor has invalid length",
218 hw->path); 223 hw->path);
219 goto usberr; 224 goto usberr;
220 } 225 }
221 226
222 #ifdef USBHID_NEW 227 #if defined(USBHID_NEW) || (defined(__FreeBSD__) && __FreeBSD_version >= 500111)
223 hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid); 228 hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid);
224 #else 229 #else
225 hdata = hid_start_parse(hw->repdesc, 1 << hid_input); 230 hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
226 #endif 231 #endif
227 if (hdata == NULL) { 232 if (hdata == NULL) {
307 rep = &joy->hwdata->inreport; 312 rep = &joy->hwdata->inreport;
308 313
309 if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) { 314 if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
310 return; 315 return;
311 } 316 }
312 #ifdef USBHID_NEW 317 #if defined(USBHID_NEW) || (defined(__FreeBSD__) && __FreeBSD_version >= 500111)
313 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); 318 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
314 #else 319 #else
315 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); 320 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
316 #endif 321 #endif
317 if (hdata == NULL) { 322 if (hdata == NULL) {
408 { 413 {
409 int len; 414 int len;
410 415
411 #ifdef __FreeBSD__ 416 #ifdef __FreeBSD__
412 # if (__FreeBSD_version >= 470000) 417 # if (__FreeBSD_version >= 470000)
418 # if (__FreeBSD_version <= 500111)
413 len = hid_report_size(rd, r->rid, repinfo[repind].kind); 419 len = hid_report_size(rd, r->rid, repinfo[repind].kind);
420 # else
421 len = hid_report_size(rd, repinfo[repind].kind, r->rid);
422 # endif
414 # else 423 # else
415 len = hid_report_size(rd, repinfo[repind].kind, &r->rid); 424 len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
416 #endif 425 #endif
417 #else 426 #else
418 # ifdef USBHID_NEW 427 # ifdef USBHID_NEW