QuakeServer.Console.Bindings (quake_server v0.1.0)

Copy Markdown View Source

FTE's key bindings (keys.c): the console's bind, in_bind, bindlevel, unbind and unbindall, and the lookups the client and menu programs make, kept in the host's QuakeServer.Cvars table (QuakeServer.Cvars.binding/3) so every holder of it shares them.

server = QuakeServer.Console.run(server, "bind w +forward; bind ctrl+q quit")
QuakeServer.Console.Bindings.get(server.cvars, ?w, 0, 0)
#=> "+forward"

Keys are named and numbered as QuakeServer.Keys names and numbers them. A binding made with no modifier in the key's name holds for every modifier state but the bind maps; unbind with no modifier clears the bind maps too. bind key alone prints the binding. in_bind map key command binds in bind map map (1 to 8). bindlevel key level command binds at restriction level level. A binding is made at the level of the command that made it: 29 for the console (:local), 31 for the server.

Summary

Functions

Run binding command name (one of commands/0) from the console (:local) or the server.

The console's binding commands.

Up to count keys bound to command (a binding matches when it starts with the command followed by its end, a space or ;), as {keynum, modifier} in key order (FTE's M_FindKeysForBind): bind map bindmap (1 to 8) only, or else the eight modifier states, skipping a modified state bound the same as a state with fewer of its modifiers.

The command bound to key number keynum (FTE's Key_GetBinding): with bindmap below 0 the binding of the first then second current bind map (Cvars.bindmaps/1); with bindmap 1 to 8 that bind map's; otherwise modifier state modifier's. nil when unbound.

Bind key number keynum to command (or unbind it with nil) in modifier state modifier at restriction level (FTE's Key_SetBinding); :all binds every state but the bind maps, or unbinds every state.

The bindings as bind, bindlevel and in_bind lines for a config (FTE's Key_WriteBindings): each key's unmodified binding, then each modifier state bound differently from it, then its bind maps.

Functions

command(server, name, tokens, line, from)

@spec command(
  QuakeServer.Server.t(),
  String.t(),
  [tuple()],
  String.t(),
  :local | :server
) ::
  QuakeServer.Server.t()

Run binding command name (one of commands/0) from the console (:local) or the server.

commands()

@spec commands() :: [String.t()]

The console's binding commands.

find(cvars, bindmap, command, count)

@spec find(QuakeServer.Cvars.t(), integer(), String.t(), pos_integer()) :: [
  {integer(), integer()}
]

Up to count keys bound to command (a binding matches when it starts with the command followed by its end, a space or ;), as {keynum, modifier} in key order (FTE's M_FindKeysForBind): bind map bindmap (1 to 8) only, or else the eight modifier states, skipping a modified state bound the same as a state with fewer of its modifiers.

get(cvars, keynum, bindmap, modifier)

@spec get(QuakeServer.Cvars.t(), integer(), integer(), integer()) :: String.t() | nil

The command bound to key number keynum (FTE's Key_GetBinding): with bindmap below 0 the binding of the first then second current bind map (Cvars.bindmaps/1); with bindmap 1 to 8 that bind map's; otherwise modifier state modifier's. nil when unbound.

set(cvars, keynum, modifier, command, level)

@spec set(
  QuakeServer.Cvars.t(),
  integer(),
  QuakeServer.Keys.modifier(),
  String.t() | nil,
  integer()
) ::
  :ok

Bind key number keynum to command (or unbind it with nil) in modifier state modifier at restriction level (FTE's Key_SetBinding); :all binds every state but the bind maps, or unbinds every state.

write(cvars)

@spec write(QuakeServer.Cvars.t()) :: String.t()

The bindings as bind, bindlevel and in_bind lines for a config (FTE's Key_WriteBindings): each key's unmodified binding, then each modifier state bound differently from it, then its bind maps.