This commit is contained in:
Narr the Reg 2023-08-21 18:09:19 -06:00
parent e33e38467c
commit 6a0ef7de68
7 changed files with 127 additions and 22 deletions

View File

@ -80,7 +80,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
{21, &IHidServer::ActivateMouse, "ActivateMouse"},
{26, nullptr, "ActivateDebugMouse"},
{31, &IHidServer::ActivateKeyboard, "ActivateKeyboard"},
{32, nullptr, "SendKeyboardLockKeyEvent"},
{32, &IHidServer::SendKeyboardLockKeyEvent, "SendKeyboardLockKeyEvent"},
{40, &IHidServer::AcquireXpadIdEventHandle, "AcquireXpadIdEventHandle"},
{41, &IHidServer::ReleaseXpadIdEventHandle, "ReleaseXpadIdEventHandle"},
{51, &IHidServer::ActivateXpad, "ActivateXpad"},
@ -166,18 +166,18 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
{305, &IHidServer::StopSevenSixAxisSensor, "StopSevenSixAxisSensor"},
{306, &IHidServer::InitializeSevenSixAxisSensor, "InitializeSevenSixAxisSensor"},
{307, &IHidServer::FinalizeSevenSixAxisSensor, "FinalizeSevenSixAxisSensor"},
{308, nullptr, "SetSevenSixAxisSensorFusionStrength"},
{309, nullptr, "GetSevenSixAxisSensorFusionStrength"},
{308, &IHidServer::SetSevenSixAxisSensorFusionStrength, "SetSevenSixAxisSensorFusionStrength"},
{309, &IHidServer::GetSevenSixAxisSensorFusionStrength, "GetSevenSixAxisSensorFusionStrength"},
{310, &IHidServer::ResetSevenSixAxisSensorTimestamp, "ResetSevenSixAxisSensorTimestamp"},
{400, nullptr, "IsUsbFullKeyControllerEnabled"},
{401, nullptr, "EnableUsbFullKeyController"},
{402, nullptr, "IsUsbFullKeyControllerConnected"},
{403, nullptr, "HasBattery"},
{404, nullptr, "HasLeftRightBattery"},
{405, nullptr, "GetNpadInterfaceType"},
{406, nullptr, "GetNpadLeftRightInterfaceType"},
{407, nullptr, "GetNpadOfHighestBatteryLevel"},
{408, nullptr, "GetNpadOfHighestBatteryLevelForJoyRight"},
{400, &IHidServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"},
{401, &IHidServer::EnableUsbFullKeyController, "EnableUsbFullKeyController"},
{402, &IHidServer::IsUsbFullKeyControllerConnected, "IsUsbFullKeyControllerConnected"},
{403, &IHidServer::HasBattery, "HasBattery"},
{404, &IHidServer::HasLeftRightBattery, "HasLeftRightBattery"},
{405, &IHidServer::GetNpadInterfaceType, "GetNpadInterfaceType"},
{406, &IHidServer::GetNpadLeftRightInterfaceType, "GetNpadLeftRightInterfaceType"},
{407, &IHidServer::GetNpadOfHighestBatteryLevel, "GetNpadOfHighestBatteryLevel"},
{408, &IHidServer::GetNpadOfHighestBatteryLevelForJoyRight, "GetNpadOfHighestBatteryLevelForJoyRight"},
{500, &IHidServer::GetPalmaConnectionHandle, "GetPalmaConnectionHandle"},
{501, &IHidServer::InitializePalma, "InitializePalma"},
{502, &IHidServer::AcquirePalmaOperationCompleteEvent, "AcquirePalmaOperationCompleteEvent"},
@ -212,7 +212,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
{1001, &IHidServer::GetNpadCommunicationMode, "GetNpadCommunicationMode"},
{1002, &IHidServer::SetTouchScreenConfiguration, "SetTouchScreenConfiguration"},
{1003, &IHidServer::IsFirmwareUpdateNeededForNotification, "IsFirmwareUpdateNeededForNotification"},
{2000, nullptr, "ActivateDigitizer"},
{2000, &IHidServer::ActivateDigitizer, "ActivateDigitizer"},
{3000, nullptr, "GetDebugPadGenericPadMap"},
{3001, nullptr, "SetDebugPadGenericPadMap"},
{3002, nullptr, "ResetDebugPadGenericPadMap"},
@ -241,6 +241,7 @@ void IHidServer::CreateAppletResource(HLERequestContext& ctx) {
if (applet_resource == nullptr) {
applet_resource = std::make_shared<IAppletResource>(system);
applet_resource->Initialize();
}
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@ -324,6 +325,9 @@ void IHidServer::ActivateKeyboard(HLERequestContext& ctx) {
rb.Push(result);
}
void IHidServer::SendKeyboardLockKeyEvent(HLERequestContext& ctx) {
}
void IHidServer::AcquireXpadIdEventHandle(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
@ -2232,6 +2236,9 @@ void IHidServer::FinalizeSevenSixAxisSensor(HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}
void IHidServer::ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx) {}
void IHidServer::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) {}
void IHidServer::ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx) {}
void IHidServer::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) {
@ -2268,6 +2275,15 @@ void IHidServer::GetPalmaConnectionHandle(HLERequestContext& ctx) {
rb.PushRaw(handle);
}
void IHidServer::EnableUsbFullKeyController(HLERequestContext& ctx) {}
void IHidServer::IsUsbFullKeyControllerConnected(HLERequestContext& ctx) {}
void IHidServer::HasBattery(HLERequestContext& ctx) {}
void IHidServer::HasLeftRightBattery(HLERequestContext& ctx) {}
void IHidServer::GetNpadInterfaceType(HLERequestContext& ctx) {}
void IHidServer::GetNpadLeftRightInterfaceType(HLERequestContext& ctx) {}
void IHidServer::GetNpadOfHighestBatteryLevel(HLERequestContext& ctx) {}
void IHidServer::GetNpadOfHighestBatteryLevelForJoyRight(HLERequestContext& ctx) {}
void IHidServer::InitializePalma(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto connection_handle{rp.PopRaw<PalmaConnectionHandle>()};
@ -2837,6 +2853,10 @@ void IHidServer::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) {
rb.Push(needs_update);
}
void IHidServer::ActivateDigitizer(HLERequestContext& ctx) {
}
bool IHidServer::IsDeviceManaged() {
InitializeDebugSettings();
return is_device_managed;

View File

@ -51,6 +51,7 @@ private:
void ActivateTouchScreen(HLERequestContext& ctx);
void ActivateMouse(HLERequestContext& ctx);
void ActivateKeyboard(HLERequestContext& ctx);
void SendKeyboardLockKeyEvent(HLERequestContext& ctx);
void AcquireXpadIdEventHandle(HLERequestContext& ctx);
void ReleaseXpadIdEventHandle(HLERequestContext& ctx);
void ActivateXpad(HLERequestContext& ctx);
@ -136,8 +137,18 @@ private:
void StopSevenSixAxisSensor(HLERequestContext& ctx);
void InitializeSevenSixAxisSensor(HLERequestContext& ctx);
void FinalizeSevenSixAxisSensor(HLERequestContext& ctx);
void SetSevenSixAxisSensorFusionStrength(HLERequestContext& ctx);
void GetSevenSixAxisSensorFusionStrength(HLERequestContext& ctx);
void ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx);
void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx);
void EnableUsbFullKeyController(HLERequestContext& ctx);
void IsUsbFullKeyControllerConnected(HLERequestContext& ctx);
void HasBattery(HLERequestContext& ctx);
void HasLeftRightBattery(HLERequestContext& ctx);
void GetNpadInterfaceType(HLERequestContext& ctx);
void GetNpadLeftRightInterfaceType(HLERequestContext& ctx);
void GetNpadOfHighestBatteryLevel(HLERequestContext& ctx);
void GetNpadOfHighestBatteryLevelForJoyRight(HLERequestContext& ctx);
void GetPalmaConnectionHandle(HLERequestContext& ctx);
void InitializePalma(HLERequestContext& ctx);
void AcquirePalmaOperationCompleteEvent(HLERequestContext& ctx);
@ -172,7 +183,9 @@ private:
void GetNpadCommunicationMode(HLERequestContext& ctx);
void SetTouchScreenConfiguration(HLERequestContext& ctx);
void IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx);
void ActivateDigitizer(HLERequestContext& ctx);
private:
Result SendVibrationValueImpl(const u64 aruid, const VibrationDeviceHandle& handle,
const VibrationValue& value);

