# `Kuroneko.Gadget.HID`
[🔗](https://github.com/cocoa-xu/kuroneko_gadget/blob/v0.5.0/lib/kuroneko/gadget/hid.ex#L1)

The kernel's HID function: a keyboard, a mouse, a game controller, any
device a HID report descriptor describes. A program writes its reports
to the instance's device file.

    pad = %{report_desc: File.read!("pad.bin"), report_length: 4}
    Kuroneko.Gadget.configure([{Kuroneko.Gadget.HID, name: "pad", descriptor: pad}])
    {:ok, path} = Kuroneko.Gadget.HID.device(name: "pad")

The `:keyboard`, `:mouse` and `:relative_mouse` of `Kuroneko.Gadget` are
instances with the descriptors of `descriptor/1`, which
`Kuroneko.Gadget.Input` drives.

## Options

  * `:descriptor` - a map with the `:report_desc`, the `:report_length` of
    the longest input report, and the boot `:protocol` and `:subclass`: 1
    and 1 for a keyboard, 2 and 1 for a mouse, 0 and 0 by default. Or a
    descriptor of `descriptor/1`, by its name.

# `builtin`

```elixir
@type builtin() :: :keyboard | :mouse | :stylus | :touch | :relative_mouse
```

The built-in descriptors: a boot keyboard, the absolute pointer as a
mouse, a pen (for Android and iPadOS) or a touch screen, and a relative
boot mouse.

# `descriptor`

```elixir
@type descriptor() :: %{
  report_desc: binary(),
  report_length: pos_integer(),
  protocol: 0..2,
  subclass: 0..1
}
```

# `builtin`

```elixir
@spec builtin(descriptor()) :: builtin() | nil
```

The name of a built-in descriptor, `nil` for another one.

# `descriptor`

```elixir
@spec descriptor(builtin()) :: descriptor()
```

A built-in descriptor.

# `device`

```elixir
@spec device(keyword()) ::
  {:ok, Path.t()} | {:error, Kuroneko.Gadget.configfs_error()}
```

The device file of an instance, such as `"/dev/hidg0"`: the one `:name`
names, `"hid"` by default. Takes the `:gadget` option.

---

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