Docs / Plugins / Plugin API reference
Input
omsi.input.* reads keys, the mouse and game controllers, and registers hotkeys. Key names are winit's: KeyH, F5, Numpad8, ShiftLeft.
omsi.input.bindings#
omsi.input.bindings([vehicles]) → list of tables
The key bindings: {action, key} of the game's keys, or the vehicles' with true (key as the game writes it: "Ctrl+D").
Parameters: vehicles bool, optional.
Since 0.2.22.
omsi.input.controllers#
omsi.input.controllers() → list of tables
The steering wheels, pedals, joysticks and gamepads: {name, gamepad, axes, buttons} (axes each axis's value; buttons how many it has - the controller_button event tells presses).
Since 0.2.22.
omsi.input.hotkey#
omsi.input.hotkey(keys, fn) → integer id
Runs fn(key) when a key combination is pressed: "F10", "Ctrl+KeyH", "Shift+Alt+Digit1" (modifiers exact: "KeyH" is not Ctrl+KeyH). The keys still reach the bus. cancel(id) removes it.
Parameters: keys string; fn function.
Since 0.2.22.
omsi.input.hotkey("Ctrl+KeyH", function()
omsi.ui.toggle("help")
end)omsi.input.key_down#
omsi.input.key_down(key) → boolean
Whether a key is held now (winit's names, as the key event: "KeyW", "ShiftLeft", "F5").
Parameters: key string.
Since 0.2.22.
omsi.input.keys_down#
omsi.input.keys_down() → list of strings
Every key held now.
Since 0.2.22.
omsi.input.mouse#
omsi.input.mouse() → x, y, left, right, middle
The mouse: where it is in the panels' pixels and its buttons held.
Since 0.2.22.
local x, y, left = omsi.input.mouse()Something wrong or missing? Fix it on GitHub or open an issue.