API changes on OpenBSD and FreeBSD...
authorSam Lantinga <slouken@libsdl.org>
Wed, 12 Jun 2002 03:32:01 +0000
changeset 407173909e17b7f
parent 406 9916da315b0d
child 408 b2c97d579dfe
API changes on OpenBSD and FreeBSD...
configure.in
src/joystick/bsd/SDL_sysjoystick.c
     1.1 --- a/configure.in	Wed Jun 12 03:30:58 2002 +0000
     1.2 +++ b/configure.in	Wed Jun 12 03:32:01 2002 +0000
     1.3 @@ -1614,6 +1614,33 @@
     1.4                  CFLAGS="$CFLAGS -DUSBHID_UCR_DATA"
     1.5              fi
     1.6              AC_MSG_RESULT($have_usbhid_ucr_data)
     1.7 +            
     1.8 +	    AC_MSG_CHECKING(for new usbhid API)
     1.9 +            have_usbhid_new=no
    1.10 +            AC_TRY_COMPILE([
    1.11 +              #include <sys/types.h>
    1.12 +              #if defined(HAVE_USB_H)
    1.13 +              #include <usb.h>
    1.14 +              #endif
    1.15 +              #include <dev/usb/usb.h>
    1.16 +              #include <dev/usb/usbhid.h>
    1.17 +              #if defined(HAVE_USBHID_H)
    1.18 +              #include <usbhid.h>
    1.19 +              #elif defined(HAVE_LIBUSB_H)
    1.20 +              #include <libusb.h>
    1.21 +              #elif defined(HAVE_LIBUSBHID_H)
    1.22 +              #include <libusbhid.h>
    1.23 +              #endif
    1.24 +            ],[
    1.25 +              report_desc_t d;
    1.26 +	      hid_start_parse(d, 1, 1);
    1.27 +            ],[
    1.28 +            have_usbhid_new=yes
    1.29 +            ])
    1.30 +            if test x$have_usbhid_new = xyes; then
    1.31 +                CFLAGS="$CFLAGS -DUSBHID_NEW"
    1.32 +            fi
    1.33 +            AC_MSG_RESULT($have_usbhid_new)
    1.34  
    1.35              JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS bsd"
    1.36              JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS bsd/libjoystick_bsd.la"
     2.1 --- a/src/joystick/bsd/SDL_sysjoystick.c	Wed Jun 12 03:30:58 2002 +0000
     2.2 +++ b/src/joystick/bsd/SDL_sysjoystick.c	Wed Jun 12 03:32:01 2002 +0000
     2.3 @@ -29,7 +29,7 @@
     2.4  
     2.5  #ifdef SAVE_RCSID
     2.6  static char rcsid =
     2.7 - "@(#) $Id $";
     2.8 + "@(#) $Id$";
     2.9  #endif
    2.10  
    2.11  #include <stdio.h>
    2.12 @@ -210,7 +210,11 @@
    2.13  		goto usberr;
    2.14  	}
    2.15  
    2.16 +#ifdef USBHID_NEW
    2.17 +	hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid);
    2.18 +#else
    2.19  	hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
    2.20 +#endif
    2.21  	if (hdata == NULL) {
    2.22  		SDL_SetError("%s: Cannot start HID parser", hw->path);
    2.23  		goto usberr;
    2.24 @@ -296,7 +300,11 @@
    2.25  	if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
    2.26  		return;
    2.27  	}
    2.28 +#ifdef USBHID_NEW
    2.29 +	hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
    2.30 +#else
    2.31  	hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
    2.32 +#endif
    2.33  	if (hdata == NULL) {
    2.34  		fprintf(stderr, "%s: Cannot start HID parser\n",
    2.35  		    joy->hwdata->path);
    2.36 @@ -400,7 +408,11 @@
    2.37  {
    2.38  	int len;
    2.39  
    2.40 +#ifdef USBHID_NEW
    2.41 +	len = hid_report_size(rd, repinfo[repind].kind, r->rid);
    2.42 +#else
    2.43  	len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
    2.44 +#endif
    2.45  	if (len < 0) {
    2.46  		SDL_SetError("Negative HID report size");
    2.47  		return (-1);