@shubham0x13/ffbeast-wheel-webhid-api 0.1.0 → 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.
- package/README.md +47 -38
- package/dist/index.d.ts +216 -173
- package/dist/index.js +665 -439
- package/package.json +20 -29
package/README.md
CHANGED
|
@@ -1,70 +1,79 @@
|
|
|
1
1
|
# FFBeast Wheel WebHID API
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/actions)
|
|
4
|
+
[](https://shubham0x13.github.io/ffbeast-wheel-webhid-api/)
|
|
5
|
+
[](https://www.npmjs.com/package/@shubham0x13/ffbeast-wheel-webhid-api)
|
|
6
|
+
[](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/blob/main/LICENSE)
|
|
4
7
|
|
|
5
|
-
|
|
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
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
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
|
|
|
34
19
|
```bash
|
|
35
|
-
npm
|
|
20
|
+
npm i @shubham0x13/ffbeast-wheel-webhid-api
|
|
36
21
|
```
|
|
37
22
|
|
|
38
|
-
##
|
|
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
|
|
51
|
-
|
|
52
|
-
});
|
|
42
|
+
// Reconnect to a previously authorized wheel without a prompt.
|
|
43
|
+
const reconnected = await wheel.tryAutoConnect();
|
|
53
44
|
|
|
54
|
-
//
|
|
55
|
-
|
|
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
|
-
//
|
|
58
|
-
|
|
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](
|
|
79
|
+
This project is licensed under the [MIT License](https://github.com/shubham0x13/ffbeast-wheel-webhid-api/blob/main/LICENSE).
|