summaryrefslogtreecommitdiff
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/mouse/mouse_input.cpp11
-rw-r--r--src/input_common/mouse/mouse_input.h12
2 files changed, 15 insertions, 8 deletions
diff --git a/src/input_common/mouse/mouse_input.cpp b/src/input_common/mouse/mouse_input.cpp
index 6818d5eee..329e416c7 100644
--- a/src/input_common/mouse/mouse_input.cpp
+++ b/src/input_common/mouse/mouse_input.cpp
@@ -59,7 +59,7 @@ void Mouse::UpdateYuzuSettings() {
59 }); 59 });
60} 60}
61 61
62void Mouse::PressButton(int x, int y, int button_) { 62void Mouse::PressButton(int x, int y, MouseButton button_) {
63 const auto button_index = static_cast<std::size_t>(button_); 63 const auto button_index = static_cast<std::size_t>(button_);
64 if (button_index >= mouse_info.size()) { 64 if (button_index >= mouse_info.size()) {
65 return; 65 return;
@@ -67,7 +67,7 @@ void Mouse::PressButton(int x, int y, int button_) {
67 67
68 const auto button = 1U << button_index; 68 const auto button = 1U << button_index;
69 buttons |= static_cast<u16>(button); 69 buttons |= static_cast<u16>(button);
70 last_button = static_cast<MouseButton>(button_index); 70 last_button = button_;
71 71
72 mouse_info[button_index].mouse_origin = Common::MakeVec(x, y); 72 mouse_info[button_index].mouse_origin = Common::MakeVec(x, y);
73 mouse_info[button_index].last_mouse_position = Common::MakeVec(x, y); 73 mouse_info[button_index].last_mouse_position = Common::MakeVec(x, y);
@@ -129,7 +129,7 @@ void Mouse::MouseMove(int x, int y, int center_x, int center_y) {
129 } 129 }
130} 130}
131 131
132void Mouse::ReleaseButton(int button_) { 132void Mouse::ReleaseButton(MouseButton button_) {
133 const auto button_index = static_cast<std::size_t>(button_); 133 const auto button_index = static_cast<std::size_t>(button_);
134 if (button_index >= mouse_info.size()) { 134 if (button_index >= mouse_info.size()) {
135 return; 135 return;
@@ -152,6 +152,11 @@ void Mouse::BeginConfiguration() {
152 152
153void Mouse::EndConfiguration() { 153void Mouse::EndConfiguration() {
154 buttons = 0; 154 buttons = 0;
155 for (MouseInfo& info : mouse_info) {
156 info.tilt_speed = 0;
157 info.data.pressed = false;
158 info.data.axis = {0, 0};
159 }
155 last_button = MouseButton::Undefined; 160 last_button = MouseButton::Undefined;
156 mouse_queue.Clear(); 161 mouse_queue.Clear();
157 configuring = false; 162 configuring = false;
diff --git a/src/input_common/mouse/mouse_input.h b/src/input_common/mouse/mouse_input.h
index a75f0ecb5..750d9b011 100644
--- a/src/input_common/mouse/mouse_input.h
+++ b/src/input_common/mouse/mouse_input.h
@@ -18,10 +18,12 @@ namespace MouseInput {
18 18
19enum class MouseButton { 19enum class MouseButton {
20 Left, 20 Left,
21 Wheel,
22 Right, 21 Right,
23 Forward, 22 Wheel,
24 Backward, 23 Backward,
24 Forward,
25 Task,
26 Extra,
25 Undefined, 27 Undefined,
26}; 28};
27 29
@@ -51,7 +53,7 @@ public:
51 * @param y the y-coordinate of the cursor 53 * @param y the y-coordinate of the cursor
52 * @param button_ the button pressed 54 * @param button_ the button pressed
53 */ 55 */
54 void PressButton(int x, int y, int button_); 56 void PressButton(int x, int y, MouseButton button_);
55 57
56 /** 58 /**
57 * Signals that mouse has moved. 59 * Signals that mouse has moved.
@@ -65,7 +67,7 @@ public:
65 /** 67 /**
66 * Signals that a motion sensor tilt has ended. 68 * Signals that a motion sensor tilt has ended.
67 */ 69 */
68 void ReleaseButton(int button_); 70 void ReleaseButton(MouseButton button_);
69 71
70 [[nodiscard]] bool ToggleButton(std::size_t button_); 72 [[nodiscard]] bool ToggleButton(std::size_t button_);
71 [[nodiscard]] bool UnlockButton(std::size_t button_); 73 [[nodiscard]] bool UnlockButton(std::size_t button_);
@@ -99,7 +101,7 @@ private:
99 u16 lock_buttons{}; 101 u16 lock_buttons{};
100 std::thread update_thread; 102 std::thread update_thread;
101 MouseButton last_button{MouseButton::Undefined}; 103 MouseButton last_button{MouseButton::Undefined};
102 std::array<MouseInfo, 5> mouse_info; 104 std::array<MouseInfo, 7> mouse_info;
103 Common::SPSCQueue<MouseStatus> mouse_queue; 105 Common::SPSCQueue<MouseStatus> mouse_queue;
104 bool configuring{false}; 106 bool configuring{false};
105 bool update_thread_running{true}; 107 bool update_thread_running{true};