Gamepad.Linux.Reader (gamepad v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

Start reading path, sending what is read to owner.

Functions

start_link(path, owner)

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

Start reading path, sending what is read to owner.