summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-11-15 04:28:38 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-25 03:30:28 +0100
commitf4e5f89e6fb9d68cd4ba7d98c281584c50f0e149 (patch)
tree9e9f9114d9b7528e74e78102279411595632f048 /src/input_common
parentcore/hid: Fully implement native mouse (diff)
downloadyuzu-f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149.tar
yuzu-f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149.tar.gz
yuzu-f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149.tar.bz2
yuzu-f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149.tar.lz
yuzu-f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149.tar.xz
yuzu-f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149.tar.zst
yuzu-f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149.zip
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/mouse.cpp21
-rw-r--r--src/input_common/drivers/mouse.h1
2 files changed, 14 insertions, 8 deletions
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp
index 478737db2..05fd7f9c0 100644
--- a/src/input_common/drivers/mouse.cpp
+++ b/src/input_common/drivers/mouse.cpp
@@ -39,7 +39,7 @@ void Mouse::UpdateThread(std::stop_token stop_token) {
Common::SetCurrentThreadName("yuzu:input:Mouse");
constexpr int update_time = 10;
while (!stop_token.stop_requested()) {
- if (Settings::values.mouse_panning) {
+ if (Settings::values.mouse_panning && !Settings::values.mouse_enabled) {
// Slow movement by 4%
last_mouse_change *= 0.96f;
const float sensitivity =
@@ -52,14 +52,17 @@ void Mouse::UpdateThread(std::stop_token stop_token) {
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);
}
}
void Mouse::MouseMove(int x, int y, f32 touch_x, f32 touch_y, int center_x, int center_y) {
+ // If native mouse is enabled just set the screen coordinates
+ if (Settings::values.mouse_enabled) {
+ SetAxis(identifier, mouse_axis_x, touch_x);
+ SetAxis(identifier, mouse_axis_y, touch_y);
+ return;
+ }
+
SetAxis(identifier, touch_axis_x, touch_x);
SetAxis(identifier, touch_axis_y, touch_y);
@@ -121,7 +124,7 @@ void Mouse::PressButton(int x, int y, f32 touch_x, f32 touch_y, MouseButton butt
void Mouse::ReleaseButton(MouseButton button) {
SetButton(identifier, static_cast<int>(button), false);
- if (!Settings::values.mouse_panning) {
+ if (!Settings::values.mouse_panning && !Settings::values.mouse_enabled) {
SetAxis(identifier, mouse_axis_x, 0);
SetAxis(identifier, mouse_axis_y, 0);
}
@@ -129,8 +132,10 @@ void Mouse::ReleaseButton(MouseButton button) {
}
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));
+ wheel_position.x += x;
+ wheel_position.y += y;
+ SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x));
+ SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y));
}
void Mouse::ReleaseAllButtons() {
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h
index 429502af9..f7e6db0b5 100644
--- a/src/input_common/drivers/mouse.h
+++ b/src/input_common/drivers/mouse.h
@@ -72,6 +72,7 @@ private:
Common::Vec2<int> mouse_origin;
Common::Vec2<int> last_mouse_position;
Common::Vec2<float> last_mouse_change;
+ Common::Vec2<int> wheel_position;
bool button_pressed;
int mouse_panning_timout{};
std::jthread update_thread;