From 0f68653742ba534759ef6b49c5587e61f23dccc4 Mon Sep 17 00:00:00 2001 From: fayjf 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: https://svn.code.sf.net/p/freeglut/code/trunk@1018 7f0cb862-5218-0410-a997-914c9d46530a --- .../freeglut/src/Common/freeglut_joystick.c | 89 ++++++++++--------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/freeglut/freeglut/src/Common/freeglut_joystick.c b/freeglut/freeglut/src/Common/freeglut_joystick.c index 416091f..bf5bf95 100644 --- a/freeglut/freeglut/src/Common/freeglut_joystick.c +++ b/freeglut/freeglut/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 ) {