Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed cursor warping when sending chat messages #2655

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Intersect.Client.Core/MonoGame/Input/MonoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ namespace Intersect.Client.MonoGame.Input;
public partial class MonoInput : GameInput
{
private readonly Dictionary<Keys, MonoGameKeys> _intersectToMonoGameKeyMap;

public override InputDeviceType CursorMovementDevice { get; set; } = InputDeviceType.Mouse;

private GamePadState _currentGamePadState;
private GamePadState _previousGamePadState;

Expand Down Expand Up @@ -146,6 +147,12 @@ private void InputHandlerOnFocusChanged(Base? control, FocusSource focusSource)
return;
}

switch (CursorMovementDevice)
{
case InputDeviceType.Mouse:
return;
}

Vector2 center = new(
(control.GlobalBounds.Left + control.GlobalBounds.Right) / 2f,
(control.GlobalBounds.Bottom + control.GlobalBounds.Top) / 2f
Expand Down Expand Up @@ -311,6 +318,11 @@ public override void Update(TimeSpan elapsed)
var deltaX = (int)(gamePadState.ThumbSticks.Right.X * elapsed.TotalSeconds * 1000);
var deltaY = (int)(-gamePadState.ThumbSticks.Right.Y * elapsed.TotalSeconds * 1000);

if (deltaX != 0 || deltaY != 0)
{
CursorMovementDevice = InputDeviceType.Controller;
}

var temporaryMouseState = Mouse.GetState();
Mouse.SetPosition(temporaryMouseState.X + deltaX, temporaryMouseState.Y + deltaY);
}
Expand All @@ -322,6 +334,9 @@ public override void Update(TimeSpan elapsed)
{
mMouseX = (int)(mouseState.X * ((MonoRenderer)Core.Graphics.Renderer).GetMouseOffset().X);
mMouseY = (int)(mouseState.Y * ((MonoRenderer)Core.Graphics.Renderer).GetMouseOffset().Y);

CursorMovementDevice = InputDeviceType.Mouse;

Interface.Interface.GwenInput.ProcessMessage(
new GwenInputMessage(
IntersectInput.InputEvent.MouseMove, GetMousePosition(), MouseButton.None, Keys.Alt
Expand Down
4 changes: 3 additions & 1 deletion Intersect.Client.Framework/Input/GameInput.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Immutable;
using System.Collections.Immutable;
using System.Numerics;
using Intersect.Client.Framework.GenericClasses;
using Intersect.Core;
Expand Down Expand Up @@ -117,6 +117,8 @@ public bool RemoveControlsProviders(params IControlsProvider[] controlsProviders

public abstract bool WasKeyDown(Keys key);

public abstract InputDeviceType CursorMovementDevice { get; set; }

public Vector2 MousePosition => GetMousePosition();

public abstract Vector2 GetMousePosition();
Expand Down
7 changes: 7 additions & 0 deletions Intersect.Client.Framework/Input/InputDeviceType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Intersect.Client.Framework.Input;

public enum InputDeviceType
{
Mouse,
Controller
}
Loading