almost 3k

This commit is contained in:
Narr the Reg 2023-08-21 00:07:24 -06:00
parent ce39e0dd45
commit e33e38467c
6 changed files with 238 additions and 23 deletions

View File

@ -168,7 +168,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
{307, &IHidServer::FinalizeSevenSixAxisSensor, "FinalizeSevenSixAxisSensor"},
{308, nullptr, "SetSevenSixAxisSensorFusionStrength"},
{309, nullptr, "GetSevenSixAxisSensorFusionStrength"},
{310, nullptr, "ResetSevenSixAxisSensorTimestamp"},
{310, &IHidServer::ResetSevenSixAxisSensorTimestamp, "ResetSevenSixAxisSensorTimestamp"},
{400, nullptr, "IsUsbFullKeyControllerEnabled"},
{401, nullptr, "EnableUsbFullKeyController"},
{402, nullptr, "IsUsbFullKeyControllerConnected"},
@ -330,7 +330,7 @@ void IHidServer::AcquireXpadIdEventHandle(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -342,7 +342,7 @@ void IHidServer::ReleaseXpadIdEventHandle(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -362,7 +362,7 @@ void IHidServer::ActivateXpad(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, basic_xpad_id={}, applet_resource_user_id={}",
parameters.basic_xpad_id, parameters.applet_resource_user_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -371,7 +371,7 @@ void IHidServer::ActivateXpad(HLERequestContext& ctx) {
void IHidServer::GetXpadIds(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called");
// This service has been hardcoded since 10.0.0+
// This function has been hardcoded since 10.0.0+
std::array<u32, 4> basic_xpad_id{0, 1, 2, 3};
ctx.WriteBuffer(basic_xpad_id);
@ -386,7 +386,7 @@ void IHidServer::ActivateJoyXpad(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -398,7 +398,7 @@ void IHidServer::GetJoyXpadLifoHandle(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -407,7 +407,7 @@ void IHidServer::GetJoyXpadLifoHandle(HLERequestContext& ctx) {
void IHidServer::GetJoyXpadIds(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called");
// This service has been hardcoded since 10.0.0+
// This function has been hardcoded since 10.0.0+
std::array<u32, 4> basic_xpad_id{};
ctx.WriteBuffer(basic_xpad_id);
@ -422,7 +422,7 @@ void IHidServer::ActivateSixAxisSensor(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -434,7 +434,7 @@ void IHidServer::DeactivateSixAxisSensor(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -446,7 +446,7 @@ void IHidServer::GetSixAxisSensorLifoHandle(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -458,7 +458,7 @@ void IHidServer::ActivateJoySixAxisSensor(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -470,7 +470,7 @@ void IHidServer::DeactivateJoySixAxisSensor(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -482,7 +482,7 @@ void IHidServer::GetJoySixAxisSensorLifoHandle(HLERequestContext& ctx) {
LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
// This service has been stubbed since 10.0.0+
// This function has been stubbed since 10.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
@ -2115,14 +2115,123 @@ void IHidServer::SendVibrationValueInBool(HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}
void IHidServer::ActivateConsoleSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::ActivateConsoleSixAxisSensor(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
Result result = ResultSuccess;
auto sixaxis = GetResourceManager()->GetConsoleSixAxis();
if (IsDeviceManaged()) {
result = sixaxis->Activate(applet_resource_user_id);
} else {
result = sixaxis->Activate();
}
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidServer::StartConsoleSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::StopConsoleSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::ActivateSevenSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::StartSevenSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::StopConsoleSixAxisSensor(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
struct Parameters {
SixAxisSensorHandle sixaxis_handle;
INSERT_PADDING_WORDS_NOINIT(1);
u64 applet_resource_user_id;
};
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
const auto parameters{rp.PopRaw<Parameters>()};
LOG_WARNING(
Service_HID,
"(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id,
parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
std::shared_ptr<SixAxisSensorState> state = nullptr;
const auto sixaxis = GetResourceManager()->GetSevenSixAxis();
const Result result = sixaxis->GetSensorState(state, parameters.applet_resource_user_id,
parameters.sixaxis_handle);
if (result.IsSuccess()) {
state->SetRunningState(false);
}
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidServer::ActivateSevenSixAxisSensor(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
Result result = ResultSuccess;
auto sixaxis = GetResourceManager()->GetConsoleSixAxis();
if (IsDeviceManaged()) {
result = sixaxis->Activate(applet_resource_user_id);
} else {
result = sixaxis->Activate();
}
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidServer::StartSevenSixAxisSensor(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}",
applet_resource_user_id);
std::shared_ptr<SixAxisSensorState> state = nullptr;
const auto sixaxis = GetResourceManager()->GetSevenSixAxis();
Result result = sixaxis->GetSensorState(state, parameters.applet_resource_user_id,
parameters.sixaxis_handle);
if (result.IsSuccess()) {
result = GetResourceManager()->GetConsoleSixAxis()->ResetSevenSixAxisSensorTimestamp();
}
if (result.IsSuccess()) {
state->SetRunningState(true);
}
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IHidServer::StopSevenSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::InitializeSevenSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::FinalizeSevenSixAxisSensor(HLERequestContext& ctx) {}
void IHidServer::FinalizeSevenSixAxisSensor(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}",
applet_resource_user_id);
std::shared_ptr<SixAxisSensorState> state = nullptr;
const auto sixaxis = GetResourceManager()->GetSevenSixAxis();
Result result = sixaxis->GetSensorState(state, parameters.applet_resource_user_id,
parameters.sixaxis_handle);
if (result.IsSuccess()) {
state->SetRunningState(false);
}
result = GetResourceManager()->GetConsoleSixAxis()->FinalizeSevenSixAxisSensor();
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IHidServer::ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx) {}
void IHidServer::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) {
@ -2653,10 +2762,80 @@ void IHidServer::SetDisallowedPalmaConnection(HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}
void IHidServer::SetNpadCommunicationMode(HLERequestContext& ctx) {}
void IHidServer::GetNpadCommunicationMode(HLERequestContext& ctx) {}
void IHidServer::SetTouchScreenConfiguration(HLERequestContext& ctx) {}
void IHidServer::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) {}
void IHidServer::SetNpadCommunicationMode(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
const auto communication_mode{rp.PopEnum<NpadCommunicationMode>()};
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, communication_mode={}",
applet_resource_user_id, communication_mode);
// This function has been stubbed since 2.0.0+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IHidServer::GetNpadCommunicationMode(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}",
applet_resource_user_id);
// This function has been stubbed since 2.0.0+
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(ResultSuccess);
rb.PushEnum(NpadCommunicationMode::Default);
}
void IHidServer::SetTouchScreenConfiguration(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
auto touchscreen_mode{rp.PopRaw<TouchScreenConfigurationForNx>()};
const auto applet_resource_user_id{rp.Pop<u64>()};
LOG_WARNING(Service_HID, "(STUBBED) called, touchscreen_mode={}, applet_resource_user_id={}",
touchscreen_mode.mode, applet_resource_user_id);
switch (touchscreen_mode.mode) {
case TouchScreenModeForNx::UseSystemSetting:
case TouchScreenModeForNx::Finger:
case TouchScreenModeForNx::Heat2:
break;
default:
touchscreen_mode.mode = TouchScreenModeForNx::UseSystemSetting;
}
const Result result =
GetResourceManager()->GetTouchScreen()->SetTouchScreenConfiguration(touchscreen_mode);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidServer::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
struct Parameters {
s32 unknown;
INSERT_PADDING_WORDS_NOINIT(1);
u64 applet_resource_user_id;
};
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
const auto parameters{rp.PopRaw<Parameters>()};
LOG_WARNING(Service_HID, "(STUBBED) called, unknown={}, applet_resource_user_id={}",
parameters.unknown, parameters.applet_resource_user_id);
const bool needs_update =
GetResourceManager()->GetNpad()->IsFirmwareUpdateNeededForNotification(
parameters.applet_resource_user_id, parameters.unknown);
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(needs_update);
}
bool IHidServer::IsDeviceManaged() {
InitializeDebugSettings();

View File

@ -22,6 +22,14 @@ enum class DeviceIndex : u8 {
MaxDeviceInfo = None,
};
// This is nn::hid::NpadCommunicationMode
enum class NpadCommunicationMode : u64 {
Mode_5ms = 0,
Mode_10ms = 1,
Mode_15ms = 2,
Default = 3,
};
// This is nn::hid::NpadButton
enum class NpadButton : u64 {
None = 0,
@ -948,4 +956,16 @@ struct PalmaConnectionHandle {
INSERT_PADDING_BYTES(4);
};
static_assert(sizeof(PalmaConnectionHandle) == 0x8, "PalmaConnectionHandle has incorrect size.");
// This is nn::hid::TouchScreenModeForNx
enum class TouchScreenModeForNx : u8 {
UseSystemSetting,
Finger,
Heat2,
};
// This is nn::hid::TouchScreenConfigurationForNx
struct TouchScreenConfigurationForNx {
TouchScreenModeForNx mode{TouchScreenModeForNx::UseSystemSetting};
INSERT_PADDING_BYTES(0xF);
};
} // namespace Service::HID

View File

@ -194,6 +194,15 @@ std::shared_ptr<SixAxis> ResourceManager::GetSixAxis() {
return sixaxis;
}
std::shared_ptr<SixAxis> ResourceManager::GetConsoleSixAxis() {
return sixaxis;
}
std::shared_ptr<SixAxis> ResourceManager::GetSevenSixAxis() {
return sixaxis;
}
std::shared_ptr<TouchScreen> ResourceManager::GetTouchScreen() {
return touch_screen;
}

View File

@ -45,6 +45,8 @@ public:
std::shared_ptr<Npad> GetNpad();
std::shared_ptr<Palma> GetPalma();
std::shared_ptr<SixAxis> GetSixAxis();
std::shared_ptr<SixAxis> GetConsoleSixAxis();
std::shared_ptr<SixAxis> GetSevenSixAxis();
std::shared_ptr<TouchScreen> GetTouchScreen();
std::shared_ptr<Vibration> GetVibration(const VibrationDeviceHandle& handle);
std::shared_ptr<Vibration> GetGCVibration(const VibrationDeviceHandle& handle);

View File

@ -854,6 +854,10 @@ Result Npad::GetVibrationMasterVolume(float& out_volume) const {
return ResultSuccess;
}
bool Npad::IsFirmwareUpdateNeededForNotification(const u64 aruid, const s32 unknown) const {
// Not Implemented
return false;
}
std::shared_ptr<AbstractNpadState> Npad::GetAbstractNpad(const NpadIdType npad_id) {
return abstract_npad_state[NpadIdTypeToIndex(npad_id)];
}

View File

@ -142,6 +142,7 @@ public:
Result SetVibrationMasterVolume(const float volume);
Result GetVibrationMasterVolume(float& out_volume) const;
bool IsFirmwareUpdateNeededForNotification(const u64 aruid, const s32 unknown) const;
std::shared_ptr<AbstractNpadState> GetAbstractNpad(const NpadIdType npad_id);