• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Recent runtimes break mouse_x/y

Cpaz

Member
For some reason, as of the December runtimes, the in room coordinates for the mouse seem to be very inconsistent.
I remember when I first found this, I reverted back to the previous runtime from October, and the issue wasn't there.
Here are some photo examples as to what I mean:

Note that my cursor is split into a sprite drawn on the GUI layer, which works as expected, and an effect that works in the room itself.
October/prior runtime:

December/current runtime:


I just want to know If anyone else has been experiencing this, or If something on my end is screwy.
Thanks in advance.
 
C

CombatCalamity

Guest
Don't worry, you're not doing anything wrong. There is a change to how GM handles view/display port. Just adapt your game and you'll be fine.
 

Cpaz

Member
Don't worry, you're not doing anything wrong. There is a change to how GM handles view/display port. Just adapt your game and you'll be fine.
Oh, interesting. Are these changes documented anywhere in detail? I wasn't able to find anything in the change logs.
 
There was a blog post about this, but it was back in August 2018 which is earlier than you said they stopped working.

https://www.yoyogames.com/blog/480/gui-layer-secrets

What are you room / view / port settings, and how are you handling your cameras / scaling of your game.

What are you scaling settings in Graphics options.Your GUI resolution seems different to your game resolution, or the way you calculate between GUI and game resolution is affecting it.
 

Cpaz

Member
There was a blog post about this, but it was back in August 2018 which is earlier than you said they stopped working.

https://www.yoyogames.com/blog/480/gui-layer-secrets

What are you room / view / port settings, and how are you handling your cameras / scaling of your game.

What are you scaling settings in Graphics options.Your GUI resolution seems different to your game resolution, or the way you calculate between GUI and game resolution is affecting it.
The GUI layer is actually working fine. It's the literal coordinates of mouse_x and mouse_y. They're just wrong, not aligned with the actual position of the mouse. They seem to treat the player as the origin (or I guess the top left corner of the screen) if that makes any sense.

I should note that I'm using old views imported from GMS1.

But in general, my view is as follows:
view width: 400
view height: 300

view port width: 800
view port height: 600

view border w/h: 1000

It also follows a camera object which is placed somewhere in between the player and cursor.
 
By default, your GUI size will be the size of your view port.

If your view width is only 400,300, mouse_x and mouse_y when the mouse is in the bottom right, in the Draw Event will be bottom right corner of the screen, but if you use mouse_x and mouse_y in the GUI layer, it will draw in the middle of the screen.

So what code are you using to draw the effects on the GUI layer, are you using mouse_x and mouse_y , or are you converting it to match the GUI layer size, please post your code.
 

Cpaz

Member
By default, your GUI size will be the size of your view port.

If your view width is only 400,300, mouse_x and mouse_y when the mouse is in the bottom right, in the Draw Event will be bottom right corner of the screen, but if you use mouse_x and mouse_y in the GUI layer, it will draw in the middle of the screen.

So what code are you using to draw the effects on the GUI layer, are you using mouse_x and mouse_y , or are you converting it to match the GUI layer size, please post your code.
I'm posting a plain image on the gui layer for accuracy.
The trail effect is it's own object that's being created every so many steps on a normal draw layer, not the gui layer.

Here's the general nonsense for the draw GUI event:
[The long if statements are basically if the player is a certain character]
Code:
var mx=device_mouse_x_to_gui(0);
var my=device_mouse_y_to_gui(0);

if !global.pause&&!global.cutscene&&!controller.ded&&controller.start{
    if (global.in!=obj_vis_ketsu)||(instance_exists(obj_vis_ketsu)&&!obj_vis_ketsu.ar){
        if (!global.gp)&&!((global.in=obj_vis_sal||global.in=obj_vis_maav||global.in=obj_vis_levi||global.in=obj_vis_vendor||global.in=obj_vis_manager)&&global.in.bulcharge){
            if alarm[0]=-1
                alarm[0]=1*delta;
            draw_sprite(ms,0,mx,my);
            image_index=0;
            image_speed=0;
        }
        if (global.in=obj_vis_sal||global.in=obj_vis_maav||global.in=obj_vis_levi||global.in=obj_vis_vendor||global.in=obj_vis_manager)&&global.in.bulcharge{
            draw_sprite(ms,image_index,mx,my);
            image_speed=0.5/delta;
        }
    }
}

if global.cutscene&&!global.gp||(!controller.title&&!controller.start)||controller.ded
    draw_sprite(spr_mencur,0,mx,my);
This part works as expected. It's the trail effect where things get weird.

The alarm 0 event is where the effect is being created (not the most efficient I know, but it works for now).
Code:
instance_create(obj_player.xx,obj_player.yy,mouse_fx);
obj_player.xx/yy is basically just a pass through of either the gamepad coordinates (which work normally btw) or mouse_x/y depending on which input has been detected last.
So basically:
Code:
if (!global.gp){
   ...
   xx=mouse_x;
   yy=mouse_y;
   ...
}
EDIT: It seems I've found the exact numbers in which the mouse position is off by. Exactly half the display gui (display_get_gui_width/height).
After a little bit of digging, I found that I set the gui size like so:
Code:
display_set_gui_size(__view_get( e__VW.WView, 0 ),__view_get( e__VW.HView, 0 ));
The weird thing is, those would return 400 and 300 respective, syncing up the GUI with the size of everything drawn on screen. Removing the above line sort of fixes the problem, but then everything drawn on the GUI (which is a fair bit) is half the size.

I guess I can live with simply manually modifying the mouse coordinates, but the fact that this affects the mouse position at all is very odd to me. There's also the fact that this may not be consistent across devices with different resolutions.
 
Last edited:
Top