@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.
- package/README.md +46 -37
- package/dist/index.d.ts +216 -173
- package/dist/index.js +665 -439
- package/package.json +20 -29
package/dist/index.d.ts
CHANGED
|
@@ -1,33 +1,42 @@
|
|
|
1
|
+
/// <reference types="w3c-web-hid" />
|
|
1
2
|
import { EventEmitter } from "eventemitter3";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/** USB Vendor ID for FFBeast devices. */
|
|
5
|
-
declare const VID = 1115;
|
|
3
|
+
/** USB Vendor ID for FFBeast devices. */
|
|
4
|
+
export declare const VID = 1115;
|
|
6
5
|
/** USB Product ID for FFBeast wheel controllers. */
|
|
7
|
-
declare const PID = 22999;
|
|
8
|
-
/** Size of HID reports in bytes. */
|
|
9
|
-
declare const REPORT_SIZE = 64;
|
|
10
|
-
/** HID usage page for interface 0. */
|
|
11
|
-
declare const INTERFACE_0_USAGE_PAGE = 65394;
|
|
12
|
-
/** HID usage for interface 0. */
|
|
13
|
-
declare const INTERFACE_0_USAGE = 161;
|
|
6
|
+
export declare const PID = 22999;
|
|
14
7
|
/**
|
|
15
8
|
* Maximum raw position value from the device.
|
|
16
9
|
* @remarks Used for converting raw position to degrees.
|
|
17
10
|
*/
|
|
18
|
-
declare const RAW_POSITION_MAX = 10000;
|
|
11
|
+
export declare const RAW_POSITION_MAX = 10000;
|
|
19
12
|
/**
|
|
20
13
|
* Maximum raw torque value from the device.
|
|
21
14
|
* @remarks Used for normalizing torque to [-100, 100] range.
|
|
22
15
|
*/
|
|
23
|
-
declare const RAW_TORQUE_MAX = 10000;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
export declare const RAW_TORQUE_MAX = 10000;
|
|
17
|
+
/**
|
|
18
|
+
* Converts raw position value to degrees.
|
|
19
|
+
*
|
|
20
|
+
* @param rawPosition - The raw position value from the device.
|
|
21
|
+
* @param motionRange - The motion range configured on the device, in degrees
|
|
22
|
+
* (see {@link EffectSettings.motionRange}).
|
|
23
|
+
* @returns The position in degrees.
|
|
24
|
+
*/
|
|
25
|
+
export declare function convertPositionToDegrees(rawPosition: number, motionRange: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* Normalizes raw torque value to a [-100, 100] range.
|
|
28
|
+
*
|
|
29
|
+
* @param rawTorque - The raw torque value from the device.
|
|
30
|
+
* @returns The normalized torque value between -100 and 100.
|
|
31
|
+
*/
|
|
32
|
+
export declare function normalizeTorque(rawTorque: number): number;
|
|
33
|
+
/** GPIO extension mode (`ExtensionModeEnum` in the reference header). */
|
|
34
|
+
export declare enum ExtensionMode {
|
|
27
35
|
None = 0,
|
|
28
|
-
Custom = 1
|
|
36
|
+
Custom = 1
|
|
29
37
|
}
|
|
30
|
-
|
|
38
|
+
/** Function assigned to a GPIO extension pin (`PinModeEnum`). */
|
|
39
|
+
export declare enum PinMode {
|
|
31
40
|
None = 0,
|
|
32
41
|
Gpio = 1,
|
|
33
42
|
Analog = 2,
|
|
@@ -38,64 +47,63 @@ declare enum PinMode {
|
|
|
38
47
|
CenterReset = 7,
|
|
39
48
|
BrakingPwm = 8,
|
|
40
49
|
EffectLed = 9,
|
|
41
|
-
Reboot = 10
|
|
50
|
+
Reboot = 10
|
|
42
51
|
}
|
|
43
|
-
|
|
52
|
+
/** How a button input is interpreted (`ButtonModeEnum`). */
|
|
53
|
+
export declare enum ButtonMode {
|
|
44
54
|
None = 0,
|
|
45
55
|
Normal = 1,
|
|
46
56
|
Inverted = 2,
|
|
57
|
+
/** Not implemented by the firmware, according to the reference header. */
|
|
47
58
|
Pulse = 3,
|
|
48
|
-
|
|
59
|
+
/** Not implemented by the firmware, according to the reference header. */
|
|
60
|
+
PulseInverted = 4
|
|
49
61
|
}
|
|
50
|
-
|
|
62
|
+
/** Amplifier gain setting (`AmplifierGainEnum`). */
|
|
63
|
+
export declare enum AmplifierGain {
|
|
51
64
|
Gain80 = 0,
|
|
52
65
|
Gain40 = 1,
|
|
53
66
|
Gain20 = 2,
|
|
54
|
-
Gain10 = 3
|
|
67
|
+
Gain10 = 3
|
|
55
68
|
}
|
|
56
|
-
|
|
69
|
+
/** SPI mode used to read the GPIO extension (`SpiModeEnum`). */
|
|
70
|
+
export declare enum SpiMode {
|
|
71
|
+
/**
|
|
72
|
+
* The first bit is output as soon as CS activates. Sequence: read, clock up,
|
|
73
|
+
* delay, clock down, delay.
|
|
74
|
+
*/
|
|
57
75
|
Mode0 = 0,
|
|
76
|
+
/**
|
|
77
|
+
* The first bit is output on the first clock edge after CS activates.
|
|
78
|
+
* Sequence: clock up, delay, read, clock down, delay.
|
|
79
|
+
*/
|
|
58
80
|
Mode1 = 1,
|
|
81
|
+
/**
|
|
82
|
+
* The first bit is output as soon as CS activates. Sequence: read, clock
|
|
83
|
+
* down, delay, clock up, delay.
|
|
84
|
+
*/
|
|
59
85
|
Mode2 = 2,
|
|
60
|
-
|
|
86
|
+
/**
|
|
87
|
+
* The first bit is output on the first clock edge after CS activates.
|
|
88
|
+
* Sequence: clock down, delay, read, clock up, delay.
|
|
89
|
+
*/
|
|
90
|
+
Mode3 = 3
|
|
61
91
|
}
|
|
62
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Edge of the chip-select signal that triggers the SPI latch
|
|
94
|
+
* (`SpiLatchModeEnum`).
|
|
95
|
+
*/
|
|
96
|
+
export declare enum SpiLatchMode {
|
|
97
|
+
/** nCS goes up to trigger the SPI latch. */
|
|
63
98
|
LatchUp = 0,
|
|
64
|
-
|
|
99
|
+
/** nCS goes down to trigger the SPI latch. */
|
|
100
|
+
LatchDown = 1
|
|
65
101
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
DataFirmwareActivationData = 19,
|
|
72
|
-
DataSettingsFieldData = 20,
|
|
73
|
-
CommandResetCenter = 4,
|
|
74
|
-
}
|
|
75
|
-
declare enum ReportType {
|
|
76
|
-
JoystickInput = 1,
|
|
77
|
-
CreateNewEffect = 17,
|
|
78
|
-
PIDBlockLoad = 18,
|
|
79
|
-
PIDPool = 19,
|
|
80
|
-
SetEffect = 17,
|
|
81
|
-
SetEnvelope = 18,
|
|
82
|
-
SetCondition = 19,
|
|
83
|
-
SetPeriodic = 20,
|
|
84
|
-
SetConstantForce = 21,
|
|
85
|
-
SetRampForce = 22,
|
|
86
|
-
EffectOperation = 26,
|
|
87
|
-
PIDState = 18,
|
|
88
|
-
PIDBlockFree = 27,
|
|
89
|
-
PIDDeviceControl = 28,
|
|
90
|
-
DeviceGain = 29,
|
|
91
|
-
HardwareSettingsFeature = 33,
|
|
92
|
-
EffectSettingsFeature = 34,
|
|
93
|
-
FirmwareLicenseFeature = 37,
|
|
94
|
-
GpioSettingsFeature = 161,
|
|
95
|
-
AdcSettingsFeature = 162,
|
|
96
|
-
GenericInputOutput = 163,
|
|
97
|
-
}
|
|
98
|
-
declare enum SettingField {
|
|
102
|
+
/**
|
|
103
|
+
* Identifiers of the settings written with {@link WheelApi.sendSetting}
|
|
104
|
+
* (`SettingsFieldEnum`).
|
|
105
|
+
*/
|
|
106
|
+
export declare enum SettingField {
|
|
99
107
|
DirectXConstantDirection = 0,
|
|
100
108
|
DirectXSpringStrength = 1,
|
|
101
109
|
DirectXConstantStrength = 2,
|
|
@@ -106,8 +114,12 @@ declare enum SettingField {
|
|
|
106
114
|
SoftStopRange = 7,
|
|
107
115
|
StaticDampeningStrength = 8,
|
|
108
116
|
SoftStopDampeningStrength = 9,
|
|
117
|
+
/** Supported by firmware RC.26.1.1; ignored by RC.24.1.4. */
|
|
118
|
+
DynamicDampeningStrength = 10,
|
|
119
|
+
/** Applies after {@link WheelApi.saveAndReboot}. */
|
|
109
120
|
ForceEnabled = 11,
|
|
110
121
|
DebugTorque = 12,
|
|
122
|
+
/** Applies after {@link WheelApi.saveAndReboot}. */
|
|
111
123
|
AmplifierGain = 13,
|
|
112
124
|
CalibrationMagnitude = 15,
|
|
113
125
|
CalibrationSpeed = 16,
|
|
@@ -122,6 +134,7 @@ declare enum SettingField {
|
|
|
122
134
|
PGain = 25,
|
|
123
135
|
IGain = 26,
|
|
124
136
|
ExtensionMode = 27,
|
|
137
|
+
/** Applies after {@link WheelApi.saveAndReboot}. */
|
|
125
138
|
PinMode = 28,
|
|
126
139
|
ButtonMode = 29,
|
|
127
140
|
SpiMode = 30,
|
|
@@ -134,33 +147,14 @@ declare enum SettingField {
|
|
|
134
147
|
AdcToButtonHigh = 37,
|
|
135
148
|
AdcSmoothing = 38,
|
|
136
149
|
AdcInvert = 39,
|
|
150
|
+
/**
|
|
151
|
+
* Sets pin Z0 (`pinMode[8]`) to {@link PinMode.CenterReset} for a non-zero
|
|
152
|
+
* value, or {@link PinMode.None} for zero. The index is ignored. Applies
|
|
153
|
+
* after {@link WheelApi.saveAndReboot}.
|
|
154
|
+
*/
|
|
137
155
|
ResetCenterOnZ0 = 41,
|
|
138
|
-
IntegratedSpringStrength = 43
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Binary field type identifiers for parsing HID reports.
|
|
142
|
-
* @internal
|
|
143
|
-
*/
|
|
144
|
-
declare enum FieldType {
|
|
145
|
-
Int8 = 0,
|
|
146
|
-
Uint8 = 1,
|
|
147
|
-
Int16 = 2,
|
|
148
|
-
Uint16 = 3,
|
|
149
|
-
Int32 = 4,
|
|
150
|
-
Uint32 = 5,
|
|
151
|
-
Float32 = 6,
|
|
156
|
+
IntegratedSpringStrength = 43
|
|
152
157
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Maps {@link SettingField} values to their corresponding {@link FieldType}.
|
|
155
|
-
*
|
|
156
|
-
* @remarks
|
|
157
|
-
* This mapping is based on the struct definitions in the original C++ `wheel_api.h`.
|
|
158
|
-
*
|
|
159
|
-
* @internal
|
|
160
|
-
*/
|
|
161
|
-
declare const FIELD_TYPE_MAP: Readonly<Record<SettingField, FieldType>>;
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region src/types.d.ts
|
|
164
158
|
interface FirmwareVersion {
|
|
165
159
|
releaseType: number;
|
|
166
160
|
/** Year of the release. */
|
|
@@ -202,7 +196,18 @@ interface EffectSettings {
|
|
|
202
196
|
directXConstantStrength: number;
|
|
203
197
|
/** DirectX periodic strength (0 to 100%). */
|
|
204
198
|
directXPeriodicStrength: number;
|
|
199
|
+
/**
|
|
200
|
+
* Dynamic dampening strength (0 to 100%).
|
|
201
|
+
* @remarks Not meaningful on firmware without dynamic dampening; see
|
|
202
|
+
* {@link SettingField.DynamicDampeningStrength}.
|
|
203
|
+
*/
|
|
204
|
+
dynamicDampeningStrength: number;
|
|
205
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* @remarks `amplifierGain` is the raw byte reported by the device. Firmware
|
|
208
|
+
* newer than this library may report a value that {@link AmplifierGain} does
|
|
209
|
+
* not list.
|
|
210
|
+
*/
|
|
206
211
|
interface HardwareSettings {
|
|
207
212
|
/** Encoder counts per revolution (CPR). */
|
|
208
213
|
encoderCPR: number;
|
|
@@ -214,8 +219,8 @@ interface HardwareSettings {
|
|
|
214
219
|
forceEnabled: number;
|
|
215
220
|
/** Debug torque output enabled (0 = Disabled, 1 = Enabled). */
|
|
216
221
|
debugTorque: number;
|
|
217
|
-
/** Amplifier gain setting.
|
|
218
|
-
amplifierGain:
|
|
222
|
+
/** Amplifier gain setting. */
|
|
223
|
+
amplifierGain: AmplifierGain;
|
|
219
224
|
/** Calibration magnitude (0 to 100%). */
|
|
220
225
|
calibrationMagnitude: number;
|
|
221
226
|
/** Calibration speed (0 to 100%). */
|
|
@@ -240,32 +245,30 @@ interface AdcSettings {
|
|
|
240
245
|
rAxisMin: number[];
|
|
241
246
|
/** Maximum raw values for the 3 analog axes. */
|
|
242
247
|
rAxisMax: number[];
|
|
243
|
-
/** Axis smoothing factor.
|
|
244
|
-
* @remarks Divide by 100 to get normalized ratio (0..1).
|
|
245
|
-
*/
|
|
248
|
+
/** Axis smoothing factor. Divide by 100 to get a ratio from 0 to 1. */
|
|
246
249
|
rAxisSmoothing: number[];
|
|
247
|
-
/** Point in % where
|
|
248
|
-
* @remarks 0 = Disabled.
|
|
249
|
-
*/
|
|
250
|
+
/** Point in % where the low button triggers; 0 disables it. */
|
|
250
251
|
rAxisToButtonLow: number[];
|
|
251
|
-
/** Point in % where
|
|
252
|
-
* @remarks 100 = Disabled.
|
|
253
|
-
*/
|
|
252
|
+
/** Point in % where the high button triggers; 100 disables it. */
|
|
254
253
|
rAxisToButtonHigh: number[];
|
|
255
254
|
/** Axis inversion flags (0 or 1). */
|
|
256
255
|
rAxisInvert: number[];
|
|
257
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* @remarks Enum-typed fields hold the raw bytes reported by the device.
|
|
259
|
+
* Firmware newer than this library may report values the enums do not list.
|
|
260
|
+
*/
|
|
258
261
|
interface GpioSettings {
|
|
259
|
-
/** Extension mode.
|
|
260
|
-
extensionMode:
|
|
261
|
-
/** Pin mode configuration for 10 pins.
|
|
262
|
-
pinMode:
|
|
263
|
-
/** Button mode configuration for 32 buttons.
|
|
264
|
-
buttonMode:
|
|
265
|
-
/** SPI communication mode.
|
|
266
|
-
spiMode:
|
|
267
|
-
/** SPI latch mode.
|
|
268
|
-
spiLatchMode:
|
|
262
|
+
/** Extension mode. */
|
|
263
|
+
extensionMode: ExtensionMode;
|
|
264
|
+
/** Pin mode configuration for 10 pins. */
|
|
265
|
+
pinMode: PinMode[];
|
|
266
|
+
/** Button mode configuration for 32 buttons. */
|
|
267
|
+
buttonMode: ButtonMode[];
|
|
268
|
+
/** SPI communication mode. */
|
|
269
|
+
spiMode: SpiMode;
|
|
270
|
+
/** SPI latch mode. */
|
|
271
|
+
spiLatchMode: SpiLatchMode;
|
|
269
272
|
/** SPI latch delay in microseconds. */
|
|
270
273
|
spiLatchDelay: number;
|
|
271
274
|
/** SPI clock pulse length in microseconds. */
|
|
@@ -295,8 +298,9 @@ interface DirectControl {
|
|
|
295
298
|
*/
|
|
296
299
|
periodicForce: number;
|
|
297
300
|
/**
|
|
298
|
-
*
|
|
299
|
-
*
|
|
301
|
+
* Inverse scale for DirectX forces, excluding periodic and dampening:
|
|
302
|
+
* `TotalForce = InitialForce * (1 - forceDrop / 100)`. Direct control forces
|
|
303
|
+
* are not affected.
|
|
300
304
|
* - Range: 0 to 100
|
|
301
305
|
* - Default: 0
|
|
302
306
|
*/
|
|
@@ -309,13 +313,9 @@ interface DeviceState {
|
|
|
309
313
|
firmwareVersion: FirmwareVersion;
|
|
310
314
|
/** Registration status (0 = unregistered, 1 = registered). */
|
|
311
315
|
isRegistered: number;
|
|
312
|
-
/** Raw wheel position
|
|
313
|
-
* - Range: -10000 to +10000 (roughly)
|
|
314
|
-
*/
|
|
316
|
+
/** Raw wheel position, from -10000 to +10000. */
|
|
315
317
|
position: number;
|
|
316
|
-
/** Raw torque
|
|
317
|
-
* - Range: -10000 to +10000
|
|
318
|
-
*/
|
|
318
|
+
/** Raw torque currently being output, from -10000 to +10000. */
|
|
319
319
|
torque: number;
|
|
320
320
|
/**
|
|
321
321
|
* Wheel position converted to degrees based on the active motion range.
|
|
@@ -324,13 +324,14 @@ interface DeviceState {
|
|
|
324
324
|
positionDegrees: number | null;
|
|
325
325
|
/**
|
|
326
326
|
* Current torque normalized to a percentage range (-100 to 100).
|
|
327
|
-
* @remarks Computed property.
|
|
327
|
+
* @remarks Computed property.
|
|
328
328
|
*/
|
|
329
329
|
torqueNormalized: number;
|
|
330
330
|
}
|
|
331
331
|
/**
|
|
332
332
|
* Aggregated settings object containing all configuration groups.
|
|
333
|
-
* @remarks
|
|
333
|
+
* @remarks Returned by {@link WheelApi.readAllSettings}; not part of the
|
|
334
|
+
* reference C++ API.
|
|
334
335
|
*/
|
|
335
336
|
interface DeviceSettings {
|
|
336
337
|
effects: EffectSettings;
|
|
@@ -338,6 +339,14 @@ interface DeviceSettings {
|
|
|
338
339
|
gpio: GpioSettings;
|
|
339
340
|
adc: AdcSettings;
|
|
340
341
|
}
|
|
342
|
+
/** Options for {@link WheelApi}. */
|
|
343
|
+
interface WheelApiOptions {
|
|
344
|
+
/**
|
|
345
|
+
* Connect automatically when a previously authorized wheel is plugged in.
|
|
346
|
+
* @defaultValue true
|
|
347
|
+
*/
|
|
348
|
+
autoConnect?: boolean;
|
|
349
|
+
}
|
|
341
350
|
/** Event handler signatures for {@link WheelApi} events. */
|
|
342
351
|
interface WheelEvents {
|
|
343
352
|
/** Emitted when a device is successfully connected. */
|
|
@@ -346,30 +355,14 @@ interface WheelEvents {
|
|
|
346
355
|
deviceDisconnected: (device: HIDDevice) => void;
|
|
347
356
|
/** Emitted when new device state is received. */
|
|
348
357
|
stateReceived: (state: DeviceState) => void;
|
|
349
|
-
/**
|
|
350
|
-
*
|
|
358
|
+
/**
|
|
359
|
+
* Emitted when an error occurs during background processing, such as
|
|
360
|
+
* parsing input reports or connecting automatically.
|
|
361
|
+
* @remarks Direct API calls (like `sendSetting`) reject their promise
|
|
362
|
+
* instead.
|
|
351
363
|
*/
|
|
352
364
|
error: (error: Error) => void;
|
|
353
365
|
}
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region src/utils.d.ts
|
|
356
|
-
/**
|
|
357
|
-
* Converts raw position value to degrees.
|
|
358
|
-
*
|
|
359
|
-
* @param rawPosition - The raw position value from the device.
|
|
360
|
-
* @param motionRange - The configured motion range in degrees.
|
|
361
|
-
* @returns The position in degrees.
|
|
362
|
-
*/
|
|
363
|
-
declare function convertPositionToDegrees(rawPosition: number, motionRange?: number): number;
|
|
364
|
-
/**
|
|
365
|
-
* Normalizes raw torque value to a [-100, 100] range.
|
|
366
|
-
*
|
|
367
|
-
* @param rawTorque - The raw torque value from the device.
|
|
368
|
-
* @returns The normalized torque value between -100 and 100.
|
|
369
|
-
*/
|
|
370
|
-
declare function normalizeTorque(rawTorque: number): number;
|
|
371
|
-
//#endregion
|
|
372
|
-
//#region src/wheel-api.d.ts
|
|
373
366
|
/**
|
|
374
367
|
* WebHID-based API for communicating with the wheel controller.
|
|
375
368
|
*
|
|
@@ -380,18 +373,23 @@ declare function normalizeTorque(rawTorque: number): number;
|
|
|
380
373
|
* const wheel = new WheelApi();
|
|
381
374
|
*
|
|
382
375
|
* wheel.on("stateReceived", (state) => {
|
|
383
|
-
* console.log("Position:", state.
|
|
376
|
+
* console.log("Position:", state.positionDegrees);
|
|
384
377
|
* });
|
|
385
378
|
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
379
|
+
* // The device picker must be opened from a user action.
|
|
380
|
+
* connectButton.addEventListener("click", () => {
|
|
381
|
+
* wheel.connect().catch(console.error);
|
|
382
|
+
* });
|
|
389
383
|
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
384
|
+
* // Later, for example when the page or component unmounts.
|
|
385
|
+
* // destroy() also disconnects.
|
|
386
|
+
* await wheel.destroy();
|
|
392
387
|
* ```
|
|
393
388
|
*/
|
|
394
|
-
declare class WheelApi extends EventEmitter<WheelEvents> {
|
|
389
|
+
export declare class WheelApi extends EventEmitter<WheelEvents> {
|
|
390
|
+
#private;
|
|
391
|
+
/** @param options - See {@link WheelApiOptions}. */
|
|
392
|
+
constructor(options?: WheelApiOptions);
|
|
395
393
|
/**
|
|
396
394
|
* Last received device state.
|
|
397
395
|
* @returns Device state, or `null` if no state received yet.
|
|
@@ -399,22 +397,24 @@ declare class WheelApi extends EventEmitter<WheelEvents> {
|
|
|
399
397
|
get lastState(): Readonly<DeviceState> | null;
|
|
400
398
|
/**
|
|
401
399
|
* Current wheel position in degrees.
|
|
402
|
-
* @returns Position in degrees, or `null` if
|
|
400
|
+
* @returns Position in degrees, or `null` if no state has been received or
|
|
401
|
+
* the motion range is unknown.
|
|
403
402
|
*/
|
|
404
403
|
get positionDegrees(): number | null;
|
|
405
404
|
/**
|
|
406
405
|
* Current torque normalized to [-100, 100] range.
|
|
407
|
-
* @returns Normalized torque, or `null` if
|
|
406
|
+
* @returns Normalized torque, or `null` if no state has been received.
|
|
408
407
|
*/
|
|
409
408
|
get torqueNormalized(): number | null;
|
|
410
409
|
/**
|
|
411
410
|
* Current firmware release type.
|
|
412
|
-
* @returns Release type number, or `null` if
|
|
411
|
+
* @returns Release type number, or `null` if no state has been received.
|
|
413
412
|
*/
|
|
414
413
|
get firmwareReleaseType(): number | null;
|
|
415
414
|
/**
|
|
416
415
|
* Current firmware version string.
|
|
417
|
-
* @returns Version string (e.g., "1.2.3"), or `null` if
|
|
416
|
+
* @returns Version string (e.g., "1.2.3"), or `null` if no state has been
|
|
417
|
+
* received.
|
|
418
418
|
*/
|
|
419
419
|
get firmwareVersion(): string | null;
|
|
420
420
|
/**
|
|
@@ -422,32 +422,52 @@ declare class WheelApi extends EventEmitter<WheelEvents> {
|
|
|
422
422
|
* @returns `true` if connected and opened.
|
|
423
423
|
*/
|
|
424
424
|
get isConnected(): boolean;
|
|
425
|
-
private device;
|
|
426
|
-
private _lastState;
|
|
427
|
-
private cachedMotionRange;
|
|
428
|
-
constructor();
|
|
429
425
|
/**
|
|
430
|
-
*
|
|
431
|
-
*
|
|
426
|
+
* Whether a previously authorized wheel connects automatically when plugged
|
|
427
|
+
* in. Set with {@link WheelApiOptions.autoConnect}.
|
|
428
|
+
*/
|
|
429
|
+
get autoConnect(): boolean;
|
|
430
|
+
/**
|
|
431
|
+
* Checks whether the current environment supports WebHID.
|
|
432
|
+
* @returns `false` outside browsers (for example during server-side
|
|
433
|
+
* rendering) and in browsers without WebHID.
|
|
432
434
|
*/
|
|
433
435
|
static isSupported(): boolean;
|
|
434
436
|
/**
|
|
435
437
|
* Opens the browser's device picker to connect to a wheel.
|
|
436
|
-
*
|
|
438
|
+
*
|
|
439
|
+
* @remarks
|
|
440
|
+
* Must be called from a user gesture (e.g. a click handler), as required by
|
|
441
|
+
* `navigator.hid.requestDevice()`. If another wheel is already connected it
|
|
442
|
+
* is disconnected first.
|
|
443
|
+
*
|
|
444
|
+
* @returns `true` if a device was connected, `false` if the user closed the
|
|
445
|
+
* picker without selecting one.
|
|
446
|
+
* @throws Error if the selected device could not be opened. The underlying
|
|
447
|
+
* `DOMException` is available as `cause`.
|
|
437
448
|
*/
|
|
438
449
|
connect(): Promise<boolean>;
|
|
439
450
|
/**
|
|
440
451
|
* Attempts to reconnect to a previously authorized device.
|
|
441
|
-
* @returns `true` if a device was found and connected
|
|
452
|
+
* @returns `true` if a device was found and connected, `false` if no
|
|
453
|
+
* previously authorized wheel is available.
|
|
454
|
+
* @throws Error if the device was found but could not be opened. The
|
|
455
|
+
* underlying `DOMException` is available as `cause`.
|
|
442
456
|
*/
|
|
443
457
|
tryAutoConnect(): Promise<boolean>;
|
|
444
458
|
/**
|
|
445
|
-
* Disconnects from the current device.
|
|
459
|
+
* Disconnects from the current device. A connection in progress finishes
|
|
460
|
+
* first.
|
|
446
461
|
*/
|
|
447
462
|
disconnect(): Promise<void>;
|
|
448
463
|
/**
|
|
449
464
|
* Cleans up all resources and event listeners.
|
|
450
465
|
* Must be called when the API instance is no longer needed.
|
|
466
|
+
*
|
|
467
|
+
* @remarks
|
|
468
|
+
* A {@link WheelApi.connect} or {@link WheelApi.tryAutoConnect} call that is
|
|
469
|
+
* still pending rejects instead of connecting; `destroy()` resolves once it
|
|
470
|
+
* has finished.
|
|
451
471
|
*/
|
|
452
472
|
destroy(): Promise<void>;
|
|
453
473
|
/**
|
|
@@ -482,25 +502,55 @@ declare class WheelApi extends EventEmitter<WheelEvents> {
|
|
|
482
502
|
readAllSettings(): Promise<DeviceSettings>;
|
|
483
503
|
/**
|
|
484
504
|
* Writes a single setting value to the device.
|
|
505
|
+
*
|
|
506
|
+
* @remarks
|
|
507
|
+
* Values are rounded to the nearest integer and clamped to the range of the
|
|
508
|
+
* field's wire type.
|
|
509
|
+
*
|
|
510
|
+
* {@link SettingField.ForceEnabled}, {@link SettingField.AmplifierGain},
|
|
511
|
+
* {@link SettingField.PinMode} and {@link SettingField.ResetCenterOnZ0} only
|
|
512
|
+
* take effect, and read back with the new value, after
|
|
513
|
+
* {@link WheelApi.saveAndReboot}.
|
|
514
|
+
*
|
|
485
515
|
* @param field - The setting field to write.
|
|
486
|
-
* @param index -
|
|
516
|
+
* @param index - Index for array settings, such as the pin for
|
|
517
|
+
* {@link SettingField.PinMode}; `0` for other settings.
|
|
487
518
|
* @param value - The value to write.
|
|
519
|
+
* @throws Error if the device is not connected.
|
|
520
|
+
* @throws RangeError if `field` is not a known setting, `index` is not an
|
|
521
|
+
* integer in `[0, 255]` or `value` is not a finite number.
|
|
488
522
|
*/
|
|
489
523
|
sendSetting(field: SettingField, index: number, value: number): Promise<void>;
|
|
490
524
|
/**
|
|
491
525
|
* Sends direct force feedback control to the device.
|
|
526
|
+
*
|
|
527
|
+
* @remarks
|
|
528
|
+
* Values are rounded to the nearest integer and clamped to their documented
|
|
529
|
+
* ranges.
|
|
530
|
+
*
|
|
531
|
+
* The device falls back to its default mode when direct control reports
|
|
532
|
+
* stop, so send them continuously while direct control is in use.
|
|
533
|
+
*
|
|
492
534
|
* @param control - Force feedback control values.
|
|
535
|
+
* @throws Error if the device is not connected.
|
|
536
|
+
* @throws RangeError if any value is not a finite number.
|
|
493
537
|
*/
|
|
494
538
|
sendDirectControl(control: DirectControl): Promise<void>;
|
|
495
539
|
/**
|
|
496
|
-
* Sends the firmware activation
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
* @
|
|
500
|
-
|
|
501
|
-
|
|
540
|
+
* Sends the firmware activation key to the device. Nothing is sent if the
|
|
541
|
+
* device already reports itself as registered.
|
|
542
|
+
*
|
|
543
|
+
* @remarks
|
|
544
|
+
* The device then saves its settings and reboots, so it disconnects.
|
|
545
|
+
*
|
|
546
|
+
* @param license - Three hexadecimal segments separated by `-`, for example
|
|
547
|
+
* `"0123ABCD-4567EF01-89ABCDEF"`.
|
|
548
|
+
* @throws Error if the device is not connected or the key is malformed.
|
|
549
|
+
*/
|
|
550
|
+
sendFirmwareActivation(license: string): Promise<void>;
|
|
502
551
|
/**
|
|
503
|
-
* Saves current settings to flash and reboots the controller.
|
|
552
|
+
* Saves the current settings to flash and reboots the controller. Settings
|
|
553
|
+
* that only apply on save take effect after the reboot.
|
|
504
554
|
*/
|
|
505
555
|
saveAndReboot(): Promise<void>;
|
|
506
556
|
/**
|
|
@@ -515,12 +565,5 @@ declare class WheelApi extends EventEmitter<WheelEvents> {
|
|
|
515
565
|
* Sets the current wheel position as center.
|
|
516
566
|
*/
|
|
517
567
|
resetWheelCenter(): Promise<void>;
|
|
518
|
-
private handleConnect;
|
|
519
|
-
private handleDisconnect;
|
|
520
|
-
private handleInputReport;
|
|
521
|
-
private openDevice;
|
|
522
|
-
private sendGenericCommand;
|
|
523
|
-
private getFeatureReport;
|
|
524
568
|
}
|
|
525
|
-
|
|
526
|
-
export { AdcSettings, AmplifierGain, ButtonMode, DeviceSettings, DeviceState, DirectControl, EffectSettings, ExtensionMode, FIELD_TYPE_MAP, FieldType, FirmwareLicense, FirmwareVersion, GpioSettings, HardwareSettings, INTERFACE_0_USAGE, INTERFACE_0_USAGE_PAGE, PID, PinMode, RAW_POSITION_MAX, RAW_TORQUE_MAX, REPORT_SIZE, ReportData, ReportType, SettingField, SpiLatchMode, SpiMode, VID, WheelApi, WheelEvents, convertPositionToDegrees, normalizeTorque };
|
|
569
|
+
export type { AdcSettings, DeviceSettings, DeviceState, DirectControl, EffectSettings, FirmwareLicense, FirmwareVersion, GpioSettings, HardwareSettings, WheelApiOptions, WheelEvents };
|