dualsense-ts
Version:
The natural interface for your DualSense and DualSense Access controllers, with Typescript
56 lines • 2.2 kB
TypeScript
/**
* Audio device matching utilities for the DualSense controller.
*
* The DualSense registers as a USB Audio Class device (speaker + microphone)
* when connected over USB. These utilities help locate the corresponding
* audio devices in the Web Audio API or native audio libraries.
*
* Note: Audio devices are only available over USB, not Bluetooth.
*/
/** USB Vendor ID for Sony Interactive Entertainment */
export declare const DUALSENSE_AUDIO_VENDOR_ID = 1356;
/** USB Product ID for the DualSense controller */
export declare const DUALSENSE_AUDIO_PRODUCT_ID = 3302;
/**
* Known device label patterns for DualSense audio devices across platforms.
* Browser `enumerateDevices()` labels vary by OS:
* - Windows: "Wireless Controller"
* - macOS: "Wireless Controller"
* - Linux: "Wireless Controller" or "Sony Interactive Entertainment Wireless Controller"
*/
export declare const DUALSENSE_AUDIO_LABELS: readonly ["Wireless Controller", "DualSense"];
/** Filtered result from audio device enumeration */
export interface DualsenseAudioDevices {
/** Audio output devices (speaker/headphone) */
outputs: MediaDeviceInfo[];
/** Audio input devices (microphone) */
inputs: MediaDeviceInfo[];
}
/**
* Find DualSense audio devices using the Web Audio API.
*
* Requires `navigator.mediaDevices` (browser only). Returns matching
* audio input and output devices based on known label patterns.
*
* Note: Device labels may be empty until the user grants microphone
* or camera permission via `getUserMedia()`.
*
* @example
* ```typescript
* import { findDualsenseAudioDevices } from "dualsense-ts";
*
* const { outputs, inputs } = await findDualsenseAudioDevices();
* if (outputs.length > 0) {
* const ctx = new AudioContext({ sinkId: outputs[0].deviceId });
* // Route audio to the controller's speaker
* }
* if (inputs.length > 0) {
* const stream = await navigator.mediaDevices.getUserMedia({
* audio: { deviceId: { exact: inputs[0].deviceId } },
* });
* // Capture from the controller's microphone
* }
* ```
*/
export declare function findDualsenseAudioDevices(): Promise<DualsenseAudioDevices>;
//# sourceMappingURL=audio.d.ts.map