Commit Graph

6 Commits

Author SHA1 Message Date
Stefano Pigozzi 85c2a4a1d2 macosx_events: make remote property an instance variable
There was no reason for it to be public.
2013-06-05 00:02:29 +02:00
Stefano Pigozzi 213ad5d6c4 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.
2013-06-04 23:02:23 +02:00
Stefano Pigozzi 72f2942dfa 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.
2013-06-03 22:35:47 +02:00
Stefano Pigozzi c39efb96d1 osx: implement media keys
Media keys are pretty handy if you use mpv as a music player (yes I'm one of
those people that do).

These are the bindings (which lead to the same behaviour as iTunes):
  * NX_KEYTYPE_PLAY   -> MP_KEY_PLAY
  * NX_KEYTYPE_FAST   -> MP_KEY_NEXT
  * NX_KEYTYPE_REWIND -> MP_KEY_PREV

I just handled these ones as the volume one would be pretty invasive. I could
maybe change it to increase the application's volume instead of system volume
only when mpv is frontmost (iTunes does this), but some users would probably
hate it.
2013-06-03 22:31:14 +02:00
Stefano Pigozzi d67b687530 macosx_events: send all queued events
Seeking feels a little faster or it may be self suggestion. There's really no
reason to just send only one event at a time.
2013-06-03 22:31:13 +02:00
Stefano Pigozzi f13f0db33a osx: create macosx_events to deal with keyDown events
On OSX with Cocoa enabled keyDown events are now handled with
addLocalMonitorForEventsMatchingMask:handler:. This allows to respond to
events even when there is no VO initialized but the GUI is focused.
2013-06-03 22:31:13 +02:00