From 218ad5c89ecc61d4c910c65381d2742c649ca04b Mon Sep 17 00:00:00 2001 From: Aidan Noll Date: Fri, 27 Jan 2017 15:22:45 -0500 Subject: [PATCH] citra-qt: release all buttons when render window focus is lost --- src/citra_qt/bootmanager.cpp | 4 ++++ src/citra_qt/bootmanager.h | 2 ++ src/core/frontend/key_map.cpp | 12 ++++++++++++ src/core/frontend/key_map.h | 5 +++++ 4 files changed, 23 insertions(+) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 948db384d..64b79c138 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -230,6 +230,10 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { motion_emu->EndTilt(); } +void GRenderWindow::focusOutEvent(QFocusEvent* event) { + KeyMap::ReleaseAllKeys(*this); +} + void GRenderWindow::ReloadSetKeymaps() { KeyMap::ClearKeyMapping(keyboard_id); for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index 7dac1c480..ad74097df 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -127,6 +127,8 @@ public: void mouseMoveEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; + void focusOutEvent(QFocusEvent* event) override; + void ReloadSetKeymaps() override; void OnClientAreaResized(unsigned width, unsigned height); diff --git a/src/core/frontend/key_map.cpp b/src/core/frontend/key_map.cpp index 15f0e079c..000a88ea6 100644 --- a/src/core/frontend/key_map.cpp +++ b/src/core/frontend/key_map.cpp @@ -149,4 +149,16 @@ void ReleaseKey(EmuWindow& emu_window, HostDeviceKey key) { } } } + +void ReleaseAllKeys(EmuWindow& emu_window) { + // Release "all" of the buttons. + emu_window.ButtonReleased({0xFFFFFFFF}); + + circle_pad_up = false; + circle_pad_right = false; + circle_pad_left = false; + circle_pad_right = false; + circle_pad_modifier = false; + UpdateCirclePad(emu_window); +} } diff --git a/src/core/frontend/key_map.h b/src/core/frontend/key_map.h index 040794578..9d65f1d55 100644 --- a/src/core/frontend/key_map.h +++ b/src/core/frontend/key_map.h @@ -90,4 +90,9 @@ void PressKey(EmuWindow& emu_window, HostDeviceKey key); * Maps a key release action and call the corresponding function in EmuWindow */ void ReleaseKey(EmuWindow& emu_window, HostDeviceKey key); + +/** +* Releases all pressed keys and resets the circle pad state to the center. +*/ +void ReleaseAllKeys(EmuWindow& emu_window); }