# `Gamepad.Linux.Reader`
[🔗](https://github.com/jaman/gamepad/blob/v0.1.0/lib/gamepad/linux/reader.ex#L1)

Reads one joystick device file inside the VM, for `Gamepad`.

`start_link/2` starts a process, linked to the caller, that opens the file and
reads it until it ends or fails, sending `owner`:

  * `{:gamepad_device, reader, :opened}` once the file is open
  * `{:gamepad_device, reader, {:data, bytes}}` for each `js_event` record read, its
    8 bytes for `Gamepad.Linux.decode/2`
  * `{:gamepad_device, reader, {:closed, reason}}` when the file could not be opened,
    ended (`:eof`) or failed, as when the controller is unplugged; the process then
    exits normally

Each read waits on one of the VM's dirty I/O threads until the controller sends
something. A reader asked to exit while waiting goes once that read returns; its
file closes with it.

# `start_link`

```elixir
@spec start_link(Path.t(), pid()) :: pid()
```

Start reading `path`, sending what is read to `owner`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
