no name: Mii Editor applet support (#2419)

* no name: Mii Editor applet support

* addresses gdkchan feedback

* Fix comment

* Bypass MountCounter of MiiDatabaseManager

* Fix GetSettingsPlatformRegion

* Disable Applet Menu for unsupported firmwares
This commit is contained in:
Ac_K 2021-06-28 20:54:45 +02:00 committed by GitHub
parent fefd4619a5
commit a79b39b913
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 591 additions and 33 deletions

View file

@ -0,0 +1,105 @@
using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.LibraryAppletProxy;
using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService
{
class ILibraryAppletProxy : IpcService
{
private readonly long _pid;
public ILibraryAppletProxy(long pid)
{
_pid = pid;
}
[CommandHipc(0)]
// GetCommonStateGetter() -> object<nn::am::service::ICommonStateGetter>
public ResultCode GetCommonStateGetter(ServiceCtx context)
{
MakeObject(context, new ICommonStateGetter(context));
return ResultCode.Success;
}
[CommandHipc(1)]
// GetSelfController() -> object<nn::am::service::ISelfController>
public ResultCode GetSelfController(ServiceCtx context)
{
MakeObject(context, new ISelfController(context, _pid));
return ResultCode.Success;
}
[CommandHipc(2)]
// GetWindowController() -> object<nn::am::service::IWindowController>
public ResultCode GetWindowController(ServiceCtx context)
{
MakeObject(context, new IWindowController(_pid));
return ResultCode.Success;
}
[CommandHipc(3)]
// GetAudioController() -> object<nn::am::service::IAudioController>
public ResultCode GetAudioController(ServiceCtx context)
{
MakeObject(context, new IAudioController());
return ResultCode.Success;
}
[CommandHipc(4)]
// GetDisplayController() -> object<nn::am::service::IDisplayController>
public ResultCode GetDisplayController(ServiceCtx context)
{
MakeObject(context, new IDisplayController(context));
return ResultCode.Success;
}
[CommandHipc(10)]
// GetProcessWindingController() -> object<nn::am::service::IProcessWindingController>
public ResultCode GetProcessWindingController(ServiceCtx context)
{
MakeObject(context, new IProcessWindingController());
return ResultCode.Success;
}
[CommandHipc(11)]
// GetLibraryAppletCreator() -> object<nn::am::service::ILibraryAppletCreator>
public ResultCode GetLibraryAppletCreator(ServiceCtx context)
{
MakeObject(context, new ILibraryAppletCreator());
return ResultCode.Success;
}
[CommandHipc(20)]
// OpenLibraryAppletSelfAccessor() -> object<nn::am::service::ILibraryAppletSelfAccessor>
public ResultCode OpenLibraryAppletSelfAccessor(ServiceCtx context)
{
MakeObject(context, new ILibraryAppletSelfAccessor(context));
return ResultCode.Success;
}
[CommandHipc(21)]
// GetAppletCommonFunctions() -> object<nn::am::service::IAppletCommonFunctions>
public ResultCode GetAppletCommonFunctions(ServiceCtx context)
{
MakeObject(context, new IAppletCommonFunctions());
return ResultCode.Success;
}
[CommandHipc(1000)]
// GetDebugFunctions() -> object<nn::am::service::IDebugFunctions>
public ResultCode GetDebugFunctions(ServiceCtx context)
{
MakeObject(context, new IDebugFunctions());
return ResultCode.Success;
}
}
}

View file

@ -24,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService
// GetSelfController() -> object<nn::am::service::ISelfController>
public ResultCode GetSelfController(ServiceCtx context)
{
MakeObject(context, new ISelfController(context.Device.System, _pid));
MakeObject(context, new ISelfController(context, _pid));
return ResultCode.Success;
}
@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService
// GetDisplayController() -> object<nn::am::service::IDisplayController>
public ResultCode GetDisplayController(ServiceCtx context)
{
MakeObject(context, new IDisplayController());
MakeObject(context, new IDisplayController(context));
return ResultCode.Success;
}

View file

@ -0,0 +1,16 @@
using System.Collections.Generic;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.LibraryAppletProxy
{
class AppletStandalone
{
public AppletId AppletId;
public LibraryAppletMode LibraryAppletMode;
public Queue<byte[]> InputData;
public AppletStandalone()
{
InputData = new Queue<byte[]>();
}
}
}

View file

@ -0,0 +1,78 @@
using Ryujinx.Common;
using System;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.LibraryAppletProxy
{
class ILibraryAppletSelfAccessor : IpcService
{
private AppletStandalone _appletStandalone = new AppletStandalone();
public ILibraryAppletSelfAccessor(ServiceCtx context)
{
if (context.Device.Application.TitleId == 0x0100000000001009)
{
// Create MiiEdit data.
_appletStandalone = new AppletStandalone()
{
AppletId = AppletId.MiiEdit,
LibraryAppletMode = LibraryAppletMode.AllForeground
};
byte[] miiEditInputData = new byte[0x100];
miiEditInputData[0] = 0x03; // Hardcoded unknown value.
_appletStandalone.InputData.Enqueue(miiEditInputData);
}
else
{
throw new NotImplementedException($"{context.Device.Application.TitleId} applet is not implemented.");
}
}
[CommandHipc(0)]
// PopInData() -> object<nn::am::service::IStorage>
public ResultCode PopInData(ServiceCtx context)
{
byte[] appletData = _appletStandalone.InputData.Dequeue();
if (appletData.Length == 0)
{
return ResultCode.NotAvailable;
}
MakeObject(context, new IStorage(appletData));
return ResultCode.Success;
}
[CommandHipc(11)]
// GetLibraryAppletInfo() -> nn::am::service::LibraryAppletInfo
public ResultCode GetLibraryAppletInfo(ServiceCtx context)
{
LibraryAppletInfo libraryAppletInfo = new LibraryAppletInfo()
{
AppletId = _appletStandalone.AppletId,
LibraryAppletMode = _appletStandalone.LibraryAppletMode
};
context.ResponseData.WriteStruct(libraryAppletInfo);
return ResultCode.Success;
}
[CommandHipc(14)]
// GetCallerAppletIdentityInfo() -> nn::am::service::AppletIdentityInfo
public ResultCode GetCallerAppletIdentityInfo(ServiceCtx context)
{
AppletIdentifyInfo appletIdentifyInfo = new AppletIdentifyInfo()
{
AppletId = AppletId.QLaunch,
TitleId = 0x0100000000001000
};
context.ResponseData.WriteStruct(appletIdentifyInfo);
return ResultCode.Success;
}
}
}

View file

@ -0,0 +1,24 @@
using Ryujinx.Common;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.LibraryAppletProxy
{
class IProcessWindingController : IpcService
{
public IProcessWindingController() { }
[CommandHipc(0)]
// GetLaunchReason() -> nn::am::service::AppletProcessLaunchReason
public ResultCode GetLaunchReason(ServiceCtx context)
{
// NOTE: Flag is set by using an internal field.
AppletProcessLaunchReason appletProcessLaunchReason = new AppletProcessLaunchReason()
{
Flag = 0
};
context.ResponseData.WriteStruct(appletProcessLaunchReason);
return ResultCode.Success;
}
}
}

View file

@ -0,0 +1,7 @@
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class IAppletCommonFunctions : IpcService
{
public IAppletCommonFunctions() { }
}
}

