Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
API changes on OpenBSD and FreeBSD...
  • Loading branch information
slouken committed Jun 12, 2002
1 parent 8f8bb09 commit 0e016ad
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
27 changes: 27 additions & 0 deletions configure.in
Expand Up @@ -1614,6 +1614,33 @@ CheckUSBHID()
CFLAGS="$CFLAGS -DUSBHID_UCR_DATA"
fi
AC_MSG_RESULT($have_usbhid_ucr_data)

AC_MSG_CHECKING(for new usbhid API)
have_usbhid_new=no
AC_TRY_COMPILE([
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
],[
report_desc_t d;
hid_start_parse(d, 1, 1);
],[
have_usbhid_new=yes
])
if test x$have_usbhid_new = xyes; then
CFLAGS="$CFLAGS -DUSBHID_NEW"
fi
AC_MSG_RESULT($have_usbhid_new)

JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS bsd"
JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS bsd/libjoystick_bsd.la"
Expand Down
14 changes: 13 additions & 1 deletion src/joystick/bsd/SDL_sysjoystick.c
Expand Up @@ -29,7 +29,7 @@

#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id $";
"@(#) $Id$";
#endif

#include <stdio.h>
Expand Down Expand Up @@ -210,7 +210,11 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy)
goto usberr;
}

#ifdef USBHID_NEW
hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid);
#else
hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
#endif
if (hdata == NULL) {
SDL_SetError("%s: Cannot start HID parser", hw->path);
goto usberr;
Expand Down Expand Up @@ -296,7 +300,11 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joy)
if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
return;
}
#ifdef USBHID_NEW
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
#else
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
#endif
if (hdata == NULL) {
fprintf(stderr, "%s: Cannot start HID parser\n",
joy->hwdata->path);
Expand Down Expand Up @@ -400,7 +408,11 @@ report_alloc(struct report *r, struct report_desc *rd, int repind)
{
int len;

#ifdef USBHID_NEW
len = hid_report_size(rd, repinfo[repind].kind, r->rid);
#else
len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
#endif
if (len < 0) {
SDL_SetError("Negative HID report size");
return (-1);
Expand Down

0 comments on commit 0e016ad

Please sign in to comment.