yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

Configuration: Add per-game input profiles

This commit is contained in:
ameerj 2022-11-17 19:23:48 -05:00
parent f426fd95fe
commit 9efdad6a27
11 changed files with 465 additions and 14 deletions

View File

@ -391,6 +391,7 @@ struct PlayerInput {
u32 body_color_right; u32 body_color_right;
u32 button_color_left; u32 button_color_left;
u32 button_color_right; u32 button_color_right;
std::string profile_name;
}; };
struct TouchscreenInput { struct TouchscreenInput {

View File

@ -107,10 +107,9 @@ void EmulatedController::ReloadFromSettings() {
original_npad_type = npad_type; original_npad_type = npad_type;
} }
Disconnect();
if (player.connected) { if (player.connected) {
Connect(); Connect();
} else {
Disconnect();
} }
ReloadInput(); ReloadInput();

View File

@ -85,6 +85,9 @@ add_executable(yuzu
configuration/configure_input_advanced.cpp configuration/configure_input_advanced.cpp
configuration/configure_input_advanced.h configuration/configure_input_advanced.h
configuration/configure_input_advanced.ui 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.cpp
configuration/configure_input_player.h configuration/configure_input_player.h
configuration/configure_input_player.ui configuration/configure_input_player.ui

View File

@ -186,7 +186,7 @@ void Config::WriteGlobalSetting(const Settings::SwitchableSetting<Type, ranged>&
void Config::ReadPlayerValue(std::size_t player_index) { void Config::ReadPlayerValue(std::size_t player_index) {
const QString player_prefix = [this, player_index] { const QString player_prefix = [this, player_index] {
if (type == ConfigType::InputProfile) { if (type == ConfigType::InputProfile && global) {
return QString{}; return QString{};
} else { } else {
return QStringLiteral("player_%1_").arg(player_index); return QStringLiteral("player_%1_").arg(player_index);
@ -244,6 +244,14 @@ void Config::ReadPlayerValue(std::size_t player_index) {
->value(QStringLiteral("%1button_color_right").arg(player_prefix), ->value(QStringLiteral("%1button_color_right").arg(player_prefix),
Settings::JOYCON_BUTTONS_NEON_RED) Settings::JOYCON_BUTTONS_NEON_RED)
.toUInt(); .toUInt();
// This only applies to per-game configs
if (!global) {
player.profile_name =
qt_config->value(QStringLiteral("%1profile_name").arg(player_prefix), QString{})
.toString()
.toStdString();
}
} }
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
@ -386,6 +394,7 @@ void Config::ReadAudioValues() {
} }
void Config::ReadControlValues() { void Config::ReadControlValues() {
Settings::values.players.SetGlobal(global);
qt_config->beginGroup(QStringLiteral("Controls")); qt_config->beginGroup(QStringLiteral("Controls"));
for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {
@ -904,7 +913,6 @@ void Config::ReadMultiplayerValues() {
void Config::ReadValues() { void Config::ReadValues() {
if (global) { if (global) {
ReadControlValues();
ReadDataStorageValues(); ReadDataStorageValues();
ReadDebuggingValues(); ReadDebuggingValues();
ReadDisabledAddOnValues(); ReadDisabledAddOnValues();
@ -913,6 +921,7 @@ void Config::ReadValues() {
ReadWebServiceValues(); ReadWebServiceValues();
ReadMiscellaneousValues(); ReadMiscellaneousValues();
} }
ReadControlValues();
ReadCoreValues(); ReadCoreValues();
ReadCpuValues(); ReadCpuValues();
ReadRendererValues(); ReadRendererValues();
@ -923,7 +932,7 @@ void Config::ReadValues() {
void Config::SavePlayerValue(std::size_t player_index) { void Config::SavePlayerValue(std::size_t player_index) {
const QString player_prefix = [this, player_index] { const QString player_prefix = [this, player_index] {
if (type == ConfigType::InputProfile) { if (type == ConfigType::InputProfile && global) {
return QString{}; return QString{};
} else { } else {
return QStringLiteral("player_%1_").arg(player_index); return QStringLiteral("player_%1_").arg(player_index);
@ -951,6 +960,12 @@ void Config::SavePlayerValue(std::size_t player_index) {
player.button_color_left, Settings::JOYCON_BUTTONS_NEON_BLUE); player.button_color_left, Settings::JOYCON_BUTTONS_NEON_BLUE);
WriteSetting(QStringLiteral("%1button_color_right").arg(player_prefix), WriteSetting(QStringLiteral("%1button_color_right").arg(player_prefix),
player.button_color_right, Settings::JOYCON_BUTTONS_NEON_RED); player.button_color_right, Settings::JOYCON_BUTTONS_NEON_RED);
// This only applies to per-game configs
if (!global) {
WriteSetting(QStringLiteral("%1profile_name").arg(player_prefix),
QString::fromStdString(player.profile_name), QString{});
}
} }
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
@ -1054,7 +1069,6 @@ void Config::SaveIrCameraValues() {
void Config::SaveValues() { void Config::SaveValues() {
if (global) { if (global) {
SaveControlValues();
SaveDataStorageValues(); SaveDataStorageValues();
SaveDebuggingValues(); SaveDebuggingValues();
SaveDisabledAddOnValues(); SaveDisabledAddOnValues();
@ -1063,6 +1077,7 @@ void Config::SaveValues() {
SaveWebServiceValues(); SaveWebServiceValues();
SaveMiscellaneousValues(); SaveMiscellaneousValues();
} }
SaveControlValues();
SaveCoreValues(); SaveCoreValues();
SaveCpuValues(); SaveCpuValues();
SaveRendererValues(); SaveRendererValues();
@ -1085,6 +1100,7 @@ void Config::SaveAudioValues() {
} }
void Config::SaveControlValues() { void Config::SaveControlValues() {
Settings::values.players.SetGlobal(global);
qt_config->beginGroup(QStringLiteral("Controls")); qt_config->beginGroup(QStringLiteral("Controls"));
for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {

View File

@ -0,0 +1,76 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/settings.h"
#include "core/core.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h"
#include "ui_configure_input_per_game.h"
#include "yuzu/configuration/configure_input_per_game.h"
#include "yuzu/configuration/input_profiles.h"
ConfigureInputPerGame::ConfigureInputPerGame(Core::System& system_, QWidget* parent)
: QWidget(parent), ui(std::make_unique<Ui::ConfigureInputPerGame>()),
profiles(std::make_unique<InputProfiles>()), system{system_} {
ui->setupUi(this);
Settings::values.players.SetGlobal(false);
const auto previous_profile = Settings::values.players.GetValue()[0].profile_name;
const auto& profile_names = profiles->GetInputProfileNames();
ui->profile_player_1->addItem(QString::fromStdString("Use global configuration"));
for (size_t index = 0; index < profile_names.size(); ++index) {
const auto& profile_name = profile_names[index];
ui->profile_player_1->addItem(QString::fromStdString(profile_name));
if (profile_name == previous_profile) {
// offset by 1 since the first element is the global config
ui->profile_player_1->setCurrentIndex(static_cast<int>(index + 1));
}
}
LoadConfiguration();
}
void ConfigureInputPerGame::ApplyConfiguration() {
LoadConfiguration();
auto& hid_core = system.HIDCore();
auto* emulated_controller = hid_core.GetEmulatedControllerByIndex(0);
const auto selection_index = ui->profile_player_1->currentIndex();
if (selection_index == 0) {
Settings::values.players.SetGlobal(true);
emulated_controller->ReloadFromSettings();
return;
} else {
Settings::values.players.SetGlobal(false);
}
const QString profile_name = ui->profile_player_1->itemText(selection_index);
if (profile_name.isEmpty()) {
return;
}
profiles->SaveProfile(Settings::values.players.GetValue()[0].profile_name, 0);
emulated_controller->ReloadFromSettings();
}
void ConfigureInputPerGame::LoadConfiguration() {
auto& hid_core = system.HIDCore();
auto* emulated_controller = hid_core.GetEmulatedControllerByIndex(0);
Settings::values.players.SetGlobal(false);
const auto selection_index = ui->profile_player_1->currentIndex();
if (selection_index == 0) {
Settings::values.players.GetValue()[0].profile_name = "";
Settings::values.players.SetGlobal(true);
emulated_controller->ReloadFromSettings();
return;
}
const QString profile_name = ui->profile_player_1->itemText(selection_index);
if (profile_name.isEmpty()) {
return;
}
profiles->LoadProfile(profile_name.toStdString(), 0);
Settings::values.players.GetValue()[0].profile_name = profile_name.toStdString();
emulated_controller->ReloadFromSettings();
}

View File

@ -0,0 +1,44 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <QWidget>
namespace Core {
class System;
}
namespace InputCommon {
class InputSubsystem;
}
namespace Ui {
class ConfigureInputPerGame;
}
class InputProfiles;
class ConfigureInputPerGame : public QWidget {
Q_OBJECT
public:
explicit ConfigureInputPerGame(Core::System& system_, QWidget* parent = nullptr);
/// Initializes the input dialog with the given input subsystem.
// void Initialize(InputCommon::InputSubsystem* input_subsystem_, std::size_t max_players = 8);
/// Save configurations to settings file.
void ApplyConfiguration();
private:
/// Load configuration from settings file.
void LoadConfiguration();
std::unique_ptr<Ui::ConfigureInputPerGame> ui;
std::unique_ptr<InputProfiles> profiles;
Core::System& system;
};

View File

@ -0,0 +1,298 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConfigureInputPerGame</class>
<widget class="QWidget" name="PerGameInput">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>541</width>
<height>759</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="accessibleName">
<string>Graphics</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_1">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Input Profiles</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QWidget" name="player_1" native="true">
<layout class="QHBoxLayout" name="input_profile_layout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_player_1">
<property name="text">
<string>Player 1 Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="profile_player_1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="player_3" native="true">
<layout class="QHBoxLayout" name="input_profile_layout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_player_3">
<property name="text">
<string>Player 3 Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="profile_player_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="player_4" native="true">
<layout class="QHBoxLayout" name="input_profile_layout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_player_4">
<property name="text">
<string>Player 4 Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="profile_player_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="player_5" native="true">
<layout class="QHBoxLayout" name="input_profile_layout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_player_5">
<property name="text">
<string>Player 5 Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="profile_player_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="player_6" native="true">
<layout class="QHBoxLayout" name="input_profile_layout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_player_6">
<property name="text">
<string>Player 6 Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="profile_player_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="player_7" native="true">
<layout class="QHBoxLayout" name="input_profile_layout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_player_7">
<property name="text">
<string>Player 7 Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="profile_player_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="player_8" native="true">
<layout class="QHBoxLayout" name="input_profile_layout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_player_8">
<property name="text">
<string>Player 8 Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="profile_player_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -38,7 +38,7 @@ enum class InputType;
namespace Ui { namespace Ui {
class ConfigureInputPlayer; class ConfigureInputPlayer;
} } // namespace Ui
namespace Core::HID { namespace Core::HID {
class HIDCore; class HIDCore;

View File

@ -28,7 +28,7 @@
#include "yuzu/configuration/configure_general.h" #include "yuzu/configuration/configure_general.h"
#include "yuzu/configuration/configure_graphics.h" #include "yuzu/configuration/configure_graphics.h"
#include "yuzu/configuration/configure_graphics_advanced.h" #include "yuzu/configuration/configure_graphics_advanced.h"
#include "yuzu/configuration/configure_input.h" #include "yuzu/configuration/configure_input_per_game.h"
#include "yuzu/configuration/configure_per_game.h" #include "yuzu/configuration/configure_per_game.h"
#include "yuzu/configuration/configure_per_game_addons.h" #include "yuzu/configuration/configure_per_game_addons.h"
#include "yuzu/configuration/configure_system.h" #include "yuzu/configuration/configure_system.h"
@ -50,6 +50,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st
general_tab = std::make_unique<ConfigureGeneral>(system_, this); general_tab = std::make_unique<ConfigureGeneral>(system_, this);
graphics_tab = std::make_unique<ConfigureGraphics>(system_, this); graphics_tab = std::make_unique<ConfigureGraphics>(system_, this);
graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(system_, this); graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(system_, this);
input_tab = std::make_unique<ConfigureInputPerGame>(system_, this);
system_tab = std::make_unique<ConfigureSystem>(system_, this); system_tab = std::make_unique<ConfigureSystem>(system_, this);
ui->setupUi(this); ui->setupUi(this);
@ -61,6 +62,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st
ui->tabWidget->addTab(graphics_tab.get(), tr("Graphics")); ui->tabWidget->addTab(graphics_tab.get(), tr("Graphics"));
ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("Adv. Graphics")); ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("Adv. Graphics"));
ui->tabWidget->addTab(audio_tab.get(), tr("Audio")); ui->tabWidget->addTab(audio_tab.get(), tr("Audio"));
ui->tabWidget->addTab(input_tab.get(), tr("Input Profiles"));
setFocusPolicy(Qt::ClickFocus); setFocusPolicy(Qt::ClickFocus);
setWindowTitle(tr("Properties")); setWindowTitle(tr("Properties"));
@ -91,6 +93,7 @@ void ConfigurePerGame::ApplyConfiguration() {
graphics_tab->ApplyConfiguration(); graphics_tab->ApplyConfiguration();
graphics_advanced_tab->ApplyConfiguration(); graphics_advanced_tab->ApplyConfiguration();
audio_tab->ApplyConfiguration(); audio_tab->ApplyConfiguration();
input_tab->ApplyConfiguration();
system.ApplySettings(); system.ApplySettings();
Settings::LogSettings(); Settings::LogSettings();

View File

@ -16,12 +16,17 @@ namespace Core {
class System; class System;
} }
namespace InputCommon {
class InputSubsystem;
}
class ConfigurePerGameAddons; class ConfigurePerGameAddons;
class ConfigureAudio; class ConfigureAudio;
class ConfigureCpu; class ConfigureCpu;
class ConfigureGeneral; class ConfigureGeneral;
class ConfigureGraphics; class ConfigureGraphics;
class ConfigureGraphicsAdvanced; class ConfigureGraphicsAdvanced;
class ConfigureInputPerGame;
class ConfigureSystem; class ConfigureSystem;
class QGraphicsScene; class QGraphicsScene;
@ -72,5 +77,6 @@ private:
std::unique_ptr<ConfigureGeneral> general_tab; std::unique_ptr<ConfigureGeneral> general_tab;
std::unique_ptr<ConfigureGraphics> graphics_tab; std::unique_ptr<ConfigureGraphics> graphics_tab;
std::unique_ptr<ConfigureGraphicsAdvanced> graphics_advanced_tab; std::unique_ptr<ConfigureGraphicsAdvanced> graphics_advanced_tab;
std::unique_ptr<ConfigureInputPerGame> input_tab;
std::unique_ptr<ConfigureSystem> system_tab; std::unique_ptr<ConfigureSystem> system_tab;
}; };

View File

@ -124,6 +124,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include "yuzu/compatibility_list.h" #include "yuzu/compatibility_list.h"
#include "yuzu/configuration/config.h" #include "yuzu/configuration/config.h"
#include "yuzu/configuration/configure_dialog.h" #include "yuzu/configuration/configure_dialog.h"
#include "yuzu/configuration/configure_input_per_game.h"
#include "yuzu/debugger/console.h" #include "yuzu/debugger/console.h"
#include "yuzu/debugger/controller.h" #include "yuzu/debugger/controller.h"
#include "yuzu/debugger/profiler.h" #include "yuzu/debugger/profiler.h"
@ -1647,6 +1648,11 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
LOG_INFO(Frontend, "yuzu starting..."); LOG_INFO(Frontend, "yuzu starting...");
StoreRecentFile(filename); // Put the filename on top of the list StoreRecentFile(filename); // Put the filename on top of the list
// Save configurations
UpdateUISettings();
game_list->SaveInterfaceLayout();
config->Save();
u64 title_id{0}; u64 title_id{0};
last_filename_booted = filename; last_filename_booted = filename;
@ -1666,11 +1672,6 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
system->ApplySettings(); system->ApplySettings();
} }
// Save configurations
UpdateUISettings();
game_list->SaveInterfaceLayout();
config->Save();
Settings::LogSettings(); Settings::LogSettings();
if (UISettings::values.select_user_on_boot) { if (UISettings::values.select_user_on_boot) {
@ -2790,6 +2791,7 @@ void GMainWindow::OnStopGame() {
ShutdownGame(); ShutdownGame();
Settings::RestoreGlobalState(system->IsPoweredOn()); Settings::RestoreGlobalState(system->IsPoweredOn());
system->HIDCore().ReloadInputDevices();
UpdateStatusButtons(); UpdateStatusButtons();
} }
@ -3250,6 +3252,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 // Do not cause the global config to write local settings into the config file
const bool is_powered_on = system->IsPoweredOn(); const bool is_powered_on = system->IsPoweredOn();
Settings::RestoreGlobalState(is_powered_on); Settings::RestoreGlobalState(is_powered_on);
system->HIDCore().ReloadInputDevices();
UISettings::values.configuration_applied = false; UISettings::values.configuration_applied = false;
@ -3709,6 +3712,7 @@ void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string detai
ShutdownGame(); ShutdownGame();
Settings::RestoreGlobalState(system->IsPoweredOn()); Settings::RestoreGlobalState(system->IsPoweredOn());
system->HIDCore().ReloadInputDevices();
UpdateStatusButtons(); UpdateStatusButtons();
} }
} else { } else {
@ -3860,18 +3864,19 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
// Unload controllers early // Unload controllers early
controller_dialog->UnloadController(); controller_dialog->UnloadController();
game_list->UnloadController(); game_list->UnloadController();
system->HIDCore().UnloadInputDevices();
// Shutdown session if the emu thread is active... // Shutdown session if the emu thread is active...
if (emu_thread != nullptr) { if (emu_thread != nullptr) {
ShutdownGame(); ShutdownGame();
Settings::RestoreGlobalState(system->IsPoweredOn()); Settings::RestoreGlobalState(system->IsPoweredOn());
system->HIDCore().ReloadInputDevices();
UpdateStatusButtons(); UpdateStatusButtons();
} }
render_window->close(); render_window->close();
multiplayer_state->Close(); multiplayer_state->Close();
system->HIDCore().UnloadInputDevices();
system->GetRoomNetwork().Shutdown(); system->GetRoomNetwork().Shutdown();
QWidget::closeEvent(event); QWidget::closeEvent(event);