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

performance, Sdl2Input, PumpInput #17520

anvilvapre opened this issue Dec 29, 2019 · 0 comments

performance, Sdl2Input, PumpInput #17520

anvilvapre opened this issue Dec 29, 2019 · 0 comments


Copy link

@anvilvapre anvilvapre commented Dec 29, 2019


PumpEvents seems to be called each frame. Most of the time SDL_PollEvent will not return any input events, since the user has not generated them.

The MakeModifiers and inputHandler.ModifierKeys however is always called each time PumpInput is called. Since it seems that pressing a modifier key will result also in an event it would best to initialize the modifier only once when at least one event was polled. I.e. to set the modifiers inside the PollEvent while loop (once).

This avoids both functions being always called in PumpInput (each Frame) without the resulting value being used or the value having been changed.

(Also the MakeModifiers method is quite expensive considering it only maps an SDL modifier to an RA modifier which are basically similar. Why not make the types/enum values equal and be able to cast the modifier flags.)

                public void PumpInput(Sdl2PlatformWindow device, IInputHandler inputHandler, int2? lockedMousePosition)
                        var mods = MakeModifiers((int)SDL.SDL_GetModState());   
                        while (SDL.SDL_PollEvent(out e) != 0)  {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.