From e646f80f41c088c1232556b75ffff5e960fc08ed Mon Sep 17 00:00:00 2001 From: MelonSpeedruns Date: Sun, 1 May 2022 13:23:40 -0400 Subject: [PATCH] Fixed Gyroscopy Settings & Drift --- libultraship/libultraship/SDLController.cpp | 2 +- libultraship/libultraship/SohImGuiImpl.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libultraship/libultraship/SDLController.cpp b/libultraship/libultraship/SDLController.cpp index 4533df20b..50bc5eabb 100644 --- a/libultraship/libultraship/SDLController.cpp +++ b/libultraship/libultraship/SDLController.cpp @@ -198,7 +198,7 @@ namespace Ship { const int isSpecialController = !strcmp("PS5 Controller", contName); float gyro_drift_x = CVar_GetFloat(StringHelper::Sprintf("gCont%i_GyroDriftX", contNumber).c_str(), 0.0f); float gyro_drift_y = CVar_GetFloat(StringHelper::Sprintf("gCont%i_GyroDriftY", contNumber).c_str(), 0.0f); - const float gyro_sensitivity = CVar_GetFloat(StringHelper::Sprintf("gCont%i_GyroSensitivity").c_str(), 1.0f); + const float gyro_sensitivity = CVar_GetFloat(StringHelper::Sprintf("gCont%i_GyroSensitivity", contNumber).c_str(), 1.0f); if (gyro_drift_x == 0) { gyro_drift_x = gyroData[0]; diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index fb4841ee9..1d9927c23 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -310,6 +310,13 @@ namespace SohImGui { LoadTexture("C-Down", "assets/ship_of_harkinian/buttons/CDown.png"); } }); + for (const auto& [i, controllers] : Ship::Window::Controllers) + { + CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftX", i).c_str(), 0); + CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftY", i).c_str(), 0); + needs_save = true; + } + ModInternal::registerHookListener({ CONTROLLER_READ, [](const HookEvent ev) { pads = static_cast(ev->baseArgs["cont_pad"]); } }); @@ -509,8 +516,8 @@ namespace SohImGui { if (ImGui::Button("Recalibrate Gyro")) { - CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftX").c_str(), 0); - CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftY").c_str(), 0); + CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftX", i).c_str(), 0); + CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftY", i).c_str(), 0); needs_save = true; }