Skip to content

Conversation

@alvinjiooo
Copy link
Collaborator

@alvinjiooo alvinjiooo commented Jun 5, 2024

This PR replaces #49 originally started by @NavidZ.

The goal of this change is to allow application to access unadjusted mouse movement data while in Pointer Lock. This is a highly requested feature from partners in the gaming space. This change adds a PointerLockOptions object as a parameter to the requestPointerLock() method. The PointerLockOptions object currently only has one useful member which is the boolean unadjustedMovement. Also, to properly return error information and make it easier for developers to implement the requestPointerLock method was changed to return a promise.

The existing Pointer Lock API returns the mouse movement that the platforms give Chrome. By default all platforms include some form of mouse acceleration in the movement information they give Chrome. Mouse acceleration is the artificial increase of velocity when the mouse is moving fast. This is useful in normal use of the pointer when a user is trying to move the mouse across the screen. However, it also makes aiming in first person perspective games very difficult. To solve this problem we are adding an option to get that unadjusted movement data when requesting pointer lock.

With Pointer Lock options now available, applications need the ability to change those options while keeping the lock. This proves difficult using the previous API which fired changed or error events on the document to indicate the result of the request. Particularly troublesome was that the error event gave no reason. To solve this problem for developers a Promise workflow is being introduced. Now when requesting a change the developers can get actionable error information on rejected requests.

Example:

try {
  await element.requestPointerLock({ unadjustedMovement: true });
  console.log(“pointer lock acquired”);
} catch (error) {
  console.log(`Failed to acquire pointer lock due to ${error}`);
}

Closes #36

The following tasks have been completed:

  • Modified Web platform tests (link to pull request)

Implementation commitment:


Preview | Diff

@alvinjiooo alvinjiooo self-assigned this Jun 5, 2024
@alvinjiooo
Copy link
Collaborator Author

Due to the IPR issue in #49 , I created this duplicate PR to bypass the CI issue.

Hi @james-howard, for some reasons I couldn't add you as reviewers at this PR, I add you here to notify that we create this dup PR for #49 .

Copy link
Contributor

@scheib scheib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the all the work on this @alvinjiooo, and earlier editors @NavidZ and @jameshollyergoogle, and all the reviewers.

@mustaqahmed mustaqahmed requested a review from domenic June 6, 2024 13:54
@mustaqahmed
Copy link
Member

I am approving the PR based on the following points:


I second @scheib in thanking everyone for their patience with #49 (which was about to become ~5 years old 😞), especially @NavidZ, @jameshollyergoogle, @alvinjiooo, @domenic and @marcoscaceres.

@mustaqahmed
Copy link
Member

At this point, I am in favor of landing this PR and move the discussion to open issues as we agreed already. Any objections? FYI @marcoscaceres who was the last reviewer of the original PR #49.

@mustaqahmed
Copy link
Member

Landing now but please continue the discussion in linked or new issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option needed to disable OS-level adjustment for mouse acceleration

4 participants