1

I need to lock the pointer but when I requestPointerLock it's telling me

Request for pointer lock was denied because Element.requestPointerLock() was not called from inside a short running user-generated event handler, and the document is not in full screen.

Or

Request for pointer lock was denied because the document is not focused.

Which makes sense, but I'm making an app that needs to open with a locked pointer, can't wait for user interaction. Good news is I have complete control over the device, so I figured I would edit some about:config setting and I'd call it a day, but I can't seem to find the one.

How can I tell firefox to allow the pointer lock at any time?

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
php_nub_qq
  • 15,199
  • 21
  • 74
  • 144
  • I've peeked `https://searchfox.org/mozilla-central/source/dom/base/Document.cpp#14415` - maybe you can affect `aUserInputOrChromeCaller`? – itsho Oct 05 '20 at 10:31

1 Answers1

0

The problem is that requestPointerLock cannot be called automatically, it should be called from the user's callback, for example, when clicking on something.

You can call requestPointerLock() directly if the user has accepted a fullscreen request see link.