@hcodes/webhid-ds4
    Preparing search index...

    Optional page-audio routing and playback. Listen for change, then call checkSupport again. Browser audio labels cannot establish which HID controller owns an output. Selection is explicit.

    Hierarchy

    • EventTarget
      • DualShock4Headphones
    Index
    • get outputDeviceId(): string | null

      Explicitly selected output, or null before successful routing/after invalidation.

      Returns string | null

    • get volumeLeft(): number | null

      Last requested left-channel HID volume (0-255), or null before configuration/after reset. This is a local cache, not a hardware readback or acknowledgement.

      Returns number | null

    • set volumeLeft(value: number): void

      Parameters

      • value: number

      Returns void

    • Route a live MediaStream to the selected headphone output, without buffering or decoding a file. Supply one audio track (mono or stereo). Call from a user action for autoplay permission. Resolves when connected, not when the stream ends. Replaces the previous stream. The caller owns the stream and its tracks; stop/reset/disconnect never stop them.

      Parameters

      • stream: MediaStream

      Returns Promise<void>

    • Call from a click. Uses the native output picker when available. Otherwise requests microphone permission to expose audio devices and immediately stops every capture track. Returns concrete outputs for user selection; it does not start playback or select a route.

      Returns Promise<MediaDeviceInfo[]>

    • Release playback, routing, pending volume promises and device listeners. A new selection is required.

      Returns void

    • Explicitly associate a concrete output with this controller. The caller/user establishes identity. Verifies routing without playing sound. Default/communications aliases are rejected. A failed change stops the old route and leaves playback disabled.

      Parameters

      • deviceId: string

      Returns Promise<void>

    • Set raw headphone HID volume bytes, independently of browser routing/playback. Right defaults to left. Finite values are clamped to 0-255 and rounded. Resolves when the HID report is sent; rejects on output failure or reset.

      Parameters

      • left: number
      • right: number = left

      Returns Promise<void>

    • Disconnect playback and cancel pending resume work, preserving the output and caller-owned tracks.

      Returns void