X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_input_devices.c;h=142ee4c7571ff3a300afc5cbf3c82ceb8b7e5695;hb=9d658d3079abac17672c300ee614ed4cf41a0553;hp=b5a9144ebe9a9f0095cacc2da43c642c43e16cbb;hpb=bce1c1e15a97d38b2b473a18d68f0f7cbd662b36;p=freeglut diff --git a/src/freeglut_input_devices.c b/src/freeglut_input_devices.c index b5a9144..142ee4c 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 { @@ -68,32 +68,32 @@ typedef struct { #define DIAL_NUM_VALUATORS 8 - /* dial parser state machine states */ -#define DIAL_NEW -1 +/* dial parser state machine states */ +#define DIAL_NEW (-1) #define DIAL_WHICH_DEVICE 0 #define DIAL_VALUE_HIGH 1 #define DIAL_VALUE_LOW 2 - /* dial/button box commands */ +/* dial/button box commands */ #define DIAL_INITIALIZE 0x20 #define DIAL_SET_LEDS 0x75 #define DIAL_SET_TEXT 0x61 #define DIAL_SET_AUTO_DIALS 0x50 #define DIAL_SET_AUTO_DELTA_DIALS 0x51 -#define DIAL_SET_FILTER 0x53 +#define DIAL_SET_FILTER 0x53 #define DIAL_SET_BUTTONS_MOM_TYPE 0x71 #define DIAL_SET_AUTO_MOM_BUTTONS 0x73 -#define DIAL_SET_ALL_LEDS 0x4b -#define DIAL_CLEAR_ALL_LEDS 0x4c +#define DIAL_SET_ALL_LEDS 0x4b +#define DIAL_CLEAR_ALL_LEDS 0x4c - /* dial/button box replies and events */ +/* dial/button box replies and events */ #define DIAL_INITIALIZED 0x20 #define DIAL_BASE 0x30 #define DIAL_DELTA_BASE 0x40 #define DIAL_PRESS_BASE 0xc0 #define DIAL_RELEASE_BASE 0xe0 - /* macros to determine reply type */ +/* macros to determine reply type */ #define IS_DIAL_EVENT(ch) (((ch)>=DIAL_BASE)&&((ch)=DIAL_PRESS_BASE)&&((ch)=DIAL_RELEASE_BASE)&&((ch)= 1400 ) // will return true for VC8 (VC2005) and higher + 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 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 +163,9 @@ void fgInitialiseInputDevices ( void ) #endif if ( !dial_device ) return; if ( !( dialbox_port = serial_open ( dial_device ) ) ) return; +#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) // will return true for VC8 (VC2005) and higher + 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; @@ -213,8 +223,8 @@ static void poll_dials ( int id ) { switch ( dial_state ) { - case DIAL_WHICH_DEVICE: - dial_which = data - DIAL_BASE; + case DIAL_WHICH_DEVICE: + dial_which = data - DIAL_BASE; dial_state++; break; case DIAL_VALUE_HIGH: @@ -250,7 +260,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,7 +281,6 @@ static SERIALPORT *serial_open ( const char *device ) tcgetattr(fd,&port->termio_save); memset(&termio, 0, sizeof(termio)); - cfmakeraw(&termio); termio.c_cflag = CS8 | CREAD | HUPCL ; termio.c_iflag = IGNPAR | IGNBRK ; termio.c_cc[VTIME] = 0; /* inter-character timer */ @@ -314,7 +323,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;