Skip to content

movedX and movedY no longer update after calling requestPointerLock #8022

@Mees0x4E

Description

@Mees0x4E

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • p5.strands
  • WebGL
  • DevOps, Build process, Unit testing
  • Internationalization (i18n)
  • Friendly Errors
  • Other (specify if possible)

p5.js version

1.11.7

Web browser and version

No response

Operating system

No response

Steps to reproduce this

Steps (see snippet):

  1. Write a program that calls requestPointerLock() on mouseClicked
  2. Use movedX and movedY values, for example by displaying them on screen

Expectation:
When I move the mouse, it shows by how much the mouse moved that frame. After I click the mouse which calls requestPointerLock, the movedX and movedY will continue showing by how much the mouse moved, even if the mouse is now invisible and locked, as per the documentation on https://p5js.org/reference/p5/movedX/:

Note: movedX continues updating even when requestPointerLock() is active.

Reality:
When using p5 version 1.11.7 or onwards, after calling requestPointerLock, movedX and movedY now no longer update and stay at 0 even when moving my mouse around.
On p5 version 1.11.6 or below, it behaves as expected.

Although I haven't tested it, I suspect that Commit fbffbc1: Consistent movedX and movedY behaviour across zoom levels is the culprit.

Snippet:

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  text(movedX, 20, 20);
  text(movedY, 20, 40);
}
function mouseClicked() {
  requestPointerLock();
}

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