diff --git a/src/core/hle/service/hid/hid_debug_server.cpp b/src/core/hle/service/hid/hid_debug_server.cpp index b6c06e502..df810ea96 100644 --- a/src/core/hle/service/hid/hid_debug_server.cpp +++ b/src/core/hle/service/hid/hid_debug_server.cpp @@ -5,53 +5,59 @@ #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/debug_pad.h" +#include "core/hle/service/hid/resource_manager/gesture.h" +#include "core/hle/service/hid/resource_manager/keyboard.h" +#include "core/hle/service/hid/resource_manager/mouse.h" #include "core/hle/service/hid/resource_manager/npad_resource/npad.h" +#include "core/hle/service/hid/resource_manager/palma.h" #include "core/hle/service/hid/resource_manager/sixaxis.h" +#include "core/hle/service/hid/resource_manager/touch_screen.h" +#include "core/hle/service/hid/hid_firmware_settings.h" #include "core/hle/service/ipc_helpers.h" namespace Service::HID { -IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr resource) - : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource} { +IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr resource, + std::shared_ptr settings) + : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource}, + firmware_settings{settings} { // clang-format off static const FunctionInfo functions[] = { - {0, nullptr, "DeactivateDebugPad"}, - {1, nullptr, "SetDebugPadAutoPilotState"}, - {2, nullptr, "UnsetDebugPadAutoPilotState"}, - {10, nullptr, "DeactivateTouchScreen"}, - {11, nullptr, "SetTouchScreenAutoPilotState"}, - {12, nullptr, "UnsetTouchScreenAutoPilotState"}, - {13, nullptr, "GetTouchScreenConfiguration"}, - {14, nullptr, "ProcessTouchScreenAutoTune"}, - {15, nullptr, "ForceStopTouchScreenManagement"}, - {16, nullptr, "ForceRestartTouchScreenManagement"}, - {17, nullptr, "IsTouchScreenManaged"}, - {20, nullptr, "DeactivateMouse"}, - {21, nullptr, "SetMouseAutoPilotState"}, - {22, nullptr, "UnsetMouseAutoPilotState"}, - {25, nullptr, "SetDebugMouseAutoPilotState"}, - {26, nullptr, "UnsetDebugMouseAutoPilotState"}, - {30, nullptr, "DeactivateKeyboard"}, - {31, nullptr, "SetKeyboardAutoPilotState"}, - {32, nullptr, "UnsetKeyboardAutoPilotState"}, - {50, nullptr, "DeactivateXpad"}, - {51, nullptr, "SetXpadAutoPilotState"}, - {52, nullptr, "UnsetXpadAutoPilotState"}, - {53, nullptr, "DeactivateJoyXpad"}, + {0, &IHidDebugServer::DeactivateDebugPad, "DeactivateDebugPad"}, + {1, &IHidDebugServer::SetDebugPadAutoPilotState, "SetDebugPadAutoPilotState"}, + {2, &IHidDebugServer::UnsetDebugPadAutoPilotState, "UnsetDebugPadAutoPilotState"}, + {10, &IHidDebugServer::DeactivateTouchScreen, "DeactivateTouchScreen"}, + {11, &IHidDebugServer::SetTouchScreenAutoPilotState, "SetTouchScreenAutoPilotState"}, + {12, &IHidDebugServer::UnsetTouchScreenAutoPilotState, "UnsetTouchScreenAutoPilotState"}, + {13, &IHidDebugServer::GetTouchScreenConfiguration, "GetTouchScreenConfiguration"}, + {14, &IHidDebugServer::ProcessTouchScreenAutoTune, "ProcessTouchScreenAutoTune"}, + {15, &IHidDebugServer::ForceStopTouchScreenManagement, "ForceStopTouchScreenManagement"}, + {16, &IHidDebugServer::ForceRestartTouchScreenManagement, "ForceRestartTouchScreenManagement"}, + {17, &IHidDebugServer::IsTouchScreenManaged, "IsTouchScreenManaged"}, + {20, &IHidDebugServer::DeactivateMouse, "DeactivateMouse"}, + {21, &IHidDebugServer::SetMouseAutoPilotState, "SetMouseAutoPilotState"}, + {22, &IHidDebugServer::UnsetMouseAutoPilotState, "UnsetMouseAutoPilotState"}, + {25, &IHidDebugServer::SetDebugMouseAutoPilotState, "SetDebugMouseAutoPilotState"}, + {26, &IHidDebugServer::UnsetDebugMouseAutoPilotState, "UnsetDebugMouseAutoPilotState"}, + {30, &IHidDebugServer::DeactivateKeyboard, "DeactivateKeyboard"}, + {31, &IHidDebugServer::SetKeyboardAutoPilotState, "SetKeyboardAutoPilotState"}, + {32, &IHidDebugServer::UnsetKeyboardAutoPilotState, "UnsetKeyboardAutoPilotState"}, + {50, &IHidDebugServer::DeactivateXpad, "DeactivateXpad"}, {60, &IHidDebugServer::ClearNpadSystemCommonPolicy, "ClearNpadSystemCommonPolicy"}, - {61, nullptr, "DeactivateNpad"}, + {61, &IHidDebugServer::DeactivateNpad, "DeactivateNpad"}, {62, &IHidDebugServer::ForceDisconnectNpad, "ForceDisconnectNpad"}, - {91, nullptr, "DeactivateGesture"}, - {110, nullptr, "DeactivateHomeButton"}, - {111, nullptr, "SetHomeButtonAutoPilotState"}, - {112, nullptr, "UnsetHomeButtonAutoPilotState"}, - {120, nullptr, "DeactivateSleepButton"}, - {121, nullptr, "SetSleepButtonAutoPilotState"}, - {122, nullptr, "UnsetSleepButtonAutoPilotState"}, - {123, nullptr, "DeactivateInputDetector"}, - {130, nullptr, "DeactivateCaptureButton"}, - {131, nullptr, "SetCaptureButtonAutoPilotState"}, - {132, nullptr, "UnsetCaptureButtonAutoPilotState"}, + {91, &IHidDebugServer::DeactivateGesture, "DeactivateGesture"}, + {110, &IHidDebugServer::DeactivateHomeButton, "DeactivateHomeButton"}, + {111, &IHidDebugServer::SetHomeButtonAutoPilotState, "SetHomeButtonAutoPilotState"}, + {112, &IHidDebugServer::UnsetHomeButtonAutoPilotState, "UnsetHomeButtonAutoPilotState"}, + {120, &IHidDebugServer::DeactivateSleepButton, "DeactivateSleepButton"}, + {121, &IHidDebugServer::SetSleepButtonAutoPilotState, "SetSleepButtonAutoPilotState"}, + {122, &IHidDebugServer::UnsetSleepButtonAutoPilotState, "UnsetSleepButtonAutoPilotState"}, + {123, &IHidDebugServer::DeactivateInputDetector, "DeactivateInputDetector"}, + {130, &IHidDebugServer::DeactivateCaptureButton, "DeactivateCaptureButton"}, + {131, &IHidDebugServer::SetCaptureButtonAutoPilotState, "SetCaptureButtonAutoPilotState"}, + {132, &IHidDebugServer::UnsetCaptureButtonAutoPilotState, "UnsetCaptureButtonAutoPilotState"}, {133, &IHidDebugServer::SetShiftAccelerometerCalibrationValue, "SetShiftAccelerometerCalibrationValue"}, {134, &IHidDebugServer::GetShiftAccelerometerCalibrationValue, "GetShiftAccelerometerCalibrationValue"}, {135, &IHidDebugServer::SetShiftGyroscopeCalibrationValue, "SetShiftGyroscopeCalibrationValue"}, @@ -147,8 +153,7 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptrIsDeviceManaged()) { + result = GetResourceManager()->GetDebugPad()->Deactivate(); + } + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::SetDebugPadAutoPilotState(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto auto_pilot_state{rp.Pop()}; + + LOG_DEBUG(Service_HID, "called"); + + const Result result = + GetResourceManager()->GetDebugPad()->SetAutoPilotState(auto_pilot_state); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::UnsetDebugPadAutoPilotState(HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "called"); + + const Result result = + GetResourceManager()->GetDebugPad()->UnsetAutoPilotState(); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::DeactivateTouchScreen(HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "called"); + + Result result = ResultSuccess; + + if (!firmware_settings->IsDeviceManaged()) { + result = GetResourceManager()->GetTouchScreen()->Deactivate(); + } + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::SetTouchScreenAutoPilotState(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto touch_state_elements{ctx.GetReadBufferNumElements()}; + const auto touch_state_buffer{ctx.ReadBuffer()}; + + LOG_DEBUG(Service_HID, "called, touch_state_elements={}", touch_state_elements); + + std::vector touch_states(touch_state_elements); + memcpy(touch_states.data(), touch_state_buffer.data(), touch_state_buffer.size()); + const Result result = GetResourceManager()->GetTouchScreen()->SetAutoPilotState(touch_states); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::UnsetTouchScreenAutoPilotState(HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "called"); + + const Result result = GetResourceManager()->GetTouchScreen()->UnsetAutoPilotState(); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::GetTouchScreenConfiguration(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto applet_resource_user_id{rp.Pop()}; + + LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", + applet_resource_user_id); + + TouchScreenConfigurationForNx touch_screen_configuration{}; + const Result result = + GetResourceManager()->GetTouchScreen()->GetConfiguration(applet_resource_user_id); + + switch (touch_screen_configuration.mode) { + case TouchScreenModeForNx::UseSystemSetting: + case TouchScreenModeForNx::Finger: + case TouchScreenModeForNx::Heat2: + break; + default: + touch_screen_configuration.mode = TouchScreenModeForNx::UseSystemSetting; + break; + } + + IPC::ResponseBuilder rb{ctx, 6}; + rb.Push(ResultSuccess); + rb.PushRaw(touch_screen_configuration); +} + +void IHidDebugServer::ProcessTouchScreenAutoTune(HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "called"); + + const Result result = GetResourceManager()->GetTouchScreen()->ProcessAutoTune(); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::ForceStopTouchScreenManagement(HLERequestContext& ctx){ + LOG_DEBUG(Service_HID, "called"); + + Result result = ResultSuccess; + auto touch_screen = GetResourceManager()->GetTouchScreen(); + + if (firmware_settings->IsDeviceManaged()) { + if (firmware_settings->IsTouchI2cManaged()) { + result=touch_screen->Something(); + if (result.IsSuccess()) { + result = touch_screen->Somethingx2(); + } + if (result.IsSuccess()) { + result = touch_screen->DeactivateTouchScreen(); + } + if (result.IsSuccess()) { + result = touch_screen->DeactivateGesture(); + } + } + } + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::ForceRestartTouchScreenManagement(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + struct Parameters { + u32 basic_gesture_id; + INSERT_PADDING_WORDS_NOINIT(1); + u64 applet_resource_user_id; + }; + static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); + + const auto parameters{rp.PopRaw()}; + + LOG_DEBUG(Service_HID, "called, basic_gesture_id={}, applet_resource_user_id={}", + parameters.basic_gesture_id, parameters.applet_resource_user_id); + + Result result = ResultSuccess; + auto touch_screen = GetResourceManager()->GetTouchScreen(); + + if (firmware_settings->IsDeviceManaged() && firmware_settings->IsTouchI2cManaged()) { + result = touch_screen->ActivateGestureUnmanaged(); + if (result.IsSuccess()) { + result = touch_screen->ActivateGesture(basic_gesture_id, applet_resource_user_id); + } + if (result.IsSuccess()) { + result = touch_screen->ActivateTouchScreenUnmanaged(); + } + if (result.IsSuccess()) { + result = touch_screen->ActivateTouchScreen(); + } + } + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::IsTouchScreenManaged(HLERequestContext& ctx){ + LOG_DEBUG(Service_HID, "called"); + + bool is_managed{}; + bool is_bool{}; + bool is_baal{}; + Result result = GetResourceManager()->GetTouchScreen()->SomeFunction(is_bool); + + if (result.IsSuccess()) { + GetResourceManager()->GetTouchScreen()->SomeFunction2(is_baal); + } + + if (result.IsSuccess()) { + is_managed = is_bool | is_baal; + } + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::DeactivateMouse(HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "called"); + + Result result = ResultSuccess; + + if (!firmware_settings->IsDeviceManaged()) { + result = GetResourceManager()->GetMouse()->Deactivate(); + } + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::SetMouseAutoPilotState(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto auto_pilot_state{rp.Pop()}; + + LOG_DEBUG(Service_HID, "called"); + + const Result result = GetResourceManager()->GetMouse()->SetAutoPilotState(auto_pilot_state); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::UnsetMouseAutoPilotState(HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "called"); + + const Result result = GetResourceManager()->GetMouse()->UnsetAutoPilotState(); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::SetDebugMouseAutoPilotState(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto auto_pilot_state{rp.Pop()}; + + LOG_DEBUG(Service_HID, "called"); + + const Result result = GetResourceManager()->GetDebugMouse()->SetAutoPilotState(auto_pilot_state); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::UnsetDebugMouseAutoPilotState(HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "called"); + + const Result result = GetResourceManager()->GetDebugMouse()->UnsetAutoPilotState(); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::DeactivateKeyboard(HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "called"); + + Result result = ResultSuccess; + + if (!firmware_settings->IsDeviceManaged()) { + result = GetResourceManager()->GetKeyboard()->Deactivate(); + } + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::SetKeyboardAutoPilotState(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto auto_pilot_state{rp.Pop()}; + + LOG_DEBUG(Service_HID, "called"); + + const Result result = + GetResourceManager()->GetKeyboard()->SetAutoPilotState(auto_pilot_state); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::UnsetKeyboardAutoPilotState(HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "called"); + + const Result result = GetResourceManager()->GetKeyboard()->UnsetAutoPilotState(); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + +void IHidDebugServer::DeactivateXpad(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto joy_xpad_id{rp.Pop()}; + + LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id); + + // This function has been stubbed since 10.0.0+ + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void IHidDebugServer::ClearNpadSystemCommonPolicy(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop()}; @@ -170,6 +464,8 @@ void IHidDebugServer::ClearNpadSystemCommonPolicy(HLERequestContext& ctx) { rb.Push(result); } +void IHidDebugServer::DeactivateNpad(HLERequestContext& ctx) {} + void IHidDebugServer::ForceDisconnectNpad(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto npad_id{rp.PopEnum()}; @@ -182,6 +478,18 @@ void IHidDebugServer::ForceDisconnectNpad(HLERequestContext& ctx) { rb.Push(ResultSuccess); } +void IHidDebugServer::DeactivateGesture(HLERequestContext& ctx) {} +void IHidDebugServer::DeactivateHomeButton(HLERequestContext& ctx) {} +void IHidDebugServer::SetHomeButtonAutoPilotState(HLERequestContext& ctx) {} +void IHidDebugServer::UnsetHomeButtonAutoPilotState(HLERequestContext& ctx) {} +void IHidDebugServer::DeactivateSleepButton(HLERequestContext& ctx) {} +void IHidDebugServer::SetSleepButtonAutoPilotState(HLERequestContext& ctx) {} +void IHidDebugServer::UnsetSleepButtonAutoPilotState(HLERequestContext& ctx) {} +void IHidDebugServer::DeactivateInputDetector(HLERequestContext& ctx) {} +void IHidDebugServer::DeactivateCaptureButton(HLERequestContext& ctx) {} +void IHidDebugServer::SetCaptureButtonAutoPilotState(HLERequestContext& ctx) {} +void IHidDebugServer::UnsetCaptureButtonAutoPilotState(HLERequestContext& ctx) {} + void IHidDebugServer::SetShiftAccelerometerCalibrationValue(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { @@ -325,6 +633,15 @@ void IHidDebugServer::SetGyroscopeFsr(HLERequestContext& ctx) {} void IHidDebugServer::GetGyroscopeOdr(HLERequestContext& ctx) {} void IHidDebugServer::SetGyroscopeOdr(HLERequestContext& ctx) {} +void IHidDebugServer::ReloadFirmwareDebugSettings(HLERequestContext& ctx) { + firmware_settings->Reload(); + + LOG_INFO(Service_HID, "called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + std::shared_ptr IHidDebugServer::GetResourceManager() { resource_manager->VerifiyInitalization(); return resource_manager; diff --git a/src/core/hle/service/hid/hid_debug_server.h b/src/core/hle/service/hid/hid_debug_server.h index c8b4e5b1f..4633799ba 100644 --- a/src/core/hle/service/hid/hid_debug_server.h +++ b/src/core/hle/service/hid/hid_debug_server.h @@ -11,16 +11,50 @@ class System; namespace Service::HID { class ResourceManager; +class HidFirmwareSettings; class IHidDebugServer final : public ServiceFramework { public: - explicit IHidDebugServer(Core::System& system_, std::shared_ptr resource); + explicit IHidDebugServer(Core::System& system_, std::shared_ptr resource, + std::shared_ptr settings); ~IHidDebugServer() override; private: // Service calls + void DeactivateDebugPad(HLERequestContext& ctx); + void SetDebugPadAutoPilotState(HLERequestContext& ctx); + void UnsetDebugPadAutoPilotState(HLERequestContext& ctx); + void DeactivateTouchScreen(HLERequestContext& ctx); + void SetTouchScreenAutoPilotState(HLERequestContext& ctx); + void UnsetTouchScreenAutoPilotState(HLERequestContext& ctx); + void GetTouchScreenConfiguration(HLERequestContext& ctx); + void ProcessTouchScreenAutoTune(HLERequestContext& ctx); + void ForceStopTouchScreenManagement(HLERequestContext& ctx); + void ForceRestartTouchScreenManagement(HLERequestContext& ctx); + void IsTouchScreenManaged(HLERequestContext& ctx); + void DeactivateMouse(HLERequestContext& ctx); + void SetMouseAutoPilotState(HLERequestContext& ctx); + void UnsetMouseAutoPilotState(HLERequestContext& ctx); + void SetDebugMouseAutoPilotState(HLERequestContext& ctx); + void UnsetDebugMouseAutoPilotState(HLERequestContext& ctx); + void DeactivateKeyboard(HLERequestContext& ctx); + void SetKeyboardAutoPilotState(HLERequestContext& ctx); + void UnsetKeyboardAutoPilotState(HLERequestContext& ctx); + void DeactivateXpad(HLERequestContext& ctx); void ClearNpadSystemCommonPolicy(HLERequestContext& ctx); + void DeactivateNpad(HLERequestContext& ctx); void ForceDisconnectNpad(HLERequestContext& ctx); + void DeactivateGesture(HLERequestContext& ctx); + void DeactivateHomeButton(HLERequestContext& ctx); + void SetHomeButtonAutoPilotState(HLERequestContext& ctx); + void UnsetHomeButtonAutoPilotState(HLERequestContext& ctx); + void DeactivateSleepButton(HLERequestContext& ctx); + void SetSleepButtonAutoPilotState(HLERequestContext& ctx); + void UnsetSleepButtonAutoPilotState(HLERequestContext& ctx); + void DeactivateInputDetector(HLERequestContext& ctx); + void DeactivateCaptureButton(HLERequestContext& ctx); + void SetCaptureButtonAutoPilotState(HLERequestContext& ctx); + void UnsetCaptureButtonAutoPilotState(HLERequestContext& ctx); void SetShiftAccelerometerCalibrationValue(HLERequestContext& ctx); void GetShiftAccelerometerCalibrationValue(HLERequestContext& ctx); void SetShiftGyroscopeCalibrationValue(HLERequestContext& ctx); @@ -33,10 +67,12 @@ private: void SetGyroscopeFsr(HLERequestContext& ctx); void GetGyroscopeOdr(HLERequestContext& ctx); void SetGyroscopeOdr(HLERequestContext& ctx); + void ReloadFirmwareDebugSettings(HLERequestContext& ctx); std::shared_ptr GetResourceManager(); std::shared_ptr resource_manager = nullptr; + std::shared_ptr firmware_settings = nullptr; }; } // namespace Service::HID diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp index a2d9c462a..16067c4ee 100644 --- a/src/core/hle/service/hid/hid_server.cpp +++ b/src/core/hle/service/hid/hid_server.cpp @@ -355,7 +355,7 @@ void IHidServer::SendKeyboardLockKeyEvent(HLERequestContext& ctx) { keyboard_lock_key_event, applet_resource_user_id); const Result result = - GetResourceManager()->GetKeyboard()->SendKeyboardLockKeyEvent(keyboard_lock_key_event); + GetResourceManager()->GetKeyboard()->SendLockKeyEvent(keyboard_lock_key_event); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(result); @@ -1295,7 +1295,7 @@ void IHidServer::SetSupportedNpadStyleSet(HLERequestContext& ctx) { const auto revision = npad->GetNpadRevision(parameters.applet_resource_user_id); if (style_tag.gamecube != 0 && revision < NpadRevision::Revision3) { - GetResourceManager()->GetPalma()->EnablePalmaBoostMode( + GetResourceManager()->GetPalma()->EnableBoostMode( parameters.applet_resource_user_id, true); } } diff --git a/src/core/hle/service/hid/hid_server.h b/src/core/hle/service/hid/hid_server.h index 54f5b8502..54517d289 100644 --- a/src/core/hle/service/hid/hid_server.h +++ b/src/core/hle/service/hid/hid_server.h @@ -15,9 +15,6 @@ struct VibrationValue; class ResourceManager; class HidFirmwareSettings; -} // namespace Service::HID - -namespace Service::HID { class IAppletResource final : public ServiceFramework { public: diff --git a/src/core/hle/service/hid/hid_system_server.cpp b/src/core/hle/service/hid/hid_system_server.cpp index 8d1e1765b..433b99902 100644 --- a/src/core/hle/service/hid/hid_system_server.cpp +++ b/src/core/hle/service/hid/hid_system_server.cpp @@ -378,7 +378,7 @@ void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx LOG_WARNING(Service_HID, "(STUBBED) called"); // TouchScreenConfigurationForNx touch_screen_configuration{}; - // const Result result = GetResourceManager()->GetTouchScreen()->GetTouchScreenConfiguration( + // const Result result = GetResourceManager()->GetTouchScreen()->GetDefaultConfiguration( // touch_screen_configuration.mode); // switch (touch_screen_configuration.mode) { diff --git a/src/core/hle/service/hid/hid_types.h b/src/core/hle/service/hid/hid_types.h index 645687f62..69616ff36 100644 --- a/src/core/hle/service/hid/hid_types.h +++ b/src/core/hle/service/hid/hid_types.h @@ -442,6 +442,11 @@ enum class NpadLagerType : u32 { U, }; +// This is nn::hid::DebugPadAttribute +enum class DebugPadAttribute : u32 { + IsConnected = 1 << 0, +}; + // This is nn::hid::NpadSystemProperties struct NPadSystemProperties { union { @@ -688,6 +693,16 @@ struct DebugPadButton { }; static_assert(sizeof(DebugPadButton) == 0x4, "DebugPadButton is an invalid size"); +// This is nn::hid::debug::DebugPadAutoPilotState +struct DebugPadAutoPilotState { + DebugPadAttribute attribute; + DebugPadButton buttons; + AnalogStickState stick_l; + AnalogStickState stick_r; +}; +static_assert(sizeof(DebugPadAutoPilotState) == 0x18, "DebugPadAutoPilotState is an invalid size"); + + // This is nn::hid::ConsoleSixAxisSensorHandle struct ConsoleSixAxisSensorHandle { u8 unknown_1{}; @@ -848,6 +863,16 @@ struct KeyboardKey { }; static_assert(sizeof(KeyboardKey) == 0x20, "KeyboardKey is an invalid size"); +// This is nn::hid::debug::KeyboardAutoPilotState +struct KeyboardAutoPilotState { + KeyboardModifier modifier{}; + INSERT_PADDING_BYTES(0x4); + KeyboardKey keys{}; +}; +static_assert(sizeof(KeyboardAutoPilotState) == 0x28, "KeyboardAutoPilotState is an invalid size"); + + + // This is nn::hid::MouseButton struct MouseButton { union { @@ -886,6 +911,18 @@ struct MouseState { }; static_assert(sizeof(MouseState) == 0x28, "MouseState is an invalid size"); +// This is nn::hid::debug::MouseAutoPilotState +struct MouseAutoPilotState { + s32 x{}; + s32 y{}; + s32 delta_x{}; + s32 delta_y{}; + s32 delta_wheel{}; + MouseButton button{}; + MouseAttribute attribute{}; +}; +static_assert(sizeof(MouseAutoPilotState) == 0x1c, "MouseAutoPilotState is an invalid size"); + // This is nn::hid::PalmaOperationType enum class PalmaOperationType : u32 { PlayActivity, diff --git a/src/core/hle/service/hid/resource_manager/debug_pad.h b/src/core/hle/service/hid/resource_manager/debug_pad.h index 2bb9523a8..55948cfdd 100644 --- a/src/core/hle/service/hid/resource_manager/debug_pad.h +++ b/src/core/hle/service/hid/resource_manager/debug_pad.h @@ -22,6 +22,10 @@ public: Result Activate(const u64 aruid); Result Activate(); + Result Deactivate(); + + Result SetAutoPilotState(const DebugPadAutoPilotState& auto_pilot_state); + Result UnsetAutoPilotState(); private: bool is_activated; diff --git a/src/core/hle/service/hid/resource_manager/keyboard.cpp b/src/core/hle/service/hid/resource_manager/keyboard.cpp index 2ba4de0ab..ba1bfeac3 100644 --- a/src/core/hle/service/hid/resource_manager/keyboard.cpp +++ b/src/core/hle/service/hid/resource_manager/keyboard.cpp @@ -20,4 +20,10 @@ Result Keyboard::Activate() { is_activated = true; return ResultSuccess; } + +Result Keyboard::Deactivate() { + is_activated = false; + return ResultSuccess; +} + } // namespace Service::HID diff --git a/src/core/hle/service/hid/resource_manager/keyboard.h b/src/core/hle/service/hid/resource_manager/keyboard.h index cfc7d8b51..fdbc48129 100644 --- a/src/core/hle/service/hid/resource_manager/keyboard.h +++ b/src/core/hle/service/hid/resource_manager/keyboard.h @@ -11,7 +11,9 @@ namespace Core { class System; } -namespace Service::HID {} // namespace Service::HID +namespace Service::HID { +struct KeyboardAutoPilotState; +} // namespace Service::HID namespace Service::HID { @@ -22,8 +24,12 @@ public: Result Activate(const u64 aruid); Result Activate(); + Result Deactivate(); - Result SendKeyboardLockKeyEvent(const u32 keyboard_lock_key_event); + Result SetAutoPilotState(const KeyboardAutoPilotState& auto_pilot_state); + Result UnsetAutoPilotState(); + + Result SendLockKeyEvent(const u32 keyboard_lock_key_event); private: bool is_activated; diff --git a/src/core/hle/service/hid/resource_manager/mouse.h b/src/core/hle/service/hid/resource_manager/mouse.h index e3887bb8f..121b4314e 100644 --- a/src/core/hle/service/hid/resource_manager/mouse.h +++ b/src/core/hle/service/hid/resource_manager/mouse.h @@ -11,7 +11,9 @@ namespace Core { class System; } -namespace Service::HID {} // namespace Service::HID +namespace Service::HID { +struct MouseAutoPilotState; +} // namespace Service::HID namespace Service::HID { @@ -22,6 +24,10 @@ public: Result Activate(const u64 aruid); Result Activate(); + Result Deactivate(); + + Result SetAutoPilotState(const MouseAutoPilotState& auto_pilot_state); + Result UnsetAutoPilotState(); private: bool is_activated; diff --git a/src/core/hle/service/hid/resource_manager/touch_screen.h b/src/core/hle/service/hid/resource_manager/touch_screen.h index 78b45c626..94d634682 100644 --- a/src/core/hle/service/hid/resource_manager/touch_screen.h +++ b/src/core/hle/service/hid/resource_manager/touch_screen.h @@ -3,7 +3,7 @@ #pragma once -#include +#include #include "core/hle/service/hid/resource_manager/base_resource.h" @@ -25,6 +25,10 @@ public: Result Activate(const u64 aruid); Result Activate(); + Result Deactivate(); + + Result SetAutoPilotState(std::span auto_pilot_state); + Result UnsetAutoPilotState(); private: bool is_activated;