Пример #1
0
 private static Microsoft.Xna.Framework.Input.Buttons AddThumbstickButtons(
     short thumbX, short thumbY, short deadZone,
     Microsoft.Xna.Framework.Input.Buttons bitFieldToAddTo,
     Microsoft.Xna.Framework.Input.Buttons thumbstickLeft,
     Microsoft.Xna.Framework.Input.Buttons thumbStickRight,
     Microsoft.Xna.Framework.Input.Buttons thumbStickUp,
     Microsoft.Xna.Framework.Input.Buttons thumbStickDown)
 {
     // TODO: this needs adjustment. Very naive implementation. Doesn't match XNA yet
     if (thumbX < -deadZone)
     {
         bitFieldToAddTo = bitFieldToAddTo | thumbstickLeft;
     }
     if (thumbX > deadZone)
     {
         bitFieldToAddTo = bitFieldToAddTo | thumbStickRight;
     }
     if (thumbY < -deadZone)
     {
         bitFieldToAddTo = bitFieldToAddTo | thumbStickUp;
     }
     else if (thumbY > deadZone)
     {
         bitFieldToAddTo = bitFieldToAddTo | thumbStickDown;
     }
     return(bitFieldToAddTo);
 }
Пример #2
0
        public static Microsoft.Xna.Framework.Input.GamePadState ToXNAGamePadState(this SharpDX.DirectInput.JoystickState joyState)
        {
            Microsoft.Xna.Framework.Vector2       LeftStick = new Microsoft.Xna.Framework.Vector2((float)joyState.X / 45000, (float)joyState.Y);
            Microsoft.Xna.Framework.Input.Buttons buttons   = joyState.Buttons[0] ? Microsoft.Xna.Framework.Input.Buttons.A : 0;

            Microsoft.Xna.Framework.Input.GamePadState outputState = new Microsoft.Xna.Framework.Input.GamePadState(LeftStick, Microsoft.Xna.Framework.Vector2.Zero, 0, 0, buttons);
            return(outputState);
        }
Пример #3
0
 private static Microsoft.Xna.Framework.Input.Buttons AddButtonIfPressed(Microsoft.Xna.Framework.Input.Buttons originalButtonState,
                                                                         SharpDX.XInput.GamepadButtonFlags buttonFlags,
                                                                         SharpDX.XInput.GamepadButtonFlags xInputButton,
                                                                         Microsoft.Xna.Framework.Input.Buttons xnaButton)
 {
     Microsoft.Xna.Framework.Input.ButtonState buttonState = ConvertToButtonState(buttonFlags, xInputButton);
     return(buttonState == Microsoft.Xna.Framework.Input.ButtonState.Pressed ? originalButtonState | xnaButton : originalButtonState);
 }
Пример #4
0
        private static Microsoft.Xna.Framework.Input.GamePadButtons ConvertToButtons(SharpDX.XInput.GamepadButtonFlags buttonFlags,
                                                                                     short leftThumbX, short leftThumbY,
                                                                                     short rightThumbX, short rightThumbY,
                                                                                     byte leftTrigger,
                                                                                     byte rightTrigger)
        {
            var ret = new Microsoft.Xna.Framework.Input.Buttons();

            for (int i = 0; i < buttonMap.Count; i++)
            {
                var curMap = buttonMap[i];
                ret = AddButtonIfPressed(ret, buttonFlags, curMap.Item1, curMap.Item2);
            }

            ret = AddThumbstickButtons(leftThumbX, leftThumbY,
                                       SharpDX.XInput.Gamepad.LeftThumbDeadZone, ret,
                                       Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickLeft,
                                       Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickRight,
                                       Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickUp,
                                       Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickDown);

            ret = AddThumbstickButtons(rightThumbX, rightThumbY,
                                       SharpDX.XInput.Gamepad.RightThumbDeadZone, ret,
                                       Microsoft.Xna.Framework.Input.Buttons.RightThumbstickLeft,
                                       Microsoft.Xna.Framework.Input.Buttons.RightThumbstickRight,
                                       Microsoft.Xna.Framework.Input.Buttons.RightThumbstickUp,
                                       Microsoft.Xna.Framework.Input.Buttons.RightThumbstickDown);

            if (leftTrigger >= SharpDX.XInput.Gamepad.TriggerThreshold)
            {
                ret = ret | Microsoft.Xna.Framework.Input.Buttons.LeftTrigger;
            }

            if (rightTrigger >= SharpDX.XInput.Gamepad.TriggerThreshold)
            {
                ret = ret | Microsoft.Xna.Framework.Input.Buttons.RightTrigger;
            }

            var r = new Microsoft.Xna.Framework.Input.GamePadButtons(ret);

            return(r);
        }
Пример #5
0
        private static Microsoft.Xna.Framework.Input.GamePadButtons ConvertToButtons(SharpDX.XInput.GamepadButtonFlags buttonFlags,
            short leftThumbX, short leftThumbY,
            short rightThumbX, short rightThumbY,
            byte leftTrigger,
            byte rightTrigger)
        {
            Microsoft.Xna.Framework.Input.Buttons ret = new Microsoft.Xna.Framework.Input.Buttons();
            for (int i = 0; i < buttonMap.Count; i++)
            {
                var curMap = buttonMap[i];
                ret = AddButtonIfPressed(ret, buttonFlags, curMap.Item1, curMap.Item2);
            }

            ret = AddThumbstickButtons(leftThumbX, leftThumbY,
                SharpDX.XInput.Gamepad.LeftThumbDeadZone, ret,
                Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickLeft, 
                Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickRight, 
                Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickUp, 
                Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickDown);

            ret = AddThumbstickButtons(rightThumbX, rightThumbY,
                SharpDX.XInput.Gamepad.RightThumbDeadZone, ret,
                Microsoft.Xna.Framework.Input.Buttons.RightThumbstickLeft, 
                Microsoft.Xna.Framework.Input.Buttons.RightThumbstickRight, 
                Microsoft.Xna.Framework.Input.Buttons.RightThumbstickUp, 
                Microsoft.Xna.Framework.Input.Buttons.RightThumbstickDown);

            if (leftTrigger >= SharpDX.XInput.Gamepad.TriggerThreshold)
                ret = ret | Microsoft.Xna.Framework.Input.Buttons.LeftTrigger;

            if (rightTrigger >= SharpDX.XInput.Gamepad.TriggerThreshold)
                ret = ret | Microsoft.Xna.Framework.Input.Buttons.RightTrigger;

            var r = new Microsoft.Xna.Framework.Input.GamePadButtons(ret);
            return r;
        }
Пример #6
0
 public XInputEventHandler(Xna.Input.Buttons button, List<InputEvent> futureEvents)
     : base(futureEvents)
 {
     this.button = button;
 }
Пример #7
0
 public bool IsButtonUp(Microsoft.Xna.Framework.Input.Buttons button)
 {
     return(!this.IsButtonDown(button));
 }
Пример #8
0
 public bool IsButtonDown(Microsoft.Xna.Framework.Input.Buttons button)
 {
     return((_buttons & button) == button);
 }
Пример #9
0
 protected override void OnButtonReleased(Microsoft.Xna.Framework.Input.Buttons button)
 {
 }
Пример #10
0
 protected override bool OnButtonPressed(Microsoft.Xna.Framework.Input.Buttons button)
 {
     return(false);
 }
Пример #11
0
 public bool IsButtonUp(Microsoft.Xna.Framework.Input.Buttons button)
 {
     throw new System.NotImplementedException();
 }