Merge pull request #9273 from ameerj/per-game-profile
Configuration: Add per-game input profiles
This commit is contained in:
commit
522e7c5663
|
@ -391,6 +391,7 @@ struct PlayerInput {
|
|||
u32 body_color_right;
|
||||
u32 button_color_left;
|
||||
u32 button_color_right;
|
||||
std::string profile_name;
|
||||
};
|
||||
|
||||
struct TouchscreenInput {
|
||||
|
|
|
@ -110,10 +110,9 @@ void EmulatedController::ReloadFromSettings() {
|
|||
original_npad_type = npad_type;
|
||||
}
|
||||
|
||||
Disconnect();
|
||||
if (player.connected) {
|
||||
Connect();
|
||||
} else {
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
ReloadInput();
|
||||
|
|
|
@ -88,6 +88,9 @@ 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
|
||||
|
|
|
@ -124,6 +124,10 @@ 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.
|
||||
|
@ -194,8 +198,20 @@ 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()) {
|
||||
if (player_prefix.isEmpty() && Settings::IsConfiguringGlobal()) {
|
||||
const auto controller = static_cast<Settings::ControllerType>(
|
||||
qt_config
|
||||
->value(QStringLiteral("%1type").arg(player_prefix),
|
||||
|
@ -388,9 +404,26 @@ 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);
|
||||
}
|
||||
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.SetGlobal(!IsCustomConfig());
|
||||
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();
|
||||
|
@ -412,18 +445,6 @@ 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();
|
||||
|
@ -905,7 +926,6 @@ void Config::ReadMultiplayerValues() {
|
|||
|
||||
void Config::ReadValues() {
|
||||
if (global) {
|
||||
ReadControlValues();
|
||||
ReadDataStorageValues();
|
||||
ReadDebuggingValues();
|
||||
ReadDisabledAddOnValues();
|
||||
|
@ -914,6 +934,7 @@ void Config::ReadValues() {
|
|||
ReadWebServiceValues();
|
||||
ReadMiscellaneousValues();
|
||||
}
|
||||
ReadControlValues();
|
||||
ReadCoreValues();
|
||||
ReadCpuValues();
|
||||
ReadRendererValues();
|
||||
|
@ -932,12 +953,20 @@ 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<u8>(player.controller_type),
|
||||
static_cast<u8>(Settings::ControllerType::ProController));
|
||||
|
||||
if (!player_prefix.isEmpty()) {
|
||||
if (!player_prefix.isEmpty() || !Settings::IsConfiguringGlobal()) {
|
||||
WriteSetting(QStringLiteral("%1connected").arg(player_prefix), player.connected,
|
||||
player_index == 0);
|
||||
WriteSetting(QStringLiteral("%1vibration_enabled").arg(player_prefix),
|
||||
|
@ -1055,7 +1084,6 @@ void Config::SaveIrCameraValues() {
|
|||
|
||||
void Config::SaveValues() {
|
||||
if (global) {
|
||||
SaveControlValues();
|
||||
SaveDataStorageValues();
|
||||
SaveDebuggingValues();
|
||||
SaveDisabledAddOnValues();
|
||||
|
@ -1064,6 +1092,7 @@ void Config::SaveValues() {
|
|||
SaveWebServiceValues();
|
||||
SaveMiscellaneousValues();
|
||||
}
|
||||
SaveControlValues();
|
||||
SaveCoreValues();
|
||||
SaveCpuValues();
|
||||
SaveRendererValues();
|
||||
|
@ -1088,9 +1117,14 @@ 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);
|
||||
}
|
||||
if (IsCustomConfig()) {
|
||||
qt_config->endGroup();
|
||||
return;
|
||||
}
|
||||
SaveDebugValues();
|
||||
SaveMouseValues();
|
||||
SaveTouchscreenValues();
|
||||
|
@ -1579,6 +1613,13 @@ 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;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
|
||||
void ReadControlPlayerValue(std::size_t player_index);
|
||||
void SaveControlPlayerValue(std::size_t player_index);
|
||||
void ClearControlPlayerValues();
|
||||
|
||||
const std::string& GetConfigFilePath() const;
|
||||
|
||||
|
@ -58,6 +59,7 @@ public:
|
|||
|
||||
private:
|
||||
void Initialize(const std::string& config_name);
|
||||
bool IsCustomConfig();
|
||||
|
||||
void ReadValues();
|
||||
void ReadPlayerValue(std::size_t player_index);
|
||||
|
|
115
src/yuzu/configuration/configure_input_per_game.cpp
Normal file
115
src/yuzu/configuration/configure_input_per_game.cpp
Normal file
|
@ -0,0 +1,115 @@
|
|||
// 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/config.h"
|
||||
#include "yuzu/configuration/configure_input_per_game.h"
|
||||
#include "yuzu/configuration/input_profiles.h"
|
||||
|
||||
ConfigureInputPerGame::ConfigureInputPerGame(Core::System& system_, Config* config_,
|
||||
QWidget* parent)
|
||||
: QWidget(parent), ui(std::make_unique<Ui::ConfigureInputPerGame>()),
|
||||
profiles(std::make_unique<InputProfiles>()), system{system_}, config{config_} {
|
||||
ui->setupUi(this);
|
||||
const std::array labels = {
|
||||
ui->label_player_1, ui->label_player_2, ui->label_player_3, ui->label_player_4,
|
||||
ui->label_player_5, ui->label_player_6, ui->label_player_7, ui->label_player_8,
|
||||
};
|
||||
profile_comboboxes = {
|
||||
ui->profile_player_1, ui->profile_player_2, ui->profile_player_3, ui->profile_player_4,
|
||||
ui->profile_player_5, ui->profile_player_6, ui->profile_player_7, ui->profile_player_8,
|
||||
};
|
||||
|
||||
Settings::values.players.SetGlobal(false);
|
||||
|
||||
const auto& profile_names = profiles->GetInputProfileNames();
|
||||
const auto populate_profiles = [this, &profile_names](size_t player_index) {
|
||||
const auto previous_profile =
|
||||
Settings::values.players.GetValue()[player_index].profile_name;
|
||||
|
||||
auto* const player_combobox = profile_comboboxes[player_index];
|
||||
player_combobox->addItem(tr("Use global input configuration"));
|
||||
|
||||
for (size_t index = 0; index < profile_names.size(); ++index) {
|
||||
const auto& profile_name = profile_names[index];
|
||||
player_combobox->addItem(QString::fromStdString(profile_name));
|
||||
if (profile_name == previous_profile) {
|
||||
// offset by 1 since the first element is the global config
|
||||
player_combobox->setCurrentIndex(static_cast<int>(index + 1));
|
||||
}
|
||||
}
|
||||
};
|
||||
for (size_t index = 0; index < profile_comboboxes.size(); ++index) {
|
||||
labels[index]->setText(tr("Player %1 profile").arg(index + 1));
|
||||
populate_profiles(index);
|
||||
}
|
||||
|
||||
LoadConfiguration();
|
||||
}
|
||||
|
||||
void ConfigureInputPerGame::ApplyConfiguration() {
|
||||
LoadConfiguration();
|
||||
SaveConfiguration();
|
||||
}
|
||||
|
||||
void ConfigureInputPerGame::LoadConfiguration() {
|
||||
static constexpr size_t HANDHELD_INDEX = 8;
|
||||
|
||||
auto& hid_core = system.HIDCore();
|
||||
for (size_t player_index = 0; player_index < profile_comboboxes.size(); ++player_index) {
|
||||
Settings::values.players.SetGlobal(false);
|
||||
|
||||
auto* emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index);
|
||||
auto* const player_combobox = profile_comboboxes[player_index];
|
||||
|
||||
const auto selection_index = player_combobox->currentIndex();
|
||||
if (selection_index == 0) {
|
||||
Settings::values.players.GetValue()[player_index].profile_name = "";
|
||||
if (player_index == 0) {
|
||||
Settings::values.players.GetValue()[HANDHELD_INDEX] = {};
|
||||
}
|
||||
Settings::values.players.SetGlobal(true);
|
||||
emulated_controller->ReloadFromSettings();
|
||||
continue;
|
||||
}
|
||||
const auto profile_name = player_combobox->itemText(selection_index).toStdString();
|
||||
if (profile_name.empty()) {
|
||||
continue;
|
||||
}
|
||||
auto& player = Settings::values.players.GetValue()[player_index];
|
||||
player.profile_name = profile_name;
|
||||
// Read from the profile into the custom player settings
|
||||
profiles->LoadProfile(profile_name, player_index);
|
||||
// Make sure the controller is connected
|
||||
player.connected = true;
|
||||
|
||||
emulated_controller->ReloadFromSettings();
|
||||
|
||||
if (player_index > 0) {
|
||||
continue;
|
||||
}
|
||||
// Handle Handheld cases
|
||||
auto& handheld_player = Settings::values.players.GetValue()[HANDHELD_INDEX];
|
||||
auto* handheld_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||
if (player.controller_type == Settings::ControllerType::Handheld) {
|
||||
handheld_player = player;
|
||||
} else {
|
||||
handheld_player = {};
|
||||
}
|
||||
handheld_controller->ReloadFromSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureInputPerGame::SaveConfiguration() {
|
||||
Settings::values.players.SetGlobal(false);
|
||||
|
||||
// Clear all controls from the config in case the user reverted back to globals
|
||||
config->ClearControlPlayerValues();
|
||||
for (size_t index = 0; index < Settings::values.players.GetValue().size(); ++index) {
|
||||
config->SaveControlPlayerValue(index);
|
||||
}
|
||||
}
|
45
src/yuzu/configuration/configure_input_per_game.h
Normal file
45
src/yuzu/configuration/configure_input_per_game.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "ui_configure_input_per_game.h"
|
||||
#include "yuzu/configuration/input_profiles.h"
|
||||
|
||||
class QComboBox;
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
} // namespace Core
|
||||
|
||||
class Config;
|
||||
|
||||
class ConfigureInputPerGame : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigureInputPerGame(Core::System& system_, Config* config_,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
/// Load and Save configurations to settings file.
|
||||
void ApplyConfiguration();
|
||||
|
||||
private:
|
||||
/// Load configuration from settings file.
|
||||
void LoadConfiguration();
|
||||
|
||||
/// Save configuration to settings file.
|
||||
void SaveConfiguration();
|
||||
|
||||
std::unique_ptr<Ui::ConfigureInputPerGame> ui;
|
||||
std::unique_ptr<InputProfiles> profiles;
|
||||
|
||||
std::array<QComboBox*, 8> profile_comboboxes;
|
||||
|
||||
Core::System& system;
|
||||
Config* config;
|
||||
};
|
333
src/yuzu/configuration/configure_input_per_game.ui
Normal file
333
src/yuzu/configuration/configure_input_per_game.ui
Normal file
|
@ -0,0 +1,333 @@
|
|||
<?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_1">
|
||||
<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_2" native="true">
|
||||
<layout class="QHBoxLayout" name="input_profile_layout_2">
|
||||
<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_2">
|
||||
<property name="text">
|
||||
<string>Player 2 Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="profile_player_2">
|
||||
<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_3">
|
||||
<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_4">
|
||||
<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_5">
|
||||
<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_6">
|
||||
<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_7">
|
||||
<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_8">
|
||||
<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>
|
|
@ -1553,6 +1553,7 @@ void ConfigureInputPlayer::LoadProfile() {
|
|||
}
|
||||
|
||||
void ConfigureInputPlayer::SaveProfile() {
|
||||
static constexpr size_t HANDHELD_INDEX = 8;
|
||||
const QString profile_name = ui->comboProfiles->itemText(ui->comboProfiles->currentIndex());
|
||||
|
||||
if (profile_name.isEmpty()) {
|
||||
|
@ -1561,7 +1562,12 @@ void ConfigureInputPlayer::SaveProfile() {
|
|||
|
||||
ApplyConfiguration();
|
||||
|
||||
if (!profiles->SaveProfile(profile_name.toStdString(), player_index)) {
|
||||
// When we're in handheld mode, only the handheld emulated controller bindings are updated
|
||||
const bool is_handheld = player_index == 0 && emulated_controller->GetNpadIdType() ==
|
||||
Core::HID::NpadIdType::Handheld;
|
||||
const auto profile_player_index = is_handheld ? HANDHELD_INDEX : player_index;
|
||||
|
||||
if (!profiles->SaveProfile(profile_name.toStdString(), profile_player_index)) {
|
||||
QMessageBox::critical(this, tr("Save Input Profile"),
|
||||
tr("Failed to save the input profile \"%1\"").arg(profile_name));
|
||||
UpdateInputProfiles();
|
||||
|
|
|
@ -38,7 +38,7 @@ enum class InputType;
|
|||
|
||||
namespace Ui {
|
||||
class ConfigureInputPlayer;
|
||||
}
|
||||
} // namespace Ui
|
||||
|
||||
namespace Core::HID {
|
||||
class HIDCore;
|
||||
|
|
|
@ -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.h"
|
||||
#include "yuzu/configuration/configure_input_per_game.h"
|
||||
#include "yuzu/configuration/configure_per_game.h"
|
||||
#include "yuzu/configuration/configure_per_game_addons.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);
|
||||
graphics_tab = std::make_unique<ConfigureGraphics>(system_, this);
|
||||
graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(system_, this);
|
||||
input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this);
|
||||
system_tab = std::make_unique<ConfigureSystem>(system_, 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_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"));
|
||||
|
@ -91,6 +93,7 @@ void ConfigurePerGame::ApplyConfiguration() {
|
|||
graphics_tab->ApplyConfiguration();
|
||||
graphics_advanced_tab->ApplyConfiguration();
|
||||
audio_tab->ApplyConfiguration();
|
||||
input_tab->ApplyConfiguration();
|
||||
|
||||
system.ApplySettings();
|
||||
Settings::LogSettings();
|
||||
|
|
|
@ -16,12 +16,17 @@ 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;
|
||||
|
@ -72,5 +77,6 @@ private:
|
|||
std::unique_ptr<ConfigureGeneral> general_tab;
|
||||
std::unique_ptr<ConfigureGraphics> graphics_tab;
|
||||
std::unique_ptr<ConfigureGraphicsAdvanced> graphics_advanced_tab;
|
||||
std::unique_ptr<ConfigureInputPerGame> input_tab;
|
||||
std::unique_ptr<ConfigureSystem> system_tab;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue