input
Gamepad and touch for the Commander, through controlsKit. It registers the `rtsKit` controlsKit scheme (pad and touch only, so the Commander's keys never bind twice), reads it each frame (`read`, `device`, `glyph`), draws the pad's virtual cursor, and holds the pure rules the Com…
rtsKit.input
Gamepad and touch for the Commander, through controlsKit. It registers the rtsKit controlsKit scheme (pad and touch only, so the Commander's keys never bind twice), reads it each frame (read, device, glyph), draws the pad's virtual cursor, and holds the pure rules the Commander applies: stepCursor (cursor motion and edge push), navigate (d-pad focus on the command card), tapIntent (what a tap means), layoutFor (the compact phone layout), focusables / highlight (command card focus) and padHints. The Commander calls it; a game rarely needs it directly.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2rtsKit.input - gamepad and touch for the commander. The keyboard and mouse stay with the Commander exactly as they were. This module adds the other two devices through controlsKit, so prompts, device switching, the touch backdrop and the pinch come from one place: Gamepad Touch left stick pan one-finger drag pan right stick move the cursor pinch zoom LT / RT zoom out / in tap select, or order the selection there A select (hold: box) double tap every unit of that type on screen B order at the cursor long press add / remove a unit, or queue an order X attack-move Box button the next drag draws a selection box Y command card focus Army / Idle / ✕ select army / idle worker / clear LB (held) add / queue order buttons the command card (48 pt on phones) RB last alert build tap to place the ghost, then Place / Cancel d-pad army / stop / idle / hold (on the card: move the focus) View (select) cancel the order mode, then clear the selection Everything that decides something (cursor motion, focus moves, what a tap means, the phone layout) is a plain function, so the suite tests it headless.
stepCursor(x: number, y: number, v: { x: number, y: number }, dt: number, w: number, h: number) → void
Move the virtual cursor by a stick reading. Returns the new x, y and how hard it pushes past each screen edge (-1..1), which pans the camera.
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| v | { x: number, y: number } | |
| dt | number | |
| w | number | |
| h | number |
navigate(rects: { any }, from: string?, dir: string) → string
The next focus on the command card for a d-pad direction ("up", "down", "left", "right"), from button rects { id, x, y, w, h }: the nearest button whose centre lies that way, favouring ones in line. Wraps along the list when nothing lies that way. Returns the id (the first one when `from` is unknown).
| arg | type | description |
|---|---|---|
| rects | { any } | |
| from | string? | |
| dir | string |
tapIntent(ctx: any) → string
What a tap means. ctx = { placing, mode, under, hasUnits, hasWorkers, structureSelected, double, long } where `under` is "own" (one of your units), "enemy", "ownStructure", "ownSite" (your unfinished building), "enemyStructure", "node" (gold or tree) or "ground". Returns "place" (move the build ghost there), "mode" (finish the order mode there), "toggle" (add / remove the unit), "queue" (a queued smart order), "sameType", "select", "selectStructure", "order" (a smart order, as a right click), "clear" or "none".
| arg | type | description |
|---|---|---|
| ctx | any |
footprintHit(cands: { any }, x: number, z: number) → string
The footprint a ground point (x, z) falls in, from candidates { id, x, z, radius, length?, thickness?, yaw? } (buildings and resource nodes): a round footprint of `radius`, or a wall segment `length` long across its facing `yaw` (degrees) and `thickness` thick. The nearest centre wins. Returns the id, or nil.
| arg | type | description |
|---|---|---|
| cands | { any } | |
| x | number | |
| z | number |
layoutFor(w: number, h: number) → any
How the interface should lay out on a screen of w x h points: { compact, portrait }. Compact below 760 x 520 (phones, small windows).
| arg | type | description |
|---|---|---|
| w | number | |
| h | number |
focusables(tree: any) → void
Every focusable command button of a HUD tree, in tree order: the ids of nodes named `fc-btn-*` with a click, and the callback each one sends.
| arg | type | description |
|---|---|---|
| tree | any |
walk(n: any) → void
| arg | type | description |
|---|---|---|
| n | any |
callbacks(tree: any) → void
Every clickable widget of a HUD tree: { [id] = callback } (buttons, portraits, group chips, the minimap), so the pad's cursor can press them.
| arg | type | description |
|---|---|---|
| tree | any |
walk(n: any) → void
| arg | type | description |
|---|---|---|
| n | any |
highlight(tree: any, id: string?) → boolean
Ring the focused button of a HUD tree (the pad's command card focus). Returns true when the id was found.
| arg | type | description |
|---|---|---|
| tree | any | |
| id | string? |
walk(n: any) → void
| arg | type | description |
|---|---|---|
| n | any |
padHints(glyph: (string) → void
The words of a pad prompt line, from a prompt function (action -> controlsKit prompt label text).
| arg | type | description |
|---|---|---|
| glyph | (string |
start( ) → void
Switch controlsKit's player 1 to the commander scheme. Returns (ok, token): ok is false when controlsKit cannot be reached (the keyboard and mouse still work); hand the token to `stop` when this user is done.
takeGestures( ) → void
The taps, double taps and long presses since the last call, oldest first: { kind, id, x, y, clock } (x, y in logical points; clock is os.clock()).
ensureScheme( ) → boolean
Put player 1 back on the commander scheme if something else switched it (another kit's `Controls.use`, or a stop that handed the scheme back). Returns true when the commander scheme is in place.
stop(token: number?) → void
This user is done (`token` from `start`); controlsKit is handed back once no user is left.
| arg | type | description |
|---|---|---|
| token | number? |
controls( ) → any return Controls end
device( ) → string
"keyboard", "pad" or "touch": what the player is holding now.
read( ) → any
One frame of readings: { pan, cursor, drag, zoom, pressed = {}, held = {}, released = {} }.
glyph(action: string) → string
The legend for an action on the pad in hand ("A", "Cross", "LT/RT").
| arg | type | description |
|---|---|---|
| action | string |
isInterfaceScreen(screen: any) → boolean
Does a hit on the UI screen named `screen` belong to the interface? controlsKit's own touch layer, the pad cursor, the editor's own chrome (the Scene panel the game draws in) and productionKit's building badges do not: the badges are labels over the map, and their pulsing rings catch hits (their `pointerEvents = "none"` sits on svgs and labels, which do not read it), so a tap beside a busy building was dropped as a tap on the interface.
| arg | type | description |
|---|---|---|
| screen | any |
overUi(x: number, y: number) → boolean
Is the window point (x, y), in logical points (the space `ui.hitTest` and `ui.getLayoutInfo` use), over a widget of some screen (so a tap there belongs to the interface, not the map)? See `isInterfaceScreen`.
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
toUi(px: number, py: number, space: string?) → void
Carry a scene viewport pixel (a pad cursor, a touch, `worldToScreen`) to the UI: `space` "window" (default) for `ui.hitTest` / `overUi`, "camera" for where a HUD widget would sit over it. Differs from dividing by the pixel ratio whenever the editor's Scene panel holds the game view.
| arg | type | description |
|---|---|---|
| px | number | |
| py | number | |
| space | string? |
overUiAtViewport(px: number, py: number) → boolean
Is the scene viewport pixel (px, py) over the interface?
| arg | type | description |
|---|---|---|
| px | number | |
| py | number |
drawCursor(show: boolean, x: number?, y: number?, mode: string?) → void
Draw (or hide) the pad cursor at logical (x, y). `mode` tints it: an order mode or placement shows amber, otherwise white.
| arg | type | description |
|---|---|---|
| show | boolean | |
| x | number? | |
| y | number? | |
| mode | string? |
removeCursor( ) → void
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.