2021-01-10 21:26:59 +01:00
|
|
|
using LibHac.Ns;
|
2018-10-17 19:15:50 +02:00
|
|
|
using Ryujinx.Common.Logging;
|
2020-05-15 03:14:38 +02:00
|
|
|
using Ryujinx.HLE.HOS.Services.Arp;
|
|
|
|
using System;
|
2018-02-10 01:14:55 +01:00
|
|
|
|
2019-09-19 02:45:11 +02:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
|
2018-02-10 01:14:55 +01:00
|
|
|
{
|
2018-03-19 19:58:46 +01:00
|
|
|
class IParentalControlService : IpcService
|
2018-02-10 01:14:55 +01:00
|
|
|
{
|
2021-01-10 21:26:59 +01:00
|
|
|
private int _permissionFlag;
|
|
|
|
private ulong _titleId;
|
|
|
|
private ParentalControlFlagValue _parentalControlFlag;
|
|
|
|
private int[] _ratingAge;
|
2020-11-24 21:19:06 +01:00
|
|
|
|
|
|
|
// TODO: Find where they are set.
|
2021-01-10 21:26:59 +01:00
|
|
|
private bool _restrictionEnabled = false;
|
|
|
|
private bool _featuresRestriction = false;
|
|
|
|
private bool _stereoVisionRestrictionConfigurable = true;
|
|
|
|
private bool _stereoVisionRestriction = false;
|
2018-06-12 20:28:45 +02:00
|
|
|
|
2020-05-15 03:14:38 +02:00
|
|
|
public IParentalControlService(ServiceCtx context, bool withInitialize, int permissionFlag)
|
2018-02-10 01:14:55 +01:00
|
|
|
{
|
2020-05-15 03:14:38 +02:00
|
|
|
_permissionFlag = permissionFlag;
|
|
|
|
|
|
|
|
if (withInitialize)
|
|
|
|
{
|
|
|
|
Initialize(context);
|
|
|
|
}
|
2018-02-10 01:14:55 +01:00
|
|
|
}
|
2018-06-12 20:28:45 +02:00
|
|
|
|
2019-07-12 03:13:43 +02:00
|
|
|
[Command(1)] // 4.0.0+
|
|
|
|
// Initialize()
|
2019-07-14 21:04:38 +02:00
|
|
|
public ResultCode Initialize(ServiceCtx context)
|
2018-06-12 20:28:45 +02:00
|
|
|
{
|
2020-05-15 03:14:38 +02:00
|
|
|
if ((_permissionFlag & 0x8001) == 0)
|
2018-06-13 02:51:59 +02:00
|
|
|
{
|
2020-05-15 03:14:38 +02:00
|
|
|
return ResultCode.PermissionDenied;
|
2018-06-13 02:51:59 +02:00
|
|
|
}
|
2020-05-15 03:14:38 +02:00
|
|
|
|
|
|
|
ResultCode resultCode = ResultCode.InvalidPid;
|
|
|
|
|
|
|
|
if (context.Process.Pid != 0)
|
2018-06-13 02:51:59 +02:00
|
|
|
{
|
2020-05-15 03:14:38 +02:00
|
|
|
if ((_permissionFlag & 0x40) == 0)
|
|
|
|
{
|
|
|
|
ulong titleId = ApplicationLaunchProperty.GetByPid(context).TitleId;
|
|
|
|
|
|
|
|
if (titleId != 0)
|
|
|
|
{
|
|
|
|
_titleId = titleId;
|
|
|
|
|
|
|
|
// TODO: Call nn::arp::GetApplicationControlProperty here when implemented, if it return ResultCode.Success we assign fields.
|
2021-01-10 21:26:59 +01:00
|
|
|
_ratingAge = Array.ConvertAll(context.Device.Application.ControlData.Value.RatingAge.ToArray(), Convert.ToInt32);
|
|
|
|
_parentalControlFlag = context.Device.Application.ControlData.Value.ParentalControl;
|
2020-05-15 03:14:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_titleId != 0)
|
|
|
|
{
|
|
|
|
// TODO: Service store some private fields in another static object.
|
|
|
|
|
|
|
|
if ((_permissionFlag & 0x8040) == 0)
|
|
|
|
{
|
|
|
|
// TODO: Service store TitleId and FreeCommunicationEnabled in another static object.
|
|
|
|
// When it's done it signal an event in this static object.
|
2020-08-04 01:32:53 +02:00
|
|
|
Logger.Stub?.PrintStub(LogClass.ServicePctl);
|
2020-05-15 03:14:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resultCode = ResultCode.Success;
|
2018-06-13 02:51:59 +02:00
|
|
|
}
|
2018-06-12 20:28:45 +02:00
|
|
|
|
2020-05-15 03:14:38 +02:00
|
|
|
return resultCode;
|
2018-06-12 20:28:45 +02:00
|
|
|
}
|
2019-04-22 08:54:47 +02:00
|
|
|
|
2019-07-12 03:13:43 +02:00
|
|
|
[Command(1001)]
|
|
|
|
// CheckFreeCommunicationPermission()
|
2019-07-14 21:04:38 +02:00
|
|
|
public ResultCode CheckFreeCommunicationPermission(ServiceCtx context)
|
2019-04-22 08:54:47 +02:00
|
|
|
{
|
2021-01-10 21:26:59 +01:00
|
|
|
if (_parentalControlFlag == ParentalControlFlagValue.FreeCommunication && _restrictionEnabled)
|
2020-05-15 03:14:38 +02:00
|
|
|
{
|
2021-01-10 21:26:59 +01:00
|
|
|
// TODO: It seems to checks if an entry exists in the FreeCommunicationApplicationList using the TitleId.
|
|
|
|
// Then it returns FreeCommunicationDisabled if the entry doesn't exist.
|
|
|
|
|
2020-05-15 03:14:38 +02:00
|
|
|
return ResultCode.FreeCommunicationDisabled;
|
|
|
|
}
|
|
|
|
|
2021-01-10 21:26:59 +01:00
|
|
|
// NOTE: This sets an internal field to true. Usage have to be determined.
|
|
|
|
|
2020-11-24 21:19:06 +01:00
|
|
|
Logger.Stub?.PrintStub(LogClass.ServicePctl);
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
return ResultCode.Success;
|
2019-04-22 08:54:47 +02:00
|
|
|
}
|
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
2020-11-15 22:30:20 +01:00
|
|
|
|
|
|
|
[Command(1013)] // 4.0.0+
|
|
|
|
// ConfirmStereoVisionPermission()
|
|
|
|
public ResultCode ConfirmStereoVisionPermission(ServiceCtx context)
|
|
|
|
{
|
|
|
|
return IsStereoVisionPermittedImpl();
|
|
|
|
}
|
|
|
|
|
2021-01-10 21:26:59 +01:00
|
|
|
[Command(1018)]
|
|
|
|
// IsFreeCommunicationAvailable()
|
|
|
|
public ResultCode IsFreeCommunicationAvailable(ServiceCtx context)
|
|
|
|
{
|
|
|
|
if (_parentalControlFlag == ParentalControlFlagValue.FreeCommunication && _restrictionEnabled)
|
|
|
|
{
|
|
|
|
// TODO: It seems to checks if an entry exists in the FreeCommunicationApplicationList using the TitleId.
|
|
|
|
// Then it returns FreeCommunicationDisabled if the entry doesn't exist.
|
|
|
|
|
|
|
|
return ResultCode.FreeCommunicationDisabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServicePctl);
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2020-11-24 21:19:06 +01:00
|
|
|
[Command(1031)]
|
|
|
|
// IsRestrictionEnabled() -> b8
|
|
|
|
public ResultCode IsRestrictionEnabled(ServiceCtx context)
|
|
|
|
{
|
|
|
|
if ((_permissionFlag & 0x140) == 0)
|
|
|
|
{
|
|
|
|
return ResultCode.PermissionDenied;
|
|
|
|
}
|
|
|
|
|
|
|
|
context.ResponseData.Write(_restrictionEnabled);
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
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
2020-11-15 22:30:20 +01:00
|
|
|
[Command(1061)] // 4.0.0+
|
|
|
|
// ConfirmStereoVisionRestrictionConfigurable()
|
|
|
|
public ResultCode ConfirmStereoVisionRestrictionConfigurable(ServiceCtx context)
|
|
|
|
{
|
|
|
|
if ((_permissionFlag & 2) == 0)
|
|
|
|
{
|
|
|
|
return ResultCode.PermissionDenied;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_stereoVisionRestrictionConfigurable)
|
|
|
|
{
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ResultCode.StereoVisionRestrictionConfigurableDisabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[Command(1062)] // 4.0.0+
|
|
|
|
// GetStereoVisionRestriction() -> bool
|
|
|
|
public ResultCode GetStereoVisionRestriction(ServiceCtx context)
|
|
|
|
{
|
|
|
|
if ((_permissionFlag & 0x200) == 0)
|
|
|
|
{
|
|
|
|
return ResultCode.PermissionDenied;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool stereoVisionRestriction = false;
|
|
|
|
|
|
|
|
if (_stereoVisionRestrictionConfigurable)
|
|
|
|
{
|
|
|
|
stereoVisionRestriction = _stereoVisionRestriction;
|
|
|
|
}
|
|
|
|
|
|
|
|
context.ResponseData.Write(stereoVisionRestriction);
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Command(1063)] // 4.0.0+
|
|
|
|
// SetStereoVisionRestriction(bool)
|
|
|
|
public ResultCode SetStereoVisionRestriction(ServiceCtx context)
|
|
|
|
{
|
|
|
|
if ((_permissionFlag & 0x200) == 0)
|
|
|
|
{
|
|
|
|
return ResultCode.PermissionDenied;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool stereoVisionRestriction = context.RequestData.ReadBoolean();
|
|
|
|
|
|
|
|
if (!_featuresRestriction)
|
|
|
|
{
|
|
|
|
if (_stereoVisionRestrictionConfigurable)
|
|
|
|
{
|
|
|
|
_stereoVisionRestriction = stereoVisionRestriction;
|
|
|
|
|
|
|
|
// TODO: It signals an internal event of service. We have to determine where this event is used.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Command(1064)] // 5.0.0+
|
|
|
|
// ResetConfirmedStereoVisionPermission()
|
|
|
|
public ResultCode ResetConfirmedStereoVisionPermission(ServiceCtx context)
|
|
|
|
{
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Command(1065)] // 5.0.0+
|
|
|
|
// IsStereoVisionPermitted() -> bool
|
|
|
|
public ResultCode IsStereoVisionPermitted(ServiceCtx context)
|
|
|
|
{
|
|
|
|
bool isStereoVisionPermitted = false;
|
|
|
|
|
|
|
|
ResultCode resultCode = IsStereoVisionPermittedImpl();
|
|
|
|
|
|
|
|
if (resultCode == ResultCode.Success)
|
|
|
|
{
|
|
|
|
isStereoVisionPermitted = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
context.ResponseData.Write(isStereoVisionPermitted);
|
|
|
|
|
|
|
|
return resultCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
private ResultCode IsStereoVisionPermittedImpl()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
// TODO: Application Exemptions are readed from file "appExemptions.dat" in the service savedata.
|
|
|
|
// Since we don't support the pctl savedata for now, this can be implemented later.
|
|
|
|
|
|
|
|
if (appExemption)
|
|
|
|
{
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (_stereoVisionRestrictionConfigurable && _stereoVisionRestriction)
|
|
|
|
{
|
|
|
|
return ResultCode.StereoVisionDenied;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
}
|
2018-02-10 01:14:55 +01:00
|
|
|
}
|
|
|
|
}
|