Skip to content
View source

controlsGenerated

Category: Packages · Manifest: use "kernels/";

What a person’s hands do, read for a program, and the one package that reads them.

What a person’s hands do, read for a program, and the one package that reads them: a game’s actions from the keyboard, the mouse and a pad alike, from a table of actions (held, pressed and released, the ways to move and look, the stick’s flicks); the pointer (where, its buttons, the wheel); and what was typed.

Layer: Interaction.

use "controls.entpkg";
  • kernels/action.ent — A game’s actions from the keyboard and a pad alike (../package.esn). Kernels: controls.start@1, controls.read@1.
  • kernels/pointer.ent — The pointer: where it is, its buttons held, pressed and released, the wheel, whether it moved. Kernels: controls.pointer_start@1, controls.pointer@1.
  • kernels/typing.ent — What was typed this frame. Kernels: controls.typing@1.

tests/ holds scenes and their replays, run on every backend: actions.replay, pointer.replay. Every Kernel of the package is reached by one of them.

Used by the controls example.

Kernel Mode Brief
controls.pointer@1 map The pointer this frame, from the one before.
controls.pointer_start@1 map
controls.read@1 map The controls this frame, from the ones before.
controls.start@1 map
controls.typing@1 map This frame’s typing.
Function Brief
action_dead_zone() -> Float How far a stick goes before it counts, and how its travel past that is spread over 0 to 1.
action_past_dead_zone(v: Vec2) -> Vec2
action_step_delay() -> Float A step held repeats after action_step_delay() seconds, every action_step_every().
action_step_every() -> Float
action_bit(on: Bool, k: Int) -> Int
action_key_down(code: Int) -> Bool
action_held(c: ActionControls, k: Int) -> Bool Whether action k is held, pressed this frame, released this frame.
action_pressed(c: ActionControls, k: Int) -> Bool
action_released(c: ActionControls, k: Int) -> Bool
action_stick_stepped(c: ActionControls, way: Int) -> Bool Whether the left stick (or the arrows) stepped way this frame: 1 up, 2 down, 4 left, 8 right.
pointer_held(p: PointerControls, b: Int) -> Bool Whether button b (0 left, 1 right, 2 middle) is held, pressed this frame, released this frame.
pointer_pressed(p: PointerControls, b: Int) -> Bool
pointer_released(p: PointerControls, b: Int) -> Bool
pointer_points(p: PointerControls) -> Vec2 The pointer at at in the window’s pixels, in its points (scale() pixels a point).
typed_at(t: Typing, k: Int) -> Int Character k typed this frame (0 past the last).
Name Syntax
ActionBinding struct ActionBinding { key: Int; key2: Int; pad: Int; }
ActionControls struct ActionControls { held: Int; pressed: Int; released: Int; move: Vec2; look: Vec2; zoom: Float; steps: Int; way: Int;
PointerControls struct PointerControls { at: Vec2; held: Int; pressed: Int; released: Int; wheel: Vec2; moved: Bool; }
Typing struct Typing { codes: [Int; 32]; n: Int; }

The pointer this frame, from the one before.

Mode map
Requires field.read, field.write, input.read
Inputs previous: Rows<PointerControls>
Params —
Outputs result: Rows<PointerControls>
Source packages/controls.entpkg/kernels/pointer.ent
Mode map
Requires field.write
Inputs —
Params —
Outputs result: Rows<PointerControls>
Source packages/controls.entpkg/kernels/pointer.ent

The controls this frame, from the ones before.

Mode map
Requires field.read, field.write, time.read, input.read
Inputs previous: Rows<ActionControls>, actions: Rows<ActionBinding>
Params —
Outputs result: Rows<ActionControls>
Source packages/controls.entpkg/kernels/action.ent
Mode map
Requires field.write
Inputs —
Params —
Outputs result: Rows<ActionControls>
Source packages/controls.entpkg/kernels/action.ent

This frame’s typing.

Mode map
Requires field.write, input.read
Inputs —
Params —
Outputs result: Rows<Typing>
Source packages/controls.entpkg/kernels/typing.ent

actions.replay, pointer.replay