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/mouse/mouse_input.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/mouse/mouse_input.cpp')
| -rw-r--r-- | src/input_common/mouse/mouse_input.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/input_common/mouse/mouse_input.cpp b/src/input_common/mouse/mouse_input.cpp index b864d26f2..6818d5eee 100644 --- a/src/input_common/mouse/mouse_input.cpp +++ b/src/input_common/mouse/mouse_input.cpp | |||
| @@ -157,6 +157,42 @@ void Mouse::EndConfiguration() { | |||
| 157 | configuring = false; | 157 | configuring = false; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | bool Mouse::ToggleButton(std::size_t button_) { | ||
| 161 | if (button_ >= mouse_info.size()) { | ||
| 162 | return false; | ||
| 163 | } | ||
| 164 | const auto button = 1U << button_; | ||
| 165 | const bool button_state = (toggle_buttons & button) != 0; | ||
| 166 | const bool button_lock = (lock_buttons & button) != 0; | ||
| 167 | |||
| 168 | if (button_lock) { | ||
| 169 | return button_state; | ||
| 170 | } | ||
| 171 | |||
| 172 | lock_buttons |= static_cast<u16>(button); | ||
| 173 | |||
| 174 | if (button_state) { | ||
| 175 | toggle_buttons &= static_cast<u16>(0xFF - button); | ||
| 176 | } else { | ||
| 177 | toggle_buttons |= static_cast<u16>(button); | ||
| 178 | } | ||
| 179 | |||
| 180 | return !button_state; | ||
| 181 | } | ||
| 182 | |||
| 183 | bool Mouse::UnlockButton(std::size_t button_) { | ||
| 184 | if (button_ >= mouse_info.size()) { | ||
| 185 | return false; | ||
| 186 | } | ||
| 187 | |||
| 188 | const auto button = 1U << button_; | ||
| 189 | const bool button_state = (toggle_buttons & button) != 0; | ||
| 190 | |||
| 191 | lock_buttons &= static_cast<u16>(0xFF - button); | ||
| 192 | |||
| 193 | return button_state; | ||
| 194 | } | ||
| 195 | |||
| 160 | Common::SPSCQueue<MouseStatus>& Mouse::GetMouseQueue() { | 196 | Common::SPSCQueue<MouseStatus>& Mouse::GetMouseQueue() { |
| 161 | return mouse_queue; | 197 | return mouse_queue; |
| 162 | } | 198 | } |