Beginnings of key handling for Apple2Mac

This commit is contained in:
Aaron Culliney 2014-10-12 16:44:49 -07:00
parent 6c63c49d09
commit a42a10eb86
2 changed files with 36 additions and 14 deletions

View File

@ -18,6 +18,8 @@
#define NIB_PROPERTIES @".nib 232960 bytes"
#define GZ_EXTENSION @"gz"
#define KEYCODE_CAPS_LOCK 0x39
@interface EmulatorWindowController ()
@property (nonatomic, assign) IBOutlet EmulatorGLView *view;
@ -312,22 +314,42 @@
self.fullscreenWindow = nil;
}
- (void)flagsChanged:(NSEvent*)event
{
static BOOL modified_caps_lock = NO;
if ([event keyCode] == KEYCODE_CAPS_LOCK)
{
NSUInteger flags = [event modifierFlags];
if (flags & NSAlphaShiftKeyMask)
{
modified_caps_lock = YES;
caps_lock = true;
}
else
{
caps_lock = false;
}
}
}
- (void)keyUp:(NSEvent *)event
{
unichar c = [[event charactersIgnoringModifiers] characterAtIndex:0];
c_keys_handle_input((int)c, 0, 1);
// Allow other character to be handled (or not and beep)
//[super keyDown:event];
}
- (void)keyDown:(NSEvent *)event
{
unichar c = [[event charactersIgnoringModifiers] characterAtIndex:0];
unichar c = [[event charactersIgnoringModifiers] characterAtIndex:0];
switch (c)
{
case 27:
NSLog(@"key ESC");
return;
case 'f':
NSLog(@"key 'f'");
return;
}
c_keys_handle_input((int)c, 1, 1);
// Allow other character to be handled (or not and beep)
[super keyDown:event];
// Allow other character to be handled (or not and beep)
//[super keyDown:event];
}
@end

View File

@ -32,7 +32,7 @@ extern int raw_js_y;
static int next_key = -1;
static int last_scancode = -1;
bool caps_lock = false; /* is enabled */
bool caps_lock = true; // default enabled because so much breaks otherwise
/* ----------------------------------------------------
//e Keymap. Mapping scancodes to Apple //e US Keyboard
@ -171,7 +171,6 @@ void c_keys_handle_input(int scancode, int pressed, int is_cooked)
{
int *keymap = NULL;
assert(scancode < 0x80);
if (is_cooked) {
last_scancode = -1;
if (!pressed) {
@ -184,6 +183,7 @@ void c_keys_handle_input(int scancode, int pressed, int is_cooked)
}
next_key = scancode;
} else if (scancode >= 0) {
assert(scancode < 0x80);
last_scancode = scancode;
if ((key_pressed[ SCODE_L_SHIFT ] || key_pressed[ SCODE_R_SHIFT ]) &&