Lock mouse position
This commit is contained in:
@@ -30,6 +30,7 @@ namespace OpenRA.Platforms.Default
|
||||
Size windowSize;
|
||||
Size surfaceSize;
|
||||
float windowScale;
|
||||
int2 mousePosition;
|
||||
|
||||
internal IntPtr Window
|
||||
{
|
||||
@@ -276,6 +277,22 @@ namespace OpenRA.Platforms.Default
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRelativeMouseMode(bool mode)
|
||||
{
|
||||
if (mode)
|
||||
{
|
||||
int x, y;
|
||||
SDL.SDL_GetMouseState(out x, out y);
|
||||
mousePosition = new int2(x, y);
|
||||
SDL.SDL_SetRelativeMouseMode(SDL.SDL_bool.SDL_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL.SDL_SetRelativeMouseMode(SDL.SDL_bool.SDL_FALSE);
|
||||
SDL.SDL_WarpMouseInWindow(window, mousePosition.X, mousePosition.Y);
|
||||
}
|
||||
}
|
||||
|
||||
internal void WindowSizeChanged()
|
||||
{
|
||||
// The ratio between pixels and points can change when moving between displays in OSX
|
||||
|
||||
Reference in New Issue
Block a user