Exemplo n.º 1
0
        public static Control?GetAnyPressedKey(DeviceState state)
        {
            Control control = new Control();

            //Scan Keyboard
            foreach (Keys key in Enum.GetValues(typeof(Keys)))
            {
                if (state.keyboard.IsKeyDown(key))
                {
                    control.key = key;
                    return(control);
                }
            }
            //Scan gamepad
            foreach (Buttons btn in Enum.GetValues(typeof(Buttons)))
            {
                if (state.gamepad.IsButtonDown(btn))
                {
                    control.button = btn;
                    return(control);
                }
            }
            //Scan mouse
            foreach (MouseButton mbtn in Enum.GetValues(typeof(MouseButton)))
            {
                if (MouseHelper.ButtonClicked(state.mouse, mbtn))
                {
                    control.mouse = mbtn;
                    return(control);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
 public bool IsControlUp(DeviceState state)
 {
     return((key != null && state.keyboard.IsKeyUp(key.GetValueOrDefault())) ||
            (button != null && state.gamepad.IsButtonUp(button.GetValueOrDefault())) ||
            (mouse != null && !MouseHelper.ButtonClicked(state.mouse, mouse.GetValueOrDefault())));
 }