am: Switch 2 graphics-scale interface and IApplicationFunctions 321

IApplicationProxy 60 returns the interface nn::oe::GetCurrentGraphicsScale
uses; its command 10 must return 10, 20 or 30, so return 10. Other
commands on it are auto-stubbed (nx2: prefix). IApplicationFunctions 321
is called right after 320; stub it.
This commit is contained in:
Takoroka 2026-10-27 13:26:44 -04:00
commit 3f5bdb81f9
6 changed files with 55 additions and 1 deletions

View file

@ -457,6 +457,7 @@ add_library(core STATIC
hle/service/am/service/application_functions.cpp
hle/service/am/service/application_functions.h
hle/service/am/service/application_proxy.cpp
hle/service/am/service/graphics_scale_controller.h
hle/service/am/service/application_proxy.h
hle/service/am/service/application_proxy_service.cpp
hle/service/am/service/application_proxy_service.h

View file

@ -119,6 +119,7 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_, std::shared_
{300, nullptr, "CreateMovieWriter"}, // [19.0.0+]
{310, nullptr, "Unknown310"}, // [20.0.0+]
{320, D<&IApplicationFunctions::Unknown320>, "Unknown320"}, // [20.0.0+]
{321, D<&IApplicationFunctions::Unknown321>, "Unknown321"}, // Switch 2
{330, D<&IApplicationFunctions::Unknown330>, "Unknown330"}, // [20.0.0+]
{500, nullptr, "StartContinuousRecordingFlushForDebug"},
{1000, nullptr, "CreateMovieMaker"},
@ -550,6 +551,12 @@ Result IApplicationFunctions::Unknown320() {
R_SUCCEED();
}
Result IApplicationFunctions::Unknown321() {
// Called by Switch 2 titles right after 320; arguments unknown.
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}
Result IApplicationFunctions::Unknown330(Out<u8> out) {
LOG_DEBUG(Service_AM, "called");
*out = 0;

View file

@ -83,6 +83,7 @@ private:
Result CreateApplicationAndRequestToStart(u64 application_id);
Result GetUnknownEvent210(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result Unknown320();
Result Unknown321();
Result Unknown330(Out<u8> out);
Result PrepareForJit();

View file

@ -11,6 +11,7 @@
#include "core/hle/service/am/service/common_state_getter.h"
#include "core/hle/service/am/service/debug_functions.h"
#include "core/hle/service/am/service/display_controller.h"
#include "core/hle/service/am/service/graphics_scale_controller.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/self_controller.h"
@ -37,7 +38,7 @@ IApplicationProxy::IApplicationProxy(Core::System& system_, std::shared_ptr<Appl
// Switch 2-only getters; see nx2_stub_interface.h.
{40, &IApplicationProxy::GetNx2Interface, "Nx2Getter40"},
{50, &IApplicationProxy::GetNx2Interface, "Nx2Getter50"},
{60, &IApplicationProxy::GetNx2Interface, "Nx2Getter60"},
{60, D<&IApplicationProxy::GetGraphicsScaleController>, "GetGraphicsScaleController (Switch 2)"},
{70, &IApplicationProxy::GetNx2Interface, "Nx2Getter70"},
{80, &IApplicationProxy::GetNx2Interface, "Nx2Getter80"},
{90, &IApplicationProxy::GetNx2Interface, "Nx2Getter90"},
@ -50,6 +51,13 @@ IApplicationProxy::IApplicationProxy(Core::System& system_, std::shared_ptr<Appl
IApplicationProxy::~IApplicationProxy() = default;
Result IApplicationProxy::GetGraphicsScaleController(
Out<SharedPointer<IGraphicsScaleController>> out_controller) {
LOG_DEBUG(Service_AM, "called");
*out_controller = std::make_shared<IGraphicsScaleController>(system);
R_SUCCEED();
}
void IApplicationProxy::GetNx2Interface(HLERequestContext& ctx) {
ReturnNx2StubInterface(system, ctx, "IApplicationProxy");
}

View file

@ -17,6 +17,7 @@ class IApplicationFunctions;
class ICommonStateGetter;
class IDebugFunctions;
class IDisplayController;
class IGraphicsScaleController;
class ILibraryAppletCreator;
class IProcessWindingController;
class ISelfController;
@ -31,6 +32,7 @@ public:
private:
void GetNx2Interface(HLERequestContext& ctx);
Result GetGraphicsScaleController(Out<SharedPointer<IGraphicsScaleController>> out_controller);
Result GetAudioController(Out<SharedPointer<IAudioController>> out_audio_controller);
Result GetDisplayController(Out<SharedPointer<IDisplayController>> out_display_controller);
Result GetProcessWindingController(

View file

@ -0,0 +1,35 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "core/hle/service/cmif_types.h"
#include "core/hle/service/nx2_stub_interface.h"
#include "core/hle/service/service.h"
namespace Service::AM {
// Switch 2 interface returned by IApplicationProxy command 60 (name is a guess). nn::oe's
// GetCurrentGraphicsScale reads command 10 and accepts 10, 20 or 30 (scale enum 0, 1, 2).
// Commands without a handler are auto-stubbed because the name carries the nx2: prefix.
class IGraphicsScaleController final : public ServiceFramework<IGraphicsScaleController> {
public:
explicit IGraphicsScaleController(Core::System& system_)
: ServiceFramework{system_, "nx2:IGraphicsScaleController"} {
// clang-format off
static const FunctionInfo functions[] = {
{10, D<&IGraphicsScaleController::GetCurrentGraphicsScale>, "GetCurrentGraphicsScale"},
};
// clang-format on
RegisterHandlers(functions);
}
private:
Result GetCurrentGraphicsScale(Out<u32> out_scale) {
LOG_WARNING(Service_AM, "(STUBBED) called, returning 10");
*out_scale = 10;
R_SUCCEED();
}
};
} // namespace Service::AM