コード例 #1
0
ファイル: hStick.cs プロジェクト: XaaK/PongBlast
    protected hStick(string name, hGamepad internalGamepad, int index, bool isAnyGamepad)
    {
        this.name            = name;
        internalFullName     = internalGamepad.internalFullName + "_" + name;
        this.internalGamepad = internalGamepad;
        this.index           = index;

        inPressedZone = new hStickPressedZone("PressedZone", this);

        if (isAnyGamepad)
        {
            return;                       // Axes are unnecessary for anyGamepad
        }
        if (index == 0 || index == 1)     // Sticks
        {
            horizontalAxis = new hAxis(internalFullName + "_Horizontal");
            verticalAxis   = new hAxis(internalFullName + "_Vertical");
        }

        if (index == 2)           // DPad
        {
            horizontalAxis = new hAxis(internalFullName + "_Horizontal",
                                       internalFullName + "_Right",
                                       internalFullName + "_Left");
            verticalAxis = new hAxis(internalFullName + "_Vertical",
                                     internalFullName + "_Up",
                                     internalFullName + "_Down");
        }
    }
コード例 #2
0
    // --------------------
    // CONSTRUCTOR
    // --------------------

    public hVibration(int index, hGamepad gamepad)
    {
        if (hUtils.os == "Windows")
        {
            if (index == 0)
            {
                this.index = PlayerIndex.One;
            }
            else if (index == 1)
            {
                this.index = PlayerIndex.Two;
            }
            else if (index == 2)
            {
                this.index = PlayerIndex.Three;
            }
            else if (index == 3)
            {
                this.index = PlayerIndex.Four;
            }
            else
            {
                return;
            }

            canVibrate = true;
        }
    }
コード例 #3
0
ファイル: hPressable.cs プロジェクト: XaaK/PongBlast
    // --------------------
    // CONSTRUCTOR
    // --------------------

    protected hPressable(string internalName, hGamepad internalGamepad, string internalFullName)
    {
        this.internalName     = internalName;
        this.internalFullName = internalFullName;
        this.internalGamepad  = internalGamepad;

        lastPressed = Mathf.NegativeInfinity;         // *force wave* this input was never pressed
    }
コード例 #4
0
ファイル: hTrigger.cs プロジェクト: henriforshort/DICE
    // --------------------
    // CONSTRUCTOR
    // --------------------

    public hTrigger(string name, hGamepad gamepad)
    {
        this._name         = name;
        this._gamepadIndex = gamepad.index;
        this._fullName     = gamepad.fullName + "_" + name;

        initialValue = measuredPosition;
    }
コード例 #5
0
ファイル: hStick.cs プロジェクト: henriforshort/game-game
    // For the D-pad
    public hStick(string name, hGamepad gamepad)
    {
        this._name         = name;
        this._gamepadIndex = gamepad.index;
        this._fullName     = gamepad.fullName + "_" + name;
        this._index        = 2;

        horizontalAxis = new hAxis(fullName + "_Horizontal", fullName + "_Left", fullName + "_Right");
        verticalAxis   = new hAxis(fullName + "_Vertical", fullName + "_Down", fullName + "_Up");
    }
コード例 #6
0
ファイル: hStick.cs プロジェクト: henriforshort/game-game
    // --------------------
    // CONSTRUCTORS
    // --------------------

    // For sticks
    public hStick(string name, hGamepad gamepad, int index)
    {
        this._name         = name;
        this._gamepadIndex = gamepad.index;
        this._fullName     = gamepad.fullName + "_" + name;
        this._index        = index;

        horizontalAxis = new hAxis(fullName + "_Horizontal");
        verticalAxis   = new hAxis(fullName + "_Vertical");
    }
コード例 #7
0
ファイル: hTester.cs プロジェクト: XaaK/hinput
 private void UpdateCurrentButtonFromGamepad(hGamepad gamepad)
 {
     foreach (hPressable button in AllGamepadButtons(gamepad))
     {
         if (!button.inDeadZone)
         {
             currentButton = button;
             break;
         }
     }
 }
