[SOLVED] How to block your mouse in the screen?

N

Neihra

Guest
Hi guys!

I'm searching for days on how to block my mouse in my game window because i play on multiple screen, i found this function:

Code:
window_mouse_set(clamp(window_mouse_get_x(), 0, window_get_width()), clamp(window_mouse_get_y(), 0, window_get_height()));
it works fine but if i move my mouse quickly i can click outside the screen... My game is normally in 60 steps/s, when i try with 600 steps it is better but still possible to click outside.

Someone has a solution? :)

thanks :)
 
P

pixelkitty

Guest
Guessing here.

Maybe try display_mouse_set, to lock into the screen instead of just the window. Not sure how that will interact with multiple screens, but worth exploring maybe.

Good luck. Share the answer if you find one.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
I wrote a DLL a while ago that uses OS-level functions to lock mouse to a rectangular region, meaning that it cannot escape that no matter what. There's a demo included.

Other than that, lock the mouse to the middle of the window, compute relative coordinates, and draw your own fake cursor on them. I made a free extension for that a while ago (gets you "mouse_delta_x" and "mouse_delta_y" variables for ease of use).
 

Bawat

Member
I wrote a DLL a while ago that uses OS-level functions to lock mouse to a rectangular region, meaning that it cannot escape that no matter what. There's a demo included.

Other than that, lock the mouse to the middle of the window, compute relative coordinates, and draw your own fake cursor on them. I made a free extension for that a while ago (gets you "mouse_delta_x" and "mouse_delta_y" variables for ease of use).
This DLL is fantastic, everyone should know about this
 
Top