View File

@ -6,6 +6,7 @@
#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_resource/npad.h"
#include "core/hle/service/hid/resource_manager/touch_screen.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::HID {
@ -36,11 +37,11 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
{303, &IHidSystemServer::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"},
{304, &IHidSystemServer::EnableAssigningSingleOnSlSrPress, "EnableAssigningSingleOnSlSrPress"},
{305, &IHidSystemServer::DisableAssigningSingleOnSlSrPress, "DisableAssigningSingleOnSlSrPress"},
{306, nullptr, "GetLastActiveNpad"},
{306, &IHidSystemServer::GetLastActiveNpad, "GetLastActiveNpad"},
{307, nullptr, "GetNpadSystemExtStyle"},
{308, &IHidSystemServer::ApplyNpadSystemCommonPolicyFull, "ApplyNpadSystemCommonPolicyFull"},
{309, nullptr, "GetNpadFullKeyGripColor"},
{310, &IHidSystemServer::GetMaskedSupportedNpadStyleSet, "GetMaskedSupportedNpadStyleSet"},
{310, &IHidSystemServer::GetMaskedSupportedNpadStyleSet, "GetMaskedSupportedNpadStyleSet"},
{311, nullptr, "SetNpadPlayerLedBlinkingDevice"},
{312, &IHidSystemServer::SetSupportedNpadStyleSetAll, "SetSupportedNpadStyleSetAll"},
{313, &IHidSystemServer::GetNpadCaptureButtonAssignment, "GetNpadCaptureButtonAssignment"},
@ -50,7 +51,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
{317, nullptr, "GetNpadLeftRightInterfaceType"},
{318, nullptr, "HasBattery"},
{319, nullptr, "HasLeftRightBattery"},
{321, nullptr, "GetUniquePadsFromNpad"},
{321, &IHidSystemServer::GetUniquePadsFromNpad, "GetUniquePadsFromNpad"},
{322, nullptr, "GetIrSensorState"},
{323, nullptr, "GetXcdHandleForNpadWithIrSensor"},
{324, nullptr, "GetUniquePadButtonSet"},
@ -68,8 +69,8 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
{505, nullptr, "EnableAppletToGetSixAxisSensor"},
{506, nullptr, "EnableAppletToGetPadInput"},
{507, nullptr, "EnableAppletToGetTouchScreen"},
{510, &IHidSystemServer::SetVibrationMasterVolume, "SetVibrationMasterVolume"},
{511, &IHidSystemServer::GetVibrationMasterVolume, "GetVibrationMasterVolume"},
{510, &IHidSystemServer::SetVibrationMasterVolume, "SetVibrationMasterVolume"},
{511, &IHidSystemServer::GetVibrationMasterVolume, "GetVibrationMasterVolume"},
{512, nullptr, "BeginPermitVibrationSession"},
{513, nullptr, "EndPermitVibrationSession"},
{514, nullptr, "Unknown514"},
@ -92,7 +93,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
{700, nullptr, "ActivateUniquePad"},
{702, nullptr, "AcquireUniquePadConnectionEventHandle"},
{703, nullptr, "GetUniquePadIds"},
{751, nullptr, "AcquireJoyDetachOnBluetoothOffEventHandle"},
{751, &IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle, "AcquireJoyDetachOnBluetoothOffEventHandle"},
{800, nullptr, "ListSixAxisSensorHandles"},
{801, nullptr, "IsSixAxisSensorUserCalibrationSupported"},
{802, nullptr, "ResetSixAxisSensorCalibrationValues"},
@ -118,7 +119,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
{830, nullptr, "SetNotificationLedPattern"},
{831, nullptr, "SetNotificationLedPatternWithTimeout"},
{832, nullptr, "PrepareHidsForNotificationWake"},
{850, nullptr, "IsUsbFullKeyControllerEnabled"},
{850, &IHidSystemServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"},
{851, nullptr, "EnableUsbFullKeyController"},
{852, nullptr, "IsUsbConnected"},
{870, nullptr, "IsHandheldButtonPressedOnConsoleMode"},
@ -149,8 +150,8 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
{1134, nullptr, "GetUsbFirmwareUpdateState"},
{1150, nullptr, "SetTouchScreenMagnification"},
{1151, nullptr, "GetTouchScreenFirmwareVersion"},
{1152, nullptr, "SetTouchScreenDefaultConfiguration"},
{1153, nullptr, "GetTouchScreenDefaultConfiguration"},
{1152, &IHidSystemServer::SetTouchScreenDefaultConfiguration, "SetTouchScreenDefaultConfiguration"},
{1153, &IHidSystemServer::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"},
{1154, nullptr, "IsFirmwareAvailableForNotification"},
{1155, nullptr, "SetForceHandheldStyleVibration"},
{1156, nullptr, "SendConnectionTriggerWithoutTimeoutEvent"},
@ -257,6 +258,17 @@ void IHidSystemServer::DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx)
rb.Push(ResultSuccess);
}
void IHidSystemServer::GetLastActiveNpad(HLERequestContext& ctx) {
NpadIdType npad_id{};
const Result result = GetResourceManager()->GetNpad()->GetLastActiveNpad(npad_id);
LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id);
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(result);
rb.PushEnum(ResultSuccess);
}
void IHidSystemServer::ApplyNpadSystemCommonPolicyFull(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto applet_resource_user_id{rp.Pop<u64>()};
@ -340,6 +352,49 @@ void IHidSystemServer::GetVibrationMasterVolume(HLERequestContext& ctx) {
rb.Push(volume);
}
void IHidSystemServer::SetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
auto touch_screen_configuration{rp.PopRaw<TouchScreenConfigurationForNx>()};
LOG_WARNING(Service_HID, "(STUBBED) called, mode={}", touch_screen_configuration.mode);
switch (touch_screen_configuration.mode) {
case TouchScreenModeForNx::UseSystemSetting:
case TouchScreenModeForNx::Finger:
case TouchScreenModeForNx::Heat2:
break;
default:
touch_screen_configuration.mode = TouchScreenModeForNx::UseSystemSetting;
}
const Result result = GetResourceManager()->GetTouchScreen()->SetTouchScreenConfiguration(
touch_screen_configuration);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
LOG_WARNING(Service_HID, "(STUBBED) called");
TouchScreenConfigurationForNx touch_screen_configuration{};
const Result result = GetResourceManager()->GetTouchScreen()->GetTouchScreenConfiguration(
touch_screen_configuration.mode);
switch (touch_screen_configuration.mode) {
case TouchScreenModeForNx::UseSystemSetting:
case TouchScreenModeForNx::Finger:
case TouchScreenModeForNx::Heat2:
break;
default:
touch_screen_configuration.mode = TouchScreenModeForNx::UseSystemSetting;
}
IPC::ResponseBuilder rb{ctx, 6};
rb.Push(ResultSuccess);
rb.PushRaw(touch_screen_configuration);
}
std::shared_ptr<ResourceManager> IHidSystemServer::GetResourceManager() {
if (!is_resource_manager_initialized) {
resource_manager->Initialize();

View File

@ -21,12 +21,15 @@ private:
void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx);
void EnableAssigningSingleOnSlSrPress(HLERequestContext& ctx);
void DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx);
void GetLastActiveNpad(HLERequestContext& ctx);
void ApplyNpadSystemCommonPolicyFull(HLERequestContext& ctx);
void GetMaskedSupportedNpadStyleSet(HLERequestContext& ctx);
void SetSupportedNpadStyleSetAll(HLERequestContext& ctx);
void GetNpadCaptureButtonAssignment(HLERequestContext& ctx);
void SetVibrationMasterVolume(HLERequestContext& ctx);
void GetVibrationMasterVolume(HLERequestContext& ctx);
void SetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
std::shared_ptr<ResourceManager> GetResourceManager();

View File

@ -968,4 +968,7 @@ struct TouchScreenConfigurationForNx {
TouchScreenModeForNx mode{TouchScreenModeForNx::UseSystemSetting};
INSERT_PADDING_BYTES(0xF);
};
static_assert(sizeof(TouchScreenConfigurationForNx) == 0x10,
"TouchScreenConfigurationForNx has incorrect size.");
} // namespace Service::HID

View File

@ -858,6 +858,16 @@ bool Npad::IsFirmwareUpdateNeededForNotification(const u64 aruid, const s32 unkn
// Not Implemented
return false;
}
Result Npad::GetLastActiveNpad(NpadIdType& out_npad_id) const {
std::scoped_lock lock{mutex};
out_npad_id = NpadIdType::Handheld;
const Result result = ResultSuccess; // last_active_npad->GetNpadIdType(out_npad_id);
return result;
}
std::shared_ptr<AbstractNpadState> Npad::GetAbstractNpad(const NpadIdType npad_id) {
return abstract_npad_state[NpadIdTypeToIndex(npad_id)];
}

View File

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