mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
Implement saving and loading lightbar values
This commit is contained in:
parent
055c456b10
commit
b433cc3eff
@ -138,7 +138,7 @@ void ControlSettings::SaveControllerConfig(bool CloseOnSave) {
|
||||
|
||||
if (std::find(ControllerInputs.begin(), ControllerInputs.end(), input_string) !=
|
||||
ControllerInputs.end() ||
|
||||
output_string == "analog_deadzone") {
|
||||
output_string == "analog_deadzone" || output_string == "override_controller_color") {
|
||||
line.erase();
|
||||
continue;
|
||||
}
|
||||
@ -244,6 +244,14 @@ void ControlSettings::SaveControllerConfig(bool CloseOnSave) {
|
||||
deadzonevalue = std::to_string(ui->RightDeadzoneSlider->value());
|
||||
lines.push_back("analog_deadzone = rightjoystick, " + deadzonevalue + ", 127");
|
||||
|
||||
lines.push_back("");
|
||||
std::string OverrideLB = ui->LightbarCheckBox->isChecked() ? "true" : "false";
|
||||
std::string LightBarR = std::to_string(ui->RSlider->value());
|
||||
std::string LightBarG = std::to_string(ui->GSlider->value());
|
||||
std::string LightBarB = std::to_string(ui->BSlider->value());
|
||||
lines.push_back("override_controller_color = " + OverrideLB + ", " + LightBarR + ", " +
|
||||
LightBarG + ", " + LightBarB);
|
||||
|
||||
std::vector<std::string> save;
|
||||
bool CurrentLineEmpty = false, LastLineEmpty = false;
|
||||
for (auto const& line : lines) {
|
||||
@ -260,6 +268,9 @@ void ControlSettings::SaveControllerConfig(bool CloseOnSave) {
|
||||
output_file.close();
|
||||
|
||||
Config::SetUseUnifiedInputConfig(!ui->PerGameCheckBox->isChecked());
|
||||
Config::SetOverrideControllerColor(ui->LightbarCheckBox->isChecked());
|
||||
Config::SetControllerCustomColor(ui->RSlider->value(), ui->GSlider->value(),
|
||||
ui->BSlider->value());
|
||||
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
||||
|
||||
if (CloseOnSave)
|
||||
@ -368,7 +379,7 @@ void ControlSettings::SetUIValuestoMappings() {
|
||||
|
||||
if (std::find(ControllerInputs.begin(), ControllerInputs.end(), input_string) !=
|
||||
ControllerInputs.end() ||
|
||||
output_string == "analog_deadzone") {
|
||||
output_string == "analog_deadzone" || output_string == "override_controller_color") {
|
||||
if (input_string == "cross") {
|
||||
ui->ABox->setCurrentText(QString::fromStdString(output_string));
|
||||
CrossExists = true;
|
||||
@ -453,9 +464,45 @@ void ControlSettings::SetUIValuestoMappings() {
|
||||
ui->RightDeadzoneSlider->setValue(2);
|
||||
ui->RightDeadzoneValue->setText("2");
|
||||
}
|
||||
} else if (output_string == "override_controller_color") {
|
||||
std::size_t comma_pos = line.find(',');
|
||||
if (comma_pos != std::string::npos) {
|
||||
std::string overridestring = line.substr(equal_pos + 1, comma_pos);
|
||||
bool override = overridestring.contains("true") ? true : false;
|
||||
ui->LightbarCheckBox->setChecked(override);
|
||||
|
||||
std::string lightbarstring = line.substr(comma_pos + 1);
|
||||
std::size_t comma_pos2 = lightbarstring.find(',');
|
||||
if (comma_pos2 != std::string::npos) {
|
||||
std::string Rstring = lightbarstring.substr(0, comma_pos2);
|
||||
ui->RSlider->setValue(std::stoi(Rstring));
|
||||
QString RedValue = QString("%1").arg(std::stoi(Rstring), 3, 10, QChar('0'));
|
||||
QString RValue = "R: " + RedValue;
|
||||
ui->RLabel->setText(RValue);
|
||||
}
|
||||
|
||||
std::string GBstring = lightbarstring.substr(comma_pos2 + 1);
|
||||
std::size_t comma_pos3 = GBstring.find(',');
|
||||
if (comma_pos3 != std::string::npos) {
|
||||
std::string Gstring = GBstring.substr(0, comma_pos3);
|
||||
ui->GSlider->setValue(std::stoi(Gstring));
|
||||
QString GreenValue =
|
||||
QString("%1").arg(std::stoi(Gstring), 3, 10, QChar('0'));
|
||||
QString GValue = "G: " + GreenValue;
|
||||
ui->GLabel->setText(GValue);
|
||||
|
||||
std::string Bstring = GBstring.substr(comma_pos3 + 1);
|
||||
ui->BSlider->setValue(std::stoi(Bstring));
|
||||
QString BlueValue =
|
||||
QString("%1").arg(std::stoi(Bstring), 3, 10, QChar('0'));
|
||||
QString BValue = "B: " + BlueValue;
|
||||
ui->BLabel->setText(BValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
|
||||
// If an entry does not exist in the config file, we assume the user wants it unmapped
|
||||
if (!CrossExists)
|
||||
@ -507,8 +554,6 @@ void ControlSettings::SetUIValuestoMappings() {
|
||||
ui->RStickUpBox->setCurrentText("unmapped");
|
||||
ui->RStickDownBox->setCurrentText("unmapped");
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
void ControlSettings::GetGameTitle() {
|
||||
|
@ -10,7 +10,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1043</width>
|
||||
<height>822</height>
|
||||
<height>792</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -22,21 +22,26 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="TabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="RemapTab">
|
||||
<attribute name="title">
|
||||
<string>Controller Remapping</string>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1019</width>
|
||||
<height>732</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>1004</width>
|
||||
<height>711</height>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1021</width>
|
||||
<height>731</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="RemapLayout">
|
||||
|
Loading…
Reference in New Issue
Block a user