diff --git a/freeglut/freeglut/src/Common/freeglut_joystick.c b/freeglut/freeglut/src/Common/freeglut_joystick.c index 17eeb00..416091f 100644 --- a/freeglut/freeglut/src/Common/freeglut_joystick.c +++ b/freeglut/freeglut/src/Common/freeglut_joystick.c @@ -455,6 +455,9 @@ static void fghJoystickAddHatElement ( SFG_Joystick* joy, CFDictionaryRef hat ); #endif +/* External function declarations (mostly platform-specific) */ +extern void fgPlatformJoystickClose ( int ident ); + /* * The static joystick structure pointer */ @@ -1619,6 +1622,48 @@ void fgInitialiseJoysticks ( void ) /* * */ + +#if TARGET_HOST_MACINTOSH +void fgPlatformJoystickClose ( int ident ) +{ + ISpSuspend( ); + ISpStop( ); + ISpShutdown( ); +} +#endif + +#if TARGET_HOST_MAC_OSX +void fgPlatformJoystickClose ( int ident ) +{ + ( *( fgJoystick[ ident ]->hidDev ) )-> + close( fgJoystick[ ident ]->hidDev ); +} +#endif + +#if TARGET_HOST_POSIX_X11 +void fgPlatformJoystickClose ( int ident ) +{ +#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) + if( fgJoystick[ident]->os ) + { + if( ! fgJoystick[ ident ]->error ) + close( fgJoystick[ ident ]->os->fd ); +#ifdef HAVE_USB_JS + if( fgJoystick[ ident ]->os->hids ) + free (fgJoystick[ ident ]->os->hids); + if( fgJoystick[ ident ]->os->hid_data_buf ) + free( fgJoystick[ ident ]->os->hid_data_buf ); +#endif + free( fgJoystick[ident]->os ); + } +#endif + + if( ! fgJoystick[ident]->error ) + close( fgJoystick[ ident ]->fd ); +} +#endif + + void fgJoystickClose( void ) { int ident ; @@ -1626,41 +1671,7 @@ void fgJoystickClose( void ) { if( fgJoystick[ ident ] ) { - -#if TARGET_HOST_MACINTOSH - ISpSuspend( ); - ISpStop( ); - ISpShutdown( ); -#endif - -#if TARGET_HOST_MAC_OSX - ( *( fgJoystick[ ident ]->hidDev ) )-> - close( fgJoystick[ ident ]->hidDev ); -#endif - -#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) - /* Do nothing special */ -#endif - -#if TARGET_HOST_POSIX_X11 -#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) - if( fgJoystick[ident]->os ) - { - if( ! fgJoystick[ ident ]->error ) - close( fgJoystick[ ident ]->os->fd ); -#ifdef HAVE_USB_JS - if( fgJoystick[ ident ]->os->hids ) - free (fgJoystick[ ident ]->os->hids); - if( fgJoystick[ ident ]->os->hid_data_buf ) - free( fgJoystick[ ident ]->os->hid_data_buf ); -#endif - free( fgJoystick[ident]->os ); - } -#endif - - if( ! fgJoystick[ident]->error ) - close( fgJoystick[ ident ]->fd ); -#endif + fgPlatformJoystickClose ( ident ); free( fgJoystick[ ident ] ); fgJoystick[ ident ] = NULL; diff --git a/freeglut/freeglut/src/mswin/freeglut_joystick_mswin.c b/freeglut/freeglut/src/mswin/freeglut_joystick_mswin.c index e69de29..2aad217 100644 --- a/freeglut/freeglut/src/mswin/freeglut_joystick_mswin.c +++ b/freeglut/freeglut/src/mswin/freeglut_joystick_mswin.c @@ -0,0 +1,38 @@ +/* + * freeglut_joystick_mswin.c + * + * The Windows-specific mouse cursor related stuff. + * + * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. + * Written by John F. Fay, + * Creation date: Sat Jan 28, 2012 + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include "../Common/freeglut_internal.h" + + +#if !defined(_WIN32_WCE) +void fgPlatformJoystickClose ( int ident ) +{ + /* Do nothing special */ +} +#endif +