Add rumble cvar

This commit is contained in:
Sirius902 2022-04-17 23:04:51 -07:00
parent 24f504ef9b
commit a2c10b7032
5 changed files with 20 additions and 3 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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<int>(100 * Game::Settings.controller.rumble_strength));
if (ImGui::SliderFloat("##RUMBLE", &Game::Settings.controller.rumble_strength, 0.0f, 1.0f, "")) {
needs_save = true;

View File

@ -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,
};
};

View File

@ -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));
}