Implement ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent

This commit is contained in:
Billy Laws 2022-04-09 12:28:47 +01:00 committed by PixelyIon
parent 7e7c0252ca
commit 9813f9f8dc
2 changed files with 21 additions and 1 deletions

View File

@ -11,7 +11,10 @@ namespace skyline::service::am {
messageEvent->Signal();
}
ICommonStateGetter::ICommonStateGetter(const DeviceState &state, ServiceManager &manager) : messageEvent(std::make_shared<type::KEvent>(state, false)), BaseService(state, manager) {
ICommonStateGetter::ICommonStateGetter(const DeviceState &state, ServiceManager &manager)
: BaseService(state, manager),
messageEvent(std::make_shared<type::KEvent>(state, false)),
defaultDisplayResolutionChangeEvent(std::make_shared<type::KEvent>(state, false)) {
operationMode = static_cast<OperationMode>(state.settings->operationMode);
Logger::Info("Switch to mode: {}", static_cast<bool>(operationMode) ? "Docked" : "Handheld");
QueueMessage(Message::FocusStateChange);
@ -72,6 +75,15 @@ namespace skyline::service::am {
return {};
}
Result ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
// TODO: Implement properly when we support listeners for settings
auto handle{state.process->InsertItem(defaultDisplayResolutionChangeEvent)};
Logger::Debug("Default Display Resolution Change Event Handle: 0x{:X}", handle);
response.copyHandles.push_back(handle);
return {};
}
Result ICommonStateGetter::SetCpuBoostMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
cpuBoostMode = request.Pop<CpuBoostMode>();
switch (cpuBoostMode) {

View File

@ -59,6 +59,8 @@ namespace skyline::service::am {
ENUM_CASE_PAIR(PowerSaving, "Power Saving");
})
std::shared_ptr<type::KEvent> defaultDisplayResolutionChangeEvent; //!< Signalled when the default display resolution changes,
/**
* @brief Queues a message for the application to read via ReceiveMessage
* @param message The message to queue
@ -110,6 +112,11 @@ namespace skyline::service::am {
*/
Result GetDefaultDisplayResolution(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @url https://switchbrew.org/wiki/Applet_Manager_services#GetDefaultDisplayResolutionChangeEvent
*/
Result GetDefaultDisplayResolutionChangeEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @brief Sets the CPU boost mode to the supplied value
* @url https://switchbrew.org/wiki/Applet_Manager_services#SetCpuBoostMode
@ -124,6 +131,7 @@ namespace skyline::service::am {
SFUNC(0x9, ICommonStateGetter, GetCurrentFocusState),
SFUNC(0x32, ICommonStateGetter, IsVrModeEnabled),
SFUNC(0x3C, ICommonStateGetter, GetDefaultDisplayResolution),
SFUNC(0x3D, ICommonStateGetter, GetDefaultDisplayResolutionChangeEvent),
SFUNC(0x42, ICommonStateGetter, SetCpuBoostMode)
)
};