mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-30 12:56:25 +02:00
lbl: Migrate service to Horizon (#5628)
* lbl: Migrate service to Horizon * Fix formatting * Addresses gdkchan's feedback * Fix comments
This commit is contained in:
parent
e2cfe6fe44
commit
e6700b314f
17 changed files with 311 additions and 181 deletions
|
@ -5,6 +5,7 @@ using Ryujinx.HLE.HOS.Services.Settings.Types;
|
|||
using Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Lbl;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
|
||||
|
@ -15,7 +16,6 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||
|
||||
private readonly Apm.ManagerServer _apmManagerServer;
|
||||
private readonly Apm.SystemManagerServer _apmSystemManagerServer;
|
||||
private readonly Lbl.LblControllerServer _lblControllerServer;
|
||||
|
||||
private bool _vrModeEnabled;
|
||||
#pragma warning disable CS0414, IDE0052 // Remove unread private member
|
||||
|
@ -34,7 +34,6 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||
|
||||
_apmManagerServer = new Apm.ManagerServer(context);
|
||||
_apmSystemManagerServer = new Apm.SystemManagerServer(context);
|
||||
_lblControllerServer = new Lbl.LblControllerServer(context);
|
||||
|
||||
_acquiredSleepLockEvent = new KEvent(context.Device.System.KernelContext);
|
||||
}
|
||||
|
@ -215,13 +214,15 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||
|
||||
_vrModeEnabled = vrModeEnabled;
|
||||
|
||||
using var lblApi = new LblApi();
|
||||
|
||||
if (vrModeEnabled)
|
||||
{
|
||||
_lblControllerServer.EnableVrMode();
|
||||
lblApi.EnableVrMode().AbortOnFailure();
|
||||
}
|
||||
else
|
||||
{
|
||||
_lblControllerServer.DisableVrMode();
|
||||
lblApi.DisableVrMode().AbortOnFailure();
|
||||
}
|
||||
|
||||
// TODO: It signals an internal event of ICommonStateGetter. We have to determine where this event is used.
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
namespace Ryujinx.HLE.HOS.Services.Lbl
|
||||
{
|
||||
abstract class ILblController : IpcService
|
||||
{
|
||||
public ILblController(ServiceCtx context) { }
|
||||
|
||||
protected abstract void SetCurrentBrightnessSettingForVrMode(float currentBrightnessSettingForVrMode);
|
||||
protected abstract float GetCurrentBrightnessSettingForVrMode();
|
||||
internal abstract void EnableVrMode();
|
||||
internal abstract void DisableVrMode();
|
||||
protected abstract bool IsVrModeEnabled();
|
||||
|
||||
[CommandCmif(17)]
|
||||
// SetBrightnessReflectionDelayLevel(float, float)
|
||||
public ResultCode SetBrightnessReflectionDelayLevel(ServiceCtx context)
|
||||
{
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(18)]
|
||||
// GetBrightnessReflectionDelayLevel(float) -> float
|
||||
public ResultCode GetBrightnessReflectionDelayLevel(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write(0.0f);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(21)]
|
||||
// SetCurrentAmbientLightSensorMapping(unknown<0xC>)
|
||||
public ResultCode SetCurrentAmbientLightSensorMapping(ServiceCtx context)
|
||||
{
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(22)]
|
||||
// GetCurrentAmbientLightSensorMapping() -> unknown<0xC>
|
||||
public ResultCode GetCurrentAmbientLightSensorMapping(ServiceCtx context)
|
||||
{
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(24)] // 3.0.0+
|
||||
// SetCurrentBrightnessSettingForVrMode(float)
|
||||
public ResultCode SetCurrentBrightnessSettingForVrMode(ServiceCtx context)
|
||||
{
|
||||
float currentBrightnessSettingForVrMode = context.RequestData.ReadSingle();
|
||||
|
||||
SetCurrentBrightnessSettingForVrMode(currentBrightnessSettingForVrMode);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(25)] // 3.0.0+
|
||||
// GetCurrentBrightnessSettingForVrMode() -> float
|
||||
public ResultCode GetCurrentBrightnessSettingForVrMode(ServiceCtx context)
|
||||
{
|
||||
float currentBrightnessSettingForVrMode = GetCurrentBrightnessSettingForVrMode();
|
||||
|
||||
context.ResponseData.Write(currentBrightnessSettingForVrMode);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(26)] // 3.0.0+
|
||||
// EnableVrMode()
|
||||
public ResultCode EnableVrMode(ServiceCtx context)
|
||||
{
|
||||
EnableVrMode();
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(27)] // 3.0.0+
|
||||
// DisableVrMode()
|
||||
public ResultCode DisableVrMode(ServiceCtx context)
|
||||
{
|
||||
DisableVrMode();
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(28)] // 3.0.0+
|
||||
// IsVrModeEnabled() -> bool
|
||||
public ResultCode IsVrModeEnabled(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write(IsVrModeEnabled());
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
namespace Ryujinx.HLE.HOS.Services.Lbl
|
||||
{
|
||||
[Service("lbl")]
|
||||
class LblControllerServer : ILblController
|
||||
{
|
||||
private bool _vrModeEnabled;
|
||||
private float _currentBrightnessSettingForVrMode;
|
||||
|
||||
public LblControllerServer(ServiceCtx context) : base(context) { }
|
||||
|
||||
protected override void SetCurrentBrightnessSettingForVrMode(float currentBrightnessSettingForVrMode)
|
||||
{
|
||||
if (float.IsNaN(currentBrightnessSettingForVrMode) || float.IsInfinity(currentBrightnessSettingForVrMode))
|
||||
{
|
||||
_currentBrightnessSettingForVrMode = 0.0f;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_currentBrightnessSettingForVrMode = currentBrightnessSettingForVrMode;
|
||||
}
|
||||
|
||||
protected override float GetCurrentBrightnessSettingForVrMode()
|
||||
{
|
||||
if (float.IsNaN(_currentBrightnessSettingForVrMode) || float.IsInfinity(_currentBrightnessSettingForVrMode))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
return _currentBrightnessSettingForVrMode;
|
||||
}
|
||||
|
||||
internal override void EnableVrMode()
|
||||
{
|
||||
_vrModeEnabled = true;
|
||||
|
||||
// NOTE: Service check _vrModeEnabled field value in a thread and then change the screen brightness.
|
||||
// Since we don't support that. It's fine to do nothing.
|
||||
}
|
||||
|
||||
internal override void DisableVrMode()
|
||||
{
|
||||
_vrModeEnabled = false;
|
||||
|
||||
// NOTE: Service check _vrModeEnabled field value in a thread and then change the screen brightness.
|
||||
// Since we don't support that. It's fine to do nothing.
|
||||
}
|
||||
|
||||
protected override bool IsVrModeEnabled()
|
||||
{
|
||||
return _vrModeEnabled;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ using Ryujinx.HLE.HOS.Kernel;
|
|||
using Ryujinx.HLE.HOS.Kernel.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.Horizon;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
@ -172,6 +173,13 @@ namespace Ryujinx.HLE.HOS.Services
|
|||
_selfProcess = KernelStatic.GetCurrentProcess();
|
||||
_selfThread = KernelStatic.GetCurrentThread();
|
||||
|
||||
HorizonStatic.Register(
|
||||
default,
|
||||
_context.Syscall,
|
||||
_selfProcess.CpuMemory,
|
||||
_selfThread.ThreadContext,
|
||||
(int)_selfThread.ThreadContext.GetX(1));
|
||||
|
||||
if (SmObjectFactory != null)
|
||||
{
|
||||
_context.Syscall.ManageNamedPort(out int serverPortHandle, "sm:", 50);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue