Note: in GM2023+, this extension is superseded by the window_mouse_set_locked function.

This extension provides a unified API for "mouselock" on desktop platforms and web (HTML5).

Foremost intended for making web-based games with camera rotation, but has numerous other uses.

Included functions are:

  • mouse_lock(): Locks the mouse cursor at current position.
  • mouse_unlock(): Unlocks the mouse cursor.
  • mouse_delta_x, mouse_delta_y: Mouse movement since the last frame (if locked),
  • mouse_lock_update(): Must be called once per frame. Updates mouse_delta_* variables.
  • mouse_is_locked(): Returns whether the mouse is currently locked.
    (on HTML5, mouse can only be locked after a click on the game)
StatusReleased
CategoryAssets
Rating
Rated 5.0 out of 5 stars
(3 total ratings)
AuthorYellowAfterlife
Made withGameMaker
TagsGameMaker

Download

Download NowName your own price

Click download now to get access to the following files:

PointerLock.gmz 19 kB

Comments

Log in with itch.io to leave a comment.

This sounds amazing, but also potentially easy to abuse.

(1 edit)

Thank you!

One cannot easily abuse PointerLock API since the visitor can press Escape at any time to unlock the cursor, cursor can only be locked on interaction, and keyboard shortcuts to close/switch the page cannot be overridden.

As for window_mouse_set/display_mouse_set - kind of. Always has been.

Sounds like somebody upstream should update the APIs then.

That’s how Windows works in general, unfortunately - just about any program that you run could start executing automation functions at incredible pace, and you wouldn’t be able to do much about it, or even easily figure out which program is at fault.

awesome