diff options
| author | 2017-03-17 21:41:25 +0200 | |
|---|---|---|
| committer | 2017-03-17 21:41:25 +0200 | |
| commit | 5245c86f2662caa0e1e4b20508608b11237993b3 (patch) | |
| tree | 5e489260c666bf8f09891e7678bfa5661dfd1c8c /src/input_common/keyboard.cpp | |
| parent | Merge pull request #2497 from wwylele/input-2 (diff) | |
| download | yuzu-5245c86f2662caa0e1e4b20508608b11237993b3.tar.gz yuzu-5245c86f2662caa0e1e4b20508608b11237993b3.tar.xz yuzu-5245c86f2662caa0e1e4b20508608b11237993b3.zip | |
citra-qt: release all buttons when render window focus is lost
credit to @Hawkheart for the original idea
Diffstat (limited to 'src/input_common/keyboard.cpp')
| -rw-r--r-- | src/input_common/keyboard.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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: | |||
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | void ChangeAllKeyStatus(bool pressed) { | ||
| 57 | std::lock_guard<std::mutex> guard(mutex); | ||
| 58 | for (const KeyButtonPair& pair : list) { | ||
| 59 | pair.key_button->status.store(pressed); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 56 | private: | 63 | private: |
| 57 | std::mutex mutex; | 64 | std::mutex mutex; |
| 58 | std::list<KeyButtonPair> list; | 65 | std::list<KeyButtonPair> list; |
| @@ -79,4 +86,8 @@ void Keyboard::ReleaseKey(int key_code) { | |||
| 79 | key_button_list->ChangeKeyStatus(key_code, false); | 86 | key_button_list->ChangeKeyStatus(key_code, false); |
| 80 | } | 87 | } |
| 81 | 88 | ||
| 89 | void Keyboard::ReleaseAllKeys() { | ||
| 90 | key_button_list->ChangeAllKeyStatus(false); | ||
| 91 | } | ||
| 92 | |||
| 82 | } // namespace InputCommon | 93 | } // namespace InputCommon |