SDL2Driver: Invoke dispatcher on main thread (#3818)

This commit is contained in:
merry 2022-12-02 13:37:22 +00:00 committed by GitHub
parent d9053bbe37
commit 204c031fef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 21 deletions

View file

@ -28,6 +28,8 @@ namespace Ryujinx.SDL2.Common
}
}
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 bool _isRunning;
@ -154,10 +156,13 @@ namespace Ryujinx.SDL2.Common
while (_isRunning)
{
while (SDL_PollEvent(out SDL_Event evnt) != 0)
MainThreadDispatcher?.Invoke(() =>
{
HandleSDLEvent(ref evnt);
}
while (SDL_PollEvent(out SDL_Event evnt) != 0)
{
HandleSDLEvent(ref evnt);
}
});
waitHandle.Wait(WaitTimeMs);
}