Splitting platform-specific code out of "fgJoystickClose" function

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1017 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
fayjf 2012-01-29 03:38:11 +00:00
parent 1c8c92fa89
commit 310d40d945
2 changed files with 84 additions and 35 deletions

View File

@ -455,6 +455,9 @@ static void fghJoystickAddHatElement ( SFG_Joystick* joy, CFDictionaryRef hat );
#endif #endif
/* External function declarations (mostly platform-specific) */
extern void fgPlatformJoystickClose ( int ident );
/* /*
* The static joystick structure pointer * 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 ) void fgJoystickClose( void )
{ {
int ident ; int ident ;
@ -1626,41 +1671,7 @@ void fgJoystickClose( void )
{ {
if( fgJoystick[ ident ] ) if( fgJoystick[ ident ] )
{ {
fgPlatformJoystickClose ( 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
free( fgJoystick[ ident ] ); free( fgJoystick[ ident ] );
fgJoystick[ ident ] = NULL; fgJoystick[ ident ] = NULL;

View File

@ -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, <fayjf@sourceforge.net>
* 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 <GL/freeglut.h>
#include "../Common/freeglut_internal.h"
#if !defined(_WIN32_WCE)
void fgPlatformJoystickClose ( int ident )
{
/* Do nothing special */
}
#endif