summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/am')
-rw-r--r--src/core/hle/service/am/am_types.h7
-rw-r--r--src/core/hle/service/am/applet.h3
-rw-r--r--src/core/hle/service/am/applet_common_functions.cpp9
-rw-r--r--src/core/hle/service/am/applet_common_functions.h1
-rw-r--r--src/core/hle/service/am/application_proxy.cpp2
-rw-r--r--src/core/hle/service/am/common_state_getter.cpp23
-rw-r--r--src/core/hle/service/am/common_state_getter.h1
-rw-r--r--src/core/hle/service/am/display_controller.cpp64
-rw-r--r--src/core/hle/service/am/display_controller.h8
-rw-r--r--src/core/hle/service/am/hid_registration.cpp6
-rw-r--r--src/core/hle/service/am/hid_registration.h2
-rw-r--r--src/core/hle/service/am/library_applet_creator.cpp27
-rw-r--r--src/core/hle/service/am/library_applet_proxy.cpp2
-rw-r--r--src/core/hle/service/am/library_applet_self_accessor.cpp114
-rw-r--r--src/core/hle/service/am/library_applet_self_accessor.h4
-rw-r--r--src/core/hle/service/am/self_controller.cpp13
-rw-r--r--src/core/hle/service/am/self_controller.h1
-rw-r--r--src/core/hle/service/am/system_applet_proxy.cpp2
-rw-r--r--src/core/hle/service/am/system_buffer_manager.cpp20
-rw-r--r--src/core/hle/service/am/system_buffer_manager.h7
-rw-r--r--src/core/hle/service/am/window_controller.cpp35
-rw-r--r--src/core/hle/service/am/window_controller.h2
22 files changed, 316 insertions, 37 deletions
diff --git a/src/core/hle/service/am/am_types.h b/src/core/hle/service/am/am_types.h
index d47028b80..a2b852b12 100644
--- a/src/core/hle/service/am/am_types.h
+++ b/src/core/hle/service/am/am_types.h
@@ -162,6 +162,13 @@ struct CommonArguments {
};
static_assert(sizeof(CommonArguments) == 0x20, "CommonArguments has incorrect size.");
+struct AppletIdentityInfo {
+ AppletId applet_id;
+ INSERT_PADDING_BYTES(0x4);
+ u64 application_id;
+};
+static_assert(sizeof(AppletIdentityInfo) == 0x10, "AppletIdentityInfo has incorrect size.");
+
using AppletResourceUserId = u64;
using ProgramId = u64;
diff --git a/src/core/hle/service/am/applet.h b/src/core/hle/service/am/applet.h
index 65bfbc250..bce6f9050 100644
--- a/src/core/hle/service/am/applet.h
+++ b/src/core/hle/service/am/applet.h
@@ -49,6 +49,9 @@ struct Applet {
s32 previous_program_index{-1};
ScreenshotPermission previous_screenshot_permission{ScreenshotPermission::Enable};
+ // TODO: some fields above can be AppletIdentityInfo
+ AppletIdentityInfo screen_shot_identity;
+
// hid state
HidRegistration hid_registration;
diff --git a/src/core/hle/service/am/applet_common_functions.cpp b/src/core/hle/service/am/applet_common_functions.cpp
index a5c54ce87..130614ae5 100644
--- a/src/core/hle/service/am/applet_common_functions.cpp
+++ b/src/core/hle/service/am/applet_common_functions.cpp
@@ -31,6 +31,7 @@ IAppletCommonFunctions::IAppletCommonFunctions(Core::System& system_,
{90, nullptr, "OpenNamedChannelAsParent"},
{91, nullptr, "OpenNamedChannelAsChild"},
{100, nullptr, "SetApplicationCoreUsageMode"},
+ {300, &IAppletCommonFunctions::GetCurrentApplicationId, "GetCurrentApplicationId"},
};
// clang-format on
@@ -51,4 +52,12 @@ void IAppletCommonFunctions::SetCpuBoostRequestPriority(HLERequestContext& ctx)
rb.Push(ResultSuccess);
}
+void IAppletCommonFunctions::GetCurrentApplicationId(HLERequestContext& ctx) {
+ LOG_WARNING(Service_AM, "(STUBBED) called");
+
+ IPC::ResponseBuilder rb{ctx, 4};
+ rb.Push(ResultSuccess);
+ rb.Push<u64>(system.GetApplicationProcessProgramID() & ~0xFFFULL);
+}
+
} // namespace Service::AM
diff --git a/src/core/hle/service/am/applet_common_functions.h b/src/core/hle/service/am/applet_common_functions.h
index 229555669..b86adf5cb 100644
--- a/src/core/hle/service/am/applet_common_functions.h
+++ b/src/core/hle/service/am/applet_common_functions.h
@@ -16,6 +16,7 @@ public:
private:
void SetCpuBoostRequestPriority(HLERequestContext& ctx);
+ void GetCurrentApplicationId(HLERequestContext& ctx);
const std::shared_ptr<Applet> applet;
};
diff --git a/src/core/hle/service/am/application_proxy.cpp b/src/core/hle/service/am/application_proxy.cpp
index 99e97f4bc..a6fd6d37f 100644
--- a/src/core/hle/service/am/application_proxy.cpp
+++ b/src/core/hle/service/am/application_proxy.cpp
@@ -53,7 +53,7 @@ void IApplicationProxy::GetDisplayController(HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
- rb.PushIpcInterface<IDisplayController>(system);
+ rb.PushIpcInterface<IDisplayController>(system, applet);
}
void IApplicationProxy::GetProcessWindingController(HLERequestContext& ctx) {
diff --git a/src/core/hle/service/am/common_state_getter.cpp b/src/core/hle/service/am/common_state_getter.cpp
index 77f3fd868..937ac0beb 100644
--- a/src/core/hle/service/am/common_state_getter.cpp
+++ b/src/core/hle/service/am/common_state_getter.cpp
@@ -60,7 +60,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Ap
{91, nullptr, "GetCurrentPerformanceConfiguration"},
{100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"},
{110, nullptr, "OpenMyGpuErrorHandler"},
- {120, nullptr, "GetAppletLaunchedHistory"},
+ {120, &ICommonStateGetter::GetAppletLaunchedHistory, "GetAppletLaunchedHistory"},
{200, nullptr, "GetOperationModeSystemInfo"},
{300, &ICommonStateGetter::GetSettingsPlatformRegion, "GetSettingsPlatformRegion"},
{400, nullptr, "ActivateMigrationService"},
@@ -271,6 +271,27 @@ void ICommonStateGetter::PerformSystemButtonPressingIfInFocus(HLERequestContext&
rb.Push(ResultSuccess);
}
+void ICommonStateGetter::GetAppletLaunchedHistory(HLERequestContext& ctx) {
+ LOG_WARNING(Service_AM, "(STUBBED) called");
+
+ std::shared_ptr<Applet> current_applet = applet;
+ std::vector<AppletId> result;
+
+ const size_t count = ctx.GetWriteBufferNumElements<AppletId>();
+ size_t i;
+
+ for (i = 0; i < count && current_applet != nullptr; i++) {
+ result.push_back(current_applet->applet_id);
+ current_applet = current_applet->caller_applet.lock();
+ }
+
+ ctx.WriteBuffer(result);
+
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(ResultSuccess);
+ rb.Push(static_cast<u32>(i));
+}
+
void ICommonStateGetter::GetSettingsPlatformRegion(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
diff --git a/src/core/hle/service/am/common_state_getter.h b/src/core/hle/service/am/common_state_getter.h
index 643ca4dc5..bf652790c 100644
--- a/src/core/hle/service/am/common_state_getter.h
+++ b/src/core/hle/service/am/common_state_getter.h
@@ -67,6 +67,7 @@ private:
void SetCpuBoostMode(HLERequestContext& ctx);
void GetBuiltInDisplayType(HLERequestContext& ctx);
void PerformSystemButtonPressingIfInFocus(HLERequestContext& ctx);
+ void GetAppletLaunchedHistory(HLERequestContext& ctx);
void GetSettingsPlatformRegion(HLERequestContext& ctx);
void SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(HLERequestContext& ctx);
diff --git a/src/core/hle/service/am/display_controller.cpp b/src/core/hle/service/am/display_controller.cpp
index d4d3d60e7..4d6858348 100644
--- a/src/core/hle/service/am/display_controller.cpp
+++ b/src/core/hle/service/am/display_controller.cpp
@@ -1,13 +1,23 @@
// 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/display_controller.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::AM {
-IDisplayController::IDisplayController(Core::System& system_)
- : ServiceFramework{system_, "IDisplayController"} {
+namespace {
+struct OutputParameters {
+ bool was_written;
+ s32 fbshare_layer_index;
+};
+
+static_assert(sizeof(OutputParameters) == 8, "OutputParameters has wrong size");
+} // namespace
+
+IDisplayController::IDisplayController(Core::System& system_, std::shared_ptr<Applet> applet_)
+ : ServiceFramework{system_, "IDisplayController"}, applet(std::move(applet_)) {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "GetLastForegroundCaptureImage"},
@@ -31,8 +41,8 @@ IDisplayController::IDisplayController(Core::System& system_)
{18, nullptr, "AcquireCallerAppletCaptureBufferEx"},
{20, nullptr, "ClearCaptureBuffer"},
{21, nullptr, "ClearAppletTransitionBuffer"},
- {22, nullptr, "AcquireLastApplicationCaptureSharedBuffer"},
- {23, nullptr, "ReleaseLastApplicationCaptureSharedBuffer"},
+ {22, &IDisplayController::AcquireLastApplicationCaptureSharedBuffer, "AcquireLastApplicationCaptureSharedBuffer"},
+ {23, &IDisplayController::ReleaseLastApplicationCaptureSharedBuffer, "ReleaseLastApplicationCaptureSharedBuffer"},
{24, &IDisplayController::AcquireLastForegroundCaptureSharedBuffer, "AcquireLastForegroundCaptureSharedBuffer"},
{25, &IDisplayController::ReleaseLastForegroundCaptureSharedBuffer, "ReleaseLastForegroundCaptureSharedBuffer"},
{26, &IDisplayController::AcquireCallerAppletCaptureSharedBuffer, "AcquireCallerAppletCaptureSharedBuffer"},
@@ -49,10 +59,13 @@ IDisplayController::~IDisplayController() = default;
void IDisplayController::GetCallerAppletCaptureImageEx(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
+ OutputParameters params{};
+ const auto res = applet->system_buffer_manager.WriteAppletCaptureBuffer(
+ &params.was_written, &params.fbshare_layer_index);
+
IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(ResultSuccess);
- rb.Push(1u);
- rb.Push(1);
+ rb.Push(res);
+ rb.PushRaw(params);
}
void IDisplayController::TakeScreenShotOfOwnLayer(HLERequestContext& ctx) {
@@ -62,13 +75,35 @@ void IDisplayController::TakeScreenShotOfOwnLayer(HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}
-void IDisplayController::AcquireLastForegroundCaptureSharedBuffer(HLERequestContext& ctx) {
+void IDisplayController::AcquireLastApplicationCaptureSharedBuffer(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
+ OutputParameters params{};
+ const auto res = applet->system_buffer_manager.WriteAppletCaptureBuffer(
+ &params.was_written, &params.fbshare_layer_index);
+
IPC::ResponseBuilder rb{ctx, 4};
+ rb.Push(res);
+ rb.PushRaw(params);
+}
+
+void IDisplayController::ReleaseLastApplicationCaptureSharedBuffer(HLERequestContext& ctx) {
+ LOG_WARNING(Service_AM, "(STUBBED) called");
+
+ IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
- rb.Push(1U);
- rb.Push(1);
+}
+
+void IDisplayController::AcquireLastForegroundCaptureSharedBuffer(HLERequestContext& ctx) {
+ LOG_WARNING(Service_AM, "(STUBBED) called");
+
+ OutputParameters params{};
+ const auto res = applet->system_buffer_manager.WriteAppletCaptureBuffer(
+ &params.was_written, &params.fbshare_layer_index);
+
+ IPC::ResponseBuilder rb{ctx, 4};
+ rb.Push(res);
+ rb.PushRaw(params);
}
void IDisplayController::ReleaseLastForegroundCaptureSharedBuffer(HLERequestContext& ctx) {
@@ -81,10 +116,13 @@ void IDisplayController::ReleaseLastForegroundCaptureSharedBuffer(HLERequestCont
void IDisplayController::AcquireCallerAppletCaptureSharedBuffer(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
+ OutputParameters params{};
+ const auto res = applet->system_buffer_manager.WriteAppletCaptureBuffer(
+ &params.was_written, &params.fbshare_layer_index);
+
IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(ResultSuccess);
- rb.Push(1U);
- rb.Push(1);
+ rb.Push(res);
+ rb.PushRaw(params);
}
void IDisplayController::ReleaseCallerAppletCaptureSharedBuffer(HLERequestContext& ctx) {
diff --git a/src/core/hle/service/am/display_controller.h b/src/core/hle/service/am/display_controller.h
index 32f819294..75172580c 100644
--- a/src/core/hle/service/am/display_controller.h
+++ b/src/core/hle/service/am/display_controller.h
@@ -7,9 +7,11 @@
namespace Service::AM {
+struct Applet;
+
class IDisplayController final : public ServiceFramework<IDisplayController> {
public:
- explicit IDisplayController(Core::System& system_);
+ explicit IDisplayController(Core::System& system_, std::shared_ptr<Applet> applet_);
~IDisplayController() override;
private:
@@ -19,6 +21,10 @@ private:
void ReleaseLastForegroundCaptureSharedBuffer(HLERequestContext& ctx);
void AcquireCallerAppletCaptureSharedBuffer(HLERequestContext& ctx);
void ReleaseCallerAppletCaptureSharedBuffer(HLERequestContext& ctx);
+ void AcquireLastApplicationCaptureSharedBuffer(HLERequestContext& ctx);
+ void ReleaseLastApplicationCaptureSharedBuffer(HLERequestContext& ctx);
+
+ const std::shared_ptr<Applet> applet;
};
} // namespace Service::AM
diff --git a/src/core/hle/service/am/hid_registration.cpp b/src/core/hle/service/am/hid_registration.cpp
index b9426f7b6..8ed49bac1 100644
--- a/src/core/hle/service/am/hid_registration.cpp
+++ b/src/core/hle/service/am/hid_registration.cpp
@@ -26,4 +26,10 @@ HidRegistration::~HidRegistration() {
}
}
+void HidRegistration::EnableAppletToGetInput(bool enable) {
+ if (m_process.IsInitialized()) {
+ m_hid_server->GetResourceManager()->EnableInput(m_process.GetProcessId(), enable);
+ }
+}
+
} // namespace Service::AM
diff --git a/src/core/hle/service/am/hid_registration.h b/src/core/hle/service/am/hid_registration.h
index 8a732349c..67cd84961 100644
--- a/src/core/hle/service/am/hid_registration.h
+++ b/src/core/hle/service/am/hid_registration.h
@@ -22,6 +22,8 @@ public:
explicit HidRegistration(Core::System& system, Process& process);
~HidRegistration();
+ void EnableAppletToGetInput(bool enable);
+
private:
Process& m_process;
std::shared_ptr<Service::HID::IHidServer> m_hid_server;
diff --git a/src/core/hle/service/am/library_applet_creator.cpp b/src/core/hle/service/am/library_applet_creator.cpp
index e69764670..47bab7528 100644
--- a/src/core/hle/service/am/library_applet_creator.cpp
+++ b/src/core/hle/service/am/library_applet_creator.cpp
@@ -84,10 +84,29 @@ AppletProgramId AppletIdToProgramId(AppletId applet_id) {
applet->type = AppletType::LibraryApplet;
applet->library_applet_mode = mode;
- // Library applet should be foreground
- applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground);
- applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
- applet->focus_state = FocusState::InFocus;
+ // Set focus state
+ switch (mode) {
+ case LibraryAppletMode::AllForeground:
+ case LibraryAppletMode::NoUI:
+ applet->focus_state = FocusState::InFocus;
+ applet->hid_registration.EnableAppletToGetInput(true);
+ applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground);
+ applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
+ break;
+ case LibraryAppletMode::AllForegroundInitiallyHidden:
+ applet->system_buffer_manager.SetWindowVisibility(false);
+ applet->focus_state = FocusState::NotInFocus;
+ applet->hid_registration.EnableAppletToGetInput(false);
+ applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
+ break;
+ case LibraryAppletMode::Background:
+ case LibraryAppletMode::BackgroundIndirectDisplay:
+ default:
+ applet->focus_state = FocusState::Background;
+ applet->hid_registration.EnableAppletToGetInput(true);
+ applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
+ break;
+ }
auto broker = std::make_shared<AppletDataBroker>(system);
applet->caller_applet = caller_applet;
diff --git a/src/core/hle/service/am/library_applet_proxy.cpp b/src/core/hle/service/am/library_applet_proxy.cpp
index 1d88dd78c..d6108fba3 100644
--- a/src/core/hle/service/am/library_applet_proxy.cpp
+++ b/src/core/hle/service/am/library_applet_proxy.cpp
@@ -81,7 +81,7 @@ void ILibraryAppletProxy::GetDisplayController(HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
- rb.PushIpcInterface<IDisplayController>(system);
+ rb.PushIpcInterface<IDisplayController>(system, applet);
}
void ILibraryAppletProxy::GetProcessWindingController(HLERequestContext& ctx) {
diff --git a/src/core/hle/service/am/library_applet_self_accessor.cpp b/src/core/hle/service/am/library_applet_self_accessor.cpp
index bc66bcb6b..b560f580b 100644
--- a/src/core/hle/service/am/library_applet_self_accessor.cpp
+++ b/src/core/hle/service/am/library_applet_self_accessor.cpp
@@ -3,6 +3,9 @@
#include "common/scope_exit.h"
#include "core/core_timing.h"
+#include "core/file_sys/control_metadata.h"
+#include "core/file_sys/patch_manager.h"
+#include "core/file_sys/registered_cache.h"
#include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/am/am_results.h"
#include "core/hle/service/am/applet_data_broker.h"
@@ -15,25 +18,20 @@
#include "core/hle/service/am/library_applet_self_accessor.h"
#include "core/hle/service/am/storage.h"
#include "core/hle/service/ipc_helpers.h"
+#include "core/hle/service/ns/ns.h"
+#include "core/hle/service/sm/sm.h"
#include "hid_core/hid_types.h"
namespace Service::AM {
namespace {
-struct AppletIdentityInfo {
- AppletId applet_id;
- INSERT_PADDING_BYTES(0x4);
- u64 application_id;
-};
-static_assert(sizeof(AppletIdentityInfo) == 0x10, "AppletIdentityInfo has incorrect size.");
-
AppletIdentityInfo GetCallerIdentity(std::shared_ptr<Applet> applet) {
if (const auto caller_applet = applet->caller_applet.lock(); caller_applet) {
// TODO: is this actually the application ID?
return {
- .applet_id = applet->applet_id,
- .application_id = applet->program_id,
+ .applet_id = caller_applet->applet_id,
+ .application_id = caller_applet->program_id,
};
} else {
return {
@@ -60,7 +58,7 @@ ILibraryAppletSelfAccessor::ILibraryAppletSelfAccessor(Core::System& system_,
{10, &ILibraryAppletSelfAccessor::ExitProcessAndReturn, "ExitProcessAndReturn"},
{11, &ILibraryAppletSelfAccessor::GetLibraryAppletInfo, "GetLibraryAppletInfo"},
{12, &ILibraryAppletSelfAccessor::GetMainAppletIdentityInfo, "GetMainAppletIdentityInfo"},
- {13, nullptr, "CanUseApplicationCore"},
+ {13, &ILibraryAppletSelfAccessor::CanUseApplicationCore, "CanUseApplicationCore"},
{14, &ILibraryAppletSelfAccessor::GetCallerAppletIdentityInfo, "GetCallerAppletIdentityInfo"},
{15, nullptr, "GetMainAppletApplicationControlProperty"},
{16, nullptr, "GetMainAppletStorageId"},
@@ -74,8 +72,8 @@ ILibraryAppletSelfAccessor::ILibraryAppletSelfAccessor(Core::System& system_,
{40, nullptr, "GetIndirectLayerProducerHandle"},
{50, nullptr, "ReportVisibleError"},
{51, nullptr, "ReportVisibleErrorWithErrorContext"},
- {60, nullptr, "GetMainAppletApplicationDesiredLanguage"},
- {70, nullptr, "GetCurrentApplicationId"},
+ {60, &ILibraryAppletSelfAccessor::GetMainAppletApplicationDesiredLanguage, "GetMainAppletApplicationDesiredLanguage"},
+ {70, &ILibraryAppletSelfAccessor::GetCurrentApplicationId, "GetCurrentApplicationId"},
{80, nullptr, "RequestExitToSelf"},
{90, nullptr, "CreateApplicationAndPushAndRequestToLaunch"},
{100, nullptr, "CreateGameMovieTrimmer"},
@@ -86,6 +84,7 @@ ILibraryAppletSelfAccessor::ILibraryAppletSelfAccessor(Core::System& system_,
{130, nullptr, "GetGpuErrorDetectedSystemEvent"},
{140, nullptr, "SetApplicationMemoryReservation"},
{150, &ILibraryAppletSelfAccessor::ShouldSetGpuTimeSliceManually, "ShouldSetGpuTimeSliceManually"},
+ {160, &ILibraryAppletSelfAccessor::Cmd160, "Cmd160"},
};
// clang-format on
RegisterHandlers(functions);
@@ -202,6 +201,15 @@ void ILibraryAppletSelfAccessor::GetMainAppletIdentityInfo(HLERequestContext& ct
rb.PushRaw(applet_info);
}
+void ILibraryAppletSelfAccessor::CanUseApplicationCore(HLERequestContext& ctx) {
+ LOG_WARNING(Service_AM, "(STUBBED) called");
+
+ // TODO: This appears to read the NPDM from state and check the core mask of the applet.
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(ResultSuccess);
+ rb.Push<u8>(0);
+}
+
void ILibraryAppletSelfAccessor::GetCallerAppletIdentityInfo(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
@@ -218,6 +226,80 @@ void ILibraryAppletSelfAccessor::GetDesirableKeyboardLayout(HLERequestContext& c
rb.Push<u32>(0);
}
+void ILibraryAppletSelfAccessor::GetMainAppletApplicationDesiredLanguage(HLERequestContext& ctx) {
+ // FIXME: this is copied from IApplicationFunctions::GetDesiredLanguage
+ auto identity = GetCallerIdentity(applet);
+
+ // TODO(bunnei): This should be configurable
+ LOG_DEBUG(Service_AM, "called");
+
+ // Get supported languages from NACP, if possible
+ // Default to 0 (all languages supported)
+ u32 supported_languages = 0;
+
+ const auto res = [this, identity] {
+ const FileSys::PatchManager pm{identity.application_id, system.GetFileSystemController(),
+ system.GetContentProvider()};
+ auto metadata = pm.GetControlMetadata();
+ if (metadata.first != nullptr) {
+ return metadata;
+ }
+
+ const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(identity.application_id),
+ system.GetFileSystemController(),
+ system.GetContentProvider()};
+ return pm_update.GetControlMetadata();
+ }();
+
+ if (res.first != nullptr) {
+ supported_languages = res.first->GetSupportedLanguages();
+ }
+
+ // Call IApplicationManagerInterface implementation.
+ auto& service_manager = system.ServiceManager();
+ auto ns_am2 = service_manager.GetService<NS::NS>("ns:am2");
+ auto app_man = ns_am2->GetApplicationManagerInterface();
+
+ // Get desired application language
+ u8 desired_language{};
+ const auto res_lang =
+ app_man->GetApplicationDesiredLanguage(&desired_language, supported_languages);
+ if (res_lang != ResultSuccess) {
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(res_lang);
+ return;
+ }
+
+ // Convert to settings language code.
+ u64 language_code{};
+ const auto res_code =
+ app_man->ConvertApplicationLanguageToLanguageCode(&language_code, desired_language);
+ if (res_code != ResultSuccess) {
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(res_code);
+ return;
+ }
+
+ LOG_DEBUG(Service_AM, "got desired_language={:016X}", language_code);
+
+ IPC::ResponseBuilder rb{ctx, 4};
+ rb.Push(ResultSuccess);
+ rb.Push(language_code);
+}
+
+void ILibraryAppletSelfAccessor::GetCurrentApplicationId(HLERequestContext& ctx) {
+ LOG_WARNING(Service_AM, "(STUBBED) called");
+
+ u64 application_id = 0;
+ if (auto caller_applet = applet->caller_applet.lock(); caller_applet) {
+ application_id = caller_applet->program_id;
+ }
+
+ IPC::ResponseBuilder rb{ctx, 4};
+ rb.Push(ResultSuccess);
+ rb.Push(application_id);
+}
+
void ILibraryAppletSelfAccessor::GetMainAppletAvailableUsers(HLERequestContext& ctx) {
const Service::Account::ProfileManager manager{};
bool is_empty{true};
@@ -245,4 +327,12 @@ void ILibraryAppletSelfAccessor::ShouldSetGpuTimeSliceManually(HLERequestContext
rb.Push<u8>(0);
}
+void ILibraryAppletSelfAccessor::Cmd160(HLERequestContext& ctx) {
+ LOG_WARNING(Service_AM, "(STUBBED) called");
+
+ IPC::ResponseBuilder rb{ctx, 4};
+ rb.Push(ResultSuccess);
+ rb.Push<u64>(0);
+}
+
} // namespace Service::AM
diff --git a/src/core/hle/service/am/library_applet_self_accessor.h b/src/core/hle/service/am/library_applet_self_accessor.h
index 596cea0df..8717a989a 100644
--- a/src/core/hle/service/am/library_applet_self_accessor.h
+++ b/src/core/hle/service/am/library_applet_self_accessor.h
@@ -27,11 +27,15 @@ private:
void GetPopInteractiveInDataEvent(HLERequestContext& ctx);
void GetLibraryAppletInfo(HLERequestContext& ctx);
void GetMainAppletIdentityInfo(HLERequestContext& ctx);
+ void CanUseApplicationCore(HLERequestContext& ctx);
void ExitProcessAndReturn(HLERequestContext& ctx);
void GetCallerAppletIdentityInfo(HLERequestContext& ctx);
void GetDesirableKeyboardLayout(HLERequestContext& ctx);
+ void GetMainAppletApplicationDesiredLanguage(HLERequestContext& ctx);
+ void GetCurrentApplicationId(HLERequestContext& ctx);
void GetMainAppletAvailableUsers(HLERequestContext& ctx);
void ShouldSetGpuTimeSliceManually(HLERequestContext& ctx);
+ void Cmd160(HLERequestContext& ctx);
const std::shared_ptr<Applet> applet;
const std::shared_ptr<AppletDataBroker> broker;
diff --git a/src/core/hle/service/am/self_controller.cpp b/src/core/hle/service/am/self_controller.cpp
index 3ac967b4d..0289f5cf1 100644
--- a/src/core/hle/service/am/self_controller.cpp
+++ b/src/core/hle/service/am/self_controller.cpp
@@ -30,7 +30,7 @@ ISelfController::ISelfController(Core::System& system_, std::shared_ptr<Applet>
{12, &ISelfController::SetPerformanceModeChangedNotification, "SetPerformanceModeChangedNotification"},
{13, &ISelfController::SetFocusHandlingMode, "SetFocusHandlingMode"},
{14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"},
- {15, nullptr, "SetScreenShotAppletIdentityInfo"},
+ {15, &ISelfController::SetScreenShotAppletIdentityInfo, "SetScreenShotAppletIdentityInfo"},
{16, &ISelfController::SetOutOfFocusSuspendingEnabled, "SetOutOfFocusSuspendingEnabled"},
{17, nullptr, "SetControllerFirmwareUpdateSection"},
{18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"},
@@ -207,6 +207,17 @@ void ISelfController::SetRestartMessageEnabled(HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}
+void ISelfController::SetScreenShotAppletIdentityInfo(HLERequestContext& ctx) {
+ LOG_WARNING(Service_AM, "(STUBBED) called");
+
+ IPC::RequestParser rp{ctx};
+ std::scoped_lock lk{applet->lock};
+ applet->screen_shot_identity = rp.PopRaw<AppletIdentityInfo>();
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+}
+
void ISelfController::SetOutOfFocusSuspendingEnabled(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
diff --git a/src/core/hle/service/am/self_controller.h b/src/core/hle/service/am/self_controller.h
index 6e6975264..a63bc2e74 100644
--- a/src/core/hle/service/am/self_controller.h
+++ b/src/core/hle/service/am/self_controller.h
@@ -28,6 +28,7 @@ private:
void SetPerformanceModeChangedNotification(HLERequestContext& ctx);
void SetFocusHandlingMode(HLERequestContext& ctx);
void SetRestartMessageEnabled(HLERequestContext& ctx);
+ void SetScreenShotAppletIdentityInfo(HLERequestContext& ctx);
void SetOutOfFocusSuspendingEnabled(HLERequestContext& ctx);
void SetAlbumImageOrientation(HLERequestContext& ctx);
void IsSystemBufferSharingEnabled(HLERequestContext& ctx);
diff --git a/src/core/hle/service/am/system_applet_proxy.cpp b/src/core/hle/service/am/system_applet_proxy.cpp
index e3013271b..38643408e 100644
--- a/src/core/hle/service/am/system_applet_proxy.cpp
+++ b/src/core/hle/service/am/system_applet_proxy.cpp
@@ -82,7 +82,7 @@ void ISystemAppletProxy::GetDisplayController(HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
- rb.PushIpcInterface<IDisplayController>(system);
+ rb.PushIpcInterface<IDisplayController>(system, applet);
}
void ISystemAppletProxy::GetLibraryAppletCreator(HLERequestContext& ctx) {
diff --git a/src/core/hle/service/am/system_buffer_manager.cpp b/src/core/hle/service/am/system_buffer_manager.cpp
index 7211ef488..60a9afc9d 100644
--- a/src/core/hle/service/am/system_buffer_manager.cpp
+++ b/src/core/hle/service/am/system_buffer_manager.cpp
@@ -4,6 +4,7 @@
#include "core/hle/service/am/system_buffer_manager.h"
#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
#include "core/hle/service/nvnflinger/nvnflinger.h"
+#include "core/hle/service/vi/vi_results.h"
namespace Service::AM {
@@ -41,9 +42,28 @@ bool SystemBufferManager::Initialize(Nvnflinger::Nvnflinger* nvnflinger, Kernel:
if (res.IsSuccess()) {
m_buffer_sharing_enabled = true;
+ m_nvnflinger->SetLayerVisibility(m_system_shared_layer_id, m_visible);
}
return m_buffer_sharing_enabled;
}
+void SystemBufferManager::SetWindowVisibility(bool visible) {
+ if (m_visible == visible) {
+ return;
+ }
+
+ m_visible = visible;
+
+ if (m_nvnflinger) {
+ m_nvnflinger->SetLayerVisibility(m_system_shared_layer_id, m_visible);
+ }
+}
+
+Result SystemBufferManager::WriteAppletCaptureBuffer(bool* out_was_written,
+ s32* out_fbshare_layer_index) {
+ // TODO
+ R_SUCCEED();
+}
+
} // namespace Service::AM
diff --git a/src/core/hle/service/am/system_buffer_manager.h b/src/core/hle/service/am/system_buffer_manager.h
index c60d73416..98c3cf055 100644
--- a/src/core/hle/service/am/system_buffer_manager.h
+++ b/src/core/hle/service/am/system_buffer_manager.h
@@ -18,6 +18,8 @@ namespace Service::Nvnflinger {
class Nvnflinger;
}
+union Result;
+
namespace Service::AM {
class SystemBufferManager {
@@ -33,10 +35,15 @@ public:
*out_system_shared_layer_id = m_system_shared_layer_id;
}
+ void SetWindowVisibility(bool visible);
+
+ Result WriteAppletCaptureBuffer(bool* out_was_written, s32* out_fbshare_layer_index);
+
private:
Kernel::KProcess* m_process{};
Nvnflinger::Nvnflinger* m_nvnflinger{};
bool m_buffer_sharing_enabled{};
+ bool m_visible{true};
u64 m_system_shared_buffer_id{};
u64 m_system_shared_layer_id{};
};
diff --git a/src/core/hle/service/am/window_controller.cpp b/src/core/hle/service/am/window_controller.cpp
index 430ca180b..f00957f83 100644
--- a/src/core/hle/service/am/window_controller.cpp
+++ b/src/core/hle/service/am/window_controller.cpp
@@ -17,8 +17,8 @@ IWindowController::IWindowController(Core::System& system_, std::shared_ptr<Appl
{10, &IWindowController::AcquireForegroundRights, "AcquireForegroundRights"},
{11, nullptr, "ReleaseForegroundRights"},
{12, nullptr, "RejectToChangeIntoBackground"},
- {20, nullptr, "SetAppletWindowVisibility"},
- {21, nullptr, "SetAppletGpuTimeSlice"},
+ {20, &IWindowController::SetAppletWindowVisibility, "SetAppletWindowVisibility"},
+ {21, &IWindowController::SetAppletGpuTimeSlice, "SetAppletGpuTimeSlice"},
};
// clang-format on
@@ -52,4 +52,35 @@ void IWindowController::AcquireForegroundRights(HLERequestContext& ctx) {
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->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground);
+ applet->focus_state = FocusState::InFocus;
+ } else {
+ applet->focus_state = FocusState::NotInFocus;
+ }
+ applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
+
+ 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
diff --git a/src/core/hle/service/am/window_controller.h b/src/core/hle/service/am/window_controller.h
index d97f93737..a28219abe 100644
--- a/src/core/hle/service/am/window_controller.h
+++ b/src/core/hle/service/am/window_controller.h
@@ -18,6 +18,8 @@ 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;
};