Input
cinnabar:extension/input@0.1.0
Local control edges, available only with explicit controls authority.
Grants: controls, except demo-pressed, which needs no grant.
Imported type event: event.
Types
text-event
A committed native field value addressed by its declared control ID.
record text-event {
id: string,
value: string,
}
| Member | Type | Description |
|---|---|---|
id | string | |
value | string |
field-key
A field navigation key with modifiers sampled at the key edge.
record field-key {
id: string,
key: string,
shift: bool,
control: bool,
alt: bool,
super-key: bool,
}
| Member | Type | Description |
|---|---|---|
id | string | |
key | string | |
shift | bool | |
control | bool | |
alt | bool | |
super-key | bool |
field-event
A native edit, submission or navigation edge; composition remains host-owned.
variant field-event {
change(text-event),
submit(text-event),
key(field-key),
}
| Member | Type | Description |
|---|---|---|
change | text-event | |
submit | text-event | |
key | field-key |
Types: field-key, text-event.
controls
One focused input sample; keys and pointer use the host’s coordinate and naming contracts.
record controls {
seconds: f32,
focused: bool,
gameplay: bool,
panel-open: bool,
keys-pressed: list<string>,
keys-held: list<string>,
keys-admitted: list<string>,
events: list<event>,
pointer: option<tuple<f32, f32>>,
wheel: f32,
}
| Member | Type | Description |
|---|---|---|
seconds | f32 | |
focused | bool | |
gameplay | bool | |
panel-open | bool | |
keys-pressed | list<string> | Physical non-repeat edges, including while this owner edits a native field; pointer buttons use MouseLeft/MouseRight/MouseMiddle. |
keys-held | list<string> | Physical keys held this frame, including reserved ones, in physical-name order. Truncated to MAX_CONTROL_KEYS when more are held. |
keys-admitted | list<string> | Held desktop keys/buttons admitted by the finalized gameplay router, including modifiers. Uses keys-held names and bounds; excludes consumed, quarantined, reserved and ineligible-device controls. Empty outside gameplay input ownership. Match read-bindings chords against this list, respecting modifier precedence. This is physical admission, never a resolved action or permission to act. Same physical-name order as keys-held, independently truncated to MAX_CONTROL_KEYS. Above that held-key cap, chord resolution can differ from the host’s gate. |
events | list<event> | |
pointer | option<tuple<f32, f32>> | Pointer position in the gameplay HUD root’s GUI units from its top left, the space ofhud.read-viewport, while this mod’s open panel owns input; none otherwise. A panel’sown fitting, such as a reference_size scaled to a small window, does not change it. |
wheel | f32 | Wheel notches this frame while this mod’s panel owns input; positive scrolls up. |
Types: event.
selection
Selects which fields to copy without changing the underlying frame or its event ordering.
record selection {
keys-pressed: option<list<string>>,
keys-held: option<list<string>>,
keys-admitted: option<list<string>>,
events: bool,
}
| Member | Type | Description |
|---|---|---|
keys-pressed | option<list<string>> | None selects all keys; some(empty) selects none; names select exact matches. |
keys-held | option<list<string>> | |
keys-admitted | option<list<string>> | |
events | bool |
binding-context
The context in which the player assigned a physical chord.
enum binding-context {
gameplay,
ui,
}
| Member | Type | Description |
|---|---|---|
gameplay | ||
ui |
binding-modifiers
Modifier groups required in addition to the key; either side satisfies a group.
record binding-modifiers {
shift: bool,
control: bool,
alt: bool,
super-key: bool,
}
| Member | Type | Description |
|---|---|---|
shift | bool | |
control | bool | |
alt | bool | |
super-key | bool |
action-binding
One player-assigned keyboard or observable mouse-button chord. Multiple rows are alternative bindings. More specific satisfied chords on the same key and context take precedence. Keys use exactly the controls.keys-held naming contract.
record action-binding {
action: string,
context: binding-context,
key: string,
modifiers: binding-modifiers,
}
| Member | Type | Description |
|---|---|---|
action | string | Stable input Action names in kebab-case: move-forward, move-backward, move-left, move-right, look-up, look-down, look-left, look-right, jump, sneak, sprint, attack, use, cycle-perspective, menu, back, hotbar-1 through hotbar-9, hotbar-previous, hotbar-next, ui-up, ui-down, ui-left, ui-right, ui-accept, ui-cancel, ui-tab-next, ui-tab-previous, player-list, freelook, interact-with-toast, pick-item. |
context | binding-context | |
key | string | |
modifiers | binding-modifiers |
Types: binding-context, binding-modifiers.
bindings
A page of the player’s current chords, in settings order. Total is at most MAX_INPUT_BINDINGS; entries has at most MAX_INPUT_BINDINGS_PER_READ rows. Only keyboard keys and MouseLeft/MouseRight/MouseMiddle are observable here; mouse axes, additional buttons, gamepads and built-in touch controls are not in keys-held.
record bindings {
revision: u64,
total: u32,
entries: list<action-binding>,
}
| Member | Type | Description |
|---|---|---|
revision | u64 | |
total | u32 | |
entries | list<action-binding> |
Types: action-binding.
Functions
read-container-screen
read-container-screen: func() -> result<option<string>, string>;
Current open container screen identity, requiring controls permission. None outside containers. Observation does not grant pointer ownership.
position-pointer
position-pointer: func(x: f32, y: f32) -> result<_, string>;
Requests one pointer move in normalized window coordinates (0..1 on each axis). Requires controls permission and a focused container. Staged until callback success; consumed once, discarded if the screen changed. Does not press buttons or capture input.
read-bindings
read-bindings: func(after: option<u64>, offset: u32, limit: u32) -> result<option<bindings>, string>;
Requires controls authority and shares read-controls’ callback read allowance. Offset is 0 through total, and limit is 1 through MAX_INPUT_BINDINGS_PER_READ. Pass the last complete revision to receive none while unchanged. To collect pages, pass none, advance offset by each page’s length and restart at zero if revision changes. Discard old assignments while collecting a changed revision; apply complete revisions. Revisions are host-local: clear guest caches on reinitialization. Returns an error until settings are sampled or for invalid page bounds. Does not resolve actions.
Types: bindings.
demo-pressed
demo-pressed: func() -> bool;
True only for the current frame’s host-assigned action edge.
read-controls
read-controls: func() -> result<controls, string>;
Reads this callback’s control sample with controls authority and the shared read allowance.
Types: controls.
read-selected-controls
read-selected-controls: func(selection: selection) -> result<controls, string>;
Reads selected fields from the same current frame, preserving native key order. Requires controls authority and shares the read-controls callback read budget.
read-native-editing
read-native-editing: func() -> result<bool, string>;
Whether a native field or numeric editor on this mod’s open panel owns key input in the current frame, including IME composition. The keys it consumes still appear in keys-pressed and keys-held; skip panel key handling of your own while this is true. False while the panel is closed or another mod owns input. Requires controls authority.
read-text-events
read-text-events: func() -> result<list<text-event>, string>;
Committed single-line native text edits, separate from legacy numeric control events. Requires controls authority; repeated reads see the same bounded batch in a frame callback.
Types: text-event.
read-field-events
read-field-events: func() -> result<list<field-event>, string>;
Live values coalesce per field between frame callbacks. Submit and navigation retain order. Navigation includes the modifiers sampled at that key edge; preedit stays host-local.
Types: field-event.
reserve-keys
reserve-keys: func(keys: list<string>) -> result<_, string>;
Physical key names reserved before the ordinary gameplay router samples them.