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 );
}
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]
*/
class FGInputDevice : public SGReferenced {
public:
- FGInputDevice() {}
+ FGInputDevice() : debugEvents(false) {}
FGInputDevice( string aName ) : name(aName) {}
virtual ~FGInputDevice();
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;
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()