From a237fb5f759f15e1e1a8f920118e2189ad6d82e0 Mon Sep 17 00:00:00 2001
From: Morph <39850852+Morph1984@users.noreply.github.com>
Date: Thu, 18 Nov 2021 23:09:28 -0500
Subject: configure_graphics_ui: AMD's -> AMD
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
AMD officially markets FSR as AMD FidelityFX™️ Super Resolution
---
src/yuzu/configuration/configure_graphics.ui | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui
index 660b68c1c..9241678e4 100644
--- a/src/yuzu/configuration/configure_graphics.ui
+++ b/src/yuzu/configuration/configure_graphics.ui
@@ -429,7 +429,7 @@
-
- AMD's FidelityFX™️ Super Resolution [Vulkan Only]
+ AMD FidelityFX™️ Super Resolution [Vulkan Only]
--
cgit v1.2.3
From 8e3371a5c5aa26e1f3d0c1f944b65ee6b65c3f34 Mon Sep 17 00:00:00 2001
From: Kewlan
Date: Sun, 21 Nov 2021 16:57:00 +0100
Subject: configure_general: Allow framerate cap to be used in custom game
configs
---
src/yuzu/configuration/config.cpp | 4 +-
src/yuzu/configuration/configure_general.cpp | 20 ++++++
src/yuzu/configuration/configure_general.ui | 99 +++++++++++++++++++++-------
3 files changed, 97 insertions(+), 26 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 8227d06bc..2b670ddfd 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -830,6 +830,7 @@ void Config::ReadRendererValues() {
ReadGlobalSetting(Settings::values.max_anisotropy);
ReadGlobalSetting(Settings::values.use_speed_limit);
ReadGlobalSetting(Settings::values.speed_limit);
+ ReadGlobalSetting(Settings::values.fps_cap);
ReadGlobalSetting(Settings::values.use_disk_shader_cache);
ReadGlobalSetting(Settings::values.gpu_accuracy);
ReadGlobalSetting(Settings::values.use_asynchronous_gpu_emulation);
@@ -844,7 +845,6 @@ void Config::ReadRendererValues() {
ReadGlobalSetting(Settings::values.bg_blue);
if (global) {
- ReadBasicSetting(Settings::values.fps_cap);
ReadBasicSetting(Settings::values.renderer_debug);
ReadBasicSetting(Settings::values.renderer_shader_feedback);
ReadBasicSetting(Settings::values.enable_nsight_aftermath);
@@ -1382,6 +1382,7 @@ void Config::SaveRendererValues() {
WriteGlobalSetting(Settings::values.max_anisotropy);
WriteGlobalSetting(Settings::values.use_speed_limit);
WriteGlobalSetting(Settings::values.speed_limit);
+ WriteGlobalSetting(Settings::values.fps_cap);
WriteGlobalSetting(Settings::values.use_disk_shader_cache);
WriteSetting(QString::fromStdString(Settings::values.gpu_accuracy.GetLabel()),
static_cast(Settings::values.gpu_accuracy.GetValue(global)),
@@ -1405,7 +1406,6 @@ void Config::SaveRendererValues() {
WriteGlobalSetting(Settings::values.bg_blue);
if (global) {
- WriteBasicSetting(Settings::values.fps_cap);
WriteBasicSetting(Settings::values.renderer_debug);
WriteBasicSetting(Settings::values.renderer_shader_feedback);
WriteBasicSetting(Settings::values.enable_nsight_aftermath);
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp
index 7af3ea97e..566879317 100644
--- a/src/yuzu/configuration/configure_general.cpp
+++ b/src/yuzu/configuration/configure_general.cpp
@@ -30,6 +30,9 @@ ConfigureGeneral::ConfigureGeneral(const Core::System& system_, QWidget* parent)
connect(ui->button_reset_defaults, &QPushButton::clicked, this,
&ConfigureGeneral::ResetDefaults);
+
+ ui->fps_cap_label->setVisible(Settings::IsConfiguringGlobal());
+ ui->fps_cap_combobox->setVisible(!Settings::IsConfiguringGlobal());
}
ConfigureGeneral::~ConfigureGeneral() = default;
@@ -57,6 +60,11 @@ void ConfigureGeneral::SetConfiguration() {
} else {
ui->speed_limit->setEnabled(Settings::values.use_speed_limit.GetValue() &&
use_speed_limit != ConfigurationShared::CheckState::Global);
+
+ ui->fps_cap_combobox->setCurrentIndex(Settings::values.fps_cap.UsingGlobal() ? 0 : 1);
+ ui->fps_cap->setEnabled(!Settings::values.fps_cap.UsingGlobal());
+ ConfigurationShared::SetHighlight(ui->fps_cap_layout,
+ !Settings::values.fps_cap.UsingGlobal());
}
}
@@ -106,6 +114,13 @@ void ConfigureGeneral::ApplyConfiguration() {
Qt::Checked);
Settings::values.speed_limit.SetValue(ui->speed_limit->value());
}
+
+ if (ui->fps_cap_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
+ Settings::values.fps_cap.SetGlobal(true);
+ } else {
+ Settings::values.fps_cap.SetGlobal(false);
+ Settings::values.fps_cap.SetValue(ui->fps_cap->value());
+ }
}
}
@@ -148,4 +163,9 @@ void ConfigureGeneral::SetupPerGameUI() {
ui->speed_limit->setEnabled(ui->toggle_speed_limit->isChecked() &&
(use_speed_limit != ConfigurationShared::CheckState::Global));
});
+
+ connect(ui->fps_cap_combobox, qOverload(&QComboBox::activated), this, [this](int index) {
+ ui->fps_cap->setEnabled(index == 1);
+ ConfigurationShared::SetHighlight(ui->fps_cap_layout, index == 1);
+ });
}
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui
index f9f0e3ebf..112dc72b3 100644
--- a/src/yuzu/configuration/configure_general.ui
+++ b/src/yuzu/configuration/configure_general.ui
@@ -6,8 +6,8 @@
0
0
- 329
- 407
+ 744
+ 568
@@ -28,34 +28,85 @@
-
-
-
-
-
-
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
-
+
+
+ Use global framerate cap
+
+
+ 0
+
+
-
- Framerate Cap
+ Use global framerate cap
-
- Requires the use of the FPS Limiter Toggle hotkey to take effect.
+
+ -
+
+ Set framerate cap:
+
-
- -
-
-
- x
-
-
- 1
-
-
- 1000
-
-
- 500
-
+
+ -
+
+
+ Requires the use of the FPS Limiter Toggle hotkey to take effect.
+
+
+ Framerate Cap
+
-
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ x
+
+
+ 1
+
+
+ 1000
+
+
+ 500
+
+
+
+
-
--
cgit v1.2.3
From 5a785ed794fff8c944283271bf25cb835c11700a Mon Sep 17 00:00:00 2001
From: german77
Date: Mon, 20 Sep 2021 17:18:40 -0500
Subject: input_common: Rewrite keyboard
---
src/yuzu/configuration/configure_input_player.cpp | 83 +----------------------
1 file changed, 1 insertion(+), 82 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 3aab5d5f8..09f0b219b 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -16,10 +16,7 @@
#include "core/hle/service/hid/controllers/npad.h"
#include "core/hle/service/hid/hid.h"
#include "core/hle/service/sm/sm.h"
-#include "input_common/gcadapter/gc_poller.h"
#include "input_common/main.h"
-#include "input_common/mouse/mouse_poller.h"
-#include "input_common/udp/udp.h"
#include "ui_configure_input_player.h"
#include "yuzu/bootmanager.h"
#include "yuzu/configuration/config.h"
@@ -564,55 +561,6 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
connect(poll_timer.get(), &QTimer::timeout, [this] {
Common::ParamPackage params;
- if (input_subsystem->GetGCButtons()->IsPolling()) {
- params = input_subsystem->GetGCButtons()->GetNextInput();
- if (params.Has("engine") && IsInputAcceptable(params)) {
- SetPollingResult(params, false);
- return;
- }
- }
- if (input_subsystem->GetGCAnalogs()->IsPolling()) {
- params = input_subsystem->GetGCAnalogs()->GetNextInput();
- if (params.Has("engine") && IsInputAcceptable(params)) {
- SetPollingResult(params, false);
- return;
- }
- }
- if (input_subsystem->GetUDPMotions()->IsPolling()) {
- params = input_subsystem->GetUDPMotions()->GetNextInput();
- if (params.Has("engine")) {
- SetPollingResult(params, false);
- return;
- }
- }
- if (input_subsystem->GetMouseButtons()->IsPolling()) {
- params = input_subsystem->GetMouseButtons()->GetNextInput();
- if (params.Has("engine") && IsInputAcceptable(params)) {
- SetPollingResult(params, false);
- return;
- }
- }
- if (input_subsystem->GetMouseAnalogs()->IsPolling()) {
- params = input_subsystem->GetMouseAnalogs()->GetNextInput();
- if (params.Has("engine") && IsInputAcceptable(params)) {
- SetPollingResult(params, false);
- return;
- }
- }
- if (input_subsystem->GetMouseMotions()->IsPolling()) {
- params = input_subsystem->GetMouseMotions()->GetNextInput();
- if (params.Has("engine") && IsInputAcceptable(params)) {
- SetPollingResult(params, false);
- return;
- }
- }
- if (input_subsystem->GetMouseTouch()->IsPolling()) {
- params = input_subsystem->GetMouseTouch()->GetNextInput();
- if (params.Has("engine") && IsInputAcceptable(params)) {
- SetPollingResult(params, false);
- return;
- }
- }
for (auto& poller : device_pollers) {
params = poller->GetNextInput();
if (params.Has("engine") && IsInputAcceptable(params)) {
@@ -1353,25 +1301,6 @@ void ConfigureInputPlayer::HandleClick(
QWidget::grabMouse();
QWidget::grabKeyboard();
- if (type == InputCommon::Polling::DeviceType::Button) {
- input_subsystem->GetGCButtons()->BeginConfiguration();
- } else {
- input_subsystem->GetGCAnalogs()->BeginConfiguration();
- }
-
- if (type == InputCommon::Polling::DeviceType::Motion) {
- input_subsystem->GetUDPMotions()->BeginConfiguration();
- }
-
- if (type == InputCommon::Polling::DeviceType::Button) {
- input_subsystem->GetMouseButtons()->BeginConfiguration();
- } else if (type == InputCommon::Polling::DeviceType::AnalogPreferred) {
- input_subsystem->GetMouseAnalogs()->BeginConfiguration();
- } else if (type == InputCommon::Polling::DeviceType::Motion) {
- input_subsystem->GetMouseMotions()->BeginConfiguration();
- } else {
- input_subsystem->GetMouseTouch()->BeginConfiguration();
- }
if (type == InputCommon::Polling::DeviceType::Button) {
ui->controllerFrame->BeginMappingButton(button_id);
@@ -1393,15 +1322,6 @@ void ConfigureInputPlayer::SetPollingResult(const Common::ParamPackage& params,
QWidget::releaseMouse();
QWidget::releaseKeyboard();
- input_subsystem->GetGCButtons()->EndConfiguration();
- input_subsystem->GetGCAnalogs()->EndConfiguration();
-
- input_subsystem->GetUDPMotions()->EndConfiguration();
-
- input_subsystem->GetMouseButtons()->EndConfiguration();
- input_subsystem->GetMouseAnalogs()->EndConfiguration();
- input_subsystem->GetMouseMotions()->EndConfiguration();
- input_subsystem->GetMouseTouch()->EndConfiguration();
if (!abort) {
(*input_setter)(params);
@@ -1435,8 +1355,7 @@ void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) {
return;
}
- const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
- input_subsystem->GetMouse()->PressButton(0, 0, button);
+ //const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
}
void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) {
--
cgit v1.2.3
From c405a19b73fa1e084918a2d39336363cd0f8b567 Mon Sep 17 00:00:00 2001
From: german77
Date: Mon, 20 Sep 2021 19:47:45 -0500
Subject: yuzu: Update frontend
---
src/yuzu/configuration/config.cpp | 1 -
src/yuzu/configuration/configure_input.cpp | 16 +-
src/yuzu/configuration/configure_input.h | 3 +-
src/yuzu/configuration/configure_input_player.cpp | 922 ++++++++-------------
src/yuzu/configuration/configure_input_player.h | 49 +-
src/yuzu/configuration/configure_input_player.ui | 10 -
.../configure_input_player_widget.cpp | 597 +++++++------
.../configuration/configure_input_player_widget.h | 133 +--
src/yuzu/configuration/configure_motion_touch.cpp | 4 +-
.../configuration/configure_mouse_advanced.cpp | 57 +-
src/yuzu/configuration/configure_mouse_advanced.h | 8 +-
.../configuration/configure_touch_from_button.cpp | 27 +-
.../configuration/configure_touch_from_button.h | 5 -
13 files changed, 822 insertions(+), 1010 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 2b670ddfd..56af07507 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -11,7 +11,6 @@
#include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/hid/controllers/npad.h"
#include "input_common/main.h"
-#include "input_common/udp/client.h"
#include "yuzu/configuration/config.h"
namespace FS = Common::FS;
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp
index 1599299db..61513865f 100644
--- a/src/yuzu/configuration/configure_input.cpp
+++ b/src/yuzu/configuration/configure_input.cpp
@@ -73,7 +73,7 @@ ConfigureInput::ConfigureInput(Core::System& system_, QWidget* parent)
ConfigureInput::~ConfigureInput() = default;
-void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
+void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, Core::System& system,
std::size_t max_players) {
player_controllers = {
new ConfigureInputPlayer(this, 0, ui->consoleInputSettings, input_subsystem, profiles.get(),
@@ -184,22 +184,8 @@ QList ConfigureInput::GetSubTabs() const {
void ConfigureInput::ApplyConfiguration() {
for (auto* controller : player_controllers) {
controller->ApplyConfiguration();
- controller->TryDisconnectSelectedController();
}
- // This emulates a delay between disconnecting and reconnecting controllers as some games
- // do not respond to a change in controller type if it was instantaneous.
- using namespace std::chrono_literals;
- std::this_thread::sleep_for(150ms);
-
- for (auto* controller : player_controllers) {
- controller->TryConnectSelectedController();
- }
-
- // This emulates a delay between disconnecting and reconnecting controllers as some games
- // do not respond to a change in controller type if it was instantaneous.
- std::this_thread::sleep_for(150ms);
-
advanced->ApplyConfiguration();
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
diff --git a/src/yuzu/configuration/configure_input.h b/src/yuzu/configuration/configure_input.h
index 4cafa3dab..6e5edad58 100644
--- a/src/yuzu/configuration/configure_input.h
+++ b/src/yuzu/configuration/configure_input.h
@@ -42,7 +42,8 @@ public:
~ConfigureInput() override;
/// Initializes the input dialog with the given input subsystem.
- void Initialize(InputCommon::InputSubsystem* input_subsystem_, std::size_t max_players = 8);
+ void Initialize(InputCommon::InputSubsystem* input_subsystem_, Core::System& system,
+ std::size_t max_players = 8);
/// Save all button configurations to settings file.
void ApplyConfiguration();
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 09f0b219b..adc9706f1 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -13,9 +13,11 @@
#include
#include "common/param_package.h"
#include "core/core.h"
-#include "core/hle/service/hid/controllers/npad.h"
-#include "core/hle/service/hid/hid.h"
-#include "core/hle/service/sm/sm.h"
+#include "core/hid/emulated_controller.h"
+#include "core/hid/hid_core.h"
+#include "core/hid/hid_types.h"
+#include "input_common/drivers/keyboard.h"
+#include "input_common/drivers/mouse.h"
#include "input_common/main.h"
#include "ui_configure_input_player.h"
#include "yuzu/bootmanager.h"
@@ -26,8 +28,6 @@
#include "yuzu/configuration/input_profiles.h"
#include "yuzu/util/limitable_input_dialog.h"
-using namespace Service::HID;
-
const std::array
ConfigureInputPlayer::analog_sub_buttons{{
"up",
@@ -40,31 +40,8 @@ namespace {
constexpr std::size_t HANDHELD_INDEX = 8;
-void UpdateController(Settings::ControllerType controller_type, std::size_t npad_index,
- bool connected, Core::System& system) {
- if (!system.IsPoweredOn()) {
- return;
- }
- Service::SM::ServiceManager& sm = system.ServiceManager();
-
- auto& npad = sm.GetService("hid")->GetAppletResource()->GetController(
- HidController::NPad);
-
- npad.UpdateControllerAt(npad.MapSettingsTypeToNPad(controller_type), npad_index, connected);
-}
-
QString GetKeyName(int key_code) {
switch (key_code) {
- case Qt::LeftButton:
- return QObject::tr("Click 0");
- case Qt::RightButton:
- return QObject::tr("Click 1");
- case Qt::MiddleButton:
- return QObject::tr("Click 2");
- case Qt::BackButton:
- return QObject::tr("Click 3");
- case Qt::ForwardButton:
- return QObject::tr("Click 4");
case Qt::Key_Shift:
return QObject::tr("Shift");
case Qt::Key_Control:
@@ -94,95 +71,26 @@ void SetAnalogParam(const Common::ParamPackage& input_param, Common::ParamPackag
}
analog_param.Set(button_name, input_param.Serialize());
}
+} // namespace
-QString ButtonToText(const Common::ParamPackage& param) {
+QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) {
if (!param.Has("engine")) {
return QObject::tr("[not set]");
}
+ // Retrieve the names from Qt
if (param.Get("engine", "") == "keyboard") {
const QString button_str = GetKeyName(param.Get("code", 0));
const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : "");
return QObject::tr("%1%2").arg(toggle, button_str);
}
- if (param.Get("engine", "") == "gcpad") {
- if (param.Has("axis")) {
- const QString axis_str = QString::fromStdString(param.Get("axis", ""));
- const QString direction_str = QString::fromStdString(param.Get("direction", ""));
-
- return QObject::tr("GC Axis %1%2").arg(axis_str, direction_str);
- }
- if (param.Has("button")) {
- const QString button_str = QString::number(int(std::log2(param.Get("button", 0))));
- return QObject::tr("GC Button %1").arg(button_str);
- }
- return GetKeyName(param.Get("code", 0));
- }
-
- if (param.Get("engine", "") == "tas") {
- if (param.Has("axis")) {
- const QString axis_str = QString::fromStdString(param.Get("axis", ""));
-
- return QObject::tr("TAS Axis %1").arg(axis_str);
- }
- if (param.Has("button")) {
- const QString button_str = QString::number(int(std::log2(param.Get("button", 0))));
- return QObject::tr("TAS Btn %1").arg(button_str);
- }
- return GetKeyName(param.Get("code", 0));
- }
-
- if (param.Get("engine", "") == "cemuhookudp") {
- if (param.Has("pad_index")) {
- const QString motion_str = QString::fromStdString(param.Get("pad_index", ""));
- return QObject::tr("Motion %1").arg(motion_str);
- }
- return GetKeyName(param.Get("code", 0));
- }
-
- if (param.Get("engine", "") == "sdl") {
- if (param.Has("hat")) {
- const QString hat_str = QString::fromStdString(param.Get("hat", ""));
- const QString direction_str = QString::fromStdString(param.Get("direction", ""));
-
- return QObject::tr("Hat %1 %2").arg(hat_str, direction_str);
- }
-
- if (param.Has("axis")) {
- const QString axis_str = QString::fromStdString(param.Get("axis", ""));
- const QString direction_str = QString::fromStdString(param.Get("direction", ""));
-
- return QObject::tr("Axis %1%2").arg(axis_str, direction_str);
- }
-
- if (param.Has("button")) {
- const QString button_str = QString::fromStdString(param.Get("button", ""));
- const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : "");
-
- return QObject::tr("%1Button %2").arg(toggle, button_str);
- }
-
- if (param.Has("motion")) {
- return QObject::tr("SDL Motion");
- }
-
- return {};
- }
-
- if (param.Get("engine", "") == "mouse") {
- if (param.Has("button")) {
- const QString button_str = QString::number(int(param.Get("button", 0)));
- const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : "");
- return QObject::tr("%1Click %2").arg(toggle, button_str);
- }
- return GetKeyName(param.Get("code", 0));
- }
-
- return QObject::tr("[unknown]");
+ std::string button_name = input_subsystem->GetButtonName(param);
+ return QString::fromStdString(button_name);
}
-QString AnalogToText(const Common::ParamPackage& param, const std::string& dir) {
+QString ConfigureInputPlayer::AnalogToText(const Common::ParamPackage& param,
+ const std::string& dir) {
if (!param.Has("engine")) {
return QObject::tr("[not set]");
}
@@ -191,39 +99,39 @@ QString AnalogToText(const Common::ParamPackage& param, const std::string& dir)
return ButtonToText(Common::ParamPackage{param.Get(dir, "")});
}
+ if (!param.Has("axis_x") || !param.Has("axis_y")) {
+ return QObject::tr("[unknown]");
+ }
+
const auto engine_str = param.Get("engine", "");
const QString axis_x_str = QString::fromStdString(param.Get("axis_x", ""));
const QString axis_y_str = QString::fromStdString(param.Get("axis_y", ""));
const bool invert_x = param.Get("invert_x", "+") == "-";
const bool invert_y = param.Get("invert_y", "+") == "-";
- if (engine_str == "sdl" || engine_str == "gcpad" || engine_str == "mouse" ||
- engine_str == "tas") {
- if (dir == "modifier") {
- return QObject::tr("[unused]");
- }
- if (dir == "left") {
- const QString invert_x_str = QString::fromStdString(invert_x ? "+" : "-");
- return QObject::tr("Axis %1%2").arg(axis_x_str, invert_x_str);
- }
- if (dir == "right") {
- const QString invert_x_str = QString::fromStdString(invert_x ? "-" : "+");
- return QObject::tr("Axis %1%2").arg(axis_x_str, invert_x_str);
- }
- if (dir == "up") {
- const QString invert_y_str = QString::fromStdString(invert_y ? "-" : "+");
- return QObject::tr("Axis %1%2").arg(axis_y_str, invert_y_str);
- }
- if (dir == "down") {
- const QString invert_y_str = QString::fromStdString(invert_y ? "+" : "-");
- return QObject::tr("Axis %1%2").arg(axis_y_str, invert_y_str);
- }
+ if (dir == "modifier") {
+ return QObject::tr("[unused]");
+ }
- return {};
+ if (dir == "left") {
+ const QString invert_x_str = QString::fromStdString(invert_x ? "+" : "-");
+ return QObject::tr("Axis %1%2").arg(axis_x_str, invert_x_str);
+ }
+ if (dir == "right") {
+ const QString invert_x_str = QString::fromStdString(invert_x ? "-" : "+");
+ return QObject::tr("Axis %1%2").arg(axis_x_str, invert_x_str);
+ }
+ if (dir == "up") {
+ const QString invert_y_str = QString::fromStdString(invert_y ? "-" : "+");
+ return QObject::tr("Axis %1%2").arg(axis_y_str, invert_y_str);
}
+ if (dir == "down") {
+ const QString invert_y_str = QString::fromStdString(invert_y ? "+" : "-");
+ return QObject::tr("Axis %1%2").arg(axis_y_str, invert_y_str);
+ }
+
return QObject::tr("[unknown]");
}
-} // namespace
ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_index,
QWidget* bottom_row,
@@ -234,6 +142,9 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
debug(debug), input_subsystem{input_subsystem_}, profiles(profiles_),
timeout_timer(std::make_unique()), poll_timer(std::make_unique()),
bottom_row(bottom_row), system{system_} {
+
+ emulated_controller = system_.HIDCore().GetEmulatedControllerByIndex(player_index);
+ emulated_controller->EnableConfiguration();
ui->setupUi(this);
setFocusPolicy(Qt::ClickFocus);
@@ -275,31 +186,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
analog_map_range_groupbox = {ui->buttonLStickRangeGroup, ui->buttonRStickRangeGroup};
analog_map_range_spinbox = {ui->spinboxLStickRange, ui->spinboxRStickRange};
- const auto ConfigureButtonClick = [&](QPushButton* button, std::size_t button_id,
- Common::ParamPackage* param, int default_val,
- InputCommon::Polling::DeviceType type) {
- connect(button, &QPushButton::clicked, [=, this] {
- HandleClick(
- button, button_id,
- [=, this](Common::ParamPackage params) {
- // Workaround for ZL & ZR for analog triggers like on XBOX
- // controllers. Analog triggers (from controllers like the XBOX
- // controller) would not work due to a different range of their
- // signals (from 0 to 255 on analog triggers instead of -32768 to
- // 32768 on analog joysticks). The SDL driver misinterprets analog
- // triggers as analog joysticks.
- // TODO: reinterpret the signal range for analog triggers to map the
- // values correctly. This is required for the correct emulation of
- // the analog triggers of the GameCube controller.
- if (button == ui->buttonZL || button == ui->buttonZR) {
- params.Set("direction", "+");
- params.Set("threshold", "0.5");
- }
- *param = std::move(params);
- },
- type);
- });
- };
+ ui->controllerFrame->SetController(emulated_controller);
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) {
auto* const button = button_map[button_id];
@@ -308,34 +195,52 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
continue;
}
- ConfigureButtonClick(button_map[button_id], button_id, &buttons_param[button_id],
- Config::default_buttons[button_id],
- InputCommon::Polling::DeviceType::Button);
+ connect(button, &QPushButton::clicked, [=, this] {
+ HandleClick(
+ button, button_id,
+ [=, this](Common::ParamPackage params) {
+ emulated_controller->SetButtonParam(button_id, params);
+ },
+ InputCommon::Polling::InputType::Button);
+ });
button->setContextMenuPolicy(Qt::CustomContextMenu);
connect(button, &QPushButton::customContextMenuRequested,
[=, this](const QPoint& menu_location) {
QMenu context_menu;
+ Common::ParamPackage param = emulated_controller->GetButtonParam(button_id);
context_menu.addAction(tr("Clear"), [&] {
- buttons_param[button_id].Clear();
+ emulated_controller->SetButtonParam(button_id, {});
button_map[button_id]->setText(tr("[not set]"));
});
- if (buttons_param[button_id].Has("toggle")) {
+ if (param.Has("button") || param.Has("hat")) {
context_menu.addAction(tr("Toggle button"), [&] {
- const bool toggle_value =
- !buttons_param[button_id].Get("toggle", false);
- buttons_param[button_id].Set("toggle", toggle_value);
- button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
+ const bool toggle_value = !param.Get("toggle", false);
+ param.Set("toggle", toggle_value);
+ button_map[button_id]->setText(ButtonToText(param));
+ emulated_controller->SetButtonParam(button_id, param);
+ });
+ context_menu.addAction(tr("Invert button"), [&] {
+ const bool toggle_value = !param.Get("inverted", false);
+ param.Set("inverted", toggle_value);
+ button_map[button_id]->setText(ButtonToText(param));
+ emulated_controller->SetButtonParam(button_id, param);
});
}
- if (buttons_param[button_id].Has("threshold")) {
+ if (param.Has("axis")) {
+ context_menu.addAction(tr("Invert axis"), [&] {
+ const bool toggle_value = !(param.Get("invert", "+") == "-");
+ param.Set("invert", toggle_value ? "-" : "+");
+ button_map[button_id]->setText(ButtonToText(param));
+ emulated_controller->SetButtonParam(button_id, param);
+ });
context_menu.addAction(tr("Set threshold"), [&] {
- const int button_threshold = static_cast(
- buttons_param[button_id].Get("threshold", 0.5f) * 100.0f);
+ const int button_threshold =
+ static_cast(param.Get("threshold", 0.5f) * 100.0f);
const int new_threshold = QInputDialog::getInt(
this, tr("Set threshold"), tr("Choose a value between 0% and 100%"),
button_threshold, 0, 100);
- buttons_param[button_id].Set("threshold", new_threshold / 100.0f);
+ param.Set("threshold", new_threshold / 100.0f);
if (button_id == Settings::NativeButton::ZL) {
ui->sliderZLThreshold->setValue(new_threshold);
@@ -343,11 +248,10 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
if (button_id == Settings::NativeButton::ZR) {
ui->sliderZRThreshold->setValue(new_threshold);
}
+ emulated_controller->SetButtonParam(button_id, param);
});
}
-
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
- ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param);
});
}
@@ -357,9 +261,14 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
continue;
}
- ConfigureButtonClick(motion_map[motion_id], motion_id, &motions_param[motion_id],
- Config::default_motions[motion_id],
- InputCommon::Polling::DeviceType::Motion);
+ connect(button, &QPushButton::clicked, [=, this] {
+ HandleClick(
+ button, motion_id,
+ [=, this](Common::ParamPackage params) {
+ emulated_controller->SetMotionParam(motion_id, params);
+ },
+ InputCommon::Polling::InputType::Motion);
+ });
button->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -367,7 +276,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
[=, this](const QPoint& menu_location) {
QMenu context_menu;
context_menu.addAction(tr("Clear"), [&] {
- motions_param[motion_id].Clear();
+ emulated_controller->SetMotionParam(motion_id, {});
motion_map[motion_id]->setText(tr("[not set]"));
});
context_menu.exec(motion_map[motion_id]->mapToGlobal(menu_location));
@@ -375,16 +284,22 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
}
connect(ui->sliderZLThreshold, &QSlider::valueChanged, [=, this] {
- if (buttons_param[Settings::NativeButton::ZL].Has("threshold")) {
+ Common::ParamPackage param =
+ emulated_controller->GetButtonParam(Settings::NativeButton::ZL);
+ if (param.Has("threshold")) {
const auto slider_value = ui->sliderZLThreshold->value();
- buttons_param[Settings::NativeButton::ZL].Set("threshold", slider_value / 100.0f);
+ param.Set("threshold", slider_value / 100.0f);
+ emulated_controller->SetButtonParam(Settings::NativeButton::ZL, param);
}
});
connect(ui->sliderZRThreshold, &QSlider::valueChanged, [=, this] {
- if (buttons_param[Settings::NativeButton::ZR].Has("threshold")) {
+ Common::ParamPackage param =
+ emulated_controller->GetButtonParam(Settings::NativeButton::ZR);
+ if (param.Has("threshold")) {
const auto slider_value = ui->sliderZRThreshold->value();
- buttons_param[Settings::NativeButton::ZR].Set("threshold", slider_value / 100.0f);
+ param.Set("threshold", slider_value / 100.0f);
+ emulated_controller->SetButtonParam(Settings::NativeButton::ZR, param);
}
});
@@ -412,45 +327,45 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
HandleClick(
analog_map_buttons[analog_id][sub_button_id], analog_id,
[=, this](const Common::ParamPackage& params) {
- SetAnalogParam(params, analogs_param[analog_id],
- analog_sub_buttons[sub_button_id]);
+ Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
+ SetAnalogParam(params, param, analog_sub_buttons[sub_button_id]);
+ emulated_controller->SetStickParam(analog_id, param);
},
- InputCommon::Polling::DeviceType::AnalogPreferred);
+ InputCommon::Polling::InputType::Stick);
});
analog_button->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(
- analog_button, &QPushButton::customContextMenuRequested,
- [=, this](const QPoint& menu_location) {
- QMenu context_menu;
- context_menu.addAction(tr("Clear"), [&] {
- analogs_param[analog_id].Clear();
- analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]"));
- });
- context_menu.addAction(tr("Invert axis"), [&] {
- if (sub_button_id == 2 || sub_button_id == 3) {
- const bool invert_value =
- analogs_param[analog_id].Get("invert_x", "+") == "-";
- const std::string invert_str = invert_value ? "+" : "-";
- analogs_param[analog_id].Set("invert_x", invert_str);
- }
- if (sub_button_id == 0 || sub_button_id == 1) {
- const bool invert_value =
- analogs_param[analog_id].Get("invert_y", "+") == "-";
- const std::string invert_str = invert_value ? "+" : "-";
- analogs_param[analog_id].Set("invert_y", invert_str);
- }
- for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM;
- ++sub_button_id) {
- analog_map_buttons[analog_id][sub_button_id]->setText(AnalogToText(
- analogs_param[analog_id], analog_sub_buttons[sub_button_id]));
- }
+ connect(analog_button, &QPushButton::customContextMenuRequested,
+ [=, this](const QPoint& menu_location) {
+ QMenu context_menu;
+ Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
+ context_menu.addAction(tr("Clear"), [&] {
+ emulated_controller->SetStickParam(analog_id, {});
+ analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]"));
+ });
+ context_menu.addAction(tr("Invert axis"), [&] {
+ if (sub_button_id == 2 || sub_button_id == 3) {
+ const bool invert_value = param.Get("invert_x", "+") == "-";
+ const std::string invert_str = invert_value ? "+" : "-";
+ param.Set("invert_x", invert_str);
+ emulated_controller->SetStickParam(analog_id, param);
+ }
+ if (sub_button_id == 0 || sub_button_id == 1) {
+ const bool invert_value = param.Get("invert_y", "+") == "-";
+ const std::string invert_str = invert_value ? "+" : "-";
+ param.Set("invert_y", invert_str);
+ emulated_controller->SetStickParam(analog_id, param);
+ }
+ for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM;
+ ++sub_button_id) {
+ analog_map_buttons[analog_id][sub_button_id]->setText(
+ AnalogToText(param, analog_sub_buttons[sub_button_id]));
+ }
+ });
+ context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(
+ menu_location));
});
- context_menu.exec(
- analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(menu_location));
- ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param);
- });
}
// Handle clicks for the modifier buttons as well.
@@ -458,9 +373,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
HandleClick(
analog_map_modifier_button[analog_id], analog_id,
[=, this](const Common::ParamPackage& params) {
- analogs_param[analog_id].Set("modifier", params.Serialize());
+ Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
+ param.Set("modifier", params.Serialize());
+ emulated_controller->SetStickParam(analog_id, param);
},
- InputCommon::Polling::DeviceType::Button);
+ InputCommon::Polling::InputType::Button);
});
analog_map_modifier_button[analog_id]->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -468,18 +385,21 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
connect(analog_map_modifier_button[analog_id], &QPushButton::customContextMenuRequested,
[=, this](const QPoint& menu_location) {
QMenu context_menu;
+ Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
context_menu.addAction(tr("Clear"), [&] {
- analogs_param[analog_id].Set("modifier", "");
+ param.Set("modifier", "");
analog_map_modifier_button[analog_id]->setText(tr("[not set]"));
+ emulated_controller->SetStickParam(analog_id, param);
});
context_menu.addAction(tr("Toggle button"), [&] {
Common::ParamPackage modifier_param =
- Common::ParamPackage{analogs_param[analog_id].Get("modifier", "")};
+ Common::ParamPackage{param.Get("modifier", "")};
const bool toggle_value = !modifier_param.Get("toggle", false);
modifier_param.Set("toggle", toggle_value);
- analogs_param[analog_id].Set("modifier", modifier_param.Serialize());
+ param.Set("modifier", modifier_param.Serialize());
analog_map_modifier_button[analog_id]->setText(
ButtonToText(modifier_param));
+ emulated_controller->SetStickParam(analog_id, param);
});
context_menu.exec(
analog_map_modifier_button[analog_id]->mapToGlobal(menu_location));
@@ -487,37 +407,39 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
connect(analog_map_range_spinbox[analog_id], qOverload(&QSpinBox::valueChanged),
[=, this] {
+ Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
const auto spinbox_value = analog_map_range_spinbox[analog_id]->value();
- analogs_param[analog_id].Set("range", spinbox_value / 100.0f);
- ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param);
+ param.Set("range", spinbox_value / 100.0f);
+ emulated_controller->SetStickParam(analog_id, param);
});
connect(analog_map_deadzone_slider[analog_id], &QSlider::valueChanged, [=, this] {
+ Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
const auto slider_value = analog_map_deadzone_slider[analog_id]->value();
analog_map_deadzone_label[analog_id]->setText(tr("Deadzone: %1%").arg(slider_value));
- analogs_param[analog_id].Set("deadzone", slider_value / 100.0f);
- ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param);
+ param.Set("deadzone", slider_value / 100.0f);
+ emulated_controller->SetStickParam(analog_id, param);
});
connect(analog_map_modifier_slider[analog_id], &QSlider::valueChanged, [=, this] {
+ Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
const auto slider_value = analog_map_modifier_slider[analog_id]->value();
analog_map_modifier_label[analog_id]->setText(
tr("Modifier Range: %1%").arg(slider_value));
- analogs_param[analog_id].Set("modifier_scale", slider_value / 100.0f);
+ param.Set("modifier_scale", slider_value / 100.0f);
+ emulated_controller->SetStickParam(analog_id, param);
});
}
// Player Connected checkbox
- connect(ui->groupConnectedController, &QGroupBox::toggled, [this](bool checked) {
- emit Connected(checked);
- ui->controllerFrame->SetConnectedStatus(checked);
- });
+ connect(ui->groupConnectedController, &QGroupBox::toggled,
+ [this](bool checked) { emit Connected(checked); });
if (player_index == 0) {
connect(ui->comboControllerType, qOverload(&QComboBox::currentIndexChanged),
[this](int index) {
emit HandheldStateChanged(GetControllerTypeFromIndex(index) ==
- Settings::ControllerType::Handheld);
+ Core::HID::NpadType::Handheld);
});
}
@@ -534,13 +456,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
SetConnectableControllers();
}
- UpdateControllerIcon();
UpdateControllerAvailableButtons();
UpdateControllerEnabledButtons();
UpdateControllerButtonNames();
UpdateMotionButtons();
connect(ui->comboControllerType, qOverload(&QComboBox::currentIndexChanged), [this](int) {
- UpdateControllerIcon();
UpdateControllerAvailableButtons();
UpdateControllerEnabledButtons();
UpdateControllerButtonNames();
@@ -560,13 +480,10 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
connect(poll_timer.get(), &QTimer::timeout, [this] {
- Common::ParamPackage params;
- for (auto& poller : device_pollers) {
- params = poller->GetNextInput();
- if (params.Has("engine") && IsInputAcceptable(params)) {
- SetPollingResult(params, false);
- return;
- }
+ const auto& params = input_subsystem->GetNextInput();
+ if (params.Has("engine") && IsInputAcceptable(params)) {
+ SetPollingResult(params, false);
+ return;
}
});
@@ -582,110 +499,14 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
&ConfigureInputPlayer::SaveProfile);
LoadConfiguration();
- ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param);
- ui->controllerFrame->SetConnectedStatus(ui->groupConnectedController->isChecked());
}
-ConfigureInputPlayer::~ConfigureInputPlayer() = default;
+ConfigureInputPlayer::~ConfigureInputPlayer() {
+ emulated_controller->DisableConfiguration();
+};
void ConfigureInputPlayer::ApplyConfiguration() {
- auto& player = Settings::values.players.GetValue()[player_index];
- auto& buttons = debug ? Settings::values.debug_pad_buttons : player.buttons;
- auto& analogs = debug ? Settings::values.debug_pad_analogs : player.analogs;
-
- std::transform(buttons_param.begin(), buttons_param.end(), buttons.begin(),
- [](const Common::ParamPackage& param) { return param.Serialize(); });
- std::transform(analogs_param.begin(), analogs_param.end(), analogs.begin(),
- [](const Common::ParamPackage& param) { return param.Serialize(); });
-
- if (debug) {
- return;
- }
-
- auto& motions = player.motions;
-
- std::transform(motions_param.begin(), motions_param.end(), motions.begin(),
- [](const Common::ParamPackage& param) { return param.Serialize(); });
-
- // Apply configuration for handheld
- if (player_index == 0) {
- auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
- const auto handheld_connected = handheld.connected;
- handheld = player;
- handheld.connected = handheld_connected;
- }
-}
-
-void ConfigureInputPlayer::TryConnectSelectedController() {
- auto& player = Settings::values.players.GetValue()[player_index];
-
- const auto controller_type =
- GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
- const auto player_connected = ui->groupConnectedController->isChecked() &&
- controller_type != Settings::ControllerType::Handheld;
-
- // Connect Handheld depending on Player 1's controller configuration.
- if (player_index == 0) {
- auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
- const auto handheld_connected = ui->groupConnectedController->isChecked() &&
- controller_type == Settings::ControllerType::Handheld;
- // Connect only if handheld is going from disconnected to connected
- if (!handheld.connected && handheld_connected) {
- UpdateController(controller_type, HANDHELD_INDEX, true, system);
- }
- handheld.connected = handheld_connected;
- }
-
- if (player.controller_type == controller_type && player.connected == player_connected) {
- // Set vibration devices in the event that the input device has changed.
- ConfigureVibration::SetVibrationDevices(player_index);
- return;
- }
-
- player.controller_type = controller_type;
- player.connected = player_connected;
-
- ConfigureVibration::SetVibrationDevices(player_index);
-
- if (!player.connected) {
- return;
- }
-
- UpdateController(controller_type, player_index, true, system);
-}
-
-void ConfigureInputPlayer::TryDisconnectSelectedController() {
- const auto& player = Settings::values.players.GetValue()[player_index];
-
- const auto controller_type =
- GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
- const auto player_connected = ui->groupConnectedController->isChecked() &&
- controller_type != Settings::ControllerType::Handheld;
-
- // Disconnect Handheld depending on Player 1's controller configuration.
- if (player_index == 0 && player.controller_type == Settings::ControllerType::Handheld) {
- const auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
- const auto handheld_connected = ui->groupConnectedController->isChecked() &&
- controller_type == Settings::ControllerType::Handheld;
- // Disconnect only if handheld is going from connected to disconnected
- if (handheld.connected && !handheld_connected) {
- UpdateController(controller_type, HANDHELD_INDEX, false, system);
- }
- return;
- }
-
- // Do not do anything if the controller configuration has not changed.
- if (player.controller_type == controller_type && player.connected == player_connected) {
- return;
- }
-
- // Do not disconnect if the controller is already disconnected
- if (!player.connected) {
- return;
- }
-
- // Disconnect the controller first.
- UpdateController(controller_type, player_index, false, system);
+ emulated_controller->SaveCurrentConfig();
}
void ConfigureInputPlayer::showEvent(QShowEvent* event) {
@@ -710,34 +531,11 @@ void ConfigureInputPlayer::RetranslateUI() {
}
void ConfigureInputPlayer::LoadConfiguration() {
- auto& player = Settings::values.players.GetValue()[player_index];
- if (debug) {
- std::transform(Settings::values.debug_pad_buttons.begin(),
- Settings::values.debug_pad_buttons.end(), buttons_param.begin(),
- [](const std::string& str) { return Common::ParamPackage(str); });
- std::transform(Settings::values.debug_pad_analogs.begin(),
- Settings::values.debug_pad_analogs.end(), analogs_param.begin(),
- [](const std::string& str) { return Common::ParamPackage(str); });
- } else {
- std::transform(player.buttons.begin(), player.buttons.end(), buttons_param.begin(),
- [](const std::string& str) { return Common::ParamPackage(str); });
- std::transform(player.analogs.begin(), player.analogs.end(), analogs_param.begin(),
- [](const std::string& str) { return Common::ParamPackage(str); });
- std::transform(player.motions.begin(), player.motions.end(), motions_param.begin(),
- [](const std::string& str) { return Common::ParamPackage(str); });
- }
-
UpdateUI();
UpdateInputDeviceCombobox();
-
- if (debug) {
- return;
- }
-
- ui->comboControllerType->setCurrentIndex(GetIndexFromControllerType(player.controller_type));
- ui->groupConnectedController->setChecked(
- player.connected ||
- (player_index == 0 && Settings::values.players.GetValue()[HANDHELD_INDEX].connected));
+ const int comboBoxIndex = GetIndexFromControllerType(emulated_controller->GetNpadType());
+ ui->comboControllerType->setCurrentIndex(comboBoxIndex);
+ ui->groupConnectedController->setChecked(emulated_controller->IsConnected());
}
void ConfigureInputPlayer::ConnectPlayer(bool connected) {
@@ -751,48 +549,63 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
return;
}
- // Find the first button that isn't empty.
- const auto button_param =
- std::find_if(buttons_param.begin(), buttons_param.end(),
- [](const Common::ParamPackage param) { return param.Has("engine"); });
- const bool buttons_empty = button_param == buttons_param.end();
+ const auto devices = emulated_controller->GetMappedDevices();
+ UpdateInputDevices();
+
+ if (devices.empty()) {
+ return;
+ }
+
+ if (devices.size() > 2) {
+ ui->comboDevices->setCurrentIndex(0);
+ return;
+ }
+
+ const auto first_engine = devices[0].Get("engine", "");
+ const auto first_guid = devices[0].Get("guid", "");
+ const auto first_port = devices[0].Get("port", "");
- const auto current_engine = button_param->Get("engine", "");
- const auto current_guid = button_param->Get("guid", "");
- const auto current_port = button_param->Get("port", "");
+ if (devices.size() == 1) {
+ const auto devices_it =
+ std::find_if(input_devices.begin(), input_devices.end(),
+ [first_engine, first_guid, first_port](const Common::ParamPackage param) {
+ return param.Get("engine", "") == first_engine &&
+ param.Get("guid", "") == first_guid &&
+ param.Get("port", "") == first_port;
+ });
+ const int device_index =
+ devices_it != input_devices.end()
+ ? static_cast(std::distance(input_devices.begin(), devices_it))
+ : 0;
+ ui->comboDevices->setCurrentIndex(device_index);
+ return;
+ }
- const bool is_keyboard_mouse = current_engine == "keyboard" || current_engine == "mouse";
+ const auto second_engine = devices[1].Get("engine", "");
+ const auto second_guid = devices[1].Get("guid", "");
+ const auto second_port = devices[1].Get("port", "");
- UpdateInputDevices();
+ const bool is_keyboard_mouse = (first_engine == "keyboard" || first_engine == "mouse") &&
+ (second_engine == "keyboard" || second_engine == "mouse");
- if (buttons_empty) {
+ if (is_keyboard_mouse) {
+ ui->comboDevices->setCurrentIndex(2);
return;
}
- const bool all_one_device =
- std::all_of(buttons_param.begin(), buttons_param.end(),
- [current_engine, current_guid, current_port,
- is_keyboard_mouse](const Common::ParamPackage param) {
- if (is_keyboard_mouse) {
- return !param.Has("engine") || param.Get("engine", "") == "keyboard" ||
- param.Get("engine", "") == "mouse";
- }
- return !param.Has("engine") || (param.Get("engine", "") == current_engine &&
- param.Get("guid", "") == current_guid &&
- param.Get("port", "") == current_port);
- });
+ const bool is_engine_equal = first_engine == second_engine;
+ const bool is_port_equal = first_port == second_port;
- if (all_one_device) {
- if (is_keyboard_mouse) {
- ui->comboDevices->setCurrentIndex(1);
- return;
- }
+ if (is_engine_equal && is_port_equal) {
const auto devices_it = std::find_if(
input_devices.begin(), input_devices.end(),
- [current_engine, current_guid, current_port](const Common::ParamPackage param) {
- return param.Get("class", "") == current_engine &&
- param.Get("guid", "") == current_guid &&
- param.Get("port", "") == current_port;
+ [first_engine, first_guid, second_guid, first_port](const Common::ParamPackage param) {
+ const bool is_guid_valid =
+ (param.Get("guid", "") == first_guid &&
+ param.Get("guid2", "") == second_guid) ||
+ (param.Get("guid", "") == second_guid && param.Get("guid2", "") == first_guid);
+ return param.Get("engine", "") == first_engine && is_guid_valid &&
+ param.Get("port", "") == first_port;
});
const int device_index =
devices_it != input_devices.end()
@@ -814,8 +627,7 @@ void ConfigureInputPlayer::ClearAll() {
if (button == nullptr) {
continue;
}
-
- buttons_param[button_id].Clear();
+ emulated_controller->SetButtonParam(button_id, {});
}
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) {
@@ -824,8 +636,7 @@ void ConfigureInputPlayer::ClearAll() {
if (analog_button == nullptr) {
continue;
}
-
- analogs_param[analog_id].Clear();
+ emulated_controller->SetStickParam(analog_id, {});
}
}
@@ -834,8 +645,7 @@ void ConfigureInputPlayer::ClearAll() {
if (motion_button == nullptr) {
continue;
}
-
- motions_param[motion_id].Clear();
+ emulated_controller->SetMotionParam(motion_id, {});
}
UpdateUI();
@@ -844,26 +654,31 @@ void ConfigureInputPlayer::ClearAll() {
void ConfigureInputPlayer::UpdateUI() {
for (int button = 0; button < Settings::NativeButton::NumButtons; ++button) {
- button_map[button]->setText(ButtonToText(buttons_param[button]));
+ const Common::ParamPackage param = emulated_controller->GetButtonParam(button);
+ button_map[button]->setText(ButtonToText(param));
}
- if (buttons_param[Settings::NativeButton::ZL].Has("threshold")) {
- const int button_threshold = static_cast(
- buttons_param[Settings::NativeButton::ZL].Get("threshold", 0.5f) * 100.0f);
+ const Common::ParamPackage ZL_param =
+ emulated_controller->GetButtonParam(Settings::NativeButton::ZL);
+ if (ZL_param.Has("threshold")) {
+ const int button_threshold = static_cast(ZL_param.Get("threshold", 0.5f) * 100.0f);
ui->sliderZLThreshold->setValue(button_threshold);
}
- if (buttons_param[Settings::NativeButton::ZR].Has("threshold")) {
- const int button_threshold = static_cast(
- buttons_param[Settings::NativeButton::ZR].Get("threshold", 0.5f) * 100.0f);
+ const Common::ParamPackage ZR_param =
+ emulated_controller->GetButtonParam(Settings::NativeButton::ZR);
+ if (ZR_param.Has("threshold")) {
+ const int button_threshold = static_cast(ZR_param.Get("threshold", 0.5f) * 100.0f);
ui->sliderZRThreshold->setValue(button_threshold);
}
for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) {
- motion_map[motion_id]->setText(ButtonToText(motions_param[motion_id]));
+ const Common::ParamPackage param = emulated_controller->GetMotionParam(motion_id);
+ motion_map[motion_id]->setText(ButtonToText(param));
}
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) {
+ const Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
auto* const analog_button = analog_map_buttons[analog_id][sub_button_id];
@@ -871,12 +686,11 @@ void ConfigureInputPlayer::UpdateUI() {
continue;
}
- analog_button->setText(
- AnalogToText(analogs_param[analog_id], analog_sub_buttons[sub_button_id]));
+ analog_button->setText(AnalogToText(param, analog_sub_buttons[sub_button_id]));
}
analog_map_modifier_button[analog_id]->setText(
- ButtonToText(Common::ParamPackage{analogs_param[analog_id].Get("modifier", "")}));
+ ButtonToText(Common::ParamPackage{param.Get("modifier", "")}));
const auto deadzone_label = analog_map_deadzone_label[analog_id];
const auto deadzone_slider = analog_map_deadzone_slider[analog_id];
@@ -887,26 +701,14 @@ void ConfigureInputPlayer::UpdateUI() {
const auto range_spinbox = analog_map_range_spinbox[analog_id];
int slider_value;
- auto& param = analogs_param[analog_id];
- const bool is_controller =
- param.Get("engine", "") == "sdl" || param.Get("engine", "") == "gcpad" ||
- param.Get("engine", "") == "mouse" || param.Get("engine", "") == "tas";
+ const bool is_controller = input_subsystem->IsController(param);
if (is_controller) {
- if (!param.Has("deadzone")) {
- param.Set("deadzone", 0.1f);
- }
- slider_value = static_cast(param.Get("deadzone", 0.1f) * 100);
+ slider_value = static_cast(param.Get("deadzone", 0.15f) * 100);
deadzone_label->setText(tr("Deadzone: %1%").arg(slider_value));
deadzone_slider->setValue(slider_value);
- if (!param.Has("range")) {
- param.Set("range", 1.0f);
- }
range_spinbox->setValue(static_cast(param.Get("range", 1.0f) * 100));
} else {
- if (!param.Has("modifier_scale")) {
- param.Set("modifier_scale", 0.5f);
- }
slider_value = static_cast(param.Get("modifier_scale", 0.5f) * 100);
modifier_label->setText(tr("Modifier Range: %1%").arg(slider_value));
modifier_slider->setValue(slider_value);
@@ -918,49 +720,48 @@ void ConfigureInputPlayer::UpdateUI() {
modifier_label->setVisible(!is_controller);
modifier_slider->setVisible(!is_controller);
range_groupbox->setVisible(is_controller);
- ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param);
}
}
void ConfigureInputPlayer::SetConnectableControllers() {
const auto add_controllers = [this](bool enable_all,
- Controller_NPad::NpadStyleSet npad_style_set = {}) {
+ Core::HID::NpadStyleTag npad_style_set = {}) {
index_controller_type_pairs.clear();
ui->comboControllerType->clear();
if (enable_all || npad_style_set.fullkey == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Settings::ControllerType::ProController);
+ Core::HID::NpadType::ProController);
ui->comboControllerType->addItem(tr("Pro Controller"));
}
if (enable_all || npad_style_set.joycon_dual == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Settings::ControllerType::DualJoyconDetached);
+ Core::HID::NpadType::JoyconDual);
ui->comboControllerType->addItem(tr("Dual Joycons"));
}
if (enable_all || npad_style_set.joycon_left == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Settings::ControllerType::LeftJoycon);
+ Core::HID::NpadType::JoyconLeft);
ui->comboControllerType->addItem(tr("Left Joycon"));
}
if (enable_all || npad_style_set.joycon_right == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Settings::ControllerType::RightJoycon);
+ Core::HID::NpadType::JoyconRight);
ui->comboControllerType->addItem(tr("Right Joycon"));
}
if (player_index == 0 && (enable_all || npad_style_set.handheld == 1)) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Settings::ControllerType::Handheld);
+ Core::HID::NpadType::Handheld);
ui->comboControllerType->addItem(tr("Handheld"));
}
if (enable_all || npad_style_set.gamecube == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Settings::ControllerType::GameCube);
+ Core::HID::NpadType::GameCube);
ui->comboControllerType->addItem(tr("GameCube Controller"));
}
};
@@ -970,27 +771,22 @@ void ConfigureInputPlayer::SetConnectableControllers() {
return;
}
- Service::SM::ServiceManager& sm = system.ServiceManager();
-
- auto& npad = sm.GetService("hid")->GetAppletResource()->GetController(
- HidController::NPad);
-
- add_controllers(false, npad.GetSupportedStyleSet());
+ add_controllers(false, system.HIDCore().GetSupportedStyleTag());
}
-Settings::ControllerType ConfigureInputPlayer::GetControllerTypeFromIndex(int index) const {
+Core::HID::NpadType ConfigureInputPlayer::GetControllerTypeFromIndex(int index) const {
const auto it =
std::find_if(index_controller_type_pairs.begin(), index_controller_type_pairs.end(),
[index](const auto& pair) { return pair.first == index; });
if (it == index_controller_type_pairs.end()) {
- return Settings::ControllerType::ProController;
+ return Core::HID::NpadType::ProController;
}
return it->second;
}
-int ConfigureInputPlayer::GetIndexFromControllerType(Settings::ControllerType type) const {
+int ConfigureInputPlayer::GetIndexFromControllerType(Core::HID::NpadType type) const {
const auto it =
std::find_if(index_controller_type_pairs.begin(), index_controller_type_pairs.end(),
[type](const auto& pair) { return pair.second == type; });
@@ -1005,52 +801,15 @@ int ConfigureInputPlayer::GetIndexFromControllerType(Settings::ControllerType ty
void ConfigureInputPlayer::UpdateInputDevices() {
input_devices = input_subsystem->GetInputDevices();
ui->comboDevices->clear();
- for (auto& device : input_devices) {
- const std::string display = device.Get("display", "Unknown");
- ui->comboDevices->addItem(QString::fromStdString(display), {});
- if (display == "TAS") {
- device.Set("pad", static_cast(player_index));
- }
+ for (auto device : input_devices) {
+ ui->comboDevices->addItem(QString::fromStdString(device.Get("display", "Unknown")), {});
}
}
-void ConfigureInputPlayer::UpdateControllerIcon() {
- // We aren't using Qt's built in theme support here since we aren't drawing an icon (and its
- // "nonstandard" to use an image through the icon support)
- const QString stylesheet = [this] {
- switch (GetControllerTypeFromIndex(ui->comboControllerType->currentIndex())) {
- case Settings::ControllerType::ProController:
- return QStringLiteral("image: url(:/controller/pro_controller%0)");
- case Settings::ControllerType::DualJoyconDetached:
- return QStringLiteral("image: url(:/controller/dual_joycon%0)");
- case Settings::ControllerType::LeftJoycon:
- return QStringLiteral("image: url(:/controller/single_joycon_left_vertical%0)");
- case Settings::ControllerType::RightJoycon:
- return QStringLiteral("image: url(:/controller/single_joycon_right_vertical%0)");
- case Settings::ControllerType::Handheld:
- return QStringLiteral("image: url(:/controller/handheld%0)");
- default:
- return QString{};
- }
- }();
-
- const QString theme = [] {
- if (QIcon::themeName().contains(QStringLiteral("dark"))) {
- return QStringLiteral("_dark");
- } else if (QIcon::themeName().contains(QStringLiteral("midnight"))) {
- return QStringLiteral("_midnight");
- } else {
- return QString{};
- }
- }();
- ui->controllerFrame->SetControllerType(
- GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()));
-}
-
void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
if (debug) {
- layout = Settings::ControllerType::ProController;
+ layout = Core::HID::NpadType::ProController;
}
// List of all the widgets that will be hidden by any of the following layouts that need
@@ -1075,15 +834,15 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
std::vector layout_hidden;
switch (layout) {
- case Settings::ControllerType::ProController:
- case Settings::ControllerType::DualJoyconDetached:
- case Settings::ControllerType::Handheld:
+ case Core::HID::NpadType::ProController:
+ case Core::HID::NpadType::JoyconDual:
+ case Core::HID::NpadType::Handheld:
layout_hidden = {
ui->buttonShoulderButtonsSLSR,
ui->horizontalSpacerShoulderButtonsWidget2,
};
break;
- case Settings::ControllerType::LeftJoycon:
+ case Core::HID::NpadType::JoyconLeft:
layout_hidden = {
ui->horizontalSpacerShoulderButtonsWidget2,
ui->buttonShoulderButtonsRight,
@@ -1091,7 +850,7 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
ui->bottomRight,
};
break;
- case Settings::ControllerType::RightJoycon:
+ case Core::HID::NpadType::JoyconRight:
layout_hidden = {
ui->horizontalSpacerShoulderButtonsWidget,
ui->buttonShoulderButtonsLeft,
@@ -1099,7 +858,7 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
ui->bottomLeft,
};
break;
- case Settings::ControllerType::GameCube:
+ case Core::HID::NpadType::GameCube:
layout_hidden = {
ui->buttonShoulderButtonsSLSR,
ui->horizontalSpacerShoulderButtonsWidget2,
@@ -1107,6 +866,8 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
ui->buttonMiscButtonsScreenshotGroup,
};
break;
+ default:
+ break;
}
for (auto* widget : layout_hidden) {
@@ -1117,13 +878,12 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
void ConfigureInputPlayer::UpdateControllerEnabledButtons() {
auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
if (debug) {
- layout = Settings::ControllerType::ProController;
+ layout = Core::HID::NpadType::ProController;
}
// List of all the widgets that will be disabled by any of the following layouts that need
// "enabled" after the controller type changes
- const std::array layout_enable = {
- ui->buttonHome,
+ const std::array layout_enable = {
ui->buttonLStickPressedGroup,
ui->groupRStickPressed,
ui->buttonShoulderButtonsButtonLGroup,
@@ -1135,17 +895,13 @@ void ConfigureInputPlayer::UpdateControllerEnabledButtons() {
std::vector layout_disable;
switch (layout) {
- case Settings::ControllerType::ProController:
- case Settings::ControllerType::DualJoyconDetached:
- case Settings::ControllerType::Handheld:
- case Settings::ControllerType::LeftJoycon:
- case Settings::ControllerType::RightJoycon:
- // TODO(wwylele): enable this when we actually emulate it
- layout_disable = {
- ui->buttonHome,
- };
+ case Core::HID::NpadType::ProController:
+ case Core::HID::NpadType::JoyconDual:
+ case Core::HID::NpadType::Handheld:
+ case Core::HID::NpadType::JoyconLeft:
+ case Core::HID::NpadType::JoyconRight:
break;
- case Settings::ControllerType::GameCube:
+ case Core::HID::NpadType::GameCube:
layout_disable = {
ui->buttonHome,
ui->buttonLStickPressedGroup,
@@ -1153,6 +909,8 @@ void ConfigureInputPlayer::UpdateControllerEnabledButtons() {
ui->buttonShoulderButtonsButtonLGroup,
};
break;
+ default:
+ break;
}
for (auto* widget : layout_disable) {
@@ -1170,24 +928,24 @@ void ConfigureInputPlayer::UpdateMotionButtons() {
// Show/hide the "Motion 1/2" groupboxes depending on the currently selected controller.
switch (GetControllerTypeFromIndex(ui->comboControllerType->currentIndex())) {
- case Settings::ControllerType::ProController:
- case Settings::ControllerType::LeftJoycon:
- case Settings::ControllerType::Handheld:
+ case Core::HID::NpadType::ProController:
+ case Core::HID::NpadType::JoyconLeft:
+ case Core::HID::NpadType::Handheld:
// Show "Motion 1" and hide "Motion 2".
ui->buttonMotionLeftGroup->show();
ui->buttonMotionRightGroup->hide();
break;
- case Settings::ControllerType::RightJoycon:
+ case Core::HID::NpadType::JoyconRight:
// Show "Motion 2" and hide "Motion 1".
ui->buttonMotionLeftGroup->hide();
ui->buttonMotionRightGroup->show();
break;
- case Settings::ControllerType::GameCube:
+ case Core::HID::NpadType::GameCube:
// Hide both "Motion 1/2".
ui->buttonMotionLeftGroup->hide();
ui->buttonMotionRightGroup->hide();
break;
- case Settings::ControllerType::DualJoyconDetached:
+ case Core::HID::NpadType::JoyconDual:
default:
// Show both "Motion 1/2".
ui->buttonMotionLeftGroup->show();
@@ -1199,15 +957,15 @@ void ConfigureInputPlayer::UpdateMotionButtons() {
void ConfigureInputPlayer::UpdateControllerButtonNames() {
auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
if (debug) {
- layout = Settings::ControllerType::ProController;
+ layout = Core::HID::NpadType::ProController;
}
switch (layout) {
- case Settings::ControllerType::ProController:
- case Settings::ControllerType::DualJoyconDetached:
- case Settings::ControllerType::Handheld:
- case Settings::ControllerType::LeftJoycon:
- case Settings::ControllerType::RightJoycon:
+ case Core::HID::NpadType::ProController:
+ case Core::HID::NpadType::JoyconDual:
+ case Core::HID::NpadType::Handheld:
+ case Core::HID::NpadType::JoyconLeft:
+ case Core::HID::NpadType::JoyconRight:
ui->buttonMiscButtonsPlusGroup->setTitle(tr("Plus"));
ui->buttonShoulderButtonsButtonZLGroup->setTitle(tr("ZL"));
ui->buttonShoulderButtonsZRGroup->setTitle(tr("ZR"));
@@ -1215,7 +973,7 @@ void ConfigureInputPlayer::UpdateControllerButtonNames() {
ui->LStick->setTitle(tr("Left Stick"));
ui->RStick->setTitle(tr("Right Stick"));
break;
- case Settings::ControllerType::GameCube:
+ case Core::HID::NpadType::GameCube:
ui->buttonMiscButtonsPlusGroup->setTitle(tr("Start / Pause"));
ui->buttonShoulderButtonsButtonZLGroup->setTitle(tr("L"));
ui->buttonShoulderButtonsZRGroup->setTitle(tr("R"));
@@ -1223,6 +981,8 @@ void ConfigureInputPlayer::UpdateControllerButtonNames() {
ui->LStick->setTitle(tr("Control Stick"));
ui->RStick->setTitle(tr("C-Stick"));
break;
+ default:
+ break;
}
}
@@ -1231,26 +991,93 @@ void ConfigureInputPlayer::UpdateMappingWithDefaults() {
return;
}
+ for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) {
+ const auto* const button = button_map[button_id];
+ if (button == nullptr) {
+ continue;
+ }
+ emulated_controller->SetButtonParam(button_id, {});
+ }
+
+ for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) {
+ for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
+ const auto* const analog_button = analog_map_buttons[analog_id][sub_button_id];
+ if (analog_button == nullptr) {
+ continue;
+ }
+ emulated_controller->SetStickParam(analog_id, {});
+ }
+ }
+
+ for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) {
+ const auto* const motion_button = motion_map[motion_id];
+ if (motion_button == nullptr) {
+ continue;
+ }
+ emulated_controller->SetMotionParam(motion_id, {});
+ }
+
+ // Reset keyboard bindings
if (ui->comboDevices->currentIndex() == 1) {
- // Reset keyboard bindings
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) {
- buttons_param[button_id] = Common::ParamPackage{
- InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])};
+ emulated_controller->SetButtonParam(
+ button_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam(
+ Config::default_buttons[button_id])});
}
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) {
+ Common::ParamPackage analog_param{};
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
Common::ParamPackage params{InputCommon::GenerateKeyboardParam(
Config::default_analogs[analog_id][sub_button_id])};
- SetAnalogParam(params, analogs_param[analog_id], analog_sub_buttons[sub_button_id]);
+ SetAnalogParam(params, analog_param, analog_sub_buttons[sub_button_id]);
}
- analogs_param[analog_id].Set("modifier", InputCommon::GenerateKeyboardParam(
- Config::default_stick_mod[analog_id]));
+ analog_param.Set("modifier", InputCommon::GenerateKeyboardParam(
+ Config::default_stick_mod[analog_id]));
+ emulated_controller->SetStickParam(analog_id, analog_param);
+ }
+
+ for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) {
+ emulated_controller->SetMotionParam(
+ motion_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam(
+ Config::default_motions[motion_id])});
+ }
+
+ UpdateUI();
+ return;
+ }
+
+ // Reset keyboard with mouse bindings
+ if (ui->comboDevices->currentIndex() == 2) {
+ for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) {
+ emulated_controller->SetButtonParam(
+ button_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam(
+ Config::default_buttons[button_id])});
+ }
+
+ Common::ParamPackage left_analog_param{};
+ for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
+ Common::ParamPackage params{InputCommon::GenerateKeyboardParam(
+ Config::default_analogs[Settings::NativeAnalog::LStick][sub_button_id])};
+ SetAnalogParam(params, left_analog_param, analog_sub_buttons[sub_button_id]);
}
+ left_analog_param.Set("modifier",
+ InputCommon::GenerateKeyboardParam(
+ Config::default_stick_mod[Settings::NativeAnalog::LStick]));
+ emulated_controller->SetStickParam(Settings::NativeAnalog::LStick, left_analog_param);
+
+ Common::ParamPackage right_analog_param{};
+ right_analog_param.Set("engine", "mouse");
+ right_analog_param.Set("port", 0);
+ right_analog_param.Set("axis_x", 0);
+ right_analog_param.Set("axis_y", 1);
+ emulated_controller->SetStickParam(Settings::NativeAnalog::RStick,
+ std::move(right_analog_param));
for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) {
- motions_param[motion_id] = Common::ParamPackage{
- InputCommon::GenerateKeyboardParam(Config::default_motions[motion_id])};
+ emulated_controller->SetMotionParam(
+ motion_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam(
+ Config::default_motions[motion_id])});
}
UpdateUI();
@@ -1262,14 +1089,17 @@ void ConfigureInputPlayer::UpdateMappingWithDefaults() {
auto button_mapping = input_subsystem->GetButtonMappingForDevice(device);
auto analog_mapping = input_subsystem->GetAnalogMappingForDevice(device);
auto motion_mapping = input_subsystem->GetMotionMappingForDevice(device);
- for (std::size_t i = 0; i < buttons_param.size(); ++i) {
- buttons_param[i] = button_mapping[static_cast(i)];
+ for (std::size_t i = 0; i < button_mapping.size(); ++i) {
+ emulated_controller->SetButtonParam(
+ i, button_mapping[static_cast(i)]);
}
- for (std::size_t i = 0; i < analogs_param.size(); ++i) {
- analogs_param[i] = analog_mapping[static_cast(i)];
+ for (std::size_t i = 0; i < analog_mapping.size(); ++i) {
+ emulated_controller->SetStickParam(
+ i, analog_mapping[static_cast(i)]);
}
- for (std::size_t i = 0; i < motions_param.size(); ++i) {
- motions_param[i] = motion_mapping[static_cast(i)];
+ for (std::size_t i = 0; i < motion_mapping.size(); ++i) {
+ emulated_controller->SetMotionParam(
+ i, motion_mapping[static_cast(i)]);
}
UpdateUI();
@@ -1278,7 +1108,7 @@ void ConfigureInputPlayer::UpdateMappingWithDefaults() {
void ConfigureInputPlayer::HandleClick(
QPushButton* button, std::size_t button_id,
std::function new_input_setter,
- InputCommon::Polling::DeviceType type) {
+ InputCommon::Polling::InputType type) {
if (button == ui->buttonMotionLeft || button == ui->buttonMotionRight) {
button->setText(tr("Shake!"));
} else {
@@ -1286,25 +1116,16 @@ void ConfigureInputPlayer::HandleClick(
}
button->setFocus();
- // The first two input devices are always Any and Keyboard/Mouse. If the user filtered to a
- // controller, then they don't want keyboard/mouse input
- want_keyboard_mouse = ui->comboDevices->currentIndex() < 2;
-
input_setter = new_input_setter;
- device_pollers = input_subsystem->GetPollers(type);
-
- for (auto& poller : device_pollers) {
- poller->Start();
- }
+ input_subsystem->BeginMapping(type);
QWidget::grabMouse();
QWidget::grabKeyboard();
-
- if (type == InputCommon::Polling::DeviceType::Button) {
+ if (type == InputCommon::Polling::InputType::Button) {
ui->controllerFrame->BeginMappingButton(button_id);
- } else if (type == InputCommon::Polling::DeviceType::AnalogPreferred) {
+ } else if (type == InputCommon::Polling::InputType::Stick) {
ui->controllerFrame->BeginMappingAnalog(button_id);
}
@@ -1315,14 +1136,11 @@ void ConfigureInputPlayer::HandleClick(
void ConfigureInputPlayer::SetPollingResult(const Common::ParamPackage& params, bool abort) {
timeout_timer->stop();
poll_timer->stop();
- for (auto& poller : device_pollers) {
- poller->Stop();
- }
+ input_subsystem->StopMapping();
QWidget::releaseMouse();
QWidget::releaseKeyboard();
-
if (!abort) {
(*input_setter)(params);
}
@@ -1340,13 +1158,14 @@ bool ConfigureInputPlayer::IsInputAcceptable(const Common::ParamPackage& params)
}
// Keyboard/Mouse
- if (ui->comboDevices->currentIndex() == 1) {
+ if (ui->comboDevices->currentIndex() == 2) {
return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse";
}
const auto current_input_device = input_devices[ui->comboDevices->currentIndex()];
- return params.Get("engine", "") == current_input_device.Get("class", "") &&
- params.Get("guid", "") == current_input_device.Get("guid", "") &&
+ return params.Get("engine", "") == current_input_device.Get("engine", "") &&
+ (params.Get("guid", "") == current_input_device.Get("guid", "") ||
+ params.Get("guid", "") == current_input_device.Get("guid2", "")) &&
params.Get("port", "") == current_input_device.Get("port", "");
}
@@ -1355,25 +1174,18 @@ void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) {
return;
}
- //const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
+ const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
+ input_subsystem->GetMouse()->PressButton(0, 0, 0, 0, button);
}
void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) {
+ event->ignore();
if (!input_setter || !event) {
return;
}
-
if (event->key() != Qt::Key_Escape) {
- if (want_keyboard_mouse) {
- SetPollingResult(Common::ParamPackage{InputCommon::GenerateKeyboardParam(event->key())},
- false);
- } else {
- // Escape key wasn't pressed and we don't want any keyboard keys, so don't stop polling
- return;
- }
+ input_subsystem->GetKeyboard()->PressKey(event->key());
}
-
- SetPollingResult({}, true);
}
void ConfigureInputPlayer::CreateProfile() {
diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h
index 39b44b8a5..02d6920f1 100644
--- a/src/yuzu/configuration/configure_input_player.h
+++ b/src/yuzu/configuration/configure_input_player.h
@@ -38,14 +38,22 @@ class InputSubsystem;
}
namespace InputCommon::Polling {
-class DevicePoller;
-enum class DeviceType;
+enum class InputType;
} // namespace InputCommon::Polling
namespace Ui {
class ConfigureInputPlayer;
}
+namespace Core {
+class System;
+}
+
+namespace Core::HID {
+class EmulatedController;
+enum class NpadType : u8;
+} // namespace Core::HID
+
class ConfigureInputPlayer : public QWidget {
Q_OBJECT
@@ -59,18 +67,6 @@ public:
/// Save all button configurations to settings file.
void ApplyConfiguration();
- /**
- * Attempts to connect the currently selected controller in the HID backend.
- * This function will not do anything if it is not connected in the frontend.
- */
- void TryConnectSelectedController();
-
- /**
- * Attempts to disconnect the currently selected controller in the HID backend.
- * This function will not do anything if the configuration has not changed.
- */
- void TryDisconnectSelectedController();
-
/// Set the connection state checkbox (used to sync state).
void ConnectPlayer(bool connected);
@@ -104,6 +100,10 @@ protected:
void showEvent(QShowEvent* event) override;
private:
+ QString ButtonToText(const Common::ParamPackage& param);
+
+ QString AnalogToText(const Common::ParamPackage& param, const std::string& dir);
+
void changeEvent(QEvent* event) override;
void RetranslateUI();
@@ -113,7 +113,7 @@ private:
/// Called when the button was pressed.
void HandleClick(QPushButton* button, std::size_t button_id,
std::function new_input_setter,
- InputCommon::Polling::DeviceType type);
+ InputCommon::Polling::InputType type);
/// Finish polling and configure input using the input_setter.
void SetPollingResult(const Common::ParamPackage& params, bool abort);
@@ -134,17 +134,14 @@ private:
void SetConnectableControllers();
/// Gets the Controller Type for a given controller combobox index.
- Settings::ControllerType GetControllerTypeFromIndex(int index) const;
+ Core::HID::NpadType GetControllerTypeFromIndex(int index) const;
/// Gets the controller combobox index for a given Controller Type.
- int GetIndexFromControllerType(Settings::ControllerType type) const;
+ int GetIndexFromControllerType(Core::HID::NpadType type) const;
/// Update the available input devices.
void UpdateInputDevices();
- /// Update the current controller icon.
- void UpdateControllerIcon();
-
/// Hides and disables controller settings based on the current controller type.
void UpdateControllerAvailableButtons();
@@ -185,7 +182,7 @@ private:
std::unique_ptr poll_timer;
/// Stores a pair of "Connected Controllers" combobox index and Controller Type enum.
- std::vector> index_controller_type_pairs;
+ std::vector> index_controller_type_pairs;
static constexpr int PLAYER_COUNT = 8;
std::array player_connected_checkbox;
@@ -193,9 +190,7 @@ private:
/// This will be the the setting function when an input is awaiting configuration.
std::optional> input_setter;
- std::array buttons_param;
- std::array analogs_param;
- std::array motions_param;
+ Core::HID::EmulatedController* emulated_controller;
static constexpr int ANALOG_SUB_BUTTONS_NUM = 4;
@@ -221,15 +216,9 @@ private:
static const std::array analog_sub_buttons;
- std::vector> device_pollers;
-
/// A flag to indicate that the "Map Analog Stick" pop-up has been shown and accepted once.
bool map_analog_stick_accepted{};
- /// A flag to indicate if keyboard keys are okay when configuring an input. If this is false,
- /// keyboard events are ignored.
- bool want_keyboard_mouse{};
-
/// List of physical devices users can map with. If a SDL backed device is selected, then you
/// can use this device to get a default mapping.
std::vector input_devices;
diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui
index e7433912b..14ca02fd8 100644
--- a/src/yuzu/configuration/configure_input_player.ui
+++ b/src/yuzu/configuration/configure_input_player.ui
@@ -148,16 +148,6 @@
21
- -
-
- Any
-
-
- -
-
- Keyboard/Mouse
-
-
-
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index f31f86339..03d29f194 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -6,10 +6,11 @@
#include
#include
#include
+#include "core/core.h"
#include "yuzu/configuration/configure_input_player_widget.h"
PlayerControlPreview::PlayerControlPreview(QWidget* parent) : QFrame(parent) {
- UpdateColors();
+ is_controller_set = false;
QTimer* timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, QOverload<>::of(&PlayerControlPreview::UpdateInput));
@@ -17,38 +18,11 @@ PlayerControlPreview::PlayerControlPreview(QWidget* parent) : QFrame(parent) {
timer->start(16);
}
-PlayerControlPreview::~PlayerControlPreview() = default;
-
-void PlayerControlPreview::SetPlayerInput(std::size_t index, const ButtonParam& buttons_param,
- const AnalogParam& analogs_param) {
- player_index = index;
- Settings::ButtonsRaw buttonss;
- Settings::AnalogsRaw analogs;
- std::transform(buttons_param.begin(), buttons_param.end(), buttonss.begin(),
- [](const Common::ParamPackage& param) { return param.Serialize(); });
- std::transform(analogs_param.begin(), analogs_param.end(), analogs.begin(),
- [](const Common::ParamPackage& param) { return param.Serialize(); });
-
- std::transform(buttonss.begin() + Settings::NativeButton::BUTTON_HID_BEGIN,
- buttonss.begin() + Settings::NativeButton::BUTTON_NS_END, buttons.begin(),
- Input::CreateDevice);
- std::transform(analogs.begin() + Settings::NativeAnalog::STICK_HID_BEGIN,
- analogs.begin() + Settings::NativeAnalog::STICK_HID_END, sticks.begin(),
- Input::CreateDevice);
- UpdateColors();
-}
-void PlayerControlPreview::SetPlayerInputRaw(std::size_t index,
- const Settings::ButtonsRaw& buttons_,
- Settings::AnalogsRaw analogs_) {
- player_index = index;
- std::transform(buttons_.begin() + Settings::NativeButton::BUTTON_HID_BEGIN,
- buttons_.begin() + Settings::NativeButton::BUTTON_NS_END, buttons.begin(),
- Input::CreateDevice);
- std::transform(analogs_.begin() + Settings::NativeAnalog::STICK_HID_BEGIN,
- analogs_.begin() + Settings::NativeAnalog::STICK_HID_END, sticks.begin(),
- Input::CreateDevice);
- UpdateColors();
-}
+PlayerControlPreview::~PlayerControlPreview() {
+ if (is_controller_set) {
+ controller->DeleteCallback(callback_key);
+ }
+};
PlayerControlPreview::LedPattern PlayerControlPreview::GetColorPattern(std::size_t index,
bool player_on) {
@@ -78,20 +52,16 @@ PlayerControlPreview::LedPattern PlayerControlPreview::GetColorPattern(std::size
}
}
-void PlayerControlPreview::SetConnectedStatus(bool checked) {
- LedPattern led_pattern = GetColorPattern(player_index, checked);
-
- led_color[0] = led_pattern.position1 ? colors.led_on : colors.led_off;
- led_color[1] = led_pattern.position2 ? colors.led_on : colors.led_off;
- led_color[2] = led_pattern.position3 ? colors.led_on : colors.led_off;
- led_color[3] = led_pattern.position4 ? colors.led_on : colors.led_off;
- is_enabled = checked;
- ResetInputs();
-}
-
-void PlayerControlPreview::SetControllerType(const Settings::ControllerType type) {
- controller_type = type;
- UpdateColors();
+void PlayerControlPreview::SetController(Core::HID::EmulatedController* controller_) {
+ if (is_controller_set) {
+ controller->DeleteCallback(callback_key);
+ }
+ is_controller_set = true;
+ controller = controller_;
+ Core::HID::ControllerUpdateCallback engine_callback{
+ [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); }};
+ callback_key = controller->SetCallback(engine_callback);
+ ControllerUpdate(Core::HID::ControllerTriggerType::All);
}
void PlayerControlPreview::BeginMappingButton(std::size_t index) {
@@ -162,79 +132,99 @@ void PlayerControlPreview::UpdateColors() {
}
void PlayerControlPreview::ResetInputs() {
- for (std::size_t index = 0; index < button_values.size(); ++index) {
- button_values[index] = false;
- }
-
- for (std::size_t index = 0; index < axis_values.size(); ++index) {
- axis_values[index].properties = {0, 1, 0};
- axis_values[index].value = {0, 0};
- axis_values[index].raw_value = {0, 0};
- }
+ button_values.fill({
+ .value = false,
+ });
+ stick_values.fill({
+ .x = {.value = 0, .properties = {0, 1, 0}},
+ .y = {.value = 0, .properties = {0, 1, 0}},
+ });
+ trigger_values.fill({
+ .analog = {.value = 0, .properties = {0, 1, 0}},
+ .pressed = false,
+ });
update();
}
-void PlayerControlPreview::UpdateInput() {
- if (!is_enabled && !mapping_active && !Settings::values.tas_enable) {
+void PlayerControlPreview::ControllerUpdate(Core::HID::ControllerTriggerType type) {
+ if (type == Core::HID::ControllerTriggerType::All) {
+ ControllerUpdate(Core::HID::ControllerTriggerType::Color);
+ ControllerUpdate(Core::HID::ControllerTriggerType::Type);
+ ControllerUpdate(Core::HID::ControllerTriggerType::Connected);
+ ControllerUpdate(Core::HID::ControllerTriggerType::Button);
+ ControllerUpdate(Core::HID::ControllerTriggerType::Stick);
+ ControllerUpdate(Core::HID::ControllerTriggerType::Trigger);
+ ControllerUpdate(Core::HID::ControllerTriggerType::Battery);
return;
}
- bool input_changed = false;
- const auto& button_state = buttons;
- for (std::size_t index = 0; index < button_values.size(); ++index) {
- bool value = false;
- if (index < Settings::NativeButton::BUTTON_NS_END) {
- value = button_state[index]->GetStatus();
- }
- bool blink = mapping_active && index == button_mapping_index;
- if (analog_mapping_index == Settings::NativeAnalog::NUM_STICKS_HID) {
- blink &= blink_counter > 25;
- }
- if (button_values[index] != value || blink) {
- input_changed = true;
- }
- button_values[index] = value || blink;
+
+ switch (type) {
+ case Core::HID::ControllerTriggerType::Connected:
+ case Core::HID::ControllerTriggerType::Disconnected:
+ is_connected = controller->IsConnected();
+ needs_redraw = true;
+ break;
+ case Core::HID::ControllerTriggerType::Type:
+ controller_type = controller->GetNpadType();
+ needs_redraw = true;
+ break;
+ case Core::HID::ControllerTriggerType::Color:
+ UpdateColors();
+ needs_redraw = true;
+ break;
+ case Core::HID::ControllerTriggerType::Button:
+ button_values = controller->GetButtonsValues();
+ needs_redraw = true;
+ break;
+ case Core::HID::ControllerTriggerType::Stick:
+ using namespace Settings::NativeAnalog;
+ stick_values = controller->GetSticksValues();
+ // Y axis is inverted
+ stick_values[LStick].y.value = -stick_values[LStick].y.value;
+ stick_values[LStick].y.raw_value = -stick_values[LStick].y.raw_value;
+ stick_values[RStick].y.value = -stick_values[RStick].y.value;
+ stick_values[RStick].y.raw_value = -stick_values[RStick].y.raw_value;
+ needs_redraw = true;
+ break;
+ case Core::HID::ControllerTriggerType::Trigger:
+ trigger_values = controller->GetTriggersValues();
+ needs_redraw = true;
+ break;
+ case Core::HID::ControllerTriggerType::Battery:
+ battery_values = controller->GetBatteryValues();
+ needs_redraw = true;
+ break;
+ default:
+ break;
}
+}
- const auto& analog_state = sticks;
- for (std::size_t index = 0; index < axis_values.size(); ++index) {
- const auto [stick_x_f, stick_y_f] = analog_state[index]->GetStatus();
- const auto [stick_x_rf, stick_y_rf] = analog_state[index]->GetRawStatus();
+void PlayerControlPreview::UpdateInput() {
+ if (mapping_active) {
- if (static_cast(stick_x_rf * 45) !=
- static_cast(axis_values[index].raw_value.x() * 45) ||
- static_cast(-stick_y_rf * 45) !=
- static_cast(axis_values[index].raw_value.y() * 45)) {
- input_changed = true;
+ for (std::size_t index = 0; index < button_values.size(); ++index) {
+ bool blink = index == button_mapping_index;
+ if (analog_mapping_index == Settings::NativeAnalog::NumAnalogs) {
+ blink &= blink_counter > 25;
+ }
+ if (button_values[index].value != blink) {
+ needs_redraw = true;
+ }
+ button_values[index].value = blink;
}
- axis_values[index].properties = analog_state[index]->GetAnalogProperties();
- axis_values[index].value = QPointF(stick_x_f, -stick_y_f);
- axis_values[index].raw_value = QPointF(stick_x_rf, -stick_y_rf);
-
- const bool blink_analog = mapping_active && index == analog_mapping_index;
- if (blink_analog) {
- input_changed = true;
- axis_values[index].value =
- QPointF(blink_counter < 25 ? -blink_counter / 25.0f : 0,
- blink_counter > 25 ? -(blink_counter - 25) / 25.0f : 0);
+ for (std::size_t index = 0; index < stick_values.size(); ++index) {
+ const bool blink_analog = index == analog_mapping_index;
+ if (blink_analog) {
+ needs_redraw = true;
+ stick_values[index].x.value = blink_counter < 25 ? -blink_counter / 25.0f : 0;
+ stick_values[index].y.value =
+ blink_counter > 25 ? -(blink_counter - 25) / 25.0f : 0;
+ }
}
}
-
- if (input_changed) {
+ if (needs_redraw) {
update();
- if (controller_callback.input != nullptr) {
- ControllerInput input{
- .axis_values = {std::pair{
- axis_values[Settings::NativeAnalog::LStick].value.x(),
- axis_values[Settings::NativeAnalog::LStick].value.y()},
- std::pair{
- axis_values[Settings::NativeAnalog::RStick].value.x(),
- axis_values[Settings::NativeAnalog::RStick].value.y()}},
- .button_values = button_values,
- .changed = true,
- };
- controller_callback.input(std::move(input));
- }
}
if (mapping_active) {
@@ -242,10 +232,6 @@ void PlayerControlPreview::UpdateInput() {
}
}
-void PlayerControlPreview::SetCallBack(ControllerCallback callback_) {
- controller_callback = std::move(callback_);
-}
-
void PlayerControlPreview::paintEvent(QPaintEvent* event) {
QFrame::paintEvent(event);
QPainter p(this);
@@ -253,22 +239,22 @@ void PlayerControlPreview::paintEvent(QPaintEvent* event) {
const QPointF center = rect().center();
switch (controller_type) {
- case Settings::ControllerType::Handheld:
+ case Core::HID::NpadType::Handheld:
DrawHandheldController(p, center);
break;
- case Settings::ControllerType::DualJoyconDetached:
+ case Core::HID::NpadType::JoyconDual:
DrawDualController(p, center);
break;
- case Settings::ControllerType::LeftJoycon:
+ case Core::HID::NpadType::JoyconLeft:
DrawLeftController(p, center);
break;
- case Settings::ControllerType::RightJoycon:
+ case Core::HID::NpadType::JoyconRight:
DrawRightController(p, center);
break;
- case Settings::ControllerType::GameCube:
+ case Core::HID::NpadType::GameCube:
DrawGCController(p, center);
break;
- case Settings::ControllerType::ProController:
+ case Core::HID::NpadType::ProController:
default:
DrawProController(p, center);
break;
@@ -281,7 +267,7 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center)
// Sideview left joystick
DrawJoystickSideview(p, center + QPoint(142, -69),
- -axis_values[Settings::NativeAnalog::LStick].value.y(), 1.15f,
+ -stick_values[Settings::NativeAnalog::LStick].y.value, 1.15f,
button_values[LStick]);
// Topview D-pad buttons
@@ -292,7 +278,7 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center)
// Topview left joystick
DrawJoystickSideview(p, center + QPointF(-140.5f, -28),
- -axis_values[Settings::NativeAnalog::LStick].value.x() + 15.0f, 1.15f,
+ -stick_values[Settings::NativeAnalog::LStick].x.value + 15.0f, 1.15f,
button_values[LStick]);
// Topview minus button
@@ -334,8 +320,10 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center)
{
// Draw joysticks
using namespace Settings::NativeAnalog;
- DrawJoystick(p, center + QPointF(9, -69) + (axis_values[LStick].value * 8), 1.8f,
- button_values[Settings::NativeButton::LStick]);
+ DrawJoystick(p,
+ center + QPointF(9, -69) +
+ (QPointF(stick_values[LStick].x.value, stick_values[LStick].y.value) * 8),
+ 1.8f, button_values[Settings::NativeButton::LStick]);
DrawRawJoystick(p, center + QPointF(-140, 90), QPointF(0, 0));
}
@@ -384,6 +372,9 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center)
p.setPen(colors.font2);
p.setBrush(colors.font2);
DrawCircle(p, center + QPoint(26, 71), 5);
+
+ // Draw battery
+ DrawBattery(p, center + QPoint(-170, -140), battery_values[0]);
}
void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center) {
@@ -392,20 +383,22 @@ void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center
// Sideview right joystick
DrawJoystickSideview(p, center + QPoint(173 - 315, 11),
- axis_values[Settings::NativeAnalog::RStick].value.y() + 10.0f, 1.15f,
+ stick_values[Settings::NativeAnalog::RStick].y.value + 10.0f, 1.15f,
button_values[Settings::NativeButton::RStick]);
+ // Topview right joystick
+ DrawJoystickSideview(p, center + QPointF(140, -28),
+ -stick_values[Settings::NativeAnalog::RStick].x.value + 15.0f, 1.15f,
+ button_values[RStick]);
+
// Topview face buttons
p.setPen(colors.outline);
button_color = colors.button;
DrawRoundButton(p, center + QPoint(163, -21), button_values[A], 11, 5, Direction::Up);
+ DrawRoundButton(p, center + QPoint(140, -21), button_values[B], 11, 5, Direction::Up);
+ DrawRoundButton(p, center + QPoint(140, -21), button_values[X], 11, 5, Direction::Up);
DrawRoundButton(p, center + QPoint(117, -21), button_values[Y], 11, 5, Direction::Up);
- // Topview right joystick
- DrawJoystickSideview(p, center + QPointF(140, -28),
- -axis_values[Settings::NativeAnalog::RStick].value.x() + 15.0f, 1.15f,
- button_values[RStick]);
-
// Topview plus button
p.setPen(colors.outline);
button_color = colors.button;
@@ -448,8 +441,10 @@ void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center
{
// Draw joysticks
using namespace Settings::NativeAnalog;
- DrawJoystick(p, center + QPointF(-9, 11) + (axis_values[RStick].value * 8), 1.8f,
- button_values[Settings::NativeButton::RStick]);
+ DrawJoystick(p,
+ center + QPointF(-9, 11) +
+ (QPointF(stick_values[RStick].x.value, stick_values[RStick].y.value) * 8),
+ 1.8f, button_values[Settings::NativeButton::RStick]);
DrawRawJoystick(p, QPointF(0, 0), center + QPointF(140, 90));
}
@@ -503,6 +498,9 @@ void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center
p.setPen(colors.transparent);
p.setBrush(colors.font2);
DrawSymbol(p, center + QPoint(-26, 66), Symbol::House, 5);
+
+ // Draw battery
+ DrawBattery(p, center + QPoint(110, -140), battery_values[1]);
}
void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center) {
@@ -512,17 +510,19 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center)
// Left/Right trigger
DrawDualTriggers(p, center, button_values[L], button_values[R]);
+ // Topview right joystick
+ DrawJoystickSideview(p, center + QPointF(180, -78),
+ -stick_values[Settings::NativeAnalog::RStick].x.value + 15.0f, 1,
+ button_values[RStick]);
+
// Topview face buttons
p.setPen(colors.outline);
button_color = colors.button;
DrawRoundButton(p, center + QPoint(200, -71), button_values[A], 10, 5, Direction::Up);
+ DrawRoundButton(p, center + QPoint(180, -71), button_values[B], 10, 5, Direction::Up);
+ DrawRoundButton(p, center + QPoint(180, -71), button_values[X], 10, 5, Direction::Up);
DrawRoundButton(p, center + QPoint(160, -71), button_values[Y], 10, 5, Direction::Up);
- // Topview right joystick
- DrawJoystickSideview(p, center + QPointF(180, -78),
- -axis_values[Settings::NativeAnalog::RStick].value.x() + 15.0f, 1,
- button_values[RStick]);
-
// Topview plus button
p.setPen(colors.outline);
button_color = colors.button;
@@ -538,7 +538,7 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center)
// Topview left joystick
DrawJoystickSideview(p, center + QPointF(-180.5f, -78),
- -axis_values[Settings::NativeAnalog::LStick].value.x() + 15.0f, 1,
+ -stick_values[Settings::NativeAnalog::LStick].x.value + 15.0f, 1,
button_values[LStick]);
// Topview minus button
@@ -557,13 +557,13 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center)
{
// Draw joysticks
using namespace Settings::NativeAnalog;
- const auto& l_stick = axis_values[LStick];
+ const auto l_stick = QPointF(stick_values[LStick].x.value, stick_values[LStick].y.value);
const auto l_button = button_values[Settings::NativeButton::LStick];
- const auto& r_stick = axis_values[RStick];
+ const auto r_stick = QPointF(stick_values[RStick].x.value, stick_values[RStick].y.value);
const auto r_button = button_values[Settings::NativeButton::RStick];
- DrawJoystick(p, center + QPointF(-65, -65) + (l_stick.value * 7), 1.62f, l_button);
- DrawJoystick(p, center + QPointF(65, 12) + (r_stick.value * 7), 1.62f, r_button);
+ DrawJoystick(p, center + QPointF(-65, -65) + (l_stick * 7), 1.62f, l_button);
+ DrawJoystick(p, center + QPointF(65, 12) + (r_stick * 7), 1.62f, r_button);
DrawRawJoystick(p, center + QPointF(-180, 90), center + QPointF(180, 90));
}
@@ -634,6 +634,10 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center)
p.setPen(colors.transparent);
p.setBrush(colors.font2);
DrawSymbol(p, center + QPoint(50, 60), Symbol::House, 4.2f);
+
+ // Draw battery
+ DrawBattery(p, center + QPoint(-100, -160), battery_values[0]);
+ DrawBattery(p, center + QPoint(40, -160), battery_values[1]);
}
void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF center) {
@@ -643,13 +647,13 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen
{
// Draw joysticks
using namespace Settings::NativeAnalog;
- const auto& l_stick = axis_values[LStick];
+ const auto l_stick = QPointF(stick_values[LStick].x.value, stick_values[LStick].y.value);
const auto l_button = button_values[Settings::NativeButton::LStick];
- const auto& r_stick = axis_values[RStick];
+ const auto r_stick = QPointF(stick_values[RStick].x.value, stick_values[RStick].y.value);
const auto r_button = button_values[Settings::NativeButton::RStick];
- DrawJoystick(p, center + QPointF(-171, -41) + (l_stick.value * 4), 1.0f, l_button);
- DrawJoystick(p, center + QPointF(171, 8) + (r_stick.value * 4), 1.0f, r_button);
+ DrawJoystick(p, center + QPointF(-171, -41) + (l_stick * 4), 1.0f, l_button);
+ DrawJoystick(p, center + QPointF(171, 8) + (r_stick * 4), 1.0f, r_button);
DrawRawJoystick(p, center + QPointF(-50, 0), center + QPointF(50, 0));
}
@@ -732,6 +736,11 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen
p.setPen(colors.transparent);
p.setBrush(colors.font2);
DrawSymbol(p, center + QPoint(161, 37), Symbol::House, 2.75f);
+
+ // Draw battery
+ DrawBattery(p, center + QPoint(-200, 110), battery_values[0]);
+ DrawBattery(p, center + QPoint(-30, 110), battery_values[1]);
+ DrawBattery(p, center + QPoint(130, 110), battery_values[2]);
}
void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) {
@@ -741,9 +750,11 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
{
// Draw joysticks
using namespace Settings::NativeAnalog;
- DrawProJoystick(p, center + QPointF(-111, -55), axis_values[LStick].value, 11,
+ const auto l_stick = QPointF(stick_values[LStick].x.value, stick_values[LStick].y.value);
+ const auto r_stick = QPointF(stick_values[RStick].x.value, stick_values[RStick].y.value);
+ DrawProJoystick(p, center + QPointF(-111, -55), l_stick, 11,
button_values[Settings::NativeButton::LStick]);
- DrawProJoystick(p, center + QPointF(51, 0), axis_values[RStick].value, 11,
+ DrawProJoystick(p, center + QPointF(51, 0), r_stick, 11,
button_values[Settings::NativeButton::RStick]);
DrawRawJoystick(p, center + QPointF(-50, 105), center + QPointF(50, 105));
}
@@ -817,24 +828,26 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
p.setPen(colors.transparent);
p.setBrush(colors.font2);
DrawSymbol(p, center + QPoint(29, -56), Symbol::House, 3.9f);
+
+ // Draw battery
+ DrawBattery(p, center + QPoint(-30, -165), battery_values[0]);
}
void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) {
- DrawGCTriggers(p, center, button_values[Settings::NativeButton::ZL],
- button_values[Settings::NativeButton::ZR]);
+ DrawGCTriggers(p, center, trigger_values[0], trigger_values[1]);
DrawGCButtonZ(p, center, button_values[Settings::NativeButton::R]);
DrawGCBody(p, center);
{
// Draw joysticks
using namespace Settings::NativeAnalog;
- DrawGCJoystick(p, center + QPointF(-111, -44) + (axis_values[LStick].value * 10), false);
+ const auto l_stick = QPointF(stick_values[LStick].x.value, stick_values[LStick].y.value);
+ const auto r_stick = QPointF(stick_values[RStick].x.value, stick_values[RStick].y.value);
+ DrawGCJoystick(p, center + QPointF(-111, -44) + (l_stick * 10), {});
button_color = colors.button2;
- DrawCircleButton(p, center + QPointF(61, 37) + (axis_values[RStick].value * 9.5f), false,
- 15);
+ DrawCircleButton(p, center + QPointF(61, 37) + (r_stick * 9.5f), {}, 15);
p.setPen(colors.transparent);
p.setBrush(colors.font);
- DrawSymbol(p, center + QPointF(61, 37) + (axis_values[RStick].value * 9.5f), Symbol::C,
- 1.0f);
+ DrawSymbol(p, center + QPointF(61, 37) + (r_stick * 9.5f), Symbol::C, 1.0f);
DrawRawJoystick(p, center + QPointF(-198, -125), center + QPointF(198, -125));
}
@@ -871,6 +884,9 @@ void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) {
// Minus and Plus buttons
p.setPen(colors.outline);
DrawCircleButton(p, center + QPoint(0, -44), button_values[Plus], 8);
+
+ // Draw battery
+ DrawBattery(p, center + QPoint(-30, -165), battery_values[0]);
}
constexpr std::array symbol_a = {
@@ -1939,8 +1955,9 @@ void PlayerControlPreview::DrawRightBody(QPainter& p, const QPointF center) {
}
}
-void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center, bool left_pressed,
- bool right_pressed) {
+void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& left_pressed,
+ const Input::ButtonStatus& right_pressed) {
std::array qleft_trigger;
std::array qright_trigger;
std::array qbody_top;
@@ -1949,8 +1966,10 @@ void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center, bo
const float trigger_x = pro_left_trigger[point * 2 + 0];
const float trigger_y = pro_left_trigger[point * 2 + 1];
- qleft_trigger[point] = center + QPointF(trigger_x, trigger_y + (left_pressed ? 2 : 0));
- qright_trigger[point] = center + QPointF(-trigger_x, trigger_y + (right_pressed ? 2 : 0));
+ qleft_trigger[point] =
+ center + QPointF(trigger_x, trigger_y + (left_pressed.value ? 2 : 0));
+ qright_trigger[point] =
+ center + QPointF(-trigger_x, trigger_y + (right_pressed.value ? 2 : 0));
}
for (std::size_t point = 0; point < pro_body_top.size() / 2; ++point) {
@@ -1967,16 +1986,17 @@ void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center, bo
DrawPolygon(p, qbody_top);
// Left trigger
- p.setBrush(left_pressed ? colors.highlight : colors.button);
+ p.setBrush(left_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
// Right trigger
- p.setBrush(right_pressed ? colors.highlight : colors.button);
+ p.setBrush(right_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
}
-void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center, bool left_pressed,
- bool right_pressed) {
+void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center,
+ Input::TriggerStatus left_trigger,
+ Input::TriggerStatus right_trigger) {
std::array qleft_trigger;
std::array qright_trigger;
@@ -1984,32 +2004,37 @@ void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center, boo
const float trigger_x = left_gc_trigger[point * 2 + 0];
const float trigger_y = left_gc_trigger[point * 2 + 1];
- qleft_trigger[point] = center + QPointF(trigger_x, trigger_y + (left_pressed ? 10 : 0));
- qright_trigger[point] = center + QPointF(-trigger_x, trigger_y + (right_pressed ? 10 : 0));
+ qleft_trigger[point] =
+ center + QPointF(trigger_x, trigger_y + (left_trigger.analog.value * 10.0f));
+ qright_trigger[point] =
+ center + QPointF(-trigger_x, trigger_y + (right_trigger.analog.value * 10.0f));
}
// Left trigger
p.setPen(colors.outline);
- p.setBrush(left_pressed ? colors.highlight : colors.button);
+ p.setBrush(left_trigger.pressed ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
// Right trigger
- p.setBrush(right_pressed ? colors.highlight : colors.button);
+ p.setBrush(right_trigger.pressed ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
// Draw L text
p.setPen(colors.transparent);
p.setBrush(colors.font);
- DrawSymbol(p, center + QPointF(-132, -119 + (left_pressed ? 10 : 0)), Symbol::L, 1.7f);
+ DrawSymbol(p, center + QPointF(-132, -119 + (left_trigger.analog.value * 10.0f)), Symbol::L,
+ 1.7f);
// Draw R text
p.setPen(colors.transparent);
p.setBrush(colors.font);
- DrawSymbol(p, center + QPointF(121.5f, -119 + (right_pressed ? 10 : 0)), Symbol::R, 1.7f);
+ DrawSymbol(p, center + QPointF(121.5f, -119 + (right_trigger.analog.value * 10.0f)), Symbol::R,
+ 1.7f);
}
void PlayerControlPreview::DrawHandheldTriggers(QPainter& p, const QPointF center,
- bool left_pressed, bool right_pressed) {
+ const Input::ButtonStatus& left_pressed,
+ const Input::ButtonStatus& right_pressed) {
std::array qleft_trigger;
std::array qright_trigger;
@@ -2018,23 +2043,24 @@ void PlayerControlPreview::DrawHandheldTriggers(QPainter& p, const QPointF cente
const float left_trigger_y = left_joycon_trigger[point * 2 + 1];
qleft_trigger[point] =
- center + QPointF(left_trigger_x, left_trigger_y + (left_pressed ? 0.5f : 0));
+ center + QPointF(left_trigger_x, left_trigger_y + (left_pressed.value ? 0.5f : 0));
qright_trigger[point] =
- center + QPointF(-left_trigger_x, left_trigger_y + (right_pressed ? 0.5f : 0));
+ center + QPointF(-left_trigger_x, left_trigger_y + (right_pressed.value ? 0.5f : 0));
}
// Left trigger
p.setPen(colors.outline);
- p.setBrush(left_pressed ? colors.highlight : colors.button);
+ p.setBrush(left_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
// Right trigger
- p.setBrush(right_pressed ? colors.highlight : colors.button);
+ p.setBrush(right_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
}
-void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center, bool left_pressed,
- bool right_pressed) {
+void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& left_pressed,
+ const Input::ButtonStatus& right_pressed) {
std::array qleft_trigger;
std::array qright_trigger;
constexpr float size = 1.62f;
@@ -2043,25 +2069,27 @@ void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center, b
const float left_trigger_x = left_joycon_trigger[point * 2 + 0];
const float left_trigger_y = left_joycon_trigger[point * 2 + 1];
- qleft_trigger[point] = center + QPointF(left_trigger_x * size + offset,
- left_trigger_y * size + (left_pressed ? 0.5f : 0));
+ qleft_trigger[point] =
+ center + QPointF(left_trigger_x * size + offset,
+ left_trigger_y * size + (left_pressed.value ? 0.5f : 0));
qright_trigger[point] =
center + QPointF(-left_trigger_x * size - offset,
- left_trigger_y * size + (right_pressed ? 0.5f : 0));
+ left_trigger_y * size + (right_pressed.value ? 0.5f : 0));
}
// Left trigger
p.setPen(colors.outline);
- p.setBrush(left_pressed ? colors.highlight : colors.button);
+ p.setBrush(left_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
// Right trigger
- p.setBrush(right_pressed ? colors.highlight : colors.button);
+ p.setBrush(right_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
}
void PlayerControlPreview::DrawDualTriggersTopView(QPainter& p, const QPointF center,
- bool left_pressed, bool right_pressed) {
+ const Input::ButtonStatus& left_pressed,
+ const Input::ButtonStatus& right_pressed) {
std::array qleft_trigger;
std::array qright_trigger;
constexpr float size = 0.9f;
@@ -2080,9 +2108,9 @@ void PlayerControlPreview::DrawDualTriggersTopView(QPainter& p, const QPointF ce
}
p.setPen(colors.outline);
- p.setBrush(left_pressed ? colors.highlight : colors.button);
+ p.setBrush(left_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
- p.setBrush(right_pressed ? colors.highlight : colors.button);
+ p.setBrush(right_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
// Draw L text
@@ -2097,7 +2125,8 @@ void PlayerControlPreview::DrawDualTriggersTopView(QPainter& p, const QPointF ce
}
void PlayerControlPreview::DrawDualZTriggersTopView(QPainter& p, const QPointF center,
- bool left_pressed, bool right_pressed) {
+ const Input::ButtonStatus& left_pressed,
+ const Input::ButtonStatus& right_pressed) {
std::array qleft_trigger;
std::array qright_trigger;
constexpr float size = 0.9f;
@@ -2114,9 +2143,9 @@ void PlayerControlPreview::DrawDualZTriggersTopView(QPainter& p, const QPointF c
}
p.setPen(colors.outline);
- p.setBrush(left_pressed ? colors.highlight : colors.button);
+ p.setBrush(left_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
- p.setBrush(right_pressed ? colors.highlight : colors.button);
+ p.setBrush(right_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
// Draw ZL text
@@ -2130,7 +2159,8 @@ void PlayerControlPreview::DrawDualZTriggersTopView(QPainter& p, const QPointF c
DrawSymbol(p, center + QPointF(180, -113), Symbol::ZR, 1.0f);
}
-void PlayerControlPreview::DrawLeftTriggers(QPainter& p, const QPointF center, bool left_pressed) {
+void PlayerControlPreview::DrawLeftTriggers(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& left_pressed) {
std::array qleft_trigger;
constexpr float size = 1.78f;
constexpr float offset = 311.5f;
@@ -2138,15 +2168,16 @@ void PlayerControlPreview::DrawLeftTriggers(QPainter& p, const QPointF center, b
for (std::size_t point = 0; point < left_joycon_trigger.size() / 2; ++point) {
qleft_trigger[point] = center + QPointF(left_joycon_trigger[point * 2] * size + offset,
left_joycon_trigger[point * 2 + 1] * size -
- (left_pressed ? 0.5f : 1.0f));
+ (left_pressed.value ? 0.5f : 1.0f));
}
p.setPen(colors.outline);
- p.setBrush(left_pressed ? colors.highlight : colors.button);
+ p.setBrush(left_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
}
-void PlayerControlPreview::DrawLeftZTriggers(QPainter& p, const QPointF center, bool left_pressed) {
+void PlayerControlPreview::DrawLeftZTriggers(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& left_pressed) {
std::array qleft_trigger;
constexpr float size = 1.1115f;
constexpr float offset2 = 335;
@@ -2154,18 +2185,18 @@ void PlayerControlPreview::DrawLeftZTriggers(QPainter& p, const QPointF center,
for (std::size_t point = 0; point < left_joycon_sideview_zl.size() / 2; ++point) {
qleft_trigger[point] = center + QPointF(left_joycon_sideview_zl[point * 2] * size + offset2,
left_joycon_sideview_zl[point * 2 + 1] * size +
- (left_pressed ? 1.5f : 1.0f));
+ (left_pressed.value ? 1.5f : 1.0f));
}
p.setPen(colors.outline);
- p.setBrush(left_pressed ? colors.highlight : colors.button);
+ p.setBrush(left_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
- p.drawArc(center.x() + 158, center.y() + (left_pressed ? -203.5f : -204.0f), 77, 77, 225 * 16,
- 44 * 16);
+ p.drawArc(center.x() + 158, center.y() + (left_pressed.value ? -203.5f : -204.0f), 77, 77,
+ 225 * 16, 44 * 16);
}
void PlayerControlPreview::DrawLeftTriggersTopView(QPainter& p, const QPointF center,
- bool left_pressed) {
+ const Input::ButtonStatus& left_pressed) {
std::array qleft_trigger;
for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) {
@@ -2174,7 +2205,7 @@ void PlayerControlPreview::DrawLeftTriggersTopView(QPainter& p, const QPointF ce
}
p.setPen(colors.outline);
- p.setBrush(left_pressed ? colors.highlight : colors.button);
+ p.setBrush(left_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
// Draw L text
@@ -2184,7 +2215,7 @@ void PlayerControlPreview::DrawLeftTriggersTopView(QPainter& p, const QPointF ce
}
void PlayerControlPreview::DrawLeftZTriggersTopView(QPainter& p, const QPointF center,
- bool left_pressed) {
+ const Input::ButtonStatus& left_pressed) {
std::array qleft_trigger;
for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) {
@@ -2193,7 +2224,7 @@ void PlayerControlPreview::DrawLeftZTriggersTopView(QPainter& p, const QPointF c
}
p.setPen(colors.outline);
- p.setBrush(left_pressed ? colors.highlight : colors.button);
+ p.setBrush(left_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
// Draw ZL text
@@ -2203,7 +2234,7 @@ void PlayerControlPreview::DrawLeftZTriggersTopView(QPainter& p, const QPointF c
}
void PlayerControlPreview::DrawRightTriggers(QPainter& p, const QPointF center,
- bool right_pressed) {
+ const Input::ButtonStatus& right_pressed) {
std::array qright_trigger;
constexpr float size = 1.78f;
constexpr float offset = 311.5f;
@@ -2211,36 +2242,36 @@ void PlayerControlPreview::DrawRightTriggers(QPainter& p, const QPointF center,
for (std::size_t point = 0; point < left_joycon_trigger.size() / 2; ++point) {
qright_trigger[point] = center + QPointF(-left_joycon_trigger[point * 2] * size - offset,
left_joycon_trigger[point * 2 + 1] * size -
- (right_pressed ? 0.5f : 1.0f));
+ (right_pressed.value ? 0.5f : 1.0f));
}
p.setPen(colors.outline);
- p.setBrush(right_pressed ? colors.highlight : colors.button);
+ p.setBrush(right_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
}
void PlayerControlPreview::DrawRightZTriggers(QPainter& p, const QPointF center,
- bool right_pressed) {
+ const Input::ButtonStatus& right_pressed) {
std::array qright_trigger;
constexpr float size = 1.1115f;
constexpr float offset2 = 335;
for (std::size_t point = 0; point < left_joycon_sideview_zl.size() / 2; ++point) {
qright_trigger[point] =
- center +
- QPointF(-left_joycon_sideview_zl[point * 2] * size - offset2,
- left_joycon_sideview_zl[point * 2 + 1] * size + (right_pressed ? 0.5f : 0) + 1);
+ center + QPointF(-left_joycon_sideview_zl[point * 2] * size - offset2,
+ left_joycon_sideview_zl[point * 2 + 1] * size +
+ (right_pressed.value ? 0.5f : 0) + 1);
}
p.setPen(colors.outline);
- p.setBrush(right_pressed ? colors.highlight : colors.button);
+ p.setBrush(right_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
- p.drawArc(center.x() - 236, center.y() + (right_pressed ? -203.5f : -204.0f), 77, 77, 271 * 16,
- 44 * 16);
+ p.drawArc(center.x() - 236, center.y() + (right_pressed.value ? -203.5f : -204.0f), 77, 77,
+ 271 * 16, 44 * 16);
}
void PlayerControlPreview::DrawRightTriggersTopView(QPainter& p, const QPointF center,
- bool right_pressed) {
+ const Input::ButtonStatus& right_pressed) {
std::array qright_trigger;
for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) {
@@ -2249,7 +2280,7 @@ void PlayerControlPreview::DrawRightTriggersTopView(QPainter& p, const QPointF c
}
p.setPen(colors.outline);
- p.setBrush(right_pressed ? colors.highlight : colors.button);
+ p.setBrush(right_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
// Draw R text
@@ -2259,7 +2290,7 @@ void PlayerControlPreview::DrawRightTriggersTopView(QPainter& p, const QPointF c
}
void PlayerControlPreview::DrawRightZTriggersTopView(QPainter& p, const QPointF center,
- bool right_pressed) {
+ const Input::ButtonStatus& right_pressed) {
std::array qright_trigger;
for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) {
@@ -2268,7 +2299,7 @@ void PlayerControlPreview::DrawRightZTriggersTopView(QPainter& p, const QPointF
}
p.setPen(colors.outline);
- p.setBrush(right_pressed ? colors.highlight : colors.button);
+ p.setBrush(right_pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
// Draw ZR text
@@ -2278,13 +2309,13 @@ void PlayerControlPreview::DrawRightZTriggersTopView(QPainter& p, const QPointF
}
void PlayerControlPreview::DrawJoystick(QPainter& p, const QPointF center, float size,
- bool pressed) {
+ const Input::ButtonStatus& pressed) {
const float radius1 = 13.0f * size;
const float radius2 = 9.0f * size;
// Outer circle
p.setPen(colors.outline);
- p.setBrush(pressed ? colors.highlight : colors.button);
+ p.setBrush(pressed.value ? colors.highlight : colors.button);
DrawCircle(p, center, radius1);
// Cross
@@ -2292,17 +2323,17 @@ void PlayerControlPreview::DrawJoystick(QPainter& p, const QPointF center, float
p.drawLine(center - QPoint(0, radius1), center + QPoint(0, radius1));
// Inner circle
- p.setBrush(pressed ? colors.highlight2 : colors.button2);
+ p.setBrush(pressed.value ? colors.highlight2 : colors.button2);
DrawCircle(p, center, radius2);
}
void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF center, float angle,
- float size, bool pressed) {
+ float size, const Input::ButtonStatus& pressed) {
QVector joystick;
joystick.reserve(static_cast(left_joystick_sideview.size() / 2));
for (std::size_t point = 0; point < left_joystick_sideview.size() / 2; ++point) {
- joystick.append(QPointF(left_joystick_sideview[point * 2] * size + (pressed ? 1 : 0),
+ joystick.append(QPointF(left_joystick_sideview[point * 2] * size + (pressed.value ? 1 : 0),
left_joystick_sideview[point * 2 + 1] * size - 1));
}
@@ -2314,14 +2345,15 @@ void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF cente
// Draw joystick
p.setPen(colors.outline);
- p.setBrush(pressed ? colors.highlight : colors.button);
+ p.setBrush(pressed.value ? colors.highlight : colors.button);
p.drawPolygon(p2);
p.drawLine(p2.at(1), p2.at(30));
p.drawLine(p2.at(32), p2.at(71));
}
void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, const QPointF offset,
- float offset_scalar, bool pressed) {
+ float offset_scalar,
+ const Input::ButtonStatus& pressed) {
const float radius1 = 24.0f;
const float radius2 = 17.0f;
@@ -2339,11 +2371,11 @@ void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, co
// Outer circle
p.setPen(colors.outline);
- p.setBrush(pressed ? colors.highlight : colors.button);
+ p.setBrush(pressed.value ? colors.highlight : colors.button);
p.drawEllipse(QPointF(0, 0), radius1 * amplitude, radius1);
// Inner circle
- p.setBrush(pressed ? colors.highlight2 : colors.button2);
+ p.setBrush(pressed.value ? colors.highlight2 : colors.button2);
const float inner_offset =
(radius1 - radius2) * 0.4f * ((offset.x() == 0 && offset.y() < 0) ? -1.0f : 1.0f);
@@ -2355,14 +2387,15 @@ void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, co
p.restore();
}
-void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, bool pressed) {
+void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& pressed) {
// Outer circle
p.setPen(colors.outline);
- p.setBrush(pressed ? colors.highlight : colors.button);
+ p.setBrush(pressed.value ? colors.highlight : colors.button);
DrawCircle(p, center, 26.0f);
// Inner circle
- p.setBrush(pressed ? colors.highlight2 : colors.button2);
+ p.setBrush(pressed.value ? colors.highlight2 : colors.button2);
DrawCircle(p, center, 19.0f);
p.setBrush(colors.transparent);
DrawCircle(p, center, 13.5f);
@@ -2371,26 +2404,24 @@ void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, boo
void PlayerControlPreview::DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right) {
using namespace Settings::NativeAnalog;
- if (controller_type != Settings::ControllerType::LeftJoycon) {
- DrawJoystickProperties(p, center_right, axis_values[RStick].properties);
+ if (controller_type != Core::HID::NpadType::JoyconLeft) {
+ DrawJoystickProperties(p, center_right, stick_values[RStick].x.properties);
p.setPen(colors.indicator);
p.setBrush(colors.indicator);
- DrawJoystickDot(p, center_right, axis_values[RStick].raw_value,
- axis_values[RStick].properties);
+ DrawJoystickDot(p, center_right, stick_values[RStick], true);
p.setPen(colors.indicator2);
p.setBrush(colors.indicator2);
- DrawJoystickDot(p, center_right, axis_values[RStick].value, axis_values[RStick].properties);
+ DrawJoystickDot(p, center_right, stick_values[RStick], false);
}
- if (controller_type != Settings::ControllerType::RightJoycon) {
- DrawJoystickProperties(p, center_left, axis_values[LStick].properties);
+ if (controller_type != Core::HID::NpadType::JoyconRight) {
+ DrawJoystickProperties(p, center_left, stick_values[LStick].x.properties);
p.setPen(colors.indicator);
p.setBrush(colors.indicator);
- DrawJoystickDot(p, center_left, axis_values[LStick].raw_value,
- axis_values[LStick].properties);
+ DrawJoystickDot(p, center_left, stick_values[LStick], true);
p.setPen(colors.indicator2);
p.setBrush(colors.indicator2);
- DrawJoystickDot(p, center_left, axis_values[LStick].value, axis_values[LStick].properties);
+ DrawJoystickDot(p, center_left, stick_values[LStick], false);
}
}
@@ -2414,19 +2445,26 @@ void PlayerControlPreview::DrawJoystickProperties(QPainter& p, const QPointF cen
DrawCircle(p, center, deadzone);
}
-void PlayerControlPreview::DrawJoystickDot(QPainter& p, const QPointF center, const QPointF value,
- const Input::AnalogProperties& properties) {
+void PlayerControlPreview::DrawJoystickDot(QPainter& p, const QPointF center,
+ const Input::StickStatus& stick, bool raw) {
constexpr float size = 45.0f;
- const float range = size * properties.range;
+ const float range = size * stick.x.properties.range;
+
+ if (raw) {
+ const QPointF value = QPointF(stick.x.raw_value, stick.y.raw_value) * size;
+ DrawCircle(p, center + value, 2);
+ return;
+ }
- // Dot pointer
- DrawCircle(p, center + (value * range), 2);
+ const QPointF value = QPointF(stick.x.value, stick.y.value) * range;
+ DrawCircle(p, center + value, 2);
}
-void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center, bool pressed, float width,
+void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center,
+ const Input::ButtonStatus& pressed, float width,
float height, Direction direction, float radius) {
p.setBrush(button_color);
- if (pressed) {
+ if (pressed.value) {
switch (direction) {
case Direction::Left:
center.setX(center.x() - 1);
@@ -2448,17 +2486,17 @@ void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center, bool pre
QRectF rect = {center.x() - width, center.y() - height, width * 2.0f, height * 2.0f};
p.drawRoundedRect(rect, radius, radius);
}
-void PlayerControlPreview::DrawMinusButton(QPainter& p, const QPointF center, bool pressed,
- int button_size) {
+void PlayerControlPreview::DrawMinusButton(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& pressed, int button_size) {
p.setPen(colors.outline);
- p.setBrush(pressed ? colors.highlight : colors.button);
+ p.setBrush(pressed.value ? colors.highlight : colors.button);
DrawRectangle(p, center, button_size, button_size / 3.0f);
}
-void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center, bool pressed,
- int button_size) {
+void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& pressed, int button_size) {
// Draw outer line
p.setPen(colors.outline);
- p.setBrush(pressed ? colors.highlight : colors.button);
+ p.setBrush(pressed.value ? colors.highlight : colors.button);
DrawRectangle(p, center, button_size, button_size / 3.0f);
DrawRectangle(p, center, button_size / 3.0f, button_size);
@@ -2471,7 +2509,8 @@ void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center, boo
DrawRectangle(p, center, button_size / 3.0f, button_size);
}
-void PlayerControlPreview::DrawGCButtonX(QPainter& p, const QPointF center, bool pressed) {
+void PlayerControlPreview::DrawGCButtonX(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& pressed) {
std::array button_x;
for (std::size_t point = 0; point < gc_button_x.size() / 2; ++point) {
@@ -2479,11 +2518,12 @@ void PlayerControlPreview::DrawGCButtonX(QPainter& p, const QPointF center, bool
}
p.setPen(colors.outline);
- p.setBrush(pressed ? colors.highlight : colors.button);
+ p.setBrush(pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, button_x);
}
-void PlayerControlPreview::DrawGCButtonY(QPainter& p, const QPointF center, bool pressed) {
+void PlayerControlPreview::DrawGCButtonY(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& pressed) {
std::array button_x;
for (std::size_t point = 0; point < gc_button_y.size() / 2; ++point) {
@@ -2491,27 +2531,28 @@ void PlayerControlPreview::DrawGCButtonY(QPainter& p, const QPointF center, bool
}
p.setPen(colors.outline);
- p.setBrush(pressed ? colors.highlight : colors.button);
+ p.setBrush(pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, button_x);
}
-void PlayerControlPreview::DrawGCButtonZ(QPainter& p, const QPointF center, bool pressed) {
+void PlayerControlPreview::DrawGCButtonZ(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& pressed) {
std::array button_x;
for (std::size_t point = 0; point < gc_button_z.size() / 2; ++point) {
button_x[point] = center + QPointF(gc_button_z[point * 2],
- gc_button_z[point * 2 + 1] + (pressed ? 1 : 0));
+ gc_button_z[point * 2 + 1] + (pressed.value ? 1 : 0));
}
p.setPen(colors.outline);
- p.setBrush(pressed ? colors.highlight : colors.button2);
+ p.setBrush(pressed.value ? colors.highlight : colors.button2);
DrawPolygon(p, button_x);
}
-void PlayerControlPreview::DrawCircleButton(QPainter& p, const QPointF center, bool pressed,
- float button_size) {
+void PlayerControlPreview::DrawCircleButton(QPainter& p, const QPointF center,
+ const Input::ButtonStatus& pressed, float button_size) {
p.setBrush(button_color);
- if (pressed) {
+ if (pressed.value) {
p.setBrush(colors.highlight);
}
p.drawEllipse(center, button_size, button_size);
@@ -2540,7 +2581,8 @@ void PlayerControlPreview::DrawArrowButtonOutline(QPainter& p, const QPointF cen
}
void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
- const Direction direction, bool pressed, float size) {
+ const Direction direction,
+ const Input::ButtonStatus& pressed, float size) {
std::array arrow_button;
QPoint offset;
@@ -2567,8 +2609,8 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
}
// Draw arrow button
- p.setPen(pressed ? colors.highlight : colors.button);
- p.setBrush(pressed ? colors.highlight : colors.button);
+ p.setPen(pressed.value ? colors.highlight : colors.button);
+ p.setBrush(pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, arrow_button);
switch (direction) {
@@ -2596,7 +2638,8 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center,
- const Direction direction, bool pressed) {
+ const Direction direction,
+ const Input::ButtonStatus& pressed) {
std::array qtrigger_button;
for (std::size_t point = 0; point < trigger_button.size() / 2; ++point) {
@@ -2619,10 +2662,44 @@ void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center,
// Draw arrow button
p.setPen(colors.outline);
- p.setBrush(pressed ? colors.highlight : colors.button);
+ p.setBrush(pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qtrigger_button);
}
+void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center, Input::BatteryLevel battery) {
+ p.setPen(colors.outline);
+ p.setBrush(colors.transparent);
+ p.drawRect(center.x(), center.y(), 56, 20);
+ p.drawRect(center.x() + 56, center.y() + 6, 3, 8);
+ p.setBrush(colors.deadzone);
+ switch (battery) {
+ case Input::BatteryLevel::Charging:
+ p.setBrush(colors.indicator2);
+ p.drawText(center + QPoint(2, 14), tr("Charging"));
+ break;
+ case Input::BatteryLevel::Full:
+ p.drawRect(center.x() + 42, center.y(), 14, 20);
+ p.drawRect(center.x() + 28, center.y(), 14, 20);
+ p.drawRect(center.x() + 14, center.y(), 14, 20);
+ break;
+ case Input::BatteryLevel::Medium:
+ p.drawRect(center.x() + 28, center.y(), 14, 20);
+ p.drawRect(center.x() + 14, center.y(), 14, 20);
+ p.drawRect(center.x(), center.y(), 14, 20);
+ break;
+ case Input::BatteryLevel::Low:
+ p.drawRect(center.x() + 14, center.y(), 14, 20);
+ p.drawRect(center.x(), center.y(), 14, 20);
+ break;
+ case Input::BatteryLevel::Critical:
+ p.drawRect(center.x(), center.y(), 14, 20);
+ break;
+ case Input::BatteryLevel::Empty:
+ p.drawRect(center.x(), center.y(), 5, 20);
+ break;
+ }
+}
+
void PlayerControlPreview::DrawSymbol(QPainter& p, const QPointF center, Symbol symbol,
float icon_size) {
std::array house_icon;
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index f4bbfa528..b44a2e347 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -7,9 +7,10 @@
#include
#include
#include
+#include "common/input.h"
#include "common/settings.h"
-#include "core/frontend/input.h"
-#include "yuzu/debugger/controller.h"
+#include "core/hid/hid_core.h"
+#include "core/hid/hid_types.h"
class QLabel;
@@ -24,17 +25,12 @@ public:
explicit PlayerControlPreview(QWidget* parent);
~PlayerControlPreview() override;
- void SetPlayerInput(std::size_t index, const ButtonParam& buttons_param,
- const AnalogParam& analogs_param);
- void SetPlayerInputRaw(std::size_t index, const Settings::ButtonsRaw& buttons_,
- Settings::AnalogsRaw analogs_);
- void SetConnectedStatus(bool checked);
- void SetControllerType(Settings::ControllerType type);
+ void SetController(Core::HID::EmulatedController* controller);
void BeginMappingButton(std::size_t button_id);
void BeginMappingAnalog(std::size_t button_id);
void EndMapping();
+ void ControllerUpdate(Core::HID::ControllerTriggerType type);
void UpdateInput();
- void SetCallBack(ControllerCallback callback_);
protected:
void paintEvent(QPaintEvent* event) override;
@@ -63,15 +59,6 @@ private:
SR,
};
- struct AxisValue {
- QPointF value{};
- QPointF raw_value{};
- Input::AnalogProperties properties{};
- int size{};
- QPoint offset{};
- bool active{};
- };
-
struct LedPattern {
bool position1;
bool position2;
@@ -122,47 +109,66 @@ private:
void DrawGCBody(QPainter& p, QPointF center);
// Draw triggers functions
- void DrawProTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
- void DrawGCTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
- void DrawHandheldTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
- void DrawDualTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
- void DrawDualTriggersTopView(QPainter& p, QPointF center, bool left_pressed,
- bool right_pressed);
- void DrawDualZTriggersTopView(QPainter& p, QPointF center, bool left_pressed,
- bool right_pressed);
- void DrawLeftTriggers(QPainter& p, QPointF center, bool left_pressed);
- void DrawLeftZTriggers(QPainter& p, QPointF center, bool left_pressed);
- void DrawLeftTriggersTopView(QPainter& p, QPointF center, bool left_pressed);
- void DrawLeftZTriggersTopView(QPainter& p, QPointF center, bool left_pressed);
- void DrawRightTriggers(QPainter& p, QPointF center, bool right_pressed);
- void DrawRightZTriggers(QPainter& p, QPointF center, bool right_pressed);
- void DrawRightTriggersTopView(QPainter& p, QPointF center, bool right_pressed);
- void DrawRightZTriggersTopView(QPainter& p, QPointF center, bool right_pressed);
+ void DrawProTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed,
+ const Input::ButtonStatus& right_pressed);
+ void DrawGCTriggers(QPainter& p, QPointF center, Input::TriggerStatus left_trigger,
+ Input::TriggerStatus right_trigger);
+ void DrawHandheldTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed,
+ const Input::ButtonStatus& right_pressed);
+ void DrawDualTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed,
+ const Input::ButtonStatus& right_pressed);
+ void DrawDualTriggersTopView(QPainter& p, QPointF center,
+ const Input::ButtonStatus& left_pressed,
+ const Input::ButtonStatus& right_pressed);
+ void DrawDualZTriggersTopView(QPainter& p, QPointF center,
+ const Input::ButtonStatus& left_pressed,
+ const Input::ButtonStatus& right_pressed);
+ void DrawLeftTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed);
+ void DrawLeftZTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed);
+ void DrawLeftTriggersTopView(QPainter& p, QPointF center,
+ const Input::ButtonStatus& left_pressed);
+ void DrawLeftZTriggersTopView(QPainter& p, QPointF center,
+ const Input::ButtonStatus& left_pressed);
+ void DrawRightTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& right_pressed);
+ void DrawRightZTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& right_pressed);
+ void DrawRightTriggersTopView(QPainter& p, QPointF center,
+ const Input::ButtonStatus& right_pressed);
+ void DrawRightZTriggersTopView(QPainter& p, QPointF center,
+ const Input::ButtonStatus& right_pressed);
// Draw joystick functions
- void DrawJoystick(QPainter& p, QPointF center, float size, bool pressed);
- void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, bool pressed);
+ void DrawJoystick(QPainter& p, QPointF center, float size, const Input::ButtonStatus& pressed);
+ void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size,
+ const Input::ButtonStatus& pressed);
void DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right);
void DrawJoystickProperties(QPainter& p, QPointF center,
const Input::AnalogProperties& properties);
- void DrawJoystickDot(QPainter& p, QPointF center, QPointF value,
- const Input::AnalogProperties& properties);
- void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, bool pressed);
- void DrawGCJoystick(QPainter& p, QPointF center, bool pressed);
+ void DrawJoystickDot(QPainter& p, QPointF center, const Input::StickStatus& stick, bool raw);
+ void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar,
+ const Input::ButtonStatus& pressed);
+ void DrawGCJoystick(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
// Draw button functions
- void DrawCircleButton(QPainter& p, QPointF center, bool pressed, float button_size);
- void DrawRoundButton(QPainter& p, QPointF center, bool pressed, float width, float height,
- Direction direction = Direction::None, float radius = 2);
- void DrawMinusButton(QPainter& p, QPointF center, bool pressed, int button_size);
- void DrawPlusButton(QPainter& p, QPointF center, bool pressed, int button_size);
- void DrawGCButtonX(QPainter& p, QPointF center, bool pressed);
- void DrawGCButtonY(QPainter& p, QPointF center, bool pressed);
- void DrawGCButtonZ(QPainter& p, QPointF center, bool pressed);
+ void DrawCircleButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
+ float button_size);
+ void DrawRoundButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
+ float width, float height, Direction direction = Direction::None,
+ float radius = 2);
+ void DrawMinusButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
+ int button_size);
+ void DrawPlusButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
+ int button_size);
+ void DrawGCButtonX(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
+ void DrawGCButtonY(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
+ void DrawGCButtonZ(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
void DrawArrowButtonOutline(QPainter& p, const QPointF center, float size = 1.0f);
- void DrawArrowButton(QPainter& p, QPointF center, Direction direction, bool pressed,
- float size = 1.0f);
- void DrawTriggerButton(QPainter& p, QPointF center, Direction direction, bool pressed);
+ void DrawArrowButton(QPainter& p, QPointF center, Direction direction,
+ const Input::ButtonStatus& pressed, float size = 1.0f);
+ void DrawTriggerButton(QPainter& p, QPointF center, Direction direction,
+ const Input::ButtonStatus& pressed);
+
+ // Draw battery functions
+ void DrawBattery(QPainter& p, QPointF center, Input::BatteryLevel battery);
// Draw icon functions
void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size);
@@ -178,24 +184,23 @@ private:
void SetTextFont(QPainter& p, float text_size,
const QString& font_family = QStringLiteral("sans-serif"));
- using ButtonArray =
- std::array, Settings::NativeButton::BUTTON_NS_END>;
- using StickArray =
- std::array, Settings::NativeAnalog::NUM_STICKS_HID>;
+ bool is_controller_set{};
+ bool is_connected{};
+ bool needs_redraw{};
+ Core::HID::NpadType controller_type;
- ControllerCallback controller_callback;
- bool is_enabled{};
bool mapping_active{};
int blink_counter{};
+ int callback_key;
QColor button_color{};
ColorMapping colors{};
std::array led_color{};
- ButtonArray buttons{};
- StickArray sticks{};
std::size_t player_index{};
- std::size_t button_mapping_index{Settings::NativeButton::BUTTON_NS_END};
- std::size_t analog_mapping_index{Settings::NativeAnalog::NUM_STICKS_HID};
- std::array axis_values{};
- std::array button_values{};
- Settings::ControllerType controller_type{Settings::ControllerType::ProController};
+ Core::HID::EmulatedController* controller;
+ std::size_t button_mapping_index{Settings::NativeButton::NumButtons};
+ std::size_t analog_mapping_index{Settings::NativeAnalog::NumAnalogs};
+ Core::HID::ButtonValues button_values{};
+ Core::HID::SticksValues stick_values{};
+ Core::HID::TriggerValues trigger_values{};
+ Core::HID::BatteryValues battery_values{};
};
diff --git a/src/yuzu/configuration/configure_motion_touch.cpp b/src/yuzu/configuration/configure_motion_touch.cpp
index f8e08c422..9fd1a919f 100644
--- a/src/yuzu/configuration/configure_motion_touch.cpp
+++ b/src/yuzu/configuration/configure_motion_touch.cpp
@@ -15,9 +15,9 @@
#include "common/logging/log.h"
#include "common/settings.h"
+#include "input_common/drivers/udp_client.h"
+#include "input_common/helpers/udp_protocol.h"
#include "input_common/main.h"
-#include "input_common/udp/client.h"
-#include "input_common/udp/udp.h"
#include "ui_configure_motion_touch.h"
#include "yuzu/configuration/configure_motion_touch.h"
#include "yuzu/configuration/configure_touch_from_button.h"
diff --git a/src/yuzu/configuration/configure_mouse_advanced.cpp b/src/yuzu/configuration/configure_mouse_advanced.cpp
index 2af3afda8..1e7a3751d 100644
--- a/src/yuzu/configuration/configure_mouse_advanced.cpp
+++ b/src/yuzu/configuration/configure_mouse_advanced.cpp
@@ -11,8 +11,11 @@
#include "common/assert.h"
#include "common/param_package.h"
+#include "input_common/drivers/keyboard.h"
+#include "input_common/drivers/mouse.h"
#include "input_common/main.h"
#include "ui_configure_mouse_advanced.h"
+#include "yuzu/bootmanager.h"
#include "yuzu/configuration/config.h"
#include "yuzu/configuration/configure_mouse_advanced.h"
@@ -101,7 +104,7 @@ ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent,
[=, this](const Common::ParamPackage& params) {
buttons_param[button_id] = params;
},
- InputCommon::Polling::DeviceType::Button);
+ InputCommon::Polling::InputType::Button);
});
connect(button, &QPushButton::customContextMenuRequested,
[=, this](const QPoint& menu_location) {
@@ -127,13 +130,10 @@ ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent,
connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
connect(poll_timer.get(), &QTimer::timeout, [this] {
- Common::ParamPackage params;
- for (auto& poller : device_pollers) {
- params = poller->GetNextInput();
- if (params.Has("engine")) {
- SetPollingResult(params, false);
- return;
- }
+ const auto& params = input_subsystem->GetNextInput();
+ if (params.Has("engine")) {
+ SetPollingResult(params, false);
+ return;
}
});
@@ -196,26 +196,13 @@ void ConfigureMouseAdvanced::UpdateButtonLabels() {
void ConfigureMouseAdvanced::HandleClick(
QPushButton* button, std::function new_input_setter,
- InputCommon::Polling::DeviceType type) {
+ InputCommon::Polling::InputType type) {
button->setText(tr("[press key]"));
button->setFocus();
- // Keyboard keys or mouse buttons can only be used as button devices
- want_keyboard_mouse = type == InputCommon::Polling::DeviceType::Button;
- if (want_keyboard_mouse) {
- const auto iter = std::find(button_map.begin(), button_map.end(), button);
- ASSERT(iter != button_map.end());
- const auto index = std::distance(button_map.begin(), iter);
- ASSERT(index < Settings::NativeButton::NumButtons && index >= 0);
- }
-
input_setter = new_input_setter;
- device_pollers = input_subsystem->GetPollers(type);
-
- for (auto& poller : device_pollers) {
- poller->Start();
- }
+ input_subsystem->BeginMapping(type);
QWidget::grabMouse();
QWidget::grabKeyboard();
@@ -227,9 +214,7 @@ void ConfigureMouseAdvanced::HandleClick(
void ConfigureMouseAdvanced::SetPollingResult(const Common::ParamPackage& params, bool abort) {
timeout_timer->stop();
poll_timer->stop();
- for (auto& poller : device_pollers) {
- poller->Stop();
- }
+ input_subsystem->StopMapping();
QWidget::releaseMouse();
QWidget::releaseKeyboard();
@@ -247,15 +232,8 @@ void ConfigureMouseAdvanced::mousePressEvent(QMouseEvent* event) {
return;
}
- if (want_keyboard_mouse) {
- SetPollingResult(Common::ParamPackage{InputCommon::GenerateKeyboardParam(event->button())},
- false);
- } else {
- // We don't want any mouse buttons, so don't stop polling
- return;
- }
-
- SetPollingResult({}, true);
+ const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
+ input_subsystem->GetMouse()->PressButton(0, 0, 0, 0, button);
}
void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) {
@@ -264,13 +242,6 @@ void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) {
}
if (event->key() != Qt::Key_Escape) {
- if (want_keyboard_mouse) {
- SetPollingResult(Common::ParamPackage{InputCommon::GenerateKeyboardParam(event->key())},
- false);
- } else {
- // Escape key wasn't pressed and we don't want any keyboard keys, so don't stop polling
- return;
- }
+ input_subsystem->GetKeyboard()->PressKey(event->key());
}
- SetPollingResult({}, true);
}
diff --git a/src/yuzu/configuration/configure_mouse_advanced.h b/src/yuzu/configuration/configure_mouse_advanced.h
index 65b6fca9a..5fa534eaf 100644
--- a/src/yuzu/configuration/configure_mouse_advanced.h
+++ b/src/yuzu/configuration/configure_mouse_advanced.h
@@ -46,7 +46,7 @@ private:
/// Called when the button was pressed.
void HandleClick(QPushButton* button,
std::function new_input_setter,
- InputCommon::Polling::DeviceType type);
+ InputCommon::Polling::InputType type);
/// Finish polling and configure input using the input_setter
void SetPollingResult(const Common::ParamPackage& params, bool abort);
@@ -67,12 +67,6 @@ private:
std::array button_map;
std::array buttons_param;
- std::vector> device_pollers;
-
std::unique_ptr timeout_timer;
std::unique_ptr poll_timer;
-
- /// A flag to indicate if keyboard keys are okay when configuring an input. If this is false,
- /// keyboard events are ignored.
- bool want_keyboard_mouse = false;
};
diff --git a/src/yuzu/configuration/configure_touch_from_button.cpp b/src/yuzu/configuration/configure_touch_from_button.cpp
index 40129f228..bde0a08c4 100644
--- a/src/yuzu/configuration/configure_touch_from_button.cpp
+++ b/src/yuzu/configuration/configure_touch_from_button.cpp
@@ -163,13 +163,10 @@ void ConfigureTouchFromButton::ConnectEvents() {
connect(timeout_timer.get(), &QTimer::timeout, [this]() { SetPollingResult({}, true); });
connect(poll_timer.get(), &QTimer::timeout, [this]() {
- Common::ParamPackage params;
- for (auto& poller : device_pollers) {
- params = poller->GetNextInput();
- if (params.Has("engine")) {
- SetPollingResult(params, false);
- return;
- }
+ const auto& params = input_subsystem->GetNextInput();
+ if (params.Has("engine")) {
+ SetPollingResult(params, false);
+ return;
}
});
}
@@ -248,11 +245,7 @@ void ConfigureTouchFromButton::GetButtonInput(const int row_index, const bool is
}
};
- device_pollers = input_subsystem->GetPollers(InputCommon::Polling::DeviceType::Button);
-
- for (auto& poller : device_pollers) {
- poller->Start();
- }
+ input_subsystem->BeginMapping(InputCommon::Polling::InputType::Button);
grabKeyboard();
grabMouse();
@@ -365,14 +358,14 @@ void ConfigureTouchFromButton::SetCoordinates(const int dot_id, const QPoint& po
void ConfigureTouchFromButton::SetPollingResult(const Common::ParamPackage& params,
const bool cancel) {
+ timeout_timer->stop();
+ poll_timer->stop();
+ input_subsystem->StopMapping();
+
releaseKeyboard();
releaseMouse();
qApp->restoreOverrideCursor();
- timeout_timer->stop();
- poll_timer->stop();
- for (auto& poller : device_pollers) {
- poller->Stop();
- }
+
if (input_setter) {
(*input_setter)(params, cancel);
input_setter.reset();
diff --git a/src/yuzu/configuration/configure_touch_from_button.h b/src/yuzu/configuration/configure_touch_from_button.h
index d9513e3bc..e1400481a 100644
--- a/src/yuzu/configuration/configure_touch_from_button.h
+++ b/src/yuzu/configuration/configure_touch_from_button.h
@@ -24,10 +24,6 @@ namespace InputCommon {
class InputSubsystem;
}
-namespace InputCommon::Polling {
-class DevicePoller;
-}
-
namespace Settings {
struct TouchFromButtonMap;
}
@@ -85,7 +81,6 @@ private:
std::unique_ptr timeout_timer;
std::unique_ptr poll_timer;
- std::vector> device_pollers;
std::optional> input_setter;
static constexpr int DataRoleDot = Qt::ItemDataRole::UserRole + 2;
--
cgit v1.2.3
From 06a5ef5874144a70e30e577a83ba68d1dad79e78 Mon Sep 17 00:00:00 2001
From: german77
Date: Mon, 11 Oct 2021 00:43:11 -0500
Subject: core/hid: Add output devices
---
src/yuzu/configuration/configure_input_player.cpp | 7 +++
.../configure_input_player_widget.cpp | 59 ++++++++--------------
.../configuration/configure_input_player_widget.h | 10 +---
3 files changed, 30 insertions(+), 46 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index adc9706f1..ed9c3facf 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -465,6 +465,8 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
UpdateControllerEnabledButtons();
UpdateControllerButtonNames();
UpdateMotionButtons();
+ emulated_controller->SetNpadType(
+ GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()));
});
connect(ui->comboDevices, qOverload(&QComboBox::activated), this,
@@ -540,6 +542,11 @@ void ConfigureInputPlayer::LoadConfiguration() {
void ConfigureInputPlayer::ConnectPlayer(bool connected) {
ui->groupConnectedController->setChecked(connected);
+ if (connected) {
+ emulated_controller->Connect();
+ } else {
+ emulated_controller->Disconnect();
+ }
}
void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 03d29f194..2ba9d7290 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -24,34 +24,6 @@ PlayerControlPreview::~PlayerControlPreview() {
}
};
-PlayerControlPreview::LedPattern PlayerControlPreview::GetColorPattern(std::size_t index,
- bool player_on) {
- if (!player_on) {
- return {0, 0, 0, 0};
- }
-
- switch (index) {
- case 0:
- return {1, 0, 0, 0};
- case 1:
- return {1, 1, 0, 0};
- case 2:
- return {1, 1, 1, 0};
- case 3:
- return {1, 1, 1, 1};
- case 4:
- return {1, 0, 0, 1};
- case 5:
- return {1, 0, 1, 0};
- case 6:
- return {1, 0, 1, 1};
- case 7:
- return {0, 1, 1, 0};
- default:
- return {0, 0, 0, 0};
- }
-}
-
void PlayerControlPreview::SetController(Core::HID::EmulatedController* controller_) {
if (is_controller_set) {
controller->DeleteCallback(callback_key);
@@ -160,8 +132,13 @@ void PlayerControlPreview::ControllerUpdate(Core::HID::ControllerTriggerType typ
switch (type) {
case Core::HID::ControllerTriggerType::Connected:
+ is_connected = true;
+ led_pattern = controller->GetLedPattern();
+ needs_redraw = true;
+ break;
case Core::HID::ControllerTriggerType::Disconnected:
- is_connected = controller->IsConnected();
+ is_connected = false;
+ led_pattern.raw = 0;
needs_redraw = true;
break;
case Core::HID::ControllerTriggerType::Type:
@@ -1853,10 +1830,14 @@ void PlayerControlPreview::DrawLeftBody(QPainter& p, const QPointF center) {
const float led_size = 5.0f;
const QPointF led_position = sideview_center + QPointF(0, -36);
int led_count = 0;
- for (const auto& color : led_color) {
- p.setBrush(color);
- DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size);
- }
+ p.setBrush(led_pattern.position1 ? colors.led_on : colors.led_off);
+ DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size);
+ p.setBrush(led_pattern.position2 ? colors.led_on : colors.led_off);
+ DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size);
+ p.setBrush(led_pattern.position3 ? colors.led_on : colors.led_off);
+ DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size);
+ p.setBrush(led_pattern.position4 ? colors.led_on : colors.led_off);
+ DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size);
}
void PlayerControlPreview::DrawRightBody(QPainter& p, const QPointF center) {
@@ -1949,10 +1930,14 @@ void PlayerControlPreview::DrawRightBody(QPainter& p, const QPointF center) {
const float led_size = 5.0f;
const QPointF led_position = sideview_center + QPointF(0, -36);
int led_count = 0;
- for (const auto& color : led_color) {
- p.setBrush(color);
- DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size);
- }
+ p.setBrush(led_pattern.position1 ? colors.led_on : colors.led_off);
+ DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size);
+ p.setBrush(led_pattern.position2 ? colors.led_on : colors.led_off);
+ DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size);
+ p.setBrush(led_pattern.position3 ? colors.led_on : colors.led_off);
+ DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size);
+ p.setBrush(led_pattern.position4 ? colors.led_on : colors.led_off);
+ DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size);
}
void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center,
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index b44a2e347..16f9748f5 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -59,13 +59,6 @@ private:
SR,
};
- struct LedPattern {
- bool position1;
- bool position2;
- bool position3;
- bool position4;
- };
-
struct ColorMapping {
QColor outline{};
QColor primary{};
@@ -88,7 +81,6 @@ private:
QColor deadzone{};
};
- static LedPattern GetColorPattern(std::size_t index, bool player_on);
void UpdateColors();
void ResetInputs();
@@ -194,7 +186,7 @@ private:
int callback_key;
QColor button_color{};
ColorMapping colors{};
- std::array led_color{};
+ Core::HID::LedPattern led_pattern{0, 0, 0, 0};
std::size_t player_index{};
Core::HID::EmulatedController* controller;
std::size_t button_mapping_index{Settings::NativeButton::NumButtons};
--
cgit v1.2.3
From e0da5c1bbcdf85676f968b63c8ae2587f0464193 Mon Sep 17 00:00:00 2001
From: german77
Date: Fri, 15 Oct 2021 19:07:47 -0500
Subject: kraken: Fix errors from rebase and format files
---
src/yuzu/configuration/configure_dialog.cpp | 2 +-
src/yuzu/configuration/configure_input.cpp | 9 ++++----
.../configure_input_player_widget.cpp | 25 ++++++++++++----------
.../configuration/configure_input_player_widget.h | 16 +++++++++++++-
4 files changed, 35 insertions(+), 17 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp
index 642a5f966..1eb9d70e5 100644
--- a/src/yuzu/configuration/configure_dialog.cpp
+++ b/src/yuzu/configuration/configure_dialog.cpp
@@ -74,7 +74,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
hotkeys_tab->Populate(registry);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
- input_tab->Initialize(input_subsystem);
+ input_tab->Initialize(input_subsystem, system_);
general_tab->SetResetCallback([&] { this->close(); });
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp
index 61513865f..a8611f77f 100644
--- a/src/yuzu/configuration/configure_input.cpp
+++ b/src/yuzu/configuration/configure_input.cpp
@@ -146,10 +146,11 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, Co
advanced = new ConfigureInputAdvanced(this);
ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced));
ui->tabAdvanced->layout()->addWidget(advanced);
- connect(advanced, &ConfigureInputAdvanced::CallDebugControllerDialog, [this, input_subsystem] {
- CallConfigureDialog(*this, input_subsystem, profiles.get(),
- system);
- });
+ connect(advanced, &ConfigureInputAdvanced::CallDebugControllerDialog,
+ [this, input_subsystem, &system] {
+ CallConfigureDialog(*this, input_subsystem,
+ profiles.get(), system);
+ });
connect(advanced, &ConfigureInputAdvanced::CallMouseConfigDialog, [this, input_subsystem] {
CallConfigureDialog(*this, input_subsystem);
});
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 2ba9d7290..446b72e55 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -19,15 +19,11 @@ PlayerControlPreview::PlayerControlPreview(QWidget* parent) : QFrame(parent) {
}
PlayerControlPreview::~PlayerControlPreview() {
- if (is_controller_set) {
- controller->DeleteCallback(callback_key);
- }
+ UnloadController();
};
void PlayerControlPreview::SetController(Core::HID::EmulatedController* controller_) {
- if (is_controller_set) {
- controller->DeleteCallback(callback_key);
- }
+ UnloadController();
is_controller_set = true;
controller = controller_;
Core::HID::ControllerUpdateCallback engine_callback{
@@ -36,14 +32,21 @@ void PlayerControlPreview::SetController(Core::HID::EmulatedController* controll
ControllerUpdate(Core::HID::ControllerTriggerType::All);
}
-void PlayerControlPreview::BeginMappingButton(std::size_t index) {
- button_mapping_index = index;
+void PlayerControlPreview::UnloadController() {
+ if (is_controller_set) {
+ controller->DeleteCallback(callback_key);
+ is_controller_set = false;
+ }
+}
+
+void PlayerControlPreview::BeginMappingButton(std::size_t button_id) {
+ button_mapping_index = button_id;
mapping_active = true;
}
-void PlayerControlPreview::BeginMappingAnalog(std::size_t index) {
- button_mapping_index = Settings::NativeButton::LStick + index;
- analog_mapping_index = index;
+void PlayerControlPreview::BeginMappingAnalog(std::size_t stick_id) {
+ button_mapping_index = Settings::NativeButton::LStick + stick_id;
+ analog_mapping_index = stick_id;
mapping_active = true;
}
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index 16f9748f5..333c3fc56 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -25,11 +25,25 @@ public:
explicit PlayerControlPreview(QWidget* parent);
~PlayerControlPreview() override;
+ // Sets the emulated controller to be displayed
void SetController(Core::HID::EmulatedController* controller);
+
+ // Disables events from the emulated controller
+ void UnloadController();
+
+ // Starts blinking animation at the button specified
void BeginMappingButton(std::size_t button_id);
- void BeginMappingAnalog(std::size_t button_id);
+
+ // Starts moving animation at the stick specified
+ void BeginMappingAnalog(std::size_t stick_id);
+
+ // Stops any ongoing animation
void EndMapping();
+
+ // Handles emulated controller events
void ControllerUpdate(Core::HID::ControllerTriggerType type);
+
+ // Updates input on sheduled interval
void UpdateInput();
protected:
--
cgit v1.2.3
From 4d308fd0b4fc8f14754c47811e751bf068b330b8 Mon Sep 17 00:00:00 2001
From: german77
Date: Mon, 18 Oct 2021 23:15:46 -0500
Subject: hid: Fix controller connection/disconnection
---
src/yuzu/configuration/configure_input.cpp | 1 +
src/yuzu/configuration/configure_input_player.cpp | 81 +++++++++++++++++++---
.../configure_input_player_widget.cpp | 2 +-
3 files changed, 75 insertions(+), 9 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp
index a8611f77f..67faa8be8 100644
--- a/src/yuzu/configuration/configure_input.cpp
+++ b/src/yuzu/configuration/configure_input.cpp
@@ -114,6 +114,7 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, Co
player_tabs[i]->setLayout(new QHBoxLayout(player_tabs[i]));
player_tabs[i]->layout()->addWidget(player_controllers[i]);
connect(player_controllers[i], &ConfigureInputPlayer::Connected, [&, i](bool is_connected) {
+ // Ensures that the controllers are always connected in sequential order
if (is_connected) {
for (std::size_t index = 0; index <= i; ++index) {
player_connected[index]->setChecked(is_connected);
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index ed9c3facf..81310a5b3 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -143,8 +143,26 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
timeout_timer(std::make_unique()), poll_timer(std::make_unique()),
bottom_row(bottom_row), system{system_} {
- emulated_controller = system_.HIDCore().GetEmulatedControllerByIndex(player_index);
- emulated_controller->EnableConfiguration();
+ if (player_index == 0) {
+ auto* emulated_controller_p1 =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
+ auto* emulated_controller_hanheld =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ emulated_controller_p1->SaveCurrentConfig();
+ emulated_controller_p1->EnableConfiguration();
+ emulated_controller_hanheld->SaveCurrentConfig();
+ emulated_controller_hanheld->EnableConfiguration();
+ if (emulated_controller_hanheld->IsConnected(true)) {
+ emulated_controller_p1->Disconnect();
+ emulated_controller = emulated_controller_hanheld;
+ } else {
+ emulated_controller = emulated_controller_p1;
+ }
+ } else {
+ emulated_controller = system_.HIDCore().GetEmulatedControllerByIndex(player_index);
+ emulated_controller->SaveCurrentConfig();
+ emulated_controller->EnableConfiguration();
+ }
ui->setupUi(this);
setFocusPolicy(Qt::ClickFocus);
@@ -460,13 +478,36 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
UpdateControllerEnabledButtons();
UpdateControllerButtonNames();
UpdateMotionButtons();
- connect(ui->comboControllerType, qOverload(&QComboBox::currentIndexChanged), [this](int) {
+ connect(ui->comboControllerType, qOverload(&QComboBox::currentIndexChanged), [this, player_index](int) {
UpdateControllerAvailableButtons();
UpdateControllerEnabledButtons();
UpdateControllerButtonNames();
UpdateMotionButtons();
- emulated_controller->SetNpadType(
- GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()));
+ const Core::HID::NpadType type = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
+
+ if (player_index == 0) {
+ auto* emulated_controller_p1 =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
+ auto* emulated_controller_hanheld =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ bool is_connected = emulated_controller->IsConnected(true);
+
+ emulated_controller_p1->SetNpadType(type);
+ emulated_controller_hanheld->SetNpadType(type);
+ if (is_connected) {
+ if (type == Core::HID::NpadType::Handheld) {
+ emulated_controller_p1->Disconnect();
+ emulated_controller_hanheld->Connect();
+ emulated_controller = emulated_controller_hanheld;
+ } else {
+ emulated_controller_hanheld->Disconnect();
+ emulated_controller_p1->Connect();
+ emulated_controller = emulated_controller_p1;
+ }
+ }
+ ui->controllerFrame->SetController(emulated_controller);
+ }
+ emulated_controller->SetNpadType(type);
});
connect(ui->comboDevices, qOverload(&QComboBox::activated), this,
@@ -504,11 +545,35 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
}
ConfigureInputPlayer::~ConfigureInputPlayer() {
- emulated_controller->DisableConfiguration();
+ if (player_index == 0) {
+ auto* emulated_controller_p1 =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
+ auto* emulated_controller_hanheld =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ emulated_controller_p1->DisableConfiguration();
+ emulated_controller_hanheld->DisableConfiguration();
+ } else {
+ emulated_controller->DisableConfiguration();
+ }
};
void ConfigureInputPlayer::ApplyConfiguration() {
+ if (player_index == 0) {
+ auto* emulated_controller_p1 =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
+ auto* emulated_controller_hanheld =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ emulated_controller_p1->DisableConfiguration();
+ emulated_controller_p1->SaveCurrentConfig();
+ emulated_controller_p1->EnableConfiguration();
+ emulated_controller_hanheld->DisableConfiguration();
+ emulated_controller_hanheld->SaveCurrentConfig();
+ emulated_controller_hanheld->EnableConfiguration();
+ return;
+ }
+ emulated_controller->DisableConfiguration();
emulated_controller->SaveCurrentConfig();
+ emulated_controller->EnableConfiguration();
}
void ConfigureInputPlayer::showEvent(QShowEvent* event) {
@@ -535,9 +600,9 @@ void ConfigureInputPlayer::RetranslateUI() {
void ConfigureInputPlayer::LoadConfiguration() {
UpdateUI();
UpdateInputDeviceCombobox();
- const int comboBoxIndex = GetIndexFromControllerType(emulated_controller->GetNpadType());
+ const int comboBoxIndex = GetIndexFromControllerType(emulated_controller->GetNpadType(true));
ui->comboControllerType->setCurrentIndex(comboBoxIndex);
- ui->groupConnectedController->setChecked(emulated_controller->IsConnected());
+ ui->groupConnectedController->setChecked(emulated_controller->IsConnected(true));
}
void ConfigureInputPlayer::ConnectPlayer(bool connected) {
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 446b72e55..3b79b6076 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -145,7 +145,7 @@ void PlayerControlPreview::ControllerUpdate(Core::HID::ControllerTriggerType typ
needs_redraw = true;
break;
case Core::HID::ControllerTriggerType::Type:
- controller_type = controller->GetNpadType();
+ controller_type = controller->GetNpadType(true);
needs_redraw = true;
break;
case Core::HID::ControllerTriggerType::Color:
--
cgit v1.2.3
From 601ac43495904f3f7666d79a800a8b4eda5a8461 Mon Sep 17 00:00:00 2001
From: german77
Date: Tue, 19 Oct 2021 00:12:24 -0500
Subject: core/hid: Only signal when needed
---
src/yuzu/configuration/configure_input_player_widget.cpp | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 3b79b6076..93f7eddc9 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -27,7 +27,9 @@ void PlayerControlPreview::SetController(Core::HID::EmulatedController* controll
is_controller_set = true;
controller = controller_;
Core::HID::ControllerUpdateCallback engine_callback{
- [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); }};
+ .on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); },
+ .is_service = false,
+ };
callback_key = controller->SetCallback(engine_callback);
ControllerUpdate(Core::HID::ControllerTriggerType::All);
}
@@ -810,7 +812,7 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
DrawSymbol(p, center + QPoint(29, -56), Symbol::House, 3.9f);
// Draw battery
- DrawBattery(p, center + QPoint(-30, -165), battery_values[0]);
+ DrawBattery(p, center + QPoint(-30, -160), battery_values[0]);
}
void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) {
@@ -2655,6 +2657,9 @@ void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center, Input::BatteryLevel battery) {
+ if (battery == Input::BatteryLevel::None) {
+ return;
+ }
p.setPen(colors.outline);
p.setBrush(colors.transparent);
p.drawRect(center.x(), center.y(), 56, 20);
@@ -2669,6 +2674,7 @@ void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center, Input::Batte
p.drawRect(center.x() + 42, center.y(), 14, 20);
p.drawRect(center.x() + 28, center.y(), 14, 20);
p.drawRect(center.x() + 14, center.y(), 14, 20);
+ p.drawRect(center.x(), center.y(), 14, 20);
break;
case Input::BatteryLevel::Medium:
p.drawRect(center.x() + 28, center.y(), 14, 20);
@@ -2685,6 +2691,8 @@ void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center, Input::Batte
case Input::BatteryLevel::Empty:
p.drawRect(center.x(), center.y(), 5, 20);
break;
+ default:
+ break;
}
}
--
cgit v1.2.3
From af55dd193533be577d0a3d01f93a4a3a2c27cd5d Mon Sep 17 00:00:00 2001
From: german77
Date: Wed, 20 Oct 2021 17:53:14 -0500
Subject: configuration: Migrate controller settings to emulated controller
---
src/yuzu/configuration/configure_input.cpp | 17 +++++++++++++----
.../configuration/configure_input_player_widget.cpp | 4 ++--
2 files changed, 15 insertions(+), 6 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp
index 67faa8be8..dece27fde 100644
--- a/src/yuzu/configuration/configure_input.cpp
+++ b/src/yuzu/configuration/configure_input.cpp
@@ -211,8 +211,10 @@ void ConfigureInput::RetranslateUI() {
}
void ConfigureInput::LoadConfiguration() {
+ const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+
LoadPlayerControllerIndices();
- UpdateDockedState(Settings::values.players.GetValue()[8].connected);
+ UpdateDockedState(handheld->IsConnected());
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue());
@@ -220,9 +222,16 @@ void ConfigureInput::LoadConfiguration() {
void ConfigureInput::LoadPlayerControllerIndices() {
for (std::size_t i = 0; i < player_connected.size(); ++i) {
- const auto connected = Settings::values.players.GetValue()[i].connected ||
- (i == 0 && Settings::values.players.GetValue()[8].connected);
- player_connected[i]->setChecked(connected);
+ if (i == 0) {
+ auto* handheld =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ if (handheld->IsConnected()) {
+ player_connected[i]->setChecked(true);
+ continue;
+ }
+ }
+ const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(i);
+ player_connected[i]->setChecked(controller->IsConnected());
}
}
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 93f7eddc9..be87204fc 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -104,8 +104,8 @@ void PlayerControlPreview::UpdateColors() {
colors.left = colors.primary;
colors.right = colors.primary;
// Possible alternative to set colors from settings
- // colors.left = QColor(Settings::values.players.GetValue()[player_index].body_color_left);
- // colors.right = QColor(Settings::values.players.GetValue()[player_index].body_color_right);
+ // colors.left = QColor(controller->GetColors().left.body);
+ // colors.right = QColor(controller->GetColors().right.body);
}
void PlayerControlPreview::ResetInputs() {
--
cgit v1.2.3
From 21819da8cd7da60be8f8ba82dc940c2496a5317e Mon Sep 17 00:00:00 2001
From: german77
Date: Fri, 22 Oct 2021 12:34:44 -0500
Subject: yuzu: Fix loading input profiles
---
src/yuzu/configuration/configure_input_player.cpp | 7 +++++++
1 file changed, 7 insertions(+)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 81310a5b3..cd33b5711 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -598,8 +598,15 @@ void ConfigureInputPlayer::RetranslateUI() {
}
void ConfigureInputPlayer::LoadConfiguration() {
+ emulated_controller->ReloadFromSettings();
+
UpdateUI();
UpdateInputDeviceCombobox();
+
+ if (debug) {
+ return;
+ }
+
const int comboBoxIndex = GetIndexFromControllerType(emulated_controller->GetNpadType(true));
ui->comboControllerType->setCurrentIndex(comboBoxIndex);
ui->groupConnectedController->setChecked(emulated_controller->IsConnected(true));
--
cgit v1.2.3
From b564f024f0be5023cf13fb2fca953ea6c1feeeb6 Mon Sep 17 00:00:00 2001
From: german77
Date: Fri, 22 Oct 2021 23:04:06 -0500
Subject: Morph review first wave
---
src/yuzu/configuration/configure_input_player_widget.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index be87204fc..3f179150d 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -28,7 +28,7 @@ void PlayerControlPreview::SetController(Core::HID::EmulatedController* controll
controller = controller_;
Core::HID::ControllerUpdateCallback engine_callback{
.on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); },
- .is_service = false,
+ .is_npad_service = false,
};
callback_key = controller->SetCallback(engine_callback);
ControllerUpdate(Core::HID::ControllerTriggerType::All);
--
cgit v1.2.3
From 464c4d26ac8e7af6302390684445b357e5cda4e4 Mon Sep 17 00:00:00 2001
From: german77
Date: Sun, 24 Oct 2021 11:22:20 -0500
Subject: settings: Fix mouse and keyboard mappings
---
src/yuzu/configuration/configure_input_player.cpp | 147 +++++++++-------------
src/yuzu/configuration/configure_vibration.cpp | 4 +-
2 files changed, 60 insertions(+), 91 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index cd33b5711..416096333 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -478,37 +478,39 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
UpdateControllerEnabledButtons();
UpdateControllerButtonNames();
UpdateMotionButtons();
- connect(ui->comboControllerType, qOverload(&QComboBox::currentIndexChanged), [this, player_index](int) {
- UpdateControllerAvailableButtons();
- UpdateControllerEnabledButtons();
- UpdateControllerButtonNames();
- UpdateMotionButtons();
- const Core::HID::NpadType type = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
-
- if (player_index == 0) {
- auto* emulated_controller_p1 =
- system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
- auto* emulated_controller_hanheld =
- system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
- bool is_connected = emulated_controller->IsConnected(true);
-
- emulated_controller_p1->SetNpadType(type);
- emulated_controller_hanheld->SetNpadType(type);
- if (is_connected) {
- if (type == Core::HID::NpadType::Handheld) {
- emulated_controller_p1->Disconnect();
- emulated_controller_hanheld->Connect();
- emulated_controller = emulated_controller_hanheld;
- } else {
- emulated_controller_hanheld->Disconnect();
- emulated_controller_p1->Connect();
- emulated_controller = emulated_controller_p1;
+ connect(ui->comboControllerType, qOverload(&QComboBox::currentIndexChanged),
+ [this, player_index](int) {
+ UpdateControllerAvailableButtons();
+ UpdateControllerEnabledButtons();
+ UpdateControllerButtonNames();
+ UpdateMotionButtons();
+ const Core::HID::NpadType type =
+ GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
+
+ if (player_index == 0) {
+ auto* emulated_controller_p1 =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
+ auto* emulated_controller_hanheld =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ bool is_connected = emulated_controller->IsConnected(true);
+
+ emulated_controller_p1->SetNpadType(type);
+ emulated_controller_hanheld->SetNpadType(type);
+ if (is_connected) {
+ if (type == Core::HID::NpadType::Handheld) {
+ emulated_controller_p1->Disconnect();
+ emulated_controller_hanheld->Connect();
+ emulated_controller = emulated_controller_hanheld;
+ } else {
+ emulated_controller_hanheld->Disconnect();
+ emulated_controller_p1->Connect();
+ emulated_controller = emulated_controller_p1;
+ }
+ }
+ ui->controllerFrame->SetController(emulated_controller);
}
- }
- ui->controllerFrame->SetController(emulated_controller);
- }
- emulated_controller->SetNpadType(type);
- });
+ emulated_controller->SetNpadType(type);
+ });
connect(ui->comboDevices, qOverload(&QComboBox::activated), this,
&ConfigureInputPlayer::UpdateMappingWithDefaults);
@@ -555,7 +557,7 @@ ConfigureInputPlayer::~ConfigureInputPlayer() {
} else {
emulated_controller->DisableConfiguration();
}
-};
+}
void ConfigureInputPlayer::ApplyConfiguration() {
if (player_index == 0) {
@@ -642,7 +644,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
const auto first_engine = devices[0].Get("engine", "");
const auto first_guid = devices[0].Get("guid", "");
- const auto first_port = devices[0].Get("port", "");
+ const auto first_port = devices[0].Get("port", 0);
if (devices.size() == 1) {
const auto devices_it =
@@ -650,7 +652,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
[first_engine, first_guid, first_port](const Common::ParamPackage param) {
return param.Get("engine", "") == first_engine &&
param.Get("guid", "") == first_guid &&
- param.Get("port", "") == first_port;
+ param.Get("port", 0) == first_port;
});
const int device_index =
devices_it != input_devices.end()
@@ -662,7 +664,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
const auto second_engine = devices[1].Get("engine", "");
const auto second_guid = devices[1].Get("guid", "");
- const auto second_port = devices[1].Get("port", "");
+ const auto second_port = devices[1].Get("port", 0);
const bool is_keyboard_mouse = (first_engine == "keyboard" || first_engine == "mouse") &&
(second_engine == "keyboard" || second_engine == "mouse");
@@ -684,7 +686,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
param.Get("guid2", "") == second_guid) ||
(param.Get("guid", "") == second_guid && param.Get("guid2", "") == first_guid);
return param.Get("engine", "") == first_engine && is_guid_valid &&
- param.Get("port", "") == first_port;
+ param.Get("port", 0) == first_port;
});
const int device_index =
devices_it != input_devices.end()
@@ -1096,8 +1098,8 @@ void ConfigureInputPlayer::UpdateMappingWithDefaults() {
emulated_controller->SetMotionParam(motion_id, {});
}
- // Reset keyboard bindings
- if (ui->comboDevices->currentIndex() == 1) {
+ // Reset keyboard or mouse bindings
+ if (ui->comboDevices->currentIndex() == 1 || ui->comboDevices->currentIndex() == 2) {
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) {
emulated_controller->SetButtonParam(
button_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam(
@@ -1122,63 +1124,30 @@ void ConfigureInputPlayer::UpdateMappingWithDefaults() {
Config::default_motions[motion_id])});
}
- UpdateUI();
- return;
- }
-
- // Reset keyboard with mouse bindings
- if (ui->comboDevices->currentIndex() == 2) {
- for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) {
- emulated_controller->SetButtonParam(
- button_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam(
- Config::default_buttons[button_id])});
- }
-
- Common::ParamPackage left_analog_param{};
- for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
- Common::ParamPackage params{InputCommon::GenerateKeyboardParam(
- Config::default_analogs[Settings::NativeAnalog::LStick][sub_button_id])};
- SetAnalogParam(params, left_analog_param, analog_sub_buttons[sub_button_id]);
- }
- left_analog_param.Set("modifier",
- InputCommon::GenerateKeyboardParam(
- Config::default_stick_mod[Settings::NativeAnalog::LStick]));
- emulated_controller->SetStickParam(Settings::NativeAnalog::LStick, left_analog_param);
-
- Common::ParamPackage right_analog_param{};
- right_analog_param.Set("engine", "mouse");
- right_analog_param.Set("port", 0);
- right_analog_param.Set("axis_x", 0);
- right_analog_param.Set("axis_y", 1);
- emulated_controller->SetStickParam(Settings::NativeAnalog::RStick,
- std::move(right_analog_param));
-
- for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) {
- emulated_controller->SetMotionParam(
- motion_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam(
- Config::default_motions[motion_id])});
+ // If mouse is selected we want to override with mappings from the driver
+ if (ui->comboDevices->currentIndex() == 1) {
+ UpdateUI();
+ return;
}
-
- UpdateUI();
- return;
}
// Reset controller bindings
const auto& device = input_devices[ui->comboDevices->currentIndex()];
- auto button_mapping = input_subsystem->GetButtonMappingForDevice(device);
- auto analog_mapping = input_subsystem->GetAnalogMappingForDevice(device);
- auto motion_mapping = input_subsystem->GetMotionMappingForDevice(device);
- for (std::size_t i = 0; i < button_mapping.size(); ++i) {
- emulated_controller->SetButtonParam(
- i, button_mapping[static_cast(i)]);
+ auto button_mappings = input_subsystem->GetButtonMappingForDevice(device);
+ auto analog_mappings = input_subsystem->GetAnalogMappingForDevice(device);
+ auto motion_mappings = input_subsystem->GetMotionMappingForDevice(device);
+
+ for (const auto& button_mapping : button_mappings) {
+ const std::size_t index = button_mapping.first;
+ emulated_controller->SetButtonParam(index, button_mapping.second);
}
- for (std::size_t i = 0; i < analog_mapping.size(); ++i) {
- emulated_controller->SetStickParam(
- i, analog_mapping[static_cast(i)]);
+ for (const auto& analog_mapping : analog_mappings) {
+ const std::size_t index = analog_mapping.first;
+ emulated_controller->SetStickParam(index, analog_mapping.second);
}
- for (std::size_t i = 0; i < motion_mapping.size(); ++i) {
- emulated_controller->SetMotionParam(
- i, motion_mapping[static_cast(i)]);
+ for (const auto& motion_mapping : motion_mappings) {
+ const std::size_t index = motion_mapping.first;
+ emulated_controller->SetMotionParam(index, motion_mapping.second);
}
UpdateUI();
@@ -1237,7 +1206,7 @@ bool ConfigureInputPlayer::IsInputAcceptable(const Common::ParamPackage& params)
}
// Keyboard/Mouse
- if (ui->comboDevices->currentIndex() == 2) {
+ if (ui->comboDevices->currentIndex() == 1 || ui->comboDevices->currentIndex() == 2) {
return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse";
}
@@ -1245,7 +1214,7 @@ bool ConfigureInputPlayer::IsInputAcceptable(const Common::ParamPackage& params)
return params.Get("engine", "") == current_input_device.Get("engine", "") &&
(params.Get("guid", "") == current_input_device.Get("guid", "") ||
params.Get("guid", "") == current_input_device.Get("guid2", "")) &&
- params.Get("port", "") == current_input_device.Get("port", "");
+ params.Get("port", 0) == current_input_device.Get("port", 0);
}
void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) {
diff --git a/src/yuzu/configuration/configure_vibration.cpp b/src/yuzu/configuration/configure_vibration.cpp
index 46a0f3025..f1ce7205d 100644
--- a/src/yuzu/configuration/configure_vibration.cpp
+++ b/src/yuzu/configuration/configure_vibration.cpp
@@ -97,7 +97,7 @@ void ConfigureVibration::SetVibrationDevices(std::size_t player_index) {
const auto engine = param.Get("engine", "");
const auto guid = param.Get("guid", "");
- const auto port = param.Get("port", "");
+ const auto port = param.Get("port", 0);
if (engine.empty() || engine == "keyboard" || engine == "mouse" || engine == "tas") {
continue;
@@ -105,7 +105,7 @@ void ConfigureVibration::SetVibrationDevices(std::size_t player_index) {
vibration_param_str += fmt::format("engine:{}", engine);
- if (!port.empty()) {
+ if (port != 0) {
vibration_param_str += fmt::format(",port:{}", port);
}
if (!guid.empty()) {
--
cgit v1.2.3
From 064ddacf49aa7155e26add55983b81fdda997077 Mon Sep 17 00:00:00 2001
From: german77
Date: Sun, 24 Oct 2021 23:23:54 -0500
Subject: core/hid: Rework battery mappings
---
src/yuzu/configuration/configure_input_player.cpp | 2 +-
.../configuration/configure_input_player_widget.cpp | 17 ++++++++---------
2 files changed, 9 insertions(+), 10 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 416096333..acb29a6b4 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -630,7 +630,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
return;
}
- const auto devices = emulated_controller->GetMappedDevices();
+ const auto devices = emulated_controller->GetMappedDevices(Core::HID::DeviceIndex::AllDevices);
UpdateInputDevices();
if (devices.empty()) {
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 3f179150d..67e56ed3a 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -356,7 +356,7 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center)
DrawCircle(p, center + QPoint(26, 71), 5);
// Draw battery
- DrawBattery(p, center + QPoint(-170, -140), battery_values[0]);
+ DrawBattery(p, center + QPoint(-170, -140), battery_values[Core::HID::DeviceIndex::LeftIndex]);
}
void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center) {
@@ -482,7 +482,7 @@ void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center
DrawSymbol(p, center + QPoint(-26, 66), Symbol::House, 5);
// Draw battery
- DrawBattery(p, center + QPoint(110, -140), battery_values[1]);
+ DrawBattery(p, center + QPoint(110, -140), battery_values[Core::HID::DeviceIndex::RightIndex]);
}
void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center) {
@@ -618,8 +618,8 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center)
DrawSymbol(p, center + QPoint(50, 60), Symbol::House, 4.2f);
// Draw battery
- DrawBattery(p, center + QPoint(-100, -160), battery_values[0]);
- DrawBattery(p, center + QPoint(40, -160), battery_values[1]);
+ DrawBattery(p, center + QPoint(-100, -160), battery_values[Core::HID::DeviceIndex::LeftIndex]);
+ DrawBattery(p, center + QPoint(40, -160), battery_values[Core::HID::DeviceIndex::RightIndex]);
}
void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF center) {
@@ -720,9 +720,8 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen
DrawSymbol(p, center + QPoint(161, 37), Symbol::House, 2.75f);
// Draw battery
- DrawBattery(p, center + QPoint(-200, 110), battery_values[0]);
- DrawBattery(p, center + QPoint(-30, 110), battery_values[1]);
- DrawBattery(p, center + QPoint(130, 110), battery_values[2]);
+ DrawBattery(p, center + QPoint(-200, 110), battery_values[Core::HID::DeviceIndex::LeftIndex]);
+ DrawBattery(p, center + QPoint(130, 110), battery_values[Core::HID::DeviceIndex::RightIndex]);
}
void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) {
@@ -812,7 +811,7 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
DrawSymbol(p, center + QPoint(29, -56), Symbol::House, 3.9f);
// Draw battery
- DrawBattery(p, center + QPoint(-30, -160), battery_values[0]);
+ DrawBattery(p, center + QPoint(-30, -160), battery_values[Core::HID::DeviceIndex::LeftIndex]);
}
void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) {
@@ -868,7 +867,7 @@ void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) {
DrawCircleButton(p, center + QPoint(0, -44), button_values[Plus], 8);
// Draw battery
- DrawBattery(p, center + QPoint(-30, -165), battery_values[0]);
+ DrawBattery(p, center + QPoint(-30, -165), battery_values[Core::HID::DeviceIndex::LeftIndex]);
}
constexpr std::array symbol_a = {
--
cgit v1.2.3
From 1d71d4b87415b2581e6757f07d29275e02671b7a Mon Sep 17 00:00:00 2001
From: german77
Date: Mon, 25 Oct 2021 12:53:14 -0500
Subject: input_common: Fix UDP uuid
---
src/yuzu/configuration/configure_input_player.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index acb29a6b4..9a1b3575e 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -1178,7 +1178,7 @@ void ConfigureInputPlayer::HandleClick(
}
timeout_timer->start(2500); // Cancel after 2.5 seconds
- poll_timer->start(50); // Check for new inputs every 50ms
+ poll_timer->start(25); // Check for new inputs every 25ms
}
void ConfigureInputPlayer::SetPollingResult(const Common::ParamPackage& params, bool abort) {
@@ -1205,6 +1205,10 @@ bool ConfigureInputPlayer::IsInputAcceptable(const Common::ParamPackage& params)
return true;
}
+ if (params.Has("motion")) {
+ return true;
+ }
+
// Keyboard/Mouse
if (ui->comboDevices->currentIndex() == 1 || ui->comboDevices->currentIndex() == 2) {
return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse";
--
cgit v1.2.3
From c085e54316c5520ed7d58a92a7faa9e896bb6c71 Mon Sep 17 00:00:00 2001
From: german77
Date: Wed, 27 Oct 2021 00:20:28 -0500
Subject: core/hid: Add TAS input
---
src/yuzu/configuration/config.cpp | 2 --
src/yuzu/configuration/configure_tas.cpp | 2 --
src/yuzu/configuration/configure_tas.ui | 9 +--------
3 files changed, 1 insertion(+), 12 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 56af07507..7a748d9c8 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -573,7 +573,6 @@ void Config::ReadControlValues() {
ReadBasicSetting(Settings::values.tas_enable);
ReadBasicSetting(Settings::values.tas_loop);
- ReadBasicSetting(Settings::values.tas_swap_controllers);
ReadBasicSetting(Settings::values.pause_tas_on_load);
ReadGlobalSetting(Settings::values.use_docked_mode);
@@ -1209,7 +1208,6 @@ void Config::SaveControlValues() {
WriteBasicSetting(Settings::values.tas_enable);
WriteBasicSetting(Settings::values.tas_loop);
- WriteBasicSetting(Settings::values.tas_swap_controllers);
WriteBasicSetting(Settings::values.pause_tas_on_load);
qt_config->endGroup();
diff --git a/src/yuzu/configuration/configure_tas.cpp b/src/yuzu/configuration/configure_tas.cpp
index 8e5a4c72d..979a8db61 100644
--- a/src/yuzu/configuration/configure_tas.cpp
+++ b/src/yuzu/configuration/configure_tas.cpp
@@ -32,7 +32,6 @@ void ConfigureTasDialog::LoadConfiguration() {
ui->tas_path_edit->setText(
QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::TASDir)));
ui->tas_enable->setChecked(Settings::values.tas_enable.GetValue());
- ui->tas_control_swap->setChecked(Settings::values.tas_swap_controllers.GetValue());
ui->tas_loop_script->setChecked(Settings::values.tas_loop.GetValue());
ui->tas_pause_on_load->setChecked(Settings::values.pause_tas_on_load.GetValue());
}
@@ -40,7 +39,6 @@ void ConfigureTasDialog::LoadConfiguration() {
void ConfigureTasDialog::ApplyConfiguration() {
Common::FS::SetYuzuPath(Common::FS::YuzuPath::TASDir, ui->tas_path_edit->text().toStdString());
Settings::values.tas_enable.SetValue(ui->tas_enable->isChecked());
- Settings::values.tas_swap_controllers.SetValue(ui->tas_control_swap->isChecked());
Settings::values.tas_loop.SetValue(ui->tas_loop_script->isChecked());
Settings::values.pause_tas_on_load.SetValue(ui->tas_pause_on_load->isChecked());
}
diff --git a/src/yuzu/configuration/configure_tas.ui b/src/yuzu/configuration/configure_tas.ui
index 7d44895c4..cf88a5bf0 100644
--- a/src/yuzu/configuration/configure_tas.ui
+++ b/src/yuzu/configuration/configure_tas.ui
@@ -59,20 +59,13 @@
-
-
-
- Automatic controller profile swapping
-
-
-
- -
Loop script
- -
+
-
false
--
cgit v1.2.3
From 2b1b0c2a30e242b08ec120e09803ec54d5445703 Mon Sep 17 00:00:00 2001
From: german77
Date: Sat, 30 Oct 2021 22:23:10 -0500
Subject: kraken: Address comments from review
start lion review
---
.../configure_input_player_widget.cpp | 105 +++++++++++----------
.../configuration/configure_input_player_widget.h | 81 +++++++++-------
2 files changed, 100 insertions(+), 86 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 67e56ed3a..bb20e9339 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -1945,8 +1945,8 @@ void PlayerControlPreview::DrawRightBody(QPainter& p, const QPointF center) {
}
void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center,
- const Input::ButtonStatus& left_pressed,
- const Input::ButtonStatus& right_pressed) {
+ const Common::Input::ButtonStatus& left_pressed,
+ const Common::Input::ButtonStatus& right_pressed) {
std::array qleft_trigger;
std::array qright_trigger;
std::array qbody_top;
@@ -1984,8 +1984,8 @@ void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center,
- Input::TriggerStatus left_trigger,
- Input::TriggerStatus right_trigger) {
+ Common::Input::TriggerStatus left_trigger,
+ Common::Input::TriggerStatus right_trigger) {
std::array qleft_trigger;
std::array qright_trigger;
@@ -2022,8 +2022,8 @@ void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawHandheldTriggers(QPainter& p, const QPointF center,
- const Input::ButtonStatus& left_pressed,
- const Input::ButtonStatus& right_pressed) {
+ const Common::Input::ButtonStatus& left_pressed,
+ const Common::Input::ButtonStatus& right_pressed) {
std::array qleft_trigger;
std::array qright_trigger;
@@ -2048,8 +2048,8 @@ void PlayerControlPreview::DrawHandheldTriggers(QPainter& p, const QPointF cente
}
void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center,
- const Input::ButtonStatus& left_pressed,
- const Input::ButtonStatus& right_pressed) {
+ const Common::Input::ButtonStatus& left_pressed,
+ const Common::Input::ButtonStatus& right_pressed) {
std::array qleft_trigger;
std::array qright_trigger;
constexpr float size = 1.62f;
@@ -2076,9 +2076,9 @@ void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center,
DrawPolygon(p, qright_trigger);
}
-void PlayerControlPreview::DrawDualTriggersTopView(QPainter& p, const QPointF center,
- const Input::ButtonStatus& left_pressed,
- const Input::ButtonStatus& right_pressed) {
+void PlayerControlPreview::DrawDualTriggersTopView(
+ QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed,
+ const Common::Input::ButtonStatus& right_pressed) {
std::array qleft_trigger;
std::array qright_trigger;
constexpr float size = 0.9f;
@@ -2113,9 +2113,9 @@ void PlayerControlPreview::DrawDualTriggersTopView(QPainter& p, const QPointF ce
DrawSymbol(p, center + QPointF(177, -84), Symbol::R, 1.0f);
}
-void PlayerControlPreview::DrawDualZTriggersTopView(QPainter& p, const QPointF center,
- const Input::ButtonStatus& left_pressed,
- const Input::ButtonStatus& right_pressed) {
+void PlayerControlPreview::DrawDualZTriggersTopView(
+ QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed,
+ const Common::Input::ButtonStatus& right_pressed) {
std::array qleft_trigger;
std::array qright_trigger;
constexpr float size = 0.9f;
@@ -2149,7 +2149,7 @@ void PlayerControlPreview::DrawDualZTriggersTopView(QPainter& p, const QPointF c
}
void PlayerControlPreview::DrawLeftTriggers(QPainter& p, const QPointF center,
- const Input::ButtonStatus& left_pressed) {
+ const Common::Input::ButtonStatus& left_pressed) {
std::array qleft_trigger;
constexpr float size = 1.78f;
constexpr float offset = 311.5f;
@@ -2166,7 +2166,7 @@ void PlayerControlPreview::DrawLeftTriggers(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawLeftZTriggers(QPainter& p, const QPointF center,
- const Input::ButtonStatus& left_pressed) {
+ const Common::Input::ButtonStatus& left_pressed) {
std::array qleft_trigger;
constexpr float size = 1.1115f;
constexpr float offset2 = 335;
@@ -2184,8 +2184,8 @@ void PlayerControlPreview::DrawLeftZTriggers(QPainter& p, const QPointF center,
225 * 16, 44 * 16);
}
-void PlayerControlPreview::DrawLeftTriggersTopView(QPainter& p, const QPointF center,
- const Input::ButtonStatus& left_pressed) {
+void PlayerControlPreview::DrawLeftTriggersTopView(
+ QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed) {
std::array qleft_trigger;
for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) {
@@ -2203,8 +2203,8 @@ void PlayerControlPreview::DrawLeftTriggersTopView(QPainter& p, const QPointF ce
DrawSymbol(p, center + QPointF(-143, -36), Symbol::L, 1.0f);
}
-void PlayerControlPreview::DrawLeftZTriggersTopView(QPainter& p, const QPointF center,
- const Input::ButtonStatus& left_pressed) {
+void PlayerControlPreview::DrawLeftZTriggersTopView(
+ QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed) {
std::array qleft_trigger;
for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) {
@@ -2223,7 +2223,7 @@ void PlayerControlPreview::DrawLeftZTriggersTopView(QPainter& p, const QPointF c
}
void PlayerControlPreview::DrawRightTriggers(QPainter& p, const QPointF center,
- const Input::ButtonStatus& right_pressed) {
+ const Common::Input::ButtonStatus& right_pressed) {
std::array qright_trigger;
constexpr float size = 1.78f;
constexpr float offset = 311.5f;
@@ -2240,7 +2240,7 @@ void PlayerControlPreview::DrawRightTriggers(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawRightZTriggers(QPainter& p, const QPointF center,
- const Input::ButtonStatus& right_pressed) {
+ const Common::Input::ButtonStatus& right_pressed) {
std::array qright_trigger;
constexpr float size = 1.1115f;
constexpr float offset2 = 335;
@@ -2259,8 +2259,8 @@ void PlayerControlPreview::DrawRightZTriggers(QPainter& p, const QPointF center,
271 * 16, 44 * 16);
}
-void PlayerControlPreview::DrawRightTriggersTopView(QPainter& p, const QPointF center,
- const Input::ButtonStatus& right_pressed) {
+void PlayerControlPreview::DrawRightTriggersTopView(
+ QPainter& p, const QPointF center, const Common::Input::ButtonStatus& right_pressed) {
std::array qright_trigger;
for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) {
@@ -2278,8 +2278,8 @@ void PlayerControlPreview::DrawRightTriggersTopView(QPainter& p, const QPointF c
DrawSymbol(p, center + QPointF(137, -36), Symbol::R, 1.0f);
}
-void PlayerControlPreview::DrawRightZTriggersTopView(QPainter& p, const QPointF center,
- const Input::ButtonStatus& right_pressed) {
+void PlayerControlPreview::DrawRightZTriggersTopView(
+ QPainter& p, const QPointF center, const Common::Input::ButtonStatus& right_pressed) {
std::array qright_trigger;
for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) {
@@ -2298,7 +2298,7 @@ void PlayerControlPreview::DrawRightZTriggersTopView(QPainter& p, const QPointF
}
void PlayerControlPreview::DrawJoystick(QPainter& p, const QPointF center, float size,
- const Input::ButtonStatus& pressed) {
+ const Common::Input::ButtonStatus& pressed) {
const float radius1 = 13.0f * size;
const float radius2 = 9.0f * size;
@@ -2317,7 +2317,8 @@ void PlayerControlPreview::DrawJoystick(QPainter& p, const QPointF center, float
}
void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF center, float angle,
- float size, const Input::ButtonStatus& pressed) {
+ float size,
+ const Common::Input::ButtonStatus& pressed) {
QVector joystick;
joystick.reserve(static_cast(left_joystick_sideview.size() / 2));
@@ -2342,7 +2343,7 @@ void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF cente
void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, const QPointF offset,
float offset_scalar,
- const Input::ButtonStatus& pressed) {
+ const Common::Input::ButtonStatus& pressed) {
const float radius1 = 24.0f;
const float radius2 = 17.0f;
@@ -2377,7 +2378,7 @@ void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, co
}
void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center,
- const Input::ButtonStatus& pressed) {
+ const Common::Input::ButtonStatus& pressed) {
// Outer circle
p.setPen(colors.outline);
p.setBrush(pressed.value ? colors.highlight : colors.button);
@@ -2414,8 +2415,8 @@ void PlayerControlPreview::DrawRawJoystick(QPainter& p, QPointF center_left, QPo
}
}
-void PlayerControlPreview::DrawJoystickProperties(QPainter& p, const QPointF center,
- const Input::AnalogProperties& properties) {
+void PlayerControlPreview::DrawJoystickProperties(
+ QPainter& p, const QPointF center, const Common::Input::AnalogProperties& properties) {
constexpr float size = 45.0f;
const float range = size * properties.range;
const float deadzone = size * properties.deadzone;
@@ -2435,7 +2436,7 @@ void PlayerControlPreview::DrawJoystickProperties(QPainter& p, const QPointF cen
}
void PlayerControlPreview::DrawJoystickDot(QPainter& p, const QPointF center,
- const Input::StickStatus& stick, bool raw) {
+ const Common::Input::StickStatus& stick, bool raw) {
constexpr float size = 45.0f;
const float range = size * stick.x.properties.range;
@@ -2450,7 +2451,7 @@ void PlayerControlPreview::DrawJoystickDot(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center,
- const Input::ButtonStatus& pressed, float width,
+ const Common::Input::ButtonStatus& pressed, float width,
float height, Direction direction, float radius) {
p.setBrush(button_color);
if (pressed.value) {
@@ -2476,13 +2477,15 @@ void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center,
p.drawRoundedRect(rect, radius, radius);
}
void PlayerControlPreview::DrawMinusButton(QPainter& p, const QPointF center,
- const Input::ButtonStatus& pressed, int button_size) {
+ const Common::Input::ButtonStatus& pressed,
+ int button_size) {
p.setPen(colors.outline);
p.setBrush(pressed.value ? colors.highlight : colors.button);
DrawRectangle(p, center, button_size, button_size / 3.0f);
}
void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center,
- const Input::ButtonStatus& pressed, int button_size) {
+ const Common::Input::ButtonStatus& pressed,
+ int button_size) {
// Draw outer line
p.setPen(colors.outline);
p.setBrush(pressed.value ? colors.highlight : colors.button);
@@ -2499,7 +2502,7 @@ void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawGCButtonX(QPainter& p, const QPointF center,
- const Input::ButtonStatus& pressed) {
+ const Common::Input::ButtonStatus& pressed) {
std::array button_x;
for (std::size_t point = 0; point < gc_button_x.size() / 2; ++point) {
@@ -2512,7 +2515,7 @@ void PlayerControlPreview::DrawGCButtonX(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawGCButtonY(QPainter& p, const QPointF center,
- const Input::ButtonStatus& pressed) {
+ const Common::Input::ButtonStatus& pressed) {
std::array button_x;
for (std::size_t point = 0; point < gc_button_y.size() / 2; ++point) {
@@ -2525,7 +2528,7 @@ void PlayerControlPreview::DrawGCButtonY(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawGCButtonZ(QPainter& p, const QPointF center,
- const Input::ButtonStatus& pressed) {
+ const Common::Input::ButtonStatus& pressed) {
std::array button_x;
for (std::size_t point = 0; point < gc_button_z.size() / 2; ++point) {
@@ -2539,7 +2542,8 @@ void PlayerControlPreview::DrawGCButtonZ(QPainter& p, const QPointF center,
}
void PlayerControlPreview::DrawCircleButton(QPainter& p, const QPointF center,
- const Input::ButtonStatus& pressed, float button_size) {
+ const Common::Input::ButtonStatus& pressed,
+ float button_size) {
p.setBrush(button_color);
if (pressed.value) {
p.setBrush(colors.highlight);
@@ -2571,7 +2575,7 @@ void PlayerControlPreview::DrawArrowButtonOutline(QPainter& p, const QPointF cen
void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
const Direction direction,
- const Input::ButtonStatus& pressed, float size) {
+ const Common::Input::ButtonStatus& pressed, float size) {
std::array arrow_button;
QPoint offset;
@@ -2628,7 +2632,7 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center,
const Direction direction,
- const Input::ButtonStatus& pressed) {
+ const Common::Input::ButtonStatus& pressed) {
std::array qtrigger_button;
for (std::size_t point = 0; point < trigger_button.size() / 2; ++point) {
@@ -2655,8 +2659,9 @@ void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center,
DrawPolygon(p, qtrigger_button);
}
-void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center, Input::BatteryLevel battery) {
- if (battery == Input::BatteryLevel::None) {
+void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center,
+ Common::Input::BatteryLevel battery) {
+ if (battery == Common::Input::BatteryLevel::None) {
return;
}
p.setPen(colors.outline);
@@ -2665,29 +2670,29 @@ void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center, Input::Batte
p.drawRect(center.x() + 56, center.y() + 6, 3, 8);
p.setBrush(colors.deadzone);
switch (battery) {
- case Input::BatteryLevel::Charging:
+ case Common::Input::BatteryLevel::Charging:
p.setBrush(colors.indicator2);
p.drawText(center + QPoint(2, 14), tr("Charging"));
break;
- case Input::BatteryLevel::Full:
+ case Common::Input::BatteryLevel::Full:
p.drawRect(center.x() + 42, center.y(), 14, 20);
p.drawRect(center.x() + 28, center.y(), 14, 20);
p.drawRect(center.x() + 14, center.y(), 14, 20);
p.drawRect(center.x(), center.y(), 14, 20);
break;
- case Input::BatteryLevel::Medium:
+ case Common::Input::BatteryLevel::Medium:
p.drawRect(center.x() + 28, center.y(), 14, 20);
p.drawRect(center.x() + 14, center.y(), 14, 20);
p.drawRect(center.x(), center.y(), 14, 20);
break;
- case Input::BatteryLevel::Low:
+ case Common::Input::BatteryLevel::Low:
p.drawRect(center.x() + 14, center.y(), 14, 20);
p.drawRect(center.x(), center.y(), 14, 20);
break;
- case Input::BatteryLevel::Critical:
+ case Common::Input::BatteryLevel::Critical:
p.drawRect(center.x(), center.y(), 14, 20);
break;
- case Input::BatteryLevel::Empty:
+ case Common::Input::BatteryLevel::Empty:
p.drawRect(center.x(), center.y(), 5, 20);
break;
default:
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index 333c3fc56..430e4f4f4 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -115,66 +115,75 @@ private:
void DrawGCBody(QPainter& p, QPointF center);
// Draw triggers functions
- void DrawProTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed,
- const Input::ButtonStatus& right_pressed);
- void DrawGCTriggers(QPainter& p, QPointF center, Input::TriggerStatus left_trigger,
- Input::TriggerStatus right_trigger);
- void DrawHandheldTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed,
- const Input::ButtonStatus& right_pressed);
- void DrawDualTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed,
- const Input::ButtonStatus& right_pressed);
+ void DrawProTriggers(QPainter& p, QPointF center,
+ const Common::Input::ButtonStatus& left_pressed,
+ const Common::Input::ButtonStatus& right_pressed);
+ void DrawGCTriggers(QPainter& p, QPointF center, Common::Input::TriggerStatus left_trigger,
+ Common::Input::TriggerStatus right_trigger);
+ void DrawHandheldTriggers(QPainter& p, QPointF center,
+ const Common::Input::ButtonStatus& left_pressed,
+ const Common::Input::ButtonStatus& right_pressed);
+ void DrawDualTriggers(QPainter& p, QPointF center,
+ const Common::Input::ButtonStatus& left_pressed,
+ const Common::Input::ButtonStatus& right_pressed);
void DrawDualTriggersTopView(QPainter& p, QPointF center,
- const Input::ButtonStatus& left_pressed,
- const Input::ButtonStatus& right_pressed);
+ const Common::Input::ButtonStatus& left_pressed,
+ const Common::Input::ButtonStatus& right_pressed);
void DrawDualZTriggersTopView(QPainter& p, QPointF center,
- const Input::ButtonStatus& left_pressed,
- const Input::ButtonStatus& right_pressed);
- void DrawLeftTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed);
- void DrawLeftZTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed);
+ const Common::Input::ButtonStatus& left_pressed,
+ const Common::Input::ButtonStatus& right_pressed);
+ void DrawLeftTriggers(QPainter& p, QPointF center,
+ const Common::Input::ButtonStatus& left_pressed);
+ void DrawLeftZTriggers(QPainter& p, QPointF center,
+ const Common::Input::ButtonStatus& left_pressed);
void DrawLeftTriggersTopView(QPainter& p, QPointF center,
- const Input::ButtonStatus& left_pressed);
+ const Common::Input::ButtonStatus& left_pressed);
void DrawLeftZTriggersTopView(QPainter& p, QPointF center,
- const Input::ButtonStatus& left_pressed);
- void DrawRightTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& right_pressed);
- void DrawRightZTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& right_pressed);
+ const Common::Input::ButtonStatus& left_pressed);
+ void DrawRightTriggers(QPainter& p, QPointF center,
+ const Common::Input::ButtonStatus& right_pressed);
+ void DrawRightZTriggers(QPainter& p, QPointF center,
+ const Common::Input::ButtonStatus& right_pressed);
void DrawRightTriggersTopView(QPainter& p, QPointF center,
- const Input::ButtonStatus& right_pressed);
+ const Common::Input::ButtonStatus& right_pressed);
void DrawRightZTriggersTopView(QPainter& p, QPointF center,
- const Input::ButtonStatus& right_pressed);
+ const Common::Input::ButtonStatus& right_pressed);
// Draw joystick functions
- void DrawJoystick(QPainter& p, QPointF center, float size, const Input::ButtonStatus& pressed);
+ void DrawJoystick(QPainter& p, QPointF center, float size,
+ const Common::Input::ButtonStatus& pressed);
void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size,
- const Input::ButtonStatus& pressed);
+ const Common::Input::ButtonStatus& pressed);
void DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right);
void DrawJoystickProperties(QPainter& p, QPointF center,
- const Input::AnalogProperties& properties);
- void DrawJoystickDot(QPainter& p, QPointF center, const Input::StickStatus& stick, bool raw);
+ const Common::Input::AnalogProperties& properties);
+ void DrawJoystickDot(QPainter& p, QPointF center, const Common::Input::StickStatus& stick,
+ bool raw);
void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar,
- const Input::ButtonStatus& pressed);
- void DrawGCJoystick(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
+ const Common::Input::ButtonStatus& pressed);
+ void DrawGCJoystick(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed);
// Draw button functions
- void DrawCircleButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
+ void DrawCircleButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed,
float button_size);
- void DrawRoundButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
+ void DrawRoundButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed,
float width, float height, Direction direction = Direction::None,
float radius = 2);
- void DrawMinusButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
+ void DrawMinusButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed,
int button_size);
- void DrawPlusButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed,
+ void DrawPlusButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed,
int button_size);
- void DrawGCButtonX(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
- void DrawGCButtonY(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
- void DrawGCButtonZ(QPainter& p, QPointF center, const Input::ButtonStatus& pressed);
+ void DrawGCButtonX(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed);
+ void DrawGCButtonY(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed);
+ void DrawGCButtonZ(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed);
void DrawArrowButtonOutline(QPainter& p, const QPointF center, float size = 1.0f);
void DrawArrowButton(QPainter& p, QPointF center, Direction direction,
- const Input::ButtonStatus& pressed, float size = 1.0f);
+ const Common::Input::ButtonStatus& pressed, float size = 1.0f);
void DrawTriggerButton(QPainter& p, QPointF center, Direction direction,
- const Input::ButtonStatus& pressed);
+ const Common::Input::ButtonStatus& pressed);
// Draw battery functions
- void DrawBattery(QPainter& p, QPointF center, Input::BatteryLevel battery);
+ void DrawBattery(QPainter& p, QPointF center, Common::Input::BatteryLevel battery);
// Draw icon functions
void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size);
--
cgit v1.2.3
From 730f07830247cfcdc551c253d30c6717fc16316c Mon Sep 17 00:00:00 2001
From: german77
Date: Sun, 31 Oct 2021 10:41:44 -0500
Subject: settings: Fix Debug controller type options
---
src/yuzu/configuration/configure_input_player.cpp | 2 --
src/yuzu/configuration/configure_input_player.ui | 25 ----------------------
.../configure_input_player_widget.cpp | 20 +++++++++--------
3 files changed, 11 insertions(+), 36 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 9a1b3575e..8d6289d8e 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -38,8 +38,6 @@ const std::array
namespace {
-constexpr std::size_t HANDHELD_INDEX = 8;
-
QString GetKeyName(int key_code) {
switch (key_code) {
case Qt::Key_Shift:
diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui
index 14ca02fd8..958a89229 100644
--- a/src/yuzu/configuration/configure_input_player.ui
+++ b/src/yuzu/configuration/configure_input_player.ui
@@ -89,31 +89,6 @@
21
-
-
-
- Pro Controller
-
-
- -
-
- Dual Joycons
-
-
- -
-
- Left Joycon
-
-
- -
-
- Right Joycon
-
-
- -
-
- Handheld
-
-
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index bb20e9339..99c4f13c3 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -118,7 +118,7 @@ void PlayerControlPreview::ResetInputs() {
});
trigger_values.fill({
.analog = {.value = 0, .properties = {0, 1, 0}},
- .pressed = false,
+ .pressed = {.value = false},
});
update();
}
@@ -2001,11 +2001,11 @@ void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center,
// Left trigger
p.setPen(colors.outline);
- p.setBrush(left_trigger.pressed ? colors.highlight : colors.button);
+ p.setBrush(left_trigger.pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
// Right trigger
- p.setBrush(right_trigger.pressed ? colors.highlight : colors.button);
+ p.setBrush(right_trigger.pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
// Draw L text
@@ -2587,15 +2587,17 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
case Direction::Up:
arrow_button[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size);
break;
- case Direction::Left:
- arrow_button[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size);
- break;
case Direction::Right:
arrow_button[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size);
break;
case Direction::Down:
arrow_button[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size);
break;
+ case Direction::Left:
+ // Compiler doesn't optimize this correctly
+ arrow_button[point] = center + QPointF(up_arrow_button[point * 2 + 1] * size,
+ up_arrow_button[point * 2 + 0] * size);
+ break;
case Direction::None:
break;
}
@@ -2610,15 +2612,15 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
case Direction::Up:
offset = QPoint(0, -20 * size);
break;
- case Direction::Left:
- offset = QPoint(-20 * size, 0);
- break;
case Direction::Right:
offset = QPoint(20 * size, 0);
break;
case Direction::Down:
offset = QPoint(0, 20 * size);
break;
+ case Direction::Left:
+ offset = QPoint(-20 * size, 0);
+ break;
case Direction::None:
offset = QPoint(0, 0);
break;
--
cgit v1.2.3
From 77fa4d4bf60526826ef8b53ee3870f7d2a761976 Mon Sep 17 00:00:00 2001
From: german77
Date: Mon, 1 Nov 2021 14:17:53 -0600
Subject: second commit lion review
---
src/yuzu/configuration/configure_input_player_widget.cpp | 5 ++---
src/yuzu/configuration/configure_input_player_widget.h | 1 +
2 files changed, 3 insertions(+), 3 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 99c4f13c3..7e71a0f58 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -2594,9 +2594,8 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
arrow_button[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size);
break;
case Direction::Left:
- // Compiler doesn't optimize this correctly
- arrow_button[point] = center + QPointF(up_arrow_button[point * 2 + 1] * size,
- up_arrow_button[point * 2 + 0] * size);
+ // Compiler doesn't optimize this correctly check why
+ arrow_button[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size);
break;
case Direction::None:
break;
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index 430e4f4f4..acc53a9e3 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -9,6 +9,7 @@
#include
#include "common/input.h"
#include "common/settings.h"
+#include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h"
#include "core/hid/hid_types.h"
--
cgit v1.2.3
From 84c58666a4dbb6d46e132514e4d91437fb689fa0 Mon Sep 17 00:00:00 2001
From: german77
Date: Wed, 3 Nov 2021 22:35:45 -0600
Subject: config: Cleanup and documentation
---
src/yuzu/configuration/config.cpp | 4 --
src/yuzu/configuration/configure_motion_touch.cpp | 8 +--
src/yuzu/configuration/configure_motion_touch.ui | 70 +++--------------------
3 files changed, 8 insertions(+), 74 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 7a748d9c8..7669fe474 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -623,9 +623,7 @@ void Config::ReadMotionTouchValues() {
}
qt_config->endArray();
- ReadBasicSetting(Settings::values.motion_device);
ReadBasicSetting(Settings::values.touch_device);
- ReadBasicSetting(Settings::values.use_touch_from_button);
ReadBasicSetting(Settings::values.touch_from_button_map_index);
Settings::values.touch_from_button_map_index = std::clamp(
Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1);
@@ -1131,9 +1129,7 @@ void Config::SaveTouchscreenValues() {
}
void Config::SaveMotionTouchValues() {
- WriteBasicSetting(Settings::values.motion_device);
WriteBasicSetting(Settings::values.touch_device);
- WriteBasicSetting(Settings::values.use_touch_from_button);
WriteBasicSetting(Settings::values.touch_from_button_map_index);
WriteBasicSetting(Settings::values.udp_input_servers);
diff --git a/src/yuzu/configuration/configure_motion_touch.cpp b/src/yuzu/configuration/configure_motion_touch.cpp
index 9fd1a919f..8539a5c8b 100644
--- a/src/yuzu/configuration/configure_motion_touch.cpp
+++ b/src/yuzu/configuration/configure_motion_touch.cpp
@@ -93,6 +93,7 @@ ConfigureMotionTouch::ConfigureMotionTouch(QWidget* parent,
"using-a-controller-or-android-phone-for-motion-or-touch-input'>Learn More"));
+ setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
SetConfiguration();
UpdateUiDisplay();
ConnectEvents();
@@ -101,17 +102,14 @@ ConfigureMotionTouch::ConfigureMotionTouch(QWidget* parent,
ConfigureMotionTouch::~ConfigureMotionTouch() = default;
void ConfigureMotionTouch::SetConfiguration() {
- const Common::ParamPackage motion_param(Settings::values.motion_device.GetValue());
const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue());
- ui->touch_from_button_checkbox->setChecked(Settings::values.use_touch_from_button.GetValue());
touch_from_button_maps = Settings::values.touch_from_button_maps;
for (const auto& touch_map : touch_from_button_maps) {
ui->touch_from_button_map->addItem(QString::fromStdString(touch_map.name));
}
ui->touch_from_button_map->setCurrentIndex(
Settings::values.touch_from_button_map_index.GetValue());
- ui->motion_sensitivity->setValue(motion_param.Get("sensitivity", 0.01f));
min_x = touch_param.Get("min_x", 100);
min_y = touch_param.Get("min_y", 50);
@@ -139,9 +137,6 @@ void ConfigureMotionTouch::SetConfiguration() {
void ConfigureMotionTouch::UpdateUiDisplay() {
const QString cemuhook_udp = QStringLiteral("cemuhookudp");
- ui->motion_sensitivity_label->setVisible(true);
- ui->motion_sensitivity->setVisible(true);
-
ui->touch_calibration->setVisible(true);
ui->touch_calibration_config->setVisible(true);
ui->touch_calibration_label->setVisible(true);
@@ -312,7 +307,6 @@ void ConfigureMotionTouch::ApplyConfiguration() {
touch_param.Set("max_y", max_y);
Settings::values.touch_device = touch_param.Serialize();
- Settings::values.use_touch_from_button = ui->touch_from_button_checkbox->isChecked();
Settings::values.touch_from_button_map_index = ui->touch_from_button_map->currentIndex();
Settings::values.touch_from_button_maps = touch_from_button_maps;
Settings::values.udp_input_servers = GetUDPServerString();
diff --git a/src/yuzu/configuration/configure_motion_touch.ui b/src/yuzu/configuration/configure_motion_touch.ui
index 1e35ea946..c75a84ae4 100644
--- a/src/yuzu/configuration/configure_motion_touch.ui
+++ b/src/yuzu/configuration/configure_motion_touch.ui
@@ -2,14 +2,6 @@
ConfigureMotionTouch
-
-
- 0
- 0
- 500
- 482
-
-
Configure Motion / Touch
@@ -17,48 +9,6 @@
- -
-
-
- Mouse Motion
-
-
-
-
-
-
-
-
-
- Sensitivity:
-
-
-
- -
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
- 4
-
-
- 0.010000000000000
-
-
- 10.000000000000000
-
-
- 0.001000000000000
-
-
- 0.010000000000000
-
-
-
-
-
-
-
-
-
@@ -101,19 +51,13 @@
-
-
-
-
-
-
- 0
- 0
-
-
-
- Use button mapping:
-
-
-
+ -
+
+
+ Touch from button profile:
+
+
+
-
--
cgit v1.2.3
From 5d0f3540c4b085103afa27d6120ea29e0324a5a2 Mon Sep 17 00:00:00 2001
From: german77
Date: Thu, 4 Nov 2021 12:08:54 -0600
Subject: core/hid: Rename NpadType to NpadStyleIndex
---
src/yuzu/configuration/configure_input_player.cpp | 87 +++++++++++-----------
src/yuzu/configuration/configure_input_player.h | 8 +-
.../configure_input_player_widget.cpp | 18 ++---
.../configuration/configure_input_player_widget.h | 2 +-
4 files changed, 58 insertions(+), 57 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 8d6289d8e..95a9b8614 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -455,7 +455,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
connect(ui->comboControllerType, qOverload(&QComboBox::currentIndexChanged),
[this](int index) {
emit HandheldStateChanged(GetControllerTypeFromIndex(index) ==
- Core::HID::NpadType::Handheld);
+ Core::HID::NpadStyleIndex::Handheld);
});
}
@@ -482,7 +482,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
UpdateControllerEnabledButtons();
UpdateControllerButtonNames();
UpdateMotionButtons();
- const Core::HID::NpadType type =
+ const Core::HID::NpadStyleIndex type =
GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
if (player_index == 0) {
@@ -492,10 +492,10 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
bool is_connected = emulated_controller->IsConnected(true);
- emulated_controller_p1->SetNpadType(type);
- emulated_controller_hanheld->SetNpadType(type);
+ emulated_controller_p1->SetNpadStyleIndex(type);
+ emulated_controller_hanheld->SetNpadStyleIndex(type);
if (is_connected) {
- if (type == Core::HID::NpadType::Handheld) {
+ if (type == Core::HID::NpadStyleIndex::Handheld) {
emulated_controller_p1->Disconnect();
emulated_controller_hanheld->Connect();
emulated_controller = emulated_controller_hanheld;
@@ -507,7 +507,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
}
ui->controllerFrame->SetController(emulated_controller);
}
- emulated_controller->SetNpadType(type);
+ emulated_controller->SetNpadStyleIndex(type);
});
connect(ui->comboDevices, qOverload(&QComboBox::activated), this,
@@ -607,7 +607,8 @@ void ConfigureInputPlayer::LoadConfiguration() {
return;
}
- const int comboBoxIndex = GetIndexFromControllerType(emulated_controller->GetNpadType(true));
+ const int comboBoxIndex =
+ GetIndexFromControllerType(emulated_controller->GetNpadStyleIndex(true));
ui->comboControllerType->setCurrentIndex(comboBoxIndex);
ui->groupConnectedController->setChecked(emulated_controller->IsConnected(true));
}
@@ -810,37 +811,37 @@ void ConfigureInputPlayer::SetConnectableControllers() {
if (enable_all || npad_style_set.fullkey == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadType::ProController);
+ Core::HID::NpadStyleIndex::ProController);
ui->comboControllerType->addItem(tr("Pro Controller"));
}
if (enable_all || npad_style_set.joycon_dual == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadType::JoyconDual);
+ Core::HID::NpadStyleIndex::JoyconDual);
ui->comboControllerType->addItem(tr("Dual Joycons"));
}
if (enable_all || npad_style_set.joycon_left == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadType::JoyconLeft);
+ Core::HID::NpadStyleIndex::JoyconLeft);
ui->comboControllerType->addItem(tr("Left Joycon"));
}
if (enable_all || npad_style_set.joycon_right == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadType::JoyconRight);
+ Core::HID::NpadStyleIndex::JoyconRight);
ui->comboControllerType->addItem(tr("Right Joycon"));
}
if (player_index == 0 && (enable_all || npad_style_set.handheld == 1)) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadType::Handheld);
+ Core::HID::NpadStyleIndex::Handheld);
ui->comboControllerType->addItem(tr("Handheld"));
}
if (enable_all || npad_style_set.gamecube == 1) {
index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadType::GameCube);
+ Core::HID::NpadStyleIndex::GameCube);
ui->comboControllerType->addItem(tr("GameCube Controller"));
}
};
@@ -853,19 +854,19 @@ void ConfigureInputPlayer::SetConnectableControllers() {
add_controllers(false, system.HIDCore().GetSupportedStyleTag());
}
-Core::HID::NpadType ConfigureInputPlayer::GetControllerTypeFromIndex(int index) const {
+Core::HID::NpadStyleIndex ConfigureInputPlayer::GetControllerTypeFromIndex(int index) const {
const auto it =
std::find_if(index_controller_type_pairs.begin(), index_controller_type_pairs.end(),
[index](const auto& pair) { return pair.first == index; });
if (it == index_controller_type_pairs.end()) {
- return Core::HID::NpadType::ProController;
+ return Core::HID::NpadStyleIndex::ProController;
}
return it->second;
}
-int ConfigureInputPlayer::GetIndexFromControllerType(Core::HID::NpadType type) const {
+int ConfigureInputPlayer::GetIndexFromControllerType(Core::HID::NpadStyleIndex type) const {
const auto it =
std::find_if(index_controller_type_pairs.begin(), index_controller_type_pairs.end(),
[type](const auto& pair) { return pair.second == type; });
@@ -888,7 +889,7 @@ void ConfigureInputPlayer::UpdateInputDevices() {
void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
if (debug) {
- layout = Core::HID::NpadType::ProController;
+ layout = Core::HID::NpadStyleIndex::ProController;
}
// List of all the widgets that will be hidden by any of the following layouts that need
@@ -913,15 +914,15 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
std::vector layout_hidden;
switch (layout) {
- case Core::HID::NpadType::ProController:
- case Core::HID::NpadType::JoyconDual:
- case Core::HID::NpadType::Handheld:
+ case Core::HID::NpadStyleIndex::ProController:
+ case Core::HID::NpadStyleIndex::JoyconDual:
+ case Core::HID::NpadStyleIndex::Handheld:
layout_hidden = {
ui->buttonShoulderButtonsSLSR,
ui->horizontalSpacerShoulderButtonsWidget2,
};
break;
- case Core::HID::NpadType::JoyconLeft:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
layout_hidden = {
ui->horizontalSpacerShoulderButtonsWidget2,
ui->buttonShoulderButtonsRight,
@@ -929,7 +930,7 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
ui->bottomRight,
};
break;
- case Core::HID::NpadType::JoyconRight:
+ case Core::HID::NpadStyleIndex::JoyconRight:
layout_hidden = {
ui->horizontalSpacerShoulderButtonsWidget,
ui->buttonShoulderButtonsLeft,
@@ -937,7 +938,7 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
ui->bottomLeft,
};
break;
- case Core::HID::NpadType::GameCube:
+ case Core::HID::NpadStyleIndex::GameCube:
layout_hidden = {
ui->buttonShoulderButtonsSLSR,
ui->horizontalSpacerShoulderButtonsWidget2,
@@ -957,7 +958,7 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
void ConfigureInputPlayer::UpdateControllerEnabledButtons() {
auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
if (debug) {
- layout = Core::HID::NpadType::ProController;
+ layout = Core::HID::NpadStyleIndex::ProController;
}
// List of all the widgets that will be disabled by any of the following layouts that need
@@ -974,13 +975,13 @@ void ConfigureInputPlayer::UpdateControllerEnabledButtons() {
std::vector layout_disable;
switch (layout) {
- case Core::HID::NpadType::ProController:
- case Core::HID::NpadType::JoyconDual:
- case Core::HID::NpadType::Handheld:
- case Core::HID::NpadType::JoyconLeft:
- case Core::HID::NpadType::JoyconRight:
+ case Core::HID::NpadStyleIndex::ProController:
+ case Core::HID::NpadStyleIndex::JoyconDual:
+ case Core::HID::NpadStyleIndex::Handheld:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
+ case Core::HID::NpadStyleIndex::JoyconRight:
break;
- case Core::HID::NpadType::GameCube:
+ case Core::HID::NpadStyleIndex::GameCube:
layout_disable = {
ui->buttonHome,
ui->buttonLStickPressedGroup,
@@ -1007,24 +1008,24 @@ void ConfigureInputPlayer::UpdateMotionButtons() {
// Show/hide the "Motion 1/2" groupboxes depending on the currently selected controller.
switch (GetControllerTypeFromIndex(ui->comboControllerType->currentIndex())) {
- case Core::HID::NpadType::ProController:
- case Core::HID::NpadType::JoyconLeft:
- case Core::HID::NpadType::Handheld:
+ case Core::HID::NpadStyleIndex::ProController:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
+ case Core::HID::NpadStyleIndex::Handheld:
// Show "Motion 1" and hide "Motion 2".
ui->buttonMotionLeftGroup->show();
ui->buttonMotionRightGroup->hide();
break;
- case Core::HID::NpadType::JoyconRight:
+ case Core::HID::NpadStyleIndex::JoyconRight:
// Show "Motion 2" and hide "Motion 1".
ui->buttonMotionLeftGroup->hide();
ui->buttonMotionRightGroup->show();
break;
- case Core::HID::NpadType::GameCube:
+ case Core::HID::NpadStyleIndex::GameCube:
// Hide both "Motion 1/2".
ui->buttonMotionLeftGroup->hide();
ui->buttonMotionRightGroup->hide();
break;
- case Core::HID::NpadType::JoyconDual:
+ case Core::HID::NpadStyleIndex::JoyconDual:
default:
// Show both "Motion 1/2".
ui->buttonMotionLeftGroup->show();
@@ -1036,15 +1037,15 @@ void ConfigureInputPlayer::UpdateMotionButtons() {
void ConfigureInputPlayer::UpdateControllerButtonNames() {
auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
if (debug) {
- layout = Core::HID::NpadType::ProController;
+ layout = Core::HID::NpadStyleIndex::ProController;
}
switch (layout) {
- case Core::HID::NpadType::ProController:
- case Core::HID::NpadType::JoyconDual:
- case Core::HID::NpadType::Handheld:
- case Core::HID::NpadType::JoyconLeft:
- case Core::HID::NpadType::JoyconRight:
+ case Core::HID::NpadStyleIndex::ProController:
+ case Core::HID::NpadStyleIndex::JoyconDual:
+ case Core::HID::NpadStyleIndex::Handheld:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
+ case Core::HID::NpadStyleIndex::JoyconRight:
ui->buttonMiscButtonsPlusGroup->setTitle(tr("Plus"));
ui->buttonShoulderButtonsButtonZLGroup->setTitle(tr("ZL"));
ui->buttonShoulderButtonsZRGroup->setTitle(tr("ZR"));
@@ -1052,7 +1053,7 @@ void ConfigureInputPlayer::UpdateControllerButtonNames() {
ui->LStick->setTitle(tr("Left Stick"));
ui->RStick->setTitle(tr("Right Stick"));
break;
- case Core::HID::NpadType::GameCube:
+ case Core::HID::NpadStyleIndex::GameCube:
ui->buttonMiscButtonsPlusGroup->setTitle(tr("Start / Pause"));
ui->buttonShoulderButtonsButtonZLGroup->setTitle(tr("L"));
ui->buttonShoulderButtonsZRGroup->setTitle(tr("R"));
diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h
index 02d6920f1..7bff4b196 100644
--- a/src/yuzu/configuration/configure_input_player.h
+++ b/src/yuzu/configuration/configure_input_player.h
@@ -51,7 +51,7 @@ class System;
namespace Core::HID {
class EmulatedController;
-enum class NpadType : u8;
+enum class NpadStyleIndex : u8;
} // namespace Core::HID
class ConfigureInputPlayer : public QWidget {
@@ -134,10 +134,10 @@ private:
void SetConnectableControllers();
/// Gets the Controller Type for a given controller combobox index.
- Core::HID::NpadType GetControllerTypeFromIndex(int index) const;
+ Core::HID::NpadStyleIndex GetControllerTypeFromIndex(int index) const;
/// Gets the controller combobox index for a given Controller Type.
- int GetIndexFromControllerType(Core::HID::NpadType type) const;
+ int GetIndexFromControllerType(Core::HID::NpadStyleIndex type) const;
/// Update the available input devices.
void UpdateInputDevices();
@@ -182,7 +182,7 @@ private:
std::unique_ptr poll_timer;
/// Stores a pair of "Connected Controllers" combobox index and Controller Type enum.
- std::vector> index_controller_type_pairs;
+ std::vector> index_controller_type_pairs;
static constexpr int PLAYER_COUNT = 8;
std::array player_connected_checkbox;
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 7e71a0f58..e63c25e70 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -147,7 +147,7 @@ void PlayerControlPreview::ControllerUpdate(Core::HID::ControllerTriggerType typ
needs_redraw = true;
break;
case Core::HID::ControllerTriggerType::Type:
- controller_type = controller->GetNpadType(true);
+ controller_type = controller->GetNpadStyleIndex(true);
needs_redraw = true;
break;
case Core::HID::ControllerTriggerType::Color:
@@ -221,22 +221,22 @@ void PlayerControlPreview::paintEvent(QPaintEvent* event) {
const QPointF center = rect().center();
switch (controller_type) {
- case Core::HID::NpadType::Handheld:
+ case Core::HID::NpadStyleIndex::Handheld:
DrawHandheldController(p, center);
break;
- case Core::HID::NpadType::JoyconDual:
+ case Core::HID::NpadStyleIndex::JoyconDual:
DrawDualController(p, center);
break;
- case Core::HID::NpadType::JoyconLeft:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
DrawLeftController(p, center);
break;
- case Core::HID::NpadType::JoyconRight:
+ case Core::HID::NpadStyleIndex::JoyconRight:
DrawRightController(p, center);
break;
- case Core::HID::NpadType::GameCube:
+ case Core::HID::NpadStyleIndex::GameCube:
DrawGCController(p, center);
break;
- case Core::HID::NpadType::ProController:
+ case Core::HID::NpadStyleIndex::ProController:
default:
DrawProController(p, center);
break;
@@ -2394,7 +2394,7 @@ void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center,
void PlayerControlPreview::DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right) {
using namespace Settings::NativeAnalog;
- if (controller_type != Core::HID::NpadType::JoyconLeft) {
+ if (controller_type != Core::HID::NpadStyleIndex::JoyconLeft) {
DrawJoystickProperties(p, center_right, stick_values[RStick].x.properties);
p.setPen(colors.indicator);
p.setBrush(colors.indicator);
@@ -2404,7 +2404,7 @@ void PlayerControlPreview::DrawRawJoystick(QPainter& p, QPointF center_left, QPo
DrawJoystickDot(p, center_right, stick_values[RStick], false);
}
- if (controller_type != Core::HID::NpadType::JoyconRight) {
+ if (controller_type != Core::HID::NpadStyleIndex::JoyconRight) {
DrawJoystickProperties(p, center_left, stick_values[LStick].x.properties);
p.setPen(colors.indicator);
p.setBrush(colors.indicator);
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index acc53a9e3..ee217f3c9 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -203,7 +203,7 @@ private:
bool is_controller_set{};
bool is_connected{};
bool needs_redraw{};
- Core::HID::NpadType controller_type;
+ Core::HID::NpadStyleIndex controller_type;
bool mapping_active{};
int blink_counter{};
--
cgit v1.2.3
From d14e74132ceaa8b5efef8a7d543cb50429cb4fb3 Mon Sep 17 00:00:00 2001
From: german77
Date: Thu, 4 Nov 2021 13:08:30 -0600
Subject: settings: Fix controller preview not displaying the correct
controller
---
src/yuzu/configuration/configure_input_player_widget.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index e63c25e70..af65cf64c 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -2394,7 +2394,7 @@ void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center,
void PlayerControlPreview::DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right) {
using namespace Settings::NativeAnalog;
- if (controller_type != Core::HID::NpadStyleIndex::JoyconLeft) {
+ if (center_right != QPointF(0, 0)) {
DrawJoystickProperties(p, center_right, stick_values[RStick].x.properties);
p.setPen(colors.indicator);
p.setBrush(colors.indicator);
@@ -2404,7 +2404,7 @@ void PlayerControlPreview::DrawRawJoystick(QPainter& p, QPointF center_left, QPo
DrawJoystickDot(p, center_right, stick_values[RStick], false);
}
- if (controller_type != Core::HID::NpadStyleIndex::JoyconRight) {
+ if (center_left != QPointF(0, 0)) {
DrawJoystickProperties(p, center_left, stick_values[LStick].x.properties);
p.setPen(colors.indicator);
p.setBrush(colors.indicator);
--
cgit v1.2.3
From 690013b342e6d9a9561017b2e94f42acfde25147 Mon Sep 17 00:00:00 2001
From: Levi Behunin
Date: Thu, 4 Nov 2021 16:09:57 -0600
Subject: UI nits Set top margin to 6 on Right Stick, LeftStick, Face Buttons,
D-Pad. Change property on Input Device QComboBox from minimumSize to
minimumContentsLength.
---
src/yuzu/configuration/configure_input_player.ui | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui
index 958a89229..756a414b5 100644
--- a/src/yuzu/configuration/configure_input_player.ui
+++ b/src/yuzu/configuration/configure_input_player.ui
@@ -117,11 +117,8 @@
-
-
-
- 0
- 21
-
+
+ 60
@@ -307,7 +304,7 @@
3
- 0
+ 6
3
@@ -883,7 +880,7 @@
3
- 0
+ 6
3
@@ -2186,7 +2183,7 @@
3
- 0
+ 6
3
@@ -2535,7 +2532,7 @@
3
- 0
+ 6
3
--
cgit v1.2.3
From a17550be9855a32a62a1358b23babab929a39cbb Mon Sep 17 00:00:00 2001
From: german77
Date: Thu, 4 Nov 2021 21:54:22 -0600
Subject: settings: Remove includes of core.h
---
.../configuration/configure_debug_controller.cpp | 9 +++---
.../configuration/configure_debug_controller.h | 7 +++--
src/yuzu/configuration/configure_dialog.cpp | 2 +-
src/yuzu/configuration/configure_input.cpp | 29 ++++++++++--------
src/yuzu/configuration/configure_input.h | 3 +-
src/yuzu/configuration/configure_input_player.cpp | 35 ++++++++++------------
src/yuzu/configuration/configure_input_player.h | 16 ++++------
.../configure_input_player_widget.cpp | 3 +-
.../configuration/configure_input_player_widget.h | 4 +--
.../configure_input_profile_dialog.cpp | 4 +--
10 files changed, 55 insertions(+), 57 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_debug_controller.cpp b/src/yuzu/configuration/configure_debug_controller.cpp
index 31ec48384..9a8de92a1 100644
--- a/src/yuzu/configuration/configure_debug_controller.cpp
+++ b/src/yuzu/configuration/configure_debug_controller.cpp
@@ -2,17 +2,18 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
-#include "core/core.h"
+#include "core/hid/hid_core.h"
#include "ui_configure_debug_controller.h"
#include "yuzu/configuration/configure_debug_controller.h"
#include "yuzu/configuration/configure_input_player.h"
ConfigureDebugController::ConfigureDebugController(QWidget* parent,
InputCommon::InputSubsystem* input_subsystem,
- InputProfiles* profiles, Core::System& system)
+ InputProfiles* profiles,
+ Core::HID::HIDCore& hid_core, bool is_powered_on)
: QDialog(parent), ui(std::make_unique()),
- debug_controller(
- new ConfigureInputPlayer(this, 9, nullptr, input_subsystem, profiles, system, true)) {
+ debug_controller(new ConfigureInputPlayer(this, 9, nullptr, input_subsystem, profiles,
+ hid_core, is_powered_on, true)) {
ui->setupUi(this);
ui->controllerLayout->addWidget(debug_controller);
diff --git a/src/yuzu/configuration/configure_debug_controller.h b/src/yuzu/configuration/configure_debug_controller.h
index 6e17c5aa0..d716edbc2 100644
--- a/src/yuzu/configuration/configure_debug_controller.h
+++ b/src/yuzu/configuration/configure_debug_controller.h
@@ -13,8 +13,8 @@ class ConfigureInputPlayer;
class InputProfiles;
-namespace Core {
-class System;
+namespace Core::HID {
+class HIDCore;
}
namespace InputCommon {
@@ -30,7 +30,8 @@ class ConfigureDebugController : public QDialog {
public:
explicit ConfigureDebugController(QWidget* parent, InputCommon::InputSubsystem* input_subsystem,
- InputProfiles* profiles, Core::System& system);
+ InputProfiles* profiles, Core::HID::HIDCore& hid_core,
+ bool is_powered_on);
~ConfigureDebugController() override;
void ApplyConfiguration();
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp
index 1eb9d70e5..642a5f966 100644
--- a/src/yuzu/configuration/configure_dialog.cpp
+++ b/src/yuzu/configuration/configure_dialog.cpp
@@ -74,7 +74,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
hotkeys_tab->Populate(registry);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
- input_tab->Initialize(input_subsystem, system_);
+ input_tab->Initialize(input_subsystem);
general_tab->SetResetCallback([&] { this->close(); });
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp
index dece27fde..99450bc7d 100644
--- a/src/yuzu/configuration/configure_input.cpp
+++ b/src/yuzu/configuration/configure_input.cpp
@@ -10,6 +10,8 @@
#include
#include "core/core.h"
+#include "core/hid/emulated_controller.h"
+#include "core/hid/hid_core.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applet_ae.h"
#include "core/hle/service/am/applet_oe.h"
@@ -73,25 +75,27 @@ ConfigureInput::ConfigureInput(Core::System& system_, QWidget* parent)
ConfigureInput::~ConfigureInput() = default;
-void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, Core::System& system,
+void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
std::size_t max_players) {
+ const bool is_powered_on = system.IsPoweredOn();
+ auto& hid_core = system.HIDCore();
player_controllers = {
new ConfigureInputPlayer(this, 0, ui->consoleInputSettings, input_subsystem, profiles.get(),
- system),
+ hid_core, is_powered_on),
new ConfigureInputPlayer(this, 1, ui->consoleInputSettings, input_subsystem, profiles.get(),
- system),
+ hid_core, is_powered_on),
new ConfigureInputPlayer(this, 2, ui->consoleInputSettings, input_subsystem, profiles.get(),
- system),
+ hid_core, is_powered_on),
new ConfigureInputPlayer(this, 3, ui->consoleInputSettings, input_subsystem, profiles.get(),
- system),
+ hid_core, is_powered_on),
new ConfigureInputPlayer(this, 4, ui->consoleInputSettings, input_subsystem, profiles.get(),
- system),
+ hid_core, is_powered_on),
new ConfigureInputPlayer(this, 5, ui->consoleInputSettings, input_subsystem, profiles.get(),
- system),
+ hid_core, is_powered_on),
new ConfigureInputPlayer(this, 6, ui->consoleInputSettings, input_subsystem, profiles.get(),
- system),
+ hid_core, is_powered_on),
new ConfigureInputPlayer(this, 7, ui->consoleInputSettings, input_subsystem, profiles.get(),
- system),
+ hid_core, is_powered_on),
};
player_tabs = {
@@ -147,10 +151,11 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, Co
advanced = new ConfigureInputAdvanced(this);
ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced));
ui->tabAdvanced->layout()->addWidget(advanced);
+
connect(advanced, &ConfigureInputAdvanced::CallDebugControllerDialog,
- [this, input_subsystem, &system] {
- CallConfigureDialog(*this, input_subsystem,
- profiles.get(), system);
+ [this, input_subsystem, &hid_core, is_powered_on] {
+ CallConfigureDialog(
+ *this, input_subsystem, profiles.get(), hid_core, is_powered_on);
});
connect(advanced, &ConfigureInputAdvanced::CallMouseConfigDialog, [this, input_subsystem] {
CallConfigureDialog(*this, input_subsystem);
diff --git a/src/yuzu/configuration/configure_input.h b/src/yuzu/configuration/configure_input.h
index 6e5edad58..4cafa3dab 100644
--- a/src/yuzu/configuration/configure_input.h
+++ b/src/yuzu/configuration/configure_input.h
@@ -42,8 +42,7 @@ public:
~ConfigureInput() override;
/// Initializes the input dialog with the given input subsystem.
- void Initialize(InputCommon::InputSubsystem* input_subsystem_, Core::System& system,
- std::size_t max_players = 8);
+ void Initialize(InputCommon::InputSubsystem* input_subsystem_, std::size_t max_players = 8);
/// Save all button configurations to settings file.
void ApplyConfiguration();
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 95a9b8614..76f55eb54 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -12,7 +12,6 @@
#include
#include
#include "common/param_package.h"
-#include "core/core.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h"
#include "core/hid/hid_types.h"
@@ -134,18 +133,17 @@ QString ConfigureInputPlayer::AnalogToText(const Common::ParamPackage& param,
ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_index,
QWidget* bottom_row,
InputCommon::InputSubsystem* input_subsystem_,
- InputProfiles* profiles_, Core::System& system_,
- bool debug)
+ InputProfiles* profiles_, Core::HID::HIDCore& hid_core_,
+ bool is_powered_on_, bool debug)
: QWidget(parent), ui(std::make_unique()), player_index(player_index),
- debug(debug), input_subsystem{input_subsystem_}, profiles(profiles_),
- timeout_timer(std::make_unique()), poll_timer(std::make_unique()),
- bottom_row(bottom_row), system{system_} {
-
+ debug(debug), is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_},
+ profiles(profiles_), timeout_timer(std::make_unique()),
+ poll_timer(std::make_unique()), bottom_row(bottom_row), hid_core{hid_core_} {
if (player_index == 0) {
auto* emulated_controller_p1 =
- system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
+ hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
auto* emulated_controller_hanheld =
- system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
emulated_controller_p1->SaveCurrentConfig();
emulated_controller_p1->EnableConfiguration();
emulated_controller_hanheld->SaveCurrentConfig();
@@ -157,7 +155,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
emulated_controller = emulated_controller_p1;
}
} else {
- emulated_controller = system_.HIDCore().GetEmulatedControllerByIndex(player_index);
+ emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index);
emulated_controller->SaveCurrentConfig();
emulated_controller->EnableConfiguration();
}
@@ -487,9 +485,9 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
if (player_index == 0) {
auto* emulated_controller_p1 =
- system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
+ hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
auto* emulated_controller_hanheld =
- system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
bool is_connected = emulated_controller->IsConnected(true);
emulated_controller_p1->SetNpadStyleIndex(type);
@@ -547,9 +545,9 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
ConfigureInputPlayer::~ConfigureInputPlayer() {
if (player_index == 0) {
auto* emulated_controller_p1 =
- system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
+ hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
auto* emulated_controller_hanheld =
- system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
emulated_controller_p1->DisableConfiguration();
emulated_controller_hanheld->DisableConfiguration();
} else {
@@ -560,9 +558,9 @@ ConfigureInputPlayer::~ConfigureInputPlayer() {
void ConfigureInputPlayer::ApplyConfiguration() {
if (player_index == 0) {
auto* emulated_controller_p1 =
- system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
+ hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
auto* emulated_controller_hanheld =
- system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
emulated_controller_p1->DisableConfiguration();
emulated_controller_p1->SaveCurrentConfig();
emulated_controller_p1->EnableConfiguration();
@@ -846,12 +844,11 @@ void ConfigureInputPlayer::SetConnectableControllers() {
}
};
- if (!system.IsPoweredOn()) {
+ if (!is_powered_on) {
add_controllers(true);
- return;
}
- add_controllers(false, system.HIDCore().GetSupportedStyleTag());
+ add_controllers(false, hid_core.GetSupportedStyleTag());
}
Core::HID::NpadStyleIndex ConfigureInputPlayer::GetControllerTypeFromIndex(int index) const {
diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h
index 7bff4b196..47df6b3d3 100644
--- a/src/yuzu/configuration/configure_input_player.h
+++ b/src/yuzu/configuration/configure_input_player.h
@@ -29,10 +29,6 @@ class QWidget;
class InputProfiles;
-namespace Core {
-class System;
-}
-
namespace InputCommon {
class InputSubsystem;
}
@@ -45,11 +41,8 @@ namespace Ui {
class ConfigureInputPlayer;
}
-namespace Core {
-class System;
-}
-
namespace Core::HID {
+class HIDCore;
class EmulatedController;
enum class NpadStyleIndex : u8;
} // namespace Core::HID
@@ -60,8 +53,8 @@ class ConfigureInputPlayer : public QWidget {
public:
explicit ConfigureInputPlayer(QWidget* parent, std::size_t player_index, QWidget* bottom_row,
InputCommon::InputSubsystem* input_subsystem_,
- InputProfiles* profiles_, Core::System& system_,
- bool debug = false);
+ InputProfiles* profiles_, Core::HID::HIDCore& hid_core_,
+ bool is_powered_on_, bool debug = false);
~ConfigureInputPlayer() override;
/// Save all button configurations to settings file.
@@ -173,6 +166,7 @@ private:
std::size_t player_index;
bool debug;
+ bool is_powered_on;
InputCommon::InputSubsystem* input_subsystem;
@@ -228,5 +222,5 @@ private:
/// parent of the widget to this widget (but thats fine).
QWidget* bottom_row;
- Core::System& system;
+ Core::HID::HIDCore& hid_core;
};
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index af65cf64c..ff40f57f5 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -6,7 +6,8 @@
#include
#include
#include
-#include "core/core.h"
+
+#include "core/hid/emulated_controller.h"
#include "yuzu/configuration/configure_input_player_widget.h"
PlayerControlPreview::PlayerControlPreview(QWidget* parent) : QFrame(parent) {
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index ee217f3c9..4cd5c3be0 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -7,10 +7,10 @@
#include
#include
#include
+
#include "common/input.h"
-#include "common/settings.h"
+#include "common/settings_input.h"
#include "core/hid/emulated_controller.h"
-#include "core/hid/hid_core.h"
#include "core/hid/hid_types.h"
class QLabel;
diff --git a/src/yuzu/configuration/configure_input_profile_dialog.cpp b/src/yuzu/configuration/configure_input_profile_dialog.cpp
index cd5a88cea..17bbe6b61 100644
--- a/src/yuzu/configuration/configure_input_profile_dialog.cpp
+++ b/src/yuzu/configuration/configure_input_profile_dialog.cpp
@@ -11,8 +11,8 @@ ConfigureInputProfileDialog::ConfigureInputProfileDialog(
QWidget* parent, InputCommon::InputSubsystem* input_subsystem, InputProfiles* profiles,
Core::System& system)
: QDialog(parent), ui(std::make_unique()),
- profile_widget(
- new ConfigureInputPlayer(this, 9, nullptr, input_subsystem, profiles, system, false)) {
+ profile_widget(new ConfigureInputPlayer(this, 9, nullptr, input_subsystem, profiles,
+ system.HIDCore(), system.IsPoweredOn(), false)) {
ui->setupUi(this);
ui->controllerLayout->addWidget(profile_widget);
--
cgit v1.2.3
From 71f9b90dd90c442425900ee16af8b4e39ac54aed Mon Sep 17 00:00:00 2001
From: german77
Date: Mon, 8 Nov 2021 20:28:09 -0600
Subject: core/hid: Remove usage of native types, fix a couple of errors with
motion
---
src/yuzu/configuration/configure_input_player.cpp | 4 +++-
.../configure_input_player_widget.cpp | 24 ++++++++++++++--------
2 files changed, 19 insertions(+), 9 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 76f55eb54..0254ea6fe 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -627,7 +627,8 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
return;
}
- const auto devices = emulated_controller->GetMappedDevices(Core::HID::DeviceIndex::AllDevices);
+ const auto devices =
+ emulated_controller->GetMappedDevices(Core::HID::EmulatedDeviceIndex::AllDevices);
UpdateInputDevices();
if (devices.empty()) {
@@ -846,6 +847,7 @@ void ConfigureInputPlayer::SetConnectableControllers() {
if (!is_powered_on) {
add_controllers(true);
+ return;
}
add_controllers(false, hid_core.GetSupportedStyleTag());
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index ff40f57f5..6630321cb 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -357,7 +357,8 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center)
DrawCircle(p, center + QPoint(26, 71), 5);
// Draw battery
- DrawBattery(p, center + QPoint(-170, -140), battery_values[Core::HID::DeviceIndex::LeftIndex]);
+ DrawBattery(p, center + QPoint(-170, -140),
+ battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]);
}
void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center) {
@@ -483,7 +484,8 @@ void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center
DrawSymbol(p, center + QPoint(-26, 66), Symbol::House, 5);
// Draw battery
- DrawBattery(p, center + QPoint(110, -140), battery_values[Core::HID::DeviceIndex::RightIndex]);
+ DrawBattery(p, center + QPoint(110, -140),
+ battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]);
}
void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center) {
@@ -619,8 +621,10 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center)
DrawSymbol(p, center + QPoint(50, 60), Symbol::House, 4.2f);
// Draw battery
- DrawBattery(p, center + QPoint(-100, -160), battery_values[Core::HID::DeviceIndex::LeftIndex]);
- DrawBattery(p, center + QPoint(40, -160), battery_values[Core::HID::DeviceIndex::RightIndex]);
+ DrawBattery(p, center + QPoint(-100, -160),
+ battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]);
+ DrawBattery(p, center + QPoint(40, -160),
+ battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]);
}
void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF center) {
@@ -721,8 +725,10 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen
DrawSymbol(p, center + QPoint(161, 37), Symbol::House, 2.75f);
// Draw battery
- DrawBattery(p, center + QPoint(-200, 110), battery_values[Core::HID::DeviceIndex::LeftIndex]);
- DrawBattery(p, center + QPoint(130, 110), battery_values[Core::HID::DeviceIndex::RightIndex]);
+ DrawBattery(p, center + QPoint(-200, 110),
+ battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]);
+ DrawBattery(p, center + QPoint(130, 110),
+ battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]);
}
void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) {
@@ -812,7 +818,8 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
DrawSymbol(p, center + QPoint(29, -56), Symbol::House, 3.9f);
// Draw battery
- DrawBattery(p, center + QPoint(-30, -160), battery_values[Core::HID::DeviceIndex::LeftIndex]);
+ DrawBattery(p, center + QPoint(-30, -160),
+ battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]);
}
void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) {
@@ -868,7 +875,8 @@ void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) {
DrawCircleButton(p, center + QPoint(0, -44), button_values[Plus], 8);
// Draw battery
- DrawBattery(p, center + QPoint(-30, -165), battery_values[Core::HID::DeviceIndex::LeftIndex]);
+ DrawBattery(p, center + QPoint(-30, -165),
+ battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]);
}
constexpr std::array symbol_a = {
--
cgit v1.2.3
From b673857d7dfc72f38d9242b315cd590b859795ff Mon Sep 17 00:00:00 2001
From: german77
Date: Sat, 13 Nov 2021 23:25:45 -0600
Subject: core/hid: Improve accuracy of the keyboard implementation
---
src/yuzu/configuration/config.cpp | 167 ++------------------------------------
1 file changed, 8 insertions(+), 159 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 7669fe474..ccf274895 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -65,157 +65,6 @@ const std::array Config::defa
Qt::Key_BracketLeft, Qt::Key_BracketRight, Qt::Key_Apostrophe, Qt::Key_Minus, Qt::Key_Equal,
};
-const std::array Config::default_keyboard_keys = {
- 0,
- 0,
- 0,
- 0,
- Qt::Key_A,
- Qt::Key_B,
- Qt::Key_C,
- Qt::Key_D,
- Qt::Key_E,
- Qt::Key_F,
- Qt::Key_G,
- Qt::Key_H,
- Qt::Key_I,
- Qt::Key_J,
- Qt::Key_K,
- Qt::Key_L,
- Qt::Key_M,
- Qt::Key_N,
- Qt::Key_O,
- Qt::Key_P,
- Qt::Key_Q,
- Qt::Key_R,
- Qt::Key_S,
- Qt::Key_T,
- Qt::Key_U,
- Qt::Key_V,
- Qt::Key_W,
- Qt::Key_X,
- Qt::Key_Y,
- Qt::Key_Z,
- Qt::Key_1,
- Qt::Key_2,
- Qt::Key_3,
- Qt::Key_4,
- Qt::Key_5,
- Qt::Key_6,
- Qt::Key_7,
- Qt::Key_8,
- Qt::Key_9,
- Qt::Key_0,
- Qt::Key_Enter,
- Qt::Key_Escape,
- Qt::Key_Backspace,
- Qt::Key_Tab,
- Qt::Key_Space,
- Qt::Key_Minus,
- Qt::Key_Equal,
- Qt::Key_BracketLeft,
- Qt::Key_BracketRight,
- Qt::Key_Backslash,
- Qt::Key_Dead_Tilde,
- Qt::Key_Semicolon,
- Qt::Key_Apostrophe,
- Qt::Key_Dead_Grave,
- Qt::Key_Comma,
- Qt::Key_Period,
- Qt::Key_Slash,
- Qt::Key_CapsLock,
-
- Qt::Key_F1,
- Qt::Key_F2,
- Qt::Key_F3,
- Qt::Key_F4,
- Qt::Key_F5,
- Qt::Key_F6,
- Qt::Key_F7,
- Qt::Key_F8,
- Qt::Key_F9,
- Qt::Key_F10,
- Qt::Key_F11,
- Qt::Key_F12,
-
- Qt::Key_SysReq,
- Qt::Key_ScrollLock,
- Qt::Key_Pause,
- Qt::Key_Insert,
- Qt::Key_Home,
- Qt::Key_PageUp,
- Qt::Key_Delete,
- Qt::Key_End,
- Qt::Key_PageDown,
- Qt::Key_Right,
- Qt::Key_Left,
- Qt::Key_Down,
- Qt::Key_Up,
-
- Qt::Key_NumLock,
- Qt::Key_Slash,
- Qt::Key_Asterisk,
- Qt::Key_Minus,
- Qt::Key_Plus,
- Qt::Key_Enter,
- Qt::Key_1,
- Qt::Key_2,
- Qt::Key_3,
- Qt::Key_4,
- Qt::Key_5,
- Qt::Key_6,
- Qt::Key_7,
- Qt::Key_8,
- Qt::Key_9,
- Qt::Key_0,
- Qt::Key_Period,
-
- 0,
- 0,
- Qt::Key_PowerOff,
- Qt::Key_Equal,
-
- Qt::Key_F13,
- Qt::Key_F14,
- Qt::Key_F15,
- Qt::Key_F16,
- Qt::Key_F17,
- Qt::Key_F18,
- Qt::Key_F19,
- Qt::Key_F20,
- Qt::Key_F21,
- Qt::Key_F22,
- Qt::Key_F23,
- Qt::Key_F24,
-
- Qt::Key_Open,
- Qt::Key_Help,
- Qt::Key_Menu,
- 0,
- Qt::Key_Stop,
- Qt::Key_AudioRepeat,
- Qt::Key_Undo,
- Qt::Key_Cut,
- Qt::Key_Copy,
- Qt::Key_Paste,
- Qt::Key_Find,
- Qt::Key_VolumeMute,
- Qt::Key_VolumeUp,
- Qt::Key_VolumeDown,
- Qt::Key_CapsLock,
- Qt::Key_NumLock,
- Qt::Key_ScrollLock,
- Qt::Key_Comma,
-
- Qt::Key_ParenLeft,
- Qt::Key_ParenRight,
-};
-
-const std::array Config::default_keyboard_mods = {
- Qt::Key_Control, Qt::Key_Shift, Qt::Key_Alt, Qt::Key_ApplicationLeft,
- Qt::Key_Control, Qt::Key_Shift, Qt::Key_AltGr, Qt::Key_ApplicationRight,
-};
-
// This shouldn't have anything except static initializers (no functions). So
// QKeySequence(...).toString() is NOT ALLOWED HERE.
// This must be in alphabetical order according to action name as it must have the same order as
@@ -496,14 +345,14 @@ void Config::ReadDebugValues() {
void Config::ReadKeyboardValues() {
ReadBasicSetting(Settings::values.keyboard_enabled);
- std::transform(default_keyboard_keys.begin(), default_keyboard_keys.end(),
- Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam);
- std::transform(default_keyboard_mods.begin(), default_keyboard_mods.end(),
- Settings::values.keyboard_keys.begin() +
- Settings::NativeKeyboard::LeftControlKey,
- InputCommon::GenerateKeyboardParam);
- std::transform(default_keyboard_mods.begin(), default_keyboard_mods.end(),
- Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam);
+ for (std::size_t i = 0; i < Settings::values.keyboard_keys.size(); ++i) {
+ Settings::values.keyboard_keys[i] = InputCommon::GenerateKeyboardParam(static_cast(i));
+ }
+
+ for (std::size_t i = 0; i < Settings::values.keyboard_mods.size(); ++i) {
+ Settings::values.keyboard_mods[i] =
+ InputCommon::GenerateModdifierKeyboardParam(static_cast(i));
+ }
}
void Config::ReadMouseValues() {
--
cgit v1.2.3
From bca299e8e0489867f7d4bbfd264e221e7e61ae1e Mon Sep 17 00:00:00 2001
From: german77
Date: Sun, 14 Nov 2021 10:45:07 -0600
Subject: input_common: Allow keyboard to be backwards compatible
---
src/yuzu/configuration/config.cpp | 9 ---------
1 file changed, 9 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index ccf274895..5865359fe 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -344,15 +344,6 @@ void Config::ReadDebugValues() {
void Config::ReadKeyboardValues() {
ReadBasicSetting(Settings::values.keyboard_enabled);
-
- for (std::size_t i = 0; i < Settings::values.keyboard_keys.size(); ++i) {
- Settings::values.keyboard_keys[i] = InputCommon::GenerateKeyboardParam(static_cast(i));
- }
-
- for (std::size_t i = 0; i < Settings::values.keyboard_mods.size(); ++i) {
- Settings::values.keyboard_mods[i] =
- InputCommon::GenerateModdifierKeyboardParam(static_cast(i));
- }
}
void Config::ReadMouseValues() {
--
cgit v1.2.3
From 654d76e79e84a3384fa503fac9003a5d0a32f28b Mon Sep 17 00:00:00 2001
From: german77
Date: Sun, 14 Nov 2021 14:09:29 -0600
Subject: core/hid: Fully implement native mouse
---
src/yuzu/configuration/config.cpp | 30 --
src/yuzu/configuration/configure_input.cpp | 4 -
.../configuration/configure_input_advanced.cpp | 2 -
src/yuzu/configuration/configure_input_advanced.ui | 204 ++++++-------
.../configuration/configure_mouse_advanced.cpp | 247 ---------------
src/yuzu/configuration/configure_mouse_advanced.h | 72 -----
src/yuzu/configuration/configure_mouse_advanced.ui | 335 ---------------------
7 files changed, 103 insertions(+), 791 deletions(-)
delete mode 100644 src/yuzu/configuration/configure_mouse_advanced.cpp
delete mode 100644 src/yuzu/configuration/configure_mouse_advanced.h
delete mode 100644 src/yuzu/configuration/configure_mouse_advanced.ui
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 5865359fe..ae1684dd4 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -60,11 +60,6 @@ const std::array Config::default_stick_mod = {
0,
};
-const std::array Config::default_mouse_buttons =
- {
- Qt::Key_BracketLeft, Qt::Key_BracketRight, Qt::Key_Apostrophe, Qt::Key_Minus, Qt::Key_Equal,
-};
-
// This shouldn't have anything except static initializers (no functions). So
// QKeySequence(...).toString() is NOT ALLOWED HERE.
// This must be in alphabetical order according to action name as it must have the same order as
@@ -348,22 +343,6 @@ void Config::ReadKeyboardValues() {
void Config::ReadMouseValues() {
ReadBasicSetting(Settings::values.mouse_enabled);
-
- for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
- const std::string default_param =
- InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]);
- auto& mouse_buttons = Settings::values.mouse_buttons[i];
-
- mouse_buttons = qt_config
- ->value(QStringLiteral("mouse_") +
- QString::fromUtf8(Settings::NativeMouseButton::mapping[i]),
- QString::fromStdString(default_param))
- .toString()
- .toStdString();
- if (mouse_buttons.empty()) {
- mouse_buttons = default_param;
- }
- }
}
void Config::ReadTouchscreenValues() {
@@ -947,15 +926,6 @@ void Config::SaveDebugValues() {
void Config::SaveMouseValues() {
WriteBasicSetting(Settings::values.mouse_enabled);
-
- for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
- const std::string default_param =
- InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]);
- WriteSetting(QStringLiteral("mouse_") +
- QString::fromStdString(Settings::NativeMouseButton::mapping[i]),
- QString::fromStdString(Settings::values.mouse_buttons[i]),
- QString::fromStdString(default_param));
- }
}
void Config::SaveTouchscreenValues() {
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp
index 99450bc7d..d53179dbb 100644
--- a/src/yuzu/configuration/configure_input.cpp
+++ b/src/yuzu/configuration/configure_input.cpp
@@ -24,7 +24,6 @@
#include "yuzu/configuration/configure_input_advanced.h"
#include "yuzu/configuration/configure_input_player.h"
#include "yuzu/configuration/configure_motion_touch.h"
-#include "yuzu/configuration/configure_mouse_advanced.h"
#include "yuzu/configuration/configure_touchscreen_advanced.h"
#include "yuzu/configuration/configure_vibration.h"
#include "yuzu/configuration/input_profiles.h"
@@ -157,9 +156,6 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
CallConfigureDialog(
*this, input_subsystem, profiles.get(), hid_core, is_powered_on);
});
- connect(advanced, &ConfigureInputAdvanced::CallMouseConfigDialog, [this, input_subsystem] {
- CallConfigureDialog(*this, input_subsystem);
- });
connect(advanced, &ConfigureInputAdvanced::CallTouchscreenConfigDialog,
[this] { CallConfigureDialog(*this); });
connect(advanced, &ConfigureInputAdvanced::CallMotionTouchConfigDialog,
diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp
index b30f09013..cf8aad4ab 100644
--- a/src/yuzu/configuration/configure_input_advanced.cpp
+++ b/src/yuzu/configuration/configure_input_advanced.cpp
@@ -82,7 +82,6 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent)
connect(ui->debug_configure, &QPushButton::clicked, this,
[this] { CallDebugControllerDialog(); });
- connect(ui->mouse_advanced, &QPushButton::clicked, this, [this] { CallMouseConfigDialog(); });
connect(ui->touchscreen_advanced, &QPushButton::clicked, this,
[this] { CallTouchscreenConfigDialog(); });
connect(ui->buttonMotionTouch, &QPushButton::clicked, this,
@@ -178,7 +177,6 @@ void ConfigureInputAdvanced::RetranslateUI() {
}
void ConfigureInputAdvanced::UpdateUIEnabled() {
- ui->mouse_advanced->setEnabled(ui->mouse_enabled->isChecked());
ui->debug_configure->setEnabled(ui->debug_enabled->isChecked());
ui->touchscreen_advanced->setEnabled(ui->touchscreen_enabled->isChecked());
}
diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui
index 9095206a0..75487a5d0 100644
--- a/src/yuzu/configuration/configure_input_advanced.ui
+++ b/src/yuzu/configuration/configure_input_advanced.ui
@@ -2528,11 +2528,11 @@
0
-
-
+
- Other
+ Emulated Devices
-
+
-
@@ -2547,7 +2547,7 @@
-
-
+
0
@@ -2555,53 +2555,18 @@
- Emulate Analog with Keyboard Input
+ Mouse
-
-
-
-
- 0
- 23
-
-
+
- Enable mouse panning
+ Touchscreen
- -
-
-
- Mouse sensitivity
-
-
- Qt::AlignCenter
-
-
- %
-
-
- 1
-
-
- 100
-
-
- 100
-
-
-
- -
-
-
- Advanced
-
-
-
- -
+
-
Qt::Horizontal
@@ -2617,80 +2582,117 @@
- -
-
-
- Advanced
-
-
-
- -
-
-
- Touchscreen
-
-
-
+ -
+
+
+ Advanced
+
+
+
-
-
-
-
- 0
- 23
-
-
-
- Mouse
-
-
-
- -
-
-
- Motion / Touch
-
-
-
- -
-
-
- Configure
-
-
-
- -
Debug Controller
- -
+
-
Configure
- -
-
-
- Requires restarting yuzu
-
-
-
- 0
- 23
-
-
-
- Enable XInput 8 player support (disables web applet)
-
-
-
+ -
+
+
+ Other
+
+
+
-
+
+
+
+ 0
+ 23
+
+
+
+ Emulate Analog with Keyboard Input
+
+
+
+ -
+
+
+ Requires restarting yuzu
+
+
+
+ 0
+ 23
+
+
+
+ Enable XInput 8 player support (disables web applet)
+
+
+
+ -
+
+
+
+ 0
+ 23
+
+
+
+ Enable mouse panning
+
+
+
+ -
+
+
+ Mouse sensitivity
+
+
+ Qt::AlignCenter
+
+
+ %
+
+
+ 1
+
+
+ 100
+
+
+ 100
+
+
+
+ -
+
+
+ Motion / Touch
+
+
+
+ -
+
+
+ Configure
+
+
+
+
+
+
-
diff --git a/src/yuzu/configuration/configure_mouse_advanced.cpp b/src/yuzu/configuration/configure_mouse_advanced.cpp
deleted file mode 100644
index 1e7a3751d..000000000
--- a/src/yuzu/configuration/configure_mouse_advanced.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include
-#include
-
-#include
-#include
-#include
-
-#include "common/assert.h"
-#include "common/param_package.h"
-#include "input_common/drivers/keyboard.h"
-#include "input_common/drivers/mouse.h"
-#include "input_common/main.h"
-#include "ui_configure_mouse_advanced.h"
-#include "yuzu/bootmanager.h"
-#include "yuzu/configuration/config.h"
-#include "yuzu/configuration/configure_mouse_advanced.h"
-
-static QString GetKeyName(int key_code) {
- switch (key_code) {
- case Qt::LeftButton:
- return QObject::tr("Click 0");
- case Qt::RightButton:
- return QObject::tr("Click 1");
- case Qt::MiddleButton:
- return QObject::tr("Click 2");
- case Qt::BackButton:
- return QObject::tr("Click 3");
- case Qt::ForwardButton:
- return QObject::tr("Click 4");
- case Qt::Key_Shift:
- return QObject::tr("Shift");
- case Qt::Key_Control:
- return QObject::tr("Ctrl");
- case Qt::Key_Alt:
- return QObject::tr("Alt");
- case Qt::Key_Meta:
- return {};
- default:
- return QKeySequence(key_code).toString();
- }
-}
-
-static QString ButtonToText(const Common::ParamPackage& param) {
- if (!param.Has("engine")) {
- return QObject::tr("[not set]");
- }
-
- if (param.Get("engine", "") == "keyboard") {
- return GetKeyName(param.Get("code", 0));
- }
-
- if (param.Get("engine", "") == "sdl") {
- if (param.Has("hat")) {
- const QString hat_str = QString::fromStdString(param.Get("hat", ""));
- const QString direction_str = QString::fromStdString(param.Get("direction", ""));
-
- return QObject::tr("Hat %1 %2").arg(hat_str, direction_str);
- }
-
- if (param.Has("axis")) {
- const QString axis_str = QString::fromStdString(param.Get("axis", ""));
- const QString direction_str = QString::fromStdString(param.Get("direction", ""));
-
- return QObject::tr("Axis %1%2").arg(axis_str, direction_str);
- }
-
- if (param.Has("button")) {
- const QString button_str = QString::fromStdString(param.Get("button", ""));
-
- return QObject::tr("Button %1").arg(button_str);
- }
- return {};
- }
-
- return QObject::tr("[unknown]");
-}
-
-ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent,
- InputCommon::InputSubsystem* input_subsystem_)
- : QDialog(parent),
- ui(std::make_unique()), input_subsystem{input_subsystem_},
- timeout_timer(std::make_unique()), poll_timer(std::make_unique()) {
- ui->setupUi(this);
- setFocusPolicy(Qt::ClickFocus);
-
- button_map = {
- ui->left_button, ui->right_button, ui->middle_button, ui->forward_button, ui->back_button,
- };
-
- for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) {
- auto* const button = button_map[button_id];
- if (button == nullptr) {
- continue;
- }
-
- button->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(button, &QPushButton::clicked, [=, this] {
- HandleClick(
- button_map[button_id],
- [=, this](const Common::ParamPackage& params) {
- buttons_param[button_id] = params;
- },
- InputCommon::Polling::InputType::Button);
- });
- connect(button, &QPushButton::customContextMenuRequested,
- [=, this](const QPoint& menu_location) {
- QMenu context_menu;
- context_menu.addAction(tr("Clear"), [&] {
- buttons_param[button_id].Clear();
- button_map[button_id]->setText(tr("[not set]"));
- });
- context_menu.addAction(tr("Restore Default"), [&] {
- buttons_param[button_id] =
- Common::ParamPackage{InputCommon::GenerateKeyboardParam(
- Config::default_mouse_buttons[button_id])};
- button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
- });
- context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
- });
- }
-
- connect(ui->buttonClearAll, &QPushButton::clicked, [this] { ClearAll(); });
- connect(ui->buttonRestoreDefaults, &QPushButton::clicked, [this] { RestoreDefaults(); });
-
- timeout_timer->setSingleShot(true);
- connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
-
- connect(poll_timer.get(), &QTimer::timeout, [this] {
- const auto& params = input_subsystem->GetNextInput();
- if (params.Has("engine")) {
- SetPollingResult(params, false);
- return;
- }
- });
-
- LoadConfiguration();
- resize(0, 0);
-}
-
-ConfigureMouseAdvanced::~ConfigureMouseAdvanced() = default;
-
-void ConfigureMouseAdvanced::ApplyConfiguration() {
- std::transform(buttons_param.begin(), buttons_param.end(),
- Settings::values.mouse_buttons.begin(),
- [](const Common::ParamPackage& param) { return param.Serialize(); });
-}
-
-void ConfigureMouseAdvanced::LoadConfiguration() {
- std::transform(Settings::values.mouse_buttons.begin(), Settings::values.mouse_buttons.end(),
- buttons_param.begin(),
- [](const std::string& str) { return Common::ParamPackage(str); });
- UpdateButtonLabels();
-}
-
-void ConfigureMouseAdvanced::changeEvent(QEvent* event) {
- if (event->type() == QEvent::LanguageChange) {
- RetranslateUI();
- }
-
- QDialog::changeEvent(event);
-}
-
-void ConfigureMouseAdvanced::RetranslateUI() {
- ui->retranslateUi(this);
-}
-
-void ConfigureMouseAdvanced::RestoreDefaults() {
- for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) {
- buttons_param[button_id] = Common::ParamPackage{
- InputCommon::GenerateKeyboardParam(Config::default_mouse_buttons[button_id])};
- }
-
- UpdateButtonLabels();
-}
-
-void ConfigureMouseAdvanced::ClearAll() {
- for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
- const auto* const button = button_map[i];
- if (button != nullptr && button->isEnabled()) {
- buttons_param[i].Clear();
- }
- }
-
- UpdateButtonLabels();
-}
-
-void ConfigureMouseAdvanced::UpdateButtonLabels() {
- for (int button = 0; button < Settings::NativeMouseButton::NumMouseButtons; button++) {
- button_map[button]->setText(ButtonToText(buttons_param[button]));
- }
-}
-
-void ConfigureMouseAdvanced::HandleClick(
- QPushButton* button, std::function new_input_setter,
- InputCommon::Polling::InputType type) {
- button->setText(tr("[press key]"));
- button->setFocus();
-
- input_setter = new_input_setter;
-
- input_subsystem->BeginMapping(type);
-
- QWidget::grabMouse();
- QWidget::grabKeyboard();
-
- timeout_timer->start(2500); // Cancel after 2.5 seconds
- poll_timer->start(50); // Check for new inputs every 50ms
-}
-
-void ConfigureMouseAdvanced::SetPollingResult(const Common::ParamPackage& params, bool abort) {
- timeout_timer->stop();
- poll_timer->stop();
- input_subsystem->StopMapping();
-
- QWidget::releaseMouse();
- QWidget::releaseKeyboard();
-
- if (!abort) {
- (*input_setter)(params);
- }
-
- UpdateButtonLabels();
- input_setter = std::nullopt;
-}
-
-void ConfigureMouseAdvanced::mousePressEvent(QMouseEvent* event) {
- if (!input_setter || !event) {
- return;
- }
-
- const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
- input_subsystem->GetMouse()->PressButton(0, 0, 0, 0, button);
-}
-
-void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) {
- if (!input_setter || !event) {
- return;
- }
-
- if (event->key() != Qt::Key_Escape) {
- input_subsystem->GetKeyboard()->PressKey(event->key());
- }
-}
diff --git a/src/yuzu/configuration/configure_mouse_advanced.h b/src/yuzu/configuration/configure_mouse_advanced.h
deleted file mode 100644
index 5fa534eaf..000000000
--- a/src/yuzu/configuration/configure_mouse_advanced.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#pragma once
-
-#include
-#include
-#include
-
-class QCheckBox;
-class QPushButton;
-class QTimer;
-
-namespace InputCommon {
-class InputSubsystem;
-}
-
-namespace Ui {
-class ConfigureMouseAdvanced;
-}
-
-class ConfigureMouseAdvanced : public QDialog {
- Q_OBJECT
-
-public:
- explicit ConfigureMouseAdvanced(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_);
- ~ConfigureMouseAdvanced() override;
-
- void ApplyConfiguration();
-
-private:
- void changeEvent(QEvent* event) override;
- void RetranslateUI();
-
- /// Load configuration settings.
- void LoadConfiguration();
- /// Restore all buttons to their default values.
- void RestoreDefaults();
- /// Clear all input configuration
- void ClearAll();
-
- /// Update UI to reflect current configuration.
- void UpdateButtonLabels();
-
- /// Called when the button was pressed.
- void HandleClick(QPushButton* button,
- std::function new_input_setter,
- InputCommon::Polling::InputType type);
-
- /// Finish polling and configure input using the input_setter
- void SetPollingResult(const Common::ParamPackage& params, bool abort);
-
- /// Handle mouse button press events.
- void mousePressEvent(QMouseEvent* event) override;
-
- /// Handle key press events.
- void keyPressEvent(QKeyEvent* event) override;
-
- std::unique_ptr ui;
-
- InputCommon::InputSubsystem* input_subsystem;
-
- /// This will be the the setting function when an input is awaiting configuration.
- std::optional> input_setter;
-
- std::array button_map;
- std::array buttons_param;
-
- std::unique_ptr timeout_timer;
- std::unique_ptr poll_timer;
-};
diff --git a/src/yuzu/configuration/configure_mouse_advanced.ui b/src/yuzu/configuration/configure_mouse_advanced.ui
deleted file mode 100644
index 5b99e1c37..000000000
--- a/src/yuzu/configuration/configure_mouse_advanced.ui
+++ /dev/null
@@ -1,335 +0,0 @@
-
-
- ConfigureMouseAdvanced
-
-
-
- 0
- 0
- 310
- 193
-
-
-
- Configure Mouse
-
-
- QPushButton {
- min-width: 60px;
-}
-
-
-
-
-
-
- Mouse Buttons
-
-
-
-
-
-
-
-
-
-
-
-
- Forward:
-
-
-
-
-
- -
-
-
-
- 68
- 0
-
-
-
-
- 68
- 16777215
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
- 54
- 0
-
-
-
- Back:
-
-
-
-
-
- -
-
-
-
- 68
- 0
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
- Left:
-
-
-
-
-
- -
-
-
-
- 68
- 0
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
- Middle:
-
-
-
-
-
- -
-
-
-
- 68
- 0
-
-
-
-
- 68
- 16777215
-
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Fixed
-
-
-
- 0
- 20
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Fixed
-
-
-
- 0
- 20
-
-
-
-
- -
-
-
-
-
-
-
-
-
- Right:
-
-
-
-
-
- -
-
-
-
- 68
- 0
-
-
-
-
- 68
- 16777215
-
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 0
- 20
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 0
- 20
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
- 68
- 0
-
-
-
-
- 68
- 16777215
-
-
-
- Clear
-
-
-
- -
-
-
-
- 68
- 0
-
-
-
-
- 68
- 16777215
-
-
-
- Defaults
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 0
- 20
-
-
-
-
- -
-
-
-
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
-
-
-
-
-
-
-
- buttonBox
- accepted()
- ConfigureMouseAdvanced
- accept()
-
-
- buttonBox
- rejected()
- ConfigureMouseAdvanced
- reject()
-
-
-
--
cgit v1.2.3
From f4e5f89e6fb9d68cd4ba7d98c281584c50f0e149 Mon Sep 17 00:00:00 2001
From: german77
Date: Sun, 14 Nov 2021 21:28:38 -0600
Subject: core/hid: Improve accuary of mouse implementation
---
src/yuzu/configuration/configure_input_advanced.cpp | 2 ++
1 file changed, 2 insertions(+)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp
index cf8aad4ab..e6127f9e6 100644
--- a/src/yuzu/configuration/configure_input_advanced.cpp
+++ b/src/yuzu/configuration/configure_input_advanced.cpp
@@ -179,4 +179,6 @@ void ConfigureInputAdvanced::RetranslateUI() {
void ConfigureInputAdvanced::UpdateUIEnabled() {
ui->debug_configure->setEnabled(ui->debug_enabled->isChecked());
ui->touchscreen_advanced->setEnabled(ui->touchscreen_enabled->isChecked());
+ ui->mouse_panning->setEnabled(!ui->mouse_enabled->isChecked());
+ ui->mouse_panning_sensitivity->setEnabled(!ui->mouse_enabled->isChecked());
}
--
cgit v1.2.3
From 746c85b56011b87afb57e37b75953435389fc810 Mon Sep 17 00:00:00 2001
From: german77
Date: Sun, 21 Nov 2021 14:12:01 -0600
Subject: input_common: Move button names to the frontend
---
src/yuzu/configuration/configure_input_player.cpp | 86 ++++++++++++++++++++++-
1 file changed, 83 insertions(+), 3 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 0254ea6fe..6219a09a8 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -52,6 +52,37 @@ QString GetKeyName(int key_code) {
}
}
+QString GetButtonName(Common::Input::ButtonNames button_name) {
+ switch (button_name) {
+ case Common::Input::ButtonNames::ButtonLeft:
+ return QObject::tr("Left");
+ case Common::Input::ButtonNames::ButtonRight:
+ return QObject::tr("Right");
+ case Common::Input::ButtonNames::ButtonDown:
+ return QObject::tr("Down");
+ case Common::Input::ButtonNames::ButtonUp:
+ return QObject::tr("Up");
+ case Common::Input::ButtonNames::TriggerZ:
+ return QObject::tr("Z");
+ case Common::Input::ButtonNames::TriggerR:
+ return QObject::tr("R");
+ case Common::Input::ButtonNames::TriggerL:
+ return QObject::tr("L");
+ case Common::Input::ButtonNames::ButtonA:
+ return QObject::tr("A");
+ case Common::Input::ButtonNames::ButtonB:
+ return QObject::tr("B");
+ case Common::Input::ButtonNames::ButtonX:
+ return QObject::tr("X");
+ case Common::Input::ButtonNames::ButtonY:
+ return QObject::tr("Y");
+ case Common::Input::ButtonNames::ButtonStart:
+ return QObject::tr("Start");
+ default:
+ return QObject::tr("[undefined]");
+ }
+}
+
void SetAnalogParam(const Common::ParamPackage& input_param, Common::ParamPackage& analog_param,
const std::string& button_name) {
// The poller returned a complete axis, so set all the buttons
@@ -75,15 +106,64 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) {
return QObject::tr("[not set]");
}
+ const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : "");
+ const QString inverted = QString::fromStdString(param.Get("inverted", false) ? "!" : "");
+ const auto common_button_name = input_subsystem->GetButtonName(param);
+
// Retrieve the names from Qt
if (param.Get("engine", "") == "keyboard") {
const QString button_str = GetKeyName(param.Get("code", 0));
- const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : "");
return QObject::tr("%1%2").arg(toggle, button_str);
}
- std::string button_name = input_subsystem->GetButtonName(param);
- return QString::fromStdString(button_name);
+ if (common_button_name == Common::Input::ButtonNames::Invalid) {
+ return QObject::tr("[invalid]");
+ }
+
+ if (common_button_name == Common::Input::ButtonNames::Engine) {
+ return QString::fromStdString(param.Get("engine", ""));
+ }
+
+ if (common_button_name == Common::Input::ButtonNames::Value) {
+ if (param.Has("hat")) {
+ const QString hat = QString::fromStdString(param.Get("direction", ""));
+ return QObject::tr("%1%2Hat %3").arg(toggle, inverted, hat);
+ }
+ if (param.Has("axis")) {
+ const QString axis = QString::fromStdString(param.Get("axis", ""));
+ return QObject::tr("%1%2Axis %3").arg(toggle, inverted, axis);
+ }
+ if (param.Has("axis_x") && param.Has("axis_y") && param.Has("axis_z")) {
+ const QString axis_x = QString::fromStdString(param.Get("axis_x", ""));
+ const QString axis_y = QString::fromStdString(param.Get("axis_y", ""));
+ const QString axis_z = QString::fromStdString(param.Get("axis_z", ""));
+ return QObject::tr("%1%2Axis %3,%4,%5").arg(toggle, inverted, axis_x, axis_y, axis_z);
+ }
+ if (param.Has("motion")) {
+ const QString motion = QString::fromStdString(param.Get("motion", ""));
+ return QObject::tr("%1%2Motion %3").arg(toggle, inverted, motion);
+ }
+ if (param.Has("button")) {
+ const QString button = QString::fromStdString(param.Get("button", ""));
+ return QObject::tr("%1%2Button %3").arg(toggle, inverted, button);
+ }
+ }
+
+ QString button_name = GetButtonName(common_button_name);
+ if (param.Has("hat")) {
+ return QObject::tr("%1%2Hat %3").arg(toggle, inverted, button_name);
+ }
+ if (param.Has("axis")) {
+ return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name);
+ }
+ if (param.Has("motion")) {
+ return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name);
+ }
+ if (param.Has("button")) {
+ return QObject::tr("%1%2Button %3").arg(toggle, inverted, button_name);
+ }
+
+ return QObject::tr("[unknown]");
}
QString ConfigureInputPlayer::AnalogToText(const Common::ParamPackage& param,
--
cgit v1.2.3
From 639402850ac65c694967ef6519becb65abe89b39 Mon Sep 17 00:00:00 2001
From: Narr the Reg
Date: Fri, 26 Nov 2021 15:45:37 -0600
Subject: input_common: Fully implement UDP controllers
---
src/yuzu/configuration/config.cpp | 2 ++
.../configuration/configure_input_advanced.cpp | 2 ++
src/yuzu/configuration/configure_input_advanced.ui | 19 ++++++++++++++---
src/yuzu/configuration/configure_input_player.cpp | 24 ++++++++++++++++++++++
4 files changed, 44 insertions(+), 3 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index ae1684dd4..38fd6e93b 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -447,6 +447,7 @@ void Config::ReadMotionTouchValues() {
Settings::values.touch_from_button_map_index = std::clamp(
Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1);
ReadBasicSetting(Settings::values.udp_input_servers);
+ ReadBasicSetting(Settings::values.enable_udp_controller);
}
void Config::ReadCoreValues() {
@@ -942,6 +943,7 @@ void Config::SaveMotionTouchValues() {
WriteBasicSetting(Settings::values.touch_device);
WriteBasicSetting(Settings::values.touch_from_button_map_index);
WriteBasicSetting(Settings::values.udp_input_servers);
+ WriteBasicSetting(Settings::values.enable_udp_controller);
qt_config->beginWriteArray(QStringLiteral("touch_from_button_maps"));
for (std::size_t p = 0; p < Settings::values.touch_from_button_maps.size(); ++p) {
diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp
index e6127f9e6..65c8e59ac 100644
--- a/src/yuzu/configuration/configure_input_advanced.cpp
+++ b/src/yuzu/configuration/configure_input_advanced.cpp
@@ -130,6 +130,7 @@ void ConfigureInputAdvanced::ApplyConfiguration() {
static_cast(ui->mouse_panning_sensitivity->value());
Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked();
Settings::values.enable_raw_input = ui->enable_raw_input->isChecked();
+ Settings::values.enable_udp_controller = ui->enable_udp_controller->isChecked();
}
void ConfigureInputAdvanced::LoadConfiguration() {
@@ -160,6 +161,7 @@ void ConfigureInputAdvanced::LoadConfiguration() {
ui->mouse_panning_sensitivity->setValue(Settings::values.mouse_panning_sensitivity.GetValue());
ui->touchscreen_enabled->setChecked(Settings::values.touchscreen.enabled);
ui->enable_raw_input->setChecked(Settings::values.enable_raw_input.GetValue());
+ ui->enable_udp_controller->setChecked(Settings::values.enable_udp_controller.GetValue());
UpdateUIEnabled();
}
diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui
index 75487a5d0..df0e4d602 100644
--- a/src/yuzu/configuration/configure_input_advanced.ui
+++ b/src/yuzu/configuration/configure_input_advanced.ui
@@ -2642,6 +2642,19 @@
-
+
+
+
+ 0
+ 23
+
+
+
+ Enable UDP controllers (not needed for motion)
+
+
+
+ -
@@ -2654,7 +2667,7 @@
- -
+
-
Mouse sensitivity
@@ -2676,14 +2689,14 @@
- -
+
-
Motion / Touch
- -
+
-
Configure
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 6219a09a8..ec071d6ec 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -78,6 +78,30 @@ QString GetButtonName(Common::Input::ButtonNames button_name) {
return QObject::tr("Y");
case Common::Input::ButtonNames::ButtonStart:
return QObject::tr("Start");
+ case Common::Input::ButtonNames::L1:
+ return QObject::tr("L1");
+ case Common::Input::ButtonNames::L2:
+ return QObject::tr("L2");
+ case Common::Input::ButtonNames::L3:
+ return QObject::tr("L3");
+ case Common::Input::ButtonNames::R1:
+ return QObject::tr("R1");
+ case Common::Input::ButtonNames::R2:
+ return QObject::tr("R2");
+ case Common::Input::ButtonNames::R3:
+ return QObject::tr("R3");
+ case Common::Input::ButtonNames::Circle:
+ return QObject::tr("Circle");
+ case Common::Input::ButtonNames::Cross:
+ return QObject::tr("Cross");
+ case Common::Input::ButtonNames::Square:
+ return QObject::tr("Square");
+ case Common::Input::ButtonNames::Triangle:
+ return QObject::tr("Triangle");
+ case Common::Input::ButtonNames::Share:
+ return QObject::tr("Share");
+ case Common::Input::ButtonNames::Options:
+ return QObject::tr("Options");
default:
return QObject::tr("[undefined]");
}
--
cgit v1.2.3
From 182cd9004f75df21979d0edd47910fecbd129b63 Mon Sep 17 00:00:00 2001
From: german77
Date: Fri, 26 Nov 2021 19:29:08 -0600
Subject: config: Remove vibration configuration
---
src/yuzu/configuration/config.cpp | 17 ------
src/yuzu/configuration/configure_vibration.cpp | 74 --------------------------
src/yuzu/configuration/configure_vibration.h | 3 --
3 files changed, 94 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 38fd6e93b..2c70d0548 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -273,18 +273,6 @@ void Config::ReadPlayerValue(std::size_t player_index) {
}
}
- for (int i = 0; i < Settings::NativeVibration::NumVibrations; ++i) {
- auto& player_vibrations = player.vibrations[i];
-
- player_vibrations =
- qt_config
- ->value(QStringLiteral("%1").arg(player_prefix) +
- QString::fromUtf8(Settings::NativeVibration::mapping[i]),
- QString{})
- .toString()
- .toStdString();
- }
-
for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) {
const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]);
auto& player_motions = player.motions[i];
@@ -891,11 +879,6 @@ void Config::SavePlayerValue(std::size_t player_index) {
QString::fromStdString(player.analogs[i]),
QString::fromStdString(default_param));
}
- for (int i = 0; i < Settings::NativeVibration::NumVibrations; ++i) {
- WriteSetting(QStringLiteral("%1").arg(player_prefix) +
- QString::fromStdString(Settings::NativeVibration::mapping[i]),
- QString::fromStdString(player.vibrations[i]), QString{});
- }
for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) {
const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]);
WriteSetting(QStringLiteral("%1").arg(player_prefix) +
diff --git a/src/yuzu/configuration/configure_vibration.cpp b/src/yuzu/configuration/configure_vibration.cpp
index f1ce7205d..adce04b27 100644
--- a/src/yuzu/configuration/configure_vibration.cpp
+++ b/src/yuzu/configuration/configure_vibration.cpp
@@ -59,80 +59,6 @@ void ConfigureVibration::ApplyConfiguration() {
ui->checkBoxAccurateVibration->isChecked());
}
-void ConfigureVibration::SetVibrationDevices(std::size_t player_index) {
- using namespace Settings::NativeButton;
- static constexpr std::array, 2> buttons{{
- {DLeft, DUp, DRight, DDown, L, ZL}, // Left Buttons
- {A, B, X, Y, R, ZR}, // Right Buttons
- }};
-
- auto& player = Settings::values.players.GetValue()[player_index];
-
- for (std::size_t device_idx = 0; device_idx < buttons.size(); ++device_idx) {
- std::unordered_map params_count;
-
- for (const auto button_index : buttons[device_idx]) {
- const auto& player_button = player.buttons[button_index];
-
- if (params_count.find(player_button) != params_count.end()) {
- ++params_count[player_button];
- continue;
- }
-
- params_count.insert_or_assign(player_button, 1);
- }
-
- const auto it = std::max_element(
- params_count.begin(), params_count.end(),
- [](const auto& lhs, const auto& rhs) { return lhs.second < rhs.second; });
-
- auto& vibration_param_str = player.vibrations[device_idx];
- vibration_param_str.clear();
-
- if (it->first.empty()) {
- continue;
- }
-
- const auto param = Common::ParamPackage(it->first);
-
- const auto engine = param.Get("engine", "");
- const auto guid = param.Get("guid", "");
- const auto port = param.Get("port", 0);
-
- if (engine.empty() || engine == "keyboard" || engine == "mouse" || engine == "tas") {
- continue;
- }
-
- vibration_param_str += fmt::format("engine:{}", engine);
-
- if (port != 0) {
- vibration_param_str += fmt::format(",port:{}", port);
- }
- if (!guid.empty()) {
- vibration_param_str += fmt::format(",guid:{}", guid);
- }
- }
-
- if (player.vibrations[0] != player.vibrations[1]) {
- return;
- }
-
- if (!player.vibrations[0].empty() &&
- player.controller_type != Settings::ControllerType::RightJoycon) {
- player.vibrations[1].clear();
- } else if (!player.vibrations[1].empty() &&
- player.controller_type == Settings::ControllerType::RightJoycon) {
- player.vibrations[0].clear();
- }
-}
-
-void ConfigureVibration::SetAllVibrationDevices() {
- // Set vibration devices for all player indices including handheld
- for (std::size_t player_idx = 0; player_idx < NUM_PLAYERS + 1; ++player_idx) {
- SetVibrationDevices(player_idx);
- }
-}
-
void ConfigureVibration::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
diff --git a/src/yuzu/configuration/configure_vibration.h b/src/yuzu/configuration/configure_vibration.h
index 07411a86f..37bbc2653 100644
--- a/src/yuzu/configuration/configure_vibration.h
+++ b/src/yuzu/configuration/configure_vibration.h
@@ -24,9 +24,6 @@ public:
void ApplyConfiguration();
- static void SetVibrationDevices(std::size_t player_index);
- static void SetAllVibrationDevices();
-
private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
--
cgit v1.2.3
From 51df96b7c0ac7086b26fa766e87e18749e0395b1 Mon Sep 17 00:00:00 2001
From: german77
Date: Sat, 27 Nov 2021 20:05:45 -0600
Subject: settings: Add debug setting to enable all controllers
---
src/yuzu/configuration/config.cpp | 2 ++
src/yuzu/configuration/configure_debug.cpp | 2 ++
src/yuzu/configuration/configure_debug.ui | 7 +++++
src/yuzu/configuration/configure_input_player.cpp | 34 +++++++++++++++++++++++
4 files changed, 45 insertions(+)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 2c70d0548..463d500c2 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -508,6 +508,7 @@ void Config::ReadDebuggingValues() {
ReadBasicSetting(Settings::values.extended_logging);
ReadBasicSetting(Settings::values.use_debug_asserts);
ReadBasicSetting(Settings::values.use_auto_stub);
+ ReadBasicSetting(Settings::values.enable_all_controllers);
qt_config->endGroup();
}
@@ -1051,6 +1052,7 @@ void Config::SaveDebuggingValues() {
WriteBasicSetting(Settings::values.quest_flag);
WriteBasicSetting(Settings::values.use_debug_asserts);
WriteBasicSetting(Settings::values.disable_macro_jit);
+ WriteBasicSetting(Settings::values.enable_all_controllers);
qt_config->endGroup();
}
diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp
index 07bfa0360..633fc295b 100644
--- a/src/yuzu/configuration/configure_debug.cpp
+++ b/src/yuzu/configuration/configure_debug.cpp
@@ -42,6 +42,7 @@ void ConfigureDebug::SetConfiguration() {
ui->quest_flag->setChecked(Settings::values.quest_flag.GetValue());
ui->use_debug_asserts->setChecked(Settings::values.use_debug_asserts.GetValue());
ui->use_auto_stub->setChecked(Settings::values.use_auto_stub.GetValue());
+ ui->enable_all_controllers->setChecked(Settings::values.enable_all_controllers.GetValue());
ui->enable_graphics_debugging->setEnabled(runtime_lock);
ui->enable_graphics_debugging->setChecked(Settings::values.renderer_debug.GetValue());
ui->enable_shader_feedback->setEnabled(runtime_lock);
@@ -67,6 +68,7 @@ void ConfigureDebug::ApplyConfiguration() {
Settings::values.quest_flag = ui->quest_flag->isChecked();
Settings::values.use_debug_asserts = ui->use_debug_asserts->isChecked();
Settings::values.use_auto_stub = ui->use_auto_stub->isChecked();
+ Settings::values.enable_all_controllers = ui->enable_all_controllers->isChecked();
Settings::values.renderer_debug = ui->enable_graphics_debugging->isChecked();
Settings::values.renderer_shader_feedback = ui->enable_shader_feedback->isChecked();
Settings::values.cpu_debug_mode = ui->enable_cpu_debugging->isChecked();
diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui
index b884a56b0..0f3b51c8d 100644
--- a/src/yuzu/configuration/configure_debug.ui
+++ b/src/yuzu/configuration/configure_debug.ui
@@ -198,6 +198,13 @@
+ -
+
+
+ Enable all Controller Types
+
+
+
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index ec071d6ec..16284d5a6 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -947,6 +947,40 @@ void ConfigureInputPlayer::SetConnectableControllers() {
Core::HID::NpadStyleIndex::GameCube);
ui->comboControllerType->addItem(tr("GameCube Controller"));
}
+
+ // Disable all unsupported controllers
+ if (!Settings::values.enable_all_controllers) {
+ return;
+ }
+ if (enable_all || npad_style_set.palma == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::Pokeball);
+ ui->comboControllerType->addItem(tr("Poke Ball Plus"));
+ }
+
+ if (enable_all || npad_style_set.lark == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::NES);
+ ui->comboControllerType->addItem(tr("NES Controller"));
+ }
+
+ if (enable_all || npad_style_set.lucia == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::SNES);
+ ui->comboControllerType->addItem(tr("SNES Controller"));
+ }
+
+ if (enable_all || npad_style_set.lagoon == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::N64);
+ ui->comboControllerType->addItem(tr("N64 Controller"));
+ }
+
+ if (enable_all || npad_style_set.lager == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::SegaGenesis);
+ ui->comboControllerType->addItem(tr("Sega Genesis"));
+ }
};
if (!is_powered_on) {
--
cgit v1.2.3
From 410df5446eb23e75582020790bce2e8241da88ff Mon Sep 17 00:00:00 2001
From: Morph <39850852+Morph1984@users.noreply.github.com>
Date: Mon, 29 Nov 2021 17:22:59 -0500
Subject: general: Fix handheld typo
---
src/yuzu/configuration/configure_input_player.cpp | 32 +++++++++++------------
1 file changed, 16 insertions(+), 16 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 16284d5a6..34099bc83 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -246,15 +246,15 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
if (player_index == 0) {
auto* emulated_controller_p1 =
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
- auto* emulated_controller_hanheld =
+ auto* emulated_controller_handheld =
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
emulated_controller_p1->SaveCurrentConfig();
emulated_controller_p1->EnableConfiguration();
- emulated_controller_hanheld->SaveCurrentConfig();
- emulated_controller_hanheld->EnableConfiguration();
- if (emulated_controller_hanheld->IsConnected(true)) {
+ emulated_controller_handheld->SaveCurrentConfig();
+ emulated_controller_handheld->EnableConfiguration();
+ if (emulated_controller_handheld->IsConnected(true)) {
emulated_controller_p1->Disconnect();
- emulated_controller = emulated_controller_hanheld;
+ emulated_controller = emulated_controller_handheld;
} else {
emulated_controller = emulated_controller_p1;
}
@@ -590,19 +590,19 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
if (player_index == 0) {
auto* emulated_controller_p1 =
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
- auto* emulated_controller_hanheld =
+ auto* emulated_controller_handheld =
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
bool is_connected = emulated_controller->IsConnected(true);
emulated_controller_p1->SetNpadStyleIndex(type);
- emulated_controller_hanheld->SetNpadStyleIndex(type);
+ emulated_controller_handheld->SetNpadStyleIndex(type);
if (is_connected) {
if (type == Core::HID::NpadStyleIndex::Handheld) {
emulated_controller_p1->Disconnect();
- emulated_controller_hanheld->Connect();
- emulated_controller = emulated_controller_hanheld;
+ emulated_controller_handheld->Connect();
+ emulated_controller = emulated_controller_handheld;
} else {
- emulated_controller_hanheld->Disconnect();
+ emulated_controller_handheld->Disconnect();
emulated_controller_p1->Connect();
emulated_controller = emulated_controller_p1;
}
@@ -650,10 +650,10 @@ ConfigureInputPlayer::~ConfigureInputPlayer() {
if (player_index == 0) {
auto* emulated_controller_p1 =
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
- auto* emulated_controller_hanheld =
+ auto* emulated_controller_handheld =
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
emulated_controller_p1->DisableConfiguration();
- emulated_controller_hanheld->DisableConfiguration();
+ emulated_controller_handheld->DisableConfiguration();
} else {
emulated_controller->DisableConfiguration();
}
@@ -663,14 +663,14 @@ void ConfigureInputPlayer::ApplyConfiguration() {
if (player_index == 0) {
auto* emulated_controller_p1 =
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
- auto* emulated_controller_hanheld =
+ auto* emulated_controller_handheld =
hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
emulated_controller_p1->DisableConfiguration();
emulated_controller_p1->SaveCurrentConfig();
emulated_controller_p1->EnableConfiguration();
- emulated_controller_hanheld->DisableConfiguration();
- emulated_controller_hanheld->SaveCurrentConfig();
- emulated_controller_hanheld->EnableConfiguration();
+ emulated_controller_handheld->DisableConfiguration();
+ emulated_controller_handheld->SaveCurrentConfig();
+ emulated_controller_handheld->EnableConfiguration();
return;
}
emulated_controller->DisableConfiguration();
--
cgit v1.2.3
From 7fe455e42ea1a8d5e702258212d54f21f1f31610 Mon Sep 17 00:00:00 2001
From: german77
Date: Sat, 4 Dec 2021 19:37:03 -0600
Subject: core/hid: Ensure only valid npad are connected
---
src/yuzu/configuration/configure_input_player.cpp | 131 ++++++++++------------
1 file changed, 61 insertions(+), 70 deletions(-)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 34099bc83..8a8be8e40 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -907,88 +907,79 @@ void ConfigureInputPlayer::UpdateUI() {
}
void ConfigureInputPlayer::SetConnectableControllers() {
- const auto add_controllers = [this](bool enable_all,
- Core::HID::NpadStyleTag npad_style_set = {}) {
- index_controller_type_pairs.clear();
- ui->comboControllerType->clear();
-
- if (enable_all || npad_style_set.fullkey == 1) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::ProController);
- ui->comboControllerType->addItem(tr("Pro Controller"));
- }
-
- if (enable_all || npad_style_set.joycon_dual == 1) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::JoyconDual);
- ui->comboControllerType->addItem(tr("Dual Joycons"));
- }
+ Core::HID::NpadStyleTag npad_style_set = hid_core.GetSupportedStyleTag();
+ index_controller_type_pairs.clear();
+ ui->comboControllerType->clear();
- if (enable_all || npad_style_set.joycon_left == 1) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::JoyconLeft);
- ui->comboControllerType->addItem(tr("Left Joycon"));
- }
+ if (npad_style_set.fullkey == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::ProController);
+ ui->comboControllerType->addItem(tr("Pro Controller"));
+ }
- if (enable_all || npad_style_set.joycon_right == 1) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::JoyconRight);
- ui->comboControllerType->addItem(tr("Right Joycon"));
- }
+ if (npad_style_set.joycon_dual == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::JoyconDual);
+ ui->comboControllerType->addItem(tr("Dual Joycons"));
+ }
- if (player_index == 0 && (enable_all || npad_style_set.handheld == 1)) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::Handheld);
- ui->comboControllerType->addItem(tr("Handheld"));
- }
+ if (npad_style_set.joycon_left == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::JoyconLeft);
+ ui->comboControllerType->addItem(tr("Left Joycon"));
+ }
- if (enable_all || npad_style_set.gamecube == 1) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::GameCube);
- ui->comboControllerType->addItem(tr("GameCube Controller"));
- }
+ if (npad_style_set.joycon_right == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::JoyconRight);
+ ui->comboControllerType->addItem(tr("Right Joycon"));
+ }
- // Disable all unsupported controllers
- if (!Settings::values.enable_all_controllers) {
- return;
- }
- if (enable_all || npad_style_set.palma == 1) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::Pokeball);
- ui->comboControllerType->addItem(tr("Poke Ball Plus"));
- }
+ if (player_index == 0 && npad_style_set.handheld == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::Handheld);
+ ui->comboControllerType->addItem(tr("Handheld"));
+ }
- if (enable_all || npad_style_set.lark == 1) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::NES);
- ui->comboControllerType->addItem(tr("NES Controller"));
- }
+ if (npad_style_set.gamecube == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::GameCube);
+ ui->comboControllerType->addItem(tr("GameCube Controller"));
+ }
- if (enable_all || npad_style_set.lucia == 1) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::SNES);
- ui->comboControllerType->addItem(tr("SNES Controller"));
- }
+ // Disable all unsupported controllers
+ if (!Settings::values.enable_all_controllers) {
+ return;
+ }
+ if (npad_style_set.palma == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::Pokeball);
+ ui->comboControllerType->addItem(tr("Poke Ball Plus"));
+ }
- if (enable_all || npad_style_set.lagoon == 1) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::N64);
- ui->comboControllerType->addItem(tr("N64 Controller"));
- }
+ if (npad_style_set.lark == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::NES);
+ ui->comboControllerType->addItem(tr("NES Controller"));
+ }
- if (enable_all || npad_style_set.lager == 1) {
- index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
- Core::HID::NpadStyleIndex::SegaGenesis);
- ui->comboControllerType->addItem(tr("Sega Genesis"));
- }
- };
+ if (npad_style_set.lucia == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::SNES);
+ ui->comboControllerType->addItem(tr("SNES Controller"));
+ }
- if (!is_powered_on) {
- add_controllers(true);
- return;
+ if (npad_style_set.lagoon == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::N64);
+ ui->comboControllerType->addItem(tr("N64 Controller"));
}
- add_controllers(false, hid_core.GetSupportedStyleTag());
+ if (npad_style_set.lager == 1) {
+ index_controller_type_pairs.emplace_back(ui->comboControllerType->count(),
+ Core::HID::NpadStyleIndex::SegaGenesis);
+ ui->comboControllerType->addItem(tr("Sega Genesis"));
+ }
}
Core::HID::NpadStyleIndex ConfigureInputPlayer::GetControllerTypeFromIndex(int index) const {
--
cgit v1.2.3
From b64d28492a24927f0702a7c0481134008b1bf455 Mon Sep 17 00:00:00 2001
From: ameerj <52414509+ameerj@users.noreply.github.com>
Date: Sun, 12 Dec 2021 15:46:42 -0500
Subject: game_list: Add persistent setting for the favorites row expanded
state
Previously, the favorites row was always expanded on launch. This change introduces a persistent setting that allows the favorites row's expanded state to be remembered between launches.
---
src/yuzu/configuration/config.cpp | 2 ++
1 file changed, 2 insertions(+)
(limited to 'src/yuzu/configuration')
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 463d500c2..0f679c37e 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -776,6 +776,7 @@ void Config::ReadUIGamelistValues() {
ReadBasicSetting(UISettings::values.row_1_text_id);
ReadBasicSetting(UISettings::values.row_2_text_id);
ReadBasicSetting(UISettings::values.cache_game_list);
+ ReadBasicSetting(UISettings::values.favorites_expanded);
const int favorites_size = qt_config->beginReadArray(QStringLiteral("favorites"));
for (int i = 0; i < favorites_size; i++) {
qt_config->setArrayIndex(i);
@@ -1300,6 +1301,7 @@ void Config::SaveUIGamelistValues() {
WriteBasicSetting(UISettings::values.row_1_text_id);
WriteBasicSetting(UISettings::values.row_2_text_id);
WriteBasicSetting(UISettings::values.cache_game_list);
+ WriteBasicSetting(UISettings::values.favorites_expanded);
qt_config->beginWriteArray(QStringLiteral("favorites"));
for (int i = 0; i < UISettings::values.favorited_ids.size(); i++) {
qt_config->setArrayIndex(i);
--
cgit v1.2.3