diff options
| author | 2021-03-06 13:27:02 -0600 | |
|---|---|---|
| committer | 2021-03-06 13:27:02 -0600 | |
| commit | 41e94b7b99f83a45633d555160b31b50f021c350 (patch) | |
| tree | 3383b74713144712144eeb5cb6a247ba4be9da42 /src/input_common/keyboard.cpp | |
| parent | Add toggle button option for normal buttons (diff) | |
| download | yuzu-41e94b7b99f83a45633d555160b31b50f021c350.tar.gz yuzu-41e94b7b99f83a45633d555160b31b50f021c350.tar.xz yuzu-41e94b7b99f83a45633d555160b31b50f021c350.zip | |
Enable mouse toggle buttons
Diffstat (limited to 'src/input_common/keyboard.cpp')
| -rw-r--r-- | src/input_common/keyboard.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/input_common/keyboard.cpp b/src/input_common/keyboard.cpp index fa0e60ac1..c467ff4c5 100644 --- a/src/input_common/keyboard.cpp +++ b/src/input_common/keyboard.cpp | |||
| @@ -19,16 +19,18 @@ public: | |||
| 19 | 19 | ||
| 20 | bool GetStatus() const override { | 20 | bool GetStatus() const override { |
| 21 | if (toggle) { | 21 | if (toggle) { |
| 22 | return toggled_status.load(); | 22 | return toggled_status.load(std::memory_order_relaxed); |
| 23 | } | 23 | } |
| 24 | return status.load(); | 24 | return status.load(); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | void ToggleButton() { | 27 | void ToggleButton() { |
| 28 | if (!lock) { | 28 | if (lock) { |
| 29 | lock = true; | 29 | return; |
| 30 | toggled_status.store(!toggled_status.load()); | ||
| 31 | } | 30 | } |
| 31 | lock = true; | ||
| 32 | const bool old_toggle_status = toggled_status.load(); | ||
| 33 | toggled_status.store(!old_toggle_status); | ||
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | void UnlockButton() { | 36 | void UnlockButton() { |
| @@ -41,7 +43,7 @@ private: | |||
| 41 | std::shared_ptr<KeyButtonList> key_button_list; | 43 | std::shared_ptr<KeyButtonList> key_button_list; |
| 42 | std::atomic<bool> status{false}; | 44 | std::atomic<bool> status{false}; |
| 43 | std::atomic<bool> toggled_status{false}; | 45 | std::atomic<bool> toggled_status{false}; |
| 44 | bool lock = {}; | 46 | bool lock{false}; |
| 45 | const bool toggle; | 47 | const bool toggle; |
| 46 | }; | 48 | }; |
| 47 | 49 | ||