Skip to content

Obtain raw mouse input with pointer lock #2135

@DNin01

Description

@DNin01

Most operating systems enable a feature known as mouse acceleration, which ramps up the speed of your cursor the faster you move your mouse. This basically means your cursor will be less sensitive to slower mouse movements and more sensitive to faster mouse movements. This is fine for most tasks that use a mouse cursor but is not the best fit for controlling 3D cameras (e.g., in first-person games). For gaming, non-accelerated input is generally preferred because then the camera moves exactly as your mouse does.

Chrome supports PointerLockOptions.unadjustedMovement to ignore mouse acceleration.

element.requestPointerLock({
  unadjustedMovement: true
});
Pointer Lock blocks

This could easily be integrated into the Pointer Lock extension. Obviously, this could be controlled by the project creator using a block. Here's a wording I came up with to make it as intuitive as possible for anyone who has never heard of this terminology before:

  • "Exact movement" means raw input is obtained directly from the mouse, bypassing modifiers from sensitivity and mouse acceleration settings.
    • This works best for 3D camera rotation and is the default option.
  • "Cursor (absolute)" obtains mouse input from the OS, which may be adjusted by sensitivity and mouse acceleration settings.
    • This works best for most computation tasks.
  • "Cursor (scaled)" obtains mouse input from the OS and then multiplies it by the project player's pixel density (measuring as if you were moving your cursor across the entire stage).
    • This works best for moving objects on a canvas or workspace, since the amount of movement will be based on the size of the player screen.

This might be overthinking it and making it even more complex for some people, though; just a block to enable or disable raw input would be fine.

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