Qt: Poll current keys in case some external force has changed them

This commit is contained in:
Vicki Pfau 2022-05-16 01:07:17 -07:00
parent af043e0792
commit 6f09085676
2 changed files with 6 additions and 1 deletions

View File

@ -859,6 +859,7 @@ void CoreController::addKey(int key) {
void CoreController::clearKey(int key) {
m_activeKeys &= ~(1 << key);
m_removedKeys |= 1 << key;
}
void CoreController::setAutofire(int key, bool enable) {
@ -1145,7 +1146,10 @@ void CoreController::setFramebufferHandle(int fb) {
}
void CoreController::updateKeys() {
int activeKeys = m_activeKeys | updateAutofire() | m_inputController->pollEvents();
int polledKeys = m_inputController->pollEvents() | updateAutofire();
int activeKeys = m_activeKeys | polledKeys;
activeKeys |= m_threadContext.core->getKeys(m_threadContext.core) & ~m_removedKeys;
m_removedKeys = polledKeys;
m_threadContext.core->setKeys(m_threadContext.core, activeKeys);
}

View File

@ -265,6 +265,7 @@ private:
QMutex m_bufferMutex;
int m_activeKeys = 0;
int m_removedKeys = 0;
bool m_autofire[32] = {};
int m_autofireStatus[32] = {};
int m_autofireThreshold = 1;