mamburu: SPMediaKeyTap (https://github.com/nevyn/SPMediaKeyTap) is now used to handle media keys - iTunes won't start on Play button while Cog is running
|
@ -9,8 +9,11 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
#import <IOKit/hidsystem/ev_keymap.h>
|
||||
|
||||
@class SPMediaKeyTap;
|
||||
|
||||
@interface MediaKeysApplication : NSApplication
|
||||
{
|
||||
SPMediaKeyTap *keyTap;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,44 +8,70 @@
|
|||
|
||||
#import "MediaKeysApplication.h"
|
||||
#import "AppController.h"
|
||||
#import "SPMediaKeyTap.h"
|
||||
#import "Logging.h"
|
||||
|
||||
@implementation MediaKeysApplication
|
||||
|
||||
- (void)mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat
|
||||
+(void)initialize;
|
||||
{
|
||||
switch( key )
|
||||
{
|
||||
case NX_KEYTYPE_PLAY:
|
||||
if( state == 0 )
|
||||
[(AppController *)[self delegate] clickPlay]; //Play pressed and released
|
||||
break;
|
||||
|
||||
case NX_KEYTYPE_NEXT:
|
||||
case NX_KEYTYPE_FAST:
|
||||
if( state == 0 )
|
||||
[(AppController *)[self delegate] clickNext]; //Next pressed and released
|
||||
break;
|
||||
|
||||
case NX_KEYTYPE_PREVIOUS:
|
||||
case NX_KEYTYPE_REWIND:
|
||||
if( state == 0 )
|
||||
[(AppController *)[self delegate] clickPrev]; //Previous pressed and released
|
||||
break;
|
||||
}
|
||||
if([self class] != [MediaKeysApplication class]) return;
|
||||
|
||||
// Register defaults for the whitelist of apps that want to use media keys
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers], kMediaKeyUsingBundleIdentifiersDefaultsKey,
|
||||
nil]];
|
||||
}
|
||||
|
||||
- (void)finishLaunching {
|
||||
[super finishLaunching];
|
||||
|
||||
keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self];
|
||||
if([SPMediaKeyTap usesGlobalMediaKeyTap])
|
||||
[keyTap startWatchingMediaKeys];
|
||||
else
|
||||
ALog(@"Media key monitoring disabled");
|
||||
}
|
||||
|
||||
- (void)sendEvent: (NSEvent*)event
|
||||
{
|
||||
if( [event type] == NSSystemDefined && [event subtype] == 8 )
|
||||
BOOL shouldHandleMediaKeyEventLocally = ![SPMediaKeyTap usesGlobalMediaKeyTap];
|
||||
|
||||
if(shouldHandleMediaKeyEventLocally && [event type] == NSSystemDefined && [event subtype] == 8 )
|
||||
{
|
||||
int keyCode = (([event data1] & 0xFFFF0000) >> 16);
|
||||
int keyFlags = ([event data1] & 0x0000FFFF);
|
||||
int keyState = (((keyFlags & 0xFF00) >> 8)) ==0xA;
|
||||
int keyRepeat = (keyFlags & 0x1);
|
||||
|
||||
[self mediaKeyEvent: keyCode state: keyState repeat: keyRepeat];
|
||||
[self mediaKeyTap:nil receivedMediaKeyEvent:event];
|
||||
}
|
||||
|
||||
[super sendEvent: event];
|
||||
}
|
||||
|
||||
-(void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
|
||||
{
|
||||
NSAssert([event type] == NSSystemDefined && [event subtype] == SPSystemDefinedEventMediaKeys, @"Unexpected NSEvent in mediaKeyTap:receivedMediaKeyEvent:");
|
||||
|
||||
int keyCode = (([event data1] & 0xFFFF0000) >> 16);
|
||||
int keyFlags = ([event data1] & 0x0000FFFF);
|
||||
BOOL keyIsPressed = (((keyFlags & 0xFF00) >> 8)) == 0xA;
|
||||
|
||||
if (!keyIsPressed) // pressed and released
|
||||
{
|
||||
switch( keyCode )
|
||||
{
|
||||
case NX_KEYTYPE_PLAY:
|
||||
[(AppController *)[self delegate] clickPlay];
|
||||
break;
|
||||
|
||||
case NX_KEYTYPE_NEXT:
|
||||
case NX_KEYTYPE_FAST:
|
||||
[(AppController *)[self delegate] clickNext];
|
||||
break;
|
||||
|
||||
case NX_KEYTYPE_PREVIOUS:
|
||||
case NX_KEYTYPE_REWIND:
|
||||
[(AppController *)[self delegate] clickPrev];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -142,6 +142,8 @@
|
|||
8360EF6D17F92E56005208A4 /* HighlyComplete.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8360EF0517F92B24005208A4 /* HighlyComplete.bundle */; };
|
||||
836D28A818086386005B7299 /* MiniModeMenuTitleTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 836D28A718086386005B7299 /* MiniModeMenuTitleTransformer.m */; };
|
||||
8375B36517FFEF130092A79F /* Opus.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8375B05717FFEA410092A79F /* Opus.bundle */; };
|
||||
83790D501809F4980073CF51 /* NSObject+SPInvocationGrabbing.m in Sources */ = {isa = PBXBuildFile; fileRef = 83790D4D1809F4980073CF51 /* NSObject+SPInvocationGrabbing.m */; };
|
||||
83790D511809F4980073CF51 /* SPMediaKeyTap.m in Sources */ = {isa = PBXBuildFile; fileRef = 83790D4F1809F4980073CF51 /* SPMediaKeyTap.m */; };
|
||||
838491211807F38A00E7332D /* NowPlayingBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8384911D1807F38A00E7332D /* NowPlayingBarView.m */; };
|
||||
838491221807F38A00E7332D /* NowPlayingBarController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8384911E1807F38A00E7332D /* NowPlayingBarController.xib */; };
|
||||
838491231807F38A00E7332D /* NowPlayingBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8384911F1807F38A00E7332D /* NowPlayingBarController.m */; };
|
||||
|
@ -772,6 +774,10 @@
|
|||
836D28A618086386005B7299 /* MiniModeMenuTitleTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MiniModeMenuTitleTransformer.h; path = Window/MiniModeMenuTitleTransformer.h; sourceTree = "<group>"; };
|
||||
836D28A718086386005B7299 /* MiniModeMenuTitleTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MiniModeMenuTitleTransformer.m; path = Window/MiniModeMenuTitleTransformer.m; sourceTree = "<group>"; };
|
||||
8375B05117FFEA400092A79F /* Opus.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Opus.xcodeproj; path = Plugins/Opus/Opus.xcodeproj; sourceTree = "<group>"; };
|
||||
83790D4C1809F4980073CF51 /* NSObject+SPInvocationGrabbing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+SPInvocationGrabbing.h"; sourceTree = "<group>"; };
|
||||
83790D4D1809F4980073CF51 /* NSObject+SPInvocationGrabbing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+SPInvocationGrabbing.m"; sourceTree = "<group>"; };
|
||||
83790D4E1809F4980073CF51 /* SPMediaKeyTap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPMediaKeyTap.h; sourceTree = "<group>"; };
|
||||
83790D4F1809F4980073CF51 /* SPMediaKeyTap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPMediaKeyTap.m; sourceTree = "<group>"; };
|
||||
8384911D1807F38A00E7332D /* NowPlayingBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NowPlayingBarView.m; path = Window/NowPlayingBarView.m; sourceTree = "<group>"; };
|
||||
8384911E1807F38A00E7332D /* NowPlayingBarController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = NowPlayingBarController.xib; path = Window/NowPlayingBarController.xib; sourceTree = "<group>"; };
|
||||
8384911F1807F38A00E7332D /* NowPlayingBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NowPlayingBarController.m; path = Window/NowPlayingBarController.m; sourceTree = "<group>"; };
|
||||
|
@ -961,6 +967,7 @@
|
|||
177EBF770B8BC2A70000BC8C /* ThirdParty */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
83790D4A1809F4980073CF51 /* SPMediaKeyTap */,
|
||||
173A439D0F3FD25500676A7B /* ToolTip */,
|
||||
178BAB920CD4E1B700B33D47 /* GCWindowMenu */,
|
||||
177EBF7D0B8BC2A70000BC8C /* AppleRemote */,
|
||||
|
@ -1450,6 +1457,25 @@
|
|||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
83790D4A1809F4980073CF51 /* SPMediaKeyTap */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
83790D4B1809F4980073CF51 /* SPInvocationGrabbing */,
|
||||
83790D4E1809F4980073CF51 /* SPMediaKeyTap.h */,
|
||||
83790D4F1809F4980073CF51 /* SPMediaKeyTap.m */,
|
||||
);
|
||||
path = SPMediaKeyTap;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
83790D4B1809F4980073CF51 /* SPInvocationGrabbing */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
83790D4C1809F4980073CF51 /* NSObject+SPInvocationGrabbing.h */,
|
||||
83790D4D1809F4980073CF51 /* NSObject+SPInvocationGrabbing.m */,
|
||||
);
|
||||
path = SPInvocationGrabbing;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8384917A1808585C00E7332D /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -2017,6 +2043,7 @@
|
|||
8E75757209F31D5A0080F1EE /* PlaylistController.m in Sources */,
|
||||
8E75757309F31D5A0080F1EE /* PlaylistEntry.m in Sources */,
|
||||
8E75757409F31D5A0080F1EE /* PlaylistView.m in Sources */,
|
||||
83790D511809F4980073CF51 /* SPMediaKeyTap.m in Sources */,
|
||||
8E75757509F31D5A0080F1EE /* Shuffle.m in Sources */,
|
||||
8E1296DB0A2BA9CE00443124 /* PlaylistHeaderView.m in Sources */,
|
||||
8E07AB790AAC930B00A4B32F /* PreferencesController.m in Sources */,
|
||||
|
@ -2032,6 +2059,7 @@
|
|||
1755E1F90BA0D2B600CA3560 /* PlaylistLoader.m in Sources */,
|
||||
8E9A30160BA792DC0091081B /* NSFileHandle+CreateFile.m in Sources */,
|
||||
179790E10C087AB7001D6996 /* OpenURLPanel.m in Sources */,
|
||||
83790D501809F4980073CF51 /* NSObject+SPInvocationGrabbing.m in Sources */,
|
||||
1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */,
|
||||
838491211807F38A00E7332D /* NowPlayingBarView.m in Sources */,
|
||||
178BAB990CD4E1B700B33D47 /* GCOneShotEffectTimer.m in Sources */,
|
||||
|
|
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 102 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.0 KiB |
|
@ -13,9 +13,14 @@
|
|||
|
||||
<style type="text/css">
|
||||
|
||||
body { font-family: "lucida grande"; font-size: 12px; }
|
||||
html, body, button, input, select, textarea
|
||||
{ font-family: sans-serif;
|
||||
font-size: 14px;
|
||||
color: #5f5c52}
|
||||
|
||||
h2 { margin-top: 30px; }
|
||||
h1, h2, h3, strong, b
|
||||
{ font-weight: 600;
|
||||
color: #423f37}
|
||||
|
||||
a:link, a:visited { color: black; }
|
||||
a:hover { text-decoration: none; }
|
||||
|
@ -29,7 +34,7 @@ td.icon { width: auto; }
|
|||
|
||||
<body>
|
||||
|
||||
<div id="header" style="clear: both;"><img src="images/logo.png" style="width: 200px; " />
|
||||
<div id="header" style="clear: both;"><img src="images/logo.png" style="width: 220px; " />
|
||||
|
||||
<ul style="float: right; list-style-type: none; margin-right: 20px;">
|
||||
<li><a href="http://cogx.org/">Cog homepage</a></li>
|
||||
|
@ -55,7 +60,7 @@ td.icon { width: auto; }
|
|||
<li>Shorten</li>
|
||||
<li>WavPack</li>
|
||||
<li>Apple Lossless</li>
|
||||
<li>Any codec supported by Mac OS X 10.4's Core Audio API</li>
|
||||
<li>Any codec supported by Mac OS X's Core Audio API</li>
|
||||
</ul>
|
||||
|
||||
<h2>Supported tags</h2>
|
||||
|
@ -70,33 +75,27 @@ td.icon { width: auto; }
|
|||
|
||||
<div class="buttons">
|
||||
|
||||
<h2>Buttons</h2>
|
||||
<h2>Controls</h2>
|
||||
|
||||
<table>
|
||||
|
||||
<tr>
|
||||
<td class="icon"><img src="images/play_gray.png"/></td>
|
||||
<td>Play/Pause</td>
|
||||
<td class="icon"><img src="images/playback.png"/></td>
|
||||
<td>Play/Pause/Previous/Next</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="icon"><img src="images/prev_gray.png"/></td>
|
||||
<td>Previous Song</td>
|
||||
<td class="icon"><img src="images/next_gray.png"/></td>
|
||||
<td>Next Song</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="icon"><img src="images/files_off.png"/></td>
|
||||
<td class="icon"><img src="images/files.png"/></td>
|
||||
<td>Show/hide<br>File Drawer</td>
|
||||
<td class="icon"><img src="images/repeat_off.png"/></td>
|
||||
<td class="icon"><img src="images/repeat.png"/></td>
|
||||
<td>Repeat on/off</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="icon"><img src="images/info_off.png"/></td>
|
||||
<td class="icon"><img src="images/info.png"/></td>
|
||||
<td>Show/hide<br>Info Drawer</td>
|
||||
<td class="icon"><img src="images/shuffle_off.png"/></td>
|
||||
<td class="icon"><img src="images/shuffle.png"/></td>
|
||||
<td>Shuffle on/off</td>
|
||||
</tr>
|
||||
|
||||
|
|
|
@ -523,7 +523,7 @@
|
|||
<key>CFBundleTypeIconFile</key>
|
||||
<string>ape.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Monkey's Audio File</string>
|
||||
<string>Monkey's Audio File</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
|
@ -875,7 +875,7 @@
|
|||
<key>CFBundleHelpBookFolder</key>
|
||||
<string>Help</string>
|
||||
<key>CFBundleHelpBookName</key>
|
||||
<string>Cog Help</string>
|
||||
<string>org.cogx.cog.help</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>icon_main</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
|
|