Right now, if you move the mouse cursor outside the game engine window it no longer gives feedback about its position.
This happens whether using bge.logic.mouse.position or mouse_sensor.position (though they both return different results, one gives a 0.0-1.0 float, the other returns an integer).
I’d much rather that in future it could be changed so that mouse position is returned as the position “on the desktop”, perhaps modified to take in to account the position of the active game window, so that if it is outside the window it can return 1.5000 or negative values such as -0.4566.
Why is this a problem?
I often have to get the position of the mouse (for adding a custom cursor object, or in a custom mouse-over script or moving the camera based on mouse position etc…), once it gets near the edge of the window there’s a chance of losing feedback. It won’t cut off at 0.0000 or 1.00000 but at whatever the reading was on the last logic tic before it went outside. Sometimes if the mouse is moving fast that can be 5 or 10 percent of the screen (today I got a reading of 0.125000, or 12% of the screen size!) which is a big deal if you want to check when the cursor is at the edge of the screen. This even happens in full screen mode, so that the cursor is obviously at the edge of the screen, but it’s no longer giving a new reading. Blender thinks it’s outside the screen area.
I checked bge.logic.mouse.active_events and it seems that MOUSEX and MOUSEY are not active when the mouse is outside the game window.
There are ways around this, for example most mouse look scripts work by setting the mouse at the center of the screen each run of the code. I found I could keep the mouse inside the area in my code by using:
To set the mouse cursor to where blender thinks it is (back inside the window), rather than where it actually is. But this gives an uncomfortable result, you have to keep jamming the mouse hard against the edge, instead of just placing it there.
So… if anyone is working on the core BGE code and feels like they’d like to change the way mouse position is handled, I’d be grateful. There are work-arounds, but they are not ideal and honestly there’s got to be a better way of handling mouse position input. (Unless there is some special reason Blender can’t get the mouse position if the mouse is outside Blender’s window…)