Exemplo n.º 1
0
        void ControllerAxisChanged(ControllerJoystick joystick, ControllerJoystickAxis axis, byte oldValue, byte newValue)
        {
            IDevice device = deviceManager.ActiveDevice;

            if (device != null)
            {
                switch (joystick)
                {
                case ControllerJoystick.Left:
                    switch (axis)
                    {
                    case ControllerJoystickAxis.X:
                        try
                        {
                            device.VerticalFinPosition = newValue;
                        }
                        catch (Exception ex)
                        {
                            //serialData.Text += ex.Message + '\n';
                        }
                        break;

                    case ControllerJoystickAxis.Y:
                        try
                        {
                            device.HorizontalFinPosition = newValue;
                        }
                        catch (Exception ex)
                        {
                            //serialData.Text += ex.Message + '\n';
                        }
                        break;
                    }
                    break;

                case ControllerJoystick.Right:
                    switch (axis)
                    {
                    case ControllerJoystickAxis.Y:

                    {
                        try
                        {
                            device.Thrust = newValue;
                        }
                        catch (Exception ex)
                        {
                            //serialData.Text += ex.Message + '\n';
                        }
                    }
                    break;
                    }
                    break;
                }
            }
        }
Exemplo n.º 2
0
 protected void OnControllerAxisChanged(ControllerJoystick joystick, ControllerJoystickAxis axis, byte oldValue, byte newValue)
 {
     if (AxisChanged != null)
     {
         ControllerAxisChangedHandler eventHandler = AxisChanged;
         Delegate[] delegates = eventHandler.GetInvocationList();
         foreach (ControllerAxisChangedHandler handler in delegates)
         {
             DispatcherObject dispatcherObject = handler.Target as DispatcherObject;
             if (dispatcherObject != null && !dispatcherObject.CheckAccess())
             {
                 dispatcherObject.Dispatcher.Invoke(DispatcherPriority.DataBind, handler, joystick, axis, oldValue, newValue);
             }
             else
             {
                 handler(joystick, axis, oldValue, newValue);
             }
         }
     }
 }
Exemplo n.º 3
0
        public Vector2 GetXboxControllerJoystickValue(int PlayerID, ControllerJoystick JoystickName)
        {
            #if DEBUG_VERBOSE
                Debug.WriteLine("GetXboxControllerJoystickValue() called in NullInputState");
            #endif

            return Vector2.Zero;
        }
Exemplo n.º 4
0
 protected void OnControllerAxisChanged(ControllerJoystick joystick, ControllerJoystickAxis axis, byte oldValue, byte newValue)
 {
     if (AxisChanged != null)
     {
         ControllerAxisChangedHandler eventHandler = AxisChanged;
         Delegate[] delegates = eventHandler.GetInvocationList();
         foreach (ControllerAxisChangedHandler handler in delegates)
         {
             DispatcherObject dispatcherObject = handler.Target as DispatcherObject;
             if (dispatcherObject != null && !dispatcherObject.CheckAccess())
             {
                 dispatcherObject.Dispatcher.Invoke(DispatcherPriority.DataBind, handler, joystick, axis, oldValue, newValue);
             }
             else
                 handler(joystick, axis, oldValue, newValue);
         }
     }
 }
        void ControllerAxisChanged(ControllerJoystick joystick, ControllerJoystickAxis axis, byte oldValue, byte newValue)
        {
            IDevice device = deviceManager.ActiveDevice;
            if (device != null)
            {
                switch (joystick)
                {
                    case ControllerJoystick.Left:
                        switch (axis)
                        {
                            case ControllerJoystickAxis.X:
                                try
                                {
                                    device.VerticalFinPosition = newValue;
                                }
                                catch (Exception ex)
                                {
                                    //serialData.Text += ex.Message + '\n';
                                }
                                break;
                            case ControllerJoystickAxis.Y:
                                try
                                {
                                    device.HorizontalFinPosition = newValue;
                                }
                                catch (Exception ex)
                                {
                                    //serialData.Text += ex.Message + '\n';
                                }
                                break;
                        }
                        break;
                    case ControllerJoystick.Right:
                        switch (axis)
                        {
                            case ControllerJoystickAxis.Y:

                                {
                                    try
                                    {
                                        device.Thrust = newValue;
                                    }
                                    catch (Exception ex)
                                    {
                                        //serialData.Text += ex.Message + '\n';
                                    }
                                }
                                break;
                        }
                        break;
                }
            }
        }
Exemplo n.º 6
0
        public Vector2 GetXboxControllerJoystickValue(int PlayerID, ControllerJoystick JoystickName)
        {
            if (!IsXboxControllerConnected(PlayerID))
                return Vector2.Zero;

            switch (JoystickName)
            {
                case ControllerJoystick.LT:
                    return new Vector2(xboxStates[PlayerID].Triggers.Left);
                case ControllerJoystick.RT:
                    return new Vector2(xboxStates[PlayerID].Triggers.Right);
                case ControllerJoystick.LS:
                    return new Vector2(xboxStates[PlayerID].ThumbSticks.Left.X, xboxStates[PlayerID].ThumbSticks.Left.Y);
                case ControllerJoystick.RS:
                    return new Vector2(xboxStates[PlayerID].ThumbSticks.Right.X, xboxStates[PlayerID].ThumbSticks.Right.Y);
                default:
                    throw new Exception("The given joystick does not exist on the XBOX controller.");
            }
        }
 public XboxControllerJoystickInputCommand(int PlayerID, ControllerJoystick Joystick, Predicate<Vector2> Condition)
 {
     this.PlayerID = PlayerID;
     this.Joystick = Joystick;
     this.Condition = Condition;
 }