configure_input: Hook up the vibration percentage spinbox

This allows setting the vibration strength percentage anywhere from 1% to 100%.
Also hooks up the remaining motion button and checkbox in the Controller Applet.
This commit is contained in:
Morph 2020-10-08 23:43:07 -04:00
parent e02ef3c3be
commit 652d6766d5
11 changed files with 26 additions and 3 deletions

View file

@ -703,7 +703,8 @@ void Controller_NPad::VibrateController(const std::vector<DeviceHandle>& vibrati
// TODO: Vibrate left/right vibration motors independently if possible.
button_state[A - BUTTON_HID_BEGIN]->SetRumblePlay(
vibration_values[i].amp_high, vibration_values[i].amp_low,
vibration_values[i].amp_high * Settings::values.vibration_strength.GetValue() / 100,
vibration_values[i].amp_low * Settings::values.vibration_strength.GetValue() / 100,
vibration_values[i].freq_high, vibration_values[i].freq_low);
latest_vibration_values[npad_index][device_index] = vibration_values[i];

View file

@ -150,6 +150,7 @@ void RestoreGlobalState() {
values.players.SetGlobal(true);
values.use_docked_mode.SetGlobal(true);
values.vibration_enabled.SetGlobal(true);
values.vibration_strength.SetGlobal(true);
values.motion_enabled.SetGlobal(true);
}

View file

@ -170,6 +170,7 @@ struct Values {
Setting<bool> use_docked_mode;
Setting<bool> vibration_enabled;
Setting<int> vibration_strength;
Setting<bool> motion_enabled;
std::string motion_device;

View file

@ -266,6 +266,8 @@ void QtControllerSelectorDialog::ApplyConfiguration() {
OnDockedModeChanged(pre_docked_mode, Settings::values.use_docked_mode.GetValue());
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
Settings::values.vibration_strength.SetValue(ui->vibrationSpin->value());
Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
}
void QtControllerSelectorDialog::LoadConfiguration() {
@ -281,6 +283,8 @@ void QtControllerSelectorDialog::LoadConfiguration() {
UpdateDockedState(Settings::values.players.GetValue()[8].connected);
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
ui->vibrationSpin->setValue(Settings::values.vibration_strength.GetValue());
ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue());
}
void QtControllerSelectorDialog::CallConfigureInputDialog() {

View file

@ -2349,7 +2349,7 @@
<number>1</number>
</property>
<property name="maximum">
<number>200</number>
<number>100</number>
</property>
<property name="value">
<number>100</number>

View file

@ -493,6 +493,8 @@ void Config::ReadControlValues() {
ReadSettingGlobal(Settings::values.use_docked_mode, QStringLiteral("use_docked_mode"), false);
ReadSettingGlobal(Settings::values.vibration_enabled, QStringLiteral("vibration_enabled"),
true);
ReadSettingGlobal(Settings::values.vibration_strength, QStringLiteral("vibration_strength"),
100);
ReadSettingGlobal(Settings::values.motion_enabled, QStringLiteral("motion_enabled"), true);
qt_config->endGroup();
@ -1150,6 +1152,8 @@ void Config::SaveControlValues() {
WriteSettingGlobal(QStringLiteral("use_docked_mode"), Settings::values.use_docked_mode, false);
WriteSettingGlobal(QStringLiteral("vibration_enabled"), Settings::values.vibration_enabled,
true);
WriteSettingGlobal(QStringLiteral("vibration_strength"), Settings::values.vibration_strength,
100);
WriteSettingGlobal(QStringLiteral("motion_enabled"), Settings::values.motion_enabled, true);
WriteSetting(QStringLiteral("motion_device"),
QString::fromStdString(Settings::values.motion_device),

View file

@ -186,6 +186,7 @@ void ConfigureInput::ApplyConfiguration() {
OnDockedModeChanged(pre_docked_mode, Settings::values.use_docked_mode.GetValue());
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
Settings::values.vibration_strength.SetValue(ui->vibrationSpin->value());
Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
}
@ -206,6 +207,7 @@ void ConfigureInput::LoadConfiguration() {
UpdateDockedState(Settings::values.players.GetValue()[8].connected);
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
ui->vibrationSpin->setValue(Settings::values.vibration_strength.GetValue());
ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue());
}

View file

@ -215,7 +215,7 @@
<number>1</number>
</property>
<property name="maximum">
<number>200</number>
<number>100</number>
</property>
<property name="value">
<number>100</number>

View file

@ -290,6 +290,8 @@ void Config::ReadValues() {
Settings::values.vibration_enabled.SetValue(
sdl2_config->GetBoolean("ControlsGeneral", "vibration_enabled", true));
Settings::values.vibration_strength.SetValue(
sdl2_config->GetInteger("ControlsGeneral", "vibration_strength", 100));
Settings::values.motion_enabled.SetValue(
sdl2_config->GetBoolean("ControlsGeneral", "motion_enabled", true));
Settings::values.touchscreen.enabled =

View file

@ -65,6 +65,13 @@ button_screenshot=
lstick=
rstick=
# Whether to enable or disable vibration
# 0: Disabled, 1 (default): Enabled
vibration_enabled=
# Vibration strength percentage (Default: 100)
vibration_strength=
# for motion input, the following devices are available:
# - "motion_emu" (default) for emulating motion input from mouse input. Required parameters:
# - "update_period": update period in milliseconds (default to 100)

View file

@ -76,6 +76,7 @@ void Config::ReadValues() {
}
Settings::values.vibration_enabled.SetValue(true);
Settings::values.vibration_strength.SetValue(100);
Settings::values.motion_enabled.SetValue(true);
Settings::values.touchscreen.enabled = "";
Settings::values.touchscreen.device = "";