From 5245c86f2662caa0e1e4b20508608b11237993b3 Mon Sep 17 00:00:00 2001 From: wwylele Date: Fri, 17 Mar 2017 21:41:25 +0200 Subject: citra-qt: release all buttons when render window focus is lost credit to @Hawkheart for the original idea --- src/input_common/keyboard.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/input_common/keyboard.cpp') diff --git a/src/input_common/keyboard.cpp b/src/input_common/keyboard.cpp index a8fc01f2e..0f0d10f23 100644 --- a/src/input_common/keyboard.cpp +++ b/src/input_common/keyboard.cpp @@ -53,6 +53,13 @@ public: } } + void ChangeAllKeyStatus(bool pressed) { + std::lock_guard guard(mutex); + for (const KeyButtonPair& pair : list) { + pair.key_button->status.store(pressed); + } + } + private: std::mutex mutex; std::list list; @@ -79,4 +86,8 @@ void Keyboard::ReleaseKey(int key_code) { key_button_list->ChangeKeyStatus(key_code, false); } +void Keyboard::ReleaseAllKeys() { + key_button_list->ChangeAllKeyStatus(false); +} + } // namespace InputCommon -- cgit v1.2.3