comparison src/joystick/bsd/SDL_sysjoystick.c @ 1402:d910939febfa

Use consistent identifiers for the various platforms we support. Make sure every source file includes SDL_config.h, so the proper system headers are chosen.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 21 Feb 2006 08:46:50 +0000
parents 19418e4422cb
children e7f61857028a
comparison
equal deleted inserted replaced
1401:1819fd069e89 1402:d910939febfa
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 18
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22 #include "SDL_config.h"
22 23
23 /* 24 /*
24 * Joystick driver for the uhid(4) interface found in OpenBSD, 25 * Joystick driver for the uhid(4) interface found in OpenBSD,
25 * NetBSD and FreeBSD. 26 * NetBSD and FreeBSD.
26 * 27 *
45 #include <libusb.h> 46 #include <libusb.h>
46 #elif defined(HAVE_LIBUSBHID_H) 47 #elif defined(HAVE_LIBUSBHID_H)
47 #include <libusbhid.h> 48 #include <libusbhid.h>
48 #endif 49 #endif
49 50
50 #ifdef __FreeBSD__ 51 #ifdef __FREEBSD__
51 #include <osreldate.h> 52 #include <osreldate.h>
52 #include <sys/joystick.h> 53 #include <sys/joystick.h>
53 #endif 54 #endif
54 55
55 #if defined(__NetBSD__) || (defined(__OpenBSD__) && defined(__i386__)) 56 #if defined(__NETBSD__) || (defined(__OPENBSD__) && defined(__i386__))
56 #include <machine/joystick.h> 57 #include <machine/joystick.h>
57 #endif 58 #endif
58 59
59 #include "SDL_joystick.h" 60 #include "SDL_joystick.h"
60 #include "../SDL_sysjoystick.h" 61 #include "../SDL_sysjoystick.h"
279 SDL_SetError("%s: Input report descriptor has invalid length", 280 SDL_SetError("%s: Input report descriptor has invalid length",
280 hw->path); 281 hw->path);
281 goto usberr; 282 goto usberr;
282 } 283 }
283 284
284 #if defined(USBHID_NEW) || (defined(__FreeBSD__) && __FreeBSD_version >= 500111) 285 #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_version >= 500111)
285 hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid); 286 hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid);
286 #else 287 #else
287 hdata = hid_start_parse(hw->repdesc, 1 << hid_input); 288 hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
288 #endif 289 #endif
289 if (hdata == NULL) { 290 if (hdata == NULL) {
359 struct hid_data *hdata; 360 struct hid_data *hdata;
360 struct report *rep; 361 struct report *rep;
361 int nbutton, naxe = -1; 362 int nbutton, naxe = -1;
362 Sint32 v; 363 Sint32 v;
363 364
364 #if defined(__FreeBSD__) || defined(__NetBSD__) || (defined(__OpenBSD__) && defined(__i386__)) 365 #if defined(__FREEBSD__) || defined(__NETBSD__) || (defined(__OPENBSD__) && defined(__i386__))
365 struct joystick gameport; 366 struct joystick gameport;
366 static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0; 367 static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0;
367 368
368 if (joy->hwdata->type == BSDJOY_JOY) { 369 if (joy->hwdata->type == BSDJOY_JOY) {
369 if (read(joy->hwdata->fd, &gameport, sizeof gameport) != sizeof gameport) 370 if (read(joy->hwdata->fd, &gameport, sizeof gameport) != sizeof gameport)
408 if (gameport.b2 != joy->buttons[1]) { 409 if (gameport.b2 != joy->buttons[1]) {
409 SDL_PrivateJoystickButton(joy, 1, gameport.b2); 410 SDL_PrivateJoystickButton(joy, 1, gameport.b2);
410 } 411 }
411 return; 412 return;
412 } 413 }
413 #endif /* defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) */ 414 #endif /* defined(__FREEBSD__) || defined(__NETBSD__) || defined(__OPENBSD__) */
414 415
415 rep = &joy->hwdata->inreport; 416 rep = &joy->hwdata->inreport;
416 417
417 if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) { 418 if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
418 return; 419 return;
419 } 420 }
420 #if defined(USBHID_NEW) || (defined(__FreeBSD__) && __FreeBSD_version >= 500111) 421 #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_version >= 500111)
421 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); 422 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
422 #else 423 #else
423 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); 424 hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
424 #endif 425 #endif
425 if (hdata == NULL) { 426 if (hdata == NULL) {
507 static int 508 static int
508 report_alloc(struct report *r, struct report_desc *rd, int repind) 509 report_alloc(struct report *r, struct report_desc *rd, int repind)
509 { 510 {
510 int len; 511 int len;
511 512
512 #ifdef __FreeBSD__ 513 #ifdef __FREEBSD__
513 # if (__FreeBSD_version >= 460000) 514 # if (__FreeBSD_version >= 460000)
514 # if (__FreeBSD_version <= 500111) 515 # if (__FreeBSD_version <= 500111)
515 len = hid_report_size(rd, r->rid, repinfo[repind].kind); 516 len = hid_report_size(rd, r->rid, repinfo[repind].kind);
516 # else 517 # else
517 len = hid_report_size(rd, repinfo[repind].kind, r->rid); 518 len = hid_report_size(rd, repinfo[repind].kind, r->rid);