From ae5df9be98e4193342321f30285655fcf88e7e63 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 23 Nov 2014 15:08:49 +0100 Subject: input, lua: redo input handling Much of it is the same, but now there's the possibility to distinguish key down/up events in the Lua API. --- DOCS/man/lua.rst | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'DOCS/man/lua.rst') diff --git a/DOCS/man/lua.rst b/DOCS/man/lua.rst index e09792a277..3f9e90e0b0 100644 --- a/DOCS/man/lua.rst +++ b/DOCS/man/lua.rst @@ -198,12 +198,23 @@ The ``mp`` module is preloaded, although it can be loaded manually with overwritten. You can omit the name, in which case a random name is generated internally. - The last argument is used for additional flags. Currently, this includes - the string ``repeatable``, which enables key repeat for this specific - binding. + The last argument is used for optional flags. This is a table, which can + have the following entries: - Internally, key bindings are dispatched via the ``script_message_to`` input - command and ``mp.register_script_message``. + ``repeatable`` + If set to ``true``, enables key repeat for this specific binding. + + ``complex`` + If set to ``true``, then ``fn`` is called on both key up and down + events (as well as key repeat, if enabled), with the first + argument being a table. This table has an ``event`` entry, which + is set to one of the strings ``down``, ``repeat``, ``up`` or + ``press`` (the latter if key up/down can't be tracked). It further + has an ``is_mouse`` entry, which tells whether the event was caused + by a mouse button. + + Internally, key bindings are dispatched via the ``script_message_to`` or + ``script_binding`` input commands and ``mp.register_script_message``. Trying to map multiple commands to a key will essentially prefer a random binding, while the other bindings are not called. It is guaranteed that @@ -226,7 +237,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with :: - y script_message something + y script_binding something This will print the message when the key ``y`` is pressed. (``x`` will @@ -237,7 +248,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with :: - y script_message_to fooscript something + y script_binding fooscript.something ``mp.add_forced_key_binding(...)`` This works almost the same as ``mp.add_key_binding``, but registers the -- cgit v1.2.3