gizhw:input
keyboards, mice and other input devices on any platform. inputs lists each device by an id the platform gives and a name; open takes the id, and events come as Linux numbers them (linux/input-event-codes.h), the numbering each backend maps its own codes to. Linux reads evdev (gizhw:evdev). A platform without a backend fails each call with the class and the platform named.
import * as Input from "gizhw:input";Types
Info
type Info = { id: string; name: string; }An input device: id opens it (its /dev/input/event node on Linux), name is the device's own name.
id:stringname:string
Event
type Event = Evdev.EventOne event: time in milliseconds, type (EV_SYN 0, EV_KEY 1, EV_REL 2, EV_ABS 3), code and value.
Input
type InputAn open input device.
Opaque: create and use it through this module's functions.
Functions
inputs
function inputs(sys: System): Vec<Info> throws stringThe input devices of this machine, in the order the platform lists them.
Effects: fail, io.
open
function open(sys: System, id: string): Input throws stringThe input device id (from inputs), open for reading its events.
Effects: fail, io.
Methods
Input.events
function Input.events(self: Input, count: i64): Vec<Event> throws stringThe next count events, waiting for them.
Effects: fail, io.
Input.close
function Input.close(self: Input): voidCloses the device.
Effects: fail, io.