summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar german772021-11-26 19:29:08 -0600
committerGravatar german772021-11-26 19:31:04 -0600
commit182cd9004f75df21979d0edd47910fecbd129b63 (patch)
tree0e53bca95c6cdf14ab763d425c3f776fb466edf4 /src
parentapplet/controller: Enable configuring mode while the applet is open (diff)
downloadyuzu-182cd9004f75df21979d0edd47910fecbd129b63.tar.gz
yuzu-182cd9004f75df21979d0edd47910fecbd129b63.tar.xz
yuzu-182cd9004f75df21979d0edd47910fecbd129b63.zip
config: Remove vibration configuration
Diffstat (limited to 'src')
-rw-r--r--src/common/settings_input.h2
-rw-r--r--src/core/hid/emulated_controller.cpp5
-rw-r--r--src/yuzu/applets/qt_controller.cpp4
-rw-r--r--src/yuzu/configuration/config.cpp17
-rw-r--r--src/yuzu/configuration/configure_vibration.cpp74
-rw-r--r--src/yuzu/configuration/configure_vibration.h3
-rw-r--r--src/yuzu/main.cpp2
7 files changed, 3 insertions, 104 deletions
diff --git a/src/common/settings_input.h b/src/common/settings_input.h
index 9a8804488..9e3df7376 100644
--- a/src/common/settings_input.h
+++ b/src/common/settings_input.h
@@ -357,7 +357,6 @@ constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods;
357using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>; 357using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>;
358using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>; 358using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>;
359using MotionsRaw = std::array<std::string, NativeMotion::NumMotions>; 359using MotionsRaw = std::array<std::string, NativeMotion::NumMotions>;
360using VibrationsRaw = std::array<std::string, NativeVibration::NumVibrations>;
361 360
362constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28; 361constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28;
363constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A; 362constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A;
@@ -378,7 +377,6 @@ struct PlayerInput {
378 ControllerType controller_type; 377 ControllerType controller_type;
379 ButtonsRaw buttons; 378 ButtonsRaw buttons;
380 AnalogsRaw analogs; 379 AnalogsRaw analogs;
381 VibrationsRaw vibrations;
382 MotionsRaw motions; 380 MotionsRaw motions;
383 381
384 bool vibration_enabled; 382 bool vibration_enabled;
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 54d4ed93d..06ae41c3e 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -92,10 +92,11 @@ void EmulatedController::ReloadFromSettings() {
92 92
93 ReloadInput(); 93 ReloadInput();
94} 94}
95
95void EmulatedController::LoadDevices() { 96void EmulatedController::LoadDevices() {
96 // TODO(german77): Use more buttons to detect the correct device 97 // TODO(german77): Use more buttons to detect the correct device
97 const auto left_joycon = button_params[Settings::NativeButton::A]; 98 const auto left_joycon = button_params[Settings::NativeButton::DRight];
98 const auto right_joycon = button_params[Settings::NativeButton::DRight]; 99 const auto right_joycon = button_params[Settings::NativeButton::A];
99 100
100 // Triggers for GC controllers 101 // Triggers for GC controllers
101 trigger_params[LeftIndex] = button_params[Settings::NativeButton::ZL]; 102 trigger_params[LeftIndex] = button_params[Settings::NativeButton::ZL];
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp
index eaa0f39f2..589e0577a 100644
--- a/src/yuzu/applets/qt_controller.cpp
+++ b/src/yuzu/applets/qt_controller.cpp
@@ -517,16 +517,12 @@ void QtControllerSelectorDialog::UpdateControllerState(std::size_t player_index)
517 517
518 if (controller->GetNpadStyleIndex(true) == controller_type && 518 if (controller->GetNpadStyleIndex(true) == controller_type &&
519 controller->IsConnected(true) == player_connected) { 519 controller->IsConnected(true) == player_connected) {
520 // Set vibration devices in the event that the input device has changed.
521 ConfigureVibration::SetVibrationDevices(player_index);
522 return; 520 return;
523 } 521 }
524 522
525 // Disconnect the controller first. 523 // Disconnect the controller first.
526 UpdateController(controller, controller_type, false); 524 UpdateController(controller, controller_type, false);
527 525
528 ConfigureVibration::SetVibrationDevices(player_index);
529
530 // Handheld 526 // Handheld
531 if (player_index == 0) { 527 if (player_index == 0) {
532 if (controller_type == Core::HID::NpadStyleIndex::Handheld) { 528 if (controller_type == Core::HID::NpadStyleIndex::Handheld) {
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) {
273 } 273 }
274 } 274 }
275 275
276 for (int i = 0; i < Settings::NativeVibration::NumVibrations; ++i) {
277 auto& player_vibrations = player.vibrations[i];
278
279 player_vibrations =
280 qt_config
281 ->value(QStringLiteral("%1").arg(player_prefix) +
282 QString::fromUtf8(Settings::NativeVibration::mapping[i]),
283 QString{})
284 .toString()
285 .toStdString();
286 }
287
288 for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) { 276 for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) {
289 const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]); 277 const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]);
290 auto& player_motions = player.motions[i]; 278 auto& player_motions = player.motions[i];
@@ -891,11 +879,6 @@ void Config::SavePlayerValue(std::size_t player_index) {
891 QString::fromStdString(player.analogs[i]), 879 QString::fromStdString(player.analogs[i]),
892 QString::fromStdString(default_param)); 880 QString::fromStdString(default_param));
893 } 881 }
894 for (int i = 0; i < Settings::NativeVibration::NumVibrations; ++i) {
895 WriteSetting(QStringLiteral("%1").arg(player_prefix) +
896 QString::fromStdString(Settings::NativeVibration::mapping[i]),
897 QString::fromStdString(player.vibrations[i]), QString{});
898 }
899 for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) { 882 for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) {
900 const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]); 883 const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]);
901 WriteSetting(QStringLiteral("%1").arg(player_prefix) + 884 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() {
59 ui->checkBoxAccurateVibration->isChecked()); 59 ui->checkBoxAccurateVibration->isChecked());
60} 60}
61 61
62void ConfigureVibration::SetVibrationDevices(std::size_t player_index) {
63 using namespace Settings::NativeButton;
64 static constexpr std::array<std::array<Settings::NativeButton::Values, 6>, 2> buttons{{
65 {DLeft, DUp, DRight, DDown, L, ZL}, // Left Buttons
66 {A, B, X, Y, R, ZR}, // Right Buttons
67 }};
68
69 auto& player = Settings::values.players.GetValue()[player_index];
70
71 for (std::size_t device_idx = 0; device_idx < buttons.size(); ++device_idx) {
72 std::unordered_map<std::string, int> params_count;
73
74 for (const auto button_index : buttons[device_idx]) {
75 const auto& player_button = player.buttons[button_index];
76
77 if (params_count.find(player_button) != params_count.end()) {
78 ++params_count[player_button];
79 continue;
80 }
81
82 params_count.insert_or_assign(player_button, 1);
83 }
84
85 const auto it = std::max_element(
86 params_count.begin(), params_count.end(),
87 [](const auto& lhs, const auto& rhs) { return lhs.second < rhs.second; });
88
89 auto& vibration_param_str = player.vibrations[device_idx];
90 vibration_param_str.clear();
91
92 if (it->first.empty()) {
93 continue;
94 }
95
96 const auto param = Common::ParamPackage(it->first);
97
98 const auto engine = param.Get("engine", "");
99 const auto guid = param.Get("guid", "");
100 const auto port = param.Get("port", 0);
101
102 if (engine.empty() || engine == "keyboard" || engine == "mouse" || engine == "tas") {
103 continue;
104 }
105
106 vibration_param_str += fmt::format("engine:{}", engine);
107
108 if (port != 0) {
109 vibration_param_str += fmt::format(",port:{}", port);
110 }
111 if (!guid.empty()) {
112 vibration_param_str += fmt::format(",guid:{}", guid);
113 }
114 }
115
116 if (player.vibrations[0] != player.vibrations[1]) {
117 return;
118 }
119
120 if (!player.vibrations[0].empty() &&
121 player.controller_type != Settings::ControllerType::RightJoycon) {
122 player.vibrations[1].clear();
123 } else if (!player.vibrations[1].empty() &&
124 player.controller_type == Settings::ControllerType::RightJoycon) {
125 player.vibrations[0].clear();
126 }
127}
128
129void ConfigureVibration::SetAllVibrationDevices() {
130 // Set vibration devices for all player indices including handheld
131 for (std::size_t player_idx = 0; player_idx < NUM_PLAYERS + 1; ++player_idx) {
132 SetVibrationDevices(player_idx);
133 }
134}
135
136void ConfigureVibration::changeEvent(QEvent* event) { 62void ConfigureVibration::changeEvent(QEvent* event) {
137 if (event->type() == QEvent::LanguageChange) { 63 if (event->type() == QEvent::LanguageChange) {
138 RetranslateUI(); 64 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:
24 24
25 void ApplyConfiguration(); 25 void ApplyConfiguration();
26 26
27 static void SetVibrationDevices(std::size_t player_index);
28 static void SetAllVibrationDevices();
29
30private: 27private:
31 void changeEvent(QEvent* event) override; 28 void changeEvent(QEvent* event) override;
32 void RetranslateUI(); 29 void RetranslateUI();
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 09ea21f5e..552db6387 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -1380,8 +1380,6 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
1380 Config per_game_config(*system, config_file_name, Config::ConfigType::PerGameConfig); 1380 Config per_game_config(*system, config_file_name, Config::ConfigType::PerGameConfig);
1381 } 1381 }
1382 1382
1383 ConfigureVibration::SetAllVibrationDevices();
1384
1385 // Disable fps limit toggle when booting a new title 1383 // Disable fps limit toggle when booting a new title
1386 Settings::values.disable_fps_limit.SetValue(false); 1384 Settings::values.disable_fps_limit.SetValue(false);
1387 1385