input
The input namespace: 63 functions.
input/armObservation
input.armObservation(on: boolean?)
Hold the input observation's mapping half open (true, the default) or close it now (false). A read arms it for a window of frames on its own, so this is for a test or a tool that wants the mapping half building continuously, or wants to stop paying for it the moment it is done.
Parameters
onboolean?— Arm (default) or disarm.
input/backUnanswered
input.backUnanswered()
Hand a Back press the script holding Back took back to the platform's own default, because no claim was held when it arrived. Internal: backs Zin.back.
input/emulateKeyDown
input.emulateKeyDown(code)
The input-emulation floor's write surface: mark code held by the floor. Merged into the default polling views (isDown, snapshot().keys) so Zin.state.keyDown cannot tell an emulated hold from a real one; tracked separately in snapshot().keys_emulated, and readable real-only via Zin.state.keyDownReal. Drained before the next frame's controller scripts run, like simulate* — but pushes no frame event and is never forwarded to the UI layer: emulated input exists for polling surfaces, and event-driven consumers already receive the real touch events the floor was driven from. code is resolved against the KeyboardEvent.code vocabulary, so an emulated hold is held under the code content reads; a name outside it raises. Internal — backs the map-driven emulation floor.
Parameters
codestring— Key code
input/emulateKeyUp
input.emulateKeyUp(code)
Release code from the input-emulation floor. Only lifts the held state if a real key-press hasn't since claimed the code (real press owns the key). code is resolved against the KeyboardEvent.code vocabulary, and a name outside it raises. No frame event, no UI forwarding. Internal — backs the map-driven emulation floor.
Parameters
codestring— Key code in KeyboardEvent.code form ("KeyW", "Space", "ShiftLeft"), or a single letter or digit
input/emulateMouseButton
input.emulateMouseButton(button, held)
Set emulated mouse button button (0=left, 1=right, 2=middle) held/released from the input-emulation floor. Mirrors emulateKeyDown/emulateKeyUp: a real mouse press owns the button thereafter. No frame event, no UI forwarding. Internal — backs the map-driven emulation floor.
Parameters
buttonnumber— Button index (0=left, 1=right, 2=middle)heldboolean— True to hold, false to release
input/emulateMouseDelta
input.emulateMouseDelta(dx, dy)
Accumulate an emulated mouse-delta contribution from the input-emulation floor into this frame's mouse_delta. No frame event, no UI forwarding. Internal — backs the map-driven emulation floor.
Parameters
dxnumber— Delta Xdynumber— Delta Y
input/events
input.events() -> {table}
Get the current frame's input events as an array of { kind = '...', ... } records in dispatch order. Internal — Zin wraps this as Zin.events.frame(). Every x, y is in the space input.snapshot() states mouse_position and its touches in: the scene viewport's physical pixels, measured from the top-left of the rect the scene is drawn into, which ui.fromViewport(x, y) carries into the UI's logical points. A mouse event the primary touch contact drove carries that contact's id as touch; a mouse's own carries none. An event a script's simulated input produced carries simulated = true; a device's carries none. Variants produced today: key.down { code, repeat }, key.up { code }, mouse.down { button, x, y, touch? }, mouse.up { button, x, y, touch? }, mouse.move { x, y, dx, dy, touch? }, mouse.wheel { dx, dy }, text { text }, touch.down { id, x, y, pressure }, touch.move { id, x, y, dx, dy, pressure }, touch.up { id, x, y }, touch.cancel { id }, gamepad.connected { slot, name }, gamepad.disconnected { slot }, gamepad.down { slot, button }, gamepad.up { slot, button }, gamepad.axis { slot, axis, value }, gamepad.device_down { slot, index }, gamepad.device_up { slot, index }, gamepad.device_axis { slot, index, value } (a device element by its 0-based index). Returns an empty array if no events have been published yet. Cleared at end of frame (PostRender). Reading does not consume.
Returns {table} — Frame events in dispatch order
input/frameId
input.frameId() -> integer
Get the engine's monotonic frame counter. Bumped once per frame at PostRender. Internal — used by Zin.tick to dedup cross-coroutine double-ticks within the same engine frame. Stable across multiple reads inside the same frame, strictly greater after a task.wait(0) yield. Returns 0 only before the very first frame has elapsed.
Returns integer — Monotonic frame counter
input/frameSeconds
input.frameSeconds() -> number
Wall seconds the frame being run lasted, apart from any time the loop waited before it on a still engine, and held to the frame clock's hitch bound. Unaffected by time.timeScale(). Internal: the length of the frame Zin.autoTick wakes on after the input layer has been at rest.
Returns number — Seconds this frame lasted
input/gamepadForce
input.gamepadForce(slot, effects)
Hold force-feedback effects on the wheel or stick in slot, replacing what it held: each effect named plays until the next call, and one left out stops, so a game calling it every tick with the forces of the moment drives the device continuously. constant is a force -1..1 along the device's first axis (a wheel's rotation), a positive and a negative level pushing it opposite ways. spring, damper and friction each take a strength -1..1, or { strength, saturation? (0..1, default 1), center? (-1..1, default 0), deadband? (0..1, default 0) }. Refuses, naming the reason, a slot no pad holds and an effect the pad's haptics states unavailable on this platform and device. The pad's snapshot record carries force while effects hold, with error when the device refused them. Backs Zin.gamepad.force.
Parameters
slotnumber— Pad sloteffectstable— { constant?, spring?, damper?, friction? }
input/gamepadRumble
input.gamepadRumble(slot, rumble)
Play rumble on the pad in slot for seconds, replacing whatever it was playing: strong (the low-frequency body motor) and weak (the high-frequency one), and leftTrigger / rightTrigger (the trigger motors), each 0..1 and 0 when omitted. Refuses, naming the reason, a slot no pad holds and a motor the pad's haptics states unavailable on this platform and device. The pad's snapshot record carries rumble while it plays, with error when the device refused it. Backs Zin.gamepad.rumble.
Parameters
slotnumber— Pad slotrumbletable— { strong?, weak?, leftTrigger?, rightTrigger?, seconds }
input/gamepadStopForce
input.gamepadStopForce(slot)
Release every force-feedback effect the pad in slot holds. Backs Zin.gamepad.stopForce.
Parameters
slotnumber— Pad slot
input/gamepadStopRumble
input.gamepadStopRumble(slot)
Stop whatever rumble the pad in slot is playing. Backs Zin.gamepad.stopRumble.
Parameters
slotnumber— Pad slot
input/isAnyDown
input.isAnyDown({name, ...}) -> boolean, string?
Are any of the given keys currently held? Returns held, which: when any key in the array is held, held=true and which is the first matched code (in iteration order); otherwise false, nil. Internal — used by Zin.
Parameters
names{string}— Array of key codes to check
Returns boolean, string? — (held, first matched code or nil)
input/isDown
input.isDown(name) -> boolean
Is the given key currently held this frame? Internal — Zin wraps this as Zin.state.keyDown(name). Direct lookup on the published snapshot's keys array.
Parameters
namestring— Key code (e.g. "KeyD", "Space", "ShiftLeft")
Returns boolean — True if the key is held this frame
input/markBaseline
input.markBaseline() -> number
Read every device as it stands — the keys and buttons held, the contacts down, the pads connected and what they hold, the pointer's position and lock, the UI focus pin, the scene context and the touch and pad capabilities — and make that reading the state input.resetToBaseline puts the devices back to. The reading is taken where the call lands in the queue of simulated input, so input queued before it is inside the reading and input queued after it is not. A caller that runs in someone else's engine — a sweep of test suites sharing one — marks before it begins, so what it leaves held is let go for the next.
Returns number — The mark's generation, counting from 1 — what input.resetToBaseline takes to restore to this mark.
local mark = input.markBaseline()
input/noteChange
input.noteChange()
State a change of the input layer that no device made: the mapping layer's own structure moved (a map activated, a context changed, a virtual control written). It advances the input change clock, so a task waiting in __waitChange("input") resumes on the next scheduler tick. Internal — called by the mapping layer when it marks itself dirty.
input/observationArmedFrames
input.observationArmedFrames() -> integer
How many more frames the arming window has left before a mapping layer stops building its half of the input observation. A read of input.observe() or of /runtime/input sets it back to the full window; every frame that passes takes one off it, and 0 means nothing is observing.
Returns integer — Frames left in the arming window.
input/observationWanted
input.observationWanted() -> boolean
Whether something has read the input observation recently enough that a mapping layer should spend a frame building its half of it. A read of input.observe() or of /runtime/input arms this for a window of frames; a world nobody is observing reads false and pays nothing. Internal — the mapping layer's per-frame tick consults it.
Returns boolean — Whether a mapping report is wanted this frame.
input/observe
input.observe() -> table
Report what the input layer did with the last completed frame: every device event that arrived with the surface it came from and whether the UI took it (consumed_by_ui), the pointer-lock quartet, which focus the UI holds, what device classes the session has, and — while the mapping layer is publishing — its account of which controls those events became and why a live control stayed silent. The observation covers ONE engine frame, the frame that has just been drawn; a read taken from a script during frame N answers for frame N-1. Reading consumes nothing and clears nothing, so any number of observers see the same frame. mappingStatus says whether the mapping half is current, stale, arming (this read armed it — read again), or unarmed. Serialised from the same document /runtime/input serves.
Returns table — The engine's current input observation.
input/pressBack
input.pressBack()
Press Back, routed the way the platform's own Back is: the topmost overlay that states how it is dismissed is dismissed, else the script holding Back takes it, else the platform's own default answers it (an Android app moves to the background). The press is a back event naming its taker. Internal: backs Zin.back.press.
input/publishMapping
input.publishMapping(report: table)
Publish the mapping layer's account of this frame into the engine's input observation, where input.observe() and the /runtime/input node serve it beside the device half. Internal — called once per frame by the mapping layer's tick while input.observationWanted() holds.
Parameters
reporttable— The mapping layer's report for this frame.
input/releaseBaseline
input.releaseBaseline(generation)
Drop the reading input.markBaseline took under generation, and every reading taken after it, once the caller that took it is done resetting to it. The devices stay as they stand. It lands in the queue of simulated input after everything queued before it, so a reset queued first still reads the mark it names.
Parameters
generationnumber— The mark to drop, asinput.markBaselinereturned it.
input.releaseBaseline(mark)
input/releasePointerLock
input.releasePointerLock()
Release pointer lock (cursor ungrab + show). Internal — backs Zin.pointer.unlock().
input/releaseUiFocus
input.releaseUiFocus()
Give the UI's focus pair back to the UI pass, which writes its own opinion on its next run. Internal — backs Zin.test.releaseUiFocus().
input/releaseXrControllers
input.releaseXrControllers()
Queue the release of every injected controller control on both hands and of the injected head, returning them to what the runtime reports. A baseline restore does the same.
input/requestPointerLock
input.requestPointerLock()
Request pointer lock (cursor grab + hide). Internal — backs Zin.pointer.lock().
input/resetToBaseline
input.resetToBaseline(generation?) -> number
Put every device back to the reading input.markBaseline took: a key or button held since is released and one held then is pressed again, a contact begun since is lifted, a pad this surface connected since is unplugged and what a pad holds is put back, the pointer returns to its position and its lock to what it was, and the UI focus pin, the scene context and the touch and pad capabilities read as they did. Each change travels the path the device's own event takes, so the UI learns of a release the way it learned of the press. The restore lands with the next drain of simulated input, one frame on.
Parameters
generationnumber(optional) — The mark to restore to, asinput.markBaselinereturned it; the newest mark when omitted. The marks taken after it go with the reset.
Returns number — How many frames stand between the call and the devices reading restored: 1.
input.resetToBaseline(mark)
input/setBackClaimed
input.setBackClaimed(claimed, byWorld?)
State whether a script holds Back. While it does, a Back press no overlay takes is recorded as a back event taken by claim, and the platform is told the app takes Back. byWorld states whether one of the claims is the world's own rather than one standing for the platform's Back; a pad's east on a game menu reaches only those. Internal: backs Zin.back.claim, which holds the claims themselves.
Parameters
claimedboolean— Whether any claim on Back is heldbyWorldboolean?— Whether a claim of the world's own is held;claimedwhen omitted
input/setTouchClaims
input.setTouchClaims(owner, regions, zones?)
State the regions of the window an owner's on-screen controls hold, replacing the ones it stated before; empty lists let go of them. Every touch contact is routed on its own, by where it began. A contact that begins inside one of an owner's regions belongs to the control there: it reaches the game as a touch, and drives no pointer, so no UI widget beneath the control receives it and no mouse button reads held. A contact that begins inside one of its zones (a movement stick's or a look area's) is offered to the UI first: it drives the pointer while no other contact does, a widget beneath it that takes its press keeps it, and once the UI leaves the press the contact is the control's, letting the pointer go without the scene reading a press; while another contact drives the pointer it is the control's at once. A contact beginning anywhere else drives the pointer while no other contact does. Zin.touch states each contact's owner. Regions are in the window pixels touch contacts arrive in. Backs the on-screen touch controls.
Parameters
ownerstring— Who holds the regions; each owner's lists stand on their ownregions{ { x: number, y: number, radius: number?, w: number?, h: number? } }— Each a disc{ x, y, radius }around its centre, or a box{ x, y, w, h }from its top-left cornerzones{ { x: number, y: number, radius: number?, w: number?, h: number? } }(optional) — Regions whose contacts a UI widget beneath them takes first, each shaped as a region is; none when omitted
input/simulateClipboard
input.simulateClipboard(content?)
State what the clipboard holds, in place of the host clipboard, until it is stated again or nil hands it back: { text?, image? }, image the bytes of a PNG, the file a screenshot tool offers. Ctrl+V reads it the way it reads the host's, a picture going to the widget taking pasted files through onFilePaste, and a copy writes its text. A browser engine hands its clipboard over through the page's paste event, so it raises there: input.simulateFilePaste drives the path that event posts to. Internal: backs Zin.test.setClipboard().
Parameters
contenttable(optional) —{ text?, image? }, or nil for the host clipboard
input/simulateFileDrag
input.simulateFileDrag(x, y, count)
Stand a drag of count files from outside the engine at this point of the WINDOW, in physical pixels, the way a person holding files over it does: the widget there reports it through onFileHover. Internal — backs Zin.test.dragFiles().
Parameters
xnumber— Window X (physical pixels)ynumber— Window Y (physical pixels)countnumber— How many files the drag carries
input/simulateFileDragEnd
input.simulateFileDragEnd()
End the drag of files input.simulateFileDrag stood over the window, the way a person carrying it off does. Internal — backs Zin.test.endFileDrag().
input/simulateFileDrop
input.simulateFileDrop(x, y, files)
Land files on this point of the WINDOW, in physical pixels, through the path a drop from the desktop takes: the widget there receives them through onFileDrop, each held to ui.maxFileBytes(). Each file is { name, bytes, type? }, type read off the name when omitted, or { name, error } for one that arrives refused ("tooLarge", "unreadable"). Internal — backs Zin.test.dropFiles().
Parameters
xnumber— Window X (physical pixels)ynumber— Window Y (physical pixels)filestable— List of { name, bytes, type? } or { name, error }
input/simulateFilePaste
input.simulateFilePaste(files)
Paste files through the path a clipboard image takes: the widget a paste lands on receives them through onFilePaste. Each file is as input.simulateFileDrop takes it. Internal — backs Zin.test.pasteFiles().
Parameters
filestable— List of { name, bytes, type? } or { name, error }
input/simulateGamepadAxis
input.simulateGamepadAxis(slot, axis, value)
Queue a simulated pad-axis move. axis is a canonical name: left_stick_x, left_stick_y, right_stick_x, right_stick_y, left_trigger, right_trigger, with case and word separators folded away and a name outside the vocabulary raising. Stick axes clamp to -1..1 with y screen-down positive; trigger axes clamp to 0..1 and latch their digital button at 0.5. Internal — backs the inputSim toolbox's padStick / padTrigger.
Parameters
slotnumber— Pad slotaxisstring— Canonical axis namevaluenumber— Axis value
input/simulateGamepadButton
input.simulateGamepadButton(slot, button, held)
Queue a simulated pad-button state change. button is a canonical name: south, east, west, north, left_shoulder, right_shoulder, left_trigger, right_trigger, left_stick, right_stick, select, start, guide, dpad_up, dpad_down, dpad_left, dpad_right. Case and word separators fold away, so "South" and "LeftShoulder" reach the same buttons the canonical spellings name; a name outside the vocabulary raises, naming every canonical button. Internal — backs the inputSim toolbox's padDown / padUp.
Parameters
slotnumber— Pad slotbuttonstring— Canonical button nameheldboolean— True for down, false for up
input/simulateGamepadConnect
input.simulateGamepadConnect(name?, device?) -> ()
Queue a simulated pad connection. The pad takes the lowest free slot and reports name (default "Simulated Gamepad") as its device name. With no device it presents the W3C standard gamepad (four stick axes, seventeen buttons, each carrying its canonical name) with rumble motors. device describes another: { axes = n, buttons = n } for a device laid out by no mapping (a wheel, pedals, a flight stick), rumble = false for one with no body motors, triggerRumble = true for one with trigger motors, force = true for one that plays force-feedback effects, id / vendor / product for its identity. Internal — backs Zin.test.connectPad. Read the slot it took from the next frame's snapshot gamepads array.
Parameters
namestring?— Device name the pad reportsdevicetable(optional) — { axes?, buttons?, rumble?, triggerRumble?, force?, id?, vendor?, product? }
input/simulateGamepadDeviceAxis
input.simulateGamepadDeviceAxis(slot, index, value)
Queue a simulated move of the device's own axis index (0-based, in the device's order), -1..1 across its range. An axis the device names (the standard layout's sticks) moves its canonical axis too. Internal — backs Zin.test.padDeviceAxis.
Parameters
slotnumber— Pad slotindexnumber— 0-based device axis indexvaluenumber— Axis value -1..1
input/simulateGamepadDeviceButton
input.simulateGamepadDeviceButton(slot, index, held, value?)
Queue a simulated change of the device's own button index (0-based, in the device's order): held or not, and its travel 0..1 (1 when held, 0 when not, unless value says). A button the device names (the standard layout's seventeen) drives its canonical button, or its trigger axis for the two triggers. Internal — backs Zin.test.padDeviceButton.
Parameters
slotnumber— Pad slotindexnumber— 0-based device button indexheldboolean— True for down, false for upvaluenumber(optional) — Travel 0..1
input/simulateGamepadDisconnect
input.simulateGamepadDisconnect(slot)
Queue a simulated pad disconnection. Anything the pad still held publishes its button-up first. Internal — backs the inputSim toolbox's disconnect.
Parameters
slotnumber— Pad slot to disconnect
input/simulateKeyDown
input.simulateKeyDown(key, target?)
Queue a simulated key-down event. key is resolved against the KeyboardEvent.code vocabulary: a code reaches itself, a differently-cased spelling reaches the canonical one, and a single letter or digit reaches its Key<L> / Digit<N> code, so the snapshot holds what a real keyboard reports. A name outside the vocabulary raises, naming the nearest code. Drained before the next frame's controller scripts run. Internal — backs Zin.test.pressKey(); production code should not call this directly.
Parameters
keystring— Key code in KeyboardEvent.code form ("KeyW", "Space", "ShiftLeft"), or a single letter or digittargetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateKeyUp
input.simulateKeyUp(key, target?)
Queue a simulated key-up event. key is resolved against the KeyboardEvent.code vocabulary exactly as simulateKeyDown resolves it, and a name outside it raises. Internal — backs Zin.test.releaseKey().
Parameters
keystring— Key code in KeyboardEvent.code form ("KeyW", "Space", "ShiftLeft"), or a single letter or digittargetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateMouseDown
input.simulateMouseDown(button?, target?)
Queue a simulated mouse-button-down event. 0=left (default), 1=right, 2=middle. Internal — backs Zin.test.pressMouse().
Parameters
buttonnumber— Button index (default: 0)targetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateMouseMove
input.simulateMouseMove(x, y, target?)
Place the pointer on the WINDOW, in physical pixels. input.snapshot().mouse_position reads it back in the scene viewport's space, which worldToScreen answers in too: the window point less the origin camera.viewData().viewport carries. A point taken from either of those reaches the place it names by adding that origin, and the two spaces are one wherever the scene is drawn across the whole window. A logical layout coordinate (getLayoutInfo / ui.screenSize) converts to window pixels with ui.pixelRatio(). Internal — backs Zin.test.moveMouse().
Parameters
xnumber— Window X (physical pixels)ynumber— Window Y (physical pixels)targetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateMouseMoveBy
input.simulateMouseMoveBy(dx, dy, target?)
Move the pointer by a relative motion, the way a mouse device reports it: the contribution accumulates into this frame's mouse_delta and advances the position by the same amount. Repeating the same (dx, dy) keeps delivering it. Internal — backs Zin.test.moveMouseBy().
Parameters
dxnumber— Horizontal motion in screen pixelsdynumber— Vertical motion in screen pixelstargetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateMouseUp
input.simulateMouseUp(button?, target?)
Queue a simulated mouse-button-up event. Internal — backs Zin.test.releaseMouse().
Parameters
buttonnumber— Button index (default: 0)targetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateMouseWarp
input.simulateMouseWarp(x, y)
Place the pointer on the WINDOW, in physical pixels, the way a cursor warp does: the pointer the UI reads and the one the scene reads both stand at the point, and the placement reports no motion, so mouse_delta and the mouse.move event's dx / dy carry none of the distance it covered. A control bound to pointer motion (a mouse look) reads nothing from it. Coordinates are those input.simulateMouseMove takes. Internal: backs the rest Zin.test.focusScene() puts the pointer at.
Parameters
xnumber— Window X (physical pixels)ynumber— Window Y (physical pixels)
input/simulateSceneContext
input.simulateSceneContext(active?: boolean)
Hand the active input context to the scene (true, the default)
or to the UI (false). While a viewport widget is on screen the
scene owns continuous pointer input — buttons, motion, scroll —
only while it is the active context, which a pointer gesture
decides by where it begins; this decides it without one. The next
gesture decides it again. Internal — backs Zin.test.focusScene().
Parameters
activeboolean— true hands the context to the scene, false to the UI (default: true)
input/simulateScroll
input.simulateScroll(dy, target?)
Queue a simulated mouse-wheel event. Internal — backs Zin.test.scroll().
Parameters
dynumber— Scroll delta (positive = up)targetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateTouchCancel
input.simulateTouchCancel(id, target?)
Queue a simulated platform touch-cancel for an active finger id.
Parameters
idnumber— Stable finger idtargetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateTouchCapable
input.simulateTouchCapable(capable)
Queue a simulated declaration of whether the session has a touch device, the way a platform declares one at boot. A simulated contact stands for a touch source only while it is on the glass; a test or an agent that checks a touch session on a desktop (a scroll area panning under a finger's drag, the surface class a touch session starts in) declares one here, and declares it gone the same way. A suite's input baseline puts the declaration back when the suite ends.
Parameters
capableboolean— Whether the session has a touch device
input/simulateTouchDown
input.simulateTouchDown(id, x, y, pressure?, target?)
Queue a simulated touch-contact-begin event, placed on the WINDOW in physical pixels, the space a finger on the glass arrives in and simulateMouseMove takes. input.snapshot() and input.events() read the contact back in the scene viewport's space: the window point less the origin camera.viewData().viewport carries. A UI widget sits at its getLayoutInfo rect times ui.pixelRatio(). id is any stable number identifying the finger until its matching simulateTouchUp/Cancel. Drained before the next frame's controller scripts run. The primary touch (slot 0) also drives the mouse path. Internal — backs Zin test touch helpers.
Parameters
idnumber— Stable finger idxnumber— Window X (physical pixels)ynumber— Window Y (physical pixels)pressurenumber— Contact pressure 0..1 (default: 1.0)targetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateTouchMove
input.simulateTouchMove(id, x, y, pressure?, target?)
Queue a simulated touch-move event for an active finger id, to a point on the WINDOW in physical pixels (see simulateTouchDown).
Parameters
idnumber— Stable finger idxnumber— Window X (physical pixels)ynumber— Window Y (physical pixels)pressurenumber— Contact pressure 0..1 (default: 1.0)targetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateTouchUp
input.simulateTouchUp(id, target?)
Queue a simulated touch-lift event for an active finger id.
Parameters
idnumber— Stable finger idtargetstring(optional) —"game"(the default): the game's input alone — the scene reads it whatever surface a person at the window holds, and no UI widget receives it."ui": the UI, the way a person's device reaches it — delivered to the focused or hovered widget, a press deciding the active input context by where it lands.
input/simulateUiFocus
input.simulateUiFocus(pointer: boolean, keyboard: boolean)
Hold the UI layer's two focus opinions at pointer and keyboard until input.releaseUiFocus() gives them back to the UI pass. The pair decides, per event surface, whether the UI took an event: a pointer event is judged on pointer focus and a key on keyboard focus, so a run with no UI on screen can still put a handler on either side of consumed_by_ui. Queued like every other simulated input, so the events queued behind it are stamped against it. Internal — backs Zin.test.uiFocus().
Parameters
pointerboolean— Whether the UI holds pointer focuskeyboardboolean— Whether the UI holds keyboard focus
input/simulateXrController
input.simulateXrController(hand, control, ...)
Queue controller state for an XR session, injected where the runtime's action set enters the engine: the injected values replace what the runtime reports for that control, and the engine reads them exactly as it reads a held controller's, so the pad, the turning, the pointer ray and xr.controller all follow. Driving any control makes the hand active. control is one of active (0 or 1), thumbstick (x, y), thumbstick_click (0 or 1), trigger (0..1), squeeze (0..1), primary (0 or 1: A right, X left), secondary (0 or 1: B right, Y left), menu (0 or 1), grip or aim (position x, y, z then orientation x, y, z, w, in the tracking space). Two controls stand in for hand tracking instead of a controller: hand (twelve numbers, the palm's position x, y, z and orientation x, y, z, w in the tracking space, then the curl of the thumb, index, middle, ring and little finger from 0 open to 1 closed, and optionally a thirteenth, a pinch from 0 to 1 that brings the thumb's tip onto the index fingertip) poses a modelled hand, and joints (26 joints of eight numbers each: position x, y, z, orientation x, y, z, w, radius) states every joint; a hand with joints and no controller is driven by hand tracking. With no values the control returns to the runtime. The state takes effect while the session holds input focus. Internal — backs the inputSim toolbox's xr.
Parameters
handstring— 'left_hand' or 'right_hand'controlstring— The control to inject...number(optional) — The control's values; none releases it
input/simulateXrHead
input.simulateXrHead(...)
Queue a head pose for an XR session, injected where the runtime's located head enters the engine: seven numbers, position x, y, z then orientation x, y, z, w, in the tracking space. Both eyes move rigidly with it, so the picture, xr.pose("head"), the facing camera.facing reports and the look ray all follow. With no values the head returns to the runtime. The pose takes effect while the session draws frames. Internal — backs the inputSim toolbox's xrHead.
Parameters
...number(optional) — x, y, z, qx, qy, qz, qw; none releases the head
input/simulateXrRuntimeExit
input.simulateXrRuntimeExit()
Make the runtime of the simulated XR session ask the app to exit, the way a headset's runtime does when it quits: the session ends on its next poll, the engine takes the session down and looks for a headset again. Native engines only; a browser engine raises. Internal — the XR test suite ends a session with it.
input/simulateXrSession
input.simulateXrSession(on)
Start (true) or stop (false) a simulated XR session, which the engine takes for a headset's: it holds input focus from its first frame, paces frames by the engine's clock, locates a head standing at the tracking space's origin 1.6 m up and facing -Z (input.simulateXrHead moves it) with two eyes 64 mm apart through symmetric 90 degree frusta, and reports the controllers and hands input.simulateXrController states. The eyes are drawn at 1024 by 1024 pixels each and shown to no compositor. The session starts and stops on the next frame, and stopping it returns every read to what an engine with no session answers. A headset's session that stands is left as it is. Native engines only; a browser engine raises. Internal — backs Zin.test.xrSession.
Parameters
onboolean— true starts the simulated session, false stops it
input/simulateXrUnfocused
input.simulateXrUnfocused(wait_ms)
Make the simulated XR session a headset that does not show its frames (the headset is off, the system menu or the desktop holds the session): it stands in the synchronized state, loses input focus, and each wait of its frame loop for the next frame takes wait_ms milliseconds, the pace a runtime throttles such a session to. The engine's frames do not wait for those waits, and no eyes are drawn. 0 gives the session focus back. Takes effect on the session's next poll. Native engines only; a browser engine raises. Internal — backs Zin.test.xrUnfocused.
Parameters
wait_msnumber— milliseconds each wait for a frame takes while unfocused; 0 restores focus
input/simulateXrWorn
input.simulateXrWorn(worn)
Take the simulated XR session's headset off (false) or put it on again (true). Taken off, the session reports the headset not worn and stands in the synchronized state, and its runtime holds each begin and end of a frame the way a runtime holds the frames of a session it does not show; the engine begins no frame then, so its own frames run at their pace and no eyes are drawn. Worn again, the frame loop runs, and the session takes focus once a frame has ended. Takes effect on the session's next poll. Native engines only; a browser engine raises. Internal — backs Zin.test.xrWorn.
Parameters
wornboolean— false takes the headset off, true puts it on again
input/snapshot
input.snapshot() -> table
Get the current frame's input state as a table. Internal — Zin wraps this as Zin.state.get(). Fields: keys, keys_pressed, keys_released — ARRAYS of pressed key code strings (e.g. {"KeyD", "Space"}). NOT a {KeyD=true} dict; t.keys["KeyD"] is always nil. They are the scene's keys: the ones pressed while the scene was the active input context (see scene_context). editor_keys, editor_keys_pressed, editor_keys_released — the same arrays for the editor, which answers to every key no focused widget took, including keys pressed after a click on a panel. keys_emulated — array of key codes held by the input-emulation floor, a subset of keys (merged there for polling); Zin.state.keyDownReal reads keys minus keys_emulated. mouse_position, mouse_delta: [x, y], the position in the scene viewport's physical pixels, measured from the top-left of the rect the scene is drawn into: the space capture and worldToScreen answer in and screenToRay takes, which is the window's own wherever the scene is drawn across the whole window; ui.fromViewport(x, y) carries such a position into the logical points a screen lays out in ("window" for the space ui.getLayoutInfo and ui.hitTest use); mouse_buttons, mouse_pressed, mouse_released — [L, R, M] bool arrays (InputResource convention); scroll_delta — number; pointer_locked, ui_focused: booleans; pointer_lock_requested — boolean, whether a script's pointer-lock request stands; pointer_lock_suppressed — boolean, true while the cursor belongs to the person (gameplay paused, a shown screen holding the pointer, or the editor sharing the window with no scene picture on it), which holds a standing request ungranted; pointer_held_by_ui: array of the names of the shown screens holding the pointer (an open modal, a widget stating holdsPointer = true); pointer_lock_armed — boolean, whether a click on the focused surface has armed the capture since the last focus loss or mode change; ui_took_press: boolean, true while a UI widget sensing a click or a drag holds the press in progress, nil until a UI pass has decided a press that arrived; pointer_owner — "scene", "ui" or "undecided": whose a person's pointer is this frame. While it is "ui" (a widget answering for the pointer stands under it or holds the press, or a screen holds the pointer, with the mouse free or a finger holding the press) or "undecided" (a finger's press waits for a UI pass to decide it), mouse_delta, mouse_buttons, mouse_pressed, mouse_released and scroll_delta carry only what a script drove the game with and the motion the emulation floor synthesized; a finger's press the UI leaves to the scene reaches mouse_pressed on the frame it is decided; keyboard_owner — "scene", "ui" or "shared": whose a person's keyboard is. "ui" while a widget taking every key holds focus (a text field with the caret, a terminal, a widget with its own onKey); "shared" while a focused widget takes some keys, the ones ui_keys names (Space and Enter for a button, the arrows, Home, End, Page Up and Page Down as well for a slider), and keys carries every other key; touches: array of { id, slot, x, y, dx, dy, pressure, phase, pointer, owner, widget, simulated } per active finger contact, x/y in the space mouse_position reads in (slot 0 = primary; phase: began|moved|stationary|ended|cancelled; pointer: whether it drives the UI's pointer; owner: the on-screen controls holding it, absent while none does; widget: whether a widget of the UI holds its press beside the contact driving the pointer; simulated: whether a script simulated it); pointer_contact — the id of the contact driving the pointer, whose motion and press the mouse fields carry, a contact simulated for the game alone included (its record's pointer reads false, since it reaches no UI); nil while no contact drives it; touch_capable — boolean, true once the session has (or declares) a touch device, and while a simulated contact is on the glass; gamepads — array of { slot, name, buttons, buttons_pressed, buttons_released, axes, simulated, device, device_axes, device_buttons, device_held, device_pressed, device_released, haptics, rumble } per connected pad, ordered by slot (button fields are ARRAYS of canonical names, axes is a map of canonical axis name to number; device is { id, name, vendor, product, mapping, axes = {{ index, name?, min, max }}, buttons = {{ index, name? }} }, every element the device reports in its own order, name the canonical name an element also drives; device_axes holds each device axis -1..1 across its native range and device_buttons each button's travel 0..1, both by index + 1; device_held / device_pressed / device_released are arrays of 0-based button indices; haptics is { rumble, trigger_rumble, constant, spring, damper, friction }, each { supported, reason? }; rumble is { strong, weak, left_trigger, right_trigger, seconds, remaining, error? } while one plays; force is { constant?, spring?, damper?, friction?, error? } while force effects hold); gamepad_capable — boolean, true once the session has seen a pad device, and while a simulated pad is connected; xr — { turnMode, turnSteps, snapDegrees } while an XR session holds input focus (what the look action reads from a headset), else nil.
Returns table — Input state snapshot for this frame