summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-24 14:32:02 +0100
committerwm4 <wm4@nowhere>2014-12-24 14:32:02 +0100
commit51abca8afd7661a33d54576a00a1fcc6661d1635 (patch)
tree35f77ca24a8e71cc120d31dbdd65e73296660421 /input
parent7f36d1532e29a29305971bd7c19fd803d9603a04 (diff)
downloadmpv-51abca8afd7661a33d54576a00a1fcc6661d1635.tar.bz2
mpv-51abca8afd7661a33d54576a00a1fcc6661d1635.tar.xz
ipc: add enable_event and disable_event commands
This was requested.
Diffstat (limited to 'input')
-rw-r--r--input/ipc.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/input/ipc.c b/input/ipc.c
index 4fd9cf17e1..2ad850e5ed 100644
--- a/input/ipc.c
+++ b/input/ipc.c
@@ -424,6 +424,39 @@ static char *json_execute_command(struct client_arg *arg, void *ta_parent,
} else if (!strcmp("resume", cmd)) {
mpv_resume(arg->client);
rc = MPV_ERROR_SUCCESS;
+ } else if (!strcmp("enable_event", cmd) ||
+ !strcmp("disable_event", cmd))
+ {
+ bool enable = !strcmp("enable_event", cmd);
+
+ if (cmd_node->u.list->num != 2) {
+ rc = MPV_ERROR_INVALID_PARAMETER;
+ goto error;
+ }
+
+ if (cmd_node->u.list->values[1].format != MPV_FORMAT_STRING) {
+ rc = MPV_ERROR_INVALID_PARAMETER;
+ goto error;
+ }
+
+ char *name = cmd_node->u.list->values[1].u.string;
+ if (strcmp(name, "all") == 0) {
+ for (int n = 0; n < 64; n++)
+ mpv_request_event(arg->client, n, enable);
+ rc = MPV_ERROR_SUCCESS;
+ } else {
+ int event = -1;
+ for (int n = 0; n < 64; n++) {
+ const char *evname = mpv_event_name(n);
+ if (evname && strcmp(evname, name) == 0)
+ event = n;
+ }
+ if (event < 0) {
+ rc = MPV_ERROR_INVALID_PARAMETER;
+ goto error;
+ }
+ rc = mpv_request_event(arg->client, event, enable);
+ }
} else {
mpv_node result_node;