mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-07-02 21:48:01 -05:00
settings: Preparation for per-game input settings
This commit is contained in:
@ -276,7 +276,7 @@ void Config::ReadPlayerValue(std::size_t player_index) {
|
||||
}
|
||||
}();
|
||||
|
||||
auto& player = Settings::values.players[player_index];
|
||||
auto& player = Settings::values.players.GetValue()[player_index];
|
||||
|
||||
if (player_prefix.isEmpty()) {
|
||||
const auto controller = static_cast<Settings::ControllerType>(
|
||||
@ -481,7 +481,7 @@ void Config::ReadAudioValues() {
|
||||
void Config::ReadControlValues() {
|
||||
qt_config->beginGroup(QStringLiteral("Controls"));
|
||||
|
||||
for (std::size_t p = 0; p < Settings::values.players.size(); ++p) {
|
||||
for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {
|
||||
ReadPlayerValue(p);
|
||||
}
|
||||
ReadDebugValues();
|
||||
@ -490,11 +490,10 @@ void Config::ReadControlValues() {
|
||||
ReadTouchscreenValues();
|
||||
ReadMotionTouchValues();
|
||||
|
||||
Settings::values.vibration_enabled =
|
||||
ReadSetting(QStringLiteral("vibration_enabled"), true).toBool();
|
||||
Settings::values.motion_enabled = ReadSetting(QStringLiteral("motion_enabled"), true).toBool();
|
||||
Settings::values.use_docked_mode =
|
||||
ReadSetting(QStringLiteral("use_docked_mode"), false).toBool();
|
||||
ReadSettingGlobal(Settings::values.use_docked_mode, QStringLiteral("use_docked_mode"), false);
|
||||
ReadSettingGlobal(Settings::values.vibration_enabled, QStringLiteral("vibration_enabled"),
|
||||
true);
|
||||
ReadSettingGlobal(Settings::values.motion_enabled, QStringLiteral("motion_enabled"), true);
|
||||
|
||||
qt_config->endGroup();
|
||||
}
|
||||
@ -976,7 +975,7 @@ void Config::SavePlayerValue(std::size_t player_index) {
|
||||
}
|
||||
}();
|
||||
|
||||
const auto& player = Settings::values.players[player_index];
|
||||
const auto& player = Settings::values.players.GetValue()[player_index];
|
||||
|
||||
WriteSetting(QStringLiteral("%1type").arg(player_prefix),
|
||||
static_cast<u8>(player.controller_type),
|
||||
@ -1140,7 +1139,7 @@ void Config::SaveAudioValues() {
|
||||
void Config::SaveControlValues() {
|
||||
qt_config->beginGroup(QStringLiteral("Controls"));
|
||||
|
||||
for (std::size_t p = 0; p < Settings::values.players.size(); ++p) {
|
||||
for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {
|
||||
SavePlayerValue(p);
|
||||
}
|
||||
SaveDebugValues();
|
||||
@ -1148,8 +1147,10 @@ void Config::SaveControlValues() {
|
||||
SaveTouchscreenValues();
|
||||
SaveMotionTouchValues();
|
||||
|
||||
WriteSetting(QStringLiteral("vibration_enabled"), Settings::values.vibration_enabled, true);
|
||||
WriteSetting(QStringLiteral("motion_enabled"), Settings::values.motion_enabled, true);
|
||||
WriteSettingGlobal(QStringLiteral("use_docked_mode"), Settings::values.use_docked_mode, false);
|
||||
WriteSettingGlobal(QStringLiteral("vibration_enabled"), Settings::values.vibration_enabled,
|
||||
true);
|
||||
WriteSettingGlobal(QStringLiteral("motion_enabled"), Settings::values.motion_enabled, true);
|
||||
WriteSetting(QStringLiteral("motion_device"),
|
||||
QString::fromStdString(Settings::values.motion_device),
|
||||
QStringLiteral("engine:motion_emu,update_period:100,sensitivity:0.01"));
|
||||
@ -1157,7 +1158,6 @@ void Config::SaveControlValues() {
|
||||
QString::fromStdString(Settings::values.touch_device),
|
||||
QStringLiteral("engine:emu_window"));
|
||||
WriteSetting(QStringLiteral("keyboard_enabled"), Settings::values.keyboard_enabled, false);
|
||||
WriteSetting(QStringLiteral("use_docked_mode"), Settings::values.use_docked_mode, false);
|
||||
|
||||
qt_config->endGroup();
|
||||
}
|
||||
|
@ -181,12 +181,12 @@ void ConfigureInput::ApplyConfiguration() {
|
||||
|
||||
advanced->ApplyConfiguration();
|
||||
|
||||
const bool pre_docked_mode = Settings::values.use_docked_mode;
|
||||
Settings::values.use_docked_mode = ui->radioDocked->isChecked();
|
||||
OnDockedModeChanged(pre_docked_mode, Settings::values.use_docked_mode);
|
||||
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
|
||||
Settings::values.use_docked_mode.SetValue(ui->radioDocked->isChecked());
|
||||
OnDockedModeChanged(pre_docked_mode, Settings::values.use_docked_mode.GetValue());
|
||||
|
||||
Settings::values.vibration_enabled = ui->vibrationGroup->isChecked();
|
||||
Settings::values.motion_enabled = ui->motionGroup->isChecked();
|
||||
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
|
||||
Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
|
||||
}
|
||||
|
||||
void ConfigureInput::changeEvent(QEvent* event) {
|
||||
@ -203,16 +203,16 @@ void ConfigureInput::RetranslateUI() {
|
||||
|
||||
void ConfigureInput::LoadConfiguration() {
|
||||
LoadPlayerControllerIndices();
|
||||
UpdateDockedState(Settings::values.players[8].connected);
|
||||
UpdateDockedState(Settings::values.players.GetValue()[8].connected);
|
||||
|
||||
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled);
|
||||
ui->motionGroup->setChecked(Settings::values.motion_enabled);
|
||||
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
|
||||
ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue());
|
||||
}
|
||||
|
||||
void ConfigureInput::LoadPlayerControllerIndices() {
|
||||
for (std::size_t i = 0; i < player_connected.size(); ++i) {
|
||||
const auto connected = Settings::values.players[i].connected ||
|
||||
(i == 0 && Settings::values.players[8].connected);
|
||||
const auto connected = Settings::values.players.GetValue()[i].connected ||
|
||||
(i == 0 && Settings::values.players.GetValue()[8].connected);
|
||||
player_connected[i]->setChecked(connected);
|
||||
}
|
||||
}
|
||||
@ -241,8 +241,8 @@ void ConfigureInput::UpdateDockedState(bool is_handheld) {
|
||||
ui->radioDocked->setEnabled(!is_handheld);
|
||||
ui->radioUndocked->setEnabled(!is_handheld);
|
||||
|
||||
ui->radioDocked->setChecked(Settings::values.use_docked_mode);
|
||||
ui->radioUndocked->setChecked(!Settings::values.use_docked_mode);
|
||||
ui->radioDocked->setChecked(Settings::values.use_docked_mode.GetValue());
|
||||
ui->radioUndocked->setChecked(!Settings::values.use_docked_mode.GetValue());
|
||||
|
||||
// Also force into undocked mode if the controller type is handheld.
|
||||
if (is_handheld) {
|
||||
|
@ -107,7 +107,7 @@ void ConfigureInputAdvanced::OnControllerButtonClick(int player_idx, int button_
|
||||
|
||||
void ConfigureInputAdvanced::ApplyConfiguration() {
|
||||
for (std::size_t player_idx = 0; player_idx < controllers_color_buttons.size(); ++player_idx) {
|
||||
auto& player = Settings::values.players[player_idx];
|
||||
auto& player = Settings::values.players.GetValue()[player_idx];
|
||||
std::array<u32, 4> colors{};
|
||||
std::transform(controllers_colors[player_idx].begin(), controllers_colors[player_idx].end(),
|
||||
colors.begin(), [](QColor color) { return color.rgb(); });
|
||||
@ -126,7 +126,7 @@ void ConfigureInputAdvanced::ApplyConfiguration() {
|
||||
|
||||
void ConfigureInputAdvanced::LoadConfiguration() {
|
||||
for (std::size_t player_idx = 0; player_idx < controllers_color_buttons.size(); ++player_idx) {
|
||||
auto& player = Settings::values.players[player_idx];
|
||||
auto& player = Settings::values.players.GetValue()[player_idx];
|
||||
std::array<u32, 4> colors = {
|
||||
player.body_color_left,
|
||||
player.button_color_left,
|
||||
|
@ -544,7 +544,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
||||
ConfigureInputPlayer::~ConfigureInputPlayer() = default;
|
||||
|
||||
void ConfigureInputPlayer::ApplyConfiguration() {
|
||||
auto& player = Settings::values.players[player_index];
|
||||
auto& player = Settings::values.players.GetValue()[player_index];
|
||||
auto& buttons = debug ? Settings::values.debug_pad_buttons : player.buttons;
|
||||
auto& analogs = debug ? Settings::values.debug_pad_analogs : player.analogs;
|
||||
|
||||
@ -572,7 +572,7 @@ void ConfigureInputPlayer::ApplyConfiguration() {
|
||||
}
|
||||
|
||||
// Player 1 and Handheld
|
||||
auto& handheld = Settings::values.players[HANDHELD_INDEX];
|
||||
auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
|
||||
// If Handheld is selected, copy all the settings from Player 1 to Handheld.
|
||||
if (player.controller_type == Settings::ControllerType::Handheld) {
|
||||
handheld = player;
|
||||
@ -609,7 +609,7 @@ void ConfigureInputPlayer::RetranslateUI() {
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::LoadConfiguration() {
|
||||
auto& player = Settings::values.players[player_index];
|
||||
auto& player = Settings::values.players.GetValue()[player_index];
|
||||
if (debug) {
|
||||
std::transform(Settings::values.debug_pad_buttons.begin(),
|
||||
Settings::values.debug_pad_buttons.end(), buttons_param.begin(),
|
||||
@ -636,7 +636,7 @@ void ConfigureInputPlayer::LoadConfiguration() {
|
||||
ui->comboControllerType->setCurrentIndex(static_cast<int>(player.controller_type));
|
||||
ui->groupConnectedController->setChecked(
|
||||
player.connected ||
|
||||
(player_index == 0 && Settings::values.players[HANDHELD_INDEX].connected));
|
||||
(player_index == 0 && Settings::values.players.GetValue()[HANDHELD_INDEX].connected));
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::ConnectPlayer(bool connected) {
|
||||
|
Reference in New Issue
Block a user