fixes
This commit is contained in:
parent
90965525ac
commit
bf93b94658
|
@ -51,7 +51,7 @@ const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> Config:
|
|||
void Config::ReadValues() {
|
||||
qt_config->beginGroup("Controls");
|
||||
|
||||
Settings::values.profile = ReadSetting("profile", 0).toInt();
|
||||
Settings::values.current_input_profile = ReadSetting("profile", 0).toInt();
|
||||
|
||||
const auto append_profile = [this] {
|
||||
Settings::InputProfile profile;
|
||||
|
@ -95,22 +95,23 @@ void Config::ReadValues() {
|
|||
|
||||
const int num_input_profiles = qt_config->beginReadArray("profiles");
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
for (int i = 0; i < num_input_profiles; ++i) {
|
||||
qt_config->setArrayIndex(i);
|
||||
append_profile();
|
||||
}
|
||||
|
||||
qt_config->endArray();
|
||||
|
||||
if (Settings::values.profile <= size) {
|
||||
Settings::values.profile = 0;
|
||||
if (Settings::values.current_input_profile <= num_input_profiles) {
|
||||
Settings::values.current_input_profile = 0;
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
// create a input profile if no input profiles exist, with the default or old settings
|
||||
if (num_input_profiles == 0) {
|
||||
append_profile();
|
||||
}
|
||||
|
||||
Settings::LoadProfile(Settings::values.profile);
|
||||
Settings::LoadProfile(Settings::values.current_input_profile);
|
||||
|
||||
qt_config->endArray();
|
||||
|
||||
|
@ -281,7 +282,7 @@ void Config::ReadValues() {
|
|||
UISettings::values.game_dir_deprecated = ReadSetting("gameListRootDir", ".").toString();
|
||||
UISettings::values.game_dir_deprecated_deepscan =
|
||||
ReadSetting("gameListDeepScan", false).toBool();
|
||||
size = qt_config->beginReadArray("gamedirs");
|
||||
int size = qt_config->beginReadArray("gamedirs");
|
||||
for (int i = 0; i < size; ++i) {
|
||||
qt_config->setArrayIndex(i);
|
||||
UISettings::GameDir game_dir;
|
||||
|
@ -376,10 +377,10 @@ void Config::ReadValues() {
|
|||
|
||||
void Config::SaveValues() {
|
||||
qt_config->beginGroup("Controls");
|
||||
WriteSetting("profile", Settings::values.profile, 0);
|
||||
WriteSetting("profile", Settings::values.current_input_profile, 0);
|
||||
qt_config->beginWriteArray("profiles");
|
||||
for (int p = 0; p < Settings::values.profiles.size(); ++p) {
|
||||
qt_config->setArrayIndex(p);
|
||||
for (std::size_t p = 0; p < Settings::values.inprofiles.size(); ++p) {
|
||||
qt_config->setArrayIndex(static_cast<int>(p));
|
||||
const auto& profile = Settings::values.profiles[p];
|
||||
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
|
||||
std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
|
||||
|
|
|
@ -104,17 +104,17 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
ui->profile->addItem(QString::fromStdString(profile.name));
|
||||
}
|
||||
ui->profile->addItem(QString::fromStdString(Settings::values.profiles[i].name));
|
||||
}
|
||||
}
|
||||
|
||||
ui->profile->setCurrentIndex(Settings::values.profile);
|
||||
ui->profile->setCurrentIndex(Settings::values.current_input_profile);
|
||||
|
||||
button_map = {
|
||||
button_map = {
|
||||
ui->buttonA, ui->buttonB, ui->buttonX, ui->buttonY, ui->buttonDpadUp,
|
||||
ui->buttonDpadDown, ui->buttonDpadLeft, ui->buttonDpadRight, ui->buttonL, ui->buttonR,
|
||||
ui->buttonStart, ui->buttonSelect, ui->buttonZL, ui->buttonZR, ui->buttonHome,
|
||||
};
|
||||
};
|
||||
|
||||
analog_map_buttons = {{
|
||||
analog_map_buttons = {{
|
||||
{
|
||||
ui->buttonCircleUp,
|
||||
ui->buttonCircleDown,
|
||||
|
@ -129,11 +129,11 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
ui->buttonCStickRight,
|
||||
nullptr,
|
||||
},
|
||||
}};
|
||||
}};
|
||||
|
||||
analog_map_stick = {ui->buttonCircleAnalog, ui->buttonCStickAnalog};
|
||||
analog_map_stick = {ui->buttonCircleAnalog, ui->buttonCStickAnalog};
|
||||
|
||||
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
|
||||
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
|
||||
if (!button_map[button_id])
|
||||
continue;
|
||||
button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
@ -165,14 +165,13 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
});
|
||||
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
|
||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
|
||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) {
|
||||
if (!analog_map_buttons[analog_id][sub_button_id])
|
||||
continue;
|
||||
analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy(
|
||||
Qt::CustomContextMenu);
|
||||
analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released, [=]() {
|
||||
handleClick(
|
||||
analog_map_buttons[analog_id][sub_button_id],
|
||||
|
@ -203,8 +202,8 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
applyConfiguration();
|
||||
Settings::SaveProfile(ui->profile->currentIndex());
|
||||
});
|
||||
context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(
|
||||
menu_location));
|
||||
context_menu.exec(
|
||||
analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(menu_location));
|
||||
});
|
||||
}
|
||||
connect(analog_map_stick[analog_id], &QPushButton::released, [=]() {
|
||||
|
@ -220,30 +219,30 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
},
|
||||
InputCommon::Polling::DeviceType::Analog);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
connect(ui->buttonMotionTouch, &QPushButton::released, [this] {
|
||||
connect(ui->buttonMotionTouch, &QPushButton::released, [this] {
|
||||
QDialog* motion_touch_dialog = new ConfigureMotionTouch(this);
|
||||
return motion_touch_dialog->exec();
|
||||
});
|
||||
connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); });
|
||||
connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); });
|
||||
connect(ui->buttonNew, &QPushButton::released, [this] { newProfile(); });
|
||||
connect(ui->buttonDelete, &QPushButton::released, [this] { deleteProfile(); });
|
||||
connect(ui->buttonRename, &QPushButton::released, [this] { renameProfile(); });
|
||||
});
|
||||
connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); });
|
||||
connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); });
|
||||
connect(ui->buttonNew, &QPushButton::released, [this] { newProfile(); });
|
||||
connect(ui->buttonDelete, &QPushButton::released, [this] { deleteProfile(); });
|
||||
connect(ui->buttonRename, &QPushButton::released, [this] { renameProfile(); });
|
||||
|
||||
connect(ui->profile, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
connect(ui->profile, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
[this](int i) {
|
||||
applyConfiguration();
|
||||
Settings::SaveProfile(Settings::values.profile);
|
||||
Settings::SaveProfile(Settings::values.current_input_profile);
|
||||
Settings::LoadProfile(i);
|
||||
loadConfiguration();
|
||||
});
|
||||
|
||||
timeout_timer->setSingleShot(true);
|
||||
connect(timeout_timer.get(), &QTimer::timeout, [this]() { setPollingResult({}, true); });
|
||||
timeout_timer->setSingleShot(true);
|
||||
connect(timeout_timer.get(), &QTimer::timeout, [this]() { setPollingResult({}, true); });
|
||||
|
||||
connect(poll_timer.get(), &QTimer::timeout, [this]() {
|
||||
connect(poll_timer.get(), &QTimer::timeout, [this]() {
|
||||
Common::ParamPackage params;
|
||||
for (auto& poller : device_pollers) {
|
||||
params = poller->GetNextInput();
|
||||
|
@ -252,12 +251,12 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this->loadConfiguration();
|
||||
this->loadConfiguration();
|
||||
|
||||
// TODO(wwylele): enable this when we actually emulate it
|
||||
ui->buttonHome->setEnabled(false);
|
||||
// TODO(wwylele): enable this when we actually emulate it
|
||||
ui->buttonHome->setEnabled(false);
|
||||
}
|
||||
|
||||
ConfigureInput::~ConfigureInput() = default;
|
||||
|
@ -270,7 +269,7 @@ void ConfigureInput::applyConfiguration() {
|
|||
}
|
||||
|
||||
void ConfigureInput::applyProfile() {
|
||||
Settings::values.profile = ui->profile->currentIndex();
|
||||
Settings::values.current_input_profile = ui->profile->currentIndex();
|
||||
}
|
||||
|
||||
void ConfigureInput::loadConfiguration() {
|
||||
|
@ -400,7 +399,7 @@ void ConfigureInput::newProfile() {
|
|||
Settings::SaveProfile(ui->profile->currentIndex());
|
||||
Settings::CreateProfile(name.toStdString());
|
||||
ui->profile->addItem(name);
|
||||
ui->profile->setCurrentIndex(Settings::values.profile);
|
||||
ui->profile->setCurrentIndex(Settings::values.current_input_profile);
|
||||
loadConfiguration();
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ void ConfigureMotionTouch::applyConfiguration() {
|
|||
Settings::values.udp_input_address = ui->udp_server->text().toStdString();
|
||||
Settings::values.udp_input_port = static_cast<u16>(ui->udp_port->text().toInt());
|
||||
Settings::values.udp_pad_index = static_cast<u8>(ui->udp_pad_index->currentIndex());
|
||||
Settings::SaveProfile(Settings::values.profile);
|
||||
Settings::SaveProfile(Settings::values.current_input_profile);
|
||||
InputCommon::ReloadInputDevices();
|
||||
|
||||
accept();
|
||||
|
|
|
@ -1326,8 +1326,8 @@ void GMainWindow::OnConfigure() {
|
|||
connect(&configureDialog, &ConfigureDialog::languageChanged, this,
|
||||
&GMainWindow::OnLanguageChanged);
|
||||
auto old_theme = UISettings::values.theme;
|
||||
const int old_profile = Settings::values.profile;
|
||||
const auto old_profiles = Settings::values.profiles;
|
||||
const int old_input_profile = Settings::values.current_input_profile;
|
||||
const auto old_input_profiles = Settings::values.input_profiles;
|
||||
const bool old_discord_presence = UISettings::values.enable_discord_presence;
|
||||
auto result = configureDialog.exec();
|
||||
if (result == QDialog::Accepted) {
|
||||
|
@ -1341,8 +1341,8 @@ void GMainWindow::OnConfigure() {
|
|||
game_list->RefreshGameDirectory();
|
||||
config->Save();
|
||||
} else {
|
||||
Settings::values.profiles = old_profiles;
|
||||
Settings::LoadProfile(old_profile);
|
||||
Settings::values.input_profiles = old_input_profiles;
|
||||
Settings::LoadProfile(old_input_profile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ void LogSettings() {
|
|||
|
||||
void LoadProfile(int index) {
|
||||
const auto& profile = values.profiles[index];
|
||||
values.profile = index;
|
||||
values.current_input_profile = index;
|
||||
values.analogs = profile.analogs;
|
||||
values.buttons = profile.buttons;
|
||||
values.motion_device = profile.motion_device;
|
||||
|
@ -134,8 +134,8 @@ void CreateProfile(std::string name) {
|
|||
profile.udp_input_port = values.udp_input_port;
|
||||
profile.udp_pad_index = values.udp_pad_index;
|
||||
values.profiles.push_back(std::move(profile));
|
||||
values.profile = static_cast<int>(values.profiles.size()) - 1;
|
||||
LoadProfile(values.profile);
|
||||
values.current_input_profile = static_cast<int>(values.profiles.size()) - 1;
|
||||
LoadProfile(values.current_input_profile);
|
||||
}
|
||||
|
||||
void DeleteProfile(int index) {
|
||||
|
@ -144,7 +144,7 @@ void DeleteProfile(int index) {
|
|||
}
|
||||
|
||||
void RenameCurrentProfile(std::string new_name) {
|
||||
values.profiles[values.profile].name = std::move(new_name);
|
||||
values.profiles[values.current_input_profile].name = std::move(new_name);
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
|
Reference in New Issue