Skip to content

Commit

Permalink
resolve: (Day) 1865 - Resolves issue where mice XButtons weren't full…
Browse files Browse the repository at this point in the history
…y implemented (#1866)
  • Loading branch information
AlexVild authored Aug 14, 2023
1 parent 376ba3c commit 2df78e1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Intersect.Client.Framework/Input/MouseButtons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ public enum MouseButtons

Right,

Middle
Middle,

X1,

X2

}
}
20 changes: 19 additions & 1 deletion Intersect.Client/Core/Controls/ControlValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ public partial class ControlValue

public Keys Key { get; set; }

public bool IsMouseKey => Key == Keys.LButton || Key == Keys.RButton || Key == Keys.MButton;
public bool IsMouseKey => Key == Keys.LButton
|| Key == Keys.RButton
|| Key == Keys.MButton
|| Key == Keys.XButton1
|| Key == Keys.XButton2;

[JsonConstructor]
public ControlValue(Keys modifier, Keys key)
Expand Down Expand Up @@ -66,6 +70,20 @@ public bool IsDown()
return true;
}

break;
case Keys.XButton1:
if (Globals.InputManager.MouseButtonDown(MouseButtons.X1))
{
return true;
}

break;
case Keys.XButton2:
if (Globals.InputManager.MouseButtonDown(MouseButtons.X2))
{
return true;
}

break;
}
}
Expand Down
16 changes: 16 additions & 0 deletions Intersect.Client/Core/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ public static void OnMouseDown(Keys modifier, MouseButtons btn)
case MouseButtons.Middle:
key = Keys.MButton;

break;
case MouseButtons.X1:
key = Keys.XButton1;

break;
case MouseButtons.X2:
key = Keys.XButton2;

break;
}

Expand Down Expand Up @@ -375,6 +383,14 @@ public static void OnMouseUp(Keys modifier, MouseButtons btn)
case MouseButtons.Middle:
key = Keys.MButton;

break;
case MouseButtons.X1:
key = Keys.XButton1;

break;
case MouseButtons.X2:
key = Keys.XButton2;

break;
}

Expand Down
8 changes: 8 additions & 0 deletions Intersect.Client/MonoGame/Input/MonoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public override bool MouseButtonDown(MouseButtons mb)
return mLastMouseState.RightButton == ButtonState.Pressed;
case MouseButtons.Middle:
return mLastMouseState.MiddleButton == ButtonState.Pressed;
case MouseButtons.X1:
return mLastMouseState.XButton1 == ButtonState.Pressed;
case MouseButtons.X2:
return mLastMouseState.XButton2 == ButtonState.Pressed;
default:
throw new ArgumentOutOfRangeException(nameof(mb), mb, null);
}
Expand Down Expand Up @@ -206,6 +210,8 @@ public override void Update()
CheckMouseButton(modifier, state.LeftButton, MouseButtons.Left);
CheckMouseButton(modifier, state.RightButton, MouseButtons.Right);
CheckMouseButton(modifier, state.MiddleButton, MouseButtons.Middle);
CheckMouseButton(modifier, state.XButton1, MouseButtons.X1);
CheckMouseButton(modifier, state.XButton2, MouseButtons.X2);

CheckMouseScrollWheel(state.ScrollWheelValue, state.HorizontalScrollWheelValue);

Expand Down Expand Up @@ -258,6 +264,8 @@ public override void Update()
CheckMouseButton(modifier, ButtonState.Released, MouseButtons.Left);
CheckMouseButton(modifier, ButtonState.Released, MouseButtons.Right);
CheckMouseButton(modifier, ButtonState.Released, MouseButtons.Middle);
CheckMouseButton(modifier, ButtonState.Released, MouseButtons.X1);
CheckMouseButton(modifier, ButtonState.Released, MouseButtons.X2);
mLastKeyboardState = new KeyboardState();
mLastMouseState = new MouseState();
}
Expand Down

0 comments on commit 2df78e1

Please sign in to comment.