Unity Gamepad/Controller Input Button Mapping Examples

Introduction

On this page you can find a small collection of example scripts related to getting button, axes and other input from different types of gamepads/controllers with the new Unity Input System, and some examples related to the old legacy Input class and Input Manager.
I sometimes find myself doing basic things in Unity, like mapping out controller buttons, over and over again for each new small experimental Unity project that I start, so I decided to post some basic examples here for future reference and to hopefully save you some work.
For now the examples are for generic gamepads, generic PlayStation DualShock controllers and for specific DualShock4, DualSense and Meta Quest Touch controllers, but I’ll hopefully expand this post later to include examples of other gamepad/controller input maps as well.

Unity Gamepad/Controller Input Mapping With The New Input System Package

The Unity Input System is a newer and much more dynamic/flexible system than the old legacy Input Manager and allows us to use any kind of Input Device quite easily. Using the Input System we can easily create so called Input Actions that can be mapped to different buttons from different input devices and Input Action Maps that can be saved to files or created at runtime from scripts.


The new input system basically has four ‘workflows’:

1. Reading values from a device directly from a C# script.
2. Using embedded Input Actions.
3. Using an Actions Asset.
4. Using an Actions Asset and a PlayerInput component.

The first workflow is the quickest and easiest to use but also the least flexible approach. But if you just want to quickly test input from a gamepad and get on with it, then with the new Input System and the direct approach, this is all you need to read the Vector2 value from a thumbstick, the equivalent of the Input.GetAxis() method of the old Input class:

Vector2 move = Gamepad.current.leftStick.ReadValue();

Example from the Input System Package Manual:

using UnityEngine;
using UnityEngine.InputSystem;
public class MyPlayerScript : MonoBehaviour
{
    void Update()
    {
        var gamepad = Gamepad.current;
        if (gamepad == null)
        {
            return; // No gamepad connected.
        }

        if (gamepad.rightTrigger.wasPressedThisFrame)
        {
            // 'Use' code here
        }

        Vector2 move = gamepad.leftStick.ReadValue();
        {
            // 'Move' code here
        }
    }
}

For more information on the new Input System and the different workflows see the Links down below.

Generic Gamepad input mapping using the Input System
Generic Gamepad Input Map (Input System Direct: Workflow Example 1)

GenericGamepadInputMapInputSystemDirect.cs

//
// Input System direct workflow example 1
// Coster-Graphics 2023. https://timcoster.com
//  
//           ____                       ____
//          |____|                     |____|
//        .'  _   '._________________.'      '.
//       :  _| |_     __        __        N    :
//      :  |_ o _|   |__|      |__|    W    E   :
//     :      _|           ___            S      :
//     :         .--.     |___|     .--.         :
//     :        :    :_____________:    :        :
//     :        '.__.'             '.__.'        :
//     :        :                       :        :
//     '       :                         :       '
//     :     .'                           '.     :
//     '.___.                               .___.'
//
// Generic Gamepad Input Map (With DualShock, DualShock4 and DualSense gamepad support)
//
// Buttons
// Gamepad.current.buttonNorth      = North button
// Gamepad.current.buttonEast       = East button
// Gamepad.current.buttonSouth      = South button
// Gamepad.current.buttonWest       = West button
// Gamepad.current.leftShoulder     = Left Shoulder button
// Gamepad.current.rightShoulder    = Right Shoulder button
// Gamepad.current.leftTrigger      = Left Trigger button
// Gamepad.current.rightTrigger     = Right Trigger button
// Gamepad.current.selectButton     = Select Button
// Gamepad.current.startButton      = Start Button
// Gamepad.current.leftStickButton  = Select Button
// Gamepad.current.rightStickButton = Start Button
// Gamepad.current.dpad.up          = D-Pad Up Button
// Gamepad.current.dpad.down        = D-Pad Down Button
// Gamepad.current.dpad.left        = D-Pad Left Button
// Gamepad.current.dpad.right       = D-Pad Right Button

// Axes
// Gamepad.current.leftStick    = Left Stick
// Gamepad.current.rightStick   = Right Stick
// Gamepad.current.leftTrigger  = Left Trigger
// Gamepad.current.rightTrigger = Right Trigger

// Gamepad specific
// Gamepad:
//      DualShockGamepad.current.touchpadButton         = Touchpad Button
// Gamepad:DualShockGamepad:
//      DualShock4GamepadHID.current.playStationButton  = Playstation Button

// Links
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/index.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Workflows.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Workflow-Direct.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/SupportedDevices.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Gamepad.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.DualShock.DualShockGamepad.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.DualShock.DualShock4GamepadHID.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Gamepad.html#playstation-controllers

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.DualShock;

public class GenericGamepadInputMapInputSystemDirect : MonoBehaviour
{
    Gamepad gamepad; 
    
    void Update()
    {
        gamepad = Gamepad.current;

        if (gamepad == null)
            return; // No gamepad connected.

        // Buttons
        if(gamepad.buttonNorth.isPressed)
            Debug.Log("Button North = " + gamepad.buttonNorth.isPressed);
        if(gamepad.buttonEast.isPressed)
            Debug.Log("Button East = " + gamepad.buttonEast.isPressed);
        if(gamepad.buttonSouth.isPressed)
            Debug.Log("Button South = " + gamepad.buttonSouth.isPressed);
        if(gamepad.buttonWest.isPressed)
            Debug.Log("Button West = " + gamepad.buttonWest.isPressed);

        if (gamepad.leftShoulder.isPressed)
            Debug.Log("Button Left Shoulder = " + gamepad.leftShoulder.isPressed);
        if (gamepad.rightShoulder.isPressed)
            Debug.Log("Button Right Shoulder = " + gamepad.rightShoulder.isPressed);
        if (gamepad.leftTrigger.isPressed)
            Debug.Log("Button Left Trigger = " + gamepad.leftTrigger.isPressed);
        if (gamepad.rightTrigger.isPressed)
            Debug.Log("Button Right Trigger = " + gamepad.rightTrigger.isPressed);

        if (gamepad.selectButton.isPressed)
            Debug.Log("Button Select = " + gamepad.selectButton.isPressed);
        if (gamepad.startButton.isPressed)
            Debug.Log("Button Start = " + gamepad.startButton.isPressed);

        if (gamepad.leftStickButton.isPressed)
            Debug.Log("Button Left Stick = " + gamepad.leftStickButton.isPressed);
        if (gamepad.rightStickButton.isPressed)
            Debug.Log("Button Right Stick = " + gamepad.rightStickButton.isPressed);

        if (gamepad.dpad.up.isPressed)
            Debug.Log("D-Pad Up = " + gamepad.dpad.up.isPressed);
        if (gamepad.dpad.down.isPressed)
            Debug.Log("D-Pad Down = " + gamepad.dpad.down.isPressed);
        if (gamepad.dpad.left.isPressed)
            Debug.Log("D-Pad Left = " + gamepad.dpad.left.isPressed);
        if (gamepad.dpad.right.isPressed)
            Debug.Log("D-Pad Right = " + gamepad.dpad.right.isPressed);
        
        // Axes
        if (gamepad.leftStick.ReadValue().x != 0)
            Debug.Log("Left Stick Horizontal = " + gamepad.leftStick.ReadValue().x);
        if (gamepad.leftStick.ReadValue().y != 0)
            Debug.Log("Left Stick Vertical = " + gamepad.leftStick.ReadValue().y);
        if (gamepad.rightStick.ReadValue().x != 0)
            Debug.Log("Right Stick Horizontal = " + gamepad.rightStick.ReadValue().x);
        if (gamepad.rightStick.ReadValue().y != 0)
            Debug.Log("Right Stick Vertical = " + gamepad.rightStick.ReadValue().y);

        if (gamepad.leftTrigger.ReadValue() > 0)
            Debug.Log("Left Trigger = " + gamepad.leftTrigger.ReadValue());
        if (gamepad.rightTrigger.ReadValue() > 0)
            Debug.Log("Right Trigger = " + gamepad.rightTrigger.ReadValue());

        // Controller specific support
        if(gamepad is DualShockGamepad){
            DualShockGamepad dualShockGamepad = gamepad as DualShockGamepad;
            
            if(dualShockGamepad.touchpadButton.isPressed)
                Debug.Log("Button Touchpad = " + dualShockGamepad.touchpadButton.isPressed);

            if(dualShockGamepad is DualShock4GamepadHID){
                DualShock4GamepadHID dualShock4GamepadHID = dualShockGamepad as DualShock4GamepadHID;
                
                if(dualShock4GamepadHID.playStationButton.isPressed)
                    Debug.Log("Button Playstation = " + dualShock4GamepadHID.playStationButton.isPressed);
            
            }else if(dualShockGamepad is DualSenseGamepadHID){
                DualSenseGamepadHID dualSenseGamepadHID = dualShockGamepad as DualSenseGamepadHID;

                if(dualSenseGamepadHID.playStationButton.isPressed)
                    Debug.Log("Button Playstation = " + dualSenseGamepadHID.playStationButton.isPressed);
            }
        }
    }
}

