Skip to content

Commit 30c18aa

Browse files
authored
fix: Fixed cursor warping when sending chat messages (AscensionGameDev#2655)
* Fixed cursor warping Signed-off-by: Timothy Green <[email protected]> * panda review --------- Signed-off-by: Timothy Green <[email protected]>
1 parent 88d1f80 commit 30c18aa

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

Intersect.Client.Core/MonoGame/Input/MonoInput.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ namespace Intersect.Client.MonoGame.Input;
2121
public partial class MonoInput : GameInput
2222
{
2323
private readonly Dictionary<Keys, MonoGameKeys> _intersectToMonoGameKeyMap;
24-
24+
public override InputDeviceType CursorMovementDevice { get; set; } = InputDeviceType.Mouse;
25+
2526
private GamePadState _currentGamePadState;
2627
private GamePadState _previousGamePadState;
2728

@@ -146,6 +147,12 @@ private void InputHandlerOnFocusChanged(Base? control, FocusSource focusSource)
146147
return;
147148
}
148149

150+
switch (CursorMovementDevice)
151+
{
152+
case InputDeviceType.Mouse:
153+
return;
154+
}
155+
149156
Vector2 center = new(
150157
(control.GlobalBounds.Left + control.GlobalBounds.Right) / 2f,
151158
(control.GlobalBounds.Bottom + control.GlobalBounds.Top) / 2f
@@ -311,6 +318,11 @@ public override void Update(TimeSpan elapsed)
311318
var deltaX = (int)(gamePadState.ThumbSticks.Right.X * elapsed.TotalSeconds * 1000);
312319
var deltaY = (int)(-gamePadState.ThumbSticks.Right.Y * elapsed.TotalSeconds * 1000);
313320

321+
if (deltaX != 0 || deltaY != 0)
322+
{
323+
CursorMovementDevice = InputDeviceType.Controller;
324+
}
325+
314326
var temporaryMouseState = Mouse.GetState();
315327
Mouse.SetPosition(temporaryMouseState.X + deltaX, temporaryMouseState.Y + deltaY);
316328
}
@@ -322,6 +334,9 @@ public override void Update(TimeSpan elapsed)
322334
{
323335
mMouseX = (int)(mouseState.X * ((MonoRenderer)Core.Graphics.Renderer).GetMouseOffset().X);
324336
mMouseY = (int)(mouseState.Y * ((MonoRenderer)Core.Graphics.Renderer).GetMouseOffset().Y);
337+
338+
CursorMovementDevice = InputDeviceType.Mouse;
339+
325340
Interface.Interface.GwenInput.ProcessMessage(
326341
new GwenInputMessage(
327342
IntersectInput.InputEvent.MouseMove, GetMousePosition(), MouseButton.None, Keys.Alt

Intersect.Client.Framework/Input/GameInput.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Immutable;
1+
using System.Collections.Immutable;
22
using System.Numerics;
33
using Intersect.Client.Framework.GenericClasses;
44
using Intersect.Core;
@@ -117,6 +117,8 @@ public bool RemoveControlsProviders(params IControlsProvider[] controlsProviders
117117

118118
public abstract bool WasKeyDown(Keys key);
119119

120+
public abstract InputDeviceType CursorMovementDevice { get; set; }
121+
120122
public Vector2 MousePosition => GetMousePosition();
121123

122124
public abstract Vector2 GetMousePosition();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Intersect.Client.Framework.Input;
2+
3+
public enum InputDeviceType
4+
{
5+
Mouse,
6+
Controller
7+
}

0 commit comments

Comments
 (0)