diff --git a/libultraship/libultraship/GameSettings.h b/libultraship/libultraship/GameSettings.h index 8508baeae..be974fd80 100644 --- a/libultraship/libultraship/GameSettings.h +++ b/libultraship/libultraship/GameSettings.h @@ -30,7 +30,9 @@ struct SoHConfigType { float gyro_sensitivity = 1.0f; float rumble_strength = 1.0f; float input_scale = 1.0f; - bool input_enabled = false; + float gyroDriftX = 0.0f; + float gyroDriftY = 0.0f; + bool input_enabled = false; } controller; // Cheats diff --git a/libultraship/libultraship/SDLController.cpp b/libultraship/libultraship/SDLController.cpp index 3d6d6800d..d1315c3e4 100644 --- a/libultraship/libultraship/SDLController.cpp +++ b/libultraship/libultraship/SDLController.cpp @@ -7,12 +7,8 @@ #include "Window.h" extern "C" uint8_t __osMaxControllers; -float gyroDriftX; -float gyroDriftY; namespace Ship { - - SDLController::SDLController(int32_t dwControllerNumber) : Controller(dwControllerNumber), Cont(nullptr), guid(INVALID_SDL_CONTROLLER_GUID) { } @@ -186,31 +182,31 @@ namespace Ship { SDL_GameControllerGetSensorData(Cont, SDL_SENSOR_GYRO, gyroData, 3); const char* contName = SDL_GameControllerName(Cont); - const int isSpecialController = strcmp("PS5 Controller", contName); + const int isSpecialController = !strcmp("PS5 Controller", contName); const float gyroSensitivity = Game::Settings.controller.gyro_sensitivity; - if (gyroDriftX == 0) { - if (isSpecialController == 0) { - gyroDriftX = gyroData[2]; + if (Game::Settings.controller.gyroDriftX == 0) { + Game::Settings.controller.gyroDriftX = gyroData[0]; + } + + if (Game::Settings.controller.gyroDriftY == 0) { + if (isSpecialController == 1) { + Game::Settings.controller.gyroDriftY = gyroData[2]; } else { - gyroDriftX = gyroData[0]; + Game::Settings.controller.gyroDriftY = gyroData[1]; } } - if (gyroDriftY == 0) { - gyroDriftY = gyroData[1]; - } - - if (isSpecialController == 0) { - wGyroX = gyroData[2] - gyroDriftX; + if (isSpecialController == 1) { + wGyroX = gyroData[0] - Game::Settings.controller.gyroDriftX; + wGyroY = -gyroData[2] - Game::Settings.controller.gyroDriftY; } else { - wGyroX = gyroData[0] - gyroDriftX; + wGyroX = gyroData[0] - Game::Settings.controller.gyroDriftX; + wGyroY = gyroData[1] - Game::Settings.controller.gyroDriftY; } - wGyroY = gyroData[1] - gyroDriftY; - wGyroX *= gyroSensitivity; wGyroY *= gyroSensitivity; } @@ -340,11 +336,19 @@ namespace Ship { } if (SDL_GameControllerHasLED(Cont)) { - if (controller->ledColor == 1) { + switch (controller->ledColor) { + case 0: SDL_JoystickSetLED(SDL_GameControllerGetJoystick(Cont), 255, 0, 0); - } - else { - SDL_JoystickSetLED(SDL_GameControllerGetJoystick(Cont), 0, 255, 0); + break; + case 1: + SDL_JoystickSetLED(SDL_GameControllerGetJoystick(Cont), 0x1E, 0x69, 0x1B); + break; + case 2: + SDL_JoystickSetLED(SDL_GameControllerGetJoystick(Cont), 0x64, 0x14, 0x00); + break; + case 3: + SDL_JoystickSetLED(SDL_GameControllerGetJoystick(Cont), 0x00, 0x3C, 0x64); + break; } } } diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 548b298ef..abc51a535 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -306,6 +306,14 @@ namespace SohImGui { if (ImGui::SliderFloat("##GYROSCOPE", &Game::Settings.controller.gyro_sensitivity, 0.0f, 1.0f, "")) { needs_save = true; } + + if (ImGui::Button("Recalibrate Gyro")) { + Game::Settings.controller.gyroDriftX = 0; + Game::Settings.controller.gyroDriftY = 0; + } + + ImGui::Separator(); + ImGui::Text("Rumble Strength: %d %%", static_cast(100 * Game::Settings.controller.rumble_strength)); if (ImGui::SliderFloat("##RUMBLE", &Game::Settings.controller.rumble_strength, 0.0f, 1.0f, "")) { needs_save = true; diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c index fb4ceb8e6..973c2b446 100644 --- a/soh/src/code/padmgr.c +++ b/soh/src/code/padmgr.c @@ -272,9 +272,19 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) { controllerCallback.rumble = padMgr->rumbleEnable[0] > 0 ? 1 : 0; if (HealthMeter_IsCritical()) { - controllerCallback.ledColor = 1; - } else { controllerCallback.ledColor = 0; + } else if (gGlobalCtx) { + switch (CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1) { + case PLAYER_TUNIC_KOKIRI: + controllerCallback.ledColor = 1; + break; + case PLAYER_TUNIC_GORON: + controllerCallback.ledColor = 2; + break; + case PLAYER_TUNIC_ZORA: + controllerCallback.ledColor = 3; + break; + } } OTRControllerCallback(&controllerCallback);