diff --git a/CHANGES b/CHANGES index 8d475a17b..9a27ae488 100644 --- a/CHANGES +++ b/CHANGES @@ -30,6 +30,7 @@ Misc: - Qt: Set default log level to FATAL, ERROR and WARN - Qt: Clarify some phrasing in the menus - GBA Memory: Implement 16- and 32-bit loads from SRAM + - Qt: Clear active buttons when focus is lost 0.1.0: (2014-12-13) - Initial release diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 2c3ec3074..1d6d6522e 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -272,6 +272,11 @@ void GameController::keyReleased(int key) { updateKeys(); } +void GameController::clearKeys() { + m_activeKeys = 0; + updateKeys(); +} + void GameController::setAudioBufferSamples(int samples) { if (m_gameOpen) { threadInterrupt(); diff --git a/src/platform/qt/GameController.h b/src/platform/qt/GameController.h index b3b89ca19..75cbb2054 100644 --- a/src/platform/qt/GameController.h +++ b/src/platform/qt/GameController.h @@ -80,6 +80,7 @@ public slots: void frameAdvance(); void keyPressed(int key); void keyReleased(int key); + void clearKeys(); void setAudioBufferSamples(int samples); void setFPSTarget(float fps); void loadState(int slot); diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 70660da7b..2ae9f6c53 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -280,6 +280,11 @@ void Window::closeEvent(QCloseEvent* event) { QMainWindow::closeEvent(event); } +void Window::focusOutEvent(QFocusEvent*) { + m_controller->setTurbo(false, false); + m_controller->clearKeys(); +} + void Window::toggleFullScreen() { if (isFullScreen()) { showNormal(); diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index d7d588b36..048ae3870 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -83,6 +83,7 @@ protected: virtual void keyReleaseEvent(QKeyEvent* event) override; virtual void resizeEvent(QResizeEvent*) override; virtual void closeEvent(QCloseEvent*) override; + virtual void focusOutEvent(QFocusEvent*) override; private slots: void gameStarted(GBAThread*);