View file

@ -2,6 +2,8 @@ using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Settings.Types;
using Ryujinx.HLE.HOS.SystemState;
using System;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
@ -241,6 +243,18 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return (ResultCode)_apmSystemManagerServer.GetCurrentPerformanceConfiguration(context);
}
[CommandHipc(300)] // 9.0.0+
// GetSettingsPlatformRegion() -> u8
public ResultCode GetSettingsPlatformRegion(ServiceCtx context)
{
PlatformRegion platformRegion = context.Device.System.State.DesiredRegionCode == (uint)RegionCode.China ? PlatformRegion.China : PlatformRegion.Global;
// FIXME: Call set:sys GetPlatformRegion
context.ResponseData.Write((byte)platformRegion);
return ResultCode.Success;
}
[CommandHipc(900)] // 11.0.0+
// SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled()
public ResultCode SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(ServiceCtx context)

View file

@ -1,7 +1,106 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Memory;
using System;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class IDisplayController : IpcService
{
public IDisplayController() { }
private KTransferMemory _transferMem;
private bool _lastApplicationCaptureBufferAcquired;
private bool _callerAppletCaptureBufferAcquired;
public IDisplayController(ServiceCtx context)
{
_transferMem = context.Device.System.AppletCaptureBufferTransfer;
}
[CommandHipc(8)] // 2.0.0+
// TakeScreenShotOfOwnLayer(b8, s32)
public ResultCode TakeScreenShotOfOwnLayer(ServiceCtx context)
{
bool unknown1 = context.RequestData.ReadBoolean();
int unknown2 = context.RequestData.ReadInt32();
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { unknown1, unknown2 });
return ResultCode.Success;
}
[CommandHipc(11)]
// ReleaseLastApplicationCaptureBuffer()
public ResultCode ReleaseLastApplicationCaptureBuffer(ServiceCtx context)
{
if (!_lastApplicationCaptureBufferAcquired)
{
return ResultCode.BufferNotAcquired;
}
_lastApplicationCaptureBufferAcquired = false;
return ResultCode.Success;
}
[CommandHipc(15)]
// ReleaseCallerAppletCaptureBuffer()
public ResultCode ReleaseCallerAppletCaptureBuffer(ServiceCtx context)
{
if (!_callerAppletCaptureBufferAcquired)
{
return ResultCode.BufferNotAcquired;
}
_callerAppletCaptureBufferAcquired = false;
return ResultCode.Success;
}
[CommandHipc(16)]
// AcquireLastApplicationCaptureBufferEx() -> (b8, handle<copy>)
public ResultCode AcquireLastApplicationCaptureBufferEx(ServiceCtx context)
{
if (_lastApplicationCaptureBufferAcquired)
{
return ResultCode.BufferAlreadyAcquired;
}
if (context.Process.HandleTable.GenerateHandle(_transferMem, out int handle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
_lastApplicationCaptureBufferAcquired = true;
context.ResponseData.Write(_lastApplicationCaptureBufferAcquired);
return ResultCode.Success;
}
[CommandHipc(18)]
// AcquireCallerAppletCaptureBufferEx() -> (b8, handle<copy>)
public ResultCode AcquireCallerAppletCaptureBufferEx(ServiceCtx context)
{
if (_callerAppletCaptureBufferAcquired)
{
return ResultCode.BufferAlreadyAcquired;
}
if (context.Process.HandleTable.GenerateHandle(_transferMem, out int handle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
_callerAppletCaptureBufferAcquired = true;
context.ResponseData.Write(_callerAppletCaptureBufferAcquired);
return ResultCode.Success;
}
}
}

View file

@ -35,9 +35,9 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
private uint _screenShotImageOrientation = 0;
private uint _idleTimeDetectionExtension = 0;
public ISelfController(Horizon system, long pid)
public ISelfController(ServiceCtx context, long pid)
{
_libraryAppletLaunchableEvent = new KEvent(system.KernelContext);
_libraryAppletLaunchableEvent = new KEvent(context.Device.System.KernelContext);
_pid = pid;
}
@ -225,6 +225,15 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return ResultCode.Success;
}
[CommandHipc(41)] // 4.0.0+
// IsSystemBufferSharingEnabled()
public ResultCode IsSystemBufferSharingEnabled(ServiceCtx context)
{
// NOTE: Service checks a private field and return an error if the SystemBufferSharing is disabled.
return ResultCode.NotImplemented;
}
[CommandHipc(44)] // 10.0.0+
// CreateManagedDisplaySeparableLayer() -> (u64, u64)
public ResultCode CreateManagedDisplaySeparableLayer(ServiceCtx context)