docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Get information about devices

    Find out which input devices are connected, get a specific device, and read the information that identifies a device, such as its name, layout, and manufacturer.

    Use this information to decide how to respond to a device, for example to show the device's name in your UI, or to handle a specific manufacturer's controller differently. If you only need to read the values of a device's controls, refer to Read devices directly.

    List connected devices

    To list connected devices, do one of the following:

    • To list all currently connected devices, use InputSystem.devices.
    • To list only the devices of one type, use the all property of that type, such as Gamepad.all:
    // List every connected device.
    foreach (var device in InputSystem.devices)
        Debug.Log(device.name);
    
    // List only the connected gamepads.
    foreach (var gamepad in Gamepad.all)
        Debug.Log(gamepad.name);
    

    Don't keep the array that InputSystem.devices returns. The array can become invalid when devices are added or removed, so query the property each time you need it. To find out when devices are added or removed, refer to Monitor devices.

    Get a specific device

    To get a specific device, use one of the methods in the following table. Each method returns null if no matching device exists.

    Device Method
    The most recently used or connected device of that type. The current property of the type, such as Gamepad.current. Only some device types have this property.
    The device of any type that received input most recently InputSystem.GetDevice<TDevice>(). Works with any device type, including your own.
    A device by its name or layout InputSystem.GetDevice(string).
    A device by its ID InputSystem.GetDeviceById.
    // The gamepad that was used or connected most recently.
    var gamepad = Gamepad.current;
    
    // The pointer device (mouse, pen, or touchscreen) that received input most recently.
    var pointer = InputSystem.GetDevice<Pointer>();
    
    // The device whose name or layout is "Keyboard".
    var keyboard = InputSystem.GetDevice("Keyboard");
    
    // The device with the given ID.
    var device = InputSystem.GetDeviceById(deviceId);
    

    To find the device that a player is using, refer to Find the device a player is using.

    Read device information

    To read the information that identifies a device, use the properties of InputDevice:

    Debug.Log($"Name: {device.name}");
    Debug.Log($"Display name: {device.displayName}");
    Debug.Log($"Layout: {device.layout}");
    Debug.Log($"ID: {device.deviceId}");
    Debug.Log($"Product: {device.description.product}");
    Debug.Log($"Manufacturer: {device.description.manufacturer}");
    Debug.Log($"Interface: {device.description.interfaceName}");
    Debug.Log($"Usages: {string.Join(", ", device.usages)}");
    Debug.Log($"Native: {device.native}");
    Debug.Log($"Enabled: {device.enabled}");
    Debug.Log($"Last update time: {device.lastUpdateTime}");
    

    The following table describes the properties:

    Property Description
    name The name of the device. If several devices have the same name, the Input System adds a number to make each name unique.
    displayName A human-readable name for the device, for example to show in your UI.
    layout The name of the layout that the Input System created the device from.
    deviceId The unique ID of the device. The Input System doesn't reuse IDs in a session. For more information, refer to Device IDs.
    description The information that the device reported when the Input System discovered it, such as its product name, manufacturer, and interface. For more information, refer to Device descriptions.
    usages The usages assigned to the device, such as LeftHand. For more information, refer to Device usages.
    native Whether the device comes from the native backend (true) or was created in code (false). For more information, refer to Native devices.
    enabled Whether the device is enabled and receives input. For more information, refer to Enable and disable devices.
    lastUpdateTime The timestamp of the last state event that updated the device. The timeline resets to 0 when you enter Play mode.

    Additional resources

    • Monitor devices
    • Read devices directly
    • Debug a device
    • Devices (scripting)
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)