diff options
Diffstat (limited to 'osdep/macosx_application.m')
-rw-r--r-- | osdep/macosx_application.m | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index 665a04b222..1329091e12 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -120,7 +120,19 @@ static NSString *escape_loadfile_name(NSString *input) - (void)sendEvent:(NSEvent *)event { - [super sendEvent:event]; + if ([event type] == NSSystemDefined && [event subtype] == 8) { + // It's a media key! Handle it specially. The magic numbers are reverse + // engineered and found on several blog posts. Unfortunately there is + // no public API for this. F-bomb. + int code = (([event data1] & 0xFFFF0000) >> 16); + int flags = ([event data1] & 0x0000FFFF); + int down = (((flags & 0xFF00) >> 8)) == 0xA; + + if (down) + [self.eventsResponder handleMediaKey:code]; + } else { + [super sendEvent:event]; + } if (self.inputContext) mp_input_wakeup(self.inputContext); |