add support for X1 and X2 buttons
parent
fa992652b1
commit
f71e2feb62
|
@ -8,6 +8,8 @@ namespace MoonWorks.Input
|
||||||
public MouseButton LeftButton { get; }
|
public MouseButton LeftButton { get; }
|
||||||
public MouseButton MiddleButton { get; }
|
public MouseButton MiddleButton { get; }
|
||||||
public MouseButton RightButton { get; }
|
public MouseButton RightButton { get; }
|
||||||
|
public MouseButton X1Button { get; }
|
||||||
|
public MouseButton X2Button { get; }
|
||||||
|
|
||||||
public int X { get; private set; }
|
public int X { get; private set; }
|
||||||
public int Y { get; private set; }
|
public int Y { get; private set; }
|
||||||
|
@ -41,27 +43,23 @@ namespace MoonWorks.Input
|
||||||
|
|
||||||
private readonly Dictionary<MouseButtonCode, MouseButton> CodeToButton;
|
private readonly Dictionary<MouseButtonCode, MouseButton> CodeToButton;
|
||||||
|
|
||||||
private IEnumerable<MouseButton> Buttons
|
private IEnumerable<MouseButton> Buttons => CodeToButton.Values;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
yield return LeftButton;
|
|
||||||
yield return MiddleButton;
|
|
||||||
yield return RightButton;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Mouse()
|
public Mouse()
|
||||||
{
|
{
|
||||||
LeftButton = new MouseButton(this, MouseButtonCode.Left, SDL.SDL_BUTTON_LMASK);
|
LeftButton = new MouseButton(this, MouseButtonCode.Left, SDL.SDL_BUTTON_LMASK);
|
||||||
MiddleButton = new MouseButton(this, MouseButtonCode.Middle, SDL.SDL_BUTTON_MMASK);
|
MiddleButton = new MouseButton(this, MouseButtonCode.Middle, SDL.SDL_BUTTON_MMASK);
|
||||||
RightButton = new MouseButton(this, MouseButtonCode.Right, SDL.SDL_BUTTON_RMASK);
|
RightButton = new MouseButton(this, MouseButtonCode.Right, SDL.SDL_BUTTON_RMASK);
|
||||||
|
X1Button = new MouseButton(this, MouseButtonCode.X1, SDL.SDL_BUTTON_X1MASK);
|
||||||
|
X2Button = new MouseButton(this, MouseButtonCode.X2, SDL.SDL_BUTTON_X2MASK);
|
||||||
|
|
||||||
CodeToButton = new Dictionary<MouseButtonCode, MouseButton>
|
CodeToButton = new Dictionary<MouseButtonCode, MouseButton>
|
||||||
{
|
{
|
||||||
{ MouseButtonCode.Left, LeftButton },
|
{ MouseButtonCode.Left, LeftButton },
|
||||||
{ MouseButtonCode.Right, RightButton },
|
{ MouseButtonCode.Right, RightButton },
|
||||||
{ MouseButtonCode.Middle, MiddleButton }
|
{ MouseButtonCode.Middle, MiddleButton },
|
||||||
|
{ MouseButtonCode.X1, X1Button },
|
||||||
|
{ MouseButtonCode.X2, X2Button }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,12 +78,10 @@ namespace MoonWorks.Input
|
||||||
Wheel = WheelRaw - previousWheelRaw;
|
Wheel = WheelRaw - previousWheelRaw;
|
||||||
previousWheelRaw = WheelRaw;
|
previousWheelRaw = WheelRaw;
|
||||||
|
|
||||||
LeftButton.Update();
|
|
||||||
MiddleButton.Update();
|
|
||||||
RightButton.Update();
|
|
||||||
|
|
||||||
foreach (var button in Buttons)
|
foreach (var button in Buttons)
|
||||||
{
|
{
|
||||||
|
button.Update();
|
||||||
|
|
||||||
if (button.IsPressed)
|
if (button.IsPressed)
|
||||||
{
|
{
|
||||||
AnyPressed = true;
|
AnyPressed = true;
|
||||||
|
|
|
@ -4,6 +4,8 @@ namespace MoonWorks.Input
|
||||||
{
|
{
|
||||||
Left,
|
Left,
|
||||||
Right,
|
Right,
|
||||||
Middle
|
Middle,
|
||||||
|
X1,
|
||||||
|
X2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue