From 76dfef85d9f4c781b7864ac60e222d1ddd79f669 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sun, 20 Nov 2022 23:51:28 +0100 Subject: [PATCH] early-access version 3141 --- README.md | 2 +- src/common/settings_input.h | 1 - src/core/hid/emulated_controller.cpp | 3 +- src/yuzu/CMakeLists.txt | 3 - src/yuzu/configuration/config.cpp | 99 +++++-------------- src/yuzu/configuration/config.h | 2 - .../configuration/configure_input_player.h | 2 +- src/yuzu/configuration/configure_per_game.cpp | 5 +- src/yuzu/configuration/configure_per_game.h | 6 -- src/yuzu/main.cpp | 18 ++-- 10 files changed, 38 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index ee1ade9d2..d3f415dd6 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3140. +This is the source code for early-access 3141. ## Legal Notice diff --git a/src/common/settings_input.h b/src/common/settings_input.h index f96d41335..1ef2ed6e6 100755 --- a/src/common/settings_input.h +++ b/src/common/settings_input.h @@ -391,7 +391,6 @@ struct PlayerInput { u32 body_color_right; u32 button_color_left; u32 button_color_right; - std::string profile_name; }; struct TouchscreenInput { diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 7b8789f25..999c4ab2c 100755 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp @@ -107,9 +107,10 @@ void EmulatedController::ReloadFromSettings() { original_npad_type = npad_type; } - Disconnect(); if (player.connected) { Connect(); + } else { + Disconnect(); } ReloadInput(); diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index a29493437..64303f9cb 100755 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -88,9 +88,6 @@ add_executable(yuzu configuration/configure_input_advanced.cpp configuration/configure_input_advanced.h configuration/configure_input_advanced.ui - configuration/configure_input_per_game.cpp - configuration/configure_input_per_game.h - configuration/configure_input_per_game.ui configuration/configure_input_player.cpp configuration/configure_input_player.h configuration/configure_input_player.ui diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index b816731dd..2ba2ee811 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -124,10 +124,6 @@ void Config::Initialize(const std::string& config_name) { } } -bool Config::IsCustomConfig() { - return type == ConfigType::PerGameConfig; -} - /* {Read,Write}BasicSetting and WriteGlobalSetting templates must be defined here before their * usages later in this file. This allows explicit definition of some types that don't work * nicely with the general version. @@ -198,20 +194,8 @@ void Config::ReadPlayerValue(std::size_t player_index) { }(); auto& player = Settings::values.players.GetValue()[player_index]; - if (IsCustomConfig()) { - const auto profile_name = - qt_config->value(QStringLiteral("%1profile_name").arg(player_prefix), QString{}) - .toString() - .toStdString(); - if (profile_name.empty()) { - // Use the global input config - player = Settings::values.players.GetValue(true)[player_index]; - return; - } - player.profile_name = profile_name; - } - if (player_prefix.isEmpty() && Settings::IsConfiguringGlobal()) { + if (player_prefix.isEmpty()) { const auto controller = static_cast( qt_config ->value(QStringLiteral("%1type").arg(player_prefix), @@ -404,26 +388,9 @@ void Config::ReadAudioValues() { void Config::ReadControlValues() { qt_config->beginGroup(QStringLiteral("Controls")); - Settings::values.players.SetGlobal(!IsCustomConfig()); for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { ReadPlayerValue(p); } - Settings::values.use_docked_mode.SetGlobal(!IsCustomConfig()); - ReadGlobalSetting(Settings::values.use_docked_mode); - - // Disable docked mode if handheld is selected - const auto controller_type = Settings::values.players.GetValue()[0].controller_type; - if (controller_type == Settings::ControllerType::Handheld) { - Settings::values.use_docked_mode.SetValue(false); - } - - ReadGlobalSetting(Settings::values.vibration_enabled); - ReadGlobalSetting(Settings::values.enable_accurate_vibrations); - ReadGlobalSetting(Settings::values.motion_enabled); - if (IsCustomConfig()) { - qt_config->endGroup(); - return; - } ReadDebugValues(); ReadKeyboardValues(); ReadMouseValues(); @@ -445,6 +412,18 @@ void Config::ReadControlValues() { ReadBasicSetting(Settings::values.tas_loop); ReadBasicSetting(Settings::values.pause_tas_on_load); + ReadGlobalSetting(Settings::values.use_docked_mode); + + // Disable docked mode if handheld is selected + const auto controller_type = Settings::values.players.GetValue()[0].controller_type; + if (controller_type == Settings::ControllerType::Handheld) { + Settings::values.use_docked_mode.SetValue(false); + } + + ReadGlobalSetting(Settings::values.vibration_enabled); + ReadGlobalSetting(Settings::values.enable_accurate_vibrations); + ReadGlobalSetting(Settings::values.motion_enabled); + ReadBasicSetting(Settings::values.controller_navigation); qt_config->endGroup(); @@ -926,6 +905,7 @@ void Config::ReadMultiplayerValues() { void Config::ReadValues() { if (global) { + ReadControlValues(); ReadDataStorageValues(); ReadDebuggingValues(); ReadDisabledAddOnValues(); @@ -934,7 +914,6 @@ void Config::ReadValues() { ReadWebServiceValues(); ReadMiscellaneousValues(); } - ReadControlValues(); ReadCoreValues(); ReadCpuValues(); ReadRendererValues(); @@ -953,20 +932,12 @@ void Config::SavePlayerValue(std::size_t player_index) { }(); const auto& player = Settings::values.players.GetValue()[player_index]; - if (IsCustomConfig()) { - if (player.profile_name.empty()) { - // No custom profile selected - return; - } - WriteSetting(QStringLiteral("%1profile_name").arg(player_prefix), - QString::fromStdString(player.profile_name), QString{}); - } WriteSetting(QStringLiteral("%1type").arg(player_prefix), static_cast(player.controller_type), static_cast(Settings::ControllerType::ProController)); - if (!player_prefix.isEmpty() || !Settings::IsConfiguringGlobal()) { + if (!player_prefix.isEmpty()) { WriteSetting(QStringLiteral("%1connected").arg(player_prefix), player.connected, player_index == 0); WriteSetting(QStringLiteral("%1vibration_enabled").arg(player_prefix), @@ -1048,22 +1019,19 @@ void Config::SaveMotionTouchValues() { WriteBasicSetting(Settings::values.udp_input_servers); WriteBasicSetting(Settings::values.enable_udp_controller); - if (Settings::values.touch_from_button_maps.empty()) { - return; - } qt_config->beginWriteArray(QStringLiteral("touch_from_button_maps")); for (std::size_t p = 0; p < Settings::values.touch_from_button_maps.size(); ++p) { - const auto& map = Settings::values.touch_from_button_maps[p]; - if (map.buttons.empty()) { - continue; - } qt_config->setArrayIndex(static_cast(p)); - WriteSetting(QStringLiteral("name"), QString::fromStdString(map.name), + WriteSetting(QStringLiteral("name"), + QString::fromStdString(Settings::values.touch_from_button_maps[p].name), QStringLiteral("default")); qt_config->beginWriteArray(QStringLiteral("entries")); - for (std::size_t q = 0; q < map.buttons.size(); ++q) { + for (std::size_t q = 0; q < Settings::values.touch_from_button_maps[p].buttons.size(); + ++q) { qt_config->setArrayIndex(static_cast(q)); - WriteSetting(QStringLiteral("bind"), QString::fromStdString(map.buttons[q])); + WriteSetting( + QStringLiteral("bind"), + QString::fromStdString(Settings::values.touch_from_button_maps[p].buttons[q])); } qt_config->endArray(); } @@ -1087,6 +1055,7 @@ void Config::SaveIrCameraValues() { void Config::SaveValues() { if (global) { + SaveControlValues(); SaveDataStorageValues(); SaveDebuggingValues(); SaveDisabledAddOnValues(); @@ -1095,7 +1064,6 @@ void Config::SaveValues() { SaveWebServiceValues(); SaveMiscellaneousValues(); } - SaveControlValues(); SaveCoreValues(); SaveCpuValues(); SaveRendererValues(); @@ -1120,19 +1088,9 @@ void Config::SaveAudioValues() { void Config::SaveControlValues() { qt_config->beginGroup(QStringLiteral("Controls")); - Settings::values.players.SetGlobal(!IsCustomConfig()); for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { SavePlayerValue(p); } - Settings::values.use_docked_mode.SetGlobal(!IsCustomConfig()); - WriteGlobalSetting(Settings::values.use_docked_mode); - WriteGlobalSetting(Settings::values.vibration_enabled); - WriteGlobalSetting(Settings::values.enable_accurate_vibrations); - WriteGlobalSetting(Settings::values.motion_enabled); - if (IsCustomConfig()) { - qt_config->endGroup(); - return; - } SaveDebugValues(); SaveMouseValues(); SaveTouchscreenValues(); @@ -1140,6 +1098,10 @@ void Config::SaveControlValues() { SaveHidbusValues(); SaveIrCameraValues(); + WriteGlobalSetting(Settings::values.use_docked_mode); + WriteGlobalSetting(Settings::values.vibration_enabled); + WriteGlobalSetting(Settings::values.enable_accurate_vibrations); + WriteGlobalSetting(Settings::values.motion_enabled); WriteBasicSetting(Settings::values.enable_raw_input); WriteBasicSetting(Settings::values.keyboard_enabled); WriteBasicSetting(Settings::values.emulate_analog_keyboard); @@ -1617,13 +1579,6 @@ void Config::SaveControlPlayerValue(std::size_t player_index) { qt_config->endGroup(); } -void Config::ClearControlPlayerValues() { - qt_config->beginGroup(QStringLiteral("Controls")); - // If key is an empty string, all keys in the current group() are removed. - qt_config->remove(QString{}); - qt_config->endGroup(); -} - const std::string& Config::GetConfigFilePath() const { return qt_config_loc; } diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 74fa2d9e5..be1602570 100755 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -34,7 +34,6 @@ public: void ReadControlPlayerValue(std::size_t player_index); void SaveControlPlayerValue(std::size_t player_index); - void ClearControlPlayerValues(); const std::string& GetConfigFilePath() const; @@ -59,7 +58,6 @@ public: private: void Initialize(const std::string& config_name); - bool IsCustomConfig(); void ReadValues(); void ReadPlayerValue(std::size_t player_index); diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h index 82c76d0f0..ffd9be0ce 100755 --- a/src/yuzu/configuration/configure_input_player.h +++ b/src/yuzu/configuration/configure_input_player.h @@ -38,7 +38,7 @@ enum class InputType; namespace Ui { class ConfigureInputPlayer; -} // namespace Ui +} namespace Core::HID { class HIDCore; diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index e0c2985e3..d945c5cd8 100755 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -28,7 +28,7 @@ #include "yuzu/configuration/configure_general.h" #include "yuzu/configuration/configure_graphics.h" #include "yuzu/configuration/configure_graphics_advanced.h" -#include "yuzu/configuration/configure_input_per_game.h" +#include "yuzu/configuration/configure_input.h" #include "yuzu/configuration/configure_per_game.h" #include "yuzu/configuration/configure_per_game_addons.h" #include "yuzu/configuration/configure_system.h" @@ -50,7 +50,6 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st general_tab = std::make_unique(system_, this); graphics_tab = std::make_unique(system_, this); graphics_advanced_tab = std::make_unique(system_, this); - input_tab = std::make_unique(system_, game_config.get(), this); system_tab = std::make_unique(system_, this); ui->setupUi(this); @@ -62,7 +61,6 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st ui->tabWidget->addTab(graphics_tab.get(), tr("Graphics")); ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("Adv. Graphics")); ui->tabWidget->addTab(audio_tab.get(), tr("Audio")); - ui->tabWidget->addTab(input_tab.get(), tr("Input Profiles")); setFocusPolicy(Qt::ClickFocus); setWindowTitle(tr("Properties")); @@ -93,7 +91,6 @@ void ConfigurePerGame::ApplyConfiguration() { graphics_tab->ApplyConfiguration(); graphics_advanced_tab->ApplyConfiguration(); audio_tab->ApplyConfiguration(); - input_tab->ApplyConfiguration(); system.ApplySettings(); Settings::LogSettings(); diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h index 4e3fee9aa..6d9bbace3 100755 --- a/src/yuzu/configuration/configure_per_game.h +++ b/src/yuzu/configuration/configure_per_game.h @@ -16,17 +16,12 @@ namespace Core { class System; } -namespace InputCommon { -class InputSubsystem; -} - class ConfigurePerGameAddons; class ConfigureAudio; class ConfigureCpu; class ConfigureGeneral; class ConfigureGraphics; class ConfigureGraphicsAdvanced; -class ConfigureInputPerGame; class ConfigureSystem; class QGraphicsScene; @@ -77,6 +72,5 @@ private: std::unique_ptr general_tab; std::unique_ptr graphics_tab; std::unique_ptr graphics_advanced_tab; - std::unique_ptr input_tab; std::unique_ptr system_tab; }; diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 6ba625e98..b4b1dd043 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -126,7 +126,6 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include "yuzu/compatibility_list.h" #include "yuzu/configuration/config.h" #include "yuzu/configuration/configure_dialog.h" -#include "yuzu/configuration/configure_input_per_game.h" #include "yuzu/debugger/console.h" #include "yuzu/debugger/controller.h" #include "yuzu/debugger/profiler.h" @@ -1671,11 +1670,6 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t LOG_INFO(Frontend, "yuzu starting..."); StoreRecentFile(filename); // Put the filename on top of the list - // Save configurations - UpdateUISettings(); - game_list->SaveInterfaceLayout(); - config->Save(); - u64 title_id{0}; last_filename_booted = filename; @@ -1692,10 +1686,14 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t ? Common::FS::PathToUTF8String(file_path.filename()) : fmt::format("{:016X}", title_id); Config per_game_config(config_file_name, Config::ConfigType::PerGameConfig); - system->HIDCore().ReloadInputDevices(); system->ApplySettings(); } + // Save configurations + UpdateUISettings(); + game_list->SaveInterfaceLayout(); + config->Save(); + Settings::LogSettings(); if (UISettings::values.select_user_on_boot) { @@ -2816,7 +2814,6 @@ void GMainWindow::OnStopGame() { ShutdownGame(); Settings::RestoreGlobalState(system->IsPoweredOn()); - system->HIDCore().ReloadInputDevices(); UpdateStatusButtons(); } @@ -3278,7 +3275,6 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file // Do not cause the global config to write local settings into the config file const bool is_powered_on = system->IsPoweredOn(); Settings::RestoreGlobalState(is_powered_on); - system->HIDCore().ReloadInputDevices(); UISettings::values.configuration_applied = false; @@ -3739,7 +3735,6 @@ void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string detai ShutdownGame(); Settings::RestoreGlobalState(system->IsPoweredOn()); - system->HIDCore().ReloadInputDevices(); UpdateStatusButtons(); } } else { @@ -3891,19 +3886,18 @@ void GMainWindow::closeEvent(QCloseEvent* event) { // Unload controllers early controller_dialog->UnloadController(); game_list->UnloadController(); + system->HIDCore().UnloadInputDevices(); // Shutdown session if the emu thread is active... if (emu_thread != nullptr) { ShutdownGame(); Settings::RestoreGlobalState(system->IsPoweredOn()); - system->HIDCore().ReloadInputDevices(); UpdateStatusButtons(); } render_window->close(); multiplayer_state->Close(); - system->HIDCore().UnloadInputDevices(); system->GetRoomNetwork().Shutdown(); QWidget::closeEvent(event);