1
0
Fork 0

Event input: button fire repeat

This commit is contained in:
James Turner 2019-05-30 09:53:56 +01:00
parent 5ffe96237f
commit 0bea6153b0
2 changed files with 11 additions and 1 deletions

View file

@ -242,6 +242,15 @@ void FGButtonEvent::fire( FGEventData & eventData )
lastState = pressed; lastState = pressed;
} }
void FGButtonEvent::update( double dt )
{
if (repeatable && lastState) {
// interval / dt handling is done by base ::fire method
FGEventData ed{1.0, dt, 0 /* modifiers */};
FGInputEvent::fire( ed );
}
}
FGInputDevice::~FGInputDevice() FGInputDevice::~FGInputDevice()
{ {
FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal"); FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");

View file

@ -175,6 +175,7 @@ public:
FGButtonEvent( FGInputDevice * device, SGPropertyNode_ptr node ); FGButtonEvent( FGInputDevice * device, SGPropertyNode_ptr node );
virtual void fire( FGEventData & eventData ); virtual void fire( FGEventData & eventData );
void update( double dt ) override;
protected: protected:
bool repeatable; bool repeatable;
bool lastState; bool lastState;