Skip to content

Add binding for requestPointerLock option unadjustedMovement: true #3862

@jf908

Description

@jf908

Motivation

Providing the { unadjustedMovement: true } option while calling requestPointerLock causes subsequent mouse move events to bypass the OS's mouse acceleration and sensitivity. This is useful for a couple reasons.

  1. Many games would rather access raw mouse input, especially for controlling first-person camera movement, so that input acceleration can be disabled or controlled.
  2. There is a longstanding Chrome bug where the occasional mouse movement event has an incorrect, very large delta value which causes the cursor to "teleport". Setting unadjustedMovement to true is a workaround for this.

Proposed Solution

The spec for pointer lock options is unstable so it makes sense to mark this with the unstable flag.

This WebIDL is a start:

dictionary PointerLockOptions {
  boolean unadjustedMovement = false;
};

partial interface Element {
  [NeedsCallerType]
  Promise<undefined> requestPointerLock(optional PointerLockOptions options = {});
};

but there are currently 2 issues I'm encountering with this solution.

  1. Since requestPointerLock is already a stable feature, this generates 2 functions with the same name. Is there a way to override an existing function in unstable?
  2. requestPointerLock returns undefined on unsupported browsers but Promise<undefined>? returns a parsing error. Any ideas why would this wouldn't work even though there are other functions that return optional values?

Any advice on these issues is welcome!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions