@rydr/game-sdk 7.0.0 → 7.1.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 +19 -0
- package/dist/protocol/glyphs.d.ts +7 -0
- package/dist/protocol/glyphs.d.ts.map +1 -1
- package/dist/protocol/glyphs.js +26 -0
- package/dist/protocol/glyphs.js.map +1 -1
- package/dist/protocol/version.d.ts +1 -1
- package/dist/protocol/version.js +1 -1
- package/dist/three/perf-overlay.d.ts +52 -2
- package/dist/three/perf-overlay.d.ts.map +1 -1
- package/dist/three/perf-overlay.js +188 -3
- package/dist/three/perf-overlay.js.map +1 -1
- package/dist/ui/README.md +119 -0
- package/dist/ui/controller/combo-demo.d.ts +74 -0
- package/dist/ui/controller/combo-demo.d.ts.map +1 -0
- package/dist/ui/controller/combo-demo.js +295 -0
- package/dist/ui/controller/combo-demo.js.map +1 -0
- package/dist/ui/controller/combo-strip.d.ts +36 -0
- package/dist/ui/controller/combo-strip.d.ts.map +1 -0
- package/dist/ui/controller/combo-strip.js +66 -0
- package/dist/ui/controller/combo-strip.js.map +1 -0
- package/dist/ui/controller/control-trainer.d.ts +132 -0
- package/dist/ui/controller/control-trainer.d.ts.map +1 -0
- package/dist/ui/controller/control-trainer.js +570 -0
- package/dist/ui/controller/control-trainer.js.map +1 -0
- package/dist/ui/controller/controller-map.d.ts +82 -0
- package/dist/ui/controller/controller-map.d.ts.map +1 -0
- package/dist/ui/controller/controller-map.js +291 -0
- package/dist/ui/controller/controller-map.js.map +1 -0
- package/dist/ui/controller/controller-pad.d.ts +122 -0
- package/dist/ui/controller/controller-pad.d.ts.map +1 -0
- package/dist/ui/controller/controller-pad.js +200 -0
- package/dist/ui/controller/controller-pad.js.map +1 -0
- package/dist/ui/controller/index.d.ts +26 -0
- package/dist/ui/controller/index.d.ts.map +1 -0
- package/dist/ui/controller/index.js +26 -0
- package/dist/ui/controller/index.js.map +1 -0
- package/dist/ui/controller/input-chip.d.ts +100 -0
- package/dist/ui/controller/input-chip.d.ts.map +1 -0
- package/dist/ui/controller/input-chip.js +322 -0
- package/dist/ui/controller/input-chip.js.map +1 -0
- package/dist/ui/controller/layouts/dualsense.d.ts +12 -0
- package/dist/ui/controller/layouts/dualsense.d.ts.map +1 -0
- package/dist/ui/controller/layouts/dualsense.js +64 -0
- package/dist/ui/controller/layouts/dualsense.js.map +1 -0
- package/dist/ui/controller/layouts/index.d.ts +20 -0
- package/dist/ui/controller/layouts/index.d.ts.map +1 -0
- package/dist/ui/controller/layouts/index.js +34 -0
- package/dist/ui/controller/layouts/index.js.map +1 -0
- package/dist/ui/controller/layouts/joycon.d.ts +21 -0
- package/dist/ui/controller/layouts/joycon.d.ts.map +1 -0
- package/dist/ui/controller/layouts/joycon.js +76 -0
- package/dist/ui/controller/layouts/joycon.js.map +1 -0
- package/dist/ui/controller/layouts/switch-pro.d.ts +12 -0
- package/dist/ui/controller/layouts/switch-pro.d.ts.map +1 -0
- package/dist/ui/controller/layouts/switch-pro.js +60 -0
- package/dist/ui/controller/layouts/switch-pro.js.map +1 -0
- package/dist/ui/controller/layouts/xbox.d.ts +11 -0
- package/dist/ui/controller/layouts/xbox.d.ts.map +1 -0
- package/dist/ui/controller/layouts/xbox.js +59 -0
- package/dist/ui/controller/layouts/xbox.js.map +1 -0
- package/dist/ui/controller/layouts/zwift.d.ts +27 -0
- package/dist/ui/controller/layouts/zwift.d.ts.map +1 -0
- package/dist/ui/controller/layouts/zwift.js +62 -0
- package/dist/ui/controller/layouts/zwift.js.map +1 -0
- package/dist/ui/controller/pad-svg.d.ts +105 -0
- package/dist/ui/controller/pad-svg.d.ts.map +1 -0
- package/dist/ui/controller/pad-svg.js +289 -0
- package/dist/ui/controller/pad-svg.js.map +1 -0
- package/dist/ui/controller/parts-map.d.ts +96 -0
- package/dist/ui/controller/parts-map.d.ts.map +1 -0
- package/dist/ui/controller/parts-map.js +187 -0
- package/dist/ui/controller/parts-map.js.map +1 -0
- package/dist/ui/controller/styles.d.ts +19 -0
- package/dist/ui/controller/styles.d.ts.map +1 -0
- package/dist/ui/controller/styles.js +364 -0
- package/dist/ui/controller/styles.js.map +1 -0
- package/dist/ui/controller/tokens.d.ts +106 -0
- package/dist/ui/controller/tokens.d.ts.map +1 -0
- package/dist/ui/controller/tokens.js +50 -0
- package/dist/ui/controller/tokens.js.map +1 -0
- package/dist/ui/controller/types.d.ts +157 -0
- package/dist/ui/controller/types.d.ts.map +1 -0
- package/dist/ui/controller/types.js +61 -0
- package/dist/ui/controller/types.js.map +1 -0
- package/dist/ui/index.d.ts +8 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +8 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/keycap.d.ts +14 -0
- package/dist/ui/keycap.d.ts.map +1 -1
- package/dist/ui/keycap.js +5 -0
- package/dist/ui/keycap.js.map +1 -1
- package/dist/ui/showcase/gallery.d.ts +13 -1
- package/dist/ui/showcase/gallery.d.ts.map +1 -1
- package/dist/ui/showcase/gallery.js.map +1 -1
- package/dist/ui/showcase/index.d.ts.map +1 -1
- package/dist/ui/showcase/index.js +257 -1
- package/dist/ui/showcase/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CONTROL TRAINER — a guided lesson: "here's what to press; now you do it."
|
|
3
|
+
*
|
|
4
|
+
* Where {@link mountComboDemo} only *shows* a combination on a loop, this one **watches the rider** and
|
|
5
|
+
* gates on them actually performing it. It exists for the paired lessons where two related controls have
|
|
6
|
+
* to be taught together — the case that named it being the trainer resistance, which is one concept
|
|
7
|
+
* (`Changer la résistance`) with two opposite halves (`−` and `+`).
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* mountControlTrainer(modalBody, {
|
|
11
|
+
* title: "Changer la résistance",
|
|
12
|
+
* press: shellInput,
|
|
13
|
+
* steps: [
|
|
14
|
+
* { label: "Réduire la résistance", combo: ["LSTICK_PRESS", "LB"] },
|
|
15
|
+
* { label: "Augmenter la résistance", combo: ["LSTICK_PRESS", "RB"] },
|
|
16
|
+
* ],
|
|
17
|
+
* onComplete: () => closeModal(),
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Layout: the title, then one panel per step laid left → right, then **one shared controller drawing
|
|
22
|
+
* spanning the full width** underneath. Sharing the drawing is the point — both halves of the lesson are
|
|
23
|
+
* on the same physical pad, and seeing the left paddle and the right paddle light up on one picture is
|
|
24
|
+
* what teaches the pairing.
|
|
25
|
+
*
|
|
26
|
+
* Each step walks three states, and each one has to *look* like what it means:
|
|
27
|
+
*
|
|
28
|
+
* 1. **hint** — whitish, pulsing, on both the panel's chips and the pad's buttons. This is an
|
|
29
|
+
* instruction, so it must not look like a press; the pulse is what separates the two, since a solid
|
|
30
|
+
* fill is what a real press already looks like. The prompt shows **one step at a time, alternating**,
|
|
31
|
+
* and builds each combination up **cumulatively** — the first control lights, STAYS lit, and the next
|
|
32
|
+
* joins it a beat later. Prompting both halves at once would light four controls on one pad and read
|
|
33
|
+
* as "press all of this"; blinking them in turn would never show that they are held together.
|
|
34
|
+
* 2. **active** — the accent colour, and the pulse STOPS. The rider has started but the combination
|
|
35
|
+
* isn't complete yet: on a two-control step this is the state between the first control and the
|
|
36
|
+
* second.
|
|
37
|
+
* 3. **done** — the step's PANEL turns green and its ✓ pops, the moment the WHOLE combination is held.
|
|
38
|
+
* Holding all of it is doing it; there is nothing further to wait for, and it stays done whether or
|
|
39
|
+
* not the rider keeps the controls down.
|
|
40
|
+
*
|
|
41
|
+
* **The controller drawing is never green.** White and blue have already taught the rider that colour on
|
|
42
|
+
* the pad means *now*, so progress there would be a third colour breaking that rule — a green button
|
|
43
|
+
* beside a white one reads as "and this one too". Progress lives on the panels, whose chips picture the
|
|
44
|
+
* same combination one line up, so the confirmation still lands on the controls they just pressed. See
|
|
45
|
+
* `paint` for the two languages.
|
|
46
|
+
*
|
|
47
|
+
* When every step is done, `onComplete` fires after a short beat so the last ✓ is actually seen. The
|
|
48
|
+
* component does not close anything itself — it has no idea it's in a modal. The host owns that, exactly
|
|
49
|
+
* as with every other piece of this kit.
|
|
50
|
+
*
|
|
51
|
+
* ⚠️ **The resistance case needs a shell-side input source.** `LB`/`RB` are shell-owned: the
|
|
52
|
+
* SDK client turns those keys into `trainer.adjustResistance` intents and they never reach a game's
|
|
53
|
+
* `onButton` (see {@link ShellControl}). So a *game* can build a trainer for its own buttons, but a
|
|
54
|
+
* resistance lesson has to be driven by the shell, which is also the only place that lesson belongs.
|
|
55
|
+
*/
|
|
56
|
+
import type { ButtonEdge } from "../../protocol/buttons.js";
|
|
57
|
+
import type { AxisName } from "../../protocol/buttons.js";
|
|
58
|
+
import type { GlyphSet } from "../../protocol/glyphs.js";
|
|
59
|
+
import { type ControllerPad } from "./controller-pad.js";
|
|
60
|
+
import type { StickPictogramStyle } from "./input-chip.js";
|
|
61
|
+
import { type ComboToken, type ControlName } from "./tokens.js";
|
|
62
|
+
import type { PadBrandKey } from "./types.js";
|
|
63
|
+
/**
|
|
64
|
+
* The input the lesson watches.
|
|
65
|
+
*
|
|
66
|
+
* Typed on {@link ControlName}, not `ButtonName`, so a shell-side source can report `LB`/`RB`.
|
|
67
|
+
* A `PlatformSession` satisfies it structurally and can drive any lesson made of game buttons.
|
|
68
|
+
*/
|
|
69
|
+
export interface TrainerInputSource {
|
|
70
|
+
onButton(cb: (e: {
|
|
71
|
+
name: ControlName;
|
|
72
|
+
edge: ButtonEdge;
|
|
73
|
+
}) => void): () => void;
|
|
74
|
+
axis?(name: AxisName): number;
|
|
75
|
+
hardware?: {
|
|
76
|
+
current: {
|
|
77
|
+
glyphSet?: GlyphSet;
|
|
78
|
+
};
|
|
79
|
+
subscribe?(cb: (snapshot: {
|
|
80
|
+
glyphSet?: GlyphSet;
|
|
81
|
+
}) => void): () => void;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export interface TrainerStep {
|
|
85
|
+
/** What the rider has to do — the panel heading. */
|
|
86
|
+
label: string;
|
|
87
|
+
/** The controls that do it. Several tokens = they must all be engaged together. */
|
|
88
|
+
combo: readonly ComboToken[];
|
|
89
|
+
/** The controls must be engaged IN ORDER rather than together. */
|
|
90
|
+
sequence?: boolean;
|
|
91
|
+
/** A quieter line under the label. */
|
|
92
|
+
hint?: string;
|
|
93
|
+
/** Stable key, for `onStepComplete`. Falls back to `label`. */
|
|
94
|
+
id?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface ControlTrainerOptions {
|
|
97
|
+
/** The one thing the lesson is about — e.g. "Changer la résistance". */
|
|
98
|
+
title: string;
|
|
99
|
+
/** One panel per step, laid left → right in the order given. */
|
|
100
|
+
steps: readonly TrainerStep[];
|
|
101
|
+
/** The input to watch. Without it the lesson still renders and prompts, but can never complete. */
|
|
102
|
+
press?: TrainerInputSource;
|
|
103
|
+
brand?: PadBrandKey;
|
|
104
|
+
glyphSet?: GlyphSet;
|
|
105
|
+
labels?: boolean;
|
|
106
|
+
accent?: string;
|
|
107
|
+
colored?: boolean;
|
|
108
|
+
stickStyle?: StickPictogramStyle;
|
|
109
|
+
/** Pad size preset. Default `"lg"` — the drawing is the shared reference here, so make it readable. */
|
|
110
|
+
size?: "sm" | "md" | "lg";
|
|
111
|
+
/**
|
|
112
|
+
* How long to hold on the final ✓ before `onComplete`. Default 900ms.
|
|
113
|
+
*
|
|
114
|
+
* Not decoration: firing the instant the last control is released would yank the lesson away before the
|
|
115
|
+
* rider sees that they got it right, which is the only feedback the whole exercise exists to give.
|
|
116
|
+
*/
|
|
117
|
+
completionDelayMs?: number;
|
|
118
|
+
onStepComplete?(step: TrainerStep, index: number): void;
|
|
119
|
+
/** Every step done. The host closes its modal here — the component never closes itself. */
|
|
120
|
+
onComplete?(): void;
|
|
121
|
+
}
|
|
122
|
+
export interface ControlTrainer {
|
|
123
|
+
readonly root: HTMLDivElement;
|
|
124
|
+
readonly pad: ControllerPad;
|
|
125
|
+
/** Which steps are done, by index. */
|
|
126
|
+
completed(): readonly boolean[];
|
|
127
|
+
/** Back to square one — every step un-done, prompts pulsing again. */
|
|
128
|
+
reset(): void;
|
|
129
|
+
dispose(): void;
|
|
130
|
+
}
|
|
131
|
+
export declare function mountControlTrainer(host: HTMLElement, opts: ControlTrainerOptions): ControlTrainer;
|
|
132
|
+
//# sourceMappingURL=control-trainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-trainer.d.ts","sourceRoot":"","sources":["../../../src/ui/controller/control-trainer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,KAAK,EAAkB,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAI3E,OAAO,EAAgD,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9G,OAAO,KAAK,EAAE,WAAW,EAAW,MAAM,YAAY,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC/E,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE;QACT,OAAO,EAAE;YAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;SAAE,CAAC;QACjC,SAAS,CAAC,CAAC,EAAE,E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