Skip to content

Allow applications to access higher-precision mouse movement data #102

@KingSupernova31

Description

@KingSupernova31

The main uievents specification leaves the frequency of mousemove events up to the implementation. In many major browsers this is around 15-60 events per second, which can result in the pointer skipping tens or even hundreds of pixels in between consecutive events. This poses a problem for applications that need careful tracking of the mouse position, as it results in unavoidable lag that can be very noticeable to the user. (Example)

If the PointerLock API is intended to bring web applications more in line with what's possible in a native app, it needs to address this limitation.

The most straightforward way to do this would be to mandate a minimum frequency of mousemove events on PointerLocked elements, such as at least 120 times per second while the pointer is moving, or at least once for every pixel of movement. However this may lead to performance and/or implementation difficulties given the complexity of the Javascript event system.

So perhaps a better approach would be to allow the application to query raw mouse location data whenever it needs it via a separate getPointerLockMousePosition() method. This method would return an x and y value that represent the true mouse position down to the ~millisecond level; not the position it had the last time a mousemove event was fired.

(Since PointerLocked elements stop using the normal screen coordinates, the coordinate system used by this method would be arbitrary; the values only matter in relation to other values. Perhaps 0,0 could be set to the location where the pointer was when the PointerLock was created.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions