widgets
The touch control behaviours and their drawing: the six sticks (fixed, floating, follow, dpad8, arcade, drag) and the five button layouts (single, pair, diamond, radial wheel, hold-to-charge). Each turns touch contacts into action readings and draws itself in a skin. The overlay…
controlsKit.widgets
The touch control behaviours and their drawing: the six sticks (fixed, floating, follow, dpad8, arcade, drag) and the five button layouts (single, pair, diamond, radial wheel, hold-to-charge). Each turns touch contacts into action readings and draws itself in a skin. The overlay and the gallery both use it; a game normally doesn't touch 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/v2controlsKit.widgets — the on-screen controls themselves. Every widget is placed in logical points, owns the touches that began on it, writes what it means into a shared reading table, and draws itself in any skin. A widget can also be drawn from a borrowed display state (the gallery mirrors the keyboard and pad onto every widget that way). local w = Widgets.stick("floating", { x = 120, y = 600, r = 60, zone = {...} }, { action = "move" }) if w:hit(x, y) then w:begin(id, x, y) end ... w:move(id, x, y) ... w:finish(id) w:frame(dt); w:read(reading); w:draw(cmds, skin) Reading table: { vec = {[action]={x,y}}, axis = {[action]=n}, held = {[action]=true}, delta = {[action]={x,y}}, charge = {[action]=t}, released = {[action]=charge}, pulse = {[action]=true} } Vectors are x right / y UP, length <= 1 (8-way sticks give -1/0/1 per axis). Deltas are screen points, x right / y DOWN, like mouse movement.
len(x: number, y: number) → number
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
clamp(v: number, a: number, b: number) → number
| arg | type | description |
|---|---|---|
| v | number | |
| a | number | |
| b | number |
inRect(z: any, x: number, y: number) → boolean
| arg | type | description |
|---|---|---|
| z | any | |
| x | number | |
| y | number |
analog(ox: number, oy: number, r: number) → void
Radial deadzone, rescaled so the output still reaches 1 at the rim.
| arg | type | description |
|---|---|---|
| ox | number | |
| oy | number | |
| r | number |
digital8(ox: number, oy: number, r: number, dead: number) → void
8-way digital: each axis -1/0/1, from the nearest of eight directions.
| arg | type | description |
|---|---|---|
| ox | number | |
| oy | number | |
| r | number | |
| dead | number |
shortLabel(s: string?) → string
| arg | type | description |
|---|---|---|
| s | string? |
addVec(out: any, action: string, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| out | any | |
| action | string | |
| x | number | |
| y | number |
addDelta(out: any, action: string, dx: number, dy: number) → void
| arg | type | description |
|---|---|---|
| out | any | |
| action | string | |
| dx | number | |
| dy | number |
newReading( ) → any
An empty reading table for widgets to write into.
stick(variant: string, geom: any, opts: any) → any
A stick of one of the six variants. floating/follow/drag stick listens in.
| arg | type | description |
|---|---|---|
| variant | string | fixed | floating | follow | dpad8 | arcade | drag |
| geom | any | { x, y, r, zone? } — rest position, radius, and the zone a |
| opts | any | { action, axis? = "x", autoFire? = action, label? } |
place(g: any) → void
| arg | type | description |
|---|---|---|
| g | any |
floats( ) → boolean
hit(x: number, y: number) → boolean
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
begin(id: number, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| id | number | |
| x | number | |
| y | number |
move(id: number, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| id | number | |
| x | number | |
| y | number |
finish(id: number) → void
| arg | type | description |
|---|---|---|
| id | number |
frame(_dt: number) → void
| arg | type | description |
|---|---|---|
| _dt | number |
vector( ) → void
read(out: any) → void
| arg | type | description |
|---|---|---|
| out | any |
claims( ) → void
drawDpad(cmds: { any }, sk: any, cx: number, cy: number, r: number, vx: number, vy: number, active: boolean) → void
| arg | type | description |
|---|---|---|
| cmds | { any } | |
| sk | any | |
| cx | number | |
| cy | number | |
| r | number | |
| vx | number | |
| vy | number | |
| active | boolean |
drawArcade(cmds: { any }, sk: any, cx: number, cy: number, r: number, vx: number, vy: number, active: boolean) → void
| arg | type | description |
|---|---|---|
| cmds | { any } | |
| sk | any | |
| cx | number | |
| cy | number | |
| r | number | |
| vx | number | |
| vy | number | |
| active | boolean |
draw(cmds: { any }, sk: any, disp: any?) → void
Draw the stick. `disp` (optional) overrides what it shows: { x, y (vector, y up), active, showZone }.
| arg | type | description |
|---|---|---|
| cmds | { any } | |
| sk | any | |
| disp | any? |
cluster(layout: string, geom: any, opts: any?) → any
A button cluster from a layout placement.
| arg | type | description |
|---|---|---|
| layout | string | single | pair | diamond | radial | charge |
| geom | any | { buttons = { { action, x, y, r, role } }, extra = { wheelR, slices, x, y }? } |
| opts | any? | { labels = { [action] = label }, chargeTime? } |
button(geom: any, opts: any?) → any
A single round button (extras and corner buttons).
| arg | type | description |
|---|---|---|
| geom | any | |
| opts | any? |
place(g: any) → void
| arg | type | description |
|---|---|---|
| g | any |
buttonAt(x: number, y: number, slack: number) → number
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| slack | number |
hit(x: number, y: number) → boolean
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
begin(id: number, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| id | number | |
| x | number | |
| y | number |
sliceAt(x: number, y: number) → number
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
move(id: number, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| id | number | |
| x | number | |
| y | number |
finish(id: number) → void
| arg | type | description |
|---|---|---|
| id | number |
heldIndex(i: number) → boolean
| arg | type | description |
|---|---|---|
| i | number |
frame(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
read(out: any) → void
| arg | type | description |
|---|---|---|
| out | any |
claims( ) → void
labelFor(action: string?) → string
| arg | type | description |
|---|---|---|
| action | string? |
draw(cmds: { any }, sk: any, disp: any?) → void
Draw the cluster. `disp` (optional) overrides what it shows: { held = { [action] = true }, charge = t, wheel = sliceIndex }.
| arg | type | description |
|---|---|---|
| cmds | { any } | |
| sk | any | |
| disp | any? |
backdrop(geom: any) → any
A drag area behind every other control. One finger drags (delta, plus a stick-like vector from where it began); a second finger hands the pair over to pinch.
| arg | type | description |
|---|---|---|
| geom | any | { zone = { x0, y0, x1, y1 }, action, invert? } |
place(g: any) → void
| arg | type | description |
|---|---|---|
| g | any |
hit(x: number, y: number) → boolean
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
begin(id: number, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| id | number | |
| x | number | |
| y | number |
move(id: number, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| id | number | |
| x | number | |
| y | number |
finish(id: number) → void
| arg | type | description |
|---|---|---|
| id | number |
frame(_dt: number) → void
| arg | type | description |
|---|---|---|
| _dt | number |
read(out: any) → void
| arg | type | description |
|---|---|---|
| out | any |
claims( ) → void
draw(cmds: { any }, sk: any, disp: any?) → void
| arg | type | description |
|---|---|---|
| cmds | { any } | |
| sk | any | |
| disp | any? |
router(widgets: { any }) → any
A touch router over a list of widgets. Earlier widgets win a new touch; backdrops should come last.
| arg | type | description |
|---|---|---|
| widgets | { any } |
update(points: { any }, dt: number) → void
Feed this frame's touch points (logical points, with ids). Returns the set of ids a widget (not a backdrop) owns, and the free contacts.
| arg | type | description |
|---|---|---|
| points | { any } | |
| dt | number |
releaseAll( ) → void
Let go of every touch (scheme switch, hide).
read(out: any) → void
| arg | type | description |
|---|---|---|
| out | any |
claims( ) → 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.
Showing up to 3 levels deep. Open a part to see what it holds further down.
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.