Skip to content

Discovery

discovery

Stream Deck device discovery via HID enumeration.

Enumerates connected Elgato HID devices filtered by a PID allowlist, returning :class:~deux.runtime.hid.device.HidDevice instances.

enumerate_devices

enumerate_devices() -> list[HidDevice]

Enumerate all connected and supported Stream Deck devices.

Scans for HID devices with Elgato's vendor ID (0x0FD9) and filters to the supported PID allowlist.

Returns:

Type Description
list[HidDevice]

List of :class:HidDevice instances (not yet opened).

Raises:

Type Description
HidApiError

If hidapi cannot be initialised or enumeration fails.

Source code in src/deux/runtime/hid/discovery.py
def enumerate_devices() -> list[HidDevice]:
    """Enumerate all connected and supported Stream Deck devices.

    Scans for HID devices with Elgato's vendor ID (``0x0FD9``) and
    filters to the supported PID allowlist.

    Returns
    -------
    list[HidDevice]
        List of :class:`HidDevice` instances (not yet opened).

    Raises
    ------
    HidApiError
        If ``hidapi`` cannot be initialised or enumeration fails.
    """
    _ensure_init()
    infos = hid_enumerate(vendor_id=ELGATO_VID, product_id=0)
    devices: list[HidDevice] = []
    for info in infos:
        if info.product_id in SUPPORTED_PIDS:
            devices.append(HidDevice(info))
    return devices

find_device_by_serial

find_device_by_serial(serial: str) -> HidDevice | None

Find a specific device by serial number.

Parameters:

Name Type Description Default
serial str

The device serial number to match.

required

Returns:

Type Description
HidDevice or None

The matching device (not yet opened), or None if not found.

Source code in src/deux/runtime/hid/discovery.py
def find_device_by_serial(serial: str) -> HidDevice | None:
    """Find a specific device by serial number.

    Parameters
    ----------
    serial : str
        The device serial number to match.

    Returns
    -------
    HidDevice or None
        The matching device (not yet opened), or ``None`` if not found.
    """
    for device in enumerate_devices():
        if device.serial_number == serial:
            return device
    return None

find_device_by_path

find_device_by_path(path: bytes) -> HidDevice | None

Find a specific device by OS device path.

Parameters:

Name Type Description Default
path bytes

The OS-specific HID device path.

required

Returns:

Type Description
HidDevice or None

The matching device (not yet opened), or None if not found.

Source code in src/deux/runtime/hid/discovery.py
def find_device_by_path(path: bytes) -> HidDevice | None:
    """Find a specific device by OS device path.

    Parameters
    ----------
    path : bytes
        The OS-specific HID device path.

    Returns
    -------
    HidDevice or None
        The matching device (not yet opened), or ``None`` if not found.
    """
    for device in enumerate_devices():
        if device.path == path:
            return device
    return None