Generic PlayStation DualShock controller input mapping using the Input System
Generic DualShock Gamepad Input Map (Input System: Direct Workflow Example 2)

GenericDualShockGamepadInputMapInputSystemDirect.cs

//
// Input System direct workflow example 2
// Coster-Graphics 2023. https://timcoster.com
//           ____                       ____
//          |____|                     |____|
//        .'  _   '._________________.'      '.
//       :  _| |_   :▯|          |▯:    △    :
//      :  |_ X _|   : |__________|:   ◻    O  :
//      :     _|     :     \ /     :      X     :
//       :.      .--:       O       :--.      .:
//       : '----:    :_____________:    :----' :
//      .'      '.__.'             '.__.'      '.
//      :       :                       :       :
//      '      :                         :      '
//     :     .'                           '.     :
//     '.___.                               .___.'
//
// Generic DualShock Controller Input Map (With DualShock4 and DualSense gamepad support)
//
// Buttons
// (Gamepad.current as DualShockGamepad).triangleButton     = Triangle Button
// (Gamepad.current as DualShockGamepad).circleButton       = Circle Button
// (Gamepad.current as DualShockGamepad).crossButton        = Cross Button
// (Gamepad.current as DualShockGamepad).squareButton       = Square Button
// (Gamepad.current as DualShockGamepad).L1                 = L1 Button
// (Gamepad.current as DualShockGamepad).R1                 = R1 Button
// (Gamepad.current as DualShockGamepad).L2                 = L2 Button
// (Gamepad.current as DualShockGamepad).R2                 = R2 Button
// (Gamepad.current as DualShockGamepad).L3                 = L3 Button
// (Gamepad.current as DualShockGamepad).R3                 = R3 Button
// (Gamepad.current as DualShockGamepad).shareButton        = Share Button
// (Gamepad.current as DualShockGamepad).optionsButton      = Options Button
// (Gamepad.current as DualShockGamepad).touchpadButton     = Touchpad Button
// (Gamepad.current as DualShockGamepad).dpad.up            = D-Pad Up Button
// (Gamepad.current as DualShockGamepad).dpad.down          = D-Pad Down Button
// (Gamepad.current as DualShockGamepad).dpad.left          = D-Pad Left Button
// (Gamepad.current as DualShockGamepad).dpad.right         = D-Pad Right Button

// Axes
// (Gamepad.current as DualShockGamepad).leftStick          = Left Stick
// (Gamepad.current as DualShockGamepad).rightStick         = Right Stick
// (Gamepad.current as DualShockGamepad).leftTrigger        = Left Trigger
// (Gamepad.current as DualShockGamepad).rightTrigger       = Right Trigger

// Gamepad specific
// Gamepad
//      :DualShockGamepad
//          :DualShock4GamepadHID.playStationButton  = Playstation Button
//          :DualSenseGamepadHID.playStationButton   = Playstation Button

// Links
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/index.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Workflows.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Workflow-Direct.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/SupportedDevices.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Gamepad.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.DualShock.DualShockGamepad.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.DualShock.DualShock4GamepadHID.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Gamepad.html#playstation-controllers

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.DualShock;

public class GenericDualShockGamepadInputMapInputSystemDirect : MonoBehaviour
{
    DualShockGamepad dualShockGamepad; 
    
    void Update()
    {
        dualShockGamepad = Gamepad.current as DualShockGamepad;

        if (dualShockGamepad == null)
            return; // No DualShock gamepad connected.

        // Buttons
        if(dualShockGamepad.triangleButton.isPressed)
            Debug.Log("Button Triangle = " + dualShockGamepad.triangleButton.isPressed);
        if(dualShockGamepad.circleButton.isPressed)
            Debug.Log("Button Circle = " + dualShockGamepad.circleButton.isPressed);
        if(dualShockGamepad.crossButton.isPressed)
            Debug.Log("Button Cross = " + dualShockGamepad.crossButton.isPressed);
        if(dualShockGamepad.squareButton.isPressed)
            Debug.Log("Button Square = " + dualShockGamepad.squareButton.isPressed);

        if (dualShockGamepad.L1.isPressed)
            Debug.Log("Button L1 = " + dualShockGamepad.L1.isPressed);
        if (dualShockGamepad.R1.isPressed)
            Debug.Log("Button R1 = " + dualShockGamepad.R1.isPressed);
        if (dualShockGamepad.L2.isPressed)
            Debug.Log("Button L2 = " + dualShockGamepad.L2.isPressed);
        if (dualShockGamepad.R2.isPressed)
            Debug.Log("Button R2 = " + dualShockGamepad.R2.isPressed);
        if (dualShockGamepad.L3.isPressed)
            Debug.Log("Button L3 = " + dualShockGamepad.L3.isPressed);
        if (dualShockGamepad.R3.isPressed)
            Debug.Log("Button R3 = " + dualShockGamepad.R3.isPressed);

        if (dualShockGamepad.shareButton.isPressed)
            Debug.Log("Button Share = " + dualShockGamepad.shareButton.isPressed);
        if (dualShockGamepad.optionsButton.isPressed)
            Debug.Log("Button Options = " + dualShockGamepad.optionsButton.isPressed);
        if(dualShockGamepad.touchpadButton.isPressed){
            Debug.Log("Button Touchpad = " + dualShockGamepad.touchpadButton.isPressed);
        }

        if (dualShockGamepad.dpad.up.isPressed)
            Debug.Log("D-Pad Up = " + dualShockGamepad.dpad.up.isPressed);
        if (dualShockGamepad.dpad.down.isPressed)
            Debug.Log("D-Pad Down = " + dualShockGamepad.dpad.down.isPressed);
        if (dualShockGamepad.dpad.left.isPressed)
            Debug.Log("D-Pad Left = " + dualShockGamepad.dpad.left.isPressed);
        if (dualShockGamepad.dpad.right.isPressed)
            Debug.Log("D-Pad Right = " + dualShockGamepad.dpad.right.isPressed);
        
        // Axes
        if (dualShockGamepad.leftStick.ReadValue().x != 0)
            Debug.Log("Left Stick Horizontal = " + dualShockGamepad.leftStick.ReadValue().x);
        if (dualShockGamepad.leftStick.ReadValue().y != 0)
            Debug.Log("Left Stick Vertical = " + dualShockGamepad.leftStick.ReadValue().y);
        if (dualShockGamepad.rightStick.ReadValue().x != 0)
            Debug.Log("Right Stick Horizontal = " + dualShockGamepad.rightStick.ReadValue().x);
        if (dualShockGamepad.rightStick.ReadValue().y != 0)
            Debug.Log("Right Stick Vertical = " + dualShockGamepad.rightStick.ReadValue().y);

        if (dualShockGamepad.L2.ReadValue() > 0)
            Debug.Log("L2 = " + dualShockGamepad.L2.ReadValue());
        if (dualShockGamepad.R2.ReadValue() > 0)
            Debug.Log("R2 = " + dualShockGamepad.R2.ReadValue());

        // Controller specific support
        if(dualShockGamepad is DualShock4GamepadHID){
            DualShock4GamepadHID dualShock4GamepadHID = dualShockGamepad as DualShock4GamepadHID;
            
            if(dualShock4GamepadHID.playStationButton.isPressed)
                Debug.Log("Button Playstation = " + dualShock4GamepadHID.playStationButton.isPressed);

        }else if(dualShockGamepad is DualSenseGamepadHID){
            DualSenseGamepadHID dualSenseGamepadHID = dualShockGamepad as DualSenseGamepadHID;

            if(dualSenseGamepadHID.playStationButton.isPressed)
                Debug.Log("Button Playstation = " + dualSenseGamepadHID.playStationButton.isPressed);
        }
    }
}

Specific PlayStation DualShock4 controller input mapping using the Input System
DualShock4HID Controller Input Map (Input System: Direct Workflow Example 3)

DualShock4HIDGamepadInputMapInputSystemDirect.cs

//
// Input System direct workflow example 3
// Coster-Graphics 2023. https://timcoster.com
//           ____                       ____
//          |____|                     |____|
//        .'  _   '._________________.'      '.
//       :  _| |_   :▯|          |▯:    △    :
//      :  |_ X _|   : |__________|:   ◻    O  :
//      :     _|     :     \ /     :      X     :
//       :.      .--:       O       :--.      .:
//       : '----:    :_____________:    :----' :
//      .'      '.__.'             '.__.'      '.
//      :       :                       :       :
//      '      :                         :      '
//     :     .'                           '.     :
//     '.___.                               .___.'
//
// Specific DualShock4HID Gamepad Input Map (with DualSense support)
//
// Buttons
// (Gamepad.current as DualShock4GamepadHID).triangleButton     = Triangle Button
// (Gamepad.current as DualShock4GamepadHID).circleButton       = Circle Button
// (Gamepad.current as DualShock4GamepadHID).crossButton        = Cross Button
// (Gamepad.current as DualShock4GamepadHID).squareButton       = Square Button
// (Gamepad.current as DualShock4GamepadHID).L1                 = L1 Button
// (Gamepad.current as DualShock4GamepadHID).R1                 = R1 Button
// (Gamepad.current as DualShock4GamepadHID).L2                 = L2 Button
// (Gamepad.current as DualShock4GamepadHID).R2                 = R2 Button
// (Gamepad.current as DualShock4GamepadHID).L3                 = L3 Button
// (Gamepad.current as DualShock4GamepadHID).R3                 = R3 Button
// (Gamepad.current as DualShock4GamepadHID).shareButton        = Share Button
// (Gamepad.current as DualShock4GamepadHID).optionsButton      = Options Button
// (Gamepad.current as DualShock4GamepadHID).touchpadButton     = Touchpad Button
// (Gamepad.current as DualShock4GamepadHID).playStationButton  = Playstation Button
// (Gamepad.current as DualShock4GamepadHID).dpad.up            = D-Pad Up Button
// (Gamepad.current as DualShock4GamepadHID).dpad.down          = D-Pad Down Button
// (Gamepad.current as DualShock4GamepadHID).dpad.left          = D-Pad Left Button
// (Gamepad.current as DualShock4GamepadHID).dpad.right         = D-Pad Right Button

// Axes
// (Gamepad.current as DualShock4GamepadHID).leftStick          = Left Stick
// (Gamepad.current as DualShock4GamepadHID).rightStick         = Right Stick
// (Gamepad.current as DualShock4GamepadHID).leftTrigger        = Left Trigger
// (Gamepad.current as DualShock4GamepadHID).rightTrigger       = Right Trigger

// Gamepad specific
// Gamepad
//      :DualShockGamepad
//          :DualSenseGamepadHID.playStationButton = Playstation Button

// Links
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/index.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Workflows.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Workflow-Direct.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/SupportedDevices.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Gamepad.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.DualShock.DualShockGamepad.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.DualShock.DualShock4GamepadHID.html
// https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Gamepad.html#playstation-controllers

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.DualShock;

public class DualShock4HIDGamepadInputMapInputSystemDirect : MonoBehaviour
{
    DualShock4GamepadHID dualShock4GamepadHID; 
    
    void Update()
    {
        dualShock4GamepadHID = Gamepad.current as DualShock4GamepadHID;

        if (dualShock4GamepadHID == null)
            return; // No DualShock4 gamepad connected.

        // Buttons
        if(dualShock4GamepadHID.triangleButton.isPressed)
            Debug.Log("Button North = " + dualShock4GamepadHID.buttonNorth.isPressed);
        if(dualShock4GamepadHID.circleButton.isPressed)
            Debug.Log("Button East = " + dualShock4GamepadHID.buttonEast.isPressed);
        if(dualShock4GamepadHID.crossButton.isPressed)
            Debug.Log("Button South = " + dualShock4GamepadHID.buttonSouth.isPressed);
        if(dualShock4GamepadHID.squareButton.isPressed)
            Debug.Log("Button West = " + dualShock4GamepadHID.buttonWest.isPressed);

        if (dualShock4GamepadHID.L1.isPressed)
            Debug.Log("Button L1 = " + dualShock4GamepadHID.L1.isPressed);
        if (dualShock4GamepadHID.R1.isPressed)
            Debug.Log("Button R1 = " + dualShock4GamepadHID.R1.isPressed);
        if (dualShock4GamepadHID.L2.isPressed)
            Debug.Log("Button L2 = " + dualShock4GamepadHID.L2.isPressed);
        if (dualShock4GamepadHID.R2.isPressed)
            Debug.Log("Button R2 = " + dualShock4GamepadHID.R2.isPressed);
        if (dualShock4GamepadHID.L3.isPressed)
            Debug.Log("Button L3 = " + dualShock4GamepadHID.L3.isPressed);
        if (dualShock4GamepadHID.R3.isPressed)
            Debug.Log("Button R3 = " + dualShock4GamepadHID.R3.isPressed);


        if (dualShock4GamepadHID.shareButton.isPressed)
            Debug.Log("Button Share = " + dualShock4GamepadHID.shareButton.isPressed);
        if (dualShock4GamepadHID.optionsButton.isPressed)
            Debug.Log("Button Options = " + dualShock4GamepadHID.optionsButton.isPressed);
        if(dualShock4GamepadHID.touchpadButton.isPressed)
            Debug.Log("Button Touchpad = " + dualShock4GamepadHID.touchpadButton.isPressed);   
        if(dualShock4GamepadHID.playStationButton.isPressed)
            Debug.Log("Button Playstation = " + dualShock4GamepadHID.playStationButton.isPressed);


        if (dualShock4GamepadHID.dpad.up.isPressed)
            Debug.Log("D-Pad Up = " + dualShock4GamepadHID.dpad.up.isPressed);
        if (dualShock4GamepadHID.dpad.down.isPressed)
            Debug.Log("D-Pad Down = " + dualShock4GamepadHID.dpad.down.isPressed);
        if (dualShock4GamepadHID.dpad.left.isPressed)
            Debug.Log("D-Pad Left = " + dualShock4GamepadHID.dpad.left.isPressed);
        if (dualShock4GamepadHID.dpad.right.isPressed)
            Debug.Log("D-Pad Right = " + dualShock4GamepadHID.dpad.right.isPressed);
        
        // Axes
        if (dualShock4GamepadHID.leftStick.ReadValue().x != 0)
            Debug.Log("Left Stick Horizontal = " + dualShock4GamepadHID.leftStick.ReadValue().x);
        if (dualShock4GamepadHID.leftStick.ReadValue().y != 0)
            Debug.Log("Left Stick Vertical = " + dualShock4GamepadHID.leftStick.ReadValue().y);
        if (dualShock4GamepadHID.rightStick.ReadValue().x != 0)
            Debug.Log("Right Stick Horizontal = " + dualShock4GamepadHID.rightStick.ReadValue().x);
        if (dualShock4GamepadHID.rightStick.ReadValue().y != 0)
            Debug.Log("Right Stick Vertical = " + dualShock4GamepadHID.rightStick.ReadValue().y);

        if (dualShock4GamepadHID.L2.ReadValue() > 0)
            Debug.Log("L2 = " + dualShock4GamepadHID.L2.ReadValue());
        if (dualShock4GamepadHID.R2.ReadValue() > 0)
            Debug.Log("R2 = " + dualShock4GamepadHID.R2.ReadValue());

        // Controller specific support
        if(Gamepad.current is DualSenseGamepadHID){
            DualSenseGamepadHID dualSenseGamepadHID = Gamepad.current as DualSenseGamepadHID;

            if(dualSenseGamepadHID.playStationButton.isPressed)
                Debug.Log("Button Playstation = " + dualSenseGamepadHID.playStationButton.isPressed);
        }
    }
}

Specific Meta Quest Touch controllers input mapping using the OVRInput class
Meta/Oculus Quest Touch Controllers Input Map (OVRInput Class: Accessing Controllers as a Combined Pair Example)

QuestTouchControllerInputMapOVRInputCombined.cs

