From a2c10b70322f39f0dc2f2f60f0eaced11adf7c90 Mon Sep 17 00:00:00 2001 From: Sirius902 <3645979-Sirius902@users.noreply.gitlab.com> Date: Sun, 17 Apr 2022 23:04:51 -0700 Subject: [PATCH] Add rumble cvar --- libultraship/libultraship/GameSettings.cpp | 4 ++++ libultraship/libultraship/GameSettings.h | 1 + libultraship/libultraship/SohImGuiImpl.cpp | 5 +++++ soh/soh/stubs.c | 4 ++-- soh/src/code/padmgr.c | 9 ++++++++- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/libultraship/libultraship/GameSettings.cpp b/libultraship/libultraship/GameSettings.cpp index 1b8d473b2..271bf6315 100644 --- a/libultraship/libultraship/GameSettings.cpp +++ b/libultraship/libultraship/GameSettings.cpp @@ -87,6 +87,9 @@ namespace Game { Settings.controller.rumble_strength = Ship::stof(Conf[ControllerSection]["rumble_strength"]); CVar_SetFloat("gRumbleStrength", Settings.controller.rumble_strength); + Settings.controller.rumble_enabled = Ship::stof(Conf[ControllerSection]["rumble_enabled"]); + CVar_SetS32("gRumbleEnabled", Settings.controller.rumble_enabled); + Settings.controller.input_scale = Ship::stof(Conf[ControllerSection]["input_scale"]); CVar_SetFloat("gInputScale", Settings.controller.input_scale); @@ -160,6 +163,7 @@ namespace Game { // Controllers Conf[ControllerSection]["gyro_sensitivity"] = std::to_string(Settings.controller.gyro_sensitivity); Conf[ControllerSection]["rumble_strength"] = std::to_string(Settings.controller.rumble_strength); + Conf[ControllerSection]["rumble_enabled"] = std::to_string(Settings.controller.rumble_enabled); Conf[ControllerSection]["input_scale"] = std::to_string(Settings.controller.input_scale); Conf[ControllerSection]["input_enabled"] = std::to_string(Settings.controller.input_enabled); Conf[ControllerSection]["dpad_pause_name"] = std::to_string(Settings.controller.dpad_pause_name); diff --git a/libultraship/libultraship/GameSettings.h b/libultraship/libultraship/GameSettings.h index 340e93d26..058ec0415 100644 --- a/libultraship/libultraship/GameSettings.h +++ b/libultraship/libultraship/GameSettings.h @@ -31,6 +31,7 @@ struct SoHConfigType { struct { float gyro_sensitivity = 1.0f; float rumble_strength = 1.0f; + bool rumble_enabled = true; float input_scale = 1.0f; float gyroDriftX = 0.0f; float gyroDriftY = 0.0f; diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 93dcd2492..cf06e1153 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -364,6 +364,11 @@ namespace SohImGui { ImGui::Separator(); + if (ImGui::Checkbox("Rumble Enabled", &Game::Settings.controller.rumble_enabled)) { + CVar_SetS32("gRumbleEnabled", Game::Settings.controller.rumble_enabled); + needs_save = true; + } + 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/soh/stubs.c b/soh/soh/stubs.c index 871d5ca22..c47c1fa5d 100644 --- a/soh/soh/stubs.c +++ b/soh/soh/stubs.c @@ -102,7 +102,7 @@ void osCreateViManager(OSPri pri) s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel) { - + return 0; } u32 osAiGetLength(void) @@ -2099,4 +2099,4 @@ u8 gSequenceFontTable[0x1C0] = { 0x01, 0x12, 0x01, 0x24, 0x01, 0x18, 0x01, 0x19, 0x01, 0x13, 0x01, 0x20, 0x01, 0x1B, 0x01, 0x1C, 0x01, 0x1D, 0x01, 0x03, 0x01, 0x1F, 0x01, 0x20, 0x01, 0x20, 0x01, 0x09, 0x01, 0x21, 0x01, 0x22, 0x01, 0x21, 0x01, 0x09, 0x01, 0x20, 0x01, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; \ No newline at end of file +}; diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c index 973c2b446..ccb4b17ac 100644 --- a/soh/src/code/padmgr.c +++ b/soh/src/code/padmgr.c @@ -269,7 +269,7 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) { input->press.stick_y += (s8)(input->cur.stick_y - input->prev.stick_y); } - controllerCallback.rumble = padMgr->rumbleEnable[0] > 0 ? 1 : 0; + controllerCallback.rumble = (CVar_GetS32("gRumbleEnabled", 0) != 0) && (padMgr->rumbleEnable[0] > 0) ? 1 : 0; if (HealthMeter_IsCritical()) { controllerCallback.ledColor = 0; @@ -303,6 +303,13 @@ void PadMgr_HandleRetraceMsg(PadMgr* padMgr) { } osRecvMesg(queue, NULL, OS_MESG_BLOCK); osContGetReadData(padMgr->pads); + + if (CVar_GetS32("gRumbleEnabled", 0) != 0) { + padMgr->padStatus[0].status = 1; + } else { + padMgr->padStatus[0].status = 0; + } + if (padMgr->preNMIShutdown) { memset(padMgr->pads, 0, sizeof(padMgr->pads)); }