Skip to content

Precise input timing information #9087

@cryslith

Description

@cryslith

What problem does this solve or what need does it fill?

The application I'm concerned with is rhythm games. Currently it is not possible to determine the time at which an input event (such as a keyboard press) occurred with precision better than 1 frame. However, rhythm games require input timing information which is more precise than this. For example, the ECFA Fantastic window is 11ms long, and the osu! 300 window can be as short as 13.33ms. On the other hand, a frame at 144fps is 6.94 ms long, while a frame at 60fps is 16.66 ms long. This means that the error incurred by measuring the time of an input precise to the next frame could be 50% or more of the actual timing window, making it impossible for players to reliably input in the window.

Besides rhythm games, precise input timing information is also applicable to other issues, such as #5984 and #6183.

What solution would you like?

Add Instant::now() to events processed in the winit event loop and the gilrs event loop. Additionally rewrite the gilrs integration so that gamepad events are polled continuously (like winit events) rather than once per frame so that these timestamps are accurate.

What alternative(s) have you considered?

Use timing information from the OS passed through by winit and gilrs, instead of measuring it ourselves using Instant::now() in the event loop. This has several issues:

  • OS timing information may be unreliable. For instance, some OS timing information is precise only to the millsecond, which might be suitable for rhythm games but not for other uses of timestamps. They might also be nonmonotonic etc.
  • winit doesn't currently expose timing information from the OS (Input event timestamps rust-windowing/winit#1194)
  • gilrs timestamps are expressed as SystemTime, which could lead to issues. For instance these timestamps aren't monotonic and are affected by system time changes.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-InputPlayer input via keyboard, mouse, gamepad, and moreC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions