GameMaker 'display_mouse_set' not working?

Hi all,

My understanding of 'display_mouse_set(x,y)' is that it will force the mouse cursor to that point whenever it's called. Currently, I'm trying to figure out 3D projection in a shader, and am getting caught up by the fact that running this code in the step event:
Code:
display_mouse_set(display_get_width()/2, display_get_height()/2);
doesn't appear to do anything to the cursor.

Am I missing something here? Is there a function to allow cursor override, or something?

EDIT: I've discovered there's also 'window_mouse_set'... Is this any different? The docs don't really specify. The effect of both does nothing to my cursor.

Thanks in advance!
 

johnwo

Member
display_mouse_set(x,y); sets the mouse to a x,y coordinate in regard to the display itself. This means that:
Code:
display_mouse_set(display_get_width()/2, display_get_height()/2);
would set the mouse to the middle of the screen, regardless if the game is fullscreen or windowed.

window_mouse_set(x,y); sets the mouse to a x,y coordinate within the game window.
It's useful, for example, in case you're making a FPS game where running in windowed mode is needed.
Consider the following code:
Code:
window_mouse_set(window_get_width()/2, window_get_height()/2);
Using display_mouse_set(x,y); the code above is (sorta) equivalent to:
Code:
display_mouse_set(window_get_x()+window_get_width()/2,window_get_y()+window_get_height()/2);

As to why display_mouse_set isn't working for you, I've got no good answer.
Function is working as intended on my end, so more info (context of code) is needed.
 
window_mouse_set(x,y); sets the mouse to a x,y coordinate within the game window.
Ah, I see thanks!

As to why display_mouse_set isn't working for you, I've got no good answer.
Function is working as intended on my end, so more info (context of code) is needed.
All right. New project, 1 room 1 object.
Environment:
IDE: v2.2.3.436
Runtime: v2.2.3.344
Output: VM

Room:
Width: 1024
Height: 768
No settings touched. No views, etc.

Object:
Code:
STEP EVENT
window_mouse_set(window_get_width()/2, window_get_height()/2);
show_debug_message(mouse_x);
Result is 512, as expected. Problem is, the mouse cursor doesn't stay bound to the window at all. Should it?

Running Windows 10, VM within Ubuntu. Possible that VMWare is preventing mouse override?
 

johnwo

Member
Running Windows 10, VM within Ubuntu. Possible that VMWare is preventing mouse override?
As long as the guest OS has focus, i.e. is capturing mouse exclusively, I assume it shouldn't be an issue, abeit I'm not sure.
Runs fine and as expected on native windows 10, so I would assume that something is amiss.

Have you tried building the project for Linux and running it in the host OS just to check if that works?
If it works, then it would pretty much confirm that the virtualization software is interfering with something in regard to the cursor.
 

TheouAegis

Member
Also, it won't lock the mouse, either. The user can still move the mouse outside the window if quick enough. But yeah, sounds like a VM issue here. The function has always worked for me (aside from said speedy-clicky bug).
 
Top