Search Unity

Question Xbox One Controller ( menu(Back) and View(Start) Button - C# Code

Discussion in 'Input System' started by MbR2XgD, Sep 2, 2022.

  1. MbR2XgD

    MbR2XgD

    Joined:
    Dec 15, 2017
    Posts:
    1
    There is a tutorial about Gamepad: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Gamepad.html

    I installed the New Input System 1.4.2, I created a code using "Gamepad" and I noticed there is
    no button "VIew(Start)" and "Menu(Back)" I have Xbox One Controller. I cannot find the Button
    "Menu or Back" and "View or Start". Is possible to create a code for "Start" and "Menu" Buttons?

    Code (CSharp):
    1.             float LStickX        = gamepad.leftStick.x.ReadValue();
    2.             float LStickY        = gamepad.leftStick.y.ReadValue();
    3.             float LStickU        = gamepad.leftStick.up.ReadValue();
    4.             float LStickD        = gamepad.leftStick.down.ReadValue();
    5.             float LStickL        = gamepad.leftStick.left.ReadValue();
    6.             float LStickR        = gamepad.leftStick.right.ReadValue();
    7.             float RStickX        = gamepad.rightStick.x.ReadValue();
    8.             float RStickY        = gamepad.rightStick.y.ReadValue();
    9.             float RStickU        = gamepad.rightStick.up.ReadValue();
    10.             float RStickD        = gamepad.rightStick.down.ReadValue();
    11.             float RStickL        = gamepad.rightStick.left.ReadValue();
    12.             float RStickR        = gamepad.rightStick.right.ReadValue();
    13.             float BLShoulder    = gamepad.leftShoulder.ReadValue();
    14.             float BRShoulder    = gamepad.rightShoulder.ReadValue();
    15.             float BLTrigger        = gamepad.leftTrigger.ReadValue();
    16.             float BRTrigger        = gamepad.rightTrigger.ReadValue();
    17.             float BNorth        = gamepad.buttonNorth.ReadValue();
    18.             float BSouth        = gamepad.buttonSouth.ReadValue();
    19.             float BWest        = gamepad.buttonWest.ReadValue();
    20.             float BEast        = gamepad.buttonEast.ReadValue();
    21.  
    22.             Debug.Log($"LStickX={LStickX} LStickY={LStickY} " +
    23.             $"RStickX={RStickX} RStickY={RStickY}" +
    24.             $"LTrigger={BLTrigger} RTrigger={BRTrigger} " +
    25.             $"LShoulder={BLShoulder} RShoulder={BRShoulder} \n" +
    26.             $"X={BWest} Y={BNorth} A={BSouth} B={BEast} " +
    27.             $"LStickUp={LStickU} LStickDown={LStickD}" +
    28.             $"LStickLeft={LStickL} LStickRight={LStickR} \n" +
    29.             $"RStickUp={RStickU} RStickDown={RStickD}" +
    30.             $"RStickReft={RStickR} RStickRight={RStickR} \n");
    31.