summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-01 17:06:11 +0200
committerwm4 <wm4@nowhere>2013-09-01 20:17:50 +0200
commitead525e17a0e81bdac915dccbb0503f07cb426bf (patch)
treea17cc671ec407eb0cb56d4e21dbf3cf67ebe321c /mpvcore
parent3ad7b9419eb37b452b7b08e71d68da6b6cf0428e (diff)
downloadmpv-ead525e17a0e81bdac915dccbb0503f07cb426bf.tar.bz2
mpv-ead525e17a0e81bdac915dccbb0503f07cb426bf.tar.xz
input: comment all default bindings in input.conf
I suspect most users will just copy etc/input.conf when they want to remap some default bindings. But usually this means the user even copies bindings he doesn't care about, and it's better if the user maps only the bindings in his input.conf the user intends to remap. Comment all bindings in etc/input.conf. Since this file also defines the builtin defaults and is baked into the mpv binary, we have to do something to get them anyway, even though they are commented. Do this by having input.c "uncomment" the bindings in the baked in input.conf. (Of course this is done only for the builtin config, not configs loaded from disk.)
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/input/input.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c
index 76d157afac..b89b6eecf2 100644
--- a/mpvcore/input/input.c
+++ b/mpvcore/input/input.c
@@ -2169,7 +2169,15 @@ struct input_ctx *mp_input_init(struct MPOpts *opts)
mp_input_enable_section(ictx, NULL, 0);
- parse_config(ictx, true, bstr0(builtin_input_conf), "<builtin>", NULL);
+ // "Uncomment" the default key bindings in etc/input.conf and add them.
+ // All lines that do not start with '# ' are parsed.
+ bstr builtin = bstr0(builtin_input_conf);
+ while (builtin.len) {
+ bstr line = bstr_getline(builtin, &builtin);
+ bstr_eatstart0(&line, "#");
+ if (!bstr_startswith0(line, " "))
+ parse_config(ictx, true, line, "<builtin>", NULL);
+ }
#ifndef __MINGW32__
long ret = pipe(ictx->wakeup_pipe);