X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffg_input_devices.c;h=d4869d15851012cf41722e3015c4b01e8b8b1d58;hb=0c5339dad42bcdda8cc4c86b16194f7267578cd2;hp=8cac504c76af390e9123495d7ea478ffdf5a161b;hpb=1b5ee849ba61b667aeba474a7e03406196478bee;p=freeglut diff --git a/src/fg_input_devices.c b/src/fg_input_devices.c index 8cac504..d4869d1 100644 --- a/src/fg_input_devices.c +++ b/src/fg_input_devices.c @@ -1,5 +1,5 @@ /* - * freeglut_input_devices.c + * fg_input_devices.c * * Handles miscellaneous input devices via direct serial-port access. * Proper X11 XInput device support is not yet supported. @@ -28,10 +28,6 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include "fg_internal.h" @@ -75,11 +71,11 @@ typedef struct _serialport SERIALPORT; /*****************************************************************/ -extern SERIALPORT *serial_open ( const char *device ); -extern void serial_close ( SERIALPORT *port ); -extern int serial_getchar ( SERIALPORT *port ); -extern int serial_putchar ( SERIALPORT *port, unsigned char ch ); -extern void serial_flush ( SERIALPORT *port ); +extern SERIALPORT *fg_serial_open ( const char *device ); +extern void fg_serial_close ( SERIALPORT *port ); +extern int fg_serial_getchar ( SERIALPORT *port ); +extern int fg_serial_putchar ( SERIALPORT *port, unsigned char ch ); +extern void fg_serial_flush ( SERIALPORT *port ); extern void fgPlatformRegisterDialDevice ( const char *dial_device ); static void send_dial_event(int dial, int value); @@ -115,11 +111,11 @@ void fgInitialiseInputDevices ( void ) { const char *dial_device=NULL; dial_device = getenv ( "GLUT_DIALS_SERIAL" ); - fgPlatformRegisterDialDevice ( dial_device ); + fgPlatformRegisterDialDevice ( dial_device ); if ( !dial_device ) return; - if ( !( dialbox_port = serial_open ( dial_device ) ) ) return; - serial_putchar(dialbox_port,DIAL_INITIALIZE); + if ( !( dialbox_port = fg_serial_open ( dial_device ) ) ) return; + fg_serial_putchar(dialbox_port,DIAL_INITIALIZE); glutTimerFunc ( 10, poll_dials, 0 ); fgState.InputDevsInitialised = GL_TRUE; } @@ -132,7 +128,7 @@ void fgInputDeviceClose( void ) { if ( fgState.InputDevsInitialised ) { - serial_close ( dialbox_port ); + fg_serial_close ( dialbox_port ); dialbox_port = NULL; fgState.InputDevsInitialised = GL_FALSE; } @@ -166,11 +162,10 @@ static void poll_dials ( int id ) static int dial_state = DIAL_NEW; static int dial_which; static int dial_value; - static int dials[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; if ( !dialbox_port ) return; - while ( (data=serial_getchar(dialbox_port)) != EOF ) + while ( (data=fg_serial_getchar(dialbox_port)) != EOF ) { if ( ( dial_state > DIAL_WHICH_DEVICE ) || IS_DIAL_EVENT ( data ) ) { @@ -187,7 +182,6 @@ static void poll_dials ( int id ) case DIAL_VALUE_LOW: dial_value |= data; if ( dial_value & 0x8000 ) dial_value -= 0x10000; - dials[dial_which] = dial_value; send_dial_event ( dial_which + 1, dial_value * 360 / 256 ); dial_state = DIAL_WHICH_DEVICE; break; @@ -200,12 +194,12 @@ static void poll_dials ( int id ) { fgState.InputDevsInitialised = GL_TRUE; dial_state = DIAL_WHICH_DEVICE; - serial_putchar(dialbox_port,DIAL_SET_AUTO_DIALS); - serial_putchar(dialbox_port,0xff); - serial_putchar(dialbox_port,0xff); + fg_serial_putchar(dialbox_port,DIAL_SET_AUTO_DIALS); + fg_serial_putchar(dialbox_port,0xff); + fg_serial_putchar(dialbox_port,0xff); } else /* Unknown data; try flushing. */ - serial_flush(dialbox_port); + fg_serial_flush(dialbox_port); } glutTimerFunc ( 2, poll_dials, 0 );