TypeScript library for configuring and controlling FFBeast force feedback wheel controllers from the browser over WebHID. It is a port of FFBeast's C++ API, which is kept in reference-cpp.
npm i @shubham0x13/ffbeast-wheel-webhid-api
import { SettingField, WheelApi } from "@shubham0x13/ffbeast-wheel-webhid-api";
const wheel = new WheelApi();
wheel.on("deviceConnected", async () => {
const settings = await wheel.readAllSettings();
console.log("Motion range:", settings.effects.motionRange);
await wheel.sendSetting(SettingField.MotionRange, 0, 900);
});
wheel.on("stateReceived", (state) => {
console.log("Position:", state.positionDegrees);
console.log("Torque:", state.torqueNormalized);
});
// Reconnect to a previously authorized wheel without a prompt.
const reconnected = await wheel.tryAutoConnect();
// Otherwise, open the browser's device picker from a user action.
if (!reconnected) {
connectButton.addEventListener("click", () => {
wheel.connect().catch(console.error);
});
}
// Later, for example when the page or component unmounts.
// destroy() also disconnects.
await wheel.destroy();
The API reference covers every method, event, setting and type. Release notes are in CHANGELOG.md.
localhost (WebHID requires a secure context)| Browser | Supported |
|---|---|
| Chrome, Brave, Edge and other Chromium-based (desktop) | Yes |
| Firefox | No |
| Safari | No |
Issues and pull requests are welcome. See CONTRIBUTING.md for development instructions.
This project is licensed under the MIT License.