AGS: in the new key input mode, only update key state once a frame

From upstream 8c456d2e4b3c9e24f883522b59b4c73d422e4c28

Not sure if this will actually do so, since there may be other places
in the ScummVM event handler where event polling may be done.
This commit is contained in:
Paul Gilbert 2022-04-27 19:31:40 -07:00
parent a302d96a28
commit ae0609ae51
3 changed files with 5 additions and 4 deletions

View File

@ -79,7 +79,7 @@ Common::Event ags_get_next_keyevent() {
}
int ags_iskeydown(eAGSKeyCode ags_key) {
return ::AGS::g_events->isKeyPressed(ags_key);
return ::AGS::g_events->isKeyPressed(ags_key, _GP(game).options[OPT_KEYHANDLEAPI] == 0);
}
void ags_simulate_keypress(eAGSKeyCode ags_key) {

View File

@ -157,8 +157,9 @@ void EventsManager::updateKeys(const Common::Event &event, bool isDown) {
_keys[event.kbd.keycode] = isDown;
}
bool EventsManager::isKeyPressed(AGS3::eAGSKeyCode key) {
pollEvents();
bool EventsManager::isKeyPressed(AGS3::eAGSKeyCode key, bool poll) {
if (poll)
pollEvents();
Common::KeyCode kc[3];
if (!ags_key_to_scancode(key, kc))

View File

@ -105,7 +105,7 @@ public:
/**
* Returns true if a given key is pressed
*/
bool isKeyPressed(AGS3::eAGSKeyCode key);
bool isKeyPressed(AGS3::eAGSKeyCode key, bool poll = true);
void clearEvents() {
_pendingEvents.clear();