X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_input_devices.c;h=0e3dc8d1ab900733bb66db3d7ebcecb96cbaed6b;hb=7f1fdd0379f174a74b4b61f0dbcdf2b39e7e9d97;hp=1734a424c6a130e65ed5a96f23692196c42525e4;hpb=7fdce1253e14170b6cb933f13c1f2a1644c93793;p=freeglut diff --git a/src/freeglut_input_devices.c b/src/freeglut_input_devices.c index 1734a42..0e3dc8d 100755 --- a/src/freeglut_input_devices.c +++ b/src/freeglut_input_devices.c @@ -136,10 +136,19 @@ 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" ); +#endif #if TARGET_HOST_MS_WINDOWS if (!dial_device){ static char devname[256]; @@ -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;