summaryrefslogtreecommitdiffstats
path: root/mpvcore/input
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-26 00:41:14 +0200
committerwm4 <wm4@nowhere>2013-09-26 01:28:58 +0200
commit6048f87e3c07d03df8a59da58c81608c5375f6dc (patch)
treebe79bfe51b5268f2c1494f456fa72538c391d54f /mpvcore/input
parentb0cc3c2cf4e342e33300adaea4a98565ad866e22 (diff)
downloadmpv-6048f87e3c07d03df8a59da58c81608c5375f6dc.tar.bz2
mpv-6048f87e3c07d03df8a59da58c81608c5375f6dc.tar.xz
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect of scripting may change in the future. I decided to merge this (preliminary) work now because it makes it easier to develop it, not because it's done. lua.rst is clear enough about it (plus some sarcasm). This requires linking to Lua. Lua has no official pkg-config file, but there are distribution specific .pc files, all with different names. Adding a non-pkg-config based configure test was considered, but we'd rather not. One major complication is that libquvi links against Lua too, and if the Lua version is different from mpv's, you will get a crash as soon as libquvi uses Lua. (libquvi by design always runs when a file is opened.) I would consider this the problem of distros and whoever builds mpv, but to make things easier for users, we add a terrible runtime test to the configure script, which probes whether libquvi will crash. This is disabled when cross-compiling, but in that case we hope the user knows what he is doing.
Diffstat (limited to 'mpvcore/input')
-rw-r--r--mpvcore/input/input.c5
-rw-r--r--mpvcore/input/input.h3
2 files changed, 8 insertions, 0 deletions
diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c
index 902aa52b47..f624b8f5dd 100644
--- a/mpvcore/input/input.c
+++ b/mpvcore/input/input.c
@@ -229,6 +229,8 @@ static const mp_cmd_t mp_cmds[] = {
{ MP_CMD_VO_CMDLINE, "vo_cmdline", { ARG_STRING } },
+ { MP_CMD_SCRIPT_DISPATCH, "script_dispatch", { ARG_STRING, ARG_INT } },
+
{0}
};
@@ -528,6 +530,7 @@ struct input_ctx {
// Autorepeat stuff
short ar_state;
int64_t last_ar;
+
// Autorepeat config
unsigned int ar_delay;
unsigned int ar_rate;
@@ -1455,6 +1458,8 @@ static void remove_key_down(struct input_ctx *ictx, int code)
static bool key_updown_ok(enum mp_command_type cmd)
{
switch (cmd) {
+ case MP_CMD_SCRIPT_DISPATCH:
+ return true;
default:
return false;
}
diff --git a/mpvcore/input/input.h b/mpvcore/input/input.h
index f3ea895395..639f069a9c 100644
--- a/mpvcore/input/input.h
+++ b/mpvcore/input/input.h
@@ -85,6 +85,9 @@ enum mp_command_type {
/// Video output commands
MP_CMD_VO_CMDLINE,
+ /// Internal for Lua scripts
+ MP_CMD_SCRIPT_DISPATCH,
+
// Internal
MP_CMD_COMMAND_LIST, // list of sub-commands in args[0].v.p
};