diff --git a/src/Input/FGEventInput.cxx b/src/Input/FGEventInput.cxx index f47a6161a..3acf7b93c 100644 --- a/src/Input/FGEventInput.cxx +++ b/src/Input/FGEventInput.cxx @@ -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::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] diff --git a/src/Input/FGEventInput.hxx b/src/Input/FGEventInput.hxx index 7a7323d43..a3896e1d4 100644 --- a/src/Input/FGEventInput.hxx +++ b/src/Input/FGEventInput.hxx @@ -164,7 +164,7 @@ typedef class SGSharedPtr 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 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_ptr; diff --git a/src/Input/FGLinuxEventInput.cxx b/src/Input/FGLinuxEventInput.cxx index eb191f524..ec0f23da2 100644 --- a/src/Input/FGLinuxEventInput.cxx +++ b/src/Input/FGLinuxEventInput.cxx @@ -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()