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.
Summary
Types
Mouse buttons as report bits: 1 left, 2 right, 4 middle, 8 back, 16 forward.
A touch: its id (0 to 9) and where, from 0 to 32767.
Functions
A position across the screen, 0.0 to 1.0 (clamped), in the pointer's range.
A boot keyboard report: the modifier bits, a reserved byte and up to six key usages.
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.
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.
A pen report: whether the tip touches, whether the pen is in range, and where, from 0 to 32767. The tip presses fully.
A touch screen report: the contacts touching, up to ten.
Types
Functions
@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
@spec keyboard(0..255, [0..255]) :: <<_::64>>
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>>
@spec mouse(buttons(), 0..32767, 0..32767, -127..127, -127..127) :: <<_::56>>
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>>
@spec relative_mouse(buttons(), -127..127, -127..127, -127..127, -127..127) :: <<_::40>>
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>>
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>>
@spec touch([contact()]) :: <<_::496>>
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}