A Linux version
Native mouselock for GameMaker » Devlog
A few people asked about this over years and the Linux API is kind of similar, so there’s this.
- The respective X11 function (
XGrabPointer
) can only lock the mouse to the window (not a specific screen region), sodisplay_mouse_lock
’s arguments will be ignored on Linux. display_mouse_unlock
works as usual.- I added a
display_mouse_lock_auto()
function to auto-lock to window region for consistency between Windows/Linux. - Since X11 doesn’t let you lock mouse to a region,
display_mouse_bounds
will returnundefined
on Linux.
Anyway, the following will work both on Windows and Linux:
if (window_has_focus()) {
display_mouse_lock_auto();
} else {
display_mouse_unlock();
}
“But what about Mac?”
As far as I can tell, CGAssociateMouseAndMouseCursorPosition
is the closest approximation of mouse locking on Mac OS, which is what window_mouse_set_locked
uses. There’s no benefit to me re-implementing it in an extension.
Files
display_mouse_lock (for GM2022+).yymps 11 kB
1 day ago
display_mouse_lock_demo (for GM2022+).yyz 37 kB
1 day ago
Get Native mouselock for GameMaker
Buy Now$2.95 USD or more
Native mouselock for GameMaker
Constrains the mouse cursor to a rectangle at system level
Status | Released |
Category | Assets |
Author | YellowAfterlife |
Tags | extension, GameMaker |
More posts
- A Windows x64 compatible versionMay 23, 2021
Leave a comment
Log in with itch.io to leave a comment.