afk v0.1.0 AFK.State View Source

A struct representing the current state of the keyboard.

The state is initialized with a list of physical key to keycode maps representing the desired layers. The first layer is assumed to be the active default.

The keyboard state can be modified by calling press_key/2 and release_key/2 with physical key IDs.

The state can then be turned into a HID report byte string using to_hid_report/1.

Link to this section Summary

Functions

Returns a new state struct initialized with the given keymap.

Adds a key being pressed.

Releases a key being pressed.

Return the keyboard state to as a 6-key USB keyboard HID report.

Link to this section Types

Link to this type

t()

View Source
t() :: %AFK.State{
  keymap: AFK.State.Keymap.t(),
  keys: %{required(atom()) => AFK.Keycode.t()},
  modifiers: %{required(atom()) => AFK.Keycode.t()},
  six_keys: [nil | AFK.Scancode.t()]
}

Link to this section Functions

Returns a new state struct initialized with the given keymap.

Link to this function

press_key(state, key)

View Source
press_key(t(), atom()) :: t()

Adds a key being pressed.

Link to this function

release_key(state, key)

View Source
release_key(t(), atom()) :: t()

Releases a key being pressed.

Link to this function

to_hid_report(state)

View Source
to_hid_report(t()) :: <<_::64>>

Return the keyboard state to as a 6-key USB keyboard HID report.