mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-07-11 13:34:18 +00: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:
130
src/Ryujinx.Horizon/Lbl/Ipc/LblController.cs
Normal file
130
src/Ryujinx.Horizon/Lbl/Ipc/LblController.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Lbl;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
|
||||
namespace Ryujinx.Horizon.Lbl.Ipc
|
||||
{
|
||||
partial class LblController : ILblController
|
||||
{
|
||||
private bool _vrModeEnabled;
|
||||
private float _currentBrightnessSettingForVrMode;
|
||||
|
||||
[CmifCommand(17)]
|
||||
public Result SetBrightnessReflectionDelayLevel(float unknown0, float unknown1)
|
||||
{
|
||||
// NOTE: Stubbed in system module.
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(18)]
|
||||
public Result GetBrightnessReflectionDelayLevel(out float unknown1, float unknown0)
|
||||
{
|
||||
// NOTE: Stubbed in system module.
|
||||
|
||||
unknown1 = 0.0f;
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(19)]
|
||||
public Result SetCurrentBrightnessMapping(float unknown0, float unknown1, float unknown2)
|
||||
{
|
||||
// NOTE: Stubbed in system module.
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(20)]
|
||||
public Result GetCurrentBrightnessMapping(out float unknown0, out float unknown1, out float unknown2)
|
||||
{
|
||||
// NOTE: Stubbed in system module.
|
||||
|
||||
unknown0 = 0.0f;
|
||||
unknown1 = 0.0f;
|
||||
unknown2 = 0.0f;
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(21)]
|
||||
public Result SetCurrentAmbientLightSensorMapping(float unknown0, float unknown1, float unknown2)
|
||||
{
|
||||
// NOTE: Stubbed in system module.
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(22)]
|
||||
public Result GetCurrentAmbientLightSensorMapping(out float unknown0, out float unknown1, out float unknown2)
|
||||
{
|
||||
// NOTE: Stubbed in system module.
|
||||
|
||||
unknown0 = 0.0f;
|
||||
unknown1 = 0.0f;
|
||||
unknown2 = 0.0f;
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(24)]
|
||||
public Result SetCurrentBrightnessSettingForVrMode(float currentBrightnessSettingForVrMode)
|
||||
{
|
||||
if (float.IsNaN(currentBrightnessSettingForVrMode) || float.IsInfinity(currentBrightnessSettingForVrMode))
|
||||
{
|
||||
_currentBrightnessSettingForVrMode = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentBrightnessSettingForVrMode = currentBrightnessSettingForVrMode;
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(25)]
|
||||
public Result GetCurrentBrightnessSettingForVrMode(out float currentBrightnessSettingForVrMode)
|
||||
{
|
||||
if (float.IsNaN(_currentBrightnessSettingForVrMode) || float.IsInfinity(_currentBrightnessSettingForVrMode))
|
||||
{
|
||||
currentBrightnessSettingForVrMode = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentBrightnessSettingForVrMode = _currentBrightnessSettingForVrMode;
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(26)]
|
||||
public Result EnableVrMode()
|
||||
{
|
||||
_vrModeEnabled = true;
|
||||
|
||||
// NOTE: The service checks _vrModeEnabled field value in a thread and then changes the screen brightness.
|
||||
// Since we don't support that, it's fine to do nothing.
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(27)]
|
||||
public Result DisableVrMode()
|
||||
{
|
||||
_vrModeEnabled = false;
|
||||
|
||||
// NOTE: The service checks _vrModeEnabled field value in a thread and then changes the screen brightness.
|
||||
// Since we don't support that, it's fine to do nothing.
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(28)]
|
||||
public Result IsVrModeEnabled(out bool vrModeEnabled)
|
||||
{
|
||||
vrModeEnabled = _vrModeEnabled;
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
src/Ryujinx.Horizon/Lbl/LblIpcServer.cs
Normal file
43
src/Ryujinx.Horizon/Lbl/LblIpcServer.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Ryujinx.Horizon.Lbl.Ipc;
|
||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||
using Ryujinx.Horizon.Sdk.Sm;
|
||||
|
||||
namespace Ryujinx.Horizon.Lbl
|
||||
{
|
||||
class LblIpcServer
|
||||
{
|
||||
private const int MaxSessionsCount = 5;
|
||||
|
||||
private const int PointerBufferSize = 0;
|
||||
private const int MaxDomains = 0;
|
||||
private const int MaxDomainObjects = 0;
|
||||
private const int MaxPortsCount = 1;
|
||||
|
||||
private static readonly ManagerOptions _managerOptions = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
|
||||
|
||||
private SmApi _sm;
|
||||
private ServerManager _serverManager;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
HeapAllocator allocator = new();
|
||||
|
||||
_sm = new SmApi();
|
||||
_sm.Initialize().AbortOnFailure();
|
||||
|
||||
_serverManager = new ServerManager(allocator, _sm, MaxPortsCount, _managerOptions, MaxSessionsCount);
|
||||
|
||||
_serverManager.RegisterObjectForServer(new LblController(), ServiceName.Encode("lbl"), MaxSessionsCount);
|
||||
}
|
||||
|
||||
public void ServiceRequests()
|
||||
{
|
||||
_serverManager.ServiceRequests();
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
_serverManager.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
17
src/Ryujinx.Horizon/Lbl/LblMain.cs
Normal file
17
src/Ryujinx.Horizon/Lbl/LblMain.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace Ryujinx.Horizon.Lbl
|
||||
{
|
||||
class LblMain : IService
|
||||
{
|
||||
public static void Main(ServiceTable serviceTable)
|
||||
{
|
||||
LblIpcServer ipcServer = new();
|
||||
|
||||
ipcServer.Initialize();
|
||||
|
||||
serviceTable.SignalServiceReady();
|
||||
|
||||
ipcServer.ServiceRequests();
|
||||
ipcServer.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user