11 changed files with 465 additions and 14 deletions
-
1src/common/settings_input.h
-
3src/core/hid/emulated_controller.cpp
-
3src/yuzu/CMakeLists.txt
-
24src/yuzu/configuration/config.cpp
-
76src/yuzu/configuration/configure_input_per_game.cpp
-
44src/yuzu/configuration/configure_input_per_game.h
-
298src/yuzu/configuration/configure_input_per_game.ui
-
2src/yuzu/configuration/configure_input_player.h
-
5src/yuzu/configuration/configure_per_game.cpp
-
6src/yuzu/configuration/configure_per_game.h
-
17src/yuzu/main.cpp
@ -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(); |
||||
|
} |
||||
@ -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; |
||||
|
}; |
||||
@ -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> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue