]> git.mxchange.org Git - flightgear.git/commitdiff
Integration of Steve's plib conglomeration.
authorcurt <curt>
Sat, 3 Apr 1999 04:20:22 +0000 (04:20 +0000)
committercurt <curt>
Sat, 3 Apr 1999 04:20:22 +0000 (04:20 +0000)
GUI/Makefile.am
GUI/gui.h
Joystick/Makefile.am
Joystick/joystick.cxx
Joystick/js.cxx [deleted file]
Joystick/js.hxx [deleted file]

index 57617ace44697917c3176d78d266065ae19e349b..b2b473bd5c3ac8a7af384edb5ef6d4413573727e 100644 (file)
@@ -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
index f642a281a10463d13098a1680707e86bc2ea8128..449ad03c1e612d4d0c788f2fa2f817d0933ba034 100644 (file)
--- a/GUI/gui.h
+++ b/GUI/gui.h
@@ -26,7 +26,7 @@
 #ifndef _GUI_H_
 #define _GUI_H_
 
-#include "PUI/pu.h"
+#include <pu.h>
 
 extern puMenuBar    *mainMenuBar;
 extern puButton     *hideMenuButton;
index 30eebce8599fbb6d407df87151350d308a8db838..416b40d674a2c7f003a02d350f1f04213685b3bb 100644 (file)
@@ -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
index a3cde39f2d32ef2fa47e9f21210656808de3ada9..b5bef52802ef7dfedaedd183a57145e2b6d77642 100644 (file)
@@ -34,7 +34,7 @@
 #include <Debug/logstream.hxx>
 
 #if defined( ENABLE_LINUX_JOYSTICK )
-#  include <Joystick/js.hxx>
+#  include <js.h>
 #elif defined( ENABLE_GLUT_JOYSTICK )
 #  include <GL/glut.h>
 #  include <XGL/xgl.h>
@@ -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 (file)
index 8f25dec..0000000
+++ /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 (file)
index ea51c0c..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-#ifndef __INCLUDED_JS_H__
-#define __INCLUDED_JS_H__ 1
-
-#ifdef __linux__
-#  include <stdio.h>
-#  include <unistd.h>
-#  include <fcntl.h>
-#  include <linux/joystick.h>
-#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
-