From e511ea0b35c08dd69bf1d8b898b68187c6fdd2ee Mon Sep 17 00:00:00 2001 From: "John F. Fay" Date: Sun, 29 Jan 2012 03:42:57 +0000 Subject: [PATCH] Moving the platform-specific code (non-Windows) farther up in the freeglut_joystick.c file git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1018 7f0cb862-5218-0410-a997-914c9d46530a --- src/Common/freeglut_joystick.c | 89 ++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/src/Common/freeglut_joystick.c b/src/Common/freeglut_joystick.c index 416091f..bf5bf95 100644 --- a/src/Common/freeglut_joystick.c +++ b/src/Common/freeglut_joystick.c @@ -464,6 +464,51 @@ extern void fgPlatformJoystickClose ( int ident ); #define MAX_NUM_JOYSTICKS 2 static SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ]; +/* + * Platform-Specific Code + */ + +#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 + + /* * Read the raw joystick data @@ -1619,50 +1664,6 @@ 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 ) { -- 1.7.10.4