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 mouse input breakage #11941

Merged
merged 3 commits into from Sep 2, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenRA.Game/Settings.cs
Expand Up @@ -171,7 +171,7 @@ public class GameSettings
public float ViewportEdgeScrollStep = 10f;
public float UIScrollSpeed = 50f;
public int SelectionDeadzone = 24;
public int JoystickScrollDeadzone = 8;
public int MouseScrollDeadzone = 8;

public bool UseClassicMouseStyle = false;
public StatusBarsType StatusBars = StatusBarsType.Standard;
Expand Down
13 changes: 9 additions & 4 deletions OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs
Expand Up @@ -35,6 +35,7 @@ public class ViewportControllerWidget : Widget
public int EdgeCornerScrollThreshold = 35;

int2? joystickScrollStart, joystickScrollEnd;
int2? standardScrollStart;
bool isStandardScrolling;

static readonly Dictionary<ScrollDirection, string> ScrollCursors = new Dictionary<ScrollDirection, string>
Expand Down Expand Up @@ -209,7 +210,7 @@ public void UpdateMouseover()

public override string GetCursor(int2 pos)
{
if (!IsJoystickScrolling &&
if (!(IsJoystickScrolling || isStandardScrolling) &&
(!Game.Settings.Game.ViewportEdgeScroll || Ui.MouseOverWidget != this))
return null;

Expand All @@ -235,7 +236,7 @@ bool IsJoystickScrolling
get
{
return joystickScrollStart.HasValue && joystickScrollEnd.HasValue &&
(joystickScrollStart.Value - joystickScrollEnd.Value).Length > Game.Settings.Game.JoystickScrollDeadzone;
(joystickScrollStart.Value - joystickScrollEnd.Value).Length > Game.Settings.Game.MouseScrollDeadzone;
}
}

Expand Down Expand Up @@ -286,7 +287,10 @@ public override bool HandleMouseInput(MouseInput mi)

if (scrollType == MouseScrollType.Standard || scrollType == MouseScrollType.Inverted)
{
if (mi.Event == MouseInputEvent.Move)
if (mi.Event == MouseInputEvent.Down && !isStandardScrolling)
standardScrollStart = mi.Location;
else if (mi.Event == MouseInputEvent.Move && (isStandardScrolling ||
(standardScrollStart.HasValue && ((standardScrollStart.Value - mi.Location).Length > Game.Settings.Game.MouseScrollDeadzone))))
{
isStandardScrolling = true;
var d = scrollType == MouseScrollType.Inverted ? -1 : 1;
Expand All @@ -297,6 +301,7 @@ public override bool HandleMouseInput(MouseInput mi)
{
var wasStandardScrolling = isStandardScrolling;
isStandardScrolling = false;
standardScrollStart = null;

if (wasStandardScrolling)
return true;
Expand All @@ -315,7 +320,7 @@ public override bool HandleMouseInput(MouseInput mi)

if (mi.Event == MouseInputEvent.Up)
{
var wasJoystickScrolling = joystickScrollStart.HasValue && joystickScrollEnd.HasValue;
var wasJoystickScrolling = IsJoystickScrolling;

joystickScrollStart = joystickScrollEnd = null;
YieldMouseFocus(mi);
Expand Down