//
// Quest Touch Controllers Input Map OVRInput Class Combined Pair Example 
// Coster-Graphics 2023. https://timcoster.com
//          
//           ____                 ____ 
//        .'      '.           .'      '.
//       :  _       :         :       _  :
//      : :   :  Y   :       :   B  :   : :
//      :  '-'  X    :       :    A  '-'  :
//       :  =     _.:         :._     oo.:
//       : '---- /  |         | \  ----' :
//      .'      |_|/           \|_|       '.
//      :       :                 :        :
//      '      :                   :       '
//     :     .'                     '.      :
//     '.___.                         .___.'
//
// Specific Quest Touch Controller Input Map using the OVRInput class
// Accessing controllers as a combined pair Example
//
// Buttons
// OVRInput.Button.One   = Button A
// OVRInput.Button.Two   = Button B
// OVRInput.Button.Three = Button X
// OVRInput.Button.Four  = Button Y
// OVRInput.Button.Start = Button Start
// OVRInput.Button.PrimaryThumbstick   = Button Primary Thumbstick
// OVRInput.Button.SecondaryThumbstick = Button Secondary Thumbstick
//
// Axes 
//   Axes Thumbsticks
// OVRInput.Axis2D.PrimaryThumbstick       = Axis2D (Vector2) Primary Thumbstick
// OVRInput.Axis2D.SecondaryThumbstick     = Axis2D (Vector2) Secondary Thumbstick
//
//   Axes Triggers
// OVRInput.Axis1D.PrimaryIndexTrigger     = Axis1D (float) PrimaryIndexTrigger
// OVRInput.Axis1D.SecondaryIndexTrigger   = Axis1D (float) SecondaryIndexTrigger
//
//   Axes Hand/Grip Triggers
// OVRInput.Axis1D.PrimaryHandTrigger      = Axis1D (float) PrimaryHandTrigger
// OVRInput.Axis1D.SecondaryHandTrigger    = Axis1D (float) SecondaryHandTrigger
//
// Touches
//   Button Touches
// OVRInput.Touch.One = Touch One
// OVRInput.Touch.Two = Touch Two
// OVRInput.Touch.Three = Touch Three
// OVRInput.Touch.Four = Touch Four
//
//   Trigger Touches
// OVRInput.Touch.PrimaryIndexTrigger = Touch Primary IndexTrigger
// OVRInput.Touch.SecondaryIndexTrigger =Touch SecondaryIndexTrigger
//
//   Thumbstick Touches
// OVRInput.Touch.PrimaryThumbstick =Touch PrimaryThumbstick 
// OVRInput.Touch.SecondaryThumbstick =Touch SecondaryThumbstick
// 
//   Thumbrest Touches
// OVRInput.Touch.PrimaryThumbRest =Touch PrimaryThumbRest
// OVRInput.Touch.SecondaryThumbRest =Touch SecondaryThumbRest 
//
// Near Touches
//   Thumb Buttons Near Touches
// OVRInput.NearTouch.PrimaryThumbButtons = Near Touch PrimaryThumbRest
// OVRInput.NearTouch.SecondaryThumbButtons = Near Touch SecondaryThumbButtons
//
//   Triggers Near Touches
// OVRInput.NearTouch.PrimaryIndexTrigger = Near Touch PrimaryIndexTrigger
// OVRInput.NearTouch.SecondaryIndexTrigger = Near Touch SecondaryIndexTrigger
//
// Links
// https://developer.oculus.com/documentation/unity/unity-ovrinput/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class QuestTouchControllerInputMapOVRInputCombined : MonoBehaviour
{
    void Update()
    {
        // Include an instance of OVRManger anywhere in your scene.
        // Call OVRInput.Update() and OVRInput.FixedUpdate() once per frame at the beginning of any component’s Update and FixedUpdate methods, respectively.
        OVRInput.Update();

        // Buttons
        if(OVRInput.Get(OVRInput.Button.One))
            Debug.Log("Button One = " + OVRInput.Get(OVRInput.Button.One));
        if(OVRInput.Get(OVRInput.Button.Two))
            Debug.Log("Button Two = " + OVRInput.Get(OVRInput.Button.Two));
        if(OVRInput.Get(OVRInput.Button.Three))
            Debug.Log("Button Three = " + OVRInput.Get(OVRInput.Button.Three));
        if(OVRInput.Get(OVRInput.Button.Four))
            Debug.Log("Button Four = " + OVRInput.Get(OVRInput.Button.Four));

        if(OVRInput.Get(OVRInput.Button.Start))
            Debug.Log("Button Start = " + OVRInput.Get(OVRInput.Button.Start));

        if(OVRInput.Get(OVRInput.Button.PrimaryThumbstick))
            Debug.Log("Button PrimaryThumbstick = " + OVRInput.Get(OVRInput.Button.PrimaryThumbstick));
        if(OVRInput.Get(OVRInput.Button.SecondaryThumbstick))
            Debug.Log("Button SecondaryThumbstick = " + OVRInput.Get(OVRInput.Button.SecondaryThumbstick));

        // Axes
            // Axes ThumbSticks
        if(OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).x != 0)
            Debug.Log("Thumbstick PrimaryThumbstick Horizontal = " + OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).x);
        if(OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).y != 0)
            Debug.Log("Thumbstick PrimaryThumbstick Vertical = " + OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).y);

        if(OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick).x != 0 )
            Debug.Log("Thumbstick SecondaryThumbstick Horizontal = " + OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick).x);
        if(OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick).y != 0 )
            Debug.Log("Thumbstick SecondaryThumbstick Vertical = " + OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick).y);

            // Axes Triggers
        if(OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger) > 0 )
            Debug.Log("Trigger PrimaryIndexTrigger = " + OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger));
        if(OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger) > 0 )
            Debug.Log("Trigger SecondaryIndexTrigger = " + OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger));

            // Axes Hand/Grip Triggers
        if(OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger) > 0 )
            Debug.Log("Trigger PrimaryHandTrigger = " + OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger));
        if(OVRInput.Get(OVRInput.Axis1D.SecondaryHandTrigger) > 0 )
            Debug.Log("Trigger SecondaryHandTrigger = " + OVRInput.Get(OVRInput.Axis1D.SecondaryHandTrigger));

        // Touches
            // Button Touches
        if(OVRInput.Get(OVRInput.Touch.One))
            Debug.Log("Touch One = " + OVRInput.Touch.One);
        if(OVRInput.Get(OVRInput.Touch.Two))
            Debug.Log("Touch Two = " + OVRInput.Touch.Two);
        if(OVRInput.Get(OVRInput.Touch.Three))
            Debug.Log("Touch Three = " + OVRInput.Touch.Three);
        if(OVRInput.Get(OVRInput.Touch.Four))
            Debug.Log("Touch Four = " + OVRInput.Touch.Four);
            // Trigger Touches
        if(OVRInput.Get(OVRInput.Touch.PrimaryIndexTrigger))
            Debug.Log("Touch PrimaryIndexTrigger = " + OVRInput.Get(OVRInput.Touch.PrimaryIndexTrigger));
        if(OVRInput.Get(OVRInput.Touch.SecondaryIndexTrigger))
            Debug.Log("Touch SecondaryIndexTrigger = " + OVRInput.Get(OVRInput.Touch.SecondaryIndexTrigger));
            // Thumbstick Touches
        if(OVRInput.Get(OVRInput.Touch.PrimaryThumbstick))
            Debug.Log("Touch PrimaryThumbstick = " + OVRInput.Touch.PrimaryThumbstick);
        if(OVRInput.Get(OVRInput.Touch.SecondaryThumbstick))
            Debug.Log("Touch SecondaryThumbstick = " + OVRInput.Touch.SecondaryThumbstick);
            // Thumbrest Touches
        if(OVRInput.Get(OVRInput.Touch.PrimaryThumbRest))
            Debug.Log("Touch PrimaryThumbRest = " + OVRInput.Get(OVRInput.Touch.PrimaryThumbRest));
        if(OVRInput.Get(OVRInput.Touch.SecondaryThumbRest))
            Debug.Log("Touch SecondaryThumbRest = " + OVRInput.Get(OVRInput.Touch.SecondaryThumbRest));

        // Near Touches
            // Thumb Buttons Near Touches
        if(OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons))
            Debug.Log("Near Touch PrimaryThumbRest = " + OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons));
        if(OVRInput.Get(OVRInput.NearTouch.SecondaryThumbButtons))
            Debug.Log("Near Touch SecondaryThumbButtons = " + OVRInput.Get(OVRInput.NearTouch.SecondaryThumbButtons));
            // Triggers Near Touches
        if(OVRInput.Get(OVRInput.NearTouch.PrimaryIndexTrigger))
            Debug.Log("Near Touch PrimaryIndexTrigger = " + OVRInput.Get(OVRInput.NearTouch.PrimaryIndexTrigger));
        if(OVRInput.Get(OVRInput.NearTouch.SecondaryIndexTrigger))
            Debug.Log("Near Touch SecondaryIndexTrigger = " + OVRInput.Get(OVRInput.NearTouch.SecondaryIndexTrigger));
    }
}
Meta/Oculus Quest Touch Controllers Input Map (OVRInput Class: Accessing Controllers Individually Example)

