diff options
author | german <german@thesoftwareartisans.com> | 2021-02-13 18:47:54 +0100 |
---|---|---|
committer | german <german@thesoftwareartisans.com> | 2021-02-14 05:23:32 +0100 |
commit | 594973bdd2dd2a82ba4b6a1c02a48fe4cad16e1b (patch) | |
tree | 40b9634b58915d6d554916d9bc02d23ba4be5544 | |
parent | Merge pull request #5919 from ReinUsesLisp/stream-buffer-tragic (diff) | |
download | yuzu-594973bdd2dd2a82ba4b6a1c02a48fe4cad16e1b.tar yuzu-594973bdd2dd2a82ba4b6a1c02a48fe4cad16e1b.tar.gz yuzu-594973bdd2dd2a82ba4b6a1c02a48fe4cad16e1b.tar.bz2 yuzu-594973bdd2dd2a82ba4b6a1c02a48fe4cad16e1b.tar.lz yuzu-594973bdd2dd2a82ba4b6a1c02a48fe4cad16e1b.tar.xz yuzu-594973bdd2dd2a82ba4b6a1c02a48fe4cad16e1b.tar.zst yuzu-594973bdd2dd2a82ba4b6a1c02a48fe4cad16e1b.zip |
Diffstat (limited to '')
-rw-r--r-- | src/input_common/mouse/mouse_input.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/input_common/mouse/mouse_input.cpp b/src/input_common/mouse/mouse_input.cpp index 67a584d53..b864d26f2 100644 --- a/src/input_common/mouse/mouse_input.cpp +++ b/src/input_common/mouse/mouse_input.cpp @@ -33,11 +33,16 @@ void Mouse::UpdateThread() { info.motion.UpdateOrientation(update_time * 1000); info.tilt_speed = 0; info.data.motion = info.motion.GetMotion(); + if (Settings::values.mouse_panning) { + info.last_mouse_change *= 0.96f; + info.data.axis = {static_cast<int>(16 * info.last_mouse_change.x), + static_cast<int>(16 * -info.last_mouse_change.y)}; + } } if (configuring) { UpdateYuzuSettings(); } - if (mouse_panning_timout++ > 8) { + if (mouse_panning_timout++ > 20) { StopPanning(); } std::this_thread::sleep_for(std::chrono::milliseconds(update_time)); @@ -82,16 +87,27 @@ void Mouse::StopPanning() { void Mouse::MouseMove(int x, int y, int center_x, int center_y) { for (MouseInfo& info : mouse_info) { if (Settings::values.mouse_panning) { - const auto mouse_change = Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y); + auto mouse_change = + (Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>(); mouse_panning_timout = 0; if (mouse_change.y == 0 && mouse_change.x == 0) { continue; } + const auto mouse_change_length = mouse_change.Length(); + if (mouse_change_length < 3.0f) { + mouse_change /= mouse_change_length / 3.0f; + } + + info.last_mouse_change = (info.last_mouse_change * 0.91f) + (mouse_change * 0.09f); + + const auto last_mouse_change_length = info.last_mouse_change.Length(); + if (last_mouse_change_length > 8.0f) { + info.last_mouse_change /= last_mouse_change_length / 8.0f; + } else if (last_mouse_change_length < 1.0f) { + info.last_mouse_change = mouse_change / mouse_change.Length(); + } - info.last_mouse_change = (info.last_mouse_change * 0.8f) + (mouse_change * 0.2f); - info.data.axis = {static_cast<int>(16 * info.last_mouse_change.x), - static_cast<int>(16 * -info.last_mouse_change.y)}; info.tilt_direction = info.last_mouse_change; info.tilt_speed = info.tilt_direction.Normalize() * info.sensitivity; continue; |