summaryrefslogtreecommitdiff
path: root/src/core/hid
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hid')
-rw-r--r--src/core/hid/emulated_controller.cpp26
-rw-r--r--src/core/hid/emulated_controller.h7
-rw-r--r--src/core/hid/hid_types.h12
3 files changed, 35 insertions, 10 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 8c3895937..085ff3fda 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -84,18 +84,19 @@ void EmulatedController::ReloadFromSettings() {
84 motion_params[index] = Common::ParamPackage(player.motions[index]); 84 motion_params[index] = Common::ParamPackage(player.motions[index]);
85 } 85 }
86 86
87 controller.colors_state.fullkey = {
88 .body = GetNpadColor(player.body_color_left),
89 .button = GetNpadColor(player.button_color_left),
90 };
87 controller.colors_state.left = { 91 controller.colors_state.left = {
88 .body = player.body_color_left, 92 .body = GetNpadColor(player.body_color_left),
89 .button = player.button_color_left, 93 .button = GetNpadColor(player.button_color_left),
90 }; 94 };
91 95 controller.colors_state.left = {
92 controller.colors_state.right = { 96 .body = GetNpadColor(player.body_color_right),
93 .body = player.body_color_right, 97 .button = GetNpadColor(player.button_color_right),
94 .button = player.button_color_right,
95 }; 98 };
96 99
97 controller.colors_state.fullkey = controller.colors_state.left;
98
99 // Other or debug controller should always be a pro controller 100 // Other or debug controller should always be a pro controller
100 if (npad_id_type != NpadIdType::Other) { 101 if (npad_id_type != NpadIdType::Other) {
101 SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); 102 SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
@@ -1310,6 +1311,15 @@ const CameraState& EmulatedController::GetCamera() const {
1310 return controller.camera_state; 1311 return controller.camera_state;
1311} 1312}
1312 1313
1314NpadColor EmulatedController::GetNpadColor(u32 color) {
1315 return {
1316 .r = static_cast<u8>((color >> 16) & 0xFF),
1317 .g = static_cast<u8>((color >> 8) & 0xFF),
1318 .b = static_cast<u8>(color & 0xFF),
1319 .a = 0xff,
1320 };
1321}
1322
1313void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_npad_service_update) { 1323void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_npad_service_update) {
1314 std::scoped_lock lock{callback_mutex}; 1324 std::scoped_lock lock{callback_mutex};
1315 for (const auto& poller_pair : callback_list) { 1325 for (const auto& poller_pair : callback_list) {
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index 823c1700c..cbd7c26d3 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -425,6 +425,13 @@ private:
425 void SetCamera(const Common::Input::CallbackStatus& callback); 425 void SetCamera(const Common::Input::CallbackStatus& callback);
426 426
427 /** 427 /**
428 * Converts a color format from bgra to rgba
429 * @param color in bgra format
430 * @return NpadColor in rgba format
431 */
432 NpadColor GetNpadColor(u32 color);
433
434 /**
428 * Triggers a callback that something has changed on the controller status 435 * Triggers a callback that something has changed on the controller status
429 * @param type Input type of the event to trigger 436 * @param type Input type of the event to trigger
430 * @param is_service_update indicates if this event should only be sent to HID services 437 * @param is_service_update indicates if this event should only be sent to HID services
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h
index e49223016..e3b1cfbc6 100644
--- a/src/core/hid/hid_types.h
+++ b/src/core/hid/hid_types.h
@@ -327,10 +327,18 @@ struct TouchState {
327}; 327};
328static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size"); 328static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size");
329 329
330struct NpadColor {
331 u8 r{};
332 u8 g{};
333 u8 b{};
334 u8 a{};
335};
336static_assert(sizeof(NpadColor) == 4, "NpadColor is an invalid size");
337
330// This is nn::hid::NpadControllerColor 338// This is nn::hid::NpadControllerColor
331struct NpadControllerColor { 339struct NpadControllerColor {
332 u32 body{}; 340 NpadColor body{};
333 u32 button{}; 341 NpadColor button{};
334}; 342};
335static_assert(sizeof(NpadControllerColor) == 8, "NpadControllerColor is an invalid size"); 343static_assert(sizeof(NpadControllerColor) == 8, "NpadControllerColor is an invalid size");
336 344