]> git.mxchange.org Git - flightgear.git/commitdiff
Joystick functionality has been moved to ../Joystick.
authorcurt <curt>
Mon, 4 Jun 2001 21:38:03 +0000 (21:38 +0000)
committercurt <curt>
Mon, 4 Jun 2001 21:38:03 +0000 (21:38 +0000)
src/Joystick/Makefile.am [deleted file]
src/Joystick/fgjs.cxx [deleted file]
src/Joystick/joystick.cxx [deleted file]
src/Joystick/joystick.hxx [deleted file]
src/Joystick/js_demo.cxx [deleted file]
src/Joystick/jsinput.cxx [deleted file]
src/Joystick/jsinput.h [deleted file]
src/Joystick/jssuper.cxx [deleted file]
src/Joystick/jssuper.h [deleted file]

diff --git a/src/Joystick/Makefile.am b/src/Joystick/Makefile.am
deleted file mode 100644 (file)
index b3454ae..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-noinst_LIBRARIES = libJoystick.a
-
-libJoystick_a_SOURCES = joystick.cxx joystick.hxx
-
-noinst_PROGRAMS = js_demo fgjs
-
-js_demo_SOURCES = js_demo.cxx
-
-js_demo_LDADD = $(audio_LIBS)
-
-fgjs_SOURCES = fgjs.cxx jsinput.cxx jssuper.cxx
-
-fgjs_LDADD =
-
-INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/src
diff --git a/src/Joystick/fgjs.cxx b/src/Joystick/fgjs.cxx
deleted file mode 100644 (file)
index 15fc46c..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-// fgjs.cxx -- assign joystick axes to flightgear properties
-//
-// Written by Tony Peden, started May 2001
-//
-// Copyright (C) 2001  Tony Peden (apeden@earthlink.net)
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-
-#include <jssuper.h>
-#include <jsinput.h>
-#include <iostream>
-#include <fstream>
-#include <math.h>
-#include <string>
-
-string axes_humannames[8] = { "elevator", "ailerons", "rudder", "throttle", 
-                              "mixture","propller pitch", "lateral view", 
-                              "longitudinal view" 
-                            };
-
-string axes_propnames[8]={ "/controls/elevator","/controls/aileron",
-                           "/controls/rudder","/controls/throttle",
-                           "/controls/mixture","/controls/pitch", 
-                           "/sim/views/axes/lat","/sim/views/axes/long" 
-                         };
-                      
-bool half_range[8]={ false,false,false,true,true,true,false,false };
-
-
-string button_humannames[7]= { "apply all brakes", "apply left brake", 
-                               "apply right brake", "step flaps up", 
-                               "step flaps down","apply nose-up trim",
-                               "apply nose-down trim"
-                             }; 
-
-string button_propnames[7]={ "/controls/brakes/all", "/controls/brakes/left",
-                             "/controls/brakes/right", "/controls/flaps",
-                             "/controls/flaps","/controls/elevator-trim",
-                             "/controls/elevator-trim" 
-                           };                                                   
-
-float button_step[7]={ 1.0, 1.0, 1.0, 0.34, -0.34, 0.001, -0.001 };
-
-string button_repeat[7]={ "false", "false", "false", "false", "false", 
-                          "true", "true" };
-
-
-void waitForButton(jsSuper *jss, int wait_ms) {
-      int b,lastb;
-      float axes[_JS_MAX_AXES];
-      b=0;
-      ulMilliSecondSleep(wait_ms);
-      do {
-        lastb=b;
-        do {
-          jss->getJoystick()->read ( &b, axes ) ;
-        } while( jss->nextJoystick()); 
-        
-        ulMilliSecondSleep(1); 
-      }while( lastb == b ); 
-      ulMilliSecondSleep(wait_ms);
-}
-
-void writeAxisProperties(fstream &fs, int control,int joystick, int axis) {
-     
-     char jsDesc[25];
-     snprintf(jsDesc,25,"--prop:/input/js%d/axis%d",joystick,axis);
-     fs << jsDesc  << "/control=" << axes_propnames[control] << endl; 
-     
-     fs << jsDesc << "/dead-band=0.02"  << endl; 
-     
-     if( half_range[control] == true) {
-       fs << jsDesc << "/offset=-1.0" << endl; 
-       fs << jsDesc << "/factor=0.5" << endl;
-     } else {
-       fs << jsDesc << "/offset=0.0" << endl; 
-       fs << jsDesc << "/factor=1.0" << endl;
-     }
-     fs << endl;
-} 
-
-void writeButtonProperties(fstream &fs, int property,int joystick, int button) {
-     
-     char jsDesc[25];
-     snprintf(jsDesc,25,"--prop:/input/js%d/button%d",joystick,button);
-     
-     fs << jsDesc << "/action=adjust" << endl; 
-     fs << jsDesc << "/control=" << button_propnames[property] << endl;
-     fs << jsDesc << "/step=" << button_step[property] << endl; 
-     fs << jsDesc << "/repeatable=" << button_repeat[property] << endl;
-     fs << endl; 
-}    
-
-        
-
-      
-int main(void) {
-  jsSuper *jss=new jsSuper();
-  jsInput *jsi=new jsInput(jss);
-  jsi->displayValues(false);
-  int i;
-  int control=0;
-  
-  
-  cout << "Found " << jss->getNumJoysticks() << " joystick(s)" << endl;
-  
-  if(jss->getNumJoysticks() <= 0) { 
-    cout << "Can't find any joysticks ..." << endl;
-    exit(1);
-  }  
-  
-  jss->firstJoystick();
-  do {
-    cout << "Joystick " << jss->getCurrentJoystickId() << " has "
-         << jss->getJoystick()->getNumAxes() << " axes" << endl;
-  } while( jss->nextJoystick() ); 
-  
-  fstream fs("fgfsrc.js",ios::out);
-
-  
-  for(control=0;control<=7;control++) {
-      cout << "Move the control you wish to use for " << axes_humannames[control]
-           << endl;
-      fflush( stdout );
-      jsi->getInput();
-      
-      if(jsi->getInputAxis() != -1) {
-         cout << endl << "Assigned axis " << jsi->getInputAxis() 
-              << " on joystick " << jsi->getInputJoystick() 
-              << " to control " << axes_humannames[control]
-              << endl;
-      
-          writeAxisProperties( fs, control, jsi->getInputJoystick(), 
-                               jsi->getInputAxis() ); 
-      } else {
-          cout << "Skipping Axis" << endl;
-      }           
-      
-      cout << "Press any button for next control" << endl;
-      
-      waitForButton(jss,500);
-      cout << endl;
-  }
-  
-  for(control=0;control<=6;control++) {
-      cout << "Press the button you wish to use to " 
-           << button_humannames[control]
-           << endl;
-      fflush( stdout );
-      jsi->getInput();
-      if(jsi->getInputButton() != -1) {
-         
-         cout << endl << "Assigned button " << jsi->getInputButton() 
-              << " on joystick " << jsi->getInputJoystick() 
-              << " to control " << button_humannames[control]
-              << endl;
-      
-          writeButtonProperties( fs, control, jsi->getInputJoystick(), 
-                               jsi->getInputButton() ); 
-      } else {
-          cout << "Skipping..." << endl;
-      }           
-      
-      cout << "Press any button for next axis" << endl;
-      
-      waitForButton(jss,500);
-      cout << endl;
-  }
-
-  delete jsi;
-  delete jss;
-      
-  cout << "Your joystick settings are in the file fgfsrc.js" << endl;
-  cout << "Check and edit as desired (especially important if you are"
-         << " using a hat switch" << endl;
-  cout << "as this program will, most likely, not get those right).  ";        
-  
-  cout << "Once you are happy, " << endl 
-       << "append its contents to your .fgfsrc or system.fgfsrc" << endl;     
-     
-  return 1;
-}      
-  
-
-
diff --git a/src/Joystick/joystick.cxx b/src/Joystick/joystick.cxx
deleted file mode 100644 (file)
index 7167eb4..0000000
+++ /dev/null
@@ -1,557 +0,0 @@
-// joystick.cxx -- joystick support
-//
-// Original module written by Curtis Olson, started October 1998.
-// Completely rewritten by David Megginson, July 2000.
-//
-// Copyright (C) 1998 - 2000  Curtis L. Olson - curt@flightgear.org
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-#include <simgear/compiler.h>
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-#  include <windows.h>                     
-#endif
-
-#include <math.h>
-
-#include <string>
-
-#include <Main/fg_props.hxx>
-
-#include <simgear/debug/logstream.hxx>
-#include <plib/js.h>
-
-#include "joystick.hxx"
-
-SG_USING_STD(string);
-#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
-SG_USING_STD(cout);
-#endif
-
-#ifdef WIN32
-static const int MAX_JOYSTICKS = 2;
-#else
-static const int MAX_JOYSTICKS = 10;
-#endif
-static const int MAX_AXES = _JS_MAX_AXES;
-static const int MAX_BUTTONS = 32;
-
-
-/**
- * Property names for joysticks and axes.
- */
-static const char * jsNames[] = {
-    "js0", "js1", "js2", "js3", "js4",
-    "js5", "js6", "js7", "js8", "js9"
-};
-static const char * axisNames[] = {
-    "axis0", "axis1", "axis2", "axis3", "axis4",
-    "axis5", "axis6", "axis7", "axis8", "axis9"
-};
-static const char * buttonNames[] = {
-    "button0", "button1", "button2", "button3", "button4",
-    "button5", "button6", "button7", "button8", "button9",
-    "button10", "button11", "button12", "button13", "button14",
-    "button15", "button16", "button17", "button18", "button19",
-    "button20", "button21", "button22", "button23", "button24",
-    "button25", "button26", "button27", "button28", "button29",
-    "button30", "button31"
-};
-
-
-/**
- * trim capture
- */
-struct trimcapture {
-    float tolerance;
-    bool captured;
-    string name;
-    SGValue* value;
-};   
-
-
-/**
- * Settings for a single axis.
- */
-struct axis {
-    axis () :
-       value(0),
-       offset(0.0),
-       factor(1.0),
-       last_value(9999999),
-       tolerance(0.002),
-       capture(NULL)
-    { }
-    SGValue * value;
-    float offset;
-    float factor;
-    float last_value;
-    float tolerance;
-    trimcapture* capture;
-};
-
-
-/**
- * Settings for a single button.
- */
-struct button {
-    enum Action {
-       TOGGLE,
-       SWITCH,
-       ADJUST
-    };
-    button () : value(0), step(0.0), action(ADJUST), isRepeatable(true),
-       lastState(-1) {}
-    SGValue * value;
-    float step;
-    Action action;
-    bool isRepeatable;
-    int lastState;
-};
-
-
-/**
- * Settings for a single joystick.
- */
-struct joystick {
-    virtual ~joystick () {
-       delete js;
-#ifndef macintosh
-       delete axes;
-       delete buttons;
-#else
-       delete[] axes;
-       delete[] buttons;
-#endif
-    }
-    int naxes;
-    int nbuttons;
-    jsJoystick * js;
-    axis * axes;
-    button * buttons;
-};
-
-
-/**
- * Array of joystick settings.
- */
-static joystick joysticks[MAX_JOYSTICKS];
-
-SGValue *trimmed;
-
-
-/**
- * Initialize any joysticks found.
- */
-int
-fgJoystickInit() 
-{
-    bool seen_joystick = false;
-
-    SG_LOG(SG_INPUT, SG_INFO, "Initializing joysticks");
-
-    for (int i = 0; i < MAX_JOYSTICKS; i++) {
-       jsJoystick * js = new jsJoystick(i);
-       joysticks[i].js = js;
-       if (js->notWorking()) {
-           SG_LOG(SG_INPUT, SG_INFO, "Joystick " << i << " not found");
-           continue;
-       }
-#ifdef WIN32
-       JOYCAPS jsCaps ;
-       joyGetDevCaps( i, &jsCaps, sizeof(jsCaps) );
-       int nbuttons = jsCaps.wNumButtons;
-       if (nbuttons > MAX_BUTTONS) nbuttons = MAX_BUTTONS;
-#else
-       int nbuttons = MAX_BUTTONS;
-#endif
-       
-       int naxes = js->getNumAxes();
-       if (naxes > MAX_AXES) naxes = MAX_AXES;
-       joysticks[i].naxes = naxes;
-       joysticks[i].nbuttons = nbuttons;
-
-       SG_LOG(SG_INPUT, SG_INFO, "Initializing joystick " << i);
-       seen_joystick = true;
-
-       // Set up range arrays
-       float *minRange = new float[naxes];
-       float *maxRange = new float[naxes];
-       float *center = new float[naxes];
-
-       // Initialize with default values
-       js->getMinRange(minRange);
-       js->getMaxRange(maxRange);
-       js->getCenter(center);
-
-       // Allocate axes and buttons
-       joysticks[i].axes = new axis[naxes];
-       joysticks[i].buttons = new button[nbuttons];
-
-
-       //
-       // Initialize the axes.
-       //
-       int j;
-       for (j = 0; j < naxes; j++) {
-           axis &a = joysticks[i].axes[j];
-
-           string base = "/input/";
-           base += jsNames[i];
-           base += '/';
-           base += axisNames[j];
-           SG_LOG(SG_INPUT, SG_INFO, "  Axis " << j << ':');
-
-           // Control property
-           string name = base;
-           name += "/control";
-           SGValue * value = fgGetValue(name);
-           if (value == 0) {
-               SG_LOG(SG_INPUT, SG_INFO, "    no control defined");
-               continue;
-           }
-           const string &control = value->getStringValue();
-           a.value = fgGetValue(control, true);
-           SG_LOG(SG_INPUT, SG_INFO, "    using control " << control);
-
-           // Dead band
-           name = base;
-           name += "/dead-band";
-           value = fgGetValue(name);
-           if (value != 0)
-               js->setDeadBand(j, value->getDoubleValue());
-           SG_LOG(SG_INPUT, SG_INFO, "    dead-band is " << js->getDeadBand(j));
-
-           // Offset
-           name = base;
-           name += "/offset";
-           value = fgGetValue(name);
-           if (value != 0)
-               a.offset = value->getDoubleValue();
-           SG_LOG(SG_INPUT, SG_INFO, "    offset is " << a.offset);
-
-
-           // Factor
-           name = base;
-           name += "/factor";
-           value = fgGetValue(name);
-           if (value != 0)
-               a.factor = value->getDoubleValue();
-           SG_LOG(SG_INPUT, SG_INFO, "    factor is " << a.factor);
-
-
-           // Tolerance
-           name = base;
-           name += "/tolerance";
-           value = fgGetValue(name);
-           if (value != 0)
-               a.tolerance = value->getDoubleValue();
-           SG_LOG(SG_INPUT, SG_INFO, "    tolerance is " << a.tolerance);
-
-
-           // Saturation
-           name = base;
-           name += "/saturation";
-           value = fgGetValue(name);
-           if (value != 0)
-               js->setSaturation(j, value->getDoubleValue());
-           SG_LOG(SG_INPUT, SG_INFO, "    saturation is " << js->getSaturation(j));
-
-           // Minimum range
-           name = base;
-           name += "/min-range";
-           value = fgGetValue(name);
-           if (value != 0)
-               minRange[j] = value->getDoubleValue();
-           SG_LOG(SG_INPUT, SG_INFO, "    min-range is " << minRange[j]);
-
-           // Maximum range
-           name = base;
-           name += "/max-range";
-           value = fgGetValue(name);
-           if (value != 0)
-               maxRange[j] = value->getDoubleValue();
-           SG_LOG(SG_INPUT, SG_INFO, "    max-range is " << maxRange[j]);
-
-           // Center
-           name = base;
-           name += "/center";
-           value = fgGetValue(name);
-           if (value != 0)
-               center[j] = value->getDoubleValue();
-           SG_LOG(SG_INPUT, SG_INFO, "    center is " << center[j]);
-      
-            // Capture
-           name = base;
-           name += "/capture";
-           value = fgGetValue(name);
-           if ( value != 0 ) {
-               string trimname = "/fdm/trim"
-                   + control.substr(control.rfind("/"),control.length());
-               if ( fgHasValue(trimname) ) {   
-                   a.capture = new trimcapture;
-                   a.capture->tolerance = value->getDoubleValue();
-                   a.capture->captured = false;
-                   a.capture->name = control;
-                   a.capture->value = fgGetValue(trimname);
-                   SG_LOG(SG_INPUT, SG_INFO, "    capture is " 
-                          << value->getDoubleValue() );
-                } else {
-                   a.capture = NULL;
-                   SG_LOG(SG_INPUT, SG_INFO, "    capture is "         
-                          << "unsupported by FDM" );
-               }                               
-          }                            
-       }
-
-
-       //
-       // Initialize the buttons.
-       //
-       for (j = 0; j < nbuttons; j++) {
-           button &b = joysticks[i].buttons[j];
-      
-           string base = "/input/";
-           base += jsNames[i];
-           base += '/';
-           base += buttonNames[j];
-           SG_LOG(SG_INPUT, SG_INFO, "  Button " << j << ':');
-
-           // Control property
-           string name = base;
-           name += "/control";
-           cout << "Trying name " << name << endl;
-           SGValue * value = fgGetValue(name);
-           if (value == 0) {
-               SG_LOG(SG_INPUT, SG_INFO, "    no control defined");
-               continue;
-           }
-           const string &control = value->getStringValue();
-           b.value = fgGetValue(control, true);
-           SG_LOG(SG_INPUT, SG_INFO, "    using control " << control);
-
-           // Step
-           name = base;
-           name += "/step";
-           value = fgGetValue(name);
-           if (value != 0)
-               b.step = value->getDoubleValue();
-           SG_LOG(SG_INPUT, SG_INFO, "    step is " << b.step);
-
-           // Type
-           name = base;
-           name += "/action";
-           value = fgGetValue(name);
-           string action = "adjust";
-           if (value != 0)
-               action = value->getStringValue();
-           if (action == "toggle") {
-               b.action = button::TOGGLE;
-               b.isRepeatable = false;
-           } else if (action == "switch") {
-               b.action = button::SWITCH;
-               b.isRepeatable = false;
-           } else if (action == "adjust") {
-               b.action = button::ADJUST;
-               b.isRepeatable = true;
-           } else {
-               SG_LOG(SG_INPUT, SG_ALERT, "    unknown action " << action);
-               action = "adjust";
-               b.action = button::ADJUST;
-               b.isRepeatable = true;
-           }
-           SG_LOG(SG_INPUT, SG_INFO, "    action is " << action);
-
-           // Repeatability.
-           name = base;
-           name += "/repeatable";
-           value = fgGetValue(name);
-           if (value != 0)
-               b.isRepeatable = value->getBoolValue();
-           SG_LOG(SG_INPUT, SG_INFO, (b.isRepeatable ?
-                                      "    repeatable" : "    not repeatable"));
-       }
-
-       js->setMinRange(minRange);
-       js->setMaxRange(maxRange);
-       js->setCenter(center);
-
-       //-dw- clean up
-       delete minRange;
-       delete maxRange;
-       delete center;
-    }
-
-    trimmed = fgGetValue("/fdm/trim/trimmed");
-    
-    if (seen_joystick)
-       SG_LOG(SG_INPUT, SG_INFO, "Done initializing joysticks");
-    else
-       SG_LOG(SG_INPUT, SG_ALERT, "No joysticks detected");
-
-    return seen_joystick;
-}
-
-
-/**
- * Update property values based on the joystick state(s).
- */
-int
-fgJoystickRead()
-{
-    int buttons;
-    float js_val, diff;
-    float *axis_values = new float[MAX_AXES];
-
-    for (int i = 0; i < MAX_JOYSTICKS; i++) {
-       jsJoystick * js = joysticks[i].js;
-       // float *axis_values = new float[joysticks[i].naxes];
-       if (js->notWorking()) {
-           continue;
-       }
-
-       js->read(&buttons, axis_values);
-
-       //
-       // Axes
-       //
-       int j;
-       for (j = 0; j < joysticks[i].naxes; j++) {
-           bool flag = true;
-           axis &a = joysticks[i].axes[j];
-
-           if ( a.capture && trimmed->getBoolValue() ) {
-               // if the model has been trimmed then capture the
-               // joystick. When a trim succeeds, the above
-               // is true for one frame only.
-               a.capture->captured = false;
-               SG_LOG( SG_GENERAL, SG_INFO, "Successful trim, capture is " <<
-                       "enabled on " << a.capture->name );
-           } 
-
-           // If the axis hasn't changed, don't
-           // force the value.
-           if (fabs(axis_values[j] - a.last_value) <= a.tolerance)
-               continue;
-           else
-               a.last_value = axis_values[j];
-           
-           if ( a.value ) {
-               js_val = ( axis_values[j] + a.offset ) * a.factor; 
-               
-               if ( a.capture && !a.capture->captured ) {
-                   diff = js_val - a.capture->value->getDoubleValue();
-                    SG_LOG( SG_GENERAL, SG_INFO, a.capture->name
-                           << " capture: " << diff );
-                   if ( fabs( diff ) < a.capture->tolerance ) {
-                       flag = a.value->setDoubleValue( js_val );
-                       a.capture->captured = true;
-                       SG_LOG(SG_GENERAL,SG_INFO, a.capture->name 
-                              << " captured." );
-                   }
-               } else {
-                   flag = a.value->setDoubleValue( js_val );
-                }
-           }
-               
-           if (!flag)
-               SG_LOG(SG_INPUT, SG_ALERT, "Failed to set value for joystick "
-                      << i << ", axis " << j);
-       }
-
-       //
-       // Buttons
-       //
-       for (j = 0; j < joysticks[i].nbuttons; j++) {
-           bool flag = false;
-           button &b = joysticks[i].buttons[j];
-           if (b.value == 0)
-               continue;
-
-           // Button is on.
-           if ((buttons & (1 << j)) > 0) {
-               // Repeating?
-               if (b.lastState == 1 && !b.isRepeatable)
-                   continue;
-
-               switch (b.action) {
-               case button::TOGGLE:
-                   if (b.step != 0.0) {
-                       if (b.value->getDoubleValue() == 0.0)
-                           flag = b.value->setDoubleValue(b.step);
-                       else
-                           flag = b.value->setDoubleValue(0.0);
-                   } else {
-                       if (b.value->getBoolValue())
-                           flag = b.value->setBoolValue(false);
-                       else
-                           flag = b.value->setBoolValue(true);
-                   }
-                   break;
-               case button::SWITCH:
-                   flag = b.value->setDoubleValue(b.step);
-                   break;
-               case button::ADJUST:
-                   flag = b.value->setDoubleValue(b.value->getDoubleValue() +
-                                                  b.step);
-                   break;
-               default:
-                   flag = false;
-                   break;
-               }
-               b.lastState = 1;
-
-               // Button is off
-           } else {
-               // Repeating?
-               if (b.lastState == 0 && !b.isRepeatable)
-                   continue;
-
-               switch (b.action) {
-               case button::ADJUST:
-               case button::TOGGLE:
-                   // no op
-                   flag = true;
-                   break;
-               case button::SWITCH:
-                   flag = b.value->setDoubleValue(0.0);
-                   break;
-               default:
-                   flag = false;
-                   break;
-               }
-
-               b.lastState = 0;
-           }
-           if (!flag)
-               SG_LOG(SG_INPUT, SG_ALERT, "Failed to set value for "
-                      << jsNames[i] << ' ' << buttonNames[j]);
-       }
-    }
-
-    // -dw- cleanup 
-    delete axis_values;
-
-    return true;
-}
-
-// end of joystick.cxx
diff --git a/src/Joystick/joystick.hxx b/src/Joystick/joystick.hxx
deleted file mode 100644 (file)
index bb4ff66..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// joystick.cxx -- joystick support
-//
-// Written by Curtis Olson, started October 1998.
-//
-// Copyright (C) 1998  Curtis L. Olson - curt@me.umn.edu
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _JOYSTICK_HXX
-#define _JOYSTICK_HXX
-
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-
-// Initialize the joystick(s)
-int fgJoystickInit( void );
-
-// update the control parameters based on joystick intput
-int fgJoystickRead( void );
-
-#endif // _JOYSTICK_HXX
-
-
diff --git a/src/Joystick/js_demo.cxx b/src/Joystick/js_demo.cxx
deleted file mode 100644 (file)
index 904a409..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-#  include <windows.h>                     
-#endif
-
-#include <string.h>            // plib/js.h should really include this !!!!!!
-#include <plib/js.h>
-
-#define Z 8
-
-int main ( int, char ** )
-{
-  jsJoystick *js[Z] ;
-  float      *ax[Z] ;
-  int i, j, t, useful[Z];
-
-  for ( i = 0; i < Z; i++ )
-      js[i] = new jsJoystick ( i ) ;
-
-  printf ( "Joystick test program.\n" ) ;
-  printf ( "~~~~~~~~~~~~~~~~~~~~~~\n" ) ;
-
-  t = 0;
-  for ( i = 0; i < Z; i++ )
-  { useful[i] = ! ( js[i]->notWorking () );
-    if ( useful[i] )
-         t++;
-    else printf ( "Joystick %i not detected\n", i ) ;
-  }
-  if ( t == 0 ) exit ( 1 ) ;
-
-  for ( i = 0; i < Z; i++ )
-    if ( useful[i] )
-       ax[i] = new float [ js[i]->getNumAxes () ] ;
-
-  for ( i = 0 ; i < Z ; i++ )
-    if ( useful[i] )
-       printf ( "+--------------------JS.%d----------------------", i ) ;
-
-  printf ( "+\n" ) ;
-
-  for ( i = 0 ; i < Z ; i++ )
-   if ( useful[i] )
-   {
-    if ( js[i]->notWorking () )
-      printf ( "|           ~~~ Not Detected ~~~             " ) ;
-    else
-    {
-      printf ( "| Btns " ) ;
-
-      for ( j = 0 ; j < js[i]->getNumAxes () ; j++ )
-        printf ( "Ax:%1d ", j ) ;
-
-      for ( ; j < 8 ; j++ )
-        printf ( "     " ) ;
-    }
-   }
-
-  printf ( "|\n" ) ;
-
-  for ( i = 0 ; i < Z ; i++ )
-    if ( useful[i] )
-      printf ( "+----------------------------------------------" ) ;
-
-  printf ( "+\n" ) ;
-
-  while (1)
-  {
-    for ( i = 0 ; i < Z ; i++ )
-    if ( useful[i] )
-     {
-      if ( js[i]->notWorking () )
-        printf ( "|  .   .   .   .   .   .   .   .   .   .   . " ) ;
-      else
-      {
-        int b ;
-
-        js[i]->read ( &b, ax[i] ) ;
-
-        printf ( "| %04x ", b ) ;
-
-       for ( j = 0 ; j < js[i]->getNumAxes () ; j++ )
-         printf ( "%+.1f ", ax[i][j] ) ;
-
-       for ( ; j < 8 ; j++ )
-         printf ( "  .  " ) ;
-      }
-     }
-
-    printf ( "|\r" ) ;
-    fflush ( stdout ) ;
-
-    /* give other processes a chance */
-
-#ifdef WIN32
-    Sleep ( 1 ) ;
-#elif defined(sgi)
-    sginap ( 1 ) ;
-#else
-    usleep ( 1000 ) ;
-#endif
-  }
-
-  return 0 ;
-}
-
-
diff --git a/src/Joystick/jsinput.cxx b/src/Joystick/jsinput.cxx
deleted file mode 100644 (file)
index 48d0d74..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-// jsinput.cxx -- wait for and identify input from joystick
-//
-// Written by Tony Peden, started May 2001
-//
-// Copyright (C) 2001  Tony Peden (apeden@earthlink.net)
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-#include <jssuper.h>
-#include <jsinput.h>
-#include <plib/js.h>
-#include <plib/ul.h>
-
-
-jsInput::jsInput(jsSuper *j) {
-  jss=j;
-  pretty_display=false;
-  joystick=axis=button=-1;
-  axis_threshold=0.2;
-}
-
-jsInput::~jsInput(void) {}
-
-int jsInput::getInput(void){
-      
-      bool gotit=false;
-      
-      float delta;
-      int i,current_button=0,button_bits;       
-
-      joystick=axis=button=-1;
-      
-      if(pretty_display) {
-          printf ( "+----------------------------------------------\n" ) ;
-          printf ( "| Btns " ) ;
-
-          for ( i = 0 ; i < jss->getJoystick()->getNumAxes() ; i++ )
-            printf ( "Ax:%1d ", i ) ;
-
-          for ( ; i < 8 ; i++ )
-            printf ( "     " ) ;
-
-          printf ( "|\n" ) ;
-
-          printf ( "+----------------------------------------------\n" ) ;
-      }
-      
-
-      jss->firstJoystick();
-      do {
-        jss->getJoystick()->read ( &button_iv[jss->getCurrentJoystickId()],
-                                       axes_iv[jss->getCurrentJoystickId()] ) ;
-      } while( jss->nextJoystick() );  
-      
-      
-      
-      while(!gotit) {
-        jss->firstJoystick();
-        do {
-
-          jss->getJoystick()->read ( &current_button, axes ) ;
-
-          if(pretty_display) printf ( "| %04x ", current_button ) ;
-
-               for ( i = 0 ; i < jss->getJoystick()->getNumAxes(); i++ ) {
-
-            delta = axes[i] - axes_iv[jss->getCurrentJoystickId()][i]; 
-            if(pretty_display) printf ( "%+.1f ", delta ) ; 
-            if(!gotit) {
-              if( fabs(delta) > axis_threshold ) {
-                gotit=true;
-                joystick=jss->getCurrentJoystickId();
-                axis=i;
-              } else if( current_button != 0 ) {
-                gotit=true;
-                joystick=jss->getCurrentJoystickId();  
-                button_bits=current_button;
-              } 
-            }            
-          }
-               
-          if(pretty_display) {
-            for ( ; i < 8 ; i++ )
-                   printf ( "  .  " ) ;
-          }
-
-
-        } while( jss->nextJoystick() && !gotit); 
-        if(pretty_display) {
-          printf ( "|\r" ) ;
-          fflush ( stdout ) ;
-        }
-
-        ulMilliSecondSleep(1);
-      }
-      if(button_bits != 0) {
-        for(int i=1;i<=31;i++) {
-          if( ( button_bits & (1 << i) ) > 0 ) {
-             button=i;
-             break;
-          } 
-        }    
-      } 
-}
-  
diff --git a/src/Joystick/jsinput.h b/src/Joystick/jsinput.h
deleted file mode 100644 (file)
index b173a3a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// jsinput.h -- wait for and identify input from joystick
-//
-// Written by Tony Peden, started May 2001
-//
-// Copyright (C) 2001  Tony Peden (apeden@earthlink.net)
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-
-
-#ifndef _JSINPUT_H
-#define _JSINPUT_H
-
-#include <jssuper.h>
-#include <plib/js.h>
-
-class jsInput {
-  private:
-    jsSuper *jss;
-    bool pretty_display;
-    float axes[_JS_MAX_AXES];
-    float axes_iv[MAX_JOYSTICKS][_JS_MAX_AXES];
-    int button_iv[MAX_JOYSTICKS];
-    
-    int joystick,axis,button;
-    
-    float axis_threshold;
-    
-  public:
-    jsInput(jsSuper *jss);
-    ~jsInput(void); 
-    
-    inline void displayValues(bool bb) { pretty_display=bb; }
-    
-    int getInput(void);
-    
-    inline int getInputJoystick(void) { return joystick; }
-    inline int getInputAxis(void)     { return axis; }
-    inline int getInputButton(void)   { return button; }
-    
-    inline float getReturnThreshold(void) { return axis_threshold; }
-    inline void setReturnThreshold(float ff) 
-              { if(fabs(ff) <= 1.0) axis_threshold=ff; }
-};    
-
-
-#endif
diff --git a/src/Joystick/jssuper.cxx b/src/Joystick/jssuper.cxx
deleted file mode 100644 (file)
index 4e1bf80..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-// jssuper.cxx -- manage access to multiple joysticks
-//
-// Written by Tony Peden, started May 2001
-//
-// Copyright (C) 2001  Tony Peden (apeden@earthlink.net)
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-
-#include <string.h>            // plib/js.h should really include this !!!!!!
-#include <plib/js.h>
-
-#include <jssuper.h>
-
-
-jsSuper::jsSuper(void) {
-  int i;
-
-  activeJoysticks=0;
-  currentJoystick=0;
-  first=-1;
-  last=0;
-  for ( i = 0; i < MAX_JOYSTICKS; i++ )
-      js[i] = new jsJoystick( i );
-  
-  for ( i = 0; i < MAX_JOYSTICKS; i++ )
-  { 
-    active[i] = ! ( js[i]->notWorking () );
-    if ( active[i] ) {
-         activeJoysticks++;
-         if(first < 0) {
-            first=i;
-         }
-         last=i;
-    }        
-  }
-  
-}  
-
-
-int jsSuper::nextJoystick(void) { 
-  int i;
-  if(!activeJoysticks) return 0;
-  if(currentJoystick == last ) return 0; 
-  currentJoystick++;
-  while(!active[currentJoystick]){ currentJoystick++; };
-  return 1;
-}    
-        
-int jsSuper::prevJoystick(void) { 
-  int i;
-  if(!activeJoysticks) return 0; 
-  if(currentJoystick == first ) return 0; 
-  currentJoystick--;
-  while(!active[currentJoystick]){ currentJoystick--; };
-  return 1;
-}    
-
-
-
-
-jsSuper::~jsSuper(void) {
-  int i;
-  for ( i = 0; i < MAX_JOYSTICKS; i++ )
-      delete js[i];
-}      
-  
-    
-
-    
-    
diff --git a/src/Joystick/jssuper.h b/src/Joystick/jssuper.h
deleted file mode 100644 (file)
index 356256d..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-// jssuper.h -- manage access to multiple joysticks
-//
-// Written by Tony Peden, started May 2001
-//
-// Copyright (C) 2001  Tony Peden (apeden@earthlink.net)
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-#ifndef _JSSUPER_H
-#define _JSSUPER_H
-
-
-#ifdef HAVE_WINDOWS_H
-#  include <windows.h>                     
-#endif
-
-#include <string.h>            // plib/js.h should really include this !!!!!!
-#include <plib/js.h>
-
-#define MAX_JOYSTICKS 8
-
-class jsSuper {
-  private:
-    int activeJoysticks;
-    int active[MAX_JOYSTICKS];
-    int currentJoystick;
-    int first, last;
-    jsJoystick* js[MAX_JOYSTICKS];
-    
-  public:  
-    jsSuper(void);
-    ~jsSuper(void);
-    
-    inline int getNumJoysticks(void) { return activeJoysticks; }
-    
-    inline int atFirst(void) { return currentJoystick == first; }
-    inline int atLast(void) { return currentJoystick == last; }
-    
-    inline void firstJoystick(void) { currentJoystick=first; }
-    inline void lastJoystick(void) { currentJoystick=last; }
-
-    int nextJoystick(void);
-    int prevJoystick(void);
-
-    inline jsJoystick* getJoystick(int Joystick) 
-            { currentJoystick=Joystick; return js[Joystick]; }
-
-    inline jsJoystick* getJoystick(void) { return js[currentJoystick]; }
-    
-    inline int getCurrentJoystickId(void) { return currentJoystick; }
-};
-    
-#endif