diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/IOverlayAppletProxy.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/IOverlayAppletProxy.cs new file mode 100644 index 000000000..fd05ae783 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/IOverlayAppletProxy.cs @@ -0,0 +1,105 @@ +using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.OverlayAppletProxy; +using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy; + +namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService +{ + class IOverlayAppletProxy : IpcService + { + private readonly ulong _pid; + + public IOverlayAppletProxy(ulong pid) + { + _pid = pid; + } + + [CommandCmif(0)] + // GetCommonStateGetter() -> object + public ResultCode GetCommonStateGetter(ServiceCtx context) + { + MakeObject(context, new ICommonStateGetter(context)); + + return ResultCode.Success; + } + + [CommandCmif(1)] + // GetSelfController() -> object + public ResultCode GetSelfController(ServiceCtx context) + { + MakeObject(context, new ISelfController(context, _pid)); + + return ResultCode.Success; + } + + [CommandCmif(2)] + // GetWindowController() -> object + public ResultCode GetWindowController(ServiceCtx context) + { + MakeObject(context, new IWindowController(_pid)); + + return ResultCode.Success; + } + + [CommandCmif(3)] + // GetAudioController() -> object + public ResultCode GetAudioController(ServiceCtx context) + { + MakeObject(context, new IAudioController()); + + return ResultCode.Success; + } + + [CommandCmif(4)] + // GetDisplayController() -> object + public ResultCode GetDisplayController(ServiceCtx context) + { + MakeObject(context, new IDisplayController(context)); + + return ResultCode.Success; + } + + [CommandCmif(11)] + // GetLibraryAppletCreator() -> object + public ResultCode GetLibraryAppletCreator(ServiceCtx context) + { + MakeObject(context, new ILibraryAppletCreator()); + + return ResultCode.Success; + } + + [CommandCmif(20)] + // GetOverlayFunctions() -> object + public ResultCode GetOverlayFunctions(ServiceCtx context) + { + MakeObject(context, new IOverlayFunctions(context.Device.System)); + + return ResultCode.Success; + } + + [CommandCmif(21)] + // GetAppletCommonFunctions() -> object + public ResultCode GetAppletCommonFunctions(ServiceCtx context) + { + MakeObject(context, new IAppletCommonFunctions()); + + return ResultCode.Success; + } + + [CommandCmif(23)] + // GetGlobalStateController() -> object + public ResultCode GetGlobalStateController(ServiceCtx context) + { + MakeObject(context, new IGlobalStateController()); + + return ResultCode.Success; + } + + [CommandCmif(1000)] + // GetDebugFunctions() -> object + public ResultCode GetDebugFunctions(ServiceCtx context) + { + MakeObject(context, new IDebugFunctions()); + + return ResultCode.Success; + } + } +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/OverlayAppletProxy/IOverlayFunctions.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/OverlayAppletProxy/IOverlayFunctions.cs new file mode 100644 index 000000000..fce952ab3 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/OverlayAppletProxy/IOverlayFunctions.cs @@ -0,0 +1,155 @@ +using LibHac.Util; +using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Ipc; +using Ryujinx.Horizon.Common; +using System; + +namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.OverlayAppletProxy +{ + class IOverlayFunctions : IpcService + { + + public IOverlayFunctions(Horizon system) + { + } + + [CommandCmif(0)] + // BeginToWatchShortHomeButtonMessage() + public ResultCode BeginToWatchShortHomeButtonMessage(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(1)] + // EndToWatchShortHomeButtonMessage() + public ResultCode EndToWatchShortHomeButtonMessage(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(2)] + // GetApplicationIdForLogo() -> nn::ncm::ApplicationId + public ResultCode GetApplicationIdForLogo(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + context.ResponseData.Write(0L); + + return ResultCode.Success; + } + + [CommandCmif(3)] + // SetGpuTimeSliceBoost(u64) + public ResultCode SetGpuTimeSliceBoost(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(4)] + // SetAutoSleepTimeAndDimmingTimeEnabled(u8) + public ResultCode SetAutoSleepTimeAndDimmingTimeEnabled(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(5)] + // TerminateApplicationAndSetReason(u32) + public ResultCode TerminateApplicationAndSetReason(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(6)] + // SetScreenShotPermissionGlobally(u8) + public ResultCode SetScreenShotPermissionGlobally(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(10)] + // StartShutdownSequenceForOverlay() + public ResultCode StartShutdownSequenceForOverlay(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(11)] + // StartRebootSequenceForOverlay() + public ResultCode StartRebootSequenceForOverlay(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(20)] + // SetHandlingHomeButtonShortPressedEnabled(u8) + public ResultCode SetHandlingHomeButtonShortPressedEnabled(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(21)] + // SetHandlingTouchScreenInputEnabled(u8) + public ResultCode SetHandlingTouchScreenInputEnabled(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(30)] + // SetHealthWarningShowingState(u8) + public ResultCode SetHealthWarningShowingState(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(31)] + // IsHealthWarningRequired() -> bool + public ResultCode IsHealthWarningRequired(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + context.ResponseData.Write(false); + + return ResultCode.Success; + } + + [CommandCmif(90)] + // SetRequiresGpuResourceUse(u8) + public ResultCode SetRequiresGpuResourceUse(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + + [CommandCmif(101)] + // BeginToObserveHidInputForDevelop() + public ResultCode BeginToObserveHidInputForDevelop(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAm); + + return ResultCode.Success; + } + } +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IAllSystemAppletProxiesService.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IAllSystemAppletProxiesService.cs index b8741b22b..b5ec6a6ee 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IAllSystemAppletProxiesService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IAllSystemAppletProxiesService.cs @@ -26,6 +26,15 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE return ResultCode.Success; } + + [CommandCmif(300)] + // OpenOverlayAppletProxy(pid, handle) -> object + public ResultCode OpenOverlayAppletProxy(ServiceCtx context) + { + MakeObject(context, new IOverlayAppletProxy(context.Request.HandleDesc.PId)); + + return ResultCode.Success; + } [CommandCmif(350)] // OpenSystemApplicationProxy(u64, pid, handle) -> object diff --git a/src/Ryujinx.HLE/Switch.cs b/src/Ryujinx.HLE/Switch.cs index 86b04061e..fed18566d 100644 --- a/src/Ryujinx.HLE/Switch.cs +++ b/src/Ryujinx.HLE/Switch.cs @@ -1,10 +1,13 @@ using LibHac.Common; +using LibHac.Ncm; using LibHac.Ns; +using LibHac.Tools.FsSystem.NcaUtils; using Ryujinx.Audio.Backends.CompatLayer; using Ryujinx.Audio.Integration; using Ryujinx.Common; using Ryujinx.Common.Configuration; using Ryujinx.Graphics.Gpu; +using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS; using Ryujinx.HLE.HOS.Services.Apm; @@ -158,5 +161,18 @@ namespace Ryujinx.HLE Shared = null; } } + + public bool LoadSystemProgramId(ulong programId) + { + string contentPath = System.ContentManager.GetInstalledContentPath(programId, StorageId.BuiltInSystem, NcaContentType.Program); + string filePath = VirtualFileSystem.SwitchPathToSystemPath(contentPath); + + if (string.IsNullOrWhiteSpace(filePath)) + { + throw new InvalidSystemResourceException("Specified title ID is not installed on the system."); + } + + return Processes.LoadNca(filePath); + } } } diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index f143d4e03..32f418e6e 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -41,6 +41,7 @@ using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS; using Ryujinx.HLE.HOS.Services.Account.Acc; using Ryujinx.HLE.HOS.SystemState; +using Ryujinx.HLE.Loaders.Processes; using Ryujinx.Input; using Ryujinx.Input.HLE; using SkiaSharp; @@ -672,6 +673,7 @@ namespace Ryujinx.Ava DiscordIntegrationModule.GuestAppStartedAt = Timestamps.Now; InitEmulatedSwitch(); + Device.LoadSystemProgramId(0x010000000000100C); MainWindow.UpdateGraphicsConfig(); SystemVersion firmwareVersion = ContentManager.GetCurrentFirmwareVersion();