joystick updates from John Fay

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@513 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
brianp 2004-09-10 15:51:10 +00:00
parent 5bd18d1bcd
commit 413bd1e861
4 changed files with 31 additions and 22 deletions

View File

@ -171,6 +171,13 @@ void FGAPIENTRY glutJoystickFunc( void (* callback)
( unsigned int, int, int, int ), ( unsigned int, int, int, int ),
int pollInterval ) int pollInterval )
{ {
if( !fgState.JoysticksInitialised )
{
fgJoystickInit( 0 );
fgJoystickInit( 1 );
fgState.JoysticksInitialised = GL_TRUE;
}
SET_CALLBACK( Joystick ); SET_CALLBACK( Joystick );
fgStructure.Window->State.JoystickPollRate = pollInterval; fgStructure.Window->State.JoystickPollRate = pollInterval;

View File

@ -85,7 +85,8 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
72, /* GameModeRefresh */ 72, /* GameModeRefresh */
GLUT_ACTION_EXIT, /* ActionOnWindowClose */ GLUT_ACTION_EXIT, /* ActionOnWindowClose */
GLUT_EXEC_STATE_INIT, /* ExecState */ GLUT_EXEC_STATE_INIT, /* ExecState */
NULL /* ProgramName */ NULL, /* ProgramName */
GL_FALSE /* JoysticksInitialised */
}; };
@ -201,11 +202,6 @@ void fgInitialize( const char* displayName )
#endif #endif
#if !TARGET_HOST_WINCE
fgJoystickInit( 0 );
fgJoystickInit( 1 );
#endif /* !TARGET_HOST_WINCE */
fgState.Initialised = GL_TRUE; fgState.Initialised = GL_TRUE;
} }
@ -247,8 +243,10 @@ void fgDeinitialize( void )
} }
#if !TARGET_HOST_WINCE #if !TARGET_HOST_WINCE
if ( fgState.JoysticksInitialised )
fgJoystickClose( ); fgJoystickClose( );
#endif /* !TARGET_HOST_WINCE */ #endif /* !TARGET_HOST_WINCE */
fgState.JoysticksInitialised = GL_FALSE;
fgState.Initialised = GL_FALSE; fgState.Initialised = GL_FALSE;

View File

@ -167,7 +167,7 @@ struct tagSFG_XYUse
typedef struct tagSFG_Time SFG_Time; typedef struct tagSFG_Time SFG_Time;
struct tagSFG_Time struct tagSFG_Time
{ {
#ifdef WIN32 #if TARGET_HOST_WIN32 || TARGET_HOST_WINCE
DWORD Value; DWORD Value;
#else #else
struct timeval Value; struct timeval Value;
@ -229,6 +229,7 @@ struct tagSFG_State
fgExecutionState ExecState; /* Used for GLUT termination */ fgExecutionState ExecState; /* Used for GLUT termination */
char *ProgramName; /* Name of the invoking program */ char *ProgramName; /* Name of the invoking program */
GLboolean JoysticksInitialised; /* Only initialize if application calls for them */
}; };
/* The structure used by display initialization in freeglut_init.c */ /* The structure used by display initialization in freeglut_init.c */

View File

@ -103,7 +103,8 @@ static void fghReshapeWindowByHandle ( SFG_WindowHandleType handle,
#if !TARGET_HOST_WINCE #if !TARGET_HOST_WINCE
{ {
RECT rect; RECT winRect;
int x, y, w, h;
/* /*
* For windowed mode, get the current position of the * For windowed mode, get the current position of the
@ -111,24 +112,29 @@ static void fghReshapeWindowByHandle ( SFG_WindowHandleType handle,
* decorations into account. * decorations into account.
*/ */
GetWindowRect( window->Window.Handle, &rect ); /* "GetWindowRect" returns the pixel coordinates of the outside of the window */
rect.right = rect.left + width; GetWindowRect( window->Window.Handle, &winRect );
rect.bottom = rect.top + height; x = winRect.left;
y = winRect.top;
w = width;
h = height;
if ( window->Parent == NULL ) if ( window->Parent == NULL )
{ {
if ( ! window->IsMenu && !window->State.IsGameMode ) if ( ! window->IsMenu && !window->State.IsGameMode )
{ {
rect.right += GetSystemMetrics( SM_CXSIZEFRAME ) * 2; w += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
rect.bottom += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + h += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
GetSystemMetrics( SM_CYCAPTION ); GetSystemMetrics( SM_CYCAPTION );
} }
} }
else else
{ {
GetWindowRect( window->Parent->Window.Handle, &rect ); RECT parentRect;
AdjustWindowRect ( &rect, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | GetWindowRect( window->Parent->Window.Handle, &parentRect );
WS_CLIPCHILDREN, FALSE ); x -= parentRect.left + GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
y -= parentRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) * 2 +
GetSystemMetrics( SM_CYCAPTION );
} }
/* /*
@ -140,10 +146,7 @@ static void fghReshapeWindowByHandle ( SFG_WindowHandleType handle,
SetWindowPos( window->Window.Handle, SetWindowPos( window->Window.Handle,
HWND_TOP, HWND_TOP,
rect.left, x, y, w, h,
rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
SWP_NOZORDER SWP_NOZORDER
); );