summaryrefslogtreecommitdiffstats
path: root/core/input/input.c
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-06-03 00:52:40 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-06-03 22:35:47 +0200
commit72f2942dfa575a57d61fe023c845ba711ab78f55 (patch)
treed62395e98d5ee0ae58a5779bd8b472ee90aa9a80 /core/input/input.c
parentc39efb96d1109b7a5960cd17cc4c392c2b93b61b (diff)
downloadmpv-72f2942dfa575a57d61fe023c845ba711ab78f55.tar.bz2
mpv-72f2942dfa575a57d61fe023c845ba711ab78f55.tar.xz
osx: add Apple Remote support
After killing the non functional AR support in c8fd9e5 I got much complaints so this adds AR support back in (and it works). I am using the HIDRemote class by Felix Schwarz and that part of the code is under the BSD license. I slightly modified it replacing [NSApplication sharedApplication] with NSApp. The code of the class is quite complex (probably because it had to deal with all the edge cases with IOKit) but it works nicely as a black box. In a later commit I'll remove the deprecation warnings caused by HIDRemote's usage of Gestalt. Check out `etc/input.conf` for the default bindings. Apple Remote functionality is automatically compiled in when cocoa is enabled. It can be disabled at runtime with the `--no-ar` option.
Diffstat (limited to 'core/input/input.c')
-rw-r--r--core/input/input.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/core/input/input.c b/core/input/input.c
index 0154fa11aa..62d75bb3c0 100644
--- a/core/input/input.c
+++ b/core/input/input.c
@@ -394,6 +394,21 @@ static const struct key_name key_names[] = {
{ MP_JOY_BTN8, "JOY_BTN8" },
{ MP_JOY_BTN9, "JOY_BTN9" },
+ { MP_AR_PLAY, "AR_PLAY" },
+ { MP_AR_PLAY_HOLD, "AR_PLAY_HOLD" },
+ { MP_AR_CENTER, "AR_CENTER" },
+ { MP_AR_CENTER_HOLD, "AR_CENTER_HOLD" },
+ { MP_AR_NEXT, "AR_NEXT" },
+ { MP_AR_NEXT_HOLD, "AR_NEXT_HOLD" },
+ { MP_AR_PREV, "AR_PREV" },
+ { MP_AR_PREV_HOLD, "AR_PREV_HOLD" },
+ { MP_AR_MENU, "AR_MENU" },
+ { MP_AR_MENU_HOLD, "AR_MENU_HOLD" },
+ { MP_AR_VUP, "AR_VUP" },
+ { MP_AR_VUP_HOLD, "AR_VUP_HOLD" },
+ { MP_AR_VDOWN, "AR_VDOWN" },
+ { MP_AR_VDOWN_HOLD, "AR_VDOWN_HOLD" },
+
{ MP_KEY_POWER, "POWER" },
{ MP_KEY_MENU, "MENU" },
{ MP_KEY_PLAY, "PLAY" },
@@ -536,6 +551,7 @@ static const m_option_t mp_input_opts[] = {
OPT_FLAG("joystick", input.use_joystick, CONF_GLOBAL),
OPT_FLAG("lirc", input.use_lirc, CONF_GLOBAL),
OPT_FLAG("lircc", input.use_lircc, CONF_GLOBAL),
+ OPT_FLAG("ar", input.use_ar, CONF_GLOBAL),
{ NULL, NULL, 0, 0, 0, 0, NULL}
};
@@ -1810,6 +1826,12 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf,
}
#endif
+#ifdef CONFIG_COCOA
+ if (input_conf->use_ar) {
+ cocoa_start_apple_remote();
+ }
+#endif
+
if (input_conf->in_file) {
int mode = O_RDONLY;
#ifndef __MINGW32__
@@ -1841,11 +1863,17 @@ static void clear_queue(struct cmd_queue *queue)
}
}
-void mp_input_uninit(struct input_ctx *ictx)
+void mp_input_uninit(struct input_ctx *ictx, struct input_conf *input_conf)
{
if (!ictx)
return;
+#ifdef CONFIG_COCOA
+ if (input_conf->use_ar) {
+ cocoa_stop_apple_remote();
+ }
+#endif
+
for (int i = 0; i < ictx->num_key_fd; i++) {
if (ictx->key_fds[i].close_func)
ictx->key_fds[i].close_func(ictx->key_fds[i].fd);