some function renaming, etc (John Fay)
[freeglut] / src / freeglut_init.c
index 33a80f8..0853d35 100644 (file)
@@ -85,7 +85,8 @@ SFG_State fgState = { { -1, -1, GL_FALSE },  /* Position */
                       72,                     /* GameModeRefresh */
                       GLUT_ACTION_EXIT,       /* ActionOnWindowClose */
                       GLUT_EXEC_STATE_INIT,   /* ExecState */
-                      NULL                    /* ProgramName */
+                      NULL,                   /* ProgramName */
+                      GL_FALSE                /* JoysticksInitialised */
 };
 
 
@@ -94,7 +95,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE },  /* Position */
 /*
  * A call to this function should initialize all the display stuff...
  */
-void fgInitialize( const char* displayName )
+static void fghInitialize( const char* displayName )
 {
 #if TARGET_HOST_UNIX_X11
     fgDisplay.Display = XOpenDisplay( displayName );
@@ -201,11 +202,6 @@ void fgInitialize( const char* displayName )
 
 #endif
 
-#if !TARGET_HOST_WINCE
-    fgJoystickInit( 0 );
-    fgJoystickInit( 1 );
-#endif /* !TARGET_HOST_WINCE */
-
     fgState.Initialised = GL_TRUE;
 }
 
@@ -247,8 +243,10 @@ void fgDeinitialize( void )
     }
 
 #if !TARGET_HOST_WINCE
-    fgJoystickClose( );
+    if ( fgState.JoysticksInitialised )
+        fgJoystickClose( );
 #endif /* !TARGET_HOST_WINCE */
+    fgState.JoysticksInitialised = GL_FALSE;
 
     fgState.Initialised = GL_FALSE;
 
@@ -618,7 +616,7 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
      * in the program arguments, we will use the DISPLAY environment
      * variable for opening the X display (see code above):
      */
-    fgInitialize( displayName );
+    fghInitialize( displayName );
 
     /*
      * Geometry parsing deffered until here because we may need the screen