Include the complete input state with each input report.
This only deals with buttons being held, so won't cause performance issues. This deals with a general problem of the input layer: you can query the current state of the inputs, but inputs are received in a queue, causing inconsistencies. This is why pressing enter during a load, then holding Alt after pressing it, causes the game to switch fullscreen after the load finishes; checking for "alt-enter" should be checking if Alt was pressed when Enter was pressed, not whether it's pressed right now. Similarly, CodeDetector has difficulty handling a "Right-Left" and a "Left-Right" code simultaneously. If both buttons are pressed quickly, it needs to check whether Right was pressed at the time Left was reported, not at the time EnteredCode was called.
This commit is contained in:
@@ -32,6 +32,9 @@ struct InputEvent
|
||||
|
||||
DeviceInput di;
|
||||
InputEventType type;
|
||||
|
||||
/* A list of all buttons that were pressed at the time of this event: */
|
||||
DeviceInputList m_ButtonState;
|
||||
};
|
||||
|
||||
class RageMutex;
|
||||
@@ -52,8 +55,9 @@ public:
|
||||
void ResetRepeatRate();
|
||||
void ResetKeyRepeat( const DeviceInput &di );
|
||||
|
||||
bool IsBeingPressed( const DeviceInput &di );
|
||||
float GetSecsHeld( const DeviceInput &di );
|
||||
// If aButtonState is NULL, use the last reported state.
|
||||
bool IsBeingPressed( const DeviceInput &di, const DeviceInputList *pButtonState = NULL );
|
||||
float GetSecsHeld( const DeviceInput &di, const DeviceInputList *pButtonState = NULL );
|
||||
RString GetButtonComment( const DeviceInput &di ) const;
|
||||
|
||||
void GetInputEvents( vector<InputEvent> &aEventOut );
|
||||
@@ -62,6 +66,7 @@ public:
|
||||
private:
|
||||
void CheckButtonChange( ButtonState &bs, DeviceInput di, const RageTimer &now );
|
||||
void ReportButtonChange( const DeviceInput &di, InputEventType t );
|
||||
void MakeButtonStateList( vector<DeviceInput> &aInputOut ) const;
|
||||
|
||||
vector<InputEvent> queue;
|
||||
RageMutex *queuemutex;
|
||||
|
||||
Reference in New Issue
Block a user