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_lengthof the longest input report, and the boot:protocoland:subclass: 1 and 1 for a keyboard, 2 and 1 for a mouse, 0 and 0 by default. Or a descriptor ofdescriptor/1, by its name.
Summary
Types
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.
Functions
The name of a built-in descriptor, nil for another one.
A built-in descriptor.
The device file of an instance, such as "/dev/hidg0": the one :name
names, "hid" by default. Takes the :gadget option.
Types
@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.
@type descriptor() :: %{ report_desc: binary(), report_length: pos_integer(), protocol: 0..2, subclass: 0..1 }
Functions
@spec builtin(descriptor()) :: builtin() | nil
The name of a built-in descriptor, nil for another one.
@spec descriptor(builtin()) :: descriptor()
A built-in descriptor.
@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.