Implement additional applet services and functions

This commit implements the services ISystemAppletProxy, IOverlayAppletProxy & IAppletCommonFunctions and implements the function GetDefaultDisplayResolution.
This commit is contained in:
greggameplayer 2019-11-17 23:29:58 +01:00 committed by ◱ PixelyIon
parent 0d141b71e9
commit 42239ae58b
6 changed files with 113 additions and 3 deletions

View File

@ -10,9 +10,12 @@ namespace skyline::kernel::service::am {
manager.RegisterService(SRVREG(IApplicationProxy), session, response); 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)}, {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) { 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); 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<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable) : BaseService(state, manager, false, serviceType, vTable) {} BaseProxy::BaseProxy(const DeviceState &state, ServiceManager &manager, Service serviceType, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable) : BaseService(state, manager, false, serviceType, vTable) {}
void BaseProxy::GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { 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); 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, { IApplicationProxy::IApplicationProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_IApplicationProxy, {
{0x0, SFUNC(BaseProxy::GetCommonStateGetter)}, {0x0, SFUNC(BaseProxy::GetCommonStateGetter)},
{0x1, SFUNC(BaseProxy::GetSelfController)}, {0x1, SFUNC(BaseProxy::GetSelfController)},
@ -77,4 +92,26 @@ namespace skyline::kernel::service::am {
{0xB, SFUNC(BaseProxy::GetLibraryAppletCreator)}, {0xB, SFUNC(BaseProxy::GetLibraryAppletCreator)},
{0x3E8, SFUNC(BaseProxy::GetDebugFunctions)} {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)}
}) {}
} }

View File

@ -33,6 +33,16 @@ namespace skyline::kernel::service::am {
* @brief This returns #IApplicationProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenApplicationProxy) * @brief This returns #IApplicationProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenApplicationProxy)
*/ */
void OpenApplicationProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); 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) * @brief This returns #IDebugFunctions (https://switchbrew.org/wiki/Applet_Manager_services#IDebugFunctions)
*/ */
void GetDebugFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); 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); 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) * @brief ILibraryAppletProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletProxy)
*/ */

View File

@ -11,7 +11,8 @@ namespace skyline::kernel::service::am {
{0x1, SFUNC(ICommonStateGetter::ReceiveMessage)}, {0x1, SFUNC(ICommonStateGetter::ReceiveMessage)},
{0x9, SFUNC(ICommonStateGetter::GetCurrentFocusState)}, {0x9, SFUNC(ICommonStateGetter::GetCurrentFocusState)},
{0x5, SFUNC(ICommonStateGetter::GetOperationMode)}, {0x5, SFUNC(ICommonStateGetter::GetOperationMode)},
{0x6, SFUNC(ICommonStateGetter::GetPerformanceMode)} {0x6, SFUNC(ICommonStateGetter::GetPerformanceMode)},
{0x3C, SFUNC(ICommonStateGetter::GetDefaultDisplayResolution)}
}) { }) {
operationMode = static_cast<OperationMode>(state.settings->GetBool("operation_mode")); operationMode = static_cast<OperationMode>(state.settings->GetBool("operation_mode"));
state.logger->Info("Switch on mode: {}", static_cast<bool>(operationMode) ? "Docked" : "Handheld"); state.logger->Info("Switch on mode: {}", static_cast<bool>(operationMode) ? "Docked" : "Handheld");
@ -45,6 +46,16 @@ namespace skyline::kernel::service::am {
response.WriteValue<u32>(static_cast<u32>(operationMode)); response.WriteValue<u32>(static_cast<u32>(operationMode));
} }
void ICommonStateGetter::GetDefaultDisplayResolution(type::KSession& session, ipc::IpcRequest& request, ipc::IpcResponse& response) {
if (operationMode == OperationMode::Handheld) {
response.WriteValue<u32>(constant::HandheldResolutionW);
response.WriteValue<u32>(constant::HandheldResolutionH);
} else if (operationMode == OperationMode::Docked) {
response.WriteValue<u32>(constant::DockedResolutionW);
response.WriteValue<u32>(constant::DockedResolutionH);
}
}
ISelfController::ISelfController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_ISelfController, { ISelfController::ISelfController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_ISelfController, {
{0xB, SFUNC(ISelfController::SetOperationModeChangedNotification)}, {0xB, SFUNC(ISelfController::SetOperationModeChangedNotification)},
{0xC, SFUNC(ISelfController::SetPerformanceModeChangedNotification)}, {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, { 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, {
}) {}
} }

View File

@ -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) * @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); 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: public:
IDebugFunctions(const DeviceState &state, ServiceManager &manager); 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);
};
} }

View File

@ -24,6 +24,8 @@ namespace skyline::kernel::service {
am_appletAE, am_appletAE,
am_IApplicationProxy, am_IApplicationProxy,
am_ILibraryAppletProxy, am_ILibraryAppletProxy,
am_ISystemAppletProxy,
am_IOverlayAppletProxy,
am_ICommonStateGetter, am_ICommonStateGetter,
am_IApplicationFunctions, am_IApplicationFunctions,
am_ISelfController, am_ISelfController,
@ -32,6 +34,7 @@ namespace skyline::kernel::service {
am_IDisplayController, am_IDisplayController,
am_ILibraryAppletCreator, am_ILibraryAppletCreator,
am_IDebugFunctions, am_IDebugFunctions,
am_IAppletCommonFunctions,
hid, hid,
hid_IAppletResource, hid_IAppletResource,
time, time,
@ -60,6 +63,8 @@ namespace skyline::kernel::service {
{"appletAE", Service::am_appletAE}, {"appletAE", Service::am_appletAE},
{"am:IApplicationProxy", Service::am_IApplicationProxy}, {"am:IApplicationProxy", Service::am_IApplicationProxy},
{"am:ILibraryAppletProxy", Service::am_ILibraryAppletProxy}, {"am:ILibraryAppletProxy", Service::am_ILibraryAppletProxy},
{"am:ISystemAppletProxy", Service::am_ISystemAppletProxy},
{"am:IOverlayAppletProxy", Service::am_IOverlayAppletProxy},
{"am:ICommonStateGetter", Service::am_ICommonStateGetter}, {"am:ICommonStateGetter", Service::am_ICommonStateGetter},
{"am:ISelfController", Service::am_ISelfController}, {"am:ISelfController", Service::am_ISelfController},
{"am:IWindowController", Service::am_IWindowController}, {"am:IWindowController", Service::am_IWindowController},
@ -68,6 +73,7 @@ namespace skyline::kernel::service {
{"am:ILibraryAppletCreator", Service::am_ILibraryAppletCreator}, {"am:ILibraryAppletCreator", Service::am_ILibraryAppletCreator},
{"am:IApplicationFunctions", Service::am_IApplicationFunctions}, {"am:IApplicationFunctions", Service::am_IApplicationFunctions},
{"am:IDebugFunctions", Service::am_IDebugFunctions}, {"am:IDebugFunctions", Service::am_IDebugFunctions},
{"am:IAppletCommonFunctions", Service::am_IAppletCommonFunctions},
{"hid", Service::hid}, {"hid", Service::hid},
{"hid:IAppletResource", Service::hid_IAppletResource}, {"hid:IAppletResource", Service::hid_IAppletResource},
{"time:s", Service::time}, {"time:s", Service::time},

View File

@ -46,6 +46,12 @@ namespace skyline::kernel::service {
case Service::am_ILibraryAppletProxy: case Service::am_ILibraryAppletProxy:
serviceObj = std::make_shared<am::ILibraryAppletProxy>(state, *this); serviceObj = std::make_shared<am::ILibraryAppletProxy>(state, *this);
break; break;
case Service::am_ISystemAppletProxy:
serviceObj = std::make_shared<am::ISystemAppletProxy>(state, *this);
break;
case Service::am_IOverlayAppletProxy:
serviceObj = std::make_shared<am::IOverlayAppletProxy>(state, *this);
break;
case Service::am_ICommonStateGetter: case Service::am_ICommonStateGetter:
serviceObj = std::make_shared<am::ICommonStateGetter>(state, *this); serviceObj = std::make_shared<am::ICommonStateGetter>(state, *this);
break; break;
@ -70,6 +76,9 @@ namespace skyline::kernel::service {
case Service::am_IDebugFunctions: case Service::am_IDebugFunctions:
serviceObj = std::make_shared<am::IDebugFunctions>(state, *this); serviceObj = std::make_shared<am::IDebugFunctions>(state, *this);
break; break;
case Service::am_IAppletCommonFunctions:
serviceObj = std::make_shared<am::IAppletCommonFunctions>(state, *this);
break;
case Service::hid: case Service::hid:
serviceObj = std::make_shared<hid::hid>(state, *this); serviceObj = std::make_shared<hid::hid>(state, *this);
break; break;