End of day 4

This commit is contained in:
Narr the Reg 2023-08-17 00:20:34 -06:00
parent 520150c78a
commit e195aa523b
7 changed files with 419 additions and 24 deletions

View File

@ -5,6 +5,7 @@
#include "core/hle/service/hid//hid_types.h"
#include "core/hle/service/hid/hid_debug_server.h"
#include "core/hle/service/hid/resource_manager.h"
#include "core/hle/service/hid/resource_manager/npad.h"
#include "core/hle/service/hid/resource_manager/sixaxis.h"
#include "core/hle/service/ipc_helpers.h"
@ -37,9 +38,9 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
{51, nullptr, "SetXpadAutoPilotState"},
{52, nullptr, "UnsetXpadAutoPilotState"},
{53, nullptr, "DeactivateJoyXpad"},
{60, nullptr, "ClearNpadSystemCommonPolicy"},
{60, &IHidDebugServer::ClearNpadSystemCommonPolicy, "ClearNpadSystemCommonPolicy"},
{61, nullptr, "DeactivateNpad"},
{62, nullptr, "ForceDisconnectNpad"},
{62, &IHidDebugServer::ForceDisconnectNpad, "ForceDisconnectNpad"},
{91, nullptr, "DeactivateGesture"},
{110, nullptr, "DeactivateHomeButton"},
{111, nullptr, "SetHomeButtonAutoPilotState"},
@ -156,6 +157,31 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
IHidDebugServer::~IHidDebugServer() = default;
void IHidDebugServer::ClearNpadSystemCommonPolicy(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
const auto npad = GetResourceManager()->GetNpad();
const auto result = npad->ClearNpadSystemCommonPolicy(applet_resource_user_id);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidDebugServer::ForceDisconnectNpad(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto npad_id{rp.PopEnum<NpadIdType>()};
LOG_INFO(Service_HID, "called, npad_id={}", npad_id);
GetResourceManager()->GetNpad()->ForceDisconnectNpad(NpadIdType::Player1);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IHidDebugServer::SetShiftAccelerometerCalibrationValue(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
struct Parameters {

View File

@ -19,6 +19,8 @@ public:
private:
// Service calls
void ClearNpadSystemCommonPolicy(HLERequestContext& ctx);
void ForceDisconnectNpad(HLERequestContext& ctx);
void SetShiftAccelerometerCalibrationValue(HLERequestContext& ctx);
void GetShiftAccelerometerCalibrationValue(HLERequestContext& ctx);
void SetShiftGyroscopeCalibrationValue(HLERequestContext& ctx);

View File

@ -131,14 +131,14 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
{210, &IHidServer::EndPermitVibrationSession, "EndPermitVibrationSession"},
{211, &IHidServer::IsVibrationDeviceMounted, "IsVibrationDeviceMounted"},
{212, nullptr, "SendVibrationValueInBool"},
{300, nullptr, "ActivateConsoleSixAxisSensor"},
{301, nullptr, "StartConsoleSixAxisSensor"},
{302, nullptr, "StopConsoleSixAxisSensor"},
{303, nullptr, "ActivateSevenSixAxisSensor"},
{304, nullptr, "StartSevenSixAxisSensor"},
{305, nullptr, "StopSevenSixAxisSensor"},
{306, nullptr, "InitializeSevenSixAxisSensor"},
{307, nullptr, "FinalizeSevenSixAxisSensor"},
{300, &IHidServer::ActivateConsoleSixAxisSensor, "ActivateConsoleSixAxisSensor"},
{301, &IHidServer::StartConsoleSixAxisSensor, "StartConsoleSixAxisSensor"},
{302, &IHidServer::StopConsoleSixAxisSensor, "StopConsoleSixAxisSensor"},
{303, &IHidServer::ActivateSevenSixAxisSensor, "ActivateSevenSixAxisSensor"},
{304, &IHidServer::StartSevenSixAxisSensor, "StartSevenSixAxisSensor"},
{305, &IHidServer::StopSevenSixAxisSensor, "StopSevenSixAxisSensor"},
{306, &IHidServer::InitializeSevenSixAxisSensor, "InitializeSevenSixAxisSensor"},
{307, &IHidServer::FinalizeSevenSixAxisSensor, "FinalizeSevenSixAxisSensor"},
{308, nullptr, "SetSevenSixAxisSensorFusionStrength"},
{309, nullptr, "GetSevenSixAxisSensorFusionStrength"},
{310, nullptr, "ResetSevenSixAxisSensorTimestamp"},
@ -1687,8 +1687,7 @@ void IHidServer::SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx) {
const auto parameters{rp.PopRaw<Parameters>()};
LOG_WARNING(Service_HID,
"(STUBBED) called, use_center_clamp={}, applet_resource_user_id={}",
LOG_WARNING(Service_HID, "(STUBBED) called, use_center_clamp={}, applet_resource_user_id={}",
parameters.use_center_clamp, parameters.applet_resource_user_id);
GetResourceManager()->GetNpad()->SetNpadAnalogStickUseCenterClamp(
@ -1757,7 +1756,18 @@ void IHidServer::StopSevenSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::InitializeSevenSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::FinalizeSevenSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx) {}
void IHidServer::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) {}
void IHidServer::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const bool is_enabled = false;
LOG_WARNING(Service_HID, "(STUBBED) called, is_enabled={}", is_enabled);
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push<u8>(is_enabled);
}
void IHidServer::GetPalmaConnectionHandle(HLERequestContext& ctx) {}
void IHidServer::InitializePalma(HLERequestContext& ctx) {}
void IHidServer::AcquirePalmaOperationCompleteEvent(HLERequestContext& ctx) {}

View File

@ -1,13 +1,17 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
#include "core/hle/service/hid//hid_result.h"
#include "core/hle/service/hid//hid_types.h"
#include "core/hle/service/hid/hid_system_server.h"
#include "core/hle/service/hid/resource_manager.h"
#include "core/hle/service/hid/resource_manager/npad.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::HID {
IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<ResourceManager> resource)
: ServiceFramework{system_, "hid:sys"}, resource_manger{resource} {
: ServiceFramework{system_, "hid:sys"}, resource_manager{resource} {
// clang-format off
static const FunctionInfo functions[] = {
{31, nullptr, "SendKeyboardLockKeyEvent"},
@ -29,14 +33,14 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
{232, nullptr, "GetIrSensorState"},
{233, nullptr, "GetXcdHandleForNpadWithIrSensor"},
{301, nullptr, "ActivateNpadSystem"},
{303, nullptr, "ApplyNpadSystemCommonPolicy"},
{304, nullptr, "EnableAssigningSingleOnSlSrPress"},
{305, nullptr, "DisableAssigningSingleOnSlSrPress"},
{303, &IHidSystemServer::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"},
{304, &IHidSystemServer::EnableAssigningSingleOnSlSrPress, "EnableAssigningSingleOnSlSrPress"},
{305, &IHidSystemServer::DisableAssigningSingleOnSlSrPress, "DisableAssigningSingleOnSlSrPress"},
{306, nullptr, "GetLastActiveNpad"},
{307, nullptr, "GetNpadSystemExtStyle"},
{308, nullptr, "ApplyNpadSystemCommonPolicyFull"},
{308, &IHidSystemServer::ApplyNpadSystemCommonPolicyFull, "ApplyNpadSystemCommonPolicyFull"},
{309, nullptr, "GetNpadFullKeyGripColor"},
{310, nullptr, "GetMaskedSupportedNpadStyleSet"},
{310, &IHidSystemServer::GetMaskedSupportedNpadStyleSet, "GetMaskedSupportedNpadStyleSet"},
{311, nullptr, "SetNpadPlayerLedBlinkingDevice"},
{312, nullptr, "SetSupportedNpadStyleSetAll"},
{313, nullptr, "GetNpadCaptureButtonAssignment"},
@ -217,4 +221,77 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
IHidSystemServer::~IHidSystemServer() = default;
void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
GetResourceManager()->GetNpad()->ApplyNpadSystemCommonPolicy(applet_resource_user_id);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IHidSystemServer::EnableAssigningSingleOnSlSrPress(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
GetResourceManager()->GetNpad()->AssigningSingleOnSlSrPress(applet_resource_user_id, true);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IHidSystemServer::DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
GetResourceManager()->GetNpad()->AssigningSingleOnSlSrPress(applet_resource_user_id, false);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IHidSystemServer::ApplyNpadSystemCommonPolicyFull(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
GetResourceManager()->GetNpad()->ApplyNpadSystemCommonPolicyFull(applet_resource_user_id);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IHidSystemServer::GetMaskedSupportedNpadStyleSet(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
NpadStyleSet supported_styleset{};
const auto& npad = GetResourceManager()->GetNpad();
const Result result =
npad->GetMaskedSupportedNpadStyleSet(applet_resource_user_id, supported_styleset);
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(result);
rb.Push(supported_styleset);
}
std::shared_ptr<ResourceManager> IHidSystemServer::GetResourceManager() {
if (!is_resource_manager_initialized) {
resource_manager->Initialize();
is_resource_manager_initialized = true;
}
return resource_manager;
}
} // namespace Service::HID

View File

@ -18,7 +18,16 @@ public:
~IHidSystemServer() override;
private:
std::shared_ptr<ResourceManager> resource_manger = nullptr;
void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx);
void EnableAssigningSingleOnSlSrPress(HLERequestContext& ctx);
void DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx);
void ApplyNpadSystemCommonPolicyFull(HLERequestContext& ctx);
std::shared_ptr<ResourceManager> GetResourceManager();
bool is_resource_manager_initialized{};
std::shared_ptr<ResourceManager> resource_manager = nullptr;
};
} // namespace Service::HID

View File

@ -134,7 +134,7 @@ NpadHandheldActivationMode NpadState::GetNpadHandheldActivationMode() const {
}
bool NpadState::IsUnintendedHomeButtonInputProtectionEnabled(const NpadIdType npad_id) const {
return data.is_unintended_home_button_input_proptection[NpadIdTypeToIndex(npad_id)];
return data.is_unintended_home_button_input_protection[NpadIdTypeToIndex(npad_id)];
}
void NpadState::SetNpadAnalogStickUseCenterClampImpl(const bool is_enabled) {
@ -145,6 +145,94 @@ void NpadState::SetCaptureButtonAssignment(std::size_t index, NpadButton npad_bu
data.npad_button_assignment[index] = npad_button_set;
}
void NpadState::ClearNpadSystemCommonPolicy() {
data.status.raw = 0;
data.supported_npad_style_set = NpadStyleSet::All;
data.npad_hold_type = static_cast<u32>(NpadJoyHoldType::Vertical);
data.handheld_activation_mode = static_cast<u32>(NpadHandheldActivationMode::Dual);
data.npad_button_assignment[0] = NpadButton::None;
data.npad_button_assignment[1] = NpadButton::None;
data.npad_button_assignment[2] = NpadButton::None;
data.npad_button_assignment[3] = NpadButton::None;
data.npad_button_assignment[4] = NpadButton::None;
data.npad_button_assignment[5] = NpadButton::None;
data.supported_npad_id_types_count = 10;
data.supported_npad_id_types[0] = NpadIdType::Player1;
data.supported_npad_id_types[1] = NpadIdType::Player2;
data.supported_npad_id_types[2] = NpadIdType::Player3;
data.supported_npad_id_types[3] = NpadIdType::Player4;
data.supported_npad_id_types[4] = NpadIdType::Player5;
data.supported_npad_id_types[5] = NpadIdType::Player6;
data.supported_npad_id_types[6] = NpadIdType::Player7;
data.supported_npad_id_types[7] = NpadIdType::Player8;
data.supported_npad_id_types[8] = NpadIdType::Other;
data.supported_npad_id_types[9] = NpadIdType::Handheld;
data.is_unintended_home_button_input_protection[0] = true;
data.is_unintended_home_button_input_protection[1] = true;
data.is_unintended_home_button_input_protection[2] = true;
data.is_unintended_home_button_input_protection[3] = true;
data.is_unintended_home_button_input_protection[4] = true;
data.is_unintended_home_button_input_protection[5] = true;
data.is_unintended_home_button_input_protection[6] = true;
data.is_unintended_home_button_input_protection[7] = true;
data.is_unintended_home_button_input_protection[8] = true;
data.is_unintended_home_button_input_protection[9] = true;
data.unknown[0] = 0;
data.unknown[1] = 0;
data.unknown[2] = 0;
data.unknown[3] = 0;
data.unknown[4] = 0;
data.unknown[5] = 0;
}
void NpadState::ApplyNpadSystemCommonPolicy(const bool is_full_policy) {
data.supported_npad_style_set = NpadStyleSet::All;
data.handheld_activation_mode = static_cast<u32>(NpadHandheldActivationMode::Dual);
data.status.is_supported_style_set.Assign(1);
data.status.is_hold_type_set.Assign(1);
data.status.lr_assignment_mode.Assign(0);
data.status.is_policy.Assign(1);
if (is_full_policy) {
data.status.is_full_policy.Assign(1);
}
data.supported_npad_id_types_count = 10;
data.supported_npad_id_types[0] = NpadIdType::Player1;
data.supported_npad_id_types[1] = NpadIdType::Player2;
data.supported_npad_id_types[2] = NpadIdType::Player3;
data.supported_npad_id_types[3] = NpadIdType::Player4;
data.supported_npad_id_types[4] = NpadIdType::Player5;
data.supported_npad_id_types[5] = NpadIdType::Player6;
data.supported_npad_id_types[6] = NpadIdType::Player7;
data.supported_npad_id_types[7] = NpadIdType::Player8;
data.supported_npad_id_types[8] = NpadIdType::Other;
data.supported_npad_id_types[9] = NpadIdType::Handheld;
data.is_unintended_home_button_input_protection[0] = true;
data.is_unintended_home_button_input_protection[1] = true;
data.is_unintended_home_button_input_protection[2] = true;
data.is_unintended_home_button_input_protection[3] = true;
data.is_unintended_home_button_input_protection[4] = true;
data.is_unintended_home_button_input_protection[5] = true;
data.is_unintended_home_button_input_protection[6] = true;
data.is_unintended_home_button_input_protection[7] = true;
data.is_unintended_home_button_input_protection[8] = true;
data.is_unintended_home_button_input_protection[9] = true;
}
bool NpadState::GetAssigningSingleOnSlSrPress() const {
return data.status.assigning_single_on_sl_sr_press != 0;
}
void NpadState::SetAssigningSingleOnSlSrPress(const bool is_enabled) {
data.status.assigning_single_on_sl_sr_press.Assign(is_enabled);
}
Npad::Npad(KernelHelpers::ServiceContext& context) : service_context{context} {
for (auto& npad : npad_state) {
npad = std::make_shared<NpadState>();
@ -178,6 +266,7 @@ void Npad::DisconnectNpad(const u64 aruid, const NpadIdType npad_id) {
}
void Npad::ForceDisconnectNpad(const NpadIdType npad_id) {
std::scoped_lock lock{mutex};
DisconnectNpad(GetNpadActiveAruid(), npad_id);
}
@ -209,7 +298,7 @@ Result Npad::GetNpadJoyHoldType(const u64 aruid, NpadJoyHoldType& out_hold_type)
const auto& state = npad_state[index];
out_hold_type = state->GetNpadJoyHoldType();
if ((state->GetStatus().raw & 0x30) != 0) { // TODO: Find name for 0x30
if (state->GetStatus().is_policy || state->GetStatus().is_full_policy) {
out_hold_type = active_npad_state->GetNpadJoyHoldType();
}
@ -686,6 +775,165 @@ Result Npad::AcquireNpadStyleSetUpdateEventHandle(const u64 aruid,
return ResultSuccess;
}
Result Npad::ClearNpadSystemCommonPolicy(const u64 aruid) {
std::scoped_lock lock{mutex};
const Result result = ClearNpadSystemCommonPolicyImpl(aruid);
if (result.IsSuccess()) {
// UpdateSystemCommonPolicy();
// SetIsPalmaPairedConnectable();
}
return result;
}
Result Npad::ClearNpadSystemCommonPolicyImpl(const u64 aruid) {
const auto index = GetIndexFromAruid(aruid);
if (index >= ARUID_MAX) {
return ResultNpadNotConnected;
}
npad_state[index]->ClearNpadSystemCommonPolicy();
if (active_aruid == aruid) {
active_npad_state->ClearNpadSystemCommonPolicy();
}
return ResultSuccess;
}
Result Npad::ApplyNpadSystemCommonPolicy(const u64 aruid) {
std::scoped_lock lock{mutex};
const Result result = ApplyNpadSystemCommonPolicyImpl(aruid, false);
if (result.IsSuccess()) {
// UpdateSystemCommonPolicy();
// SetIsPalmaPairedConnectable();
}
return result;
}
Result Npad::ApplyNpadSystemCommonPolicyFull(const u64 aruid) {
std::scoped_lock lock{mutex};
const Result result = ApplyNpadSystemCommonPolicyImpl(aruid, true);
if (result.IsSuccess()) {
// UpdateSystemCommonPolicy();
// SetIsPalmaPairedConnectable();
}
return result;
}
Result Npad::ApplyNpadSystemCommonPolicyImpl(const u64 aruid, const bool is_full_policy) {
const auto index = GetIndexFromAruid(aruid);
if (index >= ARUID_MAX) {
return ResultNpadNotConnected;
}
npad_state[index]->ApplyNpadSystemCommonPolicy(is_full_policy);
npad_state[index]->SetNpadJoyHoldType(default_joy_hold_type);
if (active_aruid == aruid) {
active_npad_state->ApplyNpadSystemCommonPolicy(is_full_policy);
npad_state[index]->SetNpadJoyHoldType(default_joy_hold_type);
}
return ResultSuccess;
}
Result Npad::AssigningSingleOnSlSrPress(const u64 aruid, const bool is_enabled) {
std::scoped_lock lock{mutex};
bool is_currently_enabled{};
Result result = GetAssigningSingleOnSlSrPress(aruid, is_currently_enabled);
if (result.IsSuccess() && is_currently_enabled != is_enabled) {
result = SetAssigningSingleOnSlSrPress(aruid, is_enabled);
}
return result;
}
Result Npad::GetAssigningSingleOnSlSrPress(const u64 aruid, bool out_is_enabled) const {
const auto index = GetIndexFromAruid(aruid);
if (index >= ARUID_MAX) {
return ResultNpadNotConnected;
}
out_is_enabled = npad_state[index]->GetAssigningSingleOnSlSrPress();
return ResultSuccess;
}
Result Npad::SetAssigningSingleOnSlSrPress(const u64 aruid, const bool is_enabled) {
const auto index = GetIndexFromAruid(aruid);
if (index >= ARUID_MAX) {
return ResultNpadNotConnected;
}
npad_state[index]->SetAssigningSingleOnSlSrPress(is_enabled);
if (active_aruid == aruid) {
active_npad_state->SetAssigningSingleOnSlSrPress(is_enabled);
}
return ResultSuccess;
}
Result Npad::GetMaskedSupportedNpadStyleSet(const u64 aruid,
NpadStyleSet& out_npad_styleset) const {
std::scoped_lock lock{mutex};
Result result = GetMaskedSupportedNpadStyleSetImpl(aruid, out_npad_styleset);
if (result == ResultUndefinedStyleSet) {
out_npad_styleset = NpadStyleSet::None;
return ResultSuccess;
}
return result;
}
Result Npad::GetMaskedSupportedNpadStyleSetImpl(const u64 aruid,
NpadStyleSet& out_npad_styleset) const {
if (aruid == 0) {
out_npad_styleset = static_cast<NpadStyleSet>(0x6000005f);
return ResultSuccess;
}
const auto index = GetIndexFromAruid(aruid);
if (index >= ARUID_MAX) {
return ResultNpadNotConnected;
}
if (npad_state[index]->GetStatus().is_supported_style_set == 0) {
return ResultUndefinedStyleSet;
}
NpadStyleTag mask{0x6000001f};
out_npad_styleset = npad_state[index]->GetSupportedNpadStyleSet();
if (index < ARUID_MAX) {
switch (npad_state[index]->GetMaskIndex()) {
case 1:
mask = static_cast<NpadStyleSet>(0x6000003f);
break;
case 2:
mask = static_cast<NpadStyleSet>(0x600001bf);
break;
case 3:
mask = static_cast<NpadStyleSet>(0x60000fbf);
break;
}
mask.palma.Assign(1);
}
out_npad_styleset = out_npad_styleset & mask.raw;
return ResultSuccess;
}
void Npad::UpdateSupportedNpadIdType() {
// Set some u64
// Call DisconnectAbstracPads(u64)

View File

@ -68,6 +68,9 @@ public:
BitField<0, 1, u32> is_supported_style_set;
BitField<1, 1, u32> is_hold_type_set;
BitField<2, 1, u32> lr_assignment_mode;
BitField<3, 1, u32> assigning_single_on_sl_sr_press;
BitField<4, 1, u32> is_full_policy;
BitField<5, 1, u32> is_policy;
BitField<6, 1, u32> use_center_clamp;
};
};
@ -98,6 +101,12 @@ public:
void SetCaptureButtonAssignment(std::size_t index, NpadButton npad_button_set);
void ClearNpadSystemCommonPolicy();
void ApplyNpadSystemCommonPolicy(const bool is_full_policy);
bool GetAssigningSingleOnSlSrPress() const;
void SetAssigningSingleOnSlSrPress(const bool is_enabled);
private:
struct DataStructure {
NpadStatus status{};
@ -106,9 +115,9 @@ private:
u32 handheld_activation_mode{};
std::array<NpadIdType, PLAYERS_MAX> supported_npad_id_types{};
std::array<NpadButton, 7> npad_button_assignment;
INSERT_PADDING_BYTES(0x30);
std::array<u64, 6> unknown;
u32 supported_npad_id_types_count{};
std::array<bool, PLAYERS_MAX> is_unintended_home_button_input_proptection{};
std::array<bool, PLAYERS_MAX> is_unintended_home_button_input_protection{};
INSERT_PADDING_BYTES(0x2);
};
static_assert(sizeof(DataStructure) == 0xB0, "DataStructure is an invalid size");
@ -173,6 +182,14 @@ public:
Result AcquireNpadStyleSetUpdateEventHandle(const u64 aruid, Kernel::KReadableEvent** out_event,
const NpadIdType npad_id);
Result ClearNpadSystemCommonPolicy(const u64 aruid);
Result ApplyNpadSystemCommonPolicy(const u64 aruid);
Result ApplyNpadSystemCommonPolicyFull(const u64 aruid);
Result AssigningSingleOnSlSrPress(const u64 aruid, const bool is_enabled);
Result GetMaskedSupportedNpadStyleSet(const u64 aruid, NpadStyleSet& out_npad_styleset) const;
private:
// Interface implementations
Result SetSupportedNpadIdTypeImpl(const u64 aruid, std::span<const NpadIdType> list);
@ -192,6 +209,11 @@ private:
const NpadIdType npad_id) const;
Result SetNpadAnalogStickUseCenterClampImpl(const u64 aruid, const bool use_center_clamp);
Result ClearNpadSystemCommonPolicyImpl(const u64 aruid);
Result ApplyNpadSystemCommonPolicyImpl(const u64 aruid, const bool is_full_policy);
Result GetAssigningSingleOnSlSrPress(const u64 aruid, bool out_is_enabled) const;
Result SetAssigningSingleOnSlSrPress(const u64 aruid, const bool is_enabled);
// Update state
void UpdateSupportedNpadIdType();
@ -201,6 +223,7 @@ private:
mutable std::mutex mutex;
u64 active_aruid{};
std::shared_ptr<NpadState> active_npad_state = nullptr;
NpadJoyHoldType default_joy_hold_type{};
std::array<std::shared_ptr<NpadState>, ARUID_MAX> npad_state{};
KernelHelpers::ServiceContext& service_context;
};