# 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.

```gizlang
import * as Input from "gizhw:input";
```

## Types

### `Info`

```gizlang
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`: `string`
- `name`: `string`

### `Event`

```gizlang
type Event = Evdev.Event
```

One event: `time` in milliseconds, `type` (EV_SYN 0, EV_KEY 1, EV_REL 2, EV_ABS 3), `code` and `value`.

### `Input`

```gizlang
type Input
```

An open input device.

Opaque: create and use it through this module's functions.

## Functions

### `inputs`

```gizlang
function inputs(sys: System): Vec<Info> throws string
```

The input devices of this machine, in the order the platform lists them.

Effects: fail, io.

### `open`

```gizlang
function open(sys: System, id: string): Input throws string
```

The input device `id` (from `inputs`), open for reading its events.

Effects: fail, io.

## Methods

### `Input.events`

```gizlang
function Input.events(self: Input, count: i64): Vec<Event> throws string
```

The next `count` events, waiting for them.

Effects: fail, io.

### `Input.close`

```gizlang
function Input.close(self: Input): void
```

Closes the device.

Effects: fail, io.

