2019-09-04 18:49:59 +02:00
|
|
|
using System;
|
2019-09-04 21:10:51 +02:00
|
|
|
using System.Linq;
|
2019-09-04 18:49:59 +02:00
|
|
|
using Microsoft.Xna.Framework.Input;
|
2019-09-04 21:10:51 +02:00
|
|
|
using MLEM.Misc;
|
2019-09-04 18:49:59 +02:00
|
|
|
|
|
|
|
namespace MLEM.Input {
|
|
|
|
public static class MouseExtensions {
|
|
|
|
|
2019-09-04 21:10:51 +02:00
|
|
|
public static readonly MouseButton[] MouseButtons = EnumHelper.GetValues<MouseButton>().ToArray();
|
|
|
|
|
2019-09-04 18:49:59 +02:00
|
|
|
public static ButtonState GetState(this MouseState state, MouseButton button) {
|
|
|
|
switch (button) {
|
|
|
|
case MouseButton.Left:
|
|
|
|
return state.LeftButton;
|
|
|
|
case MouseButton.Middle:
|
|
|
|
return state.MiddleButton;
|
|
|
|
case MouseButton.Right:
|
|
|
|
return state.RightButton;
|
|
|
|
case MouseButton.Extra1:
|
|
|
|
return state.XButton1;
|
|
|
|
case MouseButton.Extra2:
|
|
|
|
return state.XButton2;
|
|
|
|
default:
|
|
|
|
throw new ArgumentException(nameof(button));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum MouseButton {
|
|
|
|
|
|
|
|
Left,
|
|
|
|
Middle,
|
|
|
|
Right,
|
|
|
|
Extra1,
|
|
|
|
Extra2
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|