The KVM's keyboard, mouse and touch input to the target computer, on the
:keyboard, :mouse and :relative_mouse functions of
Kuroneko.Gadget.
The process keeps the keys and buttons held and sends a report on each change, so callers only send changes:
Kuroneko.Gadget.Input.key("ShiftLeft", :down)
Kuroneko.Gadget.Input.key("KeyA", :down)
Kuroneko.Gadget.Input.key("KeyA", :up)
Kuroneko.Gadget.Input.key("ShiftLeft", :up)
Kuroneko.Gadget.Input.pointer(x: 0.5, y: 0.5)
Kuroneko.Gadget.Input.pointer(buttons: [:left])
Kuroneko.Gadget.Input.pointer(buttons: [])
Kuroneko.Gadget.Input.pointer(wheel: -1)
Kuroneko.Gadget.Input.type("Hello!\n")
Kuroneko.Gadget.Input.relative(dx: 10, dy: -3)
Kuroneko.Gadget.Input.touch([{0, 0.2, 0.3}, {1, 0.6, 0.3}])Keys are KeyboardEvent.code values (see Kuroneko.Gadget.HID.Keymap)
or HID usages; keys the keyboard has no usage for are ignored.
pointer/2 and touch/2 place the pointer from 0.0 (left, top) to 1.0
(right, bottom) across the target's screen, with the :mouse function in
its mode: an absolute mouse, a pen (where the left button puts the tip
down) or a touch screen (where it touches). relative/2 moves the
:relative_mouse, which BIOS setups and games take.
Input wakes a target that sleeps, where it lets its USB devices wake it. Without a device (the function is missing, or went away while the gadget changed) reports are dropped, and the device is opened again a little later. While the target does not take reports (unplugged, asleep), only the newest report is kept for when it does: no key stays held.
Options
:name- the name to register,Kuroneko.Gadget.Inputby default:keyboard,:mouse,:relative_mouse- device paths; by default the devices of the functions of those names. Or{module, arg}, for input that goes elsewhere, such as over Bluetooth: a process thatmodule.start_link(arg)starts and links, which takes each report as{:report, report}and does not wake the target:pointer_mode- the mode of the absolute pointer, by default the one of the gadget's:mousefunction:gadget- the gadget,Kuroneko.Gadget.default_gadget/0by default:udc_class- where the device controllers are,/sys/class/udcby default
Summary
Types
A touch: an id from 0 to 9 and where, from 0.0 to 1.0.
A KeyboardEvent.code value or a HID usage.
How the absolute pointer reports: as a mouse, a pen or a touch screen.
Where the reports of a device go: its path, or a process to start.
Functions
Returns a specification to start this module under a supervisor.
Presses or releases a key.
Moves the absolute pointer, presses or releases buttons, turns the wheels
(:wheel up, :pan right). What is not given stays as it is; the wheels
turn only once.
The mode of the absolute pointer: :absolute, :stylus or :touch.
Moves the relative mouse by :dx and :dy (right, down), presses or
releases its buttons, turns its wheels.
Releases all keys, buttons and touches and stops any typing, for example when the user goes away. It does not wake the target.
Starts the process. See the module documentation for the options.
The devices in use and the reports sent and dropped for each.
The contacts touching the screen now, up to ten: on a touch screen each, else the first as the pointer with the left button.
Types text on the target as a US keyboard would, a key at a time, some 60
characters a second, after any text typed before. Characters that
keyboard has no key for are left out. release_all/1 stops the typing.
Types
@type button() :: :left | :right | :middle | :back | :forward
A touch: an id from 0 to 9 and where, from 0.0 to 1.0.
@type device_stats() :: %{ device: Path.t() | nil, sent: non_neg_integer(), dropped: non_neg_integer() }
@type key() :: Kuroneko.Gadget.HID.Keymap.code() | 4..221 | 224..231
A KeyboardEvent.code value or a HID usage.
@type option() :: {:name, GenServer.name() | nil} | {:keyboard, writer()} | {:mouse, writer()} | {:relative_mouse, writer()} | {:pointer_mode, pointer_mode()} | {:gadget, Path.t()} | {:udc_class, Path.t()}
@type pointer_mode() :: :absolute | :stylus | :touch
How the absolute pointer reports: as a mouse, a pen or a touch screen.
@type stats() :: %{ keyboard: device_stats(), mouse: device_stats(), relative_mouse: device_stats() }
Where the reports of a device go: its path, or a process to start.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec key(GenServer.server(), key(), :down | :up) :: :ok
Presses or releases a key.
@spec pointer(GenServer.server(), [pointer_change()]) :: :ok
Moves the absolute pointer, presses or releases buttons, turns the wheels
(:wheel up, :pan right). What is not given stays as it is; the wheels
turn only once.
@spec pointer_mode(GenServer.server()) :: pointer_mode()
The mode of the absolute pointer: :absolute, :stylus or :touch.
@spec relative(GenServer.server(), [relative_change()]) :: :ok
Moves the relative mouse by :dx and :dy (right, down), presses or
releases its buttons, turns its wheels.
@spec release_all(GenServer.server()) :: :ok
Releases all keys, buttons and touches and stops any typing, for example when the user goes away. It does not wake the target.
@spec start_link([option()]) :: GenServer.on_start()
Starts the process. See the module documentation for the options.
@spec stats(GenServer.server()) :: stats()
The devices in use and the reports sent and dropped for each.
@spec touch(GenServer.server(), [contact()]) :: :ok
The contacts touching the screen now, up to ten: on a touch screen each, else the first as the pointer with the left button.
@spec type(GenServer.server(), String.t()) :: :ok
Types text on the target as a US keyboard would, a key at a time, some 60
characters a second, after any text typed before. Characters that
keyboard has no key for are left out. release_all/1 stops the typing.