From 21660fdcb9e2277a518c5270f9220f28fe00d2e5 Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Sat, 18 Oct 2014 12:50:46 -0700 Subject: [PATCH] Misc tweaks * intercept application terminate and eject disks * closing last window terminates app * send scancodes for control keys --- Apple2Mac/Apple2Mac/Classes/OSX/EmulatorGLView.m | 16 ++++++++++++++++ .../Classes/OSX/EmulatorWindowController.m | 16 +++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorGLView.m b/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorGLView.m index 65285a68..89f67bb3 100644 --- a/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorGLView.m +++ b/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorGLView.m @@ -299,4 +299,20 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt [super dealloc]; } + +#pragma mark - +#pragma mark Application Delegate methods + +- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)application +{ + return YES; +} + +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)application +{ + c_eject_6(0); + c_eject_6(1); + return NSTerminateNow; +} + @end diff --git a/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorWindowController.m b/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorWindowController.m index f10f7540..b29ebbfd 100644 --- a/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorWindowController.m +++ b/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorWindowController.m @@ -183,8 +183,6 @@ default: break; } - - NSLog(@"keyCode : %04x", [event keyCode]); } - (void)_handleKeyEvent:(NSEvent *)event pressed:(BOOL)pressed @@ -192,14 +190,11 @@ unichar c = [[event charactersIgnoringModifiers] characterAtIndex:0]; int scode = (int)c; - NSLog(@"key = %08x", c); - int cooked = 0; switch (scode) { case 0x1b: scode = SCODE_ESC; - NSLog(@"ESC..."); break; case NSUpArrowFunctionKey: @@ -209,7 +204,6 @@ scode = SCODE_D; break; case NSLeftArrowFunctionKey: - NSLog(@"LEFT ARROW"); scode = SCODE_L; break; case NSRightArrowFunctionKey: @@ -284,7 +278,15 @@ break; default: - cooked = 1; + if ([event modifierFlags] & NSControlKeyMask) + { + scode = c_keys_ascii_to_scancode(scode); + cooked = 0; + } + else + { + cooked = 1; + } break; }