summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-06-04 22:12:23 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-06-04 23:02:23 +0200
commit213ad5d6c41f32cf9086fa377cd6d6df1236bb76 (patch)
treed265eda1e4deca9ad58de8e2137852d1cf3e8c1e /core
parent1b6888ae8e30331033bf197b862742d9bda21843 (diff)
downloadmpv-213ad5d6c41f32cf9086fa377cd6d6df1236bb76.tar.bz2
mpv-213ad5d6c41f32cf9086fa377cd6d6df1236bb76.tar.xz
osx: improve Media Keys support
This commit addresses some issues with the users had with the previous implementation in commit c39efb9. Here's the changes: * Use Quartz Event Taps to remove Media Key events mpv handles from the global OS X queue. This prevents conflicts with iTunes. I did this on the main thread since it is mostly idling. It's the playloop thread that actually does all the work so there is no danger of blocking the event tap callback. * Introduce `--no-media-keys` switch so that users can disable all of mpv's media key handling at runtime (some prefer iTunes for example). * Use mpv's bindings so that users can customize what the media keys do via input.conf. Current bindings are: MK_PLAY cycle pause MK_PREV playlist_prev MK_NEXT playlist_next An additional benefit of this implementation is that it is completly handled by the `macosx_events` file instead of `macosx_application` making the project organization more straightforward.
Diffstat (limited to 'core')
-rw-r--r--core/defaultopts.c1
-rw-r--r--core/input/input.c17
-rw-r--r--core/input/keycodes.h6
-rw-r--r--core/options.h1
4 files changed, 23 insertions, 2 deletions
diff --git a/core/defaultopts.c b/core/defaultopts.c
index a8a6b26930..a03370bed6 100644
--- a/core/defaultopts.c
+++ b/core/defaultopts.c
@@ -110,6 +110,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
.use_lircc = 1,
#ifdef CONFIG_COCOA
.use_ar = 1,
+ .use_media_keys = 1,
#endif
.default_bindings = 1,
}
diff --git a/core/input/input.c b/core/input/input.c
index 4bfc22a08c..8bc877ce79 100644
--- a/core/input/input.c
+++ b/core/input/input.c
@@ -409,6 +409,10 @@ static const struct key_name key_names[] = {
{ MP_AR_VDOWN, "AR_VDOWN" },
{ MP_AR_VDOWN_HOLD, "AR_VDOWN_HOLD" },
+ { MP_MK_PLAY, "MK_PLAY" },
+ { MP_MK_PREV, "MK_PREV" },
+ { MP_MK_NEXT, "MK_NEXT" },
+
{ MP_KEY_POWER, "POWER" },
{ MP_KEY_MENU, "MENU" },
{ MP_KEY_PLAY, "PLAY" },
@@ -553,6 +557,7 @@ static const m_option_t mp_input_opts[] = {
OPT_FLAG("lircc", input.use_lircc, CONF_GLOBAL),
#ifdef CONFIG_COCOA
OPT_FLAG("ar", input.use_ar, CONF_GLOBAL),
+ OPT_FLAG("media-keys", input.use_media_keys, CONF_GLOBAL),
#endif
{ NULL, NULL, 0, 0, 0, 0, NULL}
};
@@ -1830,7 +1835,11 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf,
#ifdef CONFIG_COCOA
if (input_conf->use_ar) {
- cocoa_start_apple_remote();
+ cocoa_init_apple_remote();
+ }
+
+ if (input_conf->use_media_keys) {
+ cocoa_init_media_keys();
}
#endif
@@ -1872,7 +1881,11 @@ void mp_input_uninit(struct input_ctx *ictx, struct input_conf *input_conf)
#ifdef CONFIG_COCOA
if (input_conf->use_ar) {
- cocoa_stop_apple_remote();
+ cocoa_uninit_apple_remote();
+ }
+
+ if (input_conf->use_media_keys) {
+ cocoa_uninit_media_keys();
}
#endif
diff --git a/core/input/keycodes.h b/core/input/keycodes.h
index b9d2da23b7..8770f8abfa 100644
--- a/core/input/keycodes.h
+++ b/core/input/keycodes.h
@@ -189,6 +189,12 @@
#define MP_AR_VDOWN (MP_AR_BASE + 12)
#define MP_AR_VDOWN_HOLD (MP_AR_BASE + 13)
+// Apple Media Keys input module
+#define MP_MK_BASE (MP_KEY_BASE+0xF0)
+#define MP_MK_PLAY (MP_AR_BASE + 0)
+#define MP_MK_PREV (MP_AR_BASE + 1)
+#define MP_MK_NEXT (MP_AR_BASE + 2)
+
/* Special keys */
#define MP_KEY_INTERN (MP_KEY_BASE+0x1000)
#define MP_KEY_CLOSE_WIN (MP_KEY_INTERN+0)
diff --git a/core/options.h b/core/options.h
index 0504ea0591..eaa908d7bd 100644
--- a/core/options.h
+++ b/core/options.h
@@ -241,6 +241,7 @@ typedef struct MPOpts {
int use_lircc;
#ifdef CONFIG_COCOA
int use_ar;
+ int use_media_keys;
#endif
int default_bindings;
int test;