コード例 #8
0
ファイル: hAnyInput.cs プロジェクト: XaaK/PongBlast
    // --------------------
    // CONSTRUCTOR
    // --------------------

    public hAnyInput(string name, hGamepad internalGamepad) :
        base(name, internalGamepad, internalGamepad.internalFullName + "_" + name)
    {
        inputs = new List <hPressable> {
            internalGamepad.A, internalGamepad.B, internalGamepad.X, internalGamepad.Y,
            internalGamepad.leftBumper, internalGamepad.rightBumper,
            internalGamepad.leftTrigger, internalGamepad.rightTrigger,
            internalGamepad.back, internalGamepad.start,
            internalGamepad.leftStickClick, internalGamepad.rightStickClick, internalGamepad.xBoxButton,
            internalGamepad.leftStick, internalGamepad.rightStick, internalGamepad.dPad
        };
    }
コード例 #9
0
ファイル: hTester.cs プロジェクト: XaaK/hinput
 private void UpdateCurrentStickFromGamepad(hGamepad gamepad)
 {
     if (!gamepad.leftStick.inDeadZone)
     {
         currentStick = gamepad.leftStick;
     }
     else if (!gamepad.rightStick.inDeadZone)
     {
         currentStick = gamepad.rightStick;
     }
     else if (!gamepad.dPad.inDeadZone)
     {
         currentStick = gamepad.dPad;
     }
 }
コード例 #10
0
ファイル: hTester.cs プロジェクト: XaaK/hinput
    // --------------------
    // GET ALL GAMEPAD BUTTONS
    // --------------------

    private List <hPressable> AllGamepadButtons(hGamepad gamepad)
    {
        List <hPressable> buttons = new List <hPressable>();

        if (anyInput)
        {
            buttons.Add(gamepad.anyInput);
        }

        if (individualInputs)
        {
            buttons.AddRange(new List <hPressable>()
            {
                gamepad.A, gamepad.B, gamepad.X, gamepad.Y, gamepad.leftBumper, gamepad.rightBumper,
                gamepad.leftTrigger, gamepad.rightTrigger, gamepad.leftStickClick, gamepad.rightStickClick,
                gamepad.back, gamepad.start, gamepad.xBoxButton
            });

            if (stickVerticalsAndHorizontals)
            {
                buttons.AddRange(new List <hPressable> {
                    gamepad.leftStick.up, gamepad.leftStick.down, gamepad.leftStick.left, gamepad.leftStick.right,
                    gamepad.rightStick.up, gamepad.rightStick.down, gamepad.rightStick.left, gamepad.rightStick.right,
                    gamepad.dPad.up, gamepad.dPad.down, gamepad.dPad.left, gamepad.dPad.right
                });
            }

            if (stickDiagonals)
            {
                buttons.AddRange(new List <hPressable> {
                    gamepad.leftStick.upLeft, gamepad.leftStick.upRight, gamepad.leftStick.downLeft, gamepad.leftStick.downRight,
                    gamepad.rightStick.upLeft, gamepad.rightStick.upRight, gamepad.rightStick.downLeft, gamepad.rightStick.downRight,
                    gamepad.dPad.upLeft, gamepad.dPad.upRight, gamepad.dPad.downLeft, gamepad.dPad.downRight
                });
            }

            if (stickPressedZone)
            {
                buttons.AddRange(new List <hPressable> {
                    gamepad.leftStick.inPressedZone, gamepad.rightStick.inPressedZone, gamepad.dPad.inPressedZone
                });
            }
        }

        return(buttons);
    }
コード例 #11
0
ファイル: hTester.cs プロジェクト: XaaK/hinput
    private void TestVibrationOnGamepad(hGamepad gamepad)
    {
        if (vibrateOnVPressed && Input.GetKeyDown(KeyCode.V))
        {
            if (useDuration)
            {
                if (useLeftAndRightIntensity)
                {
                    gamepad.Vibrate(leftIntensity, rightIntensity, duration);
                }
                else
                {
                    gamepad.Vibrate(duration);
                }
            }
            else
            {
                if (useLeftAndRightIntensity)
                {
                    gamepad.Vibrate(leftIntensity, rightIntensity);
                }
                else
                {
                    gamepad.Vibrate();
                }
            }
        }

        if (vibrateAdvancedOnAPressed && Input.GetKeyDown(KeyCode.A))
        {
            gamepad.VibrateAdvanced(leftIntensity, rightIntensity);
        }

        if (stopVibrationOnSPressed && Input.GetKeyDown(KeyCode.S))
        {
            gamepad.StopVibration();
        }
    }
コード例 #12
0
    // --------------------
    // CONSTRUCTOR
    // --------------------

    public hButton(string name, hGamepad gamepad)
    {
        this._name         = name;
        this._gamepadIndex = gamepad.index;
        this._fullName     = gamepad.fullName + "_" + name;
    }
コード例 #13
0
    // --------------------
    // CONSTRUCTOR
    // --------------------

    public hTrigger(string name, hGamepad internalGamepad, int index) :
        base(name, internalGamepad, internalGamepad.internalFullName + "_" + name)
    {
        this.internalIndex = index;
        initialValue       = measuredPosition;
    }
コード例 #14
0
ファイル: hAnyGamepadStick.cs プロジェクト: XaaK/PongBlast
    // --------------------
    // CONSTRUCTOR
    // --------------------

    public hAnyGamepadStick(string name, hGamepad internalGamepad, int index)
        : base(name, internalGamepad, index, true)
    {
        _pressedSticks = hinput.gamepad.Select(g => g.sticks[index]).ToList();
    }
コード例 #15
0
ファイル: hButton.cs プロジェクト: XaaK/PongBlast
    // --------------------
    // CONSTRUCTOR
    // --------------------

    public hButton(string name, hGamepad internalGamepad, int internalIndex) :
        base(name, internalGamepad, internalGamepad.internalFullName + "_" + name)
    {
        this.internalIndex = internalIndex;
    }
コード例 #16
0
ファイル: hStick.cs プロジェクト: XaaK/PongBlast
    // --------------------
    // CONSTRUCTORS
    // --------------------

    public hStick(string name, hGamepad internalGamepad, int index)
        : this(name, internalGamepad, index, false)
    {
    }
コード例 #17
0
ファイル: hTester.cs プロジェクト: XaaK/hinput
    // --------------------
    // TEST GAMEPADS
    // --------------------

    private void TestInfo()
    {
        if (gamepadInfoOnGPressed && Input.GetKeyDown(KeyCode.G))
        {
            if (currentButton == null)
            {
                Debug.Log("Current gamepad has not been set");
                return;
            }

            hGamepad currentGamepad = currentButton.internalGamepad;
            string   log            = "current gamepad: " +
                                      "[type = \"" + currentGamepad.type + "\"" +
                                      ", index = " + currentGamepad.index +
                                      ", internal index = " + currentGamepad.internalIndex +
                                      ", name = " + currentGamepad.name +
                                      ", internal name = " + currentGamepad.internalName +
                                      ", full name = " + currentGamepad.fullName +
                                      ", internal full name = " + currentGamepad.internalFullName;

            if (currentGamepad is hAnyGamepad)
            {
                log += ", gamepads = " + ToString(((hAnyGamepad)currentGamepad).gamepads.Select(g => g.internalName).ToList()) +
                       ", indices = " + ToString(((hAnyGamepad)currentGamepad).indices);
            }

            log += "]";
            Debug.Log(log);
        }

        if (gamepadListsOnLPressed && Input.GetKeyDown(KeyCode.L))
        {
            if (currentButton == null)
            {
                Debug.Log("Current gamepad has not been set");
                return;
            }

            hGamepad currentGamepad = currentButton.internalGamepad;
            Debug.Log("current gamepad buttons : " +
                      ToString(currentGamepad.buttons.Select(b => b.name).ToList()) +
                      ", current gamepad sticks : " +
                      ToString(currentGamepad.sticks.Select(s => s.name).ToList()));
        }

        if (stickInfoOnPPressed && Input.GetKeyDown(KeyCode.P))
        {
            if (currentStick == null)
            {
                Debug.Log("Current stick has not been set");
                return;
            }

            string log = "[index = " + currentStick.index +
                         ", name = " + currentStick.name +
                         ", full name = " + currentStick.fullName +
                         ", internal full name = " + currentStick.internalFullName +
                         ", gamepad full name = " + currentStick.gamepadFullName +
                         ", gamepad internal full name = " + currentStick.internalGamepadFullName +
                         ", gamepad index = " + currentStick.gamepadIndex +
                         ", gamepad internal index = " + currentStick.internalGamepadIndex;

            if (currentStick is hAnyGamepadStick)
            {
                log = "current anyGamepad stick: " + log +
                      ", pressed sticks = " + ToString(((hAnyGamepadStick)currentStick).pressedSticks.Select(s => s.fullName).ToList()) +
                      ", pressed stick = " + ((hAnyGamepadStick)currentStick).pressedStick.fullName;
            }
            else
            {
                log = "current stick: " + log;
            }

            log += "]";
            Debug.Log(log);
        }

        if (buttonInfoOnBPressed && Input.GetKeyDown(KeyCode.B))
        {
            if (currentButton == null)
            {
                Debug.Log("Current button has not been set");
                return;
            }

            string log = "name = " + currentButton.name +
                         ", internal name = " + currentButton.internalName +
                         ", full name = " + currentButton.fullName +
                         ", internal full name = " + currentButton.internalFullName +
                         ", gamepad index = " + currentButton.gamepadIndex +
                         ", gamepad internal index = " + currentButton.internalGamepadIndex +
                         ", gamepad full name = " + currentButton.gamepadFullName +
                         ", gamepad internal full name = " + currentButton.internalGamepadFullName;

            if (currentButton is hDirection)
            {
                log = "current direction: [" + log +
                      ", stick index = " + ((hDirection)currentButton).stickIndex +
                      ", stick full name = " + ((hDirection)currentButton).stickFullName +
                      ", stick internal full name = " + ((hDirection)currentButton).internalStickFullName +
                      ", angle = " + ((hDirection)currentButton).angle;
            }
            else if (currentButton is hStickPressedZone)
            {
                log = "current stick pressed zone: [" + log +
                      ", stick index = " + ((hStickPressedZone)currentButton).stickIndex +
                      ", stick full name = " + ((hStickPressedZone)currentButton).stickFullName +
                      ", stick internal full name = " + ((hStickPressedZone)currentButton).internalStickFullName;
            }
            else if (currentButton is hButton)
            {
                log = "current button: [" + log +
                      ", index = " + ((hButton)currentButton).index +
                      ", index = " + ((hButton)currentButton).internalIndex;
            }
            else if (currentButton is hTrigger)
            {
                log = "current trigger: [" + log +
                      ", index = " + ((hTrigger)currentButton).index +
                      ", internal index = " + ((hTrigger)currentButton).internalIndex;
            }
            else if (currentButton is hAnyInput)
            {
                log = "current anyInput: [" + log +
                      ", pressed inputs = " + ToString(((hAnyInput)currentButton).pressedInputs.Select(i => i.fullName).ToList()) +
                      ", index = " + ((hAnyInput)currentButton).index +
                      ", internal index = " + ((hAnyInput)currentButton).internalIndex;
            }

            log += "]";
            Debug.Log(log);
        }
    }