mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
service: hid: Implement GetPlayerLedPattern accurately
This commit is contained in:
parent
ba4cee1812
commit
a0f7f2b309
@ -8,6 +8,7 @@
|
|||||||
#include "core/hle/kernel/k_shared_memory.h"
|
#include "core/hle/kernel/k_shared_memory.h"
|
||||||
#include "core/hle/kernel/k_transfer_memory.h"
|
#include "core/hle/kernel/k_transfer_memory.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
#include "core/hle/service/hid/hid_server.h"
|
#include "core/hle/service/hid/hid_server.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
@ -153,7 +154,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
|
|||||||
{104, &IHidServer::DeactivateNpad, "DeactivateNpad"},
|
{104, &IHidServer::DeactivateNpad, "DeactivateNpad"},
|
||||||
{106, &IHidServer::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"},
|
{106, &IHidServer::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"},
|
||||||
{107, &IHidServer::DisconnectNpad, "DisconnectNpad"},
|
{107, &IHidServer::DisconnectNpad, "DisconnectNpad"},
|
||||||
{108, &IHidServer::GetPlayerLedPattern, "GetPlayerLedPattern"},
|
{108, C<&IHidServer::GetPlayerLedPattern>, "GetPlayerLedPattern"},
|
||||||
{109, &IHidServer::ActivateNpadWithRevision, "ActivateNpadWithRevision"},
|
{109, &IHidServer::ActivateNpadWithRevision, "ActivateNpadWithRevision"},
|
||||||
{120, &IHidServer::SetNpadJoyHoldType, "SetNpadJoyHoldType"},
|
{120, &IHidServer::SetNpadJoyHoldType, "SetNpadJoyHoldType"},
|
||||||
{121, &IHidServer::GetNpadJoyHoldType, "GetNpadJoyHoldType"},
|
{121, &IHidServer::GetNpadJoyHoldType, "GetNpadJoyHoldType"},
|
||||||
@ -1136,19 +1137,39 @@ void IHidServer::DisconnectNpad(HLERequestContext& ctx) {
|
|||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IHidServer::GetPlayerLedPattern(HLERequestContext& ctx) {
|
Result IHidServer::GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern,
|
||||||
IPC::RequestParser rp{ctx};
|
Core::HID::NpadIdType npad_id) {
|
||||||
const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()};
|
|
||||||
|
|
||||||
Core::HID::LedPattern pattern{0, 0, 0, 0};
|
|
||||||
auto controller = GetResourceManager()->GetNpad();
|
|
||||||
const auto result = controller->GetLedPattern(npad_id, pattern);
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id);
|
LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
switch (npad_id) {
|
||||||
rb.Push(result);
|
case Core::HID::NpadIdType::Player1:
|
||||||
rb.Push(pattern.raw);
|
*out_led_pattern = Core::HID::LedPattern{1, 0, 0, 0};
|
||||||
|
R_SUCCEED();
|
||||||
|
case Core::HID::NpadIdType::Player2:
|
||||||
|
*out_led_pattern = Core::HID::LedPattern{1, 1, 0, 0};
|
||||||
|
R_SUCCEED();
|
||||||
|
case Core::HID::NpadIdType::Player3:
|
||||||
|
*out_led_pattern = Core::HID::LedPattern{1, 1, 1, 0};
|
||||||
|
R_SUCCEED();
|
||||||
|
case Core::HID::NpadIdType::Player4:
|
||||||
|
*out_led_pattern = Core::HID::LedPattern{1, 1, 1, 1};
|
||||||
|
R_SUCCEED();
|
||||||
|
case Core::HID::NpadIdType::Player5:
|
||||||
|
*out_led_pattern = Core::HID::LedPattern{1, 0, 0, 1};
|
||||||
|
R_SUCCEED();
|
||||||
|
case Core::HID::NpadIdType::Player6:
|
||||||
|
*out_led_pattern = Core::HID::LedPattern{1, 0, 1, 0};
|
||||||
|
R_SUCCEED();
|
||||||
|
case Core::HID::NpadIdType::Player7:
|
||||||
|
*out_led_pattern = Core::HID::LedPattern{1, 0, 1, 1};
|
||||||
|
R_SUCCEED();
|
||||||
|
case Core::HID::NpadIdType::Player8:
|
||||||
|
*out_led_pattern = Core::HID::LedPattern{0, 1, 1, 0};
|
||||||
|
R_SUCCEED();
|
||||||
|
default:
|
||||||
|
*out_led_pattern = Core::HID::LedPattern{0, 0, 0, 0};
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) {
|
void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) {
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/cmif_types.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
#include "hid_core/hid_types.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
@ -66,7 +68,8 @@ private:
|
|||||||
void DeactivateNpad(HLERequestContext& ctx);
|
void DeactivateNpad(HLERequestContext& ctx);
|
||||||
void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx);
|
void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx);
|
||||||
void DisconnectNpad(HLERequestContext& ctx);
|
void DisconnectNpad(HLERequestContext& ctx);
|
||||||
void GetPlayerLedPattern(HLERequestContext& ctx);
|
Result GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern,
|
||||||
|
Core::HID::NpadIdType npad_id);
|
||||||
void ActivateNpadWithRevision(HLERequestContext& ctx);
|
void ActivateNpadWithRevision(HLERequestContext& ctx);
|
||||||
void SetNpadJoyHoldType(HLERequestContext& ctx);
|
void SetNpadJoyHoldType(HLERequestContext& ctx);
|
||||||
void GetNpadJoyHoldType(HLERequestContext& ctx);
|
void GetNpadJoyHoldType(HLERequestContext& ctx);
|
||||||
|
@ -422,7 +422,10 @@ struct NpadPowerInfo {
|
|||||||
static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size");
|
static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size");
|
||||||
|
|
||||||
struct LedPattern {
|
struct LedPattern {
|
||||||
explicit LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) {
|
LedPattern() {
|
||||||
|
raw = 0;
|
||||||
|
}
|
||||||
|
LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) {
|
||||||
position1.Assign(light1);
|
position1.Assign(light1);
|
||||||
position2.Assign(light2);
|
position2.Assign(light2);
|
||||||
position3.Assign(light3);
|
position3.Assign(light3);
|
||||||
|
@ -956,17 +956,6 @@ Result NPad::SwapNpadAssignment(u64 aruid, Core::HID::NpadIdType npad_id_1,
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result NPad::GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const {
|
|
||||||
if (!IsNpadIdValid(npad_id)) {
|
|
||||||
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
|
|
||||||
return ResultInvalidNpadId;
|
|
||||||
}
|
|
||||||
const auto aruid = applet_resource_holder.applet_resource->GetActiveAruid();
|
|
||||||
const auto& controller = GetControllerFromNpadIdType(aruid, npad_id).device;
|
|
||||||
pattern = controller->GetLedPattern();
|
|
||||||
return ResultSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result NPad::IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid,
|
Result NPad::IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid,
|
||||||
Core::HID::NpadIdType npad_id) const {
|
Core::HID::NpadIdType npad_id) const {
|
||||||
std::scoped_lock lock{mutex};
|
std::scoped_lock lock{mutex};
|
||||||
|
@ -97,8 +97,6 @@ public:
|
|||||||
Result ResetIsSixAxisSensorDeviceNewlyAssigned(
|
Result ResetIsSixAxisSensorDeviceNewlyAssigned(
|
||||||
u64 aruid, const Core::HID::SixAxisSensorHandle& sixaxis_handle);
|
u64 aruid, const Core::HID::SixAxisSensorHandle& sixaxis_handle);
|
||||||
|
|
||||||
Result GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const;
|
|
||||||
|
|
||||||
Result IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid,
|
Result IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid,
|
||||||
Core::HID::NpadIdType npad_id) const;
|
Core::HID::NpadIdType npad_id) const;
|
||||||
Result EnableUnintendedHomeButtonInputProtection(u64 aruid, Core::HID::NpadIdType npad_id,
|
Result EnableUnintendedHomeButtonInputProtection(u64 aruid, Core::HID::NpadIdType npad_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user