pool = [ [ NSAutoreleasePool alloc ] init ];
distantPast = [ NSDate distantPast ];
- if (is_active_console(vga_console))
- vga_update_display();
+ vga_hw_update();
+
do {
event = [ NSApp nextEventMatchingMask:NSAnyEventMask untilDate:distantPast
inMode: NSDefaultRunLoopMode dequeue:YES ];
case NSFlagsChanged:
{
int keycode = cocoa_keycode_to_qemu([event keyCode]);
- modifiers_state[keycode] = (modifiers_state[keycode] == 0) ? 1 : 0;
-
- if ( modifiers_state[keycode] ) { /* Keydown */
- if (keycode & 0x80)
- kbd_put_keycode(0xe0);
- kbd_put_keycode(keycode & 0x7f);
- } else { /* Keyup */
- if (keycode & 0x80)
- kbd_put_keycode(0xe0);
- kbd_put_keycode(keycode | 0x80);
- }
-
- /* emulate caps lock and num lock keyup */
- if ((keycode == 58) || (keycode == 69))
+
+ if (keycode)
{
- modifiers_state[keycode] = 0;
- if (keycode & 0x80)
- kbd_put_keycode(0xe0);
- kbd_put_keycode(keycode | 0x80);
+ if (keycode == 58 || keycode == 69) {
+ /* emulate caps lock and num lock keydown and keyup */
+ kbd_put_keycode(keycode);
+ kbd_put_keycode(keycode | 0x80);
+ } else if (is_graphic_console()) {
+ if (keycode & 0x80)
+ kbd_put_keycode(0xe0);
+ if (modifiers_state[keycode] == 0) {
+ /* keydown */
+ kbd_put_keycode(keycode & 0x7f);
+ modifiers_state[keycode] = 1;
+ } else {
+ /* keyup */
+ kbd_put_keycode(keycode | 0x80);
+ modifiers_state[keycode] = 0;
+ }
+ }
}
-
+
/* release Mouse grab when pressing ctrl+alt */
if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask))
+ {
[window setTitle: @"QEMU"];
[NSCursor unhide];
CGAssociateMouseAndMouseCursorPosition ( TRUE );
grab = 0;
+ }
}
break;
-
+
case NSKeyDown:
{
int keycode = cocoa_keycode_to_qemu([event keyCode]);
/* toggle Monitor */
case 0x02 ... 0x0a: /* '1' to '9' keys */
console_select(keycode - 0x02);
- if (is_active_console(vga_console)) {
- /* tell the vga console to redisplay itself */
- vga_invalidate_display();
break;
}
}
} else {
/* handle standard key events */
- if (is_active_console(vga_console)) {
+ if (is_graphic_console()) {
if (keycode & 0x80) //check bit for e0 in front
kbd_put_keycode(0xe0);
kbd_put_keycode(keycode & 0x7f); //remove e0 bit in front
case NSKeyUp:
{
int keycode = cocoa_keycode_to_qemu([event keyCode]);
- if (is_active_console(vga_console)) {
+ if (is_graphic_console()) {
if (keycode & 0x80)
kbd_put_keycode(0xe0);
kbd_put_keycode(keycode | 0x80); //add 128 to signal release of key