Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public static bool IsDown(string id, GamepadData data = null, bool ignoreBlock = false)
 {
     return(Check(id, CheckType.DOWN, data, ignoreBlock));
 }
Exemplo n.º 5
0
 public static bool WasReleased(string id, GamepadData data = null, bool ignoreBlock = false)
 {
     return(Check(id, CheckType.RELEASED, data, ignoreBlock));
 }
Exemplo n.º 6
0
 public static bool WasPressed(string id, GamepadData data = null, bool ignoreBlock = false)
 {
     return(Check(id, CheckType.PRESSED, data, ignoreBlock));
 }