FNA-XNA / FNA

FNA - Accuracy-focused XNA4 reimplementation for open platforms
https://fna-xna.github.io/
2.61k stars 265 forks source link

Use SDL_GetKeyboardState instead of event polling #469

Open thatcosmonaut opened 9 months ago

thatcosmonaut commented 9 months ago

We got a report from the Celeste modding/speedrunning community that FNA was causing input latency on keyboard relative to XNA. FNA currently processes keyboard input by processing all keyboard events in PollEvents and setting the keys in an internal array. But according to the report, XNA actually gets a new state every time Keyboard.GetState is called, not just once per frame. This patch brings the behavior in line with XNA, and it should address latency by allowing input polling to occur closer to when input is actually processed by the game.

We got a report from the Celeste modding/speedrunning community that FNA was causing input latency on keyboard relative to XNA when an IME was installed. This patch gets the keyboard state directly all at once instead of iterating over keydown events. This might address some scenarios where the keydown event is intercepted by something. It should also be very slightly more efficient to not have to call keys.Contains on all keypresses.