Input: Hack around desync with mkxpRawKeyStates

Make sure that when mkxpRawKeyStates was called, the Input module
will work off of the same queried snapshot of pressed keys
during the next update call.
This commit is contained in:
Jonas Kulla 2017-03-21 10:47:32 +01:00
parent ea742be6b0
commit ef06c8eca4
2 changed files with 25 additions and 6 deletions

View file

@ -66,6 +66,9 @@ struct Binding
Input::ButtonCode target;
};
// binding-mri.cpp
extern uint8_t *keyStatesMirror;
/* Keyboard binding */
struct KbBinding : public Binding
{
@ -80,14 +83,14 @@ struct KbBinding : public Binding
{
/* Special case aliases */
if (source == SDL_SCANCODE_LSHIFT)
return EventThread::keyStates[source]
|| EventThread::keyStates[SDL_SCANCODE_RSHIFT];
return keyStatesMirror[source]
|| keyStatesMirror[SDL_SCANCODE_RSHIFT];
if (source == SDL_SCANCODE_RETURN)
return EventThread::keyStates[source]
|| EventThread::keyStates[SDL_SCANCODE_KP_ENTER];
return keyStatesMirror[source]
|| keyStatesMirror[SDL_SCANCODE_KP_ENTER];
return EventThread::keyStates[source];
return keyStatesMirror[source];
}
bool sourceRepeatable() const
@ -607,6 +610,9 @@ void Input::update()
/* Poll all bindings */
p->pollBindings(repeatCand);
// reset keystate source from potential mirror to EventThread source array
keyStatesMirror = EventThread::keyStates;
/* Check for new repeating key */
if (repeatCand != None && repeatCand != p->repeating)
{