am/lbl/hid/pctl: Enabled VR Rendering (#1688)

* am/lbl/hid/pctl: Enabled VR Rendering

This PR enable VR rendering on games which support it through the Toy-Con VR Goggles.

Please remember Ryujinx currently don't support console SixAxis sensor and for now, in some games, the view can't be moved.

Everything is implemented accordingly to RE:
- am: ICommonStateGetter: SetVrModeEnabled, BeginVrModeEx, EndVrModeEx.
- lbl: ILblController: SetBrightnessReflectionDelayLevel, GetBrightnessReflectionDelayLevel, SetCurrentAmbientLightSensorMapping, GetCurrentAmbientLightSensorMapping, SetCurrentBrightnessSettingForVrMode, GetCurrentBrightnessSettingForVrMode, EnableVrMode, DisableVrMode, IsVrModeEnabled.
- pctl: IParentalControlService: ConfirmStereoVisionPermission, ConfirmStereoVisionRestrictionConfigurable, GetStereoVisionRestriction, SetStereoVisionRestriction, ResetConfirmedStereoVisionPermission, IsStereoVisionPermitted.
- hid: IHidServer: ResetSevenSixAxisSensorTimestamp is stubbed because we don't support console SixAxisSensor for now.

Maybe we could add a setting later to enable or disable VR. But I think it's fine to keep this always available since you have to enable it in games.

* Fix permission flag check

* Address gdkchan feedback
This commit is contained in:
Ac_K 2020-11-15 22:30:20 +01:00 committed by GitHub
parent 4bc4cacdd0
commit 313f8d2eb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 337 additions and 13 deletions

View file

@ -8,15 +8,17 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
class ICommonStateGetter : IpcService
{
private Apm.ManagerServer apmManagerServer;
private Apm.SystemManagerServer apmSystemManagerServer;
private Apm.ManagerServer _apmManagerServer;
private Apm.SystemManagerServer _apmSystemManagerServer;
private Lbl.LblControllerServer _lblControllerServer;
private bool _vrModeEnabled = false;
private bool _vrModeEnabled = true;
public ICommonStateGetter(ServiceCtx context)
{
apmManagerServer = new Apm.ManagerServer(context);
apmSystemManagerServer = new Apm.SystemManagerServer(context);
_apmManagerServer = new Apm.ManagerServer(context);
_apmSystemManagerServer = new Apm.SystemManagerServer(context);
_lblControllerServer = new Lbl.LblControllerServer(context);
}
[Command(0)]
@ -66,7 +68,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// GetPerformanceMode() -> nn::apm::PerformanceMode
public ResultCode GetPerformanceMode(ServiceCtx context)
{
return (ResultCode)apmManagerServer.GetPerformanceMode(context);
return (ResultCode)_apmManagerServer.GetPerformanceMode(context);
}
[Command(8)]
@ -98,6 +100,56 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return ResultCode.Success;
}
[Command(51)] // 3.0.0+
// SetVrModeEnabled(b8)
public ResultCode SetVrModeEnabled(ServiceCtx context)
{
bool vrModeEnabled = context.RequestData.ReadBoolean();
UpdateVrMode(vrModeEnabled);
return ResultCode.Success;
}
[Command(53)] // 7.0.0+
// BeginVrModeEx()
public ResultCode BeginVrModeEx(ServiceCtx context)
{
UpdateVrMode(true);
return ResultCode.Success;
}
[Command(54)] // 7.0.0+
// EndVrModeEx()
public ResultCode EndVrModeEx(ServiceCtx context)
{
UpdateVrMode(false);
return ResultCode.Success;
}
private void UpdateVrMode(bool vrModeEnabled)
{
if (_vrModeEnabled == vrModeEnabled)
{
return;
}
_vrModeEnabled = vrModeEnabled;
if (vrModeEnabled)
{
_lblControllerServer.EnableVrMode();
}
else
{
_lblControllerServer.DisableVrMode();
}
// TODO: It signals an internal event of ICommonStateGetter. We have to determine where this event is used.
}
[Command(60)] // 3.0.0+
// GetDefaultDisplayResolution() -> (u32, u32)
public ResultCode GetDefaultDisplayResolution(ServiceCtx context)
@ -135,7 +187,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return ResultCode.InvalidParameters;
}
apmSystemManagerServer.SetCpuBoostMode((Apm.CpuBoostMode)cpuBoostMode);
_apmSystemManagerServer.SetCpuBoostMode((Apm.CpuBoostMode)cpuBoostMode);
// TODO: It signals an internal event of ICommonStateGetter. We have to determine where this event is used.
@ -146,7 +198,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// GetCurrentPerformanceConfiguration() -> nn::apm::PerformanceConfiguration
public ResultCode GetCurrentPerformanceConfiguration(ServiceCtx context)
{
return (ResultCode)apmSystemManagerServer.GetCurrentPerformanceConfiguration(context);
return (ResultCode)_apmSystemManagerServer.GetCurrentPerformanceConfiguration(context);
}
}
}