Attempt to stop games gracefully before terminating emulation
This commit is contained in:
parent
ca59c3f499
commit
c93aaebd4e
8 changed files with 48 additions and 9 deletions
|
@ -21,6 +21,7 @@ using Ryujinx.Graphics.GAL.Multithreading;
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.HOS;
|
using Ryujinx.HLE.HOS;
|
||||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy;
|
||||||
using Ryujinx.HLE.HOS.SystemState;
|
using Ryujinx.HLE.HOS.SystemState;
|
||||||
using Ryujinx.Input.GTK3;
|
using Ryujinx.Input.GTK3;
|
||||||
using Ryujinx.Input.HLE;
|
using Ryujinx.Input.HLE;
|
||||||
|
@ -677,7 +678,8 @@ namespace Ryujinx.UI
|
||||||
ConfigurationState.Instance.System.AudioVolume,
|
ConfigurationState.Instance.System.AudioVolume,
|
||||||
ConfigurationState.Instance.System.UseHypervisor,
|
ConfigurationState.Instance.System.UseHypervisor,
|
||||||
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value,
|
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value,
|
||||||
ConfigurationState.Instance.Multiplayer.Mode);
|
ConfigurationState.Instance.Multiplayer.Mode,
|
||||||
|
() => StopEmulation());
|
||||||
|
|
||||||
_emulationContext = new HLE.Switch(configuration);
|
_emulationContext = new HLE.Switch(configuration);
|
||||||
}
|
}
|
||||||
|
@ -1484,7 +1486,7 @@ namespace Ryujinx.UI
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StopEmulation_Pressed(object sender, EventArgs args)
|
private void StopEmulation()
|
||||||
{
|
{
|
||||||
if (_emulationContext != null)
|
if (_emulationContext != null)
|
||||||
{
|
{
|
||||||
|
@ -1497,6 +1499,16 @@ namespace Ryujinx.UI
|
||||||
RendererWidget?.Exit();
|
RendererWidget?.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void StopEmulation_Pressed(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
_emulationContext.System.RequestExit();
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(5000);
|
||||||
|
StopEmulation();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void PauseEmulation_Pressed(object sender, EventArgs args)
|
private void PauseEmulation_Pressed(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
_pauseEmulation.Sensitive = false;
|
_pauseEmulation.Sensitive = false;
|
||||||
|
|
|
@ -169,6 +169,11 @@ namespace Ryujinx.HLE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action RefreshInputConfig { internal get; set; }
|
public Action RefreshInputConfig { internal get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An action to stop emulation.
|
||||||
|
/// </summary>
|
||||||
|
public Action Stop { internal get; set; }
|
||||||
|
|
||||||
public HLEConfiguration(VirtualFileSystem virtualFileSystem,
|
public HLEConfiguration(VirtualFileSystem virtualFileSystem,
|
||||||
LibHacHorizonManager libHacHorizonManager,
|
LibHacHorizonManager libHacHorizonManager,
|
||||||
ContentManager contentManager,
|
ContentManager contentManager,
|
||||||
|
@ -194,7 +199,8 @@ namespace Ryujinx.HLE
|
||||||
float audioVolume,
|
float audioVolume,
|
||||||
bool useHypervisor,
|
bool useHypervisor,
|
||||||
string multiplayerLanInterfaceId,
|
string multiplayerLanInterfaceId,
|
||||||
MultiplayerMode multiplayerMode)
|
MultiplayerMode multiplayerMode,
|
||||||
|
Action stop)
|
||||||
{
|
{
|
||||||
VirtualFileSystem = virtualFileSystem;
|
VirtualFileSystem = virtualFileSystem;
|
||||||
LibHacHorizonManager = libHacHorizonManager;
|
LibHacHorizonManager = libHacHorizonManager;
|
||||||
|
@ -222,6 +228,7 @@ namespace Ryujinx.HLE
|
||||||
UseHypervisor = useHypervisor;
|
UseHypervisor = useHypervisor;
|
||||||
MultiplayerLanInterfaceId = multiplayerLanInterfaceId;
|
MultiplayerLanInterfaceId = multiplayerLanInterfaceId;
|
||||||
MultiplayerMode = multiplayerMode;
|
MultiplayerMode = multiplayerMode;
|
||||||
|
Stop = stop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,6 +329,12 @@ namespace Ryujinx.HLE.HOS
|
||||||
AppletState.SetFocus(true);
|
AppletState.SetFocus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RequestExit()
|
||||||
|
{
|
||||||
|
AppletState.Messages.Enqueue(AppletMessage.Exit);
|
||||||
|
AppletState.MessageEvent.ReadableEvent.Signal();
|
||||||
|
}
|
||||||
|
|
||||||
public void SimulateWakeUpMessage()
|
public void SimulateWakeUpMessage()
|
||||||
{
|
{
|
||||||
AppletState.Messages.Enqueue(AppletMessage.Resume);
|
AppletState.Messages.Enqueue(AppletMessage.Resume);
|
||||||
|
|
|
@ -51,7 +51,9 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
||||||
// Exit()
|
// Exit()
|
||||||
public ResultCode Exit(ServiceCtx context)
|
public ResultCode Exit(ServiceCtx context)
|
||||||
{
|
{
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
Logger.Warning?.Print(LogClass.ServiceAm, "Self Applet Exit");
|
||||||
|
|
||||||
|
context.Device.Configuration.Stop();
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -580,7 +580,8 @@ namespace Ryujinx.Headless.SDL2
|
||||||
options.AudioVolume,
|
options.AudioVolume,
|
||||||
options.UseHypervisor ?? true,
|
options.UseHypervisor ?? true,
|
||||||
options.MultiplayerLanInterfaceId,
|
options.MultiplayerLanInterfaceId,
|
||||||
Common.Configuration.Multiplayer.MultiplayerMode.Disabled);
|
Common.Configuration.Multiplayer.MultiplayerMode.Disabled,
|
||||||
|
() => _window.Exit());
|
||||||
|
|
||||||
return new Switch(configuration);
|
return new Switch(configuration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,12 @@ namespace Ryujinx.Headless.SDL2
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
|
case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
|
||||||
|
Device.System.RequestExit();
|
||||||
|
/*
|
||||||
|
SDL2Driver.Instance.AddTimer(5000, () => {
|
||||||
Exit();
|
Exit();
|
||||||
|
});
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Ryujinx.SDL2.Common
|
||||||
|
|
||||||
public static Action<Action> MainThreadDispatcher { get; set; }
|
public static Action<Action> MainThreadDispatcher { get; set; }
|
||||||
|
|
||||||
private const uint SdlInitFlags = SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_VIDEO;
|
private const uint SdlInitFlags = SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_TIMER;
|
||||||
|
|
||||||
private bool _isRunning;
|
private bool _isRunning;
|
||||||
private uint _refereceCount;
|
private uint _refereceCount;
|
||||||
|
|
|
@ -872,7 +872,8 @@ namespace Ryujinx.Ava
|
||||||
ConfigurationState.Instance.System.AudioVolume,
|
ConfigurationState.Instance.System.AudioVolume,
|
||||||
ConfigurationState.Instance.System.UseHypervisor,
|
ConfigurationState.Instance.System.UseHypervisor,
|
||||||
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value,
|
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value,
|
||||||
ConfigurationState.Instance.Multiplayer.Mode);
|
ConfigurationState.Instance.Multiplayer.Mode,
|
||||||
|
() => Stop());
|
||||||
|
|
||||||
Device = new Switch(configuration);
|
Device = new Switch(configuration);
|
||||||
}
|
}
|
||||||
|
@ -1092,7 +1093,12 @@ namespace Ryujinx.Ava
|
||||||
|
|
||||||
if (shouldExit)
|
if (shouldExit)
|
||||||
{
|
{
|
||||||
|
Device.System.RequestExit();
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(5000);
|
||||||
Stop();
|
Stop();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue