aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Lbl
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Horizon/Lbl')
-rw-r--r--src/Ryujinx.Horizon/Lbl/Ipc/LblController.cs130
-rw-r--r--src/Ryujinx.Horizon/Lbl/LblIpcServer.cs43
-rw-r--r--src/Ryujinx.Horizon/Lbl/LblMain.cs17
3 files changed, 190 insertions, 0 deletions
diff --git a/src/Ryujinx.Horizon/Lbl/Ipc/LblController.cs b/src/Ryujinx.Horizon/Lbl/Ipc/LblController.cs
new file mode 100644
index 00000000..0a27d5ef
--- /dev/null
+++ b/src/Ryujinx.Horizon/Lbl/Ipc/LblController.cs
@@ -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;
+ }
+ }
+}
diff --git a/src/Ryujinx.Horizon/Lbl/LblIpcServer.cs b/src/Ryujinx.Horizon/Lbl/LblIpcServer.cs
new file mode 100644
index 00000000..53e74d51
--- /dev/null
+++ b/src/Ryujinx.Horizon/Lbl/LblIpcServer.cs
@@ -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();
+ }
+ }
+}
diff --git a/src/Ryujinx.Horizon/Lbl/LblMain.cs b/src/Ryujinx.Horizon/Lbl/LblMain.cs
new file mode 100644
index 00000000..f471f31b
--- /dev/null
+++ b/src/Ryujinx.Horizon/Lbl/LblMain.cs
@@ -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();
+ }
+ }
+}