From 277b7f12d23cb95c41a8b878781c31b209fc0ddf Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 3 Apr 1999 04:20:22 +0000 Subject: [PATCH] Integration of Steve's plib conglomeration. --- GUI/Makefile.am | 5 +- GUI/gui.h | 2 +- Joystick/Makefile.am | 5 +- Joystick/joystick.cxx | 5 +- Joystick/js.cxx | 54 ------------- Joystick/js.hxx | 184 ------------------------------------------ 6 files changed, 13 insertions(+), 242 deletions(-) delete mode 100644 Joystick/js.cxx delete mode 100644 Joystick/js.hxx diff --git a/GUI/Makefile.am b/GUI/Makefile.am index 57617ace4..b2b473bd5 100644 --- a/GUI/Makefile.am +++ b/GUI/Makefile.am @@ -6,4 +6,7 @@ noinst_LIBRARIES = libGUI.a libGUI_a_SOURCES = gui.cxx gui.h -INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator +INCLUDES += -I$(top_builddir) \ + -I$(top_builddir)/Lib \ + -I$(top_builddir)/Lib/plib/include \ + -I$(top_builddir)/Simulator diff --git a/GUI/gui.h b/GUI/gui.h index f642a281a..449ad03c1 100644 --- a/GUI/gui.h +++ b/GUI/gui.h @@ -26,7 +26,7 @@ #ifndef _GUI_H_ #define _GUI_H_ -#include "PUI/pu.h" +#include extern puMenuBar *mainMenuBar; extern puButton *hideMenuButton; diff --git a/Joystick/Makefile.am b/Joystick/Makefile.am index 30eebce85..416b40d67 100644 --- a/Joystick/Makefile.am +++ b/Joystick/Makefile.am @@ -10,4 +10,7 @@ noinst_LIBRARIES = libJoystick.a libJoystick_a_SOURCES = joystick.cxx joystick.hxx js.hxx -INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator +INCLUDES += -I$(top_builddir) \ + -I$(top_builddir)/Lib \ + -I$(top_builddir)/Lib/plib/include \ + -I$(top_builddir)/Simulator diff --git a/Joystick/joystick.cxx b/Joystick/joystick.cxx index a3cde39f2..b5bef5280 100644 --- a/Joystick/joystick.cxx +++ b/Joystick/joystick.cxx @@ -34,7 +34,7 @@ #include #if defined( ENABLE_LINUX_JOYSTICK ) -# include +# include #elif defined( ENABLE_GLUT_JOYSTICK ) # include # include @@ -197,6 +197,9 @@ int fgJoystickRead( void ) { // $Log$ +// Revision 1.8 1999/04/03 04:20:33 curt +// Integration of Steve's plib conglomeration. +// // Revision 1.7 1999/01/19 17:52:30 curt // Some joystick tweaks by Norman Vine. // diff --git a/Joystick/js.cxx b/Joystick/js.cxx deleted file mode 100644 index 8f25dec82..000000000 --- a/Joystick/js.cxx +++ /dev/null @@ -1,54 +0,0 @@ - -#include "js.hxx" - -jsJoystick js0 ( 0 ) ; -jsJoystick js1 ( 1 ) ; - -int main () -{ - printf ( "Joystick test program.\n" ) ; - printf ( "~~~~~~~~~~~~~~~~~~~~~~\n" ) ; - - if ( js0 . notWorking () ) printf ( "Joystick 0 not detected\n" ) ; - if ( js1 . notWorking () ) printf ( "Joystick 1 not detected\n" ) ; - if ( js0 . notWorking () && js1 . notWorking () ) exit ( 1 ) ; - - js0 . setDeadBand ( 0, 0.1 ) ; - js0 . setDeadBand ( 1, 0.1 ) ; - js1 . setDeadBand ( 0, 0.1 ) ; - js1 . setDeadBand ( 1, 0.1 ) ; - - float *ax0 = new float [ js0.getNumAxes () ] ; - float *ax1 = new float [ js1.getNumAxes () ] ; - - while (1) - { - int b ; - - if ( ! js0 . notWorking () ) - { - js0 . read ( &b, ax0 ) ; - - printf ( "JS0: b0:%s b1:%s X:%1.3f Y:%1.3f ", - ( b & 1 ) ? "on " : "off", ( b & 2 ) ? "on " : "off", ax0[0], ax0[1] ) ; - } - - if ( ! js1 . notWorking () ) - { - js1 . read ( &b, ax1 ) ; - - printf ( "JS1: b0:%s b1:%s X:%1.3f Y:%1.3f ", - ( b & 1 ) ? "on " : "off", ( b & 2 ) ? "on " : "off", ax1[0], ax1[1] ) ; - } - - printf ( "\r" ) ; - fflush ( stdout ) ; - - /* give other processes a chance */ - - usleep ( 1 ) ; - } - - exit ( 0 ) ; -} - diff --git a/Joystick/js.hxx b/Joystick/js.hxx deleted file mode 100644 index ea51c0ce9..000000000 --- a/Joystick/js.hxx +++ /dev/null @@ -1,184 +0,0 @@ -#ifndef __INCLUDED_JS_H__ -#define __INCLUDED_JS_H__ 1 - -#ifdef __linux__ -# include -# include -# include -# include -#endif - -#define JS_TRUE 1 -#define JS_FALSE 0 - -/* - This is all set up for the older Linux and BSD drivers - which restrict you to two axes. -*/ - -#define _JS_MAX_AXES 2 - -class jsJoystick -{ - JS_DATA_TYPE js ; - char fname [ 128 ] ; - int error ; - int fd ; - - int num_axes ; - - float dead_band [ _JS_MAX_AXES ] ; - float center [ _JS_MAX_AXES ] ; - float max [ _JS_MAX_AXES ] ; - float min [ _JS_MAX_AXES ] ; - - void open () - { - num_axes = _JS_MAX_AXES ; - - fd = ::open ( fname, O_RDONLY ) ; - - error = ( fd < 0 ) ; - - if ( error ) - return ; - - int counter = 0 ; - - /* - The Linux driver seems to return 512 for all axes - when no stick is present - but there is a chance - that could happen by accident - so it's gotta happen - on both axes for at least 100 attempts. - */ - - do - { - rawRead ( NULL, center ) ; - counter++ ; - } while ( counter < 100 && center[0] == 512.0f && center[1] == 512.0f ) ; - - if ( counter >= 100 ) - error = JS_TRUE ; - - for ( int i = 0 ; i < _JS_MAX_AXES ; i++ ) - { - max [ i ] = center [ i ] * 2.0f ; - min [ i ] = 0.0f ; - dead_band [ i ] = 0.0f ; - } - } - - void close () - { - if ( ! error ) - ::close ( fd ) ; - } - - float fudge_axis ( float value, int axis ) - { - if ( value < center[axis] ) - { - float xx = ( value - center[ axis ] ) / - ( center [ axis ] - min [ axis ] ) ; - - xx = ( xx > -dead_band [ axis ] ) ? 0.0f : - ( ( xx + dead_band [ axis ] ) / ( 1.0f - dead_band [ axis ] ) ) ; - - return ( xx < -1.0f ) ? -1.0f : xx ; - } - else - { - float xx = ( value - center [ axis ] ) / - ( max [ axis ] - center [ axis ] ) ; - - xx = ( xx < dead_band [ axis ] ) ? 0.0f : - ( ( xx - dead_band [ axis ] ) / ( 1.0f - dead_band [ axis ] ) ) ; - - return ( xx > 1.0f ) ? 1.0f : xx ; - } - } - -public: - - jsJoystick ( int id = 0 ) - { - sprintf ( fname, "/dev/js%d", id ) ; - open () ; - } - - ~jsJoystick () - { - close () ; - } - - int getNumAxes () { return num_axes ; } - int notWorking () { return error ; } - void setError () { error = JS_TRUE ; } - - float getDeadBand ( int axis ) { return dead_band [ axis ] ; } - void setDeadBand ( int axis, float db ) { dead_band [ axis ] = db ; } - - void setMinRange ( float *axes ) { memcpy ( min , axes, num_axes * sizeof(float) ) ; } - void setMaxRange ( float *axes ) { memcpy ( max , axes, num_axes * sizeof(float) ) ; } - void setCenter ( float *axes ) { memcpy ( center, axes, num_axes * sizeof(float) ) ; } - - void getMinRange ( float *axes ) { memcpy ( axes, min , num_axes * sizeof(float) ) ; } - void getMaxRange ( float *axes ) { memcpy ( axes, max , num_axes * sizeof(float) ) ; } - void getCenter ( float *axes ) { memcpy ( axes, center, num_axes * sizeof(float) ) ; } - - void read ( int *buttons, float *axes ) - { - if ( error ) - { - if ( buttons ) - *buttons = 0 ; - - if ( axes ) - for ( int i = 0 ; i < _JS_MAX_AXES ; i++ ) - axes[i] = 0.0f ; - } - - float raw_axes [ _JS_MAX_AXES ] ; - - rawRead ( buttons, raw_axes ) ; - - if ( axes ) - for ( int i = 0 ; i < _JS_MAX_AXES ; i++ ) - axes[i] = ( i < num_axes ) ? fudge_axis ( raw_axes[i], i ) : 0.0f ; - } - - void rawRead ( int *buttons, float *axes ) - { - if ( error ) - { - if ( buttons ) *buttons = 0 ; - if ( axes ) - for ( int i = 0 ; i < _JS_MAX_AXES ; i++ ) - axes[i] = 1500.0f ; - - return ; - } - - int status = ::read ( fd, &js, JS_RETURN ) ; - - if ( status != JS_RETURN ) - { - perror ( fname ) ; - setError () ; - return ; - } - - if ( buttons ) - *buttons = js.buttons ; - - if ( axes ) - { - axes[0] = (float) js.x ; - axes[1] = (float) js.y ; - } - } -} ; - -#endif - -- 2.39.5