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

The USB HID reports of the devices `Kuroneko.Gadget` sets up: the boot
keyboard, the relative boot mouse, and the absolute pointer as a mouse, a
pen or a touch screen.

# `buttons`

```elixir
@type buttons() :: 0..31
```

Mouse buttons as report bits: 1 left, 2 right, 4 middle, 8 back, 16 forward.

# `contact`

```elixir
@type contact() :: {0..9, 0..32767, 0..32767}
```

A touch: its id (0 to 9) and where, from 0 to 32767.

# `absolute`

```elixir
@spec absolute(number()) :: 0..32767
```

A position across the screen, 0.0 to 1.0 (clamped), in the pointer's
range.

    iex> Kuroneko.Gadget.HID.Report.absolute(0.5)
    16384

# `keyboard`

```elixir
@spec keyboard(0..255, [0..255]) :: &lt;&lt;_::64&gt;&gt;
```

A boot keyboard report: the modifier bits, a reserved byte and up to six
key usages.

    iex> Kuroneko.Gadget.HID.Report.keyboard(0x02, [0x04])
    <<0x02, 0, 0x04, 0, 0, 0, 0, 0>>

# `mouse`

```elixir
@spec mouse(buttons(), 0..32767, 0..32767, -127..127, -127..127) :: &lt;&lt;_::56&gt;&gt;
```

An absolute mouse report: the buttons, X and Y from 0 (left, top) to 32767
(right, bottom), and wheel steps, positive up, and to the right.

    iex> Kuroneko.Gadget.HID.Report.mouse(1, 16384, 0, -1, 0)
    <<1, 0x00, 0x40, 0, 0, 0xFF, 0>>

# `relative_mouse`

```elixir
@spec relative_mouse(buttons(), -127..127, -127..127, -127..127, -127..127) ::
  &lt;&lt;_::40&gt;&gt;
```

A relative boot mouse report: the buttons, the movement right and down,
and wheel steps, positive up, and to the right. The first three bytes are
the boot report.

    iex> Kuroneko.Gadget.HID.Report.relative_mouse(2, -5, 10, 0, 1)
    <<2, 0xFB, 10, 0, 1>>

# `stylus`

```elixir
@spec stylus(boolean(), boolean(), 0..32767, 0..32767) :: &lt;&lt;_::56&gt;&gt;
```

A pen report: whether the tip touches, whether the pen is in range, and
where, from 0 to 32767. The tip presses fully.

    iex> Kuroneko.Gadget.HID.Report.stylus(true, true, 100, 200)
    <<2, 0b11, 100, 0, 200, 0, 255>>

# `touch`

```elixir
@spec touch([contact()]) :: &lt;&lt;_::496&gt;&gt;
```

A touch screen report: the contacts touching, up to ten.

    iex> report = Kuroneko.Gadget.HID.Report.touch([{0, 1, 2}])
    iex> {byte_size(report), binary_part(report, 0, 7), :binary.last(report)}
    {62, <<3, 0b11, 0, 1, 0, 2, 0>>, 1}

---

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