Allow OSX to quit Dolphin cleanly in NoWX build with command+Q. Not sure how to let them do it via close button in the Window

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4866 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2010-01-17 08:47:35 +00:00
parent 4927e5607e
commit 936664314f
5 changed files with 40 additions and 15 deletions

View File

@ -28,6 +28,6 @@ if acenv['HAVE_PULSEAUDIO']:
if sys.platform == 'darwin':
files += [ 'CoreAudioSoundStream.cpp' ]
acenv['FRAMEWORKS'] = [ 'CoreAudio' ]
acenv['FRAMEWORKS'] = [ 'CoreAudio', 'AudioUnit' ]
acenv.StaticLibrary(env['local_libs'] + 'audiocommon', files)

View File

@ -186,7 +186,11 @@ int main(int argc, char *argv[])
while(true)
{
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
cocoaSendEvent(event);
if(cocoaSendEvent(event))
{
PowerPC::Shutdown();
break;
}
}

View File

@ -5,7 +5,7 @@ extern "C"
{
#endif
void cocoaSendEvent(NSEvent *event);
bool cocoaSendEvent(NSEvent *event);
void cocoaCreateApp();

View File

@ -46,25 +46,44 @@ void cocoaCreateApp()
}
void cocoaKeyCode(NSEvent *event)
bool cocoaKeyCode(NSEvent *event)
{
static bool CMDDown = false, QDown = false;
bool Return = false;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSConnection *connec = [NSConnection defaultConnection];
[connec setRootObject: event];
if ([connec registerName: @"DolphinCocoaEvent"] == NO)
{
//printf("error creating nsconnection\n");
}
[connec setRootObject: event];
if ([connec registerName: @"DolphinCocoaEvent"] == NO)
{
//printf("error creating nsconnection\n");
}
if( [event type] != NSFlagsChanged )
{
NSString *NewString = [event characters];
char *Keys = [NewString UTF8String];
if( Keys[0] == 'q' && [event type] == NSKeyDown )
QDown = true;
if( Keys[0] == 'q' && [event type] == NSKeyUp )
QDown = false;
}
else
if( [event modifierFlags] & NSCommandKeyMask )
CMDDown = true;
else
CMDDown = false;
if( QDown && CMDDown )
Return = true;
[pool release];
return Return;
}
void cocoaSendEvent(NSEvent *event)
bool cocoaSendEvent(NSEvent *event)
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
@ -73,7 +92,8 @@ void cocoaSendEvent(NSEvent *event)
switch ([event type]) {
case NSKeyDown:
case NSKeyUp:
cocoaKeyCode(event);
case NSFlagsChanged: // For Command
return cocoaKeyCode(event);
break;
default:
[NSApp sendEvent:event];
@ -83,6 +103,7 @@ void cocoaSendEvent(NSEvent *event)
[pool release];
return false;
}

View File

@ -43,6 +43,6 @@ dspenv.Append(
LIBS = [ 'common', 'audiocommon' ],
)
if sys.platform == 'darwin':
dspenv['FRAMEWORKS'] = [ 'CoreAudio', 'CoreServices' ]
dspenv['FRAMEWORKS'] = [ 'CoreAudio', 'CoreServices', 'AudioUnit' ]
dspenv.SharedLibrary(env['plugin_dir']+name, files)