@realnation/builder-shared-sdk 2.6.0 → 2.7.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.
|
@@ -47,7 +47,7 @@ export interface CreateGamepadOptions {
|
|
|
47
47
|
export declare class GamepadSession {
|
|
48
48
|
private readonly source;
|
|
49
49
|
private readonly profiles;
|
|
50
|
-
private
|
|
50
|
+
private thresholdOverrides?;
|
|
51
51
|
private readonly waitMs;
|
|
52
52
|
private readonly setTimer;
|
|
53
53
|
private readonly clearTimer;
|
|
@@ -88,6 +88,8 @@ export declare class GamepadSession {
|
|
|
88
88
|
* device, rather than null until the first animation frame lands.
|
|
89
89
|
*/
|
|
90
90
|
private adoptProfile;
|
|
91
|
+
/** Device profile first, caller overrides on top. */
|
|
92
|
+
private recomputeThresholds;
|
|
91
93
|
/** One-shot look at what is connected right now. */
|
|
92
94
|
private probe;
|
|
93
95
|
private startPolling;
|
|
@@ -119,6 +121,24 @@ export declare class GamepadSession {
|
|
|
119
121
|
onStateChange(handler: (state: GamepadState) => void): Unsubscribe;
|
|
120
122
|
/** The device seen last, matched or not. For operator-facing messages. */
|
|
121
123
|
get device(): ProfileLookup | null;
|
|
124
|
+
/** The press and release lines in force right now, profile plus overrides. */
|
|
125
|
+
get activeThresholds(): Thresholds;
|
|
126
|
+
/**
|
|
127
|
+
* Changes the press and release lines while the session is running.
|
|
128
|
+
*
|
|
129
|
+
* This is how a campaign tunes the feel: a lane-change game wants the wheel
|
|
130
|
+
* to register early, a racing game wants it steady, and the operator sets
|
|
131
|
+
* that per activity rather than waiting for a release. Overrides sit on top
|
|
132
|
+
* of the device profile, so anything left out keeps the model's own value;
|
|
133
|
+
* pass null to drop the overrides and fall back to the profile.
|
|
134
|
+
*
|
|
135
|
+
* Anything held right now is released first. The presses that are down were
|
|
136
|
+
* decided under the old lines, and carrying them across the change mixes two
|
|
137
|
+
* sets of rules in one state: a control could sit above the new release line
|
|
138
|
+
* forever and never send the release a hold-mode module is waiting for.
|
|
139
|
+
* Starting clean costs one release event and removes the whole problem.
|
|
140
|
+
*/
|
|
141
|
+
setThresholds(overrides: Partial<Thresholds> | null): void;
|
|
122
142
|
/**
|
|
123
143
|
* Releases anything held and stops polling, without ending the session.
|
|
124
144
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/gamepad/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAIjD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAA+B,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAE1E,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC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AG,IAAI;IAM1D;;;;;;OAMG;IACH,OAAO,IAAI,IAAI;IAQf,iCAAiC;IACjC,MAAM,IAAI,IAAI;IAKd,0EAA0E;IAC1E,KAAK,IAAI,IAAI;IAab,6DAA6D;IAC7D,OAAO,IAAI,IAAI;CAGhB;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,cAAc,CAEhF;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAYhE"}
|
package/dist/gamepad/session.js
CHANGED
|
@@ -90,7 +90,14 @@ export class GamepadSession {
|
|
|
90
90
|
if (profile === this.profile)
|
|
91
91
|
return;
|
|
92
92
|
this.profile = profile;
|
|
93
|
-
this.
|
|
93
|
+
this.recomputeThresholds();
|
|
94
|
+
}
|
|
95
|
+
/** Device profile first, caller overrides on top. */
|
|
96
|
+
recomputeThresholds() {
|
|
97
|
+
this.thresholds = resolveThresholds({
|
|
98
|
+
...this.profile?.thresholds,
|
|
99
|
+
...this.thresholdOverrides,
|
|
100
|
+
});
|
|
94
101
|
}
|
|
95
102
|
/** One-shot look at what is connected right now. */
|
|
96
103
|
probe() {
|
|
@@ -248,6 +255,30 @@ export class GamepadSession {
|
|
|
248
255
|
get device() {
|
|
249
256
|
return this.lastLookup;
|
|
250
257
|
}
|
|
258
|
+
/** The press and release lines in force right now, profile plus overrides. */
|
|
259
|
+
get activeThresholds() {
|
|
260
|
+
return { ...this.thresholds };
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Changes the press and release lines while the session is running.
|
|
264
|
+
*
|
|
265
|
+
* This is how a campaign tunes the feel: a lane-change game wants the wheel
|
|
266
|
+
* to register early, a racing game wants it steady, and the operator sets
|
|
267
|
+
* that per activity rather than waiting for a release. Overrides sit on top
|
|
268
|
+
* of the device profile, so anything left out keeps the model's own value;
|
|
269
|
+
* pass null to drop the overrides and fall back to the profile.
|
|
270
|
+
*
|
|
271
|
+
* Anything held right now is released first. The presses that are down were
|
|
272
|
+
* decided under the old lines, and carrying them across the change mixes two
|
|
273
|
+
* sets of rules in one state: a control could sit above the new release line
|
|
274
|
+
* forever and never send the release a hold-mode module is waiting for.
|
|
275
|
+
* Starting clean costs one release event and removes the whole problem.
|
|
276
|
+
*/
|
|
277
|
+
setThresholds(overrides) {
|
|
278
|
+
this.thresholdOverrides = overrides ?? undefined;
|
|
279
|
+
this.recomputeThresholds();
|
|
280
|
+
this.emitEvents(this.flushReleases());
|
|
281
|
+
}
|
|
251
282
|
/**
|
|
252
283
|
* Releases anything held and stops polling, without ending the session.
|
|
253
284
|
*
|
|
@@ -26,13 +26,18 @@ export interface Thresholds {
|
|
|
26
26
|
buttonRelease: number;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Steering was tuned on the real wheel (PF 2026-09-22): at 0.35 of full lock
|
|
30
|
+
* it had to be dragged round too far before a lane change registered, 0.2
|
|
31
|
+
* lands where a player expects it. Release sits at half of press, so the wheel
|
|
32
|
+
* has to come most of the way back before the next turn counts.
|
|
30
33
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* Pedals sit where they are because timing games score the instant of the
|
|
35
|
+
* press, and a pedal that only registers when floored feels late. That they
|
|
36
|
+
* now read higher than steering is not a contradiction: a fifth of full lock
|
|
37
|
+
* is a real turn of the wheel, a quarter of pedal travel is a light touch.
|
|
38
|
+
*
|
|
39
|
+
* A profile may override any of these: a 900-degree wheel needs a much lower
|
|
40
|
+
* steering line than a 270-degree one to feel the same.
|
|
36
41
|
*/
|
|
37
42
|
export declare const DEFAULT_THRESHOLDS: Thresholds;
|
|
38
43
|
export declare function resolveThresholds(overrides?: Partial<Thresholds>): Thresholds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/gamepad/signals.ts"],"names":[],"mappings":"AAAA;;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;AAED,kFAAkF;AAClF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAE1E,eAAO,MAAM,kBAAkB,EAAE,WAAgB,CAAC;AAElD,wBAAgB,YAAY,IAAI,cAAc,CAE7C;AAqDD;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,cAAc,EACvB,UAAU,GAAE,UAA+B,GAC1C;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAmBhD;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,WAAW,GAAG;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAMhG"}
|
package/dist/gamepad/signals.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { AXIS_CONTROLS, BUTTON_CONTROLS } from './controls.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Steering was tuned on the real wheel (PF 2026-09-22): at 0.35 of full lock
|
|
4
|
+
* it had to be dragged round too far before a lane change registered, 0.2
|
|
5
|
+
* lands where a player expects it. Release sits at half of press, so the wheel
|
|
6
|
+
* has to come most of the way back before the next turn counts.
|
|
4
7
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Pedals sit where they are because timing games score the instant of the
|
|
9
|
+
* press, and a pedal that only registers when floored feels late. That they
|
|
10
|
+
* now read higher than steering is not a contradiction: a fifth of full lock
|
|
11
|
+
* is a real turn of the wheel, a quarter of pedal travel is a light touch.
|
|
12
|
+
*
|
|
13
|
+
* A profile may override any of these: a 900-degree wheel needs a much lower
|
|
14
|
+
* steering line than a 270-degree one to feel the same.
|
|
10
15
|
*/
|
|
11
16
|
export const DEFAULT_THRESHOLDS = {
|
|
12
|
-
steeringPress: 0.
|
|
13
|
-
steeringRelease: 0.
|
|
17
|
+
steeringPress: 0.2,
|
|
18
|
+
steeringRelease: 0.1,
|
|
14
19
|
pedalPress: 0.25,
|
|
15
20
|
pedalRelease: 0.12,
|
|
16
21
|
buttonPress: 0.5,
|