diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 4bf47845..65ec0e76 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -61,8 +61,22 @@ add_library(skyline SHARED ${source_DIR}/skyline/services/settings/ISystemSettingsServer.cpp ${source_DIR}/skyline/services/apm/IManager.cpp ${source_DIR}/skyline/services/apm/ISession.cpp - ${source_DIR}/skyline/services/am/applet.cpp - ${source_DIR}/skyline/services/am/appletController.cpp + ${source_DIR}/skyline/services/am/IAllSystemAppletProxiesService.cpp + ${source_DIR}/skyline/services/am/IApplicationProxyService.cpp + ${source_DIR}/skyline/services/am/proxy/base_proxy.cpp + ${source_DIR}/skyline/services/am/proxy/IApplicationProxy.cpp + ${source_DIR}/skyline/services/am/proxy/ILibraryAppletProxy.cpp + ${source_DIR}/skyline/services/am/proxy/IOverlayAppletProxy.cpp + ${source_DIR}/skyline/services/am/proxy/ISystemAppletProxy.cpp + ${source_DIR}/skyline/services/am/controller/IAppletCommonFunctions.cpp + ${source_DIR}/skyline/services/am/controller/IApplicationFunctions.cpp + ${source_DIR}/skyline/services/am/controller/IAudioController.cpp + ${source_DIR}/skyline/services/am/controller/ICommonStateGetter.cpp + ${source_DIR}/skyline/services/am/controller/IDebugFunctions.cpp + ${source_DIR}/skyline/services/am/controller/IDisplayController.cpp + ${source_DIR}/skyline/services/am/controller/ILibraryAppletCreator.cpp + ${source_DIR}/skyline/services/am/controller/ISelfController.cpp + ${source_DIR}/skyline/services/am/controller/IWindowController.cpp ${source_DIR}/skyline/services/hid/IHidServer.cpp ${source_DIR}/skyline/services/hid/IAppletResource.cpp ${source_DIR}/skyline/services/timesrv/IStaticService.cpp diff --git a/app/src/main/cpp/skyline/services/am/IAllSystemAppletProxiesService.cpp b/app/src/main/cpp/skyline/services/am/IAllSystemAppletProxiesService.cpp new file mode 100644 index 00000000..965509e0 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/IAllSystemAppletProxiesService.cpp @@ -0,0 +1,31 @@ +#include "proxy/ILibraryAppletProxy.h" +#include "proxy/IApplicationProxy.h" +#include "proxy/IOverlayAppletProxy.h" +#include "proxy/ISystemAppletProxy.h" +#include "IAllSystemAppletProxiesService.h" + +namespace skyline::service::am { + IAllSystemAppletProxiesService::IAllSystemAppletProxiesService(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IAllSystemAppletProxiesService, "am:IAllSystemAppletProxiesService", { + {0x64, SFUNC(IAllSystemAppletProxiesService::OpenSystemAppletProxy)}, + {0xC8, SFUNC(IAllSystemAppletProxiesService::OpenLibraryAppletProxy)}, + {0xC9, SFUNC(IAllSystemAppletProxiesService::OpenLibraryAppletProxy)}, + {0x12C, SFUNC(IAllSystemAppletProxiesService::OpenOverlayAppletProxy)}, + {0x15E, SFUNC(IAllSystemAppletProxiesService::OpenApplicationProxy)} + }) {} + + void IAllSystemAppletProxiesService::OpenLibraryAppletProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(ILibraryAppletProxy), session, response); + } + + void IAllSystemAppletProxiesService::OpenApplicationProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IApplicationProxy), session, response); + } + + void IAllSystemAppletProxiesService::OpenOverlayAppletProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IOverlayAppletProxy), session, response); + } + + void IAllSystemAppletProxiesService::OpenSystemAppletProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(ISystemAppletProxy), session, response); + } +} diff --git a/app/src/main/cpp/skyline/services/am/IAllSystemAppletProxiesService.h b/app/src/main/cpp/skyline/services/am/IAllSystemAppletProxiesService.h new file mode 100644 index 00000000..0b75cb60 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/IAllSystemAppletProxiesService.h @@ -0,0 +1,34 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @brief IAllSystemAppletProxiesService is used to open proxies (https://switchbrew.org/wiki/Applet_Manager_services#appletAE) + */ + class IAllSystemAppletProxiesService : public BaseService { + public: + IAllSystemAppletProxiesService(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This returns #ILibraryAppletProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenLibraryAppletProxy) + */ + void OpenLibraryAppletProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @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); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/IApplicationProxyService.cpp b/app/src/main/cpp/skyline/services/am/IApplicationProxyService.cpp new file mode 100644 index 00000000..dd59f962 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/IApplicationProxyService.cpp @@ -0,0 +1,12 @@ +#include "proxy/IApplicationProxy.h" +#include "IApplicationProxyService.h" + +namespace skyline::service::am { + IApplicationProxyService::IApplicationProxyService(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IApplicationProxyService, "am:IApplicationProxyService", { + {0x0, SFUNC(IApplicationProxyService::OpenApplicationProxy)} + }) {} + + void IApplicationProxyService::OpenApplicationProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IApplicationProxy), session, response); + } +} diff --git a/app/src/main/cpp/skyline/services/am/IApplicationProxyService.h b/app/src/main/cpp/skyline/services/am/IApplicationProxyService.h new file mode 100644 index 00000000..1883ceef --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/IApplicationProxyService.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @brief IApplicationProxyService is used to open an application proxy (https://switchbrew.org/wiki/Applet_Manager_services#appletOE) + */ + class IApplicationProxyService : public BaseService { + public: + IApplicationProxyService(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This returns #IApplicationProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenApplicationProxy) + */ + void OpenApplicationProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/applet.cpp b/app/src/main/cpp/skyline/services/am/applet.cpp deleted file mode 100644 index 43c0129a..00000000 --- a/app/src/main/cpp/skyline/services/am/applet.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "applet.h" -#include "appletController.h" - -namespace skyline::service::am { - appletOE::appletOE(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_appletOE, "am:appletOE", { - {0x0, SFUNC(appletOE::OpenApplicationProxy)} - }) {} - - void appletOE::OpenApplicationProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(SRVREG(IApplicationProxy), session, response); - } - - appletAE::appletAE(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_appletAE, "am:appletAE", { - {0x64, SFUNC(appletAE::OpenSystemAppletProxy)}, - {0xC8, SFUNC(appletAE::OpenLibraryAppletProxy)}, - {0xC9, SFUNC(appletAE::OpenLibraryAppletProxy)}, - {0x12C, SFUNC(appletAE::OpenOverlayAppletProxy)}, - {0x15E, SFUNC(appletAE::OpenApplicationProxy)} - }) {} - - void appletAE::OpenLibraryAppletProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(SRVREG(ILibraryAppletProxy), session, response); - } - - void appletAE::OpenApplicationProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - 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, const Service serviceType, const std::string &serviceName, const std::unordered_map> &vTable) : BaseService(state, manager, serviceType, serviceName, vTable) {} - - void BaseProxy::GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(SRVREG(ICommonStateGetter), session, response); - } - - void BaseProxy::GetSelfController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(SRVREG(ISelfController), session, response); - } - - void BaseProxy::GetWindowController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(SRVREG(IWindowController), session, response); - } - - void BaseProxy::GetAudioController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(SRVREG(IAudioController), session, response); - } - - void BaseProxy::GetDisplayController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(SRVREG(IDisplayController), session, response); - } - - void BaseProxy::GetLibraryAppletCreator(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(SRVREG(ILibraryAppletCreator), session, response); - } - - void BaseProxy::GetDebugFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - 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, "am:IApplicationProxy", { - {0x0, SFUNC(BaseProxy::GetCommonStateGetter)}, - {0x1, SFUNC(BaseProxy::GetSelfController)}, - {0x2, SFUNC(BaseProxy::GetWindowController)}, - {0x3, SFUNC(BaseProxy::GetAudioController)}, - {0x4, SFUNC(BaseProxy::GetDisplayController)}, - {0xB, SFUNC(BaseProxy::GetLibraryAppletCreator)}, - {0x14, SFUNC(IApplicationProxy::GetApplicationFunctions)}, - {0x3E8, SFUNC(BaseProxy::GetDebugFunctions)} - }) {} - - void IApplicationProxy::GetApplicationFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(SRVREG(IApplicationFunctions), session, response); - } - - ILibraryAppletProxy::ILibraryAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_ILibraryAppletProxy, "am:ILibraryAppletProxy", { - {0x0, SFUNC(BaseProxy::GetCommonStateGetter)}, - {0x1, SFUNC(BaseProxy::GetSelfController)}, - {0x2, SFUNC(BaseProxy::GetWindowController)}, - {0x3, SFUNC(BaseProxy::GetAudioController)}, - {0x4, SFUNC(BaseProxy::GetDisplayController)}, - {0xB, SFUNC(BaseProxy::GetLibraryAppletCreator)}, - {0x3E8, SFUNC(BaseProxy::GetDebugFunctions)} - }) {} - - ISystemAppletProxy::ISystemAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_ISystemAppletProxy, "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, "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 deleted file mode 100644 index 908bdcab..00000000 --- a/app/src/main/cpp/skyline/services/am/applet.h +++ /dev/null @@ -1,132 +0,0 @@ -#pragma once - -#include -#include - -namespace skyline::service::am { - /** - * @brief appletOE is used to open an application proxy (https://switchbrew.org/wiki/Applet_Manager_services#appletOE) - */ - class appletOE : public BaseService { - public: - appletOE(const DeviceState &state, ServiceManager &manager); - - /** - * @brief This returns #IApplicationProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenApplicationProxy) - */ - void OpenApplicationProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - }; - - /** - * @brief appletAE is used to open proxies (https://switchbrew.org/wiki/Applet_Manager_services#appletAE) - */ - class appletAE : public BaseService { - public: - appletAE(const DeviceState &state, ServiceManager &manager); - - /** - * @brief This returns #ILibraryAppletProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenLibraryAppletProxy) - */ - void OpenLibraryAppletProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @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); - }; - - /** - * @brief ILibraryAppletProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletProxy) - */ - class BaseProxy : public BaseService { - public: - BaseProxy(const DeviceState &state, ServiceManager &manager, const Service serviceType, const std::string &serviceName, const std::unordered_map> &vTable); - - /** - * @brief This returns #ICommonStateGetter (https://switchbrew.org/wiki/Applet_Manager_services#ICommonStateGetter) - */ - void GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This returns #ISelfController (https://switchbrew.org/wiki/Applet_Manager_services#ISelfController) - */ - void GetSelfController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This returns #IWindowController (https://switchbrew.org/wiki/Applet_Manager_services#IWindowController) - */ - void GetWindowController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This returns #IAudioController (https://switchbrew.org/wiki/Applet_Manager_services#IAudioController) - */ - void GetAudioController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This returns #IDisplayController (https://switchbrew.org/wiki/Applet_Manager_services#IDisplayController) - */ - void GetDisplayController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This returns #ILibraryAppletCreator (https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletCreator) - */ - void GetLibraryAppletCreator(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @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); - }; - - /** - * @brief IApplicationProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#IApplicationProxy) - */ - class IApplicationProxy : public BaseProxy { - public: - IApplicationProxy(const DeviceState &state, ServiceManager &manager); - - /** - * @brief This returns #IApplicationFunctions (https://switchbrew.org/wiki/Applet_Manager_services#IApplicationFunctions) - */ - 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) - */ - class ILibraryAppletProxy : public BaseProxy { - public: - ILibraryAppletProxy(const DeviceState &state, ServiceManager &manager); - }; -} diff --git a/app/src/main/cpp/skyline/services/am/appletController.cpp b/app/src/main/cpp/skyline/services/am/appletController.cpp deleted file mode 100644 index deb062aa..00000000 --- a/app/src/main/cpp/skyline/services/am/appletController.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "appletController.h" - -namespace skyline::service::am { - void ICommonStateGetter::QueueMessage(ICommonStateGetter::Message message) { - messageQueue.emplace(message); - messageEvent->Signal(); - } - - ICommonStateGetter::ICommonStateGetter(const DeviceState &state, ServiceManager &manager) : messageEvent(std::make_shared(state)), BaseService(state, manager, Service::am_ICommonStateGetter, "am:ICommonStateGetter", { - {0x0, SFUNC(ICommonStateGetter::GetEventHandle)}, - {0x1, SFUNC(ICommonStateGetter::ReceiveMessage)}, - {0x5, SFUNC(ICommonStateGetter::GetOperationMode)}, - {0x6, SFUNC(ICommonStateGetter::GetPerformanceMode)}, - {0x9, SFUNC(ICommonStateGetter::GetCurrentFocusState)}, - {0x3C, SFUNC(ICommonStateGetter::GetDefaultDisplayResolution)} - }) { - operationMode = static_cast(state.settings->GetBool("operation_mode")); - state.logger->Info("Switch on mode: {}", static_cast(operationMode) ? "Docked" : "Handheld"); - QueueMessage(Message::FocusStateChange); - } - - void ICommonStateGetter::GetEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - auto handle = state.process->InsertItem(messageEvent); - state.logger->Debug("Applet Event Handle: 0x{:X}", handle); - response.copyHandles.push_back(handle); - } - - void ICommonStateGetter::ReceiveMessage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - if (messageQueue.empty()) { - response.errorCode = constant::status::NoMessages; - return; - } - response.Push(static_cast(messageQueue.front())); - messageQueue.pop(); - } - - void ICommonStateGetter::GetCurrentFocusState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - response.Push(static_cast(focusState)); - } - - void ICommonStateGetter::GetOperationMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - response.Push(static_cast(operationMode)); - } - - void ICommonStateGetter::GetPerformanceMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - response.Push(static_cast(operationMode)); - } - - void ICommonStateGetter::GetDefaultDisplayResolution(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - if (operationMode == OperationMode::Handheld) { - response.Push(constant::HandheldResolutionW); - response.Push(constant::HandheldResolutionH); - } else if (operationMode == OperationMode::Docked) { - response.Push(constant::DockedResolutionW); - response.Push(constant::DockedResolutionH); - } - } - - ISelfController::ISelfController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_ISelfController, "am:ISelfController", { - {0xB, SFUNC(ISelfController::SetOperationModeChangedNotification)}, - {0xC, SFUNC(ISelfController::SetPerformanceModeChangedNotification)}, - {0xD, SFUNC(ISelfController::SetFocusHandlingMode)}, - {0x10, SFUNC(ISelfController::SetOutOfFocusSuspendingEnabled)}, - {0x28, SFUNC(ISelfController::CreateManagedDisplayLayer)} - }) {} - - void ISelfController::SetOperationModeChangedNotification(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} - - void ISelfController::SetPerformanceModeChangedNotification(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} - - void ISelfController::SetFocusHandlingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} - - void ISelfController::SetOutOfFocusSuspendingEnabled(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} - - void ISelfController::CreateManagedDisplayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - state.logger->Debug("Creating Managed Layer"); - if (state.gpu->layerStatus == gpu::LayerStatus::Initialized) - throw exception("The application is creating more than one layer"); - state.gpu->layerStatus = gpu::LayerStatus::Initialized; - response.Push(0); - } - - IWindowController::IWindowController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IWindowController, "am:IWindowController", { - {0x1, SFUNC(IWindowController::GetAppletResourceUserId)}, - {0xA, SFUNC(IWindowController::AcquireForegroundRights)} - }) {} - - void IWindowController::GetAppletResourceUserId(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - response.Push(static_cast(state.process->pid)); - } - - void IWindowController::AcquireForegroundRights(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} - - IAudioController::IAudioController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IAudioController, "am:IAudioController", { - }) {} - - IDisplayController::IDisplayController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IDisplayController, "am:IDisplayController", { - }) {} - - ILibraryAppletCreator::ILibraryAppletCreator(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_ILibraryAppletCreator, "am:ILibraryAppletCreator", { - }) {} - - IApplicationFunctions::IApplicationFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IApplicationFunctions, "am:IApplicationFunctions", { - {0x28, SFUNC(IApplicationFunctions::NotifyRunning)} - }) {} - - void IApplicationFunctions::NotifyRunning(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - response.Push(1); - } - - IDebugFunctions::IDebugFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IDebugFunctions, "am:IDebugFunctions", { - }) {} - - IAppletCommonFunctions::IAppletCommonFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IAppletCommonFunctions, "am:IAppletCommonFunctions", { - }) {} -} diff --git a/app/src/main/cpp/skyline/services/am/appletController.h b/app/src/main/cpp/skyline/services/am/appletController.h deleted file mode 100644 index 5bf6528e..00000000 --- a/app/src/main/cpp/skyline/services/am/appletController.h +++ /dev/null @@ -1,185 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -namespace skyline::service::am { - /** - * @brief https://switchbrew.org/wiki/Applet_Manager_services#ICommonStateGetter - */ - class ICommonStateGetter : public BaseService { - private: - /** - * @brief This enumerates all the possible contents of a #AppletMessage (https://switchbrew.org/wiki/Applet_Manager_services#AppletMessage) - */ - enum class Message : u32 { - ExitRequested = 0x4, //!< The applet has been requested to exit - FocusStateChange = 0xF, //!< There was a change in the focus state of the applet - ExecutionResumed = 0x10, //!< The execution of the applet has resumed - OperationModeChange = 0x1E, //!< There was a change in the operation mode - PerformanceModeChange = 0x1F, //!< There was a change in the performance mode - RequestToDisplay = 0x33, //!< This indicates that ApproveToDisplay should be used - CaptureButtonShortPressed = 0x5A, //!< The Capture button was short pressed - ScreenshotTaken = 0x5C //!< A screenshot was taken - }; - - std::shared_ptr messageEvent; //!< The event signalled when there is a message available - std::queue messageQueue; - - enum class FocusState : u8 { - InFocus = 1, //!< The application is in foreground - OutOfFocus = 2 //!< The application is in the background - } focusState{FocusState::InFocus}; - - enum class OperationMode : u8 { - Handheld = 0, //!< The device is in handheld mode - Docked = 1 //!< The device is in docked mode - } operationMode; - - /** - * @brief This queues a message for the application to read via ReceiveMessage - * @param message The message to queue - */ - void QueueMessage(Message message); - - public: - ICommonStateGetter(const DeviceState &state, ServiceManager &manager); - - /** - * @brief This returns the handle to a KEvent object that is signalled whenever RecieveMessage has a message (https://switchbrew.org/wiki/Applet_Manager_services#GetEventHandle) - */ - void GetEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This returns an #AppletMessage or 0x680 to indicate the lack of a message (https://switchbrew.org/wiki/Applet_Manager_services#ReceiveMessage) - */ - void ReceiveMessage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This returns if an application is in focus or not. It always returns in focus on the emulator (https://switchbrew.org/wiki/Applet_Manager_services#GetCurrentFocusState) - */ - void GetCurrentFocusState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This returns the current OperationMode (https://switchbrew.org/wiki/Applet_Manager_services#GetOperationMode) - */ - void GetOperationMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @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); - }; - - /** - * @brief This has functions relating to an application's own current status (https://switchbrew.org/wiki/Applet_Manager_services#ISelfController) - */ - class ISelfController : public BaseService { - public: - ISelfController(const DeviceState &state, ServiceManager &manager); - - /** - * @brief This function takes a u8 bool flag and no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#SetOperationModeChangedNotification) - */ - void SetOperationModeChangedNotification(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This function takes a u8 bool flag and no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#SetPerformanceModeChangedNotification) - */ - void SetPerformanceModeChangedNotification(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This function takes 3 unknown u8 values and has no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#GetCurrentFocusState) - */ - void SetFocusHandlingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This function takes a u8 bool flag and has no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#SetOutOfFocusSuspendingEnabled) - */ - void SetOutOfFocusSuspendingEnabled(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This function returns an output u64 LayerId (https://switchbrew.org/wiki/Applet_Manager_services#CreateManagedDisplayLayer) - */ - void CreateManagedDisplayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - }; - - /** - * @brief This has functions used to retrieve the status of the application's window (https://switchbrew.org/wiki/Applet_Manager_services#IWindowController) - */ - class IWindowController : public BaseService { - public: - IWindowController(const DeviceState &state, ServiceManager &manager); - - /** - * @brief This returns the PID of the current application (https://switchbrew.org/wiki/Applet_Manager_services#GetAppletResourceUserId) - */ - void GetAppletResourceUserId(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - - /** - * @brief This function has mo inputs or outputs (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#AcquireForegroundRights) - */ - void AcquireForegroundRights(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - }; - - /** - * @brief This has functions relating to volume control (https://switchbrew.org/wiki/Applet_Manager_services#IAudioController) - */ - class IAudioController : public BaseService { - public: - IAudioController(const DeviceState &state, ServiceManager &manager); - }; - - /** - * @brief This has functions used to capture the contents of a display (https://switchbrew.org/wiki/Applet_Manager_services#IDisplayController) - */ - class IDisplayController : public BaseService { - public: - IDisplayController(const DeviceState &state, ServiceManager &manager); - }; - - /** - * @brief https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletCreator - */ - class ILibraryAppletCreator : public BaseService { - public: - ILibraryAppletCreator(const DeviceState &state, ServiceManager &manager); - }; - - /** - * @brief This has functions that are used to notify an application about it's state (https://switchbrew.org/wiki/Applet_Manager_services#IApplicationFunctions) - */ - class IApplicationFunctions : public BaseService { - public: - IApplicationFunctions(const DeviceState &state, ServiceManager &manager); - - /** - * @brief This returns if the application is running or not, always returns true (https://switchbrew.org/wiki/Applet_Manager_services#NotifyRunning) - */ - void NotifyRunning(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - }; - - /** - * @brief This has functions that are used for debugging purposes (https://switchbrew.org/wiki/Applet_Manager_services#IDebugFunctions) - */ - class IDebugFunctions : public BaseService { - 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/am/controller/IAppletCommonFunctions.cpp b/app/src/main/cpp/skyline/services/am/controller/IAppletCommonFunctions.cpp new file mode 100644 index 00000000..09f020d3 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IAppletCommonFunctions.cpp @@ -0,0 +1,6 @@ +#include "IAppletCommonFunctions.h" + +namespace skyline::service::am { + IAppletCommonFunctions::IAppletCommonFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IAppletCommonFunctions, "am:IAppletCommonFunctions", { + }) {} +} diff --git a/app/src/main/cpp/skyline/services/am/controller/IAppletCommonFunctions.h b/app/src/main/cpp/skyline/services/am/controller/IAppletCommonFunctions.h new file mode 100644 index 00000000..cb2c0cfd --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IAppletCommonFunctions.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @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/am/controller/IApplicationFunctions.cpp b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.cpp new file mode 100644 index 00000000..e09196ca --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.cpp @@ -0,0 +1,11 @@ +#include "IApplicationFunctions.h" + +namespace skyline::service::am { + IApplicationFunctions::IApplicationFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IApplicationFunctions, "am:IApplicationFunctions", { + {0x28, SFUNC(IApplicationFunctions::NotifyRunning)} + }) {} + + void IApplicationFunctions::NotifyRunning(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + response.Push(1); + } +} diff --git a/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h new file mode 100644 index 00000000..20173c9e --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @brief This has functions that are used to notify an application about it's state (https://switchbrew.org/wiki/Applet_Manager_services#IApplicationFunctions) + */ + class IApplicationFunctions : public BaseService { + public: + IApplicationFunctions(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This returns if the application is running or not, always returns true (https://switchbrew.org/wiki/Applet_Manager_services#NotifyRunning) + */ + void NotifyRunning(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/controller/IAudioController.cpp b/app/src/main/cpp/skyline/services/am/controller/IAudioController.cpp new file mode 100644 index 00000000..20eb5cd4 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IAudioController.cpp @@ -0,0 +1,6 @@ +#include "IAudioController.h" + +namespace skyline::service::am { + IAudioController::IAudioController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IAudioController, "am:IAudioController", { + }) {} +} diff --git a/app/src/main/cpp/skyline/services/am/controller/IAudioController.h b/app/src/main/cpp/skyline/services/am/controller/IAudioController.h new file mode 100644 index 00000000..0014eb6a --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IAudioController.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @brief This has functions relating to volume control (https://switchbrew.org/wiki/Applet_Manager_services#IAudioController) + */ + class IAudioController : public BaseService { + public: + IAudioController(const DeviceState &state, ServiceManager &manager); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.cpp b/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.cpp new file mode 100644 index 00000000..fbe4567e --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.cpp @@ -0,0 +1,59 @@ +#include +#include "ICommonStateGetter.h" + +namespace skyline::service::am { + void ICommonStateGetter::QueueMessage(ICommonStateGetter::Message message) { + messageQueue.emplace(message); + messageEvent->Signal(); + } + + ICommonStateGetter::ICommonStateGetter(const DeviceState &state, ServiceManager &manager) : messageEvent(std::make_shared(state)), BaseService(state, manager, Service::am_ICommonStateGetter, "am:ICommonStateGetter", { + {0x0, SFUNC(ICommonStateGetter::GetEventHandle)}, + {0x1, SFUNC(ICommonStateGetter::ReceiveMessage)}, + {0x5, SFUNC(ICommonStateGetter::GetOperationMode)}, + {0x6, SFUNC(ICommonStateGetter::GetPerformanceMode)}, + {0x9, SFUNC(ICommonStateGetter::GetCurrentFocusState)}, + {0x3C, SFUNC(ICommonStateGetter::GetDefaultDisplayResolution)} + }) { + operationMode = static_cast(state.settings->GetBool("operation_mode")); + state.logger->Info("Switch to mode: {}", static_cast(operationMode) ? "Docked" : "Handheld"); + QueueMessage(Message::FocusStateChange); + } + + void ICommonStateGetter::GetEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + auto handle = state.process->InsertItem(messageEvent); + state.logger->Debug("Applet Event Handle: 0x{:X}", handle); + response.copyHandles.push_back(handle); + } + + void ICommonStateGetter::ReceiveMessage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + if (messageQueue.empty()) { + response.errorCode = constant::status::NoMessages; + return; + } + response.Push(messageQueue.front()); + messageQueue.pop(); + } + + void ICommonStateGetter::GetCurrentFocusState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + response.Push(focusState); + } + + void ICommonStateGetter::GetOperationMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + response.Push(operationMode); + } + + void ICommonStateGetter::GetPerformanceMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + response.Push(static_cast(operationMode)); + } + + void ICommonStateGetter::GetDefaultDisplayResolution(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + if (operationMode == OperationMode::Handheld) { + response.Push(constant::HandheldResolutionW); + response.Push(constant::HandheldResolutionH); + } else if (operationMode == OperationMode::Docked) { + response.Push(constant::DockedResolutionW); + response.Push(constant::DockedResolutionH); + } + } +} diff --git a/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h b/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h new file mode 100644 index 00000000..1083bfa3 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h @@ -0,0 +1,80 @@ +#pragma once + +#include +#include +#include +#include + +namespace skyline::service::am { + /** + * @brief https://switchbrew.org/wiki/Applet_Manager_services#ICommonStateGetter + */ + class ICommonStateGetter : public BaseService { + private: + /** + * @brief This enumerates all the possible contents of a #AppletMessage (https://switchbrew.org/wiki/Applet_Manager_services#AppletMessage) + */ + enum class Message : u32 { + ExitRequested = 0x4, //!< The applet has been requested to exit + FocusStateChange = 0xF, //!< There was a change in the focus state of the applet + ExecutionResumed = 0x10, //!< The execution of the applet has resumed + OperationModeChange = 0x1E, //!< There was a change in the operation mode + PerformanceModeChange = 0x1F, //!< There was a change in the performance mode + RequestToDisplay = 0x33, //!< This indicates that ApproveToDisplay should be used + CaptureButtonShortPressed = 0x5A, //!< The Capture button was short pressed + ScreenshotTaken = 0x5C //!< A screenshot was taken + }; + + std::shared_ptr messageEvent; //!< The event signalled when there is a message available + std::queue messageQueue; + + enum class FocusState : u8 { + InFocus = 1, //!< The application is in foreground + OutOfFocus = 2 //!< The application is in the background + } focusState{FocusState::InFocus}; + + enum class OperationMode : u8 { + Handheld = 0, //!< The device is in handheld mode + Docked = 1 //!< The device is in docked mode + } operationMode; + + /** + * @brief This queues a message for the application to read via ReceiveMessage + * @param message The message to queue + */ + void QueueMessage(Message message); + + public: + ICommonStateGetter(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This returns the handle to a KEvent object that is signalled whenever RecieveMessage has a message (https://switchbrew.org/wiki/Applet_Manager_services#GetEventHandle) + */ + void GetEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns an #AppletMessage or 0x680 to indicate the lack of a message (https://switchbrew.org/wiki/Applet_Manager_services#ReceiveMessage) + */ + void ReceiveMessage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns if an application is in focus or not. It always returns in focus on the emulator (https://switchbrew.org/wiki/Applet_Manager_services#GetCurrentFocusState) + */ + void GetCurrentFocusState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns the current OperationMode (https://switchbrew.org/wiki/Applet_Manager_services#GetOperationMode) + */ + void GetOperationMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @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); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/controller/IDebugFunctions.cpp b/app/src/main/cpp/skyline/services/am/controller/IDebugFunctions.cpp new file mode 100644 index 00000000..d294ee96 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IDebugFunctions.cpp @@ -0,0 +1,6 @@ +#include "IDebugFunctions.h" + +namespace skyline::service::am { + IDebugFunctions::IDebugFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IDebugFunctions, "am:IDebugFunctions", { + }) {} +} diff --git a/app/src/main/cpp/skyline/services/am/controller/IDebugFunctions.h b/app/src/main/cpp/skyline/services/am/controller/IDebugFunctions.h new file mode 100644 index 00000000..2198576c --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IDebugFunctions.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @brief This has functions that are used for debugging purposes (https://switchbrew.org/wiki/Applet_Manager_services#IDebugFunctions) + */ + class IDebugFunctions : public BaseService { + public: + IDebugFunctions(const DeviceState &state, ServiceManager &manager); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/controller/IDisplayController.cpp b/app/src/main/cpp/skyline/services/am/controller/IDisplayController.cpp new file mode 100644 index 00000000..ab5bda2c --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IDisplayController.cpp @@ -0,0 +1,6 @@ +#include "IDisplayController.h" + +namespace skyline::service::am { + IDisplayController::IDisplayController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IDisplayController, "am:IDisplayController", { + }) {} +} diff --git a/app/src/main/cpp/skyline/services/am/controller/IDisplayController.h b/app/src/main/cpp/skyline/services/am/controller/IDisplayController.h new file mode 100644 index 00000000..38ab4cd3 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IDisplayController.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @brief This has functions used to capture the contents of a display (https://switchbrew.org/wiki/Applet_Manager_services#IDisplayController) + */ + class IDisplayController : public BaseService { + public: + IDisplayController(const DeviceState &state, ServiceManager &manager); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/controller/ILibraryAppletCreator.cpp b/app/src/main/cpp/skyline/services/am/controller/ILibraryAppletCreator.cpp new file mode 100644 index 00000000..e60f9445 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/ILibraryAppletCreator.cpp @@ -0,0 +1,6 @@ +#include "ILibraryAppletCreator.h" + +namespace skyline::service::am { + ILibraryAppletCreator::ILibraryAppletCreator(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_ILibraryAppletCreator, "am:ILibraryAppletCreator", { + }) {} +} diff --git a/app/src/main/cpp/skyline/services/am/controller/ILibraryAppletCreator.h b/app/src/main/cpp/skyline/services/am/controller/ILibraryAppletCreator.h new file mode 100644 index 00000000..6cd4f159 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/ILibraryAppletCreator.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @brief https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletCreator + */ + class ILibraryAppletCreator : public BaseService { + public: + ILibraryAppletCreator(const DeviceState &state, ServiceManager &manager); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/controller/ISelfController.cpp b/app/src/main/cpp/skyline/services/am/controller/ISelfController.cpp new file mode 100644 index 00000000..d3129e26 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/ISelfController.cpp @@ -0,0 +1,28 @@ +#include +#include "ISelfController.h" + +namespace skyline::service::am { + ISelfController::ISelfController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_ISelfController, "am:ISelfController", { + {0xB, SFUNC(ISelfController::SetOperationModeChangedNotification)}, + {0xC, SFUNC(ISelfController::SetPerformanceModeChangedNotification)}, + {0xD, SFUNC(ISelfController::SetFocusHandlingMode)}, + {0x10, SFUNC(ISelfController::SetOutOfFocusSuspendingEnabled)}, + {0x28, SFUNC(ISelfController::CreateManagedDisplayLayer)} + }) {} + + void ISelfController::SetOperationModeChangedNotification(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} + + void ISelfController::SetPerformanceModeChangedNotification(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} + + void ISelfController::SetFocusHandlingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} + + void ISelfController::SetOutOfFocusSuspendingEnabled(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} + + void ISelfController::CreateManagedDisplayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + state.logger->Debug("Creating Managed Layer"); + if (state.gpu->layerStatus == gpu::LayerStatus::Initialized) + throw exception("The application is creating more than one layer"); + state.gpu->layerStatus = gpu::LayerStatus::Initialized; + response.Push(0); + } +} diff --git a/app/src/main/cpp/skyline/services/am/controller/ISelfController.h b/app/src/main/cpp/skyline/services/am/controller/ISelfController.h new file mode 100644 index 00000000..fd206834 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/ISelfController.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @brief This has functions relating to an application's own current status (https://switchbrew.org/wiki/Applet_Manager_services#ISelfController) + */ + class ISelfController : public BaseService { + public: + ISelfController(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This function takes a u8 bool flag and no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#SetOperationModeChangedNotification) + */ + void SetOperationModeChangedNotification(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This function takes a u8 bool flag and no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#SetPerformanceModeChangedNotification) + */ + void SetPerformanceModeChangedNotification(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This function takes 3 unknown u8 values and has no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#GetCurrentFocusState) + */ + void SetFocusHandlingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This function takes a u8 bool flag and has no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#SetOutOfFocusSuspendingEnabled) + */ + void SetOutOfFocusSuspendingEnabled(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This function returns an output u64 LayerId (https://switchbrew.org/wiki/Applet_Manager_services#CreateManagedDisplayLayer) + */ + void CreateManagedDisplayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/controller/IWindowController.cpp b/app/src/main/cpp/skyline/services/am/controller/IWindowController.cpp new file mode 100644 index 00000000..ca321186 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IWindowController.cpp @@ -0,0 +1,15 @@ +#include +#include "IWindowController.h" + +namespace skyline::service::am { + IWindowController::IWindowController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IWindowController, "am:IWindowController", { + {0x1, SFUNC(IWindowController::GetAppletResourceUserId)}, + {0xA, SFUNC(IWindowController::AcquireForegroundRights)} + }) {} + + void IWindowController::GetAppletResourceUserId(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + response.Push(static_cast(state.process->pid)); + } + + void IWindowController::AcquireForegroundRights(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} +} diff --git a/app/src/main/cpp/skyline/services/am/controller/IWindowController.h b/app/src/main/cpp/skyline/services/am/controller/IWindowController.h new file mode 100644 index 00000000..530381d9 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/controller/IWindowController.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @brief This has functions used to retrieve the status of the application's window (https://switchbrew.org/wiki/Applet_Manager_services#IWindowController) + */ + class IWindowController : public BaseService { + public: + IWindowController(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This returns the PID of the current application (https://switchbrew.org/wiki/Applet_Manager_services#GetAppletResourceUserId) + */ + void GetAppletResourceUserId(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This function has mo inputs or outputs (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#AcquireForegroundRights) + */ + void AcquireForegroundRights(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/proxy/IApplicationProxy.cpp b/app/src/main/cpp/skyline/services/am/proxy/IApplicationProxy.cpp new file mode 100644 index 00000000..3413c677 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/proxy/IApplicationProxy.cpp @@ -0,0 +1,19 @@ +#include +#include "IApplicationProxy.h" + +namespace skyline::service::am { + IApplicationProxy::IApplicationProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_IApplicationProxy, "am:IApplicationProxy", { + {0x0, SFUNC(BaseProxy::GetCommonStateGetter)}, + {0x1, SFUNC(BaseProxy::GetSelfController)}, + {0x2, SFUNC(BaseProxy::GetWindowController)}, + {0x3, SFUNC(BaseProxy::GetAudioController)}, + {0x4, SFUNC(BaseProxy::GetDisplayController)}, + {0xB, SFUNC(BaseProxy::GetLibraryAppletCreator)}, + {0x14, SFUNC(IApplicationProxy::GetApplicationFunctions)}, + {0x3E8, SFUNC(BaseProxy::GetDebugFunctions)} + }) {} + + void IApplicationProxy::GetApplicationFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IApplicationFunctions), session, response); + } +} diff --git a/app/src/main/cpp/skyline/services/am/proxy/IApplicationProxy.h b/app/src/main/cpp/skyline/services/am/proxy/IApplicationProxy.h new file mode 100644 index 00000000..3c3710c4 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/proxy/IApplicationProxy.h @@ -0,0 +1,18 @@ +#pragma once + +#include "base_proxy.h" + +namespace skyline::service::am { + /** + * @brief IApplicationProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#IApplicationProxy) + */ + class IApplicationProxy : public BaseProxy { + public: + IApplicationProxy(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This returns #IApplicationFunctions (https://switchbrew.org/wiki/Applet_Manager_services#IApplicationFunctions) + */ + void GetApplicationFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/proxy/ILibraryAppletProxy.cpp b/app/src/main/cpp/skyline/services/am/proxy/ILibraryAppletProxy.cpp new file mode 100644 index 00000000..24d2138a --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/proxy/ILibraryAppletProxy.cpp @@ -0,0 +1,13 @@ +#include "ILibraryAppletProxy.h" + +namespace skyline::service::am { + ILibraryAppletProxy::ILibraryAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_ILibraryAppletProxy, "am:ILibraryAppletProxy", { + {0x0, SFUNC(BaseProxy::GetCommonStateGetter)}, + {0x1, SFUNC(BaseProxy::GetSelfController)}, + {0x2, SFUNC(BaseProxy::GetWindowController)}, + {0x3, SFUNC(BaseProxy::GetAudioController)}, + {0x4, SFUNC(BaseProxy::GetDisplayController)}, + {0xB, SFUNC(BaseProxy::GetLibraryAppletCreator)}, + {0x3E8, SFUNC(BaseProxy::GetDebugFunctions)} + }) {} +} diff --git a/app/src/main/cpp/skyline/services/am/proxy/ILibraryAppletProxy.h b/app/src/main/cpp/skyline/services/am/proxy/ILibraryAppletProxy.h new file mode 100644 index 00000000..6041c378 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/proxy/ILibraryAppletProxy.h @@ -0,0 +1,13 @@ +#pragma once + +#include "base_proxy.h" + +namespace skyline::service::am { + /** + * @brief ILibraryAppletProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletProxy) + */ + class ILibraryAppletProxy : public BaseProxy { + public: + ILibraryAppletProxy(const DeviceState &state, ServiceManager &manager); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/proxy/IOverlayAppletProxy.cpp b/app/src/main/cpp/skyline/services/am/proxy/IOverlayAppletProxy.cpp new file mode 100644 index 00000000..875bd01b --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/proxy/IOverlayAppletProxy.cpp @@ -0,0 +1,14 @@ +#include "IOverlayAppletProxy.h" + +namespace skyline::service::am { + IOverlayAppletProxy::IOverlayAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_IOverlayAppletProxy, "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/proxy/IOverlayAppletProxy.h b/app/src/main/cpp/skyline/services/am/proxy/IOverlayAppletProxy.h new file mode 100644 index 00000000..171cfbed --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/proxy/IOverlayAppletProxy.h @@ -0,0 +1,13 @@ +#pragma once + +#include "base_proxy.h" + +namespace skyline::service::am { + /** + * @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); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/proxy/ISystemAppletProxy.cpp b/app/src/main/cpp/skyline/services/am/proxy/ISystemAppletProxy.cpp new file mode 100644 index 00000000..25f8d3ac --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/proxy/ISystemAppletProxy.cpp @@ -0,0 +1,14 @@ +#include "ISystemAppletProxy.h" + +namespace skyline::service::am { + ISystemAppletProxy::ISystemAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_ISystemAppletProxy, "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)} + }) {} +} diff --git a/app/src/main/cpp/skyline/services/am/proxy/ISystemAppletProxy.h b/app/src/main/cpp/skyline/services/am/proxy/ISystemAppletProxy.h new file mode 100644 index 00000000..ba85ba56 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/proxy/ISystemAppletProxy.h @@ -0,0 +1,13 @@ +#pragma once + +#include "base_proxy.h" + +namespace skyline::service::am { + /** + * @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); + }; +} diff --git a/app/src/main/cpp/skyline/services/am/proxy/base_proxy.cpp b/app/src/main/cpp/skyline/services/am/proxy/base_proxy.cpp new file mode 100644 index 00000000..d6b32215 --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/proxy/base_proxy.cpp @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "base_proxy.h" + + +namespace skyline::service::am { + BaseProxy::BaseProxy(const DeviceState &state, ServiceManager &manager, const Service serviceType, const std::string &serviceName, const std::unordered_map> &vTable) : BaseService(state, manager, serviceType, serviceName, vTable) {} + + void BaseProxy::GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(ICommonStateGetter), session, response); + } + + void BaseProxy::GetSelfController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(ISelfController), session, response); + } + + void BaseProxy::GetWindowController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IWindowController), session, response); + } + + void BaseProxy::GetAudioController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IAudioController), session, response); + } + + void BaseProxy::GetDisplayController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IDisplayController), session, response); + } + + void BaseProxy::GetLibraryAppletCreator(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(ILibraryAppletCreator), session, response); + } + + void BaseProxy::GetDebugFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IDebugFunctions), session, response); + } + + void BaseProxy::GetAppletCommonFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(SRVREG(IAppletCommonFunctions), session, response); + } +} diff --git a/app/src/main/cpp/skyline/services/am/proxy/base_proxy.h b/app/src/main/cpp/skyline/services/am/proxy/base_proxy.h new file mode 100644 index 00000000..1ea3e84c --- /dev/null +++ b/app/src/main/cpp/skyline/services/am/proxy/base_proxy.h @@ -0,0 +1,54 @@ +#pragma once + +#include +#include + +namespace skyline::service::am { + /** + * @brief BaseProxy contains common functions used by most service proxies + */ + class BaseProxy : public BaseService { + public: + BaseProxy(const DeviceState &state, ServiceManager &manager, const Service serviceType, const std::string &serviceName, const std::unordered_map> &vTable); + + /** + * @brief This returns #ICommonStateGetter (https://switchbrew.org/wiki/Applet_Manager_services#ICommonStateGetter) + */ + void GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns #ISelfController (https://switchbrew.org/wiki/Applet_Manager_services#ISelfController) + */ + void GetSelfController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns #IWindowController (https://switchbrew.org/wiki/Applet_Manager_services#IWindowController) + */ + void GetWindowController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns #IAudioController (https://switchbrew.org/wiki/Applet_Manager_services#IAudioController) + */ + void GetAudioController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns #IDisplayController (https://switchbrew.org/wiki/Applet_Manager_services#IDisplayController) + */ + void GetDisplayController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns #ILibraryAppletCreator (https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletCreator) + */ + void GetLibraryAppletCreator(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @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); + }; +} diff --git a/app/src/main/cpp/skyline/services/base_service.h b/app/src/main/cpp/skyline/services/base_service.h index a5a25db9..7b5c9028 100644 --- a/app/src/main/cpp/skyline/services/base_service.h +++ b/app/src/main/cpp/skyline/services/base_service.h @@ -23,8 +23,8 @@ namespace skyline::service { settings_ISystemSettingsServer, apm_IManager, apm_ISession, - am_appletOE, - am_appletAE, + am_IAllSystemAppletProxiesService, + am_IApplicationProxyService, am_IApplicationProxy, am_ILibraryAppletProxy, am_ISystemAppletProxy, @@ -64,8 +64,8 @@ namespace skyline::service { {"fatal:u", Service::fatalsrv_IService}, {"set:sys", Service::settings_ISystemSettingsServer}, {"apm", Service::apm_IManager}, - {"appletOE", Service::am_appletOE}, - {"appletAE", Service::am_appletAE}, + {"appletOE", Service::am_IApplicationProxyService}, + {"appletAE", Service::am_IAllSystemAppletProxiesService}, {"audout:u", Service::audio_IAudioOutManager}, {"audren:u", Service::audio_IAudioRendererManager}, {"hid", Service::hid_IHidServer}, diff --git a/app/src/main/cpp/skyline/services/serviceman.cpp b/app/src/main/cpp/skyline/services/serviceman.cpp index e555267f..adf17b6a 100644 --- a/app/src/main/cpp/skyline/services/serviceman.cpp +++ b/app/src/main/cpp/skyline/services/serviceman.cpp @@ -2,8 +2,8 @@ #include "sm/IUserInterface.h" #include "settings/ISystemSettingsServer.h" #include "apm/IManager.h" -#include "am/applet.h" -#include "am/appletController.h" +#include "am/IApplicationProxyService.h" +#include "am/IAllSystemAppletProxiesService.h" #include "audio/IAudioOutManager.h" #include "audio/IAudioRendererManager.h" #include "fatalsrv/IService.h" @@ -35,11 +35,11 @@ namespace skyline::service { case Service::apm_IManager: serviceObj = std::make_shared(state, *this); break; - case Service::am_appletOE: - serviceObj = std::make_shared(state, *this); + case Service::am_IApplicationProxyService: + serviceObj = std::make_shared(state, *this); break; - case Service::am_appletAE: - serviceObj = std::make_shared(state, *this); + case Service::am_IAllSystemAppletProxiesService: + serviceObj = std::make_shared(state, *this); break; case Service::audio_IAudioOutManager: serviceObj = std::make_shared(state, *this);