X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_input_devices.c;h=0e3dc8d1ab900733bb66db3d7ebcecb96cbaed6b;hb=fc6f0b39d73b3d9f6ee900f23015fac4f692c644;hp=d1a35ede607b74d22017e381eb9d1133a61de7f8;hpb=db377b3dff92f125c441c5b6004d21bb22b4f56e;p=freeglut diff --git a/src/freeglut_input_devices.c b/src/freeglut_input_devices.c index d1a35ed..0e3dc8d 100755 --- a/src/freeglut_input_devices.c +++ b/src/freeglut_input_devices.c @@ -35,7 +35,7 @@ #include #include "freeglut_internal.h" -#if TARGET_HOST_UNIX_X11 +#if TARGET_HOST_POSIX_X11 #include #include #include @@ -53,7 +53,7 @@ typedef struct { struct termios termio, termio_save; } SERIALPORT; -#elif TARGET_HOST_WIN32 +#elif TARGET_HOST_MS_WINDOWS #include #include typedef struct { @@ -136,11 +136,20 @@ int fgInputDeviceDetect( void ) */ void fgInitialiseInputDevices ( void ) { - const char *dial_device=NULL; if( !fgState.InputDevsInitialised ) { + /* will return true for VC8 (VC2005) and higher */ +#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) + char *dial_device=NULL; + size_t sLen; + errno_t err = _dupenv_s( &dial_device, &sLen, "GLUT_DIALS_SERIAL" ); + if (err) + fgError("Error getting GLUT_DIALS_SERIAL environment variable"); +#else + const char *dial_device=NULL; dial_device = getenv ( "GLUT_DIALS_SERIAL" ); -#if TARGET_HOST_WIN32 +#endif +#if TARGET_HOST_MS_WINDOWS if (!dial_device){ static char devname[256]; DWORD size=sizeof(devname); @@ -156,6 +165,10 @@ void fgInitialiseInputDevices ( void ) #endif if ( !dial_device ) return; if ( !( dialbox_port = serial_open ( dial_device ) ) ) return; + /* will return true for VC8 (VC2005) and higher */ +#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) + free ( dial_device ); dial_device = NULL; /* dupenv_s allocates a string that we must free */ +#endif serial_putchar(dialbox_port,DIAL_INITIALIZE); glutTimerFunc ( 10, poll_dials, 0 ); fgState.InputDevsInitialised = GL_TRUE; @@ -250,7 +263,7 @@ static void poll_dials ( int id ) /******** OS Specific Serial I/O routines *******/ -#if TARGET_HOST_UNIX_X11 /* ==> Linux/BSD/UNIX POSIX serial I/O */ +#if TARGET_HOST_POSIX_X11 /* ==> Linux/BSD/UNIX POSIX serial I/O */ static SERIALPORT *serial_open ( const char *device ) { int fd; @@ -271,14 +284,6 @@ static SERIALPORT *serial_open ( const char *device ) tcgetattr(fd,&port->termio_save); memset(&termio, 0, sizeof(termio)); - - /* Same as "cfmakeraw(&termio)", but Solaris doesn't have this call */ - termio.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON ); - termio.c_oflag &= ~OPOST; - termio.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); - termio.c_cflag &= ~( CSIZE | PARENB ); - termio.c_cflag |= CS8; - termio.c_cflag = CS8 | CREAD | HUPCL ; termio.c_iflag = IGNPAR | IGNBRK ; termio.c_cc[VTIME] = 0; /* inter-character timer */ @@ -321,7 +326,7 @@ static void serial_flush ( SERIALPORT *port ) tcflush ( port->fd, TCIOFLUSH ); } -#elif TARGET_HOST_WIN32 +#elif TARGET_HOST_MS_WINDOWS static SERIALPORT *serial_open(const char *device){ HANDLE fh;