From: John F. Fay Date: Sun, 29 Jan 2012 03:38:11 +0000 (+0000) Subject: Splitting platform-specific code out of "fgJoystickClose" function X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=38011fb92295a6a40a003b3d1fabcd565694cfb1;p=freeglut Splitting platform-specific code out of "fgJoystickClose" function git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1017 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/Common/freeglut_joystick.c b/src/Common/freeglut_joystick.c index 17eeb00..416091f 100644 --- a/src/Common/freeglut_joystick.c +++ b/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,49 +1622,57 @@ void fgInitialiseJoysticks ( void ) /* * */ -void fgJoystickClose( void ) -{ - int ident ; - for( ident = 0; ident < MAX_NUM_JOYSTICKS; ident++ ) - { - if( fgJoystick[ ident ] ) - { #if TARGET_HOST_MACINTOSH - ISpSuspend( ); - ISpStop( ); - ISpShutdown( ); +void fgPlatformJoystickClose ( int ident ) +{ + 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 */ +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 ); + 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 ); + 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 ); - } + free( fgJoystick[ident]->os ); + } #endif - if( ! fgJoystick[ident]->error ) - close( fgJoystick[ ident ]->fd ); + if( ! fgJoystick[ident]->error ) + close( fgJoystick[ ident ]->fd ); +} #endif + +void fgJoystickClose( void ) +{ + int ident ; + for( ident = 0; ident < MAX_NUM_JOYSTICKS; ident++ ) + { + if( fgJoystick[ ident ] ) + { + fgPlatformJoystickClose ( ident ); + free( fgJoystick[ ident ] ); fgJoystick[ ident ] = NULL; /* show joystick has been deinitialized */ diff --git a/src/mswin/freeglut_joystick_mswin.c b/src/mswin/freeglut_joystick_mswin.c index e69de29..2aad217 100644 --- a/src/mswin/freeglut_joystick_mswin.c +++ b/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 +