From 42239ae58b3b8292f50d70d1d553439be62d1de5 Mon Sep 17 00:00:00 2001 From: greggameplayer <33609333+greggameplayer@users.noreply.github.com> Date: Sun, 17 Nov 2019 23:29:58 +0100 Subject: [PATCH] Implement additional applet services and functions This commit implements the services ISystemAppletProxy, IOverlayAppletProxy & IAppletCommonFunctions and implements the function GetDefaultDisplayResolution. --- .../main/cpp/skyline/services/am/applet.cpp | 41 ++++++++++++++++++- app/src/main/cpp/skyline/services/am/applet.h | 31 ++++++++++++++ .../skyline/services/am/appletController.cpp | 16 +++++++- .../skyline/services/am/appletController.h | 13 ++++++ .../main/cpp/skyline/services/base_service.h | 6 +++ .../main/cpp/skyline/services/serviceman.cpp | 9 ++++ 6 files changed, 113 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/skyline/services/am/applet.cpp b/app/src/main/cpp/skyline/services/am/applet.cpp index 09dea3f2..f8fc65be 100644 --- a/app/src/main/cpp/skyline/services/am/applet.cpp +++ b/app/src/main/cpp/skyline/services/am/applet.cpp @@ -10,9 +10,12 @@ namespace skyline::kernel::service::am { manager.RegisterService(SRVREG(IApplicationProxy), session, response); } - appletAE::appletAE(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_appletAE, { + appletAE::appletAE(const DeviceState& state, ServiceManager& manager) : BaseService(state, manager, false, Service::am_appletAE, { + {0x64, SFUNC(appletAE::OpenSystemAppletProxy)}, {0xC8, SFUNC(appletAE::OpenLibraryAppletProxy)}, - {0x15E, SFUNC(appletAE::OpenApplicationProxy)}, + {0xC9, SFUNC(appletAE::OpenLibraryAppletProxy)}, + {0x12C, SFUNC(appletAE::OpenOverlayAppletProxy)}, + {0x15E, SFUNC(appletAE::OpenApplicationProxy)} }) {} void appletAE::OpenLibraryAppletProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { @@ -23,6 +26,14 @@ namespace skyline::kernel::service::am { manager.RegisterService(SRVREG(IApplicationProxy), session, response); } + void appletAE::OpenOverlayAppletProxy(type::KSession& session, ipc::IpcRequest& request, ipc::IpcResponse& response) { + manager.RegisterService(SRVREG(IOverlayAppletProxy), session, response); + } + + void appletAE::OpenSystemAppletProxy(type::KSession& session, ipc::IpcRequest& request, ipc::IpcResponse& response) { + manager.RegisterService(SRVREG(ISystemAppletProxy), session, response); + } + BaseProxy::BaseProxy(const DeviceState &state, ServiceManager &manager, Service serviceType, const std::unordered_map> &vTable) : BaseService(state, manager, false, serviceType, vTable) {} void BaseProxy::GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { @@ -53,6 +64,10 @@ namespace skyline::kernel::service::am { manager.RegisterService(SRVREG(IDebugFunctions), session, response); } + void BaseProxy::GetAppletCommonFunctions(type::KSession& session, ipc::IpcRequest& request, ipc::IpcResponse& response) { + manager.RegisterService(SRVREG(IAppletCommonFunctions), session, response); + } + IApplicationProxy::IApplicationProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_IApplicationProxy, { {0x0, SFUNC(BaseProxy::GetCommonStateGetter)}, {0x1, SFUNC(BaseProxy::GetSelfController)}, @@ -77,4 +92,26 @@ namespace skyline::kernel::service::am { {0xB, SFUNC(BaseProxy::GetLibraryAppletCreator)}, {0x3E8, SFUNC(BaseProxy::GetDebugFunctions)} }) {} + + ISystemAppletProxy::ISystemAppletProxy(const DeviceState& state, ServiceManager& manager) : BaseProxy(state, manager, Service::am_ISystemAppletProxy, { + {0x0, SFUNC(BaseProxy::GetCommonStateGetter)}, + {0x1, SFUNC(BaseProxy::GetSelfController)}, + {0x2, SFUNC(BaseProxy::GetWindowController)}, + {0x3, SFUNC(BaseProxy::GetAudioController)}, + {0x4, SFUNC(BaseProxy::GetDisplayController)}, + {0xB, SFUNC(BaseProxy::GetLibraryAppletCreator)}, + {0x17, SFUNC(BaseProxy::GetAppletCommonFunctions)}, + {0x3E8, SFUNC(BaseProxy::GetDebugFunctions)} + }) {} + + IOverlayAppletProxy::IOverlayAppletProxy(const DeviceState& state, ServiceManager& manager) : BaseProxy(state, manager, Service::am_IOverlayAppletProxy, { + {0x0, SFUNC(BaseProxy::GetCommonStateGetter)}, + {0x1, SFUNC(BaseProxy::GetSelfController)}, + {0x2, SFUNC(BaseProxy::GetWindowController)}, + {0x3, SFUNC(BaseProxy::GetAudioController)}, + {0x4, SFUNC(BaseProxy::GetDisplayController)}, + {0xB, SFUNC(BaseProxy::GetLibraryAppletCreator)}, + {0x15, SFUNC(BaseProxy::GetAppletCommonFunctions)}, + {0x3E8, SFUNC(BaseProxy::GetDebugFunctions)} + }) {} } diff --git a/app/src/main/cpp/skyline/services/am/applet.h b/app/src/main/cpp/skyline/services/am/applet.h index 53b6031e..9ff657e8 100644 --- a/app/src/main/cpp/skyline/services/am/applet.h +++ b/app/src/main/cpp/skyline/services/am/applet.h @@ -33,6 +33,16 @@ namespace skyline::kernel::service::am { * @brief This returns #IApplicationProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenApplicationProxy) */ void OpenApplicationProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns #IOverlayAppletProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenOverlayAppletProxy) + */ + void OpenOverlayAppletProxy(type::KSession& session, ipc::IpcRequest& request, ipc::IpcResponse& response); + + /** + * @brief This returns #ISystemAppletProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenSystemAppletProxy) + */ + void OpenSystemAppletProxy(type::KSession& session, ipc::IpcRequest& request, ipc::IpcResponse& response); }; /** @@ -76,6 +86,11 @@ namespace skyline::kernel::service::am { * @brief This returns #IDebugFunctions (https://switchbrew.org/wiki/Applet_Manager_services#IDebugFunctions) */ void GetDebugFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns #IAppletCommonFunctions (https://switchbrew.org/wiki/Applet_Manager_services#IAppletCommonFunctions) + */ + void GetAppletCommonFunctions(type::KSession& session, ipc::IpcRequest& request, ipc::IpcResponse& response); }; /** @@ -91,6 +106,22 @@ namespace skyline::kernel::service::am { void GetApplicationFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); }; + /** + * @brief IOverlayAppletProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#IOverlayAppletProxy) + */ + class IOverlayAppletProxy : public BaseProxy { + public: + IOverlayAppletProxy(const DeviceState& state, ServiceManager& manager); + }; + + /** + * @brief ISystemAppletProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#ISystemAppletProxy) + */ + class ISystemAppletProxy : public BaseProxy { + public: + ISystemAppletProxy(const DeviceState& state, ServiceManager& manager); + }; + /** * @brief ILibraryAppletProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletProxy) */ diff --git a/app/src/main/cpp/skyline/services/am/appletController.cpp b/app/src/main/cpp/skyline/services/am/appletController.cpp index c4be4b1e..87843191 100644 --- a/app/src/main/cpp/skyline/services/am/appletController.cpp +++ b/app/src/main/cpp/skyline/services/am/appletController.cpp @@ -11,7 +11,8 @@ namespace skyline::kernel::service::am { {0x1, SFUNC(ICommonStateGetter::ReceiveMessage)}, {0x9, SFUNC(ICommonStateGetter::GetCurrentFocusState)}, {0x5, SFUNC(ICommonStateGetter::GetOperationMode)}, - {0x6, SFUNC(ICommonStateGetter::GetPerformanceMode)} + {0x6, SFUNC(ICommonStateGetter::GetPerformanceMode)}, + {0x3C, SFUNC(ICommonStateGetter::GetDefaultDisplayResolution)} }) { operationMode = static_cast(state.settings->GetBool("operation_mode")); state.logger->Info("Switch on mode: {}", static_cast(operationMode) ? "Docked" : "Handheld"); @@ -45,6 +46,16 @@ namespace skyline::kernel::service::am { response.WriteValue(static_cast(operationMode)); } + void ICommonStateGetter::GetDefaultDisplayResolution(type::KSession& session, ipc::IpcRequest& request, ipc::IpcResponse& response) { + if (operationMode == OperationMode::Handheld) { + response.WriteValue(constant::HandheldResolutionW); + response.WriteValue(constant::HandheldResolutionH); + } else if (operationMode == OperationMode::Docked) { + response.WriteValue(constant::DockedResolutionW); + response.WriteValue(constant::DockedResolutionH); + } + } + ISelfController::ISelfController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_ISelfController, { {0xB, SFUNC(ISelfController::SetOperationModeChangedNotification)}, {0xC, SFUNC(ISelfController::SetPerformanceModeChangedNotification)}, @@ -99,4 +110,7 @@ namespace skyline::kernel::service::am { IDebugFunctions::IDebugFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_IDebugFunctions, { }) {} + + IAppletCommonFunctions::IAppletCommonFunctions(const DeviceState& state, ServiceManager& manager) : BaseService(state, manager, false, Service::am_IAppletCommonFunctions, { + }) {} } diff --git a/app/src/main/cpp/skyline/services/am/appletController.h b/app/src/main/cpp/skyline/services/am/appletController.h index 4accef1e..828aceec 100644 --- a/app/src/main/cpp/skyline/services/am/appletController.h +++ b/app/src/main/cpp/skyline/services/am/appletController.h @@ -72,6 +72,11 @@ namespace skyline::kernel::service::am { * @brief This returns the current PerformanceMode (Same as operationMode but u32) (https://switchbrew.org/wiki/Applet_Manager_services#GetPerformanceMode) */ void GetPerformanceMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns the current display width and height in two u32s (https://switchbrew.org/wiki/Applet_Manager_services#GetDefaultDisplayResolution) + */ + void GetDefaultDisplayResolution(type::KSession& session, ipc::IpcRequest& request, ipc::IpcResponse& response); }; /** @@ -169,4 +174,12 @@ namespace skyline::kernel::service::am { public: IDebugFunctions(const DeviceState &state, ServiceManager &manager); }; + + /** + * @brief This contains common various functions (https://switchbrew.org/wiki/Applet_Manager_services#IAppletCommonFunctions) + */ + class IAppletCommonFunctions : public BaseService { + public: + IAppletCommonFunctions(const DeviceState& state, ServiceManager& manager); + }; } diff --git a/app/src/main/cpp/skyline/services/base_service.h b/app/src/main/cpp/skyline/services/base_service.h index ed20eb40..30251460 100644 --- a/app/src/main/cpp/skyline/services/base_service.h +++ b/app/src/main/cpp/skyline/services/base_service.h @@ -24,6 +24,8 @@ namespace skyline::kernel::service { am_appletAE, am_IApplicationProxy, am_ILibraryAppletProxy, + am_ISystemAppletProxy, + am_IOverlayAppletProxy, am_ICommonStateGetter, am_IApplicationFunctions, am_ISelfController, @@ -32,6 +34,7 @@ namespace skyline::kernel::service { am_IDisplayController, am_ILibraryAppletCreator, am_IDebugFunctions, + am_IAppletCommonFunctions, hid, hid_IAppletResource, time, @@ -60,6 +63,8 @@ namespace skyline::kernel::service { {"appletAE", Service::am_appletAE}, {"am:IApplicationProxy", Service::am_IApplicationProxy}, {"am:ILibraryAppletProxy", Service::am_ILibraryAppletProxy}, + {"am:ISystemAppletProxy", Service::am_ISystemAppletProxy}, + {"am:IOverlayAppletProxy", Service::am_IOverlayAppletProxy}, {"am:ICommonStateGetter", Service::am_ICommonStateGetter}, {"am:ISelfController", Service::am_ISelfController}, {"am:IWindowController", Service::am_IWindowController}, @@ -68,6 +73,7 @@ namespace skyline::kernel::service { {"am:ILibraryAppletCreator", Service::am_ILibraryAppletCreator}, {"am:IApplicationFunctions", Service::am_IApplicationFunctions}, {"am:IDebugFunctions", Service::am_IDebugFunctions}, + {"am:IAppletCommonFunctions", Service::am_IAppletCommonFunctions}, {"hid", Service::hid}, {"hid:IAppletResource", Service::hid_IAppletResource}, {"time:s", Service::time}, diff --git a/app/src/main/cpp/skyline/services/serviceman.cpp b/app/src/main/cpp/skyline/services/serviceman.cpp index 201df390..d05eeaf5 100644 --- a/app/src/main/cpp/skyline/services/serviceman.cpp +++ b/app/src/main/cpp/skyline/services/serviceman.cpp @@ -46,6 +46,12 @@ namespace skyline::kernel::service { case Service::am_ILibraryAppletProxy: serviceObj = std::make_shared(state, *this); break; + case Service::am_ISystemAppletProxy: + serviceObj = std::make_shared(state, *this); + break; + case Service::am_IOverlayAppletProxy: + serviceObj = std::make_shared(state, *this); + break; case Service::am_ICommonStateGetter: serviceObj = std::make_shared(state, *this); break; @@ -70,6 +76,9 @@ namespace skyline::kernel::service { case Service::am_IDebugFunctions: serviceObj = std::make_shared(state, *this); break; + case Service::am_IAppletCommonFunctions: + serviceObj = std::make_shared(state, *this); + break; case Service::hid: serviceObj = std::make_shared(state, *this); break;