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
+5 -1
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;
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ extern "C"
{
#endif
void cocoaSendEvent(NSEvent *event);
bool cocoaSendEvent(NSEvent *event);
void cocoaCreateApp();
+32 -11
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;
}