summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers/mouse.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/drivers/mouse.cpp')
-rw-r--r--src/input_common/drivers/mouse.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp
index afa92b458..478737db2 100644
--- a/src/input_common/drivers/mouse.cpp
+++ b/src/input_common/drivers/mouse.cpp
@@ -12,6 +12,10 @@
#include "input_common/drivers/mouse.h"
namespace InputCommon {
+constexpr int mouse_axis_x = 0;
+constexpr int mouse_axis_y = 1;
+constexpr int wheel_axis_x = 2;
+constexpr int wheel_axis_y = 3;
constexpr int touch_axis_x = 10;
constexpr int touch_axis_y = 11;
constexpr PadIdentifier identifier = {
@@ -22,6 +26,12 @@ constexpr PadIdentifier identifier = {
Mouse::Mouse(const std::string input_engine_) : InputEngine(input_engine_) {
PreSetController(identifier);
+ PreSetAxis(identifier, mouse_axis_x);
+ PreSetAxis(identifier, mouse_axis_y);
+ PreSetAxis(identifier, wheel_axis_x);
+ PreSetAxis(identifier, wheel_axis_y);
+ PreSetAxis(identifier, touch_axis_x);
+ PreSetAxis(identifier, touch_axis_x);
update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); });
}
@@ -34,14 +44,18 @@ void Mouse::UpdateThread(std::stop_token stop_token) {
last_mouse_change *= 0.96f;
const float sensitivity =
Settings::values.mouse_panning_sensitivity.GetValue() * 0.022f;
- SetAxis(identifier, 0, last_mouse_change.x * sensitivity);
- SetAxis(identifier, 1, -last_mouse_change.y * sensitivity);
+ SetAxis(identifier, mouse_axis_x, last_mouse_change.x * sensitivity);
+ SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity);
}
if (mouse_panning_timout++ > 20) {
StopPanning();
}
std::this_thread::sleep_for(std::chrono::milliseconds(update_time));
+
+ // Reset wheel position
+ SetAxis(identifier, wheel_axis_x, 0);
+ SetAxis(identifier, wheel_axis_y, 0);
}
}
@@ -89,8 +103,8 @@ void Mouse::MouseMove(int x, int y, f32 touch_x, f32 touch_y, int center_x, int
if (button_pressed) {
const auto mouse_move = Common::MakeVec<int>(x, y) - mouse_origin;
const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * 0.0012f;
- SetAxis(identifier, 0, static_cast<float>(mouse_move.x) * sensitivity);
- SetAxis(identifier, 1, static_cast<float>(-mouse_move.y) * sensitivity);
+ SetAxis(identifier, mouse_axis_x, static_cast<float>(mouse_move.x) * sensitivity);
+ SetAxis(identifier, mouse_axis_y, static_cast<float>(-mouse_move.y) * sensitivity);
}
}
@@ -108,12 +122,17 @@ void Mouse::ReleaseButton(MouseButton button) {
SetButton(identifier, static_cast<int>(button), false);
if (!Settings::values.mouse_panning) {
- SetAxis(identifier, 0, 0);
- SetAxis(identifier, 1, 0);
+ SetAxis(identifier, mouse_axis_x, 0);
+ SetAxis(identifier, mouse_axis_y, 0);
}
button_pressed = false;
}
+void Mouse::MouseWheelChange(int x, int y) {
+ SetAxis(identifier, wheel_axis_x, static_cast<f32>(x));
+ SetAxis(identifier, wheel_axis_y, static_cast<f32>(y));
+}
+
void Mouse::ReleaseAllButtons() {
ResetButtonState();
button_pressed = false;