QuestTouchControllerInputMapOVRInputIndividual.cs

//
// Quest Touch Controllers Input Map OVRInput Class Individual Controllers Example 
// Coster-Graphics 2024. https://timcoster.com
//          
//           ____                 ____ 
//        .'      '.           .'      '.
//       :  _       :         :       _  :
//      : :   :  Y   :       :   B  :   : :
//      :  '-'  X    :       :    A  '-'  :
//       :  =     _.:         :._     oo.:
//       : '---- /  |         | \  ----' :
//      .'      |_|/           \|_|       '.
//      :       :                 :        :
//      '      :                   :       '
//     :     .'                     '.      :
//     '.___.                         .___.'
//
// Specific Quest Touch Controller Input Map using the OVRInput class
// Accessing Controllers Individually Example
//
// Buttons
// OVRInput.Button.One                      = Button A or X
// OVRInput.Button.Two                      = Button B or Y
// OVRInput.Button.Start                    = Button Start
// OVRInput.Button.PrimaryThumbstick        = Button Thumbstick Left or Right
//
// Axes 
//   Axes Thumbsticks
// OVRInput.Axis2D.PrimaryThumbstick        = Axis2D (Vector2) Thumbstick Left or Right
//
//   Axes Triggers
// OVRInput.Axis1D.PrimaryIndexTrigger      = Axis1D (float) Trigger Left or Right
//
//   Axes Hand/Grip Triggers
// OVRInput.Axis1D.PrimaryHandTrigger       = Axis1D (float) Hand Trigger Left or Right
//
// Touches
//   Button Touches
// OVRInput.Touch.One                       = Touch Button A or X
// OVRInput.Touch.Two                       = Touch Button B or Y
//
//   Trigger Touches
// OVRInput.Touch.PrimaryIndexTrigger       = Touch Trigger Left or Right
//
//   Thumbstick Touches
// OVRInput.Touch.PrimaryThumbstick         = Touch Thumbstick Left or Right
// 
//   Thumbrest Touches
// OVRInput.Touch.PrimaryThumbRest          = Touch Thumb Rest Left or Right
//
// Near Touches
//   Thumb Buttons Near Touches
// OVRInput.NearTouch.PrimaryThumbButtons   = Near Touch Thumb Buttons Left or Right
//
//   Triggers Near Touches
// OVRInput.NearTouch.PrimaryIndexTrigger   = Near Touch Trigger Left or Right
//
// Links
// https://developer.oculus.com/documentation/unity/unity-ovrinput/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Controller = OVRInput.Controller;

public class QuestTouchControllerInputMapOVRInputIndividual : MonoBehaviour
{
    // To allow the same code to be used for either hand you can 
    // specify the controller in a variable that is set externally, 
    // such as on a public variable in Unity Editor.
    // This is convenient since it avoids the common pattern of if/else 
    // checks for left or right hand input mappings.

    // public variable that can be set to LTouch or RTouch in the Unity Inspector
    public Controller controller;

    void Update()
    {
        // Requirements
        // -Include an instance of OVRManger anywhere in your scene.
        // -Call OVRInput.Update() and OVRInput.FixedUpdate() once per frame at the beginning of any component’s 
        //  Update and FixedUpdate methods, respectively.
        OVRInput.Update();

        // Buttons
        if(OVRInput.Get(OVRInput.Button.One, controller))
            Debug.Log("Button One = " + OVRInput.Get(OVRInput.Button.One, controller));
        if(OVRInput.Get(OVRInput.Button.Two, controller))
            Debug.Log("Button Two = " + OVRInput.Get(OVRInput.Button.Two, controller));

        if(OVRInput.Get(OVRInput.Button.Start, controller))
            Debug.Log("Button Start = " + OVRInput.Get(OVRInput.Button.Start, controller));

        if(OVRInput.Get(OVRInput.Button.PrimaryThumbstick, controller))
            Debug.Log("Button PrimaryThumbstick = " + OVRInput.Get(OVRInput.Button.PrimaryThumbstick, controller));


        // Axes
            // Axes ThumbSticks
        if(OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).x != 0)
            Debug.Log("Thumbstick PrimaryThumbstick Horizontal = " + OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, controller).x);
        if(OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).y != 0)
            Debug.Log("Thumbstick PrimaryThumbstick Vertical = " + OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, controller).y);

            // Axes Triggers
        if(OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger) > 0 )
            Debug.Log("Trigger PrimaryIndexTrigger = " + OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, controller));

            // Axes Hand/Grip Triggers
        if(OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger) > 0 )
            Debug.Log("Trigger PrimaryHandTrigger = " + OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, controller));

        // Touches
            // Button Touches
        if(OVRInput.Get(OVRInput.Touch.One, controller))
            Debug.Log("Touch One = " + OVRInput.Get(OVRInput.Touch.One, controller));
        if(OVRInput.Get(OVRInput.Touch.Two, controller))
            Debug.Log("Touch Two = " + OVRInput.Get(OVRInput.Touch.Two, controller));

            // Trigger Touches
        if(OVRInput.Get(OVRInput.Touch.PrimaryIndexTrigger, controller))
            Debug.Log("Touch PrimaryIndexTrigger = " + OVRInput.Get(OVRInput.Touch.PrimaryIndexTrigger, controller));

            // Thumbstick Touches
        if(OVRInput.Get(OVRInput.Touch.PrimaryThumbstick, controller))
            Debug.Log("Touch PrimaryThumbstick = " + OVRInput.Get(OVRInput.Touch.PrimaryThumbstick, controller));

            // Thumbrest Touches
        if(OVRInput.Get(OVRInput.Touch.PrimaryThumbRest, controller))
            Debug.Log("Touch PrimaryThumbRest = " + OVRInput.Get(OVRInput.Touch.PrimaryThumbRest, controller));

        // Near Touches
            // Thumb Buttons Near Touches
        if(OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, controller))
            Debug.Log("Near Touch PrimaryThumbButtons = " + OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, controller));

            // Triggers Near Touches
        if(OVRInput.Get(OVRInput.NearTouch.PrimaryIndexTrigger, controller))
            Debug.Log("Near Touch PrimaryIndexTrigger = " + OVRInput.Get(OVRInput.NearTouch.PrimaryIndexTrigger, controller));
    }
}
Meta/Oculus Quest Touch Controllers Input Map (OVRInput Class: Raw Mapping Controllers Example)

QuestTouchControllerInputMapOVRInputRaw.cs

