Ejemplo n.º 1
0
        /// <summary>
        /// Fixe le controller droite/gauche / haut bas
        /// </summary>
        /// <param name="gamepadSugoi"></param>
        /// <param name="thumbStick"></param>
        /// <param name="buttonSugoiMin"></param>
        /// <param name="buttonSugoiMax"></param>

        private void SetSugoiGamepadThumb(Gamepad gamepadSugoi, double thumbStick, GamepadKeys buttonSugoiMin, GamepadKeys buttonSugoiMax)
        {
            if (gamepadSugoi != null)
            {
                if (thumbStick > 0.3)
                {
                    gamepadSugoi.Press(buttonSugoiMax);
                }
                else if (thumbStick < -0.3)
                {
                    gamepadSugoi.Press(buttonSugoiMin);
                }
                else
                {
                    if (gamepadSugoi.IsPressed(buttonSugoiMin))
                    {
                        gamepadSugoi.Release(buttonSugoiMin);
                    }
                    else if (gamepadSugoi.IsPressed(buttonSugoiMax))
                    {
                        gamepadSugoi.Release(buttonSugoiMax);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Permet d'obtenir le gamepad dont la clé est pressé. le func peut renvoyé true pour arreter la recherche
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>

        public void FindGamepadByKeyPressed(GamepadKeys key, Func <Gamepad, bool> gamepadPressed)
        {
            if (gamepadPressed == null)
            {
                return;
            }

            for (int i = 0; i < this.gamepads.Length; i++)
            {
                var gamepad = this.gamepads[i];

                if (gamepad.IsFree == false)
                {
                    if (gamepad.IsPressed(key))
                    {
                        bool mustContinue = gamepadPressed(gamepad);

                        if (mustContinue == false)
                        {
                            return;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void WaitForRelease(GamepadKeys gamepadKey, Action completed = null)
 {
     this.machine.PrepareWaiting(() =>
     {
         return(this.IsRelease(gamepadKey) == false);
     },
                                 completed
                                 );
 }
Ejemplo n.º 4
0
        public void WaitForRelease(GamepadKeys gamepadKey, int maximumFrame, Action completed = null)
        {
            frameWaitCount = 0;
            this.machine.PrepareWaiting(() =>
            {
                if (frameWaitCount < maximumFrame)
                {
                    frameWaitCount++;
                    return(this.IsRelease(gamepadKey) == false);
                }

                // on attend plus
                return(false);
            },
                                        completed
                                        );
        }
Ejemplo n.º 5
0
        public void Press(GamepadKeys key)
        {
            gamePadKeyValues[(int)key] = true;

            switch (key)
            {
            case GamepadKeys.Up:
                Release(GamepadKeys.Down);
                break;

            case GamepadKeys.Down:
                Release(GamepadKeys.Up);
                break;

            case GamepadKeys.Right:
                Release(GamepadKeys.Left);
                break;

            case GamepadKeys.Left:
                Release(GamepadKeys.Right);
                break;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Fixe les buttons
        /// </summary>
        /// <param name="gamepadValues"></param>
        /// <param name="gamepadSugoi"></param>
        /// <param name="buttonWindows"></param>
        /// <param name="buttonSugoi"></param>

        private void SetSugoiGamepadButton(Gamepad gamepadSugoi, GamepadWindows.GamepadReading gamepadValues, GamepadWindows.GamepadButtons buttonWindows, GamepadKeys buttonSugoi)
        {
            if (gamepadSugoi != null)
            {
                if ((gamepadValues.Buttons & buttonWindows) == buttonWindows)
                {
                    gamepadSugoi.Press(buttonSugoi);
                }
                else if (gamepadSugoi.IsPressed(buttonSugoi))
                {
                    gamepadSugoi.Release(buttonSugoi);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// One key is released
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>

        public bool IsRelease(GamepadKeys key)
        {
            return(gamePadKeyValues[(int)key] == false);
        }
Ejemplo n.º 8
0
 public void Release(GamepadKeys key)
 {
     gamePadKeyValues[(int)key] = false;
 }
Ejemplo n.º 9
0
 public bool IsPressed(GamepadKeys key)
 {
     return(gamePadKeyValues[(int)key]);
 }