FFBeast Wheel WebHID API
    Preparing search index...

    Class WheelApi

    WebHID-based API for communicating with the wheel controller.

    import { WheelApi } from "@shubham0x13/ffbeast-wheel-webhid-api";

    const wheel = new WheelApi();

    wheel.on("stateReceived", (state) => {
    console.log("Position:", state.positionDegrees);
    });

    // The device picker must be opened from a user action.
    connectButton.addEventListener("click", () => {
    wheel.connect().catch(console.error);
    });

    // Later, for example when the page or component unmounts.
    // destroy() also disconnects.
    await wheel.destroy();

    Hierarchy

    Index
    prefixed: string | boolean
    • get firmwareReleaseType(): number | null

      Current firmware release type.

      Returns number | null

      Release type number, or null if no state has been received.

    • get firmwareVersion(): string | null

      Current firmware version string.

      Returns string | null

      Version string (e.g., "1.2.3"), or null if no state has been received.

    • get isConnected(): boolean

      Device connection status.

      Returns boolean

      true if connected and opened.

    • get positionDegrees(): number | null

      Current wheel position in degrees.

      Returns number | null

      Position in degrees, or null if no state has been received or the motion range is unknown.

    • get torqueNormalized(): number | null

      Current torque normalized to [-100, 100] range.

      Returns number | null

      Normalized torque, or null if no state has been received.

    • Type Parameters

      Parameters

      Returns this

    • Opens the browser's device picker to connect to a wheel.

      Returns Promise<boolean>

      true if a device was connected, false if the user closed the picker without selecting one.

      Must be called from a user gesture (e.g. a click handler), as required by navigator.hid.requestDevice(). If another wheel is already connected it is disconnected first.

      Error if the selected device could not be opened. The underlying DOMException is available as cause.

    • Cleans up all resources and event listeners. Must be called when the API instance is no longer needed.

      Returns Promise<void>

      A WheelApi.connect or WheelApi.tryAutoConnect call that is still pending rejects instead of connecting; destroy() resolves once it has finished.

    • Disconnects from the current device. A connection in progress finishes first.

      Returns Promise<void>

    • Calls each of the listeners registered for a given event.

      Type Parameters

      Parameters

      Returns boolean

    • Return an array listing the events for which the emitter has registered listeners.

      Returns (keyof WheelEvents)[]

    • Return the number of listeners listening to a given event.

      Parameters

      Returns number

    • Return the listeners registered for a given event.

      Type Parameters

      Parameters

      • event: T

      Returns ((...args: ArgumentMap<WheelEvents>[Extract<T, keyof WheelEvents>]) => void)[]

    • Type Parameters

      Parameters

      • event: T
      • Optionalfn: (...args: ArgumentMap<WheelEvents>[Extract<T, keyof WheelEvents>]) => void
      • Optionalcontext: any
      • Optionalonce: boolean

      Returns this

    • Add a listener for a given event.

      Type Parameters

      Parameters

      Returns this

    • Add a one-time listener for a given event.

      Type Parameters

      Parameters

      Returns this

    • Reboots the controller without saving settings.

      Returns Promise<void>

    • Remove all listeners, or those of the specified event.

      Parameters

      • Optionalevent: keyof WheelEvents

      Returns this

    • Remove the listeners of a given event.

      Type Parameters

      Parameters

      • event: T
      • Optionalfn: (...args: ArgumentMap<WheelEvents>[Extract<T, keyof WheelEvents>]) => void
      • Optionalcontext: any
      • Optionalonce: boolean

      Returns this

    • Sets the current wheel position as center.

      Returns Promise<void>

    • Saves the current settings to flash and reboots the controller. Settings that only apply on save take effect after the reboot.

      Returns Promise<void>

    • Sends direct force feedback control to the device.

      Parameters

      Returns Promise<void>

      Values are rounded to the nearest integer and clamped to their documented ranges.

      The device falls back to its default mode when direct control reports stop, so send them continuously while direct control is in use.

      Error if the device is not connected.

      RangeError if any value is not a finite number.

    • Sends the firmware activation key to the device. Nothing is sent if the device already reports itself as registered.

      Parameters

      • license: string

        Three hexadecimal segments separated by -, for example "0123ABCD-4567EF01-89ABCDEF".

      Returns Promise<void>

      The device then saves its settings and reboots, so it disconnects.

      Error if the device is not connected or the key is malformed.

    • Switches the device to DFU mode for firmware updates.

      Returns Promise<void>

    • Attempts to reconnect to a previously authorized device.

      Returns Promise<boolean>

      true if a device was found and connected, false if no previously authorized wheel is available.

      Error if the device was found but could not be opened. The underlying DOMException is available as cause.

    • Checks whether the current environment supports WebHID.

      Returns boolean

      false outside browsers (for example during server-side rendering) and in browsers without WebHID.