Fix build on NetBSD.

(cherry picked from commit 1236c76445)

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1835 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2017-07-31 20:49:26 +00:00
parent 72e830f256
commit 5bcf802a95
2 changed files with 61 additions and 59 deletions

View File

@ -40,65 +40,6 @@
#define JS_TRUE 1 #define JS_TRUE 1
#define JS_FALSE 0 #define JS_FALSE 0
/* BSD defines from "jsBSD.cxx" around lines 42-270 */
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# ifdef HAVE_USB_JS
# if defined(__NetBSD__)
# ifdef HAVE_USBHID_H
# include <usbhid.h>
# else
# include <usb.h>
# endif
# include <dev/usb/usb.h>
# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# ifdef HAVE_USBHID_H
# include <usbhid.h>
# else
# include <libusbhid.h>
# endif
# include <legacy/dev/usb/usb.h>
# endif
# include <dev/usb/usbhid.h>
/* Compatibility with older usb.h revisions */
# if !defined(USB_MAX_DEVNAMES) && defined(MAXDEVNAMES)
# define USB_MAX_DEVNAMES MAXDEVNAMES
# endif
# endif
struct os_specific_s {
char fname [128 ];
int fd;
int is_analog;
/* The following structure members are specific to analog joysticks */
struct joystick ajs;
# ifdef HAVE_USB_JS
/* The following structure members are specific to USB joysticks */
struct hid_item *hids;
int hid_dlen;
int hid_offset;
char *hid_data_buf;
int axes_usage [ _JS_MAX_AXES ];
# endif
/* We keep button and axes state ourselves, as they might not be updated
* on every read of a USB device
*/
int cache_buttons;
float cache_axes [ _JS_MAX_AXES ];
};
/* Idents lower than USB_IDENT_OFFSET are for analog joysticks. */
# define USB_IDENT_OFFSET 2
# define USBDEV "/dev/usb"
# define UHIDDEV "/dev/uhid"
# define AJSDEV "/dev/joy"
#endif
/* /*
* Functions associated with the "jsJoystick" class in PLIB * Functions associated with the "jsJoystick" class in PLIB
*/ */

View File

@ -42,8 +42,68 @@
#include <fcntl.h> #include <fcntl.h>
/* BSD defines from "jsBSD.cxx" around lines 42-270 */
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# ifdef HAVE_USB_JS
# if defined(__NetBSD__)
# ifdef HAVE_USBHID_H
# include <usbhid.h>
# else
# include <usb.h>
# endif
# include <dev/usb/usb.h>
# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# ifdef HAVE_USBHID_H
# include <usbhid.h>
# else
# include <libusbhid.h>
# endif
# include <legacy/dev/usb/usb.h>
# endif
# include <dev/usb/usbhid.h>
/* Compatibility with older usb.h revisions */
# if !defined(USB_MAX_DEVNAMES) && defined(MAXDEVNAMES)
# define USB_MAX_DEVNAMES MAXDEVNAMES
# endif
# endif
struct os_specific_s {
char fname [128 ];
int fd;
int is_analog;
/* The following structure members are specific to analog joysticks */
struct joystick ajs;
# ifdef HAVE_USB_JS
/* The following structure members are specific to USB joysticks */
struct hid_item *hids;
int hid_dlen;
int hid_offset;
char *hid_data_buf;
int axes_usage [ _JS_MAX_AXES ];
# endif
/* We keep button and axes state ourselves, as they might not be updated
* on every read of a USB device
*/
int cache_buttons;
float cache_axes [ _JS_MAX_AXES ];
};
/* Idents lower than USB_IDENT_OFFSET are for analog joysticks. */
# define USB_IDENT_OFFSET 2
# define USBDEV "/dev/usb"
# define UHIDDEV "/dev/uhid"
# define AJSDEV "/dev/joy"
#endif
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
static int hatmap_x[9] = {0, 0, 1, 1, 1, 0, -1, -1, -1}; static int hatmap_x[9] = {0, 0, 1, 1, 1, 0, -1, -1, -1};
static int hatmap_y[9] = {0, 1, 1, 0, -1, -1, -1, 0, 1}; static int hatmap_y[9] = {0, 1, 1, 0, -1, -1, -1, 0, 1};
@ -104,6 +164,7 @@ static int fghJoystickFindUSBdev(char *name, char *out, int outlen)
} }
return 0; return 0;
} }
#endif
static int fghJoystickInitializeHID(struct os_specific_s *os, static int fghJoystickInitializeHID(struct os_specific_s *os,
int *num_axes, int *num_buttons) int *num_axes, int *num_buttons)