Joe Krahn\'s input (dials) device implementation.

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@636 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
fayjf 2005-06-22 21:37:26 +00:00
parent 2ded92b062
commit a84f4042f0
5 changed files with 45 additions and 24 deletions

View File

@ -27,6 +27,7 @@ lib@LIBRARY@_la_SOURCES = freeglut_callbacks.c \
freeglut_gamemode.c \
freeglut_geometry.c \
freeglut_init.c \
freeglut_input_devices.c \
freeglut_joystick.c \
freeglut_main.c \
freeglut_menu.c \

View File

@ -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 */
};
@ -202,6 +203,9 @@ static void fghInitialize( const char* displayName )
#endif
fgState.Initialised = GL_TRUE;
/* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
fgInitialiseInputDevices();
}
/*
@ -242,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;

View File

@ -244,6 +244,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 */
GLboolean InputDevsInitialised; /* Only initialize if application calls for them */
};
/* The structure used by display initialization in freeglut_init.c */
@ -772,6 +773,11 @@ int glutJoystickGetNumAxes( int ident );
int glutJoystickGetNumButtons( int ident );
int glutJoystickNotWorking( int ident );
/* InputDevice Init/Fini */
int fgInputDeviceDetect( void );
void fgInitialiseInputDevices( void );
void fgInputDeviceClose( void );
/* Setting the cursor for a given window */
void fgSetCursor ( SFG_Window *window, int cursorID );

View File

@ -1581,7 +1581,6 @@ static void fghJoystickInit( int ident )
*/
void fgInitialiseJoysticks ( void )
{
/* Initialization courtesy of OpenGLUT -- do we want it? */
if( !fgState.JoysticksInitialised )
{
int ident ;

View File

@ -540,14 +540,21 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
case GLUT_JOYSTICK_AXES:
return glutJoystickGetNumAxes ( 0 );
case GLUT_HAS_SPACEBALL:
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
return fgInputDeviceDetect ();
case GLUT_NUM_DIALS:
if ( fgState.InputDevsInitialised ) return 8;
return 0;
case GLUT_NUM_BUTTON_BOX_BUTTONS:
return 0;
case GLUT_HAS_SPACEBALL:
case GLUT_HAS_TABLET:
return FALSE;
case GLUT_NUM_SPACEBALL_BUTTONS:
case GLUT_NUM_BUTTON_BOX_BUTTONS:
case GLUT_NUM_DIALS:
case GLUT_NUM_TABLET_BUTTONS:
return 0;