mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 22:25:30 +03:00
Refactor apm services
Use the new service naming scheme. Switch to std::array for performanceConfig.
This commit is contained in:
parent
52d47120a8
commit
616222a6db
@ -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
|
||||
|
12
app/src/main/cpp/skyline/services/apm/IManager.cpp
Normal file
12
app/src/main/cpp/skyline/services/apm/IManager.cpp
Normal file
@ -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<ISession>(state, manager), session, response);
|
||||
}
|
||||
}
|
19
app/src/main/cpp/skyline/services/apm/IManager.h
Normal file
19
app/src/main/cpp/skyline/services/apm/IManager.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <services/base_service.h>
|
||||
#include <services/serviceman.h>
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
@ -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<ISession>(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<u32>();
|
||||
auto config = request.Pop<u32>();
|
||||
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<u32>();
|
||||
response.Push<u32>(performanceConfig[performanceMode]);
|
||||
response.Push<u32>(performanceConfig.at(performanceMode));
|
||||
}
|
||||
}
|
@ -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<u32, 2> performanceConfig = {0x00010000, 0x00020001}; //!< This holds the performance config for both handheld(0) and docked(1) mode
|
||||
|
||||
public:
|
||||
ISession(const DeviceState &state, ServiceManager &manager);
|
@ -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<std::string, Service> 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},
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <kernel/types/KProcess.h>
|
||||
#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<settings::ISystemSettingsServer>(state, *this);
|
||||
break;
|
||||
case Service::apm:
|
||||
serviceObj = std::make_shared<apm::apm>(state, *this);
|
||||
case Service::apm_IManager:
|
||||
serviceObj = std::make_shared<apm::IManager>(state, *this);
|
||||
break;
|
||||
case Service::am_appletOE:
|
||||
serviceObj = std::make_shared<am::appletOE>(state, *this);
|
||||
|
Loading…
Reference in New Issue
Block a user