Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate receiving input without using window event flow #6141

Open
peppy opened this issue Jan 18, 2024 · 2 comments · May be fixed by #6235
Open

Investigate receiving input without using window event flow #6141

peppy opened this issue Jan 18, 2024 · 2 comments · May be fixed by #6235

Comments

@peppy
Copy link
Sponsor Member

peppy commented Jan 18, 2024

Using window events can really suck if something on the OS decides to block the macOS main thread. Any app can do this and it will cause a delay in receiving events across all apps (example ppy/osu#26604). I've hit this many times myself.

It may also be relevant on windows for key input, as we are not using raw input there (I've seen reports of some users hitting input delays on windows with similar blocking).

cc @Susko3 since you might have something to add here.

@Susko3
Copy link
Member

Susko3 commented Jan 18, 2024

If I understand correctly, blocking the main thread only happens because we (or SDL) asks the OS for events (on Windows that would be via PeekMessage()) and that call blocks / takes a while for whatever reason. So the idea is to get (specifically) input events in another thread?

Would be useful to have a program that can generate this kind of lag. I played around in AutoHotkey and the best lag generator I could come up with is just sending a lot of mouse clicks. I'm unsure how representative this is of real-world lag, but it does spike the InputThread WndProc monitor and makes keyboard and mouse input lag.

Anyways, SDL3 recently added support for pooling Windows raw mouse input in a separate thread (libsdl-org/SDL#8756). I believe it should be possible to hook directly into these events by installing an SDL event filter/watch, like we currently do for other specific events.

It probably isn't too hard to add RAWKEYBOARD handling to SDL.


It may also be relevant on windows for key input, as we are not using raw input there (I've seen reports of some users hitting input delays on windows with similar blocking).

onWndProc in WindowsMouseHandler is only called by SDL_PumpEvents(). So it is still very much tied to the event loop.

@Susko3
Copy link
Member

Susko3 commented Mar 27, 2024

SDL3 has added raw keyboard on windows: libsdl-org/SDL#9363. This is starting to look like a really interesting update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants