# `Cauldron2D.Wx.Input`
[🔗](https://github.com/jaman/cauldron/blob/v0.1.3/cauldron_2d_wx/lib/cauldron_2d/wx/input.ex#L1)

The keys and buttons a desktop player holds, as the input message the server takes.

    input = Cauldron2D.Wx.Input.new(%{?A => :left, 315 => :jump, {:mouse, :left} => :act}, steering: [:left, :right])
    {input, handled?} = Cauldron2D.Wx.Input.press(input, ?A)
    Cauldron2D.Wx.Input.state(input)

Keys are wx key codes (`?A`, `32`, `315` for the up arrow); buttons `{:mouse, :left | :right | :middle}`.
A held key of a steering action clears the aim, so the keys take over from the pointer
until it moves again, as the other clients do.

# `t`

```elixir
@type t() :: %Cauldron2D.Wx.Input{
  aim: {number(), number()} | nil,
  held: MapSet.t(atom()),
  keymap: map(),
  steering: [atom()]
}
```

# `aim`

```elixir
@spec aim(t(), {number(), number()} | nil) :: t()
```

The pointer moved to a world position.

# `button`

```elixir
@spec button(t(), :left | :right | :middle, boolean()) :: t()
```

A mouse button went down or up.

# `drop`

```elixir
@spec drop(t()) :: t()
```

Every key let go, as when the window loses focus.

# `new`

```elixir
@spec new(map(), keyword()) :: t()
```

An input reading `keymap`; `:steering` names the actions the pointer also drives.

# `press`

```elixir
@spec press(t(), integer()) :: {t(), boolean()}
```

A key went down; `{input, whether the key meant anything}`.

# `release`

```elixir
@spec release(t(), integer()) :: {t(), boolean()}
```

A key came up; `{input, whether the key meant anything}`.

# `state`

```elixir
@spec state(t()) :: %{held: [String.t()], aim: [number()] | nil}
```

What to send: the actions held, by name, and the aim as a pair.

---

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