X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2FCommon%2Ffreeglut_input_devices.c;h=7cff5a0b8d59c58b3dff81d64bb6c13ea32698f8;hb=0cf70b776640b9fda4e620c7553ff8168be2b8e1;hp=bcc98fb4d85ebe500953c7c73abc22dded3cbcfb;hpb=e7a97e7b2dc1bb7ec0110c4b5b4bf24d3e5a1abc;p=freeglut diff --git a/src/Common/freeglut_input_devices.c b/src/Common/freeglut_input_devices.c index bcc98fb..7cff5a0 100644 --- a/src/Common/freeglut_input_devices.c +++ b/src/Common/freeglut_input_devices.c @@ -35,24 +35,6 @@ #include #include "freeglut_internal.h" -#if TARGET_HOST_POSIX_X11 -#ifdef HAVE_ERRNO_H -#include -#endif -#include -#include -#include -#include -#include -#include - -struct { - int fd; - struct termios termio, termio_save; -} _serialport; - -#endif - typedef struct _serialport SERIALPORT; @@ -99,7 +81,7 @@ extern int serial_getchar ( SERIALPORT *port ); extern int serial_putchar ( SERIALPORT *port, unsigned char ch ); extern void serial_flush ( SERIALPORT *port ); -extern void fghRegisterDialDevice ( const char *dial_device ); +extern void fgPlatformRegisterDialDevice ( const char *dial_device ); static void send_dial_event(int dial, int value); static void poll_dials(int id); @@ -127,19 +109,13 @@ int fgInputDeviceDetect( void ) /* * Try initializing the input device(s) */ -#if TARGET_HOST_POSIX_X11 -static void fghRegisterDialDevice ( const char *dial_device ) -{ -} -#endif - void fgInitialiseInputDevices ( void ) { if( !fgState.InputDevsInitialised ) { const char *dial_device=NULL; dial_device = getenv ( "GLUT_DIALS_SERIAL" ); - fghRegisterDialDevice ( dial_device ); + fgPlatformRegisterDialDevice ( dial_device ); if ( !dial_device ) return; if ( !( dialbox_port = serial_open ( dial_device ) ) ) return; @@ -235,69 +211,3 @@ static void poll_dials ( int id ) glutTimerFunc ( 2, poll_dials, 0 ); } - -/******** OS Specific Serial I/O routines *******/ -#if TARGET_HOST_POSIX_X11 /* ==> Linux/BSD/UNIX POSIX serial I/O */ -static SERIALPORT *serial_open ( const char *device ) -{ - int fd; - struct termios termio; - SERIALPORT *port; - - fd = open(device, O_RDWR | O_NONBLOCK ); - if (fd <0) { - perror(device); - return NULL; - } - - port = malloc(sizeof(SERIALPORT)); - memset(port, 0, sizeof(SERIALPORT)); - port->fd = fd; - - /* save current port settings */ - tcgetattr(fd,&port->termio_save); - - memset(&termio, 0, sizeof(termio)); - termio.c_cflag = CS8 | CREAD | HUPCL ; - termio.c_iflag = IGNPAR | IGNBRK ; - termio.c_cc[VTIME] = 0; /* inter-character timer */ - termio.c_cc[VMIN] = 1; /* block read until 1 chars received, when blocking I/O */ - - cfsetispeed(&termio, B9600); - cfsetospeed(&termio, B9600); - tcsetattr(fd,TCSANOW,&termio); - - serial_flush(port); - return port; -} - -static void serial_close(SERIALPORT *port) -{ - if (port) - { - /* restore old port settings */ - tcsetattr(port->fd,TCSANOW,&port->termio_save); - close(port->fd); - free(port); - } -} - -static int serial_getchar(SERIALPORT *port) -{ - unsigned char ch; - if (!port) return EOF; - if (read(port->fd,&ch,1)) return ch; - return EOF; -} - -static int serial_putchar(SERIALPORT *port, unsigned char ch){ - if (!port) return 0; - return write(port->fd,&ch,1); -} - -static void serial_flush ( SERIALPORT *port ) -{ - tcflush ( port->fd, TCIOFLUSH ); -} - -#endif