X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_init.c;h=a8a59d4784c751c4b035e3869c7802cf5399db37;hb=e9a96a71a2feff9da7ccae395c5f316e67af3bd0;hp=9cc6a722b9449f179d0d862d22030e3b0777922d;hpb=102d7dff8f914d2e32c099f1bc0db809ef780b5e;p=freeglut diff --git a/src/freeglut_init.c b/src/freeglut_init.c index 9cc6a72..a8a59d4 100644 --- a/src/freeglut_init.c +++ b/src/freeglut_init.c @@ -60,8 +60,8 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */ GL_FALSE, /* UseCurrentContext */ GL_FALSE, /* GLDebugSwitch */ GL_FALSE, /* XSyncSwitch */ - GL_TRUE, /* KeyRepeat */ - 0xffffffff, /* Modifiers */ + GLUT_KEY_REPEAT_ON, /* KeyRepeat */ + INVALID_MODIFIERS, /* Modifiers */ 0, /* FPSInterval */ 0, /* SwapCount */ 0, /* SwapTime */ @@ -82,7 +82,8 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */ GLUT_ACTION_EXIT, /* ActionOnWindowClose */ GLUT_EXEC_STATE_INIT, /* ExecState */ NULL, /* ProgramName */ - GL_FALSE /* JoysticksInitialised */ + GL_FALSE, /* JoysticksInitialised */ + GL_FALSE /* InputDevsInitialised */ }; @@ -196,9 +197,15 @@ static void fghInitialize( const char* displayName ) ReleaseDC( desktop, context ); } + /* Set the timer granularity to 1 ms */ + timeBeginPeriod ( 1 ); + #endif fgState.Initialised = GL_TRUE; + + /* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */ + fgInitialiseInputDevices(); } /* @@ -239,8 +246,12 @@ void fgDeinitialize( void ) #if !TARGET_HOST_WINCE if ( fgState.JoysticksInitialised ) fgJoystickClose( ); + + if ( fgState.InputDevsInitialised ) + fgInputDeviceClose( ); #endif /* !TARGET_HOST_WINCE */ fgState.JoysticksInitialised = GL_FALSE; + fgState.InputDevsInitialised = GL_FALSE; fgState.Initialised = GL_FALSE; @@ -262,8 +273,8 @@ void fgDeinitialize( void ) fgState.ActionOnWindowClose = GLUT_ACTION_EXIT; fgState.ExecState = GLUT_EXEC_STATE_INIT; - fgState.KeyRepeat = GL_TRUE; - fgState.Modifiers = 0xffffffff; + fgState.KeyRepeat = GLUT_KEY_REPEAT_ON; + fgState.Modifiers = INVALID_MODIFIERS; fgState.GameModeSize.X = 640; fgState.GameModeSize.Y = 480; @@ -289,7 +300,6 @@ void fgDeinitialize( void ) fgState.ProgramName = NULL; } - #if TARGET_HOST_UNIX_X11 /* @@ -304,6 +314,11 @@ void fgDeinitialize( void ) */ XCloseDisplay( fgDisplay.Display ); +#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE + + /* Reset the timer granularity */ + timeEndPeriod ( 1 ); + #endif fgState.Initialised = GL_FALSE; @@ -678,7 +693,6 @@ void FGAPIENTRY glutInitDisplayMode( unsigned int displayMode ) /* -- INIT DISPLAY STRING PARSING ------------------------------------------ */ -#define NUM_TOKENS 36 static char* Tokens[] = { "alpha", "acca", "acc", "blue", "buffer", "conformant", "depth", "double", @@ -689,6 +703,7 @@ static char* Tokens[] = "xstaticgrey", "xgreyscale", "xstaticcolour", "xpseudocolour", "xtruecolour", "xdirectcolour", "borderless", "aux" }; +#define NUM_TOKENS (sizeof(Tokens) / sizeof(*Tokens)) void FGAPIENTRY glutInitDisplayString( const char* displayMode ) {