From 7bd29d6e44c60a7812c499879e160d3a95e53f25 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 3 Aug 2017 22:20:43 -0700 Subject: [PATCH] Qt: Fix autofire --- src/platform/qt/CoreController.cpp | 14 ++++++++------ src/platform/qt/CoreController.h | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/platform/qt/CoreController.cpp b/src/platform/qt/CoreController.cpp index 286f3dc4d..00c40e1a9 100644 --- a/src/platform/qt/CoreController.cpp +++ b/src/platform/qt/CoreController.cpp @@ -209,12 +209,13 @@ QSize CoreController::screenDimensions() const { void CoreController::loadConfig(ConfigController* config) { Interrupter interrupter(this); - m_loadStateFlags = config->getOption("loadStateExtdata").toInt(); - m_saveStateFlags = config->getOption("saveStateExtdata").toInt(); - m_fastForwardRatio = config->getOption("fastForwardRatio").toFloat(); - m_videoSync = config->getOption("videoSync").toInt(); - m_audioSync = config->getOption("audioSync").toInt(); + m_loadStateFlags = config->getOption("loadStateExtdata", m_loadStateFlags).toInt(); + m_saveStateFlags = config->getOption("saveStateExtdata", m_saveStateFlags).toInt(); + m_fastForwardRatio = config->getOption("fastForwardRatio", m_fastForwardRatio).toFloat(); + m_videoSync = config->getOption("videoSync", m_videoSync).toInt(); + m_audioSync = config->getOption("audioSync", m_audioSync).toInt(); m_fpsTarget = config->getOption("fpsTarget").toFloat(); + m_autofireThreshold = config->getOption("autofireThreshold", m_autofireThreshold).toInt(); updateFastForward(); mCoreLoadForeignConfig(m_threadContext.core, config->config()); mCoreThreadRewindParamsChanged(&m_threadContext); @@ -706,8 +707,9 @@ int CoreController::updateAutofire() { continue; } ++m_autofireStatus[k]; - if (m_autofireStatus[k]) { + if (m_autofireStatus[k] >= 2 * m_autofireThreshold) { m_autofireStatus[k] = 0; + } else if (m_autofireStatus[k] >= m_autofireThreshold) { active |= 1 << k; } } diff --git a/src/platform/qt/CoreController.h b/src/platform/qt/CoreController.h index 13c79e56c..4cd1a9f05 100644 --- a/src/platform/qt/CoreController.h +++ b/src/platform/qt/CoreController.h @@ -184,6 +184,7 @@ private: int m_activeKeys = 0; bool m_autofire[32] = {}; int m_autofireStatus[32] = {}; + int m_autofireThreshold = 1; VFileDevice m_backupLoadState; QByteArray m_backupSaveState{nullptr};