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

Implemented precise key events #1688

Conversation

EliteMasterEric
Copy link
Contributor

@EliteMasterEric EliteMasterEric commented May 15, 2023

This feature PR adds two new key press event, one for pressing a key and one for releasing a key. The distinction is that the precise key press events include the SDL timestamp of the keypress. By calling SDL_GetTicks() (which this PR also includes an interface for), you can calculate the number of milliseconds since the key was pressed. This is useful for mitigating input latency.

Notes:

  • The previous PR (Added timestamp to KeyDown and KeyUp events. #1561) is now deprecated and has been closed.
  • This PR creates a new, otherwise-redundant key press event to prevent breaking changes from modifying the existing key press event.
  • The event has been made to be compatible with both Native and HTML5.
  • The timestamp provided by the keypress event is only suitable for comparision, and is not an absolute/Unix timestamp.
    • This behavior probably needs to change somehow, for example making a Timestamp object with various compare functions available.
    • On native, compare to lime._internal.backend.native.NativeCFFI.lime_sdl_get_ticks().
    • On HTML5, compare to js.Browser.window.performance.now().
  • The old key press event can be deprecated and eventually removed in a future update.
  • Once Migrate backend from SDL 2 to SDL 3 #1684 is tested, debugged, and implemented, the event can be updated to use nanosecond timings instead.

@player-03 player-03 changed the base branch from develop to 8.2.0-Dev February 5, 2024 19:42
@EliteMasterEric
Copy link
Contributor Author

Since I made this PR I also had to tweak these code changes to make a similar addition to gamepads.

That commit is public.

@EliteMasterEric
Copy link
Contributor Author

Redone in #1802 to include the gamepad stuff and exclude extra commits.

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

Successfully merging this pull request may close these issues.

2 participants