Added timestamp to KeyDown and KeyUp events. #1561
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am looking into methods of retrieving a highly precise timestamp corresponding with a user's keypress. This is important for applications which need to know exactly when a given key was pressed (which, among other things, includes video games such as rhythm games or fighting games, which demand precise inputs).
If each key event includes a precise hardware timestamp, recorded before any of the processing required to call event listeners is done, then said processing can be compensated for by retrieving a new timestamp and calculating the difference.
I discovered in my research that the
SDL_KeyboardEvent
which Lime receives (on native) does include such a timestamp, however the value is not retained, so I made this pull request to include it.The pull request is a draft pending the resolution of the following issues:
lime.app.Application.onKeyDown
is a breaking change which affects OpenFL, Flixel, and other dependent libraries, is there a more stable method to make this change?SDL_KeyboardEvent
is millisecond accurate, and is the value ofSDL_GetTicks
function, which is based on the duration since SDL was initialized, but there is not currently an accessible method to retrieve this value in Lime to perform comparison with.