X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_joystick.c;h=c00937769816609c38cb3eae805f94856c1ee2ef;hb=096d5fe9317224a4764c709c379b428ac052e144;hp=8260340ab2a2553d79e3e833f14d5bf231d0f1a6;hpb=4f4c33c357f3dae74ac98fbdb450b3f624026049;p=freeglut diff --git a/src/freeglut_joystick.c b/src/freeglut_joystick.c index 8260340..c009377 100644 --- a/src/freeglut_joystick.c +++ b/src/freeglut_joystick.c @@ -75,7 +75,9 @@ # if HAVE_FCNTL_H # include # endif -# include +# if HAVE_ERRNO +# include +# endif # if defined(__FreeBSD__) || defined(__NetBSD__) /* XXX The below hack is done until freeglut's autoconf is updated. */ # define HAVE_USB_JS 1 @@ -237,12 +239,15 @@ static int fghJoystickFindUSBdev(char *name, char *out, int outlen) close(f); if (cp) return 1; - } else if (errno == EACCES) { + } +#if HAVE_ERRNO + else if (errno == EACCES) { if (!protection_warned) { fgWarning ( "Can't open %s for read!", buf ); protection_warned = 1; } } +#endif } return 0; } @@ -260,7 +265,11 @@ static int fghJoystickInitializeHID(struct os_specific_s *os, if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 ) { +#if HAVE_ERRNO fgWarning ( "error: %s: %s", os->fname, strerror( errno ) ); +#else + fgWarning ( "error: %s", os->fname ); +#endif return FALSE; } @@ -270,7 +279,11 @@ static int fghJoystickInitializeHID(struct os_specific_s *os, if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0) { /*** XXX {report_id} may not be the right variable? ***/ +#if HAVE_ERRNO fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) ); +#else + fgWarning ( "error: %s%d", UHIDDEV, report_id ); +#endif return FALSE; } @@ -663,7 +676,11 @@ static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) } } } +#if HAVE_ERRNO if ( len < 0 && errno != EAGAIN ) +#else + if ( len < 0 ) +#endif { perror( joy->os->fname ); joy->error = 1; @@ -682,6 +699,7 @@ static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) if ( status != sizeof( struct js_event ) ) { +#if HAVE_ERRNO if ( errno == EAGAIN ) { /* Use the old values */ @@ -692,6 +710,7 @@ static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) sizeof( float ) * joy->num_axes ); return; } +#endif fgWarning ( "%s", joy->fname ); joy->error = GL_TRUE; @@ -1298,8 +1317,10 @@ static void fghJoystickOpen( SFG_Joystick* joy ) joy->os->fd = open( joy->os->fname, O_RDONLY | O_NONBLOCK); +#if HAVE_ERRNO if( joy->os->fd < 0 && errno == EACCES ) fgWarning ( "%s exists but is not readable by you", joy->os->fname ); +#endif joy->error =( joy->os->fd < 0 ); @@ -1325,7 +1346,7 @@ static void fghJoystickOpen( SFG_Joystick* joy ) if( joy->error ) return; - snprintf( joyfname, sizeof(buffer), "%s/.joy%drc", getenv( "HOME" ), joy->id ); + snprintf( joyfname, sizeof(joyfname), "%s/.joy%drc", getenv( "HOME" ), joy->id ); joyfile = fopen( joyfname, "r" ); joy->error =( joyfile == NULL );