summaryrefslogtreecommitdiff
path: root/src/core/hid/emulated_controller.cpp
diff options
context:
space:
mode:
authorGravatar liamwhite2023-11-23 12:36:19 -0500
committerGravatar GitHub2023-11-23 12:36:19 -0500
commit0b766e4523dea156d69aab1a2a43b55f50c65071 (patch)
tree44715eb026414d084f3f493f137b578339884a99 /src/core/hid/emulated_controller.cpp
parentMerge pull request #12123 from merryhime/explicit-this (diff)
parentservice: hid: Create appropriate hid resources (diff)
downloadyuzu-0b766e4523dea156d69aab1a2a43b55f50c65071.tar.gz
yuzu-0b766e4523dea156d69aab1a2a43b55f50c65071.tar.xz
yuzu-0b766e4523dea156d69aab1a2a43b55f50c65071.zip
Merge pull request #12076 from german77/resource
service: hid: Create appropriate hid resources
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
-rw-r--r--src/core/hid/emulated_controller.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 34927cddd..a22015ada 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -8,6 +8,7 @@
8#include "common/thread.h" 8#include "common/thread.h"
9#include "core/hid/emulated_controller.h" 9#include "core/hid/emulated_controller.h"
10#include "core/hid/input_converter.h" 10#include "core/hid/input_converter.h"
11#include "core/hle/service/hid/hid_util.h"
11 12
12namespace Core::HID { 13namespace Core::HID {
13constexpr s32 HID_JOYSTICK_MAX = 0x7fff; 14constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
@@ -82,7 +83,7 @@ Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadStyleInde
82} 83}
83 84
84void EmulatedController::ReloadFromSettings() { 85void EmulatedController::ReloadFromSettings() {
85 const auto player_index = NpadIdTypeToIndex(npad_id_type); 86 const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
86 const auto& player = Settings::values.players.GetValue()[player_index]; 87 const auto& player = Settings::values.players.GetValue()[player_index];
87 88
88 for (std::size_t index = 0; index < player.buttons.size(); ++index) { 89 for (std::size_t index = 0; index < player.buttons.size(); ++index) {
@@ -118,7 +119,7 @@ void EmulatedController::ReloadFromSettings() {
118} 119}
119 120
120void EmulatedController::ReloadColorsFromSettings() { 121void EmulatedController::ReloadColorsFromSettings() {
121 const auto player_index = NpadIdTypeToIndex(npad_id_type); 122 const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
122 const auto& player = Settings::values.players.GetValue()[player_index]; 123 const auto& player = Settings::values.players.GetValue()[player_index];
123 124
124 // Avoid updating colors if overridden by physical controller 125 // Avoid updating colors if overridden by physical controller
@@ -215,7 +216,7 @@ void EmulatedController::LoadDevices() {
215} 216}
216 217
217void EmulatedController::LoadTASParams() { 218void EmulatedController::LoadTASParams() {
218 const auto player_index = NpadIdTypeToIndex(npad_id_type); 219 const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
219 Common::ParamPackage common_params{}; 220 Common::ParamPackage common_params{};
220 common_params.Set("engine", "tas"); 221 common_params.Set("engine", "tas");
221 common_params.Set("port", static_cast<int>(player_index)); 222 common_params.Set("port", static_cast<int>(player_index));
@@ -264,7 +265,7 @@ void EmulatedController::LoadTASParams() {
264} 265}
265 266
266void EmulatedController::LoadVirtualGamepadParams() { 267void EmulatedController::LoadVirtualGamepadParams() {
267 const auto player_index = NpadIdTypeToIndex(npad_id_type); 268 const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
268 Common::ParamPackage common_params{}; 269 Common::ParamPackage common_params{};
269 common_params.Set("engine", "virtual_gamepad"); 270 common_params.Set("engine", "virtual_gamepad");
270 common_params.Set("port", static_cast<int>(player_index)); 271 common_params.Set("port", static_cast<int>(player_index));
@@ -615,7 +616,7 @@ bool EmulatedController::IsConfiguring() const {
615} 616}
616 617
617void EmulatedController::SaveCurrentConfig() { 618void EmulatedController::SaveCurrentConfig() {
618 const auto player_index = NpadIdTypeToIndex(npad_id_type); 619 const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
619 auto& player = Settings::values.players.GetValue()[player_index]; 620 auto& player = Settings::values.players.GetValue()[player_index];
620 player.connected = is_connected; 621 player.connected = is_connected;
621 player.controller_type = MapNPadToSettingsType(npad_type); 622 player.controller_type = MapNPadToSettingsType(npad_type);
@@ -1212,7 +1213,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
1212 if (!output_devices[device_index]) { 1213 if (!output_devices[device_index]) {
1213 return false; 1214 return false;
1214 } 1215 }
1215 const auto player_index = NpadIdTypeToIndex(npad_id_type); 1216 const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
1216 const auto& player = Settings::values.players.GetValue()[player_index]; 1217 const auto& player = Settings::values.players.GetValue()[player_index];
1217 const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f; 1218 const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f;
1218 1219
@@ -1238,7 +1239,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
1238} 1239}
1239 1240
1240bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { 1241bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {
1241 const auto player_index = NpadIdTypeToIndex(npad_id_type); 1242 const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
1242 const auto& player = Settings::values.players.GetValue()[player_index]; 1243 const auto& player = Settings::values.players.GetValue()[player_index];
1243 1244
1244 if (!player.vibration_enabled) { 1245 if (!player.vibration_enabled) {
@@ -1648,7 +1649,7 @@ void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) {
1648 } 1649 }
1649 if (is_connected) { 1650 if (is_connected) {
1650 LOG_WARNING(Service_HID, "Controller {} type changed while it's connected", 1651 LOG_WARNING(Service_HID, "Controller {} type changed while it's connected",
1651 NpadIdTypeToIndex(npad_id_type)); 1652 Service::HID::NpadIdTypeToIndex(npad_id_type));
1652 } 1653 }
1653 npad_type = npad_type_; 1654 npad_type = npad_type_;
1654} 1655}