//
// Quest Touch Controllers Input Map OVRInput Class Raw Mapping Example 
// Coster-Graphics 2024. https://timcoster.com
//          
//           ____                 ____ 
//        .'      '.           .'      '.
//       :  _       :         :       _  :
//      : :   :  Y   :       :   B  :   : :
//      :  '-'  X    :       :    A  '-'  :
//       :  =     _.:         :._     oo.:
//       : '---- /  |         | \  ----' :
//      .'      |_|/           \|_|       '.
//      :       :                 :        :
//      '      :                   :       '
//     :     .'                     '.      :
//     '.___.                         .___.'
//
// Specific Quest Touch Controller Input Map using the OVRInput class
// Raw Mapping Controllers Example
//
// The raw mapping directly exposes the controllers. 
// The layout of the controllers closely matches the layout
// of a typical gamepad split across the left and right hands.
//
// Buttons
// OVRInput.RawButton.A                     = Raw Button A
// OVRInput.RawButton.B                     = Raw Button B
// OVRInput.RawButton.X                     = Raw Button X
// OVRInput.RawButton.Y                     = Raw Button Y
// OVRInput.RawButton.Start                 = Raw Button Start
// OVRInput.RawButton.LThumbstick           = Raw Button Thumbstick Left
// OVRInput.RawButton.RThumbstick           = Raw Button Thumbstick Right
//
// Axes 
//   Axes Thumbsticks
// OVRInput.RawAxis2D.LThumbstick           = Axis2D (Vector2) Raw Thumbstick Left
// OVRInput.RawAxis2D.RThumbstick           = Axis2D (Vector2) Raw Thumbstick Right
//
//   Axes Triggers
// OVRInput.RawAxis1D.LIndexTrigger         = Axis1D (float) Raw Trigger Left
// OVRInput.RawAxis1D.RIndexTrigger         = Axis1D (float) Raw Trigger Right
//
//   Axes Hand/Grip Triggers
// OVRInput.RawAxis1D.LHandTrigger          = Axis1D (float) Raw Hand Trigger Left
// OVRInput.RawAxis1D.RHandTrigger          = Axis1D (float) Raw Hand Trigger Right
//
// Touches
//   Button Touches
// OVRInput.RawTouch.A                      = Raw Touch Button A
// OVRInput.RawTouch.B                      = Raw Touch Button B
// OVRInput.RawTouch.X                      = Raw Touch Button X
// OVRInput.RawTouch.Y                      = Raw Touch Button Y
//
//   Trigger Touches
// OVRInput.RawTouch.LIndexTrigger          = Raw Touch Trigger Left
// OVRInput.RawTouch.RIndexTrigger          = Raw Touch Trigger Right
//
//   Thumbstick Touches
// OVRInput.RawTouch.LThumbstick            = Raw Touch Thumbstick Left
// OVRInput.RawTouch.RThumbstick            = Raw Touch Thumbstick Right
// 
//   Thumbrest Touches
// OVRInput.RawTouch.LThumbRest             = Raw Touch Thumb Rest Left
// OVRInput.RawTouch.RThumbRest             = Raw Touch Thumb Rest Right
//
// Near Touches
//   Thumb Buttons Near Touches
// OVRInput.RawNearTouch.LThumbButtons       = Raw Near Touch Thumb Buttons Left
// OVRInput.RawNearTouch.RThumbButtons       = Raw Near Touch Thumb Buttons Right
//
//   Triggers Near Touches
// OVRInput.RawNearTouch.LIndexTrigger = Raw Near Touch Trigger Left
// OVRInput.RawNearTouch.RIndexTrigger = Raw Near Touch Trigger Right
//
// Links
// https://developer.oculus.com/documentation/unity/unity-ovrinput/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class QuestTouchControllerInputMapOVRInputRaw: MonoBehaviour
{
    void Update()
    {
        // Requirements
        // -Include an instance of OVRManger anywhere in your scene.
        // -Call OVRInput.Update() and OVRInput.FixedUpdate() once per frame at the beginning of any component’s 
        //  Update and FixedUpdate methods, respectively.
        OVRInput.Update();

        // Buttons
        if(OVRInput.Get(OVRInput.RawButton.A))
            Debug.Log("Raw Button A = " + OVRInput.Get(OVRInput.RawButton.A));
        if(OVRInput.Get(OVRInput.RawButton.B))
            Debug.Log("Raw Button B = " + OVRInput.Get(OVRInput.RawButton.B));
        if(OVRInput.Get(OVRInput.RawButton.X))
            Debug.Log("Raw Button X = " + OVRInput.Get(OVRInput.RawButton.X));
        if(OVRInput.Get(OVRInput.RawButton.Y))
            Debug.Log("Raw Button Y = " + OVRInput.Get(OVRInput.RawButton.Y));

        if(OVRInput.Get(OVRInput.RawButton.Start))
            Debug.Log("Raw Button Start = " + OVRInput.Get(OVRInput.RawButton.Start));

        if(OVRInput.Get(OVRInput.RawButton.LThumbstick))
            Debug.Log("Raw Button Left Thumbstick LThumbstick = " + OVRInput.Get(OVRInput.RawButton.LThumbstick));
        if(OVRInput.Get(OVRInput.RawButton.RThumbstick))
            Debug.Log("Raw Button Right Thumbstick RThumbstick = " + OVRInput.Get(OVRInput.RawButton.RThumbstick));

        // Axes
            // Axes ThumbSticks
        if(OVRInput.Get(OVRInput.RawAxis2D.LThumbstick).x != 0)
            Debug.Log("Raw Thumbstick Left LThumbstick Horizontal = " + OVRInput.Get(OVRInput.RawAxis2D.LThumbstick).x);
        if(OVRInput.Get(OVRInput.RawAxis2D.LThumbstick).y != 0)
            Debug.Log("Raw Thumbstick Left LThumbstick Vertical = " + OVRInput.Get(OVRInput.RawAxis2D.LThumbstick).y);

        if(OVRInput.Get(OVRInput.RawAxis2D.RThumbstick).x != 0 )
            Debug.Log("Raw Thumbstick Right RThumbstick Horizontal = " + OVRInput.Get(OVRInput.RawAxis2D.RThumbstick).x);
        if(OVRInput.Get(OVRInput.RawAxis2D.RThumbstick).y != 0 )
            Debug.Log("Raw Thumbstick Right RThumbstick Vertical = " + OVRInput.Get(OVRInput.RawAxis2D.RThumbstick).y);

            // Axes Triggers
        if(OVRInput.Get(OVRInput.RawAxis1D.LIndexTrigger) > 0 )
            Debug.Log("Raw Trigger Left LIndexTrigger = " + OVRInput.Get(OVRInput.RawAxis1D.LIndexTrigger));
        if(OVRInput.Get(OVRInput.RawAxis1D.RIndexTrigger) > 0 )
            Debug.Log("Raw Trigger Right RIndexTrigger = " + OVRInput.Get(OVRInput.RawAxis1D.RIndexTrigger));

            // Axes Hand/Grip Triggers
        if(OVRInput.Get(OVRInput.RawAxis1D.LHandTrigger) > 0 )
            Debug.Log("Raw Trigger Left LHandTrigger = " + OVRInput.Get(OVRInput.RawAxis1D.LHandTrigger));
        if(OVRInput.Get(OVRInput.RawAxis1D.RHandTrigger) > 0 )
            Debug.Log("Raw Trigger Right RHandTrigger = " + OVRInput.Get(OVRInput.RawAxis1D.RHandTrigger));

        // Touches
            // Button Touches
        if(OVRInput.Get(OVRInput.RawTouch.A))
            Debug.Log("Raw Touch Button A = " + OVRInput.RawTouch.A);
        if(OVRInput.Get(OVRInput.RawTouch.B))
            Debug.Log("Raw Touch Button B = " + OVRInput.RawTouch.B);
        if(OVRInput.Get(OVRInput.RawTouch.X))
            Debug.Log("Raw Touch Button X = " + OVRInput.RawTouch.X);
        if(OVRInput.Get(OVRInput.RawTouch.Y))
            Debug.Log("Raw Touch Button Y = " + OVRInput.RawTouch.Y);
            // Trigger Touches
        if(OVRInput.Get(OVRInput.RawTouch.LIndexTrigger))
            Debug.Log("Raw Touch Trigger Left LIndexTrigger = " + OVRInput.Get(OVRInput.RawTouch.LIndexTrigger));
        if(OVRInput.Get(OVRInput.RawTouch.RIndexTrigger))
            Debug.Log("Raw Touch Trigger Right RIndexTrigger = " + OVRInput.Get(OVRInput.RawTouch.RIndexTrigger));
            // Thumbstick Touches
        if(OVRInput.Get(OVRInput.RawTouch.LThumbstick))
            Debug.Log("Raw Touch Thumbstick Left LThumbstick = " + OVRInput.RawTouch.LThumbstick);
        if(OVRInput.Get(OVRInput.RawTouch.RThumbstick))
            Debug.Log("Raw Touch Thumbstick Right RThumbstick = " + OVRInput.RawTouch.RThumbstick);
            // Thumbrest Touches
        if(OVRInput.Get(OVRInput.RawTouch.LThumbRest))
            Debug.Log("Raw Touch Thumb Rest Left LThumbRest = " + OVRInput.Get(OVRInput.RawTouch.LThumbRest));
        if(OVRInput.Get(OVRInput.RawTouch.RThumbRest))
            Debug.Log("Raw Touch Thumb Rest Right RThumbRest = " + OVRInput.Get(OVRInput.RawTouch.RThumbRest));

        // Near Touches
            // Thumb Buttons Near Touches
        if(OVRInput.Get(OVRInput.RawNearTouch.LThumbButtons))
            Debug.Log("Raw Near Touch LThumbButtons = " + OVRInput.Get(OVRInput.RawNearTouch.LThumbButtons));
        if(OVRInput.Get(OVRInput.RawNearTouch.RThumbButtons))
            Debug.Log("Raw Near Touch RThumbButtons = " + OVRInput.Get(OVRInput.RawNearTouch.RThumbButtons));
            // Triggers Near Touches
        if(OVRInput.Get(OVRInput.RawNearTouch.LIndexTrigger))
            Debug.Log("Raw Near Touch LIndexTrigger = " + OVRInput.Get(OVRInput.RawNearTouch.LIndexTrigger));
        if(OVRInput.Get(OVRInput.RawNearTouch.RIndexTrigger))
            Debug.Log("Raw Near Touch RIndexTrigger = " + OVRInput.Get(OVRInput.RawNearTouch.RIndexTrigger));
    }
}
Links

