RMG-Input-GCA: implement 'Swap Z and L' setting

This commit is contained in:
Rosalie Wanders
2025-10-16 22:52:56 +02:00
parent 72d13568fb
commit 30121f2db7
3 changed files with 24 additions and 2 deletions
@@ -21,6 +21,7 @@ MainDialog::MainDialog(QWidget* parent) : QDialog(parent)
this->sensitivitySlider->setValue(CoreSettingsGetIntValue(SettingsID::GCAInput_Sensitivity));
this->triggerTresholdSlider->setValue(CoreSettingsGetIntValue(SettingsID::GCAInput_TriggerTreshold));
this->cButtonTresholdSlider->setValue(CoreSettingsGetIntValue(SettingsID::GCAInput_CButtonTreshold));
this->swapZLCheckBox->setChecked(CoreSettingsGetBoolValue(SettingsID::GCAInput_SwapZL));
}
MainDialog::~MainDialog()
@@ -39,6 +40,7 @@ void MainDialog::on_buttonBox_clicked(QAbstractButton* button)
CoreSettingsSetValue(SettingsID::GCAInput_Sensitivity, this->sensitivitySlider->value());
CoreSettingsSetValue(SettingsID::GCAInput_TriggerTreshold, this->triggerTresholdSlider->value());
CoreSettingsSetValue(SettingsID::GCAInput_CButtonTreshold, this->cButtonTresholdSlider->value());
CoreSettingsSetValue(SettingsID::GCAInput_SwapZL, this->swapZLCheckBox->isChecked());
CoreSettingsSave();
}
else if (pushButton == defaultButton)
@@ -47,6 +49,7 @@ void MainDialog::on_buttonBox_clicked(QAbstractButton* button)
this->sensitivitySlider->setValue(CoreSettingsGetDefaultIntValue(SettingsID::GCAInput_Sensitivity));
this->triggerTresholdSlider->setValue(CoreSettingsGetDefaultIntValue(SettingsID::GCAInput_TriggerTreshold));
this->cButtonTresholdSlider->setValue(CoreSettingsGetDefaultIntValue(SettingsID::GCAInput_CButtonTreshold));
this->swapZLCheckBox->setChecked(CoreSettingsGetDefaultBoolValue(SettingsID::GCAInput_SwapZL));
}
}
@@ -90,6 +90,22 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Buttons</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="swapZLCheckBox">
<property name="text">
<string>Swap Z and L</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
+5 -2
View File
@@ -52,6 +52,8 @@ struct SettingsProfile
double TriggerTreshold = 0.5;
double CButtonTreshold = 0.4;
bool SwapZL = false;
};
struct GameCubeAdapterControllerState
@@ -307,6 +309,7 @@ static void load_settings(void)
l_Settings.SensitivityValue = static_cast<double>(CoreSettingsGetIntValue(SettingsID::GCAInput_Sensitivity)) / 100.0;
l_Settings.CButtonTreshold = static_cast<double>(CoreSettingsGetIntValue(SettingsID::GCAInput_CButtonTreshold)) / 100.0;
l_Settings.TriggerTreshold = static_cast<double>(CoreSettingsGetIntValue(SettingsID::GCAInput_TriggerTreshold)) / 100.0;
l_Settings.SwapZL = CoreSettingsGetBoolValue(SettingsID::GCAInput_SwapZL);
}
static double apply_deadzone(const double input, const double deadzone)
@@ -424,15 +427,15 @@ EXPORT void CALL GetKeys(int Control, BUTTONS* Keys)
Keys->R_DPAD = state.DpadRight;
Keys->D_DPAD = state.DpadDown;
Keys->U_DPAD = state.DpadUp;
Keys->Z_TRIG = state.Z;
const int triggerTreshold = INT8_MAX * l_Settings.TriggerTreshold;
const int cStickTreshold = INT8_MAX * l_Settings.CButtonTreshold;
const int8_t cX = static_cast<int8_t>(state.RightStickX + 128);
const int8_t cY = static_cast<int8_t>(state.RightStickY + 128);
Keys->L_TRIG = state.LeftTrigger > triggerTreshold;
Keys->R_TRIG = state.RightTrigger > triggerTreshold;
Keys->L_TRIG = l_Settings.SwapZL ? state.Z : (state.LeftTrigger > triggerTreshold);
Keys->Z_TRIG = l_Settings.SwapZL ? (state.LeftTrigger > triggerTreshold) : state.Z;
Keys->L_CBUTTON = cX < -cStickTreshold;
Keys->R_CBUTTON = cX > cStickTreshold;