mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-27 22:06:24 +02:00
Work around Escape hotkey race with exit confirmation dialog
See merge request ryubing/ryujinx!54
This commit is contained in:
parent
90582e9e93
commit
512120db04
2 changed files with 21 additions and 0 deletions
|
@ -1152,6 +1152,24 @@ namespace Ryujinx.Ava.Systems
|
|||
|
||||
_dialogShown = true;
|
||||
|
||||
// The hard-coded hotkey mapped to exit is Escape, but it's also the same key
|
||||
// that causes the dialog we launch to close (without doing anything). In release
|
||||
// mode, a race is observed that between ShowExitPrompt() appearing on KeyDown
|
||||
// and the ContentDialog we create seeing the key state before KeyUp. Merely waiting
|
||||
// for the key to no longer be pressed appears to be insufficient.
|
||||
// NB: Using _keyboardInterface.IsPressed(Key.Escape) does not currently work.
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
while (GetAsyncKeyState(0x1B) != 0)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Delay(250);
|
||||
}
|
||||
|
||||
shouldExit = await ContentDialogHelper.CreateStopEmulationDialog();
|
||||
|
||||
_dialogShown = false;
|
||||
|
|
|
@ -110,5 +110,8 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
|
||||
[LibraryImport("user32.dll", SetLastError = true)]
|
||||
public static partial nint SetWindowLongPtrW(nint hWnd, int nIndex, nint value);
|
||||
|
||||
[LibraryImport("user32.dll", SetLastError = true)]
|
||||
public static partial ushort GetAsyncKeyState(int nVirtKey);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue