diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 4c465bd3..4bf47845 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -59,7 +59,8 @@ add_library(skyline SHARED ${source_DIR}/skyline/services/audio/IAudioRenderer/voice.cpp ${source_DIR}/skyline/services/audio/IAudioRenderer/memoryPool.cpp ${source_DIR}/skyline/services/settings/ISystemSettingsServer.cpp - ${source_DIR}/skyline/services/apm/apm.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/hid/IHidServer.cpp diff --git a/app/src/main/cpp/skyline/services/apm/IManager.cpp b/app/src/main/cpp/skyline/services/apm/IManager.cpp new file mode 100644 index 00000000..d0a6dd8c --- /dev/null +++ b/app/src/main/cpp/skyline/services/apm/IManager.cpp @@ -0,0 +1,12 @@ +#include "ISession.h" +#include "IManager.h" + +namespace skyline::service::apm { + IManager::IManager(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::apm_IManager, "apm:IManager", { + {0x0, SFUNC(IManager::OpenSession)} + }) {} + + void IManager::OpenSession(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(std::make_shared(state, manager), session, response); + } +} diff --git a/app/src/main/cpp/skyline/services/apm/IManager.h b/app/src/main/cpp/skyline/services/apm/IManager.h new file mode 100644 index 00000000..94f9828a --- /dev/null +++ b/app/src/main/cpp/skyline/services/apm/IManager.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +namespace skyline::service::apm { + /** + * @brief IManager is mostly only used to open an ISession (https://switchbrew.org/wiki/PPC_services#apm) + */ + class IManager : public BaseService { + public: + IManager(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This returns an handle to ISession + */ + void OpenSession(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; +} diff --git a/app/src/main/cpp/skyline/services/apm/apm.cpp b/app/src/main/cpp/skyline/services/apm/ISession.cpp similarity index 62% rename from app/src/main/cpp/skyline/services/apm/apm.cpp rename to app/src/main/cpp/skyline/services/apm/ISession.cpp index 94b08bec..d58beb88 100644 --- a/app/src/main/cpp/skyline/services/apm/apm.cpp +++ b/app/src/main/cpp/skyline/services/apm/ISession.cpp @@ -1,14 +1,6 @@ -#include "apm.h" +#include "ISession.h" namespace skyline::service::apm { - apm::apm(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::apm, "apm", { - {0x0, SFUNC(apm::OpenSession)} - }) {} - - void apm::OpenSession(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(std::make_shared(state, manager), session, response); - } - ISession::ISession(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::apm_ISession, "apm:ISession", { {0x0, SFUNC(ISession::SetPerformanceConfiguration)}, {0x1, SFUNC(ISession::GetPerformanceConfiguration)} @@ -17,12 +9,12 @@ namespace skyline::service::apm { void ISession::SetPerformanceConfiguration(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { auto mode = request.Pop(); auto config = request.Pop(); - performanceConfig[mode] = config; + performanceConfig.at(mode) = config; state.logger->Info("SetPerformanceConfiguration called with 0x{:X} ({})", config, mode ? "Docked" : "Handheld"); } void ISession::GetPerformanceConfiguration(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { u32 performanceMode = request.Pop(); - response.Push(performanceConfig[performanceMode]); + response.Push(performanceConfig.at(performanceMode)); } } diff --git a/app/src/main/cpp/skyline/services/apm/apm.h b/app/src/main/cpp/skyline/services/apm/ISession.h similarity index 56% rename from app/src/main/cpp/skyline/services/apm/apm.h rename to app/src/main/cpp/skyline/services/apm/ISession.h index 503f6e78..37443a24 100644 --- a/app/src/main/cpp/skyline/services/apm/apm.h +++ b/app/src/main/cpp/skyline/services/apm/ISession.h @@ -5,24 +5,11 @@ namespace skyline::service::apm { /** - * @brief apm is used to control performance modes of the device, this service however is mostly only used to open an ISession (https://switchbrew.org/wiki/PPC_services#apm) - */ - class apm : public BaseService { - public: - apm(const DeviceState &state, ServiceManager &manager); - - /** - * @brief This returns an handle to ISession - */ - void OpenSession(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - }; - - /** - * @brief apm:ISession is a service opened when OpenSession is called by apm + * @brief ISession is a service opened when OpenSession is called by apm for controlling performance */ class ISession : public BaseService { private: - u32 performanceConfig[2] = {0x00010000, 0x00020001}; //!< This holds the performance config for both handheld(0) and docked(1) mode + std::array performanceConfig = {0x00010000, 0x00020001}; //!< This holds the performance config for both handheld(0) and docked(1) mode public: ISession(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 29c423db..a5a25db9 100644 --- a/app/src/main/cpp/skyline/services/base_service.h +++ b/app/src/main/cpp/skyline/services/base_service.h @@ -21,7 +21,7 @@ namespace skyline::service { sm_IUserInterface, fatalsrv_IService, settings_ISystemSettingsServer, - apm, + apm_IManager, apm_ISession, am_appletOE, am_appletAE, @@ -63,7 +63,7 @@ namespace skyline::service { const static std::unordered_map ServiceString{ {"fatal:u", Service::fatalsrv_IService}, {"set:sys", Service::settings_ISystemSettingsServer}, - {"apm", Service::apm}, + {"apm", Service::apm_IManager}, {"appletOE", Service::am_appletOE}, {"appletAE", Service::am_appletAE}, {"audout:u", Service::audio_IAudioOutManager}, diff --git a/app/src/main/cpp/skyline/services/serviceman.cpp b/app/src/main/cpp/skyline/services/serviceman.cpp index 411044cf..e555267f 100644 --- a/app/src/main/cpp/skyline/services/serviceman.cpp +++ b/app/src/main/cpp/skyline/services/serviceman.cpp @@ -1,7 +1,7 @@ #include #include "sm/IUserInterface.h" #include "settings/ISystemSettingsServer.h" -#include "apm/apm.h" +#include "apm/IManager.h" #include "am/applet.h" #include "am/appletController.h" #include "audio/IAudioOutManager.h" @@ -32,8 +32,8 @@ namespace skyline::service { case Service::settings_ISystemSettingsServer: serviceObj = std::make_shared(state, *this); break; - case Service::apm: - serviceObj = std::make_shared(state, *this); + case Service::apm_IManager: + serviceObj = std::make_shared(state, *this); break; case Service::am_appletOE: serviceObj = std::make_shared(state, *this);