]> git.mxchange.org Git - flightgear.git/commitdiff
Add a debug property to make devices print out incoming events on the console.
authortorsten <torsten>
Wed, 12 Aug 2009 06:08:12 +0000 (06:08 +0000)
committerTim Moore <timoore@redhat.com>
Wed, 12 Aug 2009 21:45:55 +0000 (23:45 +0200)
src/Input/FGEventInput.cxx
src/Input/FGEventInput.hxx
src/Input/FGLinuxEventInput.cxx

index f47a6161aeae737a35edbbb768c8d88e58d34c25..3acf7b93c0c870b2164e19c86033457beef84218 100644 (file)
@@ -192,7 +192,10 @@ void FGInputDevice::update( double dt )
 void FGInputDevice::HandleEvent( FGEventData & eventData )
 {
   string eventName = TranslateEventName( eventData );  
-//  cout << GetName() << " has event " << eventName << " modifiers=" << eventData.modifiers << " value=" << eventData.value << endl;
+  if( debugEvents )
+    cout << GetName() << " has event " << 
+    eventName << " modifiers=" << eventData.modifiers << " value=" << eventData.value << endl;
+
   if( handledEvents.count( eventName ) > 0 ) {
     handledEvents[ eventName ]->fire( eventData );
   }
@@ -272,6 +275,8 @@ void FGEventInput::AddDevice( FGInputDevice * inputDevice )
   for( vector<SGPropertyNode_ptr>::iterator it = eventNodes.begin(); it != eventNodes.end(); it++ )
     inputDevice->AddHandledEvent( FGInputEvent::NewObject( inputDevice, *it ) );
 
+  inputDevice->SetDebugEvents( deviceNode->getBoolValue("debug-events", inputDevice->GetDebugEvents() ));
+
   // TODO:
   // add nodes for the last event:
   // last-event/name [string]
index 7a7323d4370dd5a5903a0344a5abb1c7348b20fd..a3896e1d47a06497771dbe27b2c9fb6261160f29 100644 (file)
@@ -164,7 +164,7 @@ typedef class SGSharedPtr<FGInputEvent> FGInputEvent_ptr;
  */
 class FGInputDevice : public SGReferenced {
 public:
-  FGInputDevice() {}
+  FGInputDevice() : debugEvents(false) {}
   FGInputDevice( string aName ) : name(aName) {}
     
   virtual ~FGInputDevice();
@@ -193,12 +193,19 @@ public:
 
   virtual void update( double dt );
 
+  bool GetDebugEvents () const { return debugEvents; }
+  void SetDebugEvents( bool value ) { debugEvents = value; }
+
 private:
   // A map of events, this device handles
   map<string,FGInputEvent_ptr> handledEvents;
 
   // the device has a name to be recognized
   string name;
+
+  // print out events comming in from the device
+  // if true
+  bool   debugEvents;
 };
 
 typedef SGSharedPtr<FGInputDevice> FGInputDevice_ptr;
index eb191f52402008a12aff0df126b3cffd54f0790a..ec0f23da2c6b4843a751c80ddf09e48ac419e675 100644 (file)
@@ -252,15 +252,6 @@ void FGLinuxInputDevice::Open()
   if( (fd = ::open( devname.c_str(), O_RDWR )) == -1 ) { 
     throw exception();
   }
-/*
-  input_event evt;
-  evt.type=EV_LED;
-  evt.code = 8;
-  evt.value = 1;
-  evt.time.tv_sec = 0;
-  evt.time.tv_usec = 0;
-  write( fd, &evt, sizeof(evt) );
-*/
 }
 
 void FGLinuxInputDevice::Close()