X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffreeglut_joystick.c;h=3de906b4817cd7c0f12e5334ab2ec90ff5ea429f;hb=3b06156b86b860856303b3673e7aa09cc7624d4a;hp=a6622becfac119d8a1ee20e20ed20dd815a6f48a;hpb=eb076bbad64abd3c75b86d0b093ed244cd239a2e;p=freeglut diff --git a/src/freeglut_joystick.c b/src/freeglut_joystick.c index a6622be..3de906b 100644 --- a/src/freeglut_joystick.c +++ b/src/freeglut_joystick.c @@ -73,18 +73,23 @@ #if TARGET_HOST_UNIX_X11 # define _JS_MAX_AXES 16 # if defined(__FreeBSD__) || defined(__NetBSD__) -/* XXX The next line is an unjustified hack which needs to be changed by someone who - * XXX is familiar with *nix, BSD, and USB joysticks. +/* + * XXX The below hack is done until freeglut's autoconf is updated. */ # define HAVE_USB_JS 1 # include -# include /* For analog joysticks */ - -# if __FreeBSD_version >= 500000 +# if defined(__FreeBSD__) && __FreeBSD_version >= 500000 # include # else -# include +/* + * XXX NetBSD/amd64 systems may find that they have to steal the + * XXX /usr/include/machine/joystick.h from a NetBSD/i386 system. + * XXX I cannot comment whether that works for the interface, but + * XXX it lets you compile...(^& I do not think that we can do away + * XXX with this header. + */ +# include /* For analog joysticks */ # endif # define JS_DATA_TYPE joystick # define JS_RETURN (sizeof(struct JS_DATA_TYPE)) @@ -137,7 +142,7 @@ # ifdef HAVE_USB_JS # if defined(__NetBSD__) /* - * XXX Apparently another ugly hack which someone who knows BSD and USBHID needs to solve + * XXX The below hack is done until freeglut's autoconf is updated. */ # define HAVE_USBHID_H 1 # ifdef HAVE_USBHID_H @@ -146,7 +151,15 @@ # include # endif # elif defined(__FreeBSD__) -# include +# if __FreeBSD_version < 500000 +# include +# else +/* + * XXX The below hack is done until freeglut's autoconf is updated. + */ +# define HAVE_USBHID_H 1 +# include +# endif # endif # include # include @@ -397,7 +410,7 @@ struct tagSFG_Joystick # endif # ifdef JS_NEW - struct js_event js ; + struct js_event js; int tmp_buttons; float tmp_axes [ _JS_MAX_AXES ]; # else @@ -846,7 +859,7 @@ static int fghJoystickFindDevices ( SFG_Joystick *joy, mach_port_t masterPort ) rv = IOServiceGetMatchingServices(masterPort, hidMatch, &hidIterator); if (rv != kIOReturnSuccess || !hidIterator) { - fgWarning ( "%s", "no joystick (HID) devices found"); + fgWarning( "%s", "no joystick (HID) devices found" ); return; } @@ -1038,6 +1051,9 @@ static void fghJoystickAddHatElement ( SFG_Joystick *joy, CFDictionaryRef button /* Inspired by http://msdn.microsoft.com/archive/en-us/dnargame/html/msdn_sidewind3d.asp */ +# if defined(_MSC_VER) +# pragma comment (lib, "advapi32.lib") +# endif static int fghJoystickGetOEMProductName ( SFG_Joystick* joy, char *buf, int buf_sz ) { @@ -1565,7 +1581,7 @@ void fgJoystickInit( int ident ) ref = CFDictionaryGetValue (properties, CFSTR("USB Product Name")); if (!ref || !CFStringGetCString ((CFStringRef) ref, name, 128, CFStringGetSystemEncoding ())) { - fgWarning ( "%s", "error getting device name"); + fgWarning( "%s", "error getting device name" ); name[0] = '\0'; } #endif @@ -1700,33 +1716,33 @@ void fgJoystickPollWindow( SFG_Window* window ) * PWO: These jsJoystick class methods have not been implemented. * We might consider adding such functions to freeglut-2.0. */ -int getNumAxes ( int ident ) +int glutJoystickGetNumAxes ( int ident ) { return fgJoystick[ident]->num_axes; } -int notWorking ( int ident ) +int glutJoystickNotWorking ( int ident ) { return fgJoystick[ident]->error; } -float getDeadBand ( int ident, int axis ) +float glutJoystickGetDeadBand ( int ident, int axis ) { return fgJoystick[ident]->dead_band [ axis ]; } -void setDeadBand ( int ident, int axis, float db ) +void glutJoystickSetDeadBand ( int ident, int axis, float db ) { fgJoystick[ident]->dead_band [ axis ] = db; } -float getSaturation ( int ident, int axis ) +float glutJoystickGetSaturation ( int ident, int axis ) { return fgJoystick[ident]->saturate [ axis ]; } -void setSaturation ( int ident, int axis, float st ) +void glutJoystickSetSaturation ( int ident, int axis, float st ) { fgJoystick[ident]->saturate [ axis ] = st; } -void setMinRange ( int ident, float *axes ) +void glutJoystickSetMinRange ( int ident, float *axes ) { memcpy ( fgJoystick[ident]->min , axes, fgJoystick[ident]->num_axes * sizeof(float) ); } -void setMaxRange ( int ident, float *axes ) +void glutJoystickSetMaxRange ( int ident, float *axes ) { memcpy ( fgJoystick[ident]->max , axes, fgJoystick[ident]->num_axes * sizeof(float) ); } -void setCenter ( int ident, float *axes ) +void glutJoystickSetCenter ( int ident, float *axes ) { memcpy ( fgJoystick[ident]->center, axes, fgJoystick[ident]->num_axes * sizeof(float) ); } -void getMinRange ( int ident, float *axes ) +void glutJoystickGetMinRange ( int ident, float *axes ) { memcpy ( axes, fgJoystick[ident]->min , fgJoystick[ident]->num_axes * sizeof(float) ); } -void getMaxRange ( int ident, float *axes ) +void glutJoystickGetMaxRange ( int ident, float *axes ) { memcpy ( axes, fgJoystick[ident]->max , fgJoystick[ident]->num_axes * sizeof(float) ); } -void getCenter ( int ident, float *axes ) +void glutJoystickGetCenter ( int ident, float *axes ) { memcpy ( axes, fgJoystick[ident]->center, fgJoystick[ident]->num_axes * sizeof(float) ); } /*** END OF FILE ***/