Merge pull request #9273 from ameerj/per-game-profile

Configuration: Add per-game input profiles
This commit is contained in:
liamwhite 2022-12-04 13:38:01 -05:00 committed by GitHub
commit 522e7c5663
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 587 additions and 27 deletions

View file

@ -126,6 +126,7 @@ 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"
@ -1658,6 +1659,11 @@ 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;
@ -1674,14 +1680,10 @@ 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) {
@ -2802,6 +2804,7 @@ void GMainWindow::OnStopGame() {
ShutdownGame();
Settings::RestoreGlobalState(system->IsPoweredOn());
system->HIDCore().ReloadInputDevices();
UpdateStatusButtons();
}
@ -3281,6 +3284,7 @@ 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;
@ -3764,6 +3768,7 @@ void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string detai
ShutdownGame();
Settings::RestoreGlobalState(system->IsPoweredOn());
system->HIDCore().ReloadInputDevices();
UpdateStatusButtons();
}
} else {
@ -3915,18 +3920,19 @@ 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);