Relative mouse pos
This commit is contained in:
@@ -138,16 +138,14 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (cursor == null)
|
if (cursor != null && frame >= cursor.Length)
|
||||||
|
frame %= cursor.Length;
|
||||||
|
|
||||||
|
if (cursor == null || isLocked)
|
||||||
Game.Renderer.Window.SetHardwareCursor(null);
|
Game.Renderer.Window.SetHardwareCursor(null);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if (frame >= cursor.Length)
|
|
||||||
frame = frame % cursor.Length;
|
|
||||||
|
|
||||||
Game.Renderer.Window.SetHardwareCursor(hardwareCursors[cursor.Name][frame]);
|
Game.Renderer.Window.SetHardwareCursor(hardwareCursors[cursor.Name][frame]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Render(Renderer renderer)
|
public void Render(Renderer renderer)
|
||||||
{
|
{
|
||||||
@@ -171,12 +169,14 @@ namespace OpenRA.Graphics
|
|||||||
lockedPosition = Viewport.LastMousePos;
|
lockedPosition = Viewport.LastMousePos;
|
||||||
Game.Renderer.Window.SetRelativeMouseMode(true);
|
Game.Renderer.Window.SetRelativeMouseMode(true);
|
||||||
isLocked = true;
|
isLocked = true;
|
||||||
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unlock()
|
public void Unlock()
|
||||||
{
|
{
|
||||||
Game.Renderer.Window.SetRelativeMouseMode(false);
|
Game.Renderer.Window.SetRelativeMouseMode(false);
|
||||||
isLocked = false;
|
isLocked = false;
|
||||||
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|||||||
@@ -130,9 +130,14 @@ namespace OpenRA.Platforms.Default
|
|||||||
|
|
||||||
case SDL.SDL_EventType.SDL_MOUSEMOTION:
|
case SDL.SDL_EventType.SDL_MOUSEMOTION:
|
||||||
{
|
{
|
||||||
var input = lockedMousePosition ?? new int2(e.motion.x, e.motion.y);
|
var mousePos = new int2(e.motion.x, e.motion.y);
|
||||||
|
var input = lockedMousePosition ?? mousePos;
|
||||||
var pos = EventPosition(device, input.X, input.Y);
|
var pos = EventPosition(device, input.X, input.Y);
|
||||||
var delta = EventPosition(device, e.motion.xrel, e.motion.yrel);
|
|
||||||
|
var delta = lockedMousePosition == null
|
||||||
|
? EventPosition(device, e.motion.xrel, e.motion.yrel)
|
||||||
|
: mousePos - lockedMousePosition.Value;
|
||||||
|
|
||||||
pendingMotion = new MouseInput(
|
pendingMotion = new MouseInput(
|
||||||
MouseInputEvent.Move, lastButtonBits, pos, delta, mods, 0);
|
MouseInputEvent.Move, lastButtonBits, pos, delta, mods, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -284,11 +284,9 @@ namespace OpenRA.Platforms.Default
|
|||||||
int x, y;
|
int x, y;
|
||||||
SDL.SDL_GetMouseState(out x, out y);
|
SDL.SDL_GetMouseState(out x, out y);
|
||||||
lockedMousePosition = new int2(x, y);
|
lockedMousePosition = new int2(x, y);
|
||||||
SDL.SDL_SetRelativeMouseMode(SDL.SDL_bool.SDL_TRUE);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL.SDL_SetRelativeMouseMode(SDL.SDL_bool.SDL_FALSE);
|
|
||||||
if (lockedMousePosition.HasValue)
|
if (lockedMousePosition.HasValue)
|
||||||
SDL.SDL_WarpMouseInWindow(window, lockedMousePosition.Value.X, lockedMousePosition.Value.Y);
|
SDL.SDL_WarpMouseInWindow(window, lockedMousePosition.Value.X, lockedMousePosition.Value.Y);
|
||||||
|
|
||||||
@@ -352,6 +350,9 @@ namespace OpenRA.Platforms.Default
|
|||||||
{
|
{
|
||||||
VerifyThreadAffinity();
|
VerifyThreadAffinity();
|
||||||
input.PumpInput(this, inputHandler, lockedMousePosition);
|
input.PumpInput(this, inputHandler, lockedMousePosition);
|
||||||
|
|
||||||
|
if (lockedMousePosition.HasValue)
|
||||||
|
SDL.SDL_WarpMouseInWindow(window, lockedMousePosition.Value.X, lockedMousePosition.Value.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetClipboardText()
|
public string GetClipboardText()
|
||||||
|
|||||||
Reference in New Issue
Block a user