oryol icon indicating copy to clipboard operation
oryol copied to clipboard

Oryol::Input::Mouse does not offer possibility to enter lock mode without mouse button being pressed

Open anthraxx opened this issue 9 years ago • 1 comments

It seems like it is not supported to enter the lockedMode (PointerLockModeEnable) without a mouse button being pressed.

For GLFW, updating the locked mode is bound to the mouseButtonCallback https://github.com/floooh/oryol/blob/master/code/Modules/Input/glfw/glfwInputMgr.cc#L145 (seems to also be the case for the other platforms)

It would be nice if locked mode can be enforced in the Oryol API without the need to press any buttons (and also release it without any mouse-button being pressed). This can be quite useful for FPS (first person shooter) mode of mouse handling and deactivating it via code (f.e. if ESC is being pressed).

anthraxx avatar Mar 17 '16 00:03 anthraxx

Yes, that's a web platform limitation. Certain actions, like enter mouse lock or entering fullscreen must only happen when caused by a user action (for security reasons, but IMHO this is pretty stupid), that's why I had to move this stuff into a callback. I'm going to make this more flexibel by unifying input events, but entering mouse lock will always have to be tied to an input event somehow on web platforms.

What we can do is to initialize the input system with a flag in InputSetup which basically says "please go into mouse-lock mode as soon as possible", on web platforms this would happen on the first input event, on other platforms it could happen right away. Same could also be done while the game runs, basically some "please enter mouse lock as soon as possible" method on the Input facade.

floooh avatar Mar 17 '16 08:03 floooh