tecs.platform.events
Typed platform events produced by the Rust host.
Every kind is its own nupp.events declaration, so a world delivers a key press to the observers of KeyDown and nothing else, and the twelve shapes the kinds share are unions of the declarations that carry them. Kind strings are a stable external data surface used by recordings and tools. Rust translates winit events into these records and passes one ordered batch to tecs.application.Application:iterate.
Module contents
Types
| Type | Kind | Description |
|---|---|---|
Event | type | An event in one sealed host batch. |
FingerCanceled | record | A touch the platform cancelled. |
FingerDown | record | A finger touching the surface. |
FingerMotion | record | A finger moving on the surface. |
FingerUp | record | A finger leaving the surface. |
FocusEvent | type | A window focus transition. |
GamepadAdded | record | A gamepad appearing. |
GamepadAxis | record | A gamepad axis reading. |
GamepadAxisEvent | type | A gamepad axis reading. |
GamepadButtonDown | record | A gamepad button going down. |
GamepadButtonEvent | type | A gamepad button transition. |
GamepadButtonUp | record | A gamepad button coming up. |
GamepadDeviceEvent | type | A gamepad appearing or going away. |
GamepadRemoved | record | A gamepad going away. |
KeyDown | record | A key going down. |
KeyEvent | type | A physical and logical keyboard transition. |
KeyUp | record | A key coming up. |
Kind | type | A platform event kind supported by the Rust host. |
MouseDown | record | A pointer button going down. |
MouseMotion | record | An absolute pointer position and optional relative movement. |
MouseUp | record | A pointer button coming up. |
MouseWheel | record | A normalized pointer wheel movement. |
PointerButtonEvent | type | A pointer button transition. |
PointerMoveEvent | type | An absolute pointer position and optional relative movement. |
Quit | record | A process quit request. |
QuitEvent | type | A process or window close request. |
ResizeEvent | type | A logical window size change. |
TextEvent | type | Text committed by the platform input method. |
TextInput | record | Text committed by the platform input method. |
TouchEvent | type | One finger on a touch surface. |
WheelEvent | type | A normalized pointer wheel movement. |
WindowCloseRequested | record | A close request for one window. |
WindowFocusGained | record | A window gaining focus. |
WindowFocusLost | record | A window losing focus. |
WindowResized | record | A logical window resize. |
WindowScaleChanged | record | A scale-factor change with the resulting logical size. |
Functions
| Function | Kind | Description |
|---|---|---|
closeRequested | function | Constructs a close request for one window. |
dispatch | function | Delivers one translated event to the world's observers of its kind. |
focused | function | Constructs a window focus transition. |
gamepadAxis | function | Constructs a gamepad axis reading. |
gamepadButton | function | Constructs a gamepad button transition. |
gamepadDevice | function | Constructs a gamepad appearing or going away. |
key | function | Constructs a keyboard transition. |
kinds | function | Returns every platform event kind, in the union's declared order. |
pointerButton | function | Constructs a pointer button transition. |
pointerMoved | function | Constructs an absolute pointer movement. |
quit | function | Constructs a process or window close request. |
resized | function | Constructs a logical window resize. |
scaleChanged | function | Constructs a scale-factor change with the resulting logical size. |
text | function | Constructs committed text input. |
touch | function | Constructs one finger's transition or movement. |
wheel | function | Constructs normalized pointer wheel movement. |
Types#
Eventtype#
type Event = Quit
| WindowCloseRequested
| WindowResized
| WindowScaleChanged
| WindowFocusGained
| WindowFocusLost
| KeyDown
| KeyUp
| MouseMotion
| MouseDown
| MouseUp
| MouseWheel
| TextInput
| FingerDown
| FingerUp
| FingerMotion
| FingerCanceled
| GamepadAdded
| GamepadRemoved
| GamepadButtonDown
| GamepadButtonUp
| GamepadAxisAn event in one sealed host batch.
FingerCanceledrecord#
record FingerCanceled
kind: "fingerCanceled"
timestamp: number
sequence: integer
window: integer
touchDevice: string
finger: string
x: number
y: number
dx: number
dy: number
normalX: number
normalY: number
pressure: number
down: boolean
endA touch the platform cancelled.
Fields
kind#
kind: "fingerCanceled"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integertouchDevice#
touchDevice: stringfinger#
finger: stringx#
x: numbery#
y: numberdx#
dx: numberdy#
dy: numbernormalX#
normalX: numbernormalY#
normalY: numberpressure#
pressure: numberdown#
down: booleanFingerDownrecord#
record FingerDown
kind: "fingerDown"
timestamp: number
sequence: integer
window: integer
touchDevice: string
finger: string
x: number
y: number
dx: number
dy: number
normalX: number
normalY: number
pressure: number
down: boolean
endA finger touching the surface.
Fields
kind#
kind: "fingerDown"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integertouchDevice#
touchDevice: stringfinger#
finger: stringx#
x: numbery#
y: numberdx#
dx: numberdy#
dy: numbernormalX#
normalX: numbernormalY#
normalY: numberpressure#
pressure: numberdown#
down: booleanFingerMotionrecord#
record FingerMotion
kind: "fingerMotion"
timestamp: number
sequence: integer
window: integer
touchDevice: string
finger: string
x: number
y: number
dx: number
dy: number
normalX: number
normalY: number
pressure: number
down: boolean
endA finger moving on the surface.
Fields
kind#
kind: "fingerMotion"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integertouchDevice#
touchDevice: stringfinger#
finger: stringx#
x: numbery#
y: numberdx#
dx: numberdy#
dy: numbernormalX#
normalX: numbernormalY#
normalY: numberpressure#
pressure: numberdown#
down: booleanFingerUprecord#
record FingerUp
kind: "fingerUp"
timestamp: number
sequence: integer
window: integer
touchDevice: string
finger: string
x: number
y: number
dx: number
dy: number
normalX: number
normalY: number
pressure: number
down: boolean
endA finger leaving the surface.
Fields
kind#
kind: "fingerUp"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integertouchDevice#
touchDevice: stringfinger#
finger: stringx#
x: numbery#
y: numberdx#
dx: numberdy#
dy: numbernormalX#
normalX: numbernormalY#
normalY: numberpressure#
pressure: numberdown#
down: booleanFocusEventtype#
type FocusEvent = WindowFocusGained | WindowFocusLostA window focus transition.
Whichever kind carries this shape; an observer written against it fits any of them.
GamepadAddedrecord#
record GamepadAdded
kind: "gamepadAdded"
timestamp: number
sequence: integer
window: integer
which: integer
endA gamepad appearing.
Fields
kind#
kind: "gamepadAdded"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerwhich#
which: integerGamepadAxisrecord#
record GamepadAxis
kind: "gamepadAxis"
timestamp: number
sequence: integer
window: integer
which: integer
axis: integer
value: number
endA gamepad axis reading.
Fields
kind#
kind: "gamepadAxis"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerwhich#
which: integeraxis#
axis: integervalue#
value: numberGamepadAxisEventtype#
type GamepadAxisEvent = GamepadAxisA gamepad axis reading.
GamepadButtonDownrecord#
record GamepadButtonDown
kind: "gamepadButtonDown"
timestamp: number
sequence: integer
window: integer
which: integer
button: integer
down: boolean
endA gamepad button going down.
Fields
kind#
kind: "gamepadButtonDown"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerwhich#
which: integerbutton#
button: integerdown#
down: booleanGamepadButtonEventtype#
type GamepadButtonEvent = GamepadButtonDown | GamepadButtonUpA gamepad button transition.
Whichever kind carries this shape; an observer written against it fits any of them.
GamepadButtonUprecord#
record GamepadButtonUp
kind: "gamepadButtonUp"
timestamp: number
sequence: integer
window: integer
which: integer
button: integer
down: boolean
endA gamepad button coming up.
Fields
kind#
kind: "gamepadButtonUp"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerwhich#
which: integerbutton#
button: integerdown#
down: booleanGamepadDeviceEventtype#
type GamepadDeviceEvent = GamepadAdded | GamepadRemovedA gamepad appearing or going away.
Compatibility surface: which names the device rather than the window. window is zero because a gamepad belongs to no window.
Whichever kind carries this shape; an observer written against it fits any of them.
GamepadRemovedrecord#
record GamepadRemoved
kind: "gamepadRemoved"
timestamp: number
sequence: integer
window: integer
which: integer
endA gamepad going away.
Fields
kind#
kind: "gamepadRemoved"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerwhich#
which: integerKeyDownrecord#
record KeyDown
kind: "keyDown"
timestamp: number
sequence: integer
window: integer
physicalKey: string
logicalKey: string?
text: string?
modifiers: integer
repeated: boolean
down: boolean
endA key going down.
Fields
kind#
kind: "keyDown"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerphysicalKey#
physicalKey: stringlogicalKey#
logicalKey: string?modifiers#
modifiers: integerrepeated#
repeated: booleandown#
down: booleanKeyEventtype#
A physical and logical keyboard transition.
Whichever kind carries this shape; an observer written against it fits any of them.
KeyUprecord#
record KeyUp
kind: "keyUp"
timestamp: number
sequence: integer
window: integer
physicalKey: string
logicalKey: string?
text: string?
modifiers: integer
repeated: boolean
down: boolean
endA key coming up.
Fields
kind#
kind: "keyUp"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerphysicalKey#
physicalKey: stringlogicalKey#
logicalKey: string?modifiers#
modifiers: integerrepeated#
repeated: booleandown#
down: booleanKindtype#
type Kind = "quit"
| "windowCloseRequested"
| "windowResized"
| "windowScaleChanged"
| "windowFocusGained"
| "windowFocusLost"
| "keyDown"
| "keyUp"
| "mouseMotion"
| "mouseDown"
| "mouseUp"
| "mouseWheel"
| "textInput"
| "fingerDown"
| "fingerUp"
| "fingerMotion"
| "fingerCanceled"
| "gamepadAdded"
| "gamepadRemoved"
| "gamepadButtonDown"
| "gamepadButtonUp"
| "gamepadAxis"A platform event kind supported by the Rust host.
MouseDownrecord#
record MouseDown
kind: "mouseDown"
timestamp: number
sequence: integer
window: integer
x: number
y: number
button: integer
clicks: integer
down: boolean
endA pointer button going down.
Fields
kind#
kind: "mouseDown"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerx#
x: numbery#
y: numberbutton#
button: integerclicks#
clicks: integerdown#
down: booleanMouseMotionrecord#
record MouseMotion
kind: "mouseMotion"
timestamp: number
sequence: integer
window: integer
x: number
y: number
dx: number
dy: number
endAn absolute pointer position and optional relative movement.
Fields
kind#
kind: "mouseMotion"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerx#
x: numbery#
y: numberdx#
dx: numberdy#
dy: numberMouseUprecord#
record MouseUp
kind: "mouseUp"
timestamp: number
sequence: integer
window: integer
x: number
y: number
button: integer
clicks: integer
down: boolean
endA pointer button coming up.
Fields
kind#
kind: "mouseUp"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerx#
x: numbery#
y: numberbutton#
button: integerclicks#
clicks: integerdown#
down: booleanMouseWheelrecord#
record MouseWheel
kind: "mouseWheel"
timestamp: number
sequence: integer
window: integer
x: number
y: number
wheelX: number
wheelY: number
wheelTicksX: integer
wheelTicksY: integer
endA normalized pointer wheel movement.
Fields
kind#
kind: "mouseWheel"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerx#
x: numbery#
y: numberwheelX#
wheelX: numberwheelY#
wheelY: numberwheelTicksX#
wheelTicksX: integerwheelTicksY#
wheelTicksY: integerPointerButtonEventtype#
A pointer button transition.
Whichever kind carries this shape; an observer written against it fits any of them.
PointerMoveEventtype#
type PointerMoveEvent = MouseMotionAn absolute pointer position and optional relative movement.
Quitrecord#
A process quit request.
Fields
kind#
kind: "quit"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerQuitEventtype#
type QuitEvent = Quit | WindowCloseRequestedA process or window close request.
Whichever kind carries this shape; an observer written against it fits any of them.
ResizeEventtype#
type ResizeEvent = WindowResized | WindowScaleChangedA logical window size change.
Whichever kind carries this shape; an observer written against it fits any of them.
TextEventtype#
type TextEvent = TextInputText committed by the platform input method.
TextInputrecord#
record TextInput
kind: "textInput"
timestamp: number
sequence: integer
window: integer
text: string
endText committed by the platform input method.
Fields
kind#
kind: "textInput"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerTouchEventtype#
type TouchEvent = FingerDown | FingerUp | FingerMotion | FingerCanceledOne finger on a touch surface.
Compatibility surface: touchDevice and finger are stable field names, and both stay strings because a device and a finger are 64-bit identities that a Lua number would round together.
Whichever kind carries this shape; an observer written against it fits any of them.
WheelEventtype#
type WheelEvent = MouseWheelA normalized pointer wheel movement.
WindowCloseRequestedrecord#
record WindowCloseRequested
kind: "windowCloseRequested"
timestamp: number
sequence: integer
window: integer
endA close request for one window.
Fields
kind#
kind: "windowCloseRequested"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerWindowFocusGainedrecord#
record WindowFocusGained
kind: "windowFocusGained"
timestamp: number
sequence: integer
window: integer
focused: boolean
endA window gaining focus.
Fields
kind#
kind: "windowFocusGained"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerWindowFocusLostrecord#
record WindowFocusLost
kind: "windowFocusLost"
timestamp: number
sequence: integer
window: integer
focused: boolean
endA window losing focus.
Fields
kind#
kind: "windowFocusLost"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerWindowResizedrecord#
record WindowResized
kind: "windowResized"
timestamp: number
sequence: integer
window: integer
width: integer
height: integer
pixelWidth: integer
pixelHeight: integer
scaleFactor: number
endA logical window resize.
Fields
kind#
kind: "windowResized"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerwidth#
width: integerheight#
height: integerpixelWidth#
pixelWidth: integerpixelHeight#
pixelHeight: integerscaleFactor#
scaleFactor: numberWindowScaleChangedrecord#
record WindowScaleChanged
kind: "windowScaleChanged"
timestamp: number
sequence: integer
window: integer
width: integer
height: integer
pixelWidth: integer
pixelHeight: integer
scaleFactor: number
endA scale-factor change with the resulting logical size.
Fields
kind#
kind: "windowScaleChanged"timestamp#
timestamp: numbersequence#
sequence: integerwindow#
window: integerwidth#
width: integerheight#
height: integerpixelWidth#
pixelWidth: integerpixelHeight#
pixelHeight: integerscaleFactor#
scaleFactor: numberFunctions#
closeRequestedfunction#
function closeRequested(window: integer?, timestamp: number?, sequence: integer?): QuitEventConstructs a close request for one window.
Arguments
| Name | Type | Description |
|---|---|---|
window | integer? | |
timestamp | number? | |
sequence | integer? |
Returns
| Type | Description |
|---|---|
QuitEvent |
dispatchfunction#
Delivers one translated event to the world's observers of its kind.
The host's instance is delivered as it is: nothing is copied or constructed, and observers receive it as a borrow for the call.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive world | ecs.World | the receiving world |
event | Event | the translated platform event |
Returns
| Type | Description |
|---|---|
nil |
focusedfunction#
function focused(focused: boolean, window: integer?, timestamp: number?, sequence: integer?): FocusEventConstructs a window focus transition.
Arguments
| Name | Type | Description |
|---|---|---|
focused | boolean | |
window | integer? | |
timestamp | number? | |
sequence | integer? |
Returns
| Type | Description |
|---|---|
FocusEvent |
gamepadAxisfunction#
function gamepadAxis(which: integer, axis: integer, value: number, timestamp: number?, sequence: integer?): GamepadAxisEventConstructs a gamepad axis reading.
Arguments
| Name | Type | Description |
|---|---|---|
which | integer | the device identifier the backend issued |
axis | integer | the axis code |
value | number | the reading from -1 to 1, with a trigger running zero to one |
timestamp | number? | the host time the platform reported |
sequence | integer? | the host's ordering number for the batch |
Returns
| Type | Description |
|---|---|
GamepadAxisEvent | the constructed axis event |
Raises
when the axis code is not positive
gamepadButtonfunction#
function gamepadButton(down: boolean, which: integer, button: integer, timestamp: number?, sequence: integer?): GamepadButtonEventConstructs a gamepad button transition.
Arguments
| Name | Type | Description |
|---|---|---|
down | boolean | whether the button went down rather than came up |
which | integer | the device identifier the backend issued |
button | integer | the positional button code |
timestamp | number? | the host time the platform reported |
sequence | integer? | the host's ordering number for the batch |
Returns
| Type | Description |
|---|---|
GamepadButtonEvent | the constructed button event |
Raises
when the button code is not positive
gamepadDevicefunction#
function gamepadDevice(added: boolean, which: integer, timestamp: number?, sequence: integer?): GamepadDeviceEventConstructs a gamepad appearing or going away.
Arguments
| Name | Type | Description |
|---|---|---|
added | boolean | whether the device appeared rather than went away |
which | integer | the device identifier the backend issued |
timestamp | number? | the host time the platform reported |
sequence | integer? | the host's ordering number for the batch |
Returns
| Type | Description |
|---|---|
GamepadDeviceEvent | the constructed device event |
keyfunction#
function key(down: boolean, physicalKey: string, logicalKey: string?, text: string?, modifiers: integer?, repeated: boolean?, window: integer?, timestamp: number?, sequence: integer?): KeyEventConstructs a keyboard transition.
Arguments
| Name | Type | Description |
|---|---|---|
down | boolean | |
physicalKey | string | |
logicalKey | string? | |
text | string? | |
modifiers | integer? | |
repeated | boolean? | |
window | integer? | |
timestamp | number? | |
sequence | integer? |
Returns
| Type | Description |
|---|---|
KeyEvent |
kindsfunction#
function kinds(): {string}Returns every platform event kind, in the union's declared order.
Compatibility surface: each string is the externally typed kind an agent names over the debug protocol, so the spellings here are the same ones Kind declares and must not change with a module move. The union is a type and cannot be read at run time, so a caller that needs the kinds as data reads them here rather than keeping a second copy that drifts.
Returns
| Type | Description |
|---|---|
{string} | a fresh caller-owned list of the twenty-two kind strings |
pointerButtonfunction#
function pointerButton(down: boolean, button: integer, x: number, y: number, clicks: integer?, window: integer?, timestamp: number?, sequence: integer?): PointerButtonEventConstructs a pointer button transition.
Arguments
| Name | Type | Description |
|---|---|---|
down | boolean | |
button | integer | |
x | number | |
y | number | |
clicks | integer? | |
window | integer? | |
timestamp | number? | |
sequence | integer? |
Returns
| Type | Description |
|---|---|
PointerButtonEvent |
pointerMovedfunction#
function pointerMoved(x: number, y: number, dx: number?, dy: number?, window: integer?, timestamp: number?, sequence: integer?): PointerMoveEventConstructs an absolute pointer movement.
Arguments
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
dx | number? | |
dy | number? | |
window | integer? | |
timestamp | number? | |
sequence | integer? |
Returns
| Type | Description |
|---|---|
PointerMoveEvent |
quitfunction#
function quit(window: integer?, timestamp: number?, sequence: integer?): QuitEventConstructs a process or window close request.
Arguments
| Name | Type | Description |
|---|---|---|
window | integer? | |
timestamp | number? | |
sequence | integer? |
Returns
| Type | Description |
|---|---|
QuitEvent |
resizedfunction#
function resized(width: integer, height: integer, window: integer?, scaleFactor: number?, timestamp: number?, sequence: integer?, pixelWidth: integer?, pixelHeight: integer?): ResizeEventConstructs a logical window resize.
Arguments
| Name | Type | Description |
|---|---|---|
width | integer | |
height | integer | |
window | integer? | |
scaleFactor | number? | |
timestamp | number? | |
sequence | integer? | |
pixelWidth | integer? | |
pixelHeight | integer? |
Returns
| Type | Description |
|---|---|
ResizeEvent |
scaleChangedfunction#
function scaleChanged(scaleFactor: number, width: integer, height: integer, window: integer?, timestamp: number?, sequence: integer?, pixelWidth: integer?, pixelHeight: integer?): ResizeEventConstructs a scale-factor change with the resulting logical size.
Arguments
| Name | Type | Description |
|---|---|---|
scaleFactor | number | |
width | integer | |
height | integer | |
window | integer? | |
timestamp | number? | |
sequence | integer? | |
pixelWidth | integer? | |
pixelHeight | integer? |
Returns
| Type | Description |
|---|---|
ResizeEvent |
textfunction#
Constructs committed text input.
Arguments
| Name | Type | Description |
|---|---|---|
text | string | |
window | integer? | |
timestamp | number? | |
sequence | integer? |
Returns
| Type | Description |
|---|---|
TextEvent |
touchfunction#
function touch(phase: "fingerDown" | "fingerUp" | "fingerMotion" | "fingerCanceled", touchDevice: string, finger: string, x: number, y: number, normalX: number?, normalY: number?, pressure: number?, dx: number?, dy: number?, window: integer?, timestamp: number?, sequence: integer?): TouchEventConstructs one finger's transition or movement.
x and y are in the window's logical coordinates, normalX and normalY run from zero to one across the touch surface, and pressure runs from zero to one where the surface reports it and is one where it does not.
Arguments
| Name | Type | Description |
|---|---|---|
phase | "fingerDown" | "fingerUp" | "fingerMotion" | "fingerCanceled" | the finger's transition, spelled as the event kind |
touchDevice | string | the touch surface's opaque identity |
finger | string | the finger's opaque identity on that surface |
x | number | the position in logical window coordinates |
y | number | the position in logical window coordinates |
normalX | number? | the position across the surface, from zero to one |
normalY | number? | the position down the surface, from zero to one |
pressure | number? | the reported pressure from zero to one |
dx | number? | the movement since the previous event, in logical coordinates |
dy | number? | the movement since the previous event, in logical coordinates |
window | integer? | the window the touch is over |
timestamp | number? | the host time the platform reported |
sequence | integer? | the host's ordering number for the batch |
Returns
| Type | Description |
|---|---|
TouchEvent | the constructed touch event |
Raises
when the finger identity is empty
wheelfunction#
function wheel(wheelX: number, wheelY: number, ticksX: integer?, ticksY: integer?, x: number?, y: number?, window: integer?, timestamp: number?, sequence: integer?): WheelEventConstructs normalized pointer wheel movement.
Arguments
| Name | Type | Description |
|---|---|---|
wheelX | number | |
wheelY | number | |
ticksX | integer? | |
ticksY | integer? | |
x | number? | |
y | number? | |
window | integer? | |
timestamp | number? | |
sequence | integer? |
Returns
| Type | Description |
|---|---|
WheelEvent |