Misc tweaks

* intercept application terminate and eject disks
    * closing last window terminates app
    * send scancodes for control keys
This commit is contained in:
Aaron Culliney 2014-10-18 12:50:46 -07:00
parent 2f884cf129
commit 21660fdcb9
2 changed files with 25 additions and 7 deletions

View File

@ -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

View File

@ -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;
}