warn if InputHandler::UpdateTimer is not being called
This commit is contained in:
@@ -2,18 +2,40 @@
|
|||||||
#include "InputFilter.h"
|
#include "InputFilter.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "InputHandler.h"
|
#include "InputHandler.h"
|
||||||
|
#include "RageLog.h"
|
||||||
|
|
||||||
void InputHandler::UpdateTimer()
|
void InputHandler::UpdateTimer()
|
||||||
{
|
{
|
||||||
m_LastUpdate.Touch();
|
m_LastUpdate.Touch();
|
||||||
|
m_iInputsSinceUpdate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler::ButtonPressed( DeviceInput di, bool Down )
|
void InputHandler::ButtonPressed( DeviceInput di, bool Down )
|
||||||
{
|
{
|
||||||
if( di.ts.IsZero() )
|
if( di.ts.IsZero() )
|
||||||
|
{
|
||||||
di.ts = m_LastUpdate.Half();
|
di.ts = m_LastUpdate.Half();
|
||||||
|
++m_iInputsSinceUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
INPUTFILTER->ButtonPressed( di, Down );
|
INPUTFILTER->ButtonPressed( di, Down );
|
||||||
|
|
||||||
|
if( m_iInputsSinceUpdate >= 50 )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* We havn't received an update in a long time, so warn about it. We expect to receive
|
||||||
|
* input events before the first UpdateTimer call only on the first update. Leave
|
||||||
|
* m_iInputsSinceUpdate where it is, so we only warn once. Only updates that didn't provide
|
||||||
|
* a timestamp are counted; if the driver provides its own timestamps, UpdateTimer is
|
||||||
|
* optional.
|
||||||
|
*
|
||||||
|
* This can also happen if a device sends a lot of inputs at once; for example, a keyboard
|
||||||
|
* driver that sends every key in one frame. If that's really needed (wasteful), increase
|
||||||
|
* the threshold.
|
||||||
|
*/
|
||||||
|
LOG->Warn( "InputHandler::ButtonPressed: Driver sent 50 updates without calling UpdateTimer" );
|
||||||
|
FAIL_M("x");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -24,9 +24,8 @@
|
|||||||
|
|
||||||
class InputHandler
|
class InputHandler
|
||||||
{
|
{
|
||||||
RageTimer m_LastUpdate;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
InputHandler() { m_iInputsSinceUpdate = 0; }
|
||||||
virtual ~InputHandler() { }
|
virtual ~InputHandler() { }
|
||||||
virtual void Update(float fDeltaTime) { }
|
virtual void Update(float fDeltaTime) { }
|
||||||
virtual void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut) = 0;
|
virtual void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut) = 0;
|
||||||
@@ -53,6 +52,10 @@ protected:
|
|||||||
|
|
||||||
/* Call this at the end of polling input. */
|
/* Call this at the end of polling input. */
|
||||||
void UpdateTimer();
|
void UpdateTimer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
RageTimer m_LastUpdate;
|
||||||
|
int m_iInputsSinceUpdate;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user