Unity Input System Package Manual / Introduction
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/index.html
Unity Input System Package Manual / Introduction / Workflows
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Workflows.html
Unity Input System Package Manual / Introduction / Workflows / Workflow Direct
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Workflow-Direct.html
Unity Input System Package Manual / Supported Input Devices
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/SupportedDevices.html
Unity Input System Package Manual / Supported Input Devices / Gamepad Support
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Gamepad.html

Unity Input System Package Scripting API /  Gamepad Class
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.Gamepad.html
Unity Input System Package Scripting API /  Gamepad : DualShockGamepad Class
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.DualShock.DualShockGamepad.html
Unity Input System Package Scripting API/ Gamepad : DualShockGamepad : DualShock4GamepadHID Class
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.DualShock.DualShock4GamepadHID.html
Unity Input System Package Scripting API/ Gamepad : DualShockGamepad : DualSenseGamepadHID Class
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.DualShock.DualSenseGamepadHID.html

Meta Quest Developer Resources
https://developer.oculus.com/resources/
Meta Quest Documentation / Unity / Get Started / Overview
https://developer.oculus.com/documentation/unity/unity-gs-overview/
Meta Quest Documentation / Unity / Controllers / Overview
https://developer.oculus.com/documentation/unity/unity-ovrinput/

Meta Quest Documentation / Unity / API Reference / OVRInput
https://developer.oculus.com/reference/unity/v60/class_o_v_r_input

Mapping a PS4 controller using the legacy Input Manager

Below you can find two button maps for the PS4 DS controller to use with the old legacy Unity Input class and the built-in Input Manager.
Mapping the PS4 controller using the old input system is a seriously confusing and very unintuitive process so I decided to post the button maps here for future reference in the hopes that I won’t have to figure this out all over again in the future, and to maybe save some other people from having to go trough the annoying process of finding out by trial and error why the input received from some of the PS4 controller’s buttons and axes seems to be totally unpredictable and change just when you thought you’d figured it out.
As it turns out, some of the controllers joystick axes assigned in the Input Manager are different when the controller is connected to your (Windows) machine with the USB cable than they are when the controller is connected over Bluetooth, so keep in mind that if you want to use the PS4 controller and the legacy input class then either setup your axes in the Input Manager window for using the controller with only USB or only Bluetooth connection or setup separate axes for USB and Bluetooth.
When the PS4 controller is connected both by USB cable and by Bluetooth at the same time then Unity will detect two separate controllers and things get really funky so make sure to, only connect by USB only:
by plugging in the cable and by not pressing the PS button (No light will shine from the light bar or orange light will shine to indicate that it is charging),
or by Bluetooth only:
by not connecting the USB cable and by pressing the PS button to connect trough Bluetooth (dim white light will shine from the light bar indicating that it is connected over Bluetooth).
Make the USB wired or Bluetooth connection before launching the Unity editor or relaunch Unity after you switch from a cable to a wireless connection and vise versa, or Unity might get the axes all mixed up.

My advice is to not use the legacy built-in Input class but to use the new Input System package instead, because it is a lot easier and quicker to setup, once you know how, and it is a lot more flexible and dynamic. So then why do I post this here you ask?.. Well I guess I just needed some closure on this.. And for legacy reasons of course!

Setting up the Input Manager Axes

To setup the Input Manager Axes for use with the PS4 gamepad over USB automatically you can download the Input Manager preset files listed below the debug scripts. Simply add the preset files to your project, go to Project Settings > Input Manager and click on the select preset button in the top right to setup the Input Manager with preset axes.

If you want to add the axes to the Input Manager in your project manually yourself then keep in mind that the Vertical axes for the left and right thumbstick should be inverted, so that pushing them up returns a positive value instead of a negative value.

Also know that the left and right L2 and R2 triggers can be used both as Boolean buttons that return true when pulled almost all the way in, or they can be used as analog triggers that return a float value depending on how far they’re pressed.

Important: When using the triggers as analog trigger axes, L2 and R2 return a value going from -1 to 1 instead of going from 0 to 1 (which would make a lot more sense), so you’ll have to remap the -1 to 1 range to a workable 0 to 1 range in your controller scripts yourself, which can be done by simply multiplying the return value of the trigger axes by 0.5 and then adding 0.5, or by using the Mathf.InverseLerp() function like so:

float throttleInputAxis;
float brakeInputAxis;

void Update()
{
	throttleInputAxis = Mathf.InverseLerp(-1,1f,Input.GetAxis("Trigger R2"));
	brakeInputAxis    = Input.GetAxis("Trigger L2") * 0.5f + 0.5f;
}

Another thing to take in account is that when you click outside of the Game view in Unity during play testing all of the axes will be reset to 0 which is fine because usually axes are neutral in 0 but this will cause the triggers to return 0.5 when their return values are remapped, so it is best to check with the Application.IsFocused bool if the Game view has focus and set the triggers to 0 if it hasn’t, like so:

float steerInputAxis;
float throttleInputAxis;
float brakeInputAxis;
bool handBrakeButton;

void Update()
{
    steerInputAxis = Input.GetAxis("Thumbstick Left Horizontal");

	if(Application.isFocused) {
		throttleInputAxis = Mathf.InverseLerp(-1,1f,Input.GetAxis("Trigger R2"));
	    brakeInputAxis = Mathf.InverseLerp(-1,1f, Input.GetAxis("Trigger L2"));
	} else {
		throttleInputAxis = 0;
		brakeInputAxis = 0;
	}
	
    handBrakeButton = Input.GetButton("Button Cross");
}

The scripts below can be used as a reference map and also to test the Input from the PS4 controller. Simply attach the script to a GameObject in your scene to get debug messages in the Console view with the input values from the controller.

Specific PlayStation DualShock4 controller input mapping using the Legacy Input class Examples
DualShock4HID Controller Input Map (legacy Input class: USB Example)

PS4ControllerInputMapUSB.cs

//           ____                       ____
//          |____|                     |____|
//        .'  _   '._________________.'      '.
//       :  _| |_   :▯|          |▯:    △    :
//      :  |_ X _|   : |__________|:   ◻    O  :
//      :     _|     :     \ /     :      X     :
//       :.      .--:       O       :--.      .:
//       : '----:    :_____________:    :----' :
//      .'      '.__.'             '.__.'      '.
//      :       :                       :       :
//      '      :                         :      '
//     :     .'                           '.     :
//     '.___.                               .___.'
//            PS4 Controller Map (Over USB)
//
// Buttons
// joystick button 0    = Button Square     = West 
// joystick button 1    = Button Cross      = South
// joystick button 2    = Button Circle     = East
// joystick button 3    = Button Triangle   = North
// Joystick button 4    = Button L1         = Left Shoulder
// Joystick button 5    = Button R1         = Right Shoulder
// Joystick button 6    = Button L2         = Left Trigger as Button
// Joystick button 7    = Button R2         = Right Trigger as Button		
// Joystick button 8    = Share Button
// Joystick button 9    = Options Button
// Joystick button 10   = Button L3         = Left Thumbstick Button
// Joystick button 11   = Button R3         = Right Thumbstick Button
// Joystick button 12   = Button PS         = Playstation Button
// Joystick button 13   = Button Touchpad

// Thumbsticks
// X axis   = Left Thumbstick "Horizontal"
// Y axis   = Left Thumbstick "Vertical"
// 3rd axis = Right Thumbstick "Horizontal"
// 6th axis = Right Thumbstick "Vertical"

// Triggers as Axis
// 4th axis = Trigger L2 = Left Trigger as Axis  = Range -1.0 to 1.0
// 5th axis = Trigger R2 = Right Trigger as Axis = Range -1.0 to 1.0

// D-Pad as Axis
// 7th Axis = D-Pad Horizontal  = Directional pad buttons Left and Right as Axis. Left = -1 and right = 1
// 8th axis = D-Pad Vertical    = Directional pad buttons Up and Down as Axis. Up = 1 and Down = -1

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PS4ControllerInputMapUSB : MonoBehaviour
{
    void Update()
    {
        if (Input.GetButtonDown("Button Square"))
            Debug.Log("Button Square");
        if (Input.GetButtonDown("Button Cross"))
            Debug.Log("Button Cross");
        if (Input.GetButtonDown("Button Circle"))
            Debug.Log("Button Circle");
        if (Input.GetButtonDown("Button Triangle"))
            Debug.Log("Button Triangle");

        if (Input.GetButtonDown("Button L1"))
            Debug.Log("Button L1");
        if (Input.GetButtonDown("Button R1"))
            Debug.Log("Button R1");
        if (Input.GetButtonDown("Button L2"))
            Debug.Log("Button L2");
        if (Input.GetButtonDown("Button R2"))
            Debug.Log("Button R2");

        if (Input.GetButtonDown("Button Share"))
            Debug.Log("Button Share");
        if (Input.GetButtonDown("Button Options"))
            Debug.Log("Button Options");

        if (Input.GetButtonDown("Button L3"))
            Debug.Log("Button L3");
        if (Input.GetButtonDown("Button R3"))
            Debug.Log("Button R3");

        if (Input.GetButtonDown("Button PS"))
            Debug.Log("Button PS");
        if (Input.GetButtonDown("Button Touchpad"))
            Debug.Log("Button Touchpad");

        if (Input.GetAxis("Thumbstick Left Horizontal") != 0)
            Debug.Log("Thumbstick Left Horizontal = " + Input.GetAxis("Thumbstick Left Horizontal"));
        if (Input.GetAxis("Thumbstick Left Vertical") != 0)
            Debug.Log("Thumbstick Left Vertical = " + Input.GetAxis("Thumbstick Left Vertical"));
        if (Input.GetAxis("Thumbstick Right Horizontal") != 0)
            Debug.Log("Thumbstick Right Horizontal = " + Input.GetAxis("Thumbstick Right Horizontal"));
        if (Input.GetAxis("Thumbstick Right Vertical") != 0)
            Debug.Log("Thumbstick Right Vertical = " + Input.GetAxis("Thumbstick Right Vertical"));

        if (Input.GetAxis("Trigger L2") != -1)
            Debug.Log("Trigger L2 = " + Input.GetAxis("Trigger L2"));
        if (Input.GetAxis("Trigger R2") != -1)
            Debug.Log("Trigger R2: " + Input.GetAxis("Trigger R2"));
        if (Input.GetAxis("D-Pad Horizontal") != 0)
            Debug.Log("D-Pad Horizontal: " + Input.GetAxis("D-Pad Horizontal"));
        if (Input.GetAxis("D-Pad Vertical") != 0)
            Debug.Log("D-Pad Vertical: " + Input.GetAxis("D-Pad Vertical"));
    }
}

InputManagerPreset-PS4ControllerUSB.preset

DualShock4HID Controller Input Map (legacy Input class: Bluetooth Example)

PS4ControllerInputMapBluetooth.cs

//           ____                       ____
//          |____|                     |____|
//        .'  _   '._________________.'      '.
//       :  _| |_   :▯|          |▯:    △    :
//      :  |_   _|   : |__________|:   ◻    O  :
//      :     _|     :     \_/     :      X     :
//       :.      .--:       O       :--.      .:
//       : '----:    :_____________:    :----' :
//      .'      '.__.'             '.__.'      '.
//      :       :                       :       :
//      '      :                         :      '
//     :     .'                           '.     :
//     '.___.                               .___.'
//         PS4 Controller Map (Over Bluetooth)
//
// Buttons
// joystick button 0    = Button Square     = West 
// joystick button 1    = Button Cross      = South
// joystick button 2    = Button Circle     = East
// joystick button 3    = Button Triangle   = North
// Joystick button 4    = Button L1         = Left Shoulder
// Joystick button 5    = Button R1         = Right Shoulder
// Joystick button 6    = Button L2         = Left Trigger as Button
// Joystick button 7    = Button R2         = Right Trigger as Button		
// Joystick button 8    = Share Button
// Joystick button 9    = Options Button
// Joystick button 10   = Button L3         = Left Thumbstick Button
// Joystick button 11   = Button R3         = Right Thumbstick Button
// Joystick button 12   = Button PS         = Playstation Button
// Joystick button 13   = Button Touchpad

// Thumbsticks
// X axis   = Left Thumbstick "Horizontal"
// 3d axis  = Left Thumbstick "Vertical"
// 4th axis = Right Thumbstick "Horizontal"
// 7th axis = Right Thumbstick "Vertical"

// Triggers as Axis
// 5th axis = Trigger L2 = Left Trigger as Axis  = Range -1.0 to 1.0
// 6th axis = Trigger R2 = Right Trigger as Axis = Range -1.0 to 1.0

// D-Pad as Axis
// 8th Axis = D-Pad Horizontal  = Directional pad buttons Left and Right as Axis. Left = -1 and right = 1
// 9th axis = D-Pad Vertical    = Directional pad buttons Up and Down as Axis. Up = 1 and Down = -1

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PS4ControllerInputMapBluetooth : MonoBehaviour 
{
    void Update()
    {
        if(Input.GetButtonDown("Button Square"))
            Debug.Log("Button Square");
        if(Input.GetButtonDown("Button Cross"))
            Debug.Log("Button Cross");
        if(Input.GetButtonDown("Button Circle"))
            Debug.Log("Button Circle");
        if(Input.GetButtonDown("Button Triangle"))
            Debug.Log("Button Triangle");

        if(Input.GetButtonDown("Button L1"))
            Debug.Log("Button L1");
        if(Input.GetButtonDown("Button R1"))
            Debug.Log("Button R1");
        if(Input.GetButtonDown("Button L2"))
            Debug.Log("Button L2");
        if(Input.GetButtonDown("Button R2"))
            Debug.Log("Button R2");

        if(Input.GetButtonDown("Button Share"))
            Debug.Log("Button Share");
        if(Input.GetButtonDown("Button Options"))
            Debug.Log("Button Options");

        if(Input.GetButtonDown("Button L3"))
            Debug.Log("Button L3");
        if(Input.GetButtonDown("Button R3"))
            Debug.Log("Button R3");

        if(Input.GetButtonDown("Button PS"))
            Debug.Log("Button PS");
        if(Input.GetButtonDown("Button Touchpad"))
            Debug.Log("Button Touchpad");

        if(Input.GetAxis("Thumbstick Left Horizontal") != 0)
            Debug.Log("Thumbstick Left Horizontal = " + Input.GetAxis("Thumbstick Left Horizontal"));
        if(Input.GetAxis("Thumbstick Left Vertical") != 0)
            Debug.Log("Thumbstick Left Vertical = " + Input.GetAxis("Thumbstick Left Vertical"));
        if(Input.GetAxis("Thumbstick Right Horizontal") != 0)
            Debug.Log("Thumbstick Right Horizontal = " +  Input.GetAxis("Thumbstick Right Horizontal"));
        if(Input.GetAxis("Thumbstick Right Vertical") != 0)
            Debug.Log("Thumbstick Right Vertical = " +  Input.GetAxis("Thumbstick Right Vertical"));
        
        if(Input.GetAxis("Trigger L2") != -1)
            Debug.Log("Trigger L2 = " + Input.GetAxis("Trigger L2"));
        if(Input.GetAxis("Trigger R2") != -1)
            Debug.Log("Trigger R2: " + Input.GetAxis("Trigger R2"));
        if(Input.GetAxis("D-Pad Horizontal") != 0)
            Debug.Log("D-Pad Horizontal: " + Input.GetAxis("D-Pad Horizontal"));
        if(Input.GetAxis("D-Pad Vertical") != 0)
            Debug.Log("D-Pad Vertical: " + Input.GetAxis("D-Pad Vertical"));
    }
}

InputManagerPreset-PS4ControllerBluetooth.preset

BUY ME A COFFEE

Donate $5 to buy me a coffee so I have the fuel I need to keep producing great tutorials!

$5.00