# gizhw:evdev

the Linux backend of gizhw:input. Input devices (evdev, /dev/input/eventN): a device's name and ids, and its events as the kernel reports them (struct input_event: 24 bytes on 64-bit). Every call is on a Handle of gizhw:device, so no libc call is here.

```gizlang
import * as Evdev from "gizhw:evdev";
```

## Types

### `Ids`

```gizlang
type Ids = { bus: i64; vendor: i64; product: i64; version: i64; }
```

A device's ids: bus, vendor, product and version (struct input_id).

- `bus`: `i64`
- `vendor`: `i64`
- `product`: `i64`
- `version`: `i64`

### `Event`

```gizlang
type Event = { time: i64; type: i64; code: i64; value: i64; }
```

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

- `time`: `i64`
- `type`: `i64`
- `code`: `i64`
- `value`: `i64`

## Functions

### `parseIds`

```gizlang
function parseIds(data: bytes): Ids
```

The ids in the 8-byte reply to EVIOCGID.

Effects: fail.

### `parseEvents`

```gizlang
function parseEvents(data: bytes): Vec<Event>
```

The events in `data`, whole structs only: time (seconds and microseconds, 8 bytes each), type, code (u16 each) and
value (i32).

Effects: fail.

### `name`

```gizlang
function name(h: Device.Handle): string throws string
```

The name of the input device behind `h`.

Effects: fail, io.

### `ids`

```gizlang
function ids(h: Device.Handle): Ids throws string
```

The ids of the input device behind `h`.

Effects: fail, io.

### `events`

```gizlang
function events(h: Device.Handle, count: i64): Vec<Event> throws string
```

The next `count` events, waiting for them.

Effects: fail, io.

### `inputs`

```gizlang
function inputs(sys: System): Vec<Device.Device> throws IoError
```

The event devices of the input class (`eventN` with a node).

Effects: fail, io.

### `open`

```gizlang
function open(sys: System, node: string): Device.Handle throws string
```

The handle on the event device `node` (read-only is enough for reading events).

Effects: fail, io.

