simvx.core.input.spelling¶
The written form of an input source, shared by simvx.toml and the rebind file.
One spelling for everything an action’s source list can hold, so a project’s settings and a player’s saved rebinds read and write the same thing:
.. code-block:: toml
jump = ["space", "controller:a"] # a key's name, or any control's spelling
save = ["ctrl+s", {key = "s", held = ["meta"]}] # a combo, or the table it stands for
find = [{key = "f", held = ["ctrl"], exact = false}]
super = [{control = "controller:a", held = ["controller:left_bumper"]}]
steer = ["controller:left_x", {low = "a", high = "d"}] # a whole axis, or two sides of one
move = ["controller:left_stick", {up = "w", down = "s", left = "a", right = "d"}]
pause = [{name = "start"}, "escape"] # another entry, by name
A string is always a control (a key’s name, a combo, or a control’s
type:name spelling) and never another entry’s name, which is written
{name = "..."}, so a string is never ambiguous. A whole axis reads as its
two halves and a stick as its four, as they do in code. Every value is plain
data (strings, numbers, booleans, lists and tables), so it fits TOML and JSON
alike.
A binding is written in the shortest form that reads back as exactly it: a bare key as its name, anything else as a table.
Module Contents¶
Functions¶
One source read back from its written form; a name reference reads as the name. |
|
source as plain data: the shortest form that reads back as exactly it. |
Data¶
API¶
- simvx.core.input.spelling.__all__¶
[‘source_from_data’, ‘source_to_data’]
- simvx.core.input.spelling.source_from_data(data: Any, *, device_id: int | None = None) simvx.core.input.actions.Source[source]¶
One source read back from its written form; a name reference reads as the name.
device_id pins every control read to that unit, which is how a section of the rebind file filed under one controller comes back. Raises
ValueErrornaming what is wrong, with the spelling that would be right.
- simvx.core.input.spelling.source_to_data(source: simvx.core.input.actions.Source) Any[source]¶
source as plain data: the shortest form that reads back as exactly it.
A control’s unit is not written: the rebind file files a pinned binding under its device’s guid, and reading that section pins it again.