mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 12:56:27 -05:00
am: rewrite IWindowController
This commit is contained in:
parent
203d213529
commit
87b740df46
8 changed files with 121 additions and 118 deletions
|
@ -481,12 +481,12 @@ add_library(core STATIC
|
||||||
hle/service/am/service/storage.h
|
hle/service/am/service/storage.h
|
||||||
hle/service/am/service/system_applet_proxy.cpp
|
hle/service/am/service/system_applet_proxy.cpp
|
||||||
hle/service/am/service/system_applet_proxy.h
|
hle/service/am/service/system_applet_proxy.h
|
||||||
|
hle/service/am/service/window_controller.cpp
|
||||||
|
hle/service/am/service/window_controller.h
|
||||||
hle/service/am/system_buffer_manager.cpp
|
hle/service/am/system_buffer_manager.cpp
|
||||||
hle/service/am/system_buffer_manager.h
|
hle/service/am/system_buffer_manager.h
|
||||||
hle/service/am/spsm.cpp
|
hle/service/am/spsm.cpp
|
||||||
hle/service/am/spsm.h
|
hle/service/am/spsm.h
|
||||||
hle/service/am/window_controller.cpp
|
|
||||||
hle/service/am/window_controller.h
|
|
||||||
hle/service/aoc/aoc_u.cpp
|
hle/service/aoc/aoc_u.cpp
|
||||||
hle/service/aoc/aoc_u.h
|
hle/service/aoc/aoc_u.h
|
||||||
hle/service/apm/apm.cpp
|
hle/service/apm/apm.cpp
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "core/hle/service/am/service/library_applet_creator.h"
|
#include "core/hle/service/am/service/library_applet_creator.h"
|
||||||
#include "core/hle/service/am/service/process_winding_controller.h"
|
#include "core/hle/service/am/service/process_winding_controller.h"
|
||||||
#include "core/hle/service/am/service/self_controller.h"
|
#include "core/hle/service/am/service/self_controller.h"
|
||||||
#include "core/hle/service/am/window_controller.h"
|
#include "core/hle/service/am/service/window_controller.h"
|
||||||
#include "core/hle/service/cmif_serialization.h"
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
|
|
||||||
namespace Service::AM {
|
namespace Service::AM {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "core/hle/service/am/service/library_applet_self_accessor.h"
|
#include "core/hle/service/am/service/library_applet_self_accessor.h"
|
||||||
#include "core/hle/service/am/service/process_winding_controller.h"
|
#include "core/hle/service/am/service/process_winding_controller.h"
|
||||||
#include "core/hle/service/am/service/self_controller.h"
|
#include "core/hle/service/am/service/self_controller.h"
|
||||||
#include "core/hle/service/am/window_controller.h"
|
#include "core/hle/service/am/service/window_controller.h"
|
||||||
#include "core/hle/service/cmif_serialization.h"
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
|
|
||||||
namespace Service::AM {
|
namespace Service::AM {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "core/hle/service/am/service/process_winding_controller.h"
|
#include "core/hle/service/am/service/process_winding_controller.h"
|
||||||
#include "core/hle/service/am/service/self_controller.h"
|
#include "core/hle/service/am/service/self_controller.h"
|
||||||
#include "core/hle/service/am/service/system_applet_proxy.h"
|
#include "core/hle/service/am/service/system_applet_proxy.h"
|
||||||
#include "core/hle/service/am/window_controller.h"
|
#include "core/hle/service/am/service/window_controller.h"
|
||||||
#include "core/hle/service/cmif_serialization.h"
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
|
|
||||||
namespace Service::AM {
|
namespace Service::AM {
|
||||||
|
|
86
src/core/hle/service/am/service/window_controller.cpp
Normal file
86
src/core/hle/service/am/service/window_controller.cpp
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "core/hle/service/am/applet.h"
|
||||||
|
#include "core/hle/service/am/applet_manager.h"
|
||||||
|
#include "core/hle/service/am/service/window_controller.h"
|
||||||
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
|
|
||||||
|
namespace Service::AM {
|
||||||
|
|
||||||
|
IWindowController::IWindowController(Core::System& system_, std::shared_ptr<Applet> applet)
|
||||||
|
: ServiceFramework{system_, "IWindowController"}, m_applet{std::move(applet)} {
|
||||||
|
// clang-format off
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{0, nullptr, "CreateWindow"},
|
||||||
|
{1, D<&IWindowController::GetAppletResourceUserId>, "GetAppletResourceUserId"},
|
||||||
|
{2, D<&IWindowController::GetAppletResourceUserIdOfCallerApplet>, "GetAppletResourceUserIdOfCallerApplet"},
|
||||||
|
{10, D<&IWindowController::AcquireForegroundRights>, "AcquireForegroundRights"},
|
||||||
|
{11, D<&IWindowController::ReleaseForegroundRights>, "ReleaseForegroundRights"},
|
||||||
|
{12, D<&IWindowController::RejectToChangeIntoBackground>, "RejectToChangeIntoBackground"},
|
||||||
|
{20, D<&IWindowController::SetAppletWindowVisibility>, "SetAppletWindowVisibility"},
|
||||||
|
{21, D<&IWindowController::SetAppletGpuTimeSlice>, "SetAppletGpuTimeSlice"},
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
IWindowController::~IWindowController() = default;
|
||||||
|
|
||||||
|
Result IWindowController::GetAppletResourceUserId(Out<AppletResourceUserId> out_aruid) {
|
||||||
|
LOG_INFO(Service_AM, "called");
|
||||||
|
*out_aruid = m_applet->aruid;
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result IWindowController::GetAppletResourceUserIdOfCallerApplet(
|
||||||
|
Out<AppletResourceUserId> out_aruid) {
|
||||||
|
LOG_INFO(Service_AM, "called");
|
||||||
|
|
||||||
|
if (auto caller_applet = m_applet->caller_applet.lock(); caller_applet != nullptr) {
|
||||||
|
*out_aruid = caller_applet->aruid;
|
||||||
|
} else {
|
||||||
|
*out_aruid = AppletResourceUserId{};
|
||||||
|
}
|
||||||
|
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result IWindowController::AcquireForegroundRights() {
|
||||||
|
LOG_INFO(Service_AM, "called");
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result IWindowController::ReleaseForegroundRights() {
|
||||||
|
LOG_INFO(Service_AM, "called");
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result IWindowController::RejectToChangeIntoBackground() {
|
||||||
|
LOG_INFO(Service_AM, "called");
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result IWindowController::SetAppletWindowVisibility(bool visible) {
|
||||||
|
m_applet->system_buffer_manager.SetWindowVisibility(visible);
|
||||||
|
m_applet->hid_registration.EnableAppletToGetInput(visible);
|
||||||
|
|
||||||
|
if (visible) {
|
||||||
|
m_applet->message_queue.PushMessage(AppletMessage::ChangeIntoForeground);
|
||||||
|
m_applet->focus_state = FocusState::InFocus;
|
||||||
|
} else {
|
||||||
|
m_applet->focus_state = FocusState::NotInFocus;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_applet->message_queue.PushMessage(AppletMessage::FocusStateChanged);
|
||||||
|
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result IWindowController::SetAppletGpuTimeSlice(s64 time_slice) {
|
||||||
|
LOG_WARNING(Service_AM, "(STUBBED) called, time_slice={}", time_slice);
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Service::AM
|
30
src/core/hle/service/am/service/window_controller.h
Normal file
30
src/core/hle/service/am/service/window_controller.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/cmif_types.h"
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Service::AM {
|
||||||
|
|
||||||
|
struct Applet;
|
||||||
|
|
||||||
|
class IWindowController final : public ServiceFramework<IWindowController> {
|
||||||
|
public:
|
||||||
|
explicit IWindowController(Core::System& system_, std::shared_ptr<Applet> applet);
|
||||||
|
~IWindowController() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Result GetAppletResourceUserId(Out<AppletResourceUserId> out_aruid);
|
||||||
|
Result GetAppletResourceUserIdOfCallerApplet(Out<AppletResourceUserId> out_aruid);
|
||||||
|
Result AcquireForegroundRights();
|
||||||
|
Result ReleaseForegroundRights();
|
||||||
|
Result RejectToChangeIntoBackground();
|
||||||
|
Result SetAppletWindowVisibility(bool visible);
|
||||||
|
Result SetAppletGpuTimeSlice(s64 time_slice);
|
||||||
|
|
||||||
|
const std::shared_ptr<Applet> m_applet;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Service::AM
|
|
@ -1,86 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#include "core/hle/service/am/applet.h"
|
|
||||||
#include "core/hle/service/am/window_controller.h"
|
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
|
||||||
|
|
||||||
namespace Service::AM {
|
|
||||||
|
|
||||||
IWindowController::IWindowController(Core::System& system_, std::shared_ptr<Applet> applet_)
|
|
||||||
: ServiceFramework{system_, "IWindowController"}, applet{std::move(applet_)} {
|
|
||||||
// clang-format off
|
|
||||||
static const FunctionInfo functions[] = {
|
|
||||||
{0, nullptr, "CreateWindow"},
|
|
||||||
{1, &IWindowController::GetAppletResourceUserId, "GetAppletResourceUserId"},
|
|
||||||
{2, &IWindowController::GetAppletResourceUserIdOfCallerApplet, "GetAppletResourceUserIdOfCallerApplet"},
|
|
||||||
{10, &IWindowController::AcquireForegroundRights, "AcquireForegroundRights"},
|
|
||||||
{11, nullptr, "ReleaseForegroundRights"},
|
|
||||||
{12, nullptr, "RejectToChangeIntoBackground"},
|
|
||||||
{20, &IWindowController::SetAppletWindowVisibility, "SetAppletWindowVisibility"},
|
|
||||||
{21, &IWindowController::SetAppletGpuTimeSlice, "SetAppletGpuTimeSlice"},
|
|
||||||
};
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
RegisterHandlers(functions);
|
|
||||||
}
|
|
||||||
|
|
||||||
IWindowController::~IWindowController() = default;
|
|
||||||
|
|
||||||
void IWindowController::GetAppletResourceUserId(HLERequestContext& ctx) {
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push<u64>(applet->aruid);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IWindowController::GetAppletResourceUserIdOfCallerApplet(HLERequestContext& ctx) {
|
|
||||||
u64 aruid = 0;
|
|
||||||
if (auto caller = applet->caller_applet.lock(); caller) {
|
|
||||||
aruid = caller->aruid;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push<u64>(aruid);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IWindowController::AcquireForegroundRights(HLERequestContext& ctx) {
|
|
||||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IWindowController::SetAppletWindowVisibility(HLERequestContext& ctx) {
|
|
||||||
LOG_INFO(Service_AM, "called");
|
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const bool visible = rp.Pop<bool>();
|
|
||||||
|
|
||||||
applet->system_buffer_manager.SetWindowVisibility(visible);
|
|
||||||
applet->hid_registration.EnableAppletToGetInput(visible);
|
|
||||||
|
|
||||||
if (visible) {
|
|
||||||
applet->focus_state = FocusState::InFocus;
|
|
||||||
applet->message_queue.PushMessage(AppletMessage::ChangeIntoForeground);
|
|
||||||
} else {
|
|
||||||
applet->focus_state = FocusState::NotInFocus;
|
|
||||||
applet->message_queue.PushMessage(AppletMessage::ChangeIntoBackground);
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IWindowController::SetAppletGpuTimeSlice(HLERequestContext& ctx) {
|
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto time_slice = rp.Pop<s64>();
|
|
||||||
|
|
||||||
LOG_WARNING(Service_AM, "(STUBBED) called, time_slice={}", time_slice);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Service::AM
|
|
|
@ -1,27 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "core/hle/service/service.h"
|
|
||||||
|
|
||||||
namespace Service::AM {
|
|
||||||
|
|
||||||
struct Applet;
|
|
||||||
|
|
||||||
class IWindowController final : public ServiceFramework<IWindowController> {
|
|
||||||
public:
|
|
||||||
explicit IWindowController(Core::System& system_, std::shared_ptr<Applet> applet_);
|
|
||||||
~IWindowController() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void GetAppletResourceUserId(HLERequestContext& ctx);
|
|
||||||
void GetAppletResourceUserIdOfCallerApplet(HLERequestContext& ctx);
|
|
||||||
void AcquireForegroundRights(HLERequestContext& ctx);
|
|
||||||
void SetAppletWindowVisibility(HLERequestContext& ctx);
|
|
||||||
void SetAppletGpuTimeSlice(HLERequestContext& ctx);
|
|
||||||
|
|
||||||
const std::shared_ptr<Applet> applet;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Service::AM
|
|
Loading…
Reference in a new issue