]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/FGEventInput.hxx
Merge branch 'next' of 10.101.2.62:~/FlightGear/fg-osg/FlightGear into next
[flightgear.git] / src / Input / FGEventInput.hxx
index a3896e1d47a06497771dbe27b2c9fb6261160f29..7188c83813f112d844e0d2afae40a27c09465d34 100644 (file)
@@ -33,7 +33,7 @@
  * To be extended for O/S specific implementation data
  */
 struct FGEventData {
-  FGEventData( double aValue, double aDt, int aModifiers ) : value(aValue), dt(aDt), modifiers(aModifiers) {}
+  FGEventData( double aValue, double aDt, int aModifiers ) : modifiers(aModifiers), value(aValue), dt(aDt) {}
   int modifiers;
   double value;
   double dt;
@@ -83,6 +83,7 @@ typedef vector<FGEventSetting_ptr> setting_list_t;
 class FGInputDevice;
 class FGInputEvent : public SGReferenced,FGCommonInput {
 public:
+
   /*
    * Constructor for the class. The arg node shall point
    * to the property corresponding to the <event>  node
@@ -110,6 +111,7 @@ public:
   static FGInputEvent * NewObject( FGInputDevice * device, SGPropertyNode_ptr node );
 
 protected:
+  virtual void fire( SGBinding * binding, FGEventData & eventData );
   /* A more or less meaningfull description of the event */
   string desc;
 
@@ -143,6 +145,9 @@ protected:
 class FGAxisEvent : public FGInputEvent {
 public:
   FGAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node );
+  void SetMaxRange( double value ) { maxRange = value; }
+  void SetMinRange( double value ) { minRange = value; }
+  void SetRange( double min, double max ) { minRange = min; maxRange = max; }
 protected:
   virtual void fire( FGEventData & eventData );
   double tolerance;
@@ -155,6 +160,20 @@ protected:
   double lastValue;
 };
 
+class FGRelAxisEvent : public FGAxisEvent {
+public:
+  FGRelAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node );
+protected:
+  virtual void fire( SGBinding * binding, FGEventData & eventData );
+};
+
+class FGAbsAxisEvent : public FGAxisEvent {
+public:
+  FGAbsAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ) : FGAxisEvent( device, node ) {}
+protected:
+  virtual void fire( SGBinding * binding, FGEventData & eventData );
+};
+
 typedef class SGSharedPtr<FGInputEvent> FGInputEvent_ptr;
 
 /*
@@ -164,7 +183,7 @@ typedef class SGSharedPtr<FGInputEvent> FGInputEvent_ptr;
  */
 class FGInputDevice : public SGReferenced {
 public:
-  FGInputDevice() : debugEvents(false) {}
+  FGInputDevice() : debugEvents(false), grab(false) {}
   FGInputDevice( string aName ) : name(aName) {}
     
   virtual ~FGInputDevice();
@@ -191,10 +210,15 @@ public:
       handledEvents[handledEvent->GetName()] = handledEvent;
   }
 
+  virtual void Configure( SGPropertyNode_ptr deviceNode );
+
   virtual void update( double dt );
 
   bool GetDebugEvents () const { return debugEvents; }
-  void SetDebugEvents( bool value ) { debugEvents = value; }
+
+  bool GetGrab() const { return grab; }
+
+  const string & GetNasalModule() const { return nasalModule; }
 
 private:
   // A map of events, this device handles
@@ -206,6 +230,13 @@ private:
   // print out events comming in from the device
   // if true
   bool   debugEvents;
+
+  // grab the device exclusively, if O/S supports this
+  // so events are not sent to other applications
+  bool   grab;
+
+  SGPropertyNode_ptr deviceNode;
+  string nasalModule;
 };
 
 typedef SGSharedPtr<FGInputDevice> FGInputDevice_ptr;
@@ -222,12 +253,18 @@ public:
   virtual void postinit();
   virtual void update( double dt );
 
+  const static unsigned MAX_DEVICES = 1000;
+  const static unsigned INVALID_DEVICE_INDEX = MAX_DEVICES + 1;
 protected:
   static const char * PROPERTY_ROOT;
 
-  void AddDevice( FGInputDevice * inputDevice );
+  unsigned AddDevice( FGInputDevice * inputDevice );
+  void RemoveDevice( unsigned index );
+
   map<int,FGInputDevice*> input_devices;
   FGDeviceConfigurationMap configMap;
+
+  SGPropertyNode_ptr nasalClose;
 };
 
 #endif