diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs index d9dfb4b2..79fef93d 100644 --- a/Ryujinx.HLE/HOS/Horizon.cs +++ b/Ryujinx.HLE/HOS/Horizon.cs @@ -7,6 +7,7 @@ using LibHac.FsSystem.NcaUtils; using LibHac.Ncm; using LibHac.Ns; using LibHac.Spl; +using Ryujinx.Common; using Ryujinx.Common.Configuration; using Ryujinx.Common.Logging; using Ryujinx.Configuration; @@ -16,7 +17,9 @@ using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Memory; using Ryujinx.HLE.HOS.Kernel.Process; using Ryujinx.HLE.HOS.Kernel.Threading; +using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy; using Ryujinx.HLE.HOS.Services.Mii; +using Ryujinx.HLE.HOS.Services.Nv; using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl; using Ryujinx.HLE.HOS.Services.Pcv.Bpc; using Ryujinx.HLE.HOS.Services.Settings; @@ -41,7 +44,6 @@ using TimeServiceManager = Ryujinx.HLE.HOS.Services.Time.TimeManager; using NsoExecutable = Ryujinx.HLE.Loaders.Executables.NsoExecutable; using static LibHac.Fs.ApplicationSaveDataManagement; -using Ryujinx.HLE.HOS.Services.Nv; namespace Ryujinx.HLE.HOS { @@ -114,6 +116,8 @@ namespace Ryujinx.HLE.HOS internal KEvent VsyncEvent { get; private set; } + internal KEvent DisplayResolutionChangeEvent { get; private set; } + public Keyset KeySet => Device.FileSystem.KeySet; #pragma warning disable CS0649 @@ -224,6 +228,8 @@ namespace Ryujinx.HLE.HOS VsyncEvent = new KEvent(this); + DisplayResolutionChangeEvent = new KEvent(this); + ContentManager = contentManager; // TODO: use set:sys (and get external clock source id from settings) @@ -272,6 +278,20 @@ namespace Ryujinx.HLE.HOS HostSyncpoint = new NvHostSyncpt(device); SurfaceFlinger = new SurfaceFlinger(device); + + ConfigurationState.Instance.System.EnableDockedMode.Event += OnDockedModeChange; + } + + private void OnDockedModeChange(object sender, ReactiveEventArgs e) + { + if (e.NewValue != State.DockedMode) + { + State.DockedMode = e.NewValue; + + AppletState.EnqueueMessage(MessageInfo.OperationModeChanged); + AppletState.EnqueueMessage(MessageInfo.PerformanceModeChanged); + SignalDisplayResolutionChange(); + } } public void LoadCart(string exeFsDir, string romFsFile = null) @@ -807,6 +827,11 @@ namespace Ryujinx.HLE.HOS return rc; } + public void SignalDisplayResolutionChange() + { + DisplayResolutionChangeEvent.ReadableEvent.Signal(); + } + public void SignalVsync() { VsyncEvent.ReadableEvent.Signal(); @@ -852,6 +877,8 @@ namespace Ryujinx.HLE.HOS { if (!_isDisposed && disposing) { + ConfigurationState.Instance.System.EnableDockedMode.Event -= OnDockedModeChange; + _isDisposed = true; SurfaceFlinger.Dispose(); diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ISystemAppletProxy.cs b/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ISystemAppletProxy.cs index ecd5076f..de2281c2 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ISystemAppletProxy.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ISystemAppletProxy.cs @@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService // GetCommonStateGetter() -> object public ResultCode GetCommonStateGetter(ServiceCtx context) { - MakeObject(context, new ICommonStateGetter(context.Device.System)); + MakeObject(context, new ICommonStateGetter()); return ResultCode.Success; } diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs b/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs index 10c732b7..b495b86f 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs @@ -9,14 +9,9 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys { class ICommonStateGetter : IpcService { - private KEvent _displayResolutionChangeEvent; - private CpuBoostMode _cpuBoostMode = CpuBoostMode.Disabled; - public ICommonStateGetter(Horizon system) - { - _displayResolutionChangeEvent = new KEvent(system); - } + public ICommonStateGetter() { } [Command(0)] // GetEventHandle() -> handle @@ -108,7 +103,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys // GetDefaultDisplayResolutionChangeEvent() -> handle public ResultCode GetDefaultDisplayResolutionChangeEvent(ServiceCtx context) { - if (context.Process.HandleTable.GenerateHandle(_displayResolutionChangeEvent.ReadableEvent, out int handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(context.Device.System.DisplayResolutionChangeEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs index eda73e22..3d3287d0 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService // GetCommonStateGetter() -> object public ResultCode GetCommonStateGetter(ServiceCtx context) { - MakeObject(context, new ICommonStateGetter(context.Device.System)); + MakeObject(context, new ICommonStateGetter()); return ResultCode.Success; } diff --git a/Ryujinx.HLE/Switch.cs b/Ryujinx.HLE/Switch.cs index ea3ab238..6fcb3fb8 100644 --- a/Ryujinx.HLE/Switch.cs +++ b/Ryujinx.HLE/Switch.cs @@ -68,7 +68,6 @@ namespace Ryujinx.HLE EnableDeviceVsync = ConfigurationState.Instance.Graphics.EnableVsync; - // TODO: Make this reloadable and implement Docking/Undocking logic. System.State.DockedMode = ConfigurationState.Instance.System.EnableDockedMode; if (ConfigurationState.Instance.System.EnableMulticoreScheduling)