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 ),
int pollInterval )
{
if( !fgState.JoysticksInitialised )
{
fgJoystickInit( 0 );
fgJoystickInit( 1 );
fgState.JoysticksInitialised = GL_TRUE;
}
SET_CALLBACK( Joystick );
fgStructure.Window->State.JoystickPollRate = pollInterval;

View 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 */
};
@ -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
if ( fgState.JoysticksInitialised )
fgJoystickClose( );
#endif /* !TARGET_HOST_WINCE */
fgState.JoysticksInitialised = GL_FALSE;
fgState.Initialised = GL_FALSE;

View File

@ -167,7 +167,7 @@ struct tagSFG_XYUse
typedef struct tagSFG_Time SFG_Time;
struct tagSFG_Time
{
#ifdef WIN32
#if TARGET_HOST_WIN32 || TARGET_HOST_WINCE
DWORD Value;
#else
struct timeval Value;
@ -229,6 +229,7 @@ struct tagSFG_State
fgExecutionState ExecState; /* Used for GLUT termination */
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 */

View File

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