Skip to content

joypad: improve input latency by polling just before vblank #760

@rasky

Description

@rasky

I think currently there’s a "race" between the main thread being unblocked by the vblank interrupt (display_get() exiting with a new buffer) and the joypad module trying to poll the controllers in background. If the main thread reaches joypad_poll() before joypad manages to finish the handshake, the inputs will be one full frame late. This probably depends on the architecture of the main loop so varies from game to gam.

With the new VI module, we now have a nice API for line interrupts.

So in theory the best solution would be to estimate the duration of joypad polling (which depends on the number of plugged-in devices) and configure a line interrupt so that inputs are refreshed just in time for vblank to trigger. This should minimize the input latency as much as possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    new featureSuggestion for a new featureperformanceSuggestion for a performance-related improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions