@shubham0x13/ffbeast-wheel-webhid-api 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +46 -37
  2. package/dist/index.d.ts +216 -173
  3. package/dist/index.js +665 -439
  4. package/package.json +20 -29
package/README.md CHANGED
@@ -1,33 +1,18 @@
1
1
  # FFBeast Wheel WebHID API
2
2
 
3
- A TypeScript WebHID-based API for communicating with [FFBeast](https://ffbeast.github.io/) force feedback wheel controllers directly from the browser.
3
+ [![Build Status](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/actions/workflows/ci.yml/badge.svg)](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/actions)
4
+ [![Documentation](https://img.shields.io/badge/docs-online-blue)](https://shubham0x13.github.io/ffbeast-wheel-webhid-api/)
5
+ [![NPM Version](https://img.shields.io/npm/v/@shubham0x13/ffbeast-wheel-webhid-api)](https://www.npmjs.com/package/@shubham0x13/ffbeast-wheel-webhid-api)
6
+ [![License](https://img.shields.io/npm/l/@shubham0x13/ffbeast-wheel-webhid-api)](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/blob/main/LICENSE)
4
7
 
5
- This library is a TypeScript rewrite of the original C/C++ API, adapted to use the [WebHID API](https://developer.mozilla.org/en-US/docs/Web/API/WebHID_API) for browser-based applications. The original C/C++ source code is available in the [`reference_cpp`](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/tree/main/reference_cpp) directory for reference.
6
-
7
- > **Note:** This API includes additional helper methods and properties not present in the original C/C++ implementation, such as `readAllSettings()`, `positionDegrees`, `torqueNormalized`, and more for convenience.
8
+ TypeScript library for configuring and controlling [FFBeast](https://ffbeast.github.io/) force feedback wheel controllers from the browser over [WebHID](https://developer.mozilla.org/en-US/docs/Web/API/WebHID_API). It is a port of FFBeast's C++ API, which is kept in [`reference-cpp`](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/tree/main/reference-cpp).
8
9
 
9
10
  ## Features
10
11
 
11
- - 🎮 **Direct wheel communication** via WebHID (no drivers or native apps required)
12
- - 📊 **Real-time device state** - position, torque, firmware version
13
- - ⚙️ **Full settings control** - effect settings, hardware settings, GPIO, ADC configurations
14
- - 🔧 **Direct force feedback control** - spring, constant, and periodic forces
15
- - 📡 **Event-driven architecture** - subscribe to device state changes
16
- - 🔒 **Type-safe** - full TypeScript support with comprehensive types
17
-
18
- ## Documentation
19
-
20
- 📚 **[Full API Documentation](https://shubham0x13.github.io/ffbeast-wheel-webhid-api/)**
21
-
22
- ## Browser Support
23
-
24
- > **Note:** Supported in all modern Chromium-based browsers (e.g., Chrome, Edge, Opera, Brave, etc).
25
-
26
- | Browser | Supported |
27
- | -------------- | --------- |
28
- | Chromium-based | ✅ |
29
- | Firefox | ❌ |
30
- | Safari | ❌ |
12
+ - Read effect, hardware, GPIO, ADC and license settings, and write individual settings
13
+ - Receive the wheel position and torque in real time
14
+ - Send direct force feedback control
15
+ - Save settings, reboot, reset the wheel center, switch to DFU mode and activate the firmware
31
16
 
32
17
  ## Installation
33
18
 
@@ -35,36 +20,60 @@ This library is a TypeScript rewrite of the original C/C++ API, adapted to use t
35
20
  npm i @shubham0x13/ffbeast-wheel-webhid-api
36
21
  ```
37
22
 
38
- ## Quick Start
23
+ ## Usage
39
24
 
40
25
  ```typescript
41
- import { WheelApi } from "@shubham0x13/ffbeast-wheel-webhid-api";
26
+ import { SettingField, WheelApi } from "@shubham0x13/ffbeast-wheel-webhid-api";
42
27
 
43
28
  const wheel = new WheelApi();
44
29
 
30
+ wheel.on("deviceConnected", async () => {
31
+ const settings = await wheel.readAllSettings();
32
+ console.log("Motion range:", settings.effects.motionRange);
33
+
34
+ await wheel.sendSetting(SettingField.MotionRange, 0, 900);
35
+ });
36
+
45
37
  wheel.on("stateReceived", (state) => {
46
38
  console.log("Position:", state.positionDegrees);
47
39
  console.log("Torque:", state.torqueNormalized);
48
40
  });
49
41
 
50
- wheel.on("deviceConnected", (device) => {
51
- console.log("Connected to:", device.productName);
52
- });
42
+ // Reconnect to a previously authorized wheel without a prompt.
43
+ const reconnected = await wheel.tryAutoConnect();
53
44
 
54
- // Connect to the wheel (opens browser device picker)
55
- await wheel.connect();
45
+ // Otherwise, open the browser's device picker from a user action.
46
+ if (!reconnected) {
47
+ connectButton.addEventListener("click", () => {
48
+ wheel.connect().catch(console.error);
49
+ });
50
+ }
56
51
 
57
- // Cleanup when done
58
- await wheel.disconnect();
59
- wheel.destroy();
52
+ // Later, for example when the page or component unmounts.
53
+ // destroy() also disconnects.
54
+ await wheel.destroy();
60
55
  ```
61
56
 
57
+ ## Documentation
58
+
59
+ The [API reference](https://shubham0x13.github.io/ffbeast-wheel-webhid-api/) covers every method, event, setting and type. Release notes are in [CHANGELOG.md](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/blob/main/CHANGELOG.md).
60
+
62
61
  ## Requirements
63
62
 
64
- - Node.js >= 20.19.0
65
- - A Chromium-based browser with WebHID support
66
63
  - An FFBeast wheel controller
64
+ - A page served over HTTPS or from `localhost` (WebHID requires a secure context)
65
+ - A browser with WebHID support:
66
+
67
+ | Browser | Supported |
68
+ | ------------------------------------------------------ | --------- |
69
+ | Chrome, Brave, Edge and other Chromium-based (desktop) | Yes |
70
+ | Firefox | No |
71
+ | Safari | No |
72
+
73
+ ## Contributing
74
+
75
+ Issues and pull requests are welcome. See [CONTRIBUTING.md](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/blob/main/CONTRIBUTING.md) for development instructions.
67
76
 
68
77
  ## License
69
78
 
70
- This project is licensed under the [MIT License](./LICENSE)
79
+ This project is licensed under the [MIT License](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/blob/main/LICENSE).