public static void Init() { Keyboard = new KeyboardData(); Mouse = new MouseData(); Gamepads = new GamepadData[4]; for (int i = 0; i < Gamepads.Length; i++) { Gamepads[i] = new GamepadData((PlayerIndex)i); } }
private static bool Check(string id, CheckType type, GamepadData data = null, bool ignoreBlock = false) { if (Blocked > 0 && !ignoreBlock) { return(false); } if (!Buttons.TryGetValue(id, out var button)) { return(false); } if (button.Keys != null) { foreach (var key in button.Keys) { if (Keyboard.Check(key, type)) { return(true); } } } if (data != null && data.Attached && button.Buttons != null) { foreach (var b in button.Buttons) { if (data.Check(b, type)) { return(true); } } } if (button.MouseButtons != null) { foreach (var b in button.MouseButtons) { if (Mouse.Check(b, type)) { return(true); } } } return(false); }
public static bool IsDownOnController(string id, GamepadData data) { if (!Buttons.TryGetValue(id, out var button)) { return(false); } if (data != null && data.Attached && button.Buttons != null) { foreach (var b in button.Buttons) { if (data.IsDown(b)) { return(true); } } } return(false); }
public static bool IsDown(string id, GamepadData data = null, bool ignoreBlock = false) { return(Check(id, CheckType.DOWN, data, ignoreBlock)); }
public static bool WasReleased(string id, GamepadData data = null, bool ignoreBlock = false) { return(Check(id, CheckType.RELEASED, data, ignoreBlock)); }
public static bool WasPressed(string id, GamepadData data = null, bool ignoreBlock = false) { return(Check(id, CheckType.PRESSED, data, ignoreBlock)); }