Changeset 93
- Timestamp:
- 09/15/07 01:06:09 (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 removed
- 16 modified
-
build_i386.sh (modified) (2 diffs)
-
build_ppc.sh (modified) (1 diff)
-
changelog.txt (modified) (1 diff)
-
host-cocoa/Resources/q_icon.icns (modified) (previous)
-
host-cocoa/cocoaQemu.m (modified) (20 diffs)
-
host-cocoa/cocoaQemuOpenGLView.h (modified) (3 diffs)
-
host-cocoa/cocoaQemuOpenGLView.m (modified) (4 diffs)
-
host-cocoa/cocoaQemuQuartzView.h (modified) (3 diffs)
-
host-cocoa/cocoaQemuQuartzView.m (modified) (6 diffs)
-
host-cocoa/cocoaQemuWindow.m (modified) (8 diffs)
-
patches/q_vga.c_02.diff (deleted)
-
patches/qemu-0.9.0-big_endian_display4.diff (added)
-
qcontrol/QControlTableView.m (modified) (5 diffs)
-
qcontrol/Resources/q_icon.icns (modified) (previous)
-
qcontrol/cocoaControlController.m (modified) (10 diffs)
-
qcontrol/cocoaControlDOServer.h (modified) (5 diffs)
-
qcontrol/cocoaControlDOServer.m (modified) (8 diffs)
-
qcontrol/cocoaControlEditPC.m (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/build_i386.sh
r86 r93 35 35 patch -p0 -u < ../../q/patches/q_host-cocoa_02.diff 36 36 37 #qemu hotfixfor qcow237 #qemu cvs backport for qcow2 38 38 patch -p0 -u < ../../q/patches/qemu-0.9.0-qcow2.diff 39 40 #qemu cvs backport rgb support for bigendian 41 patch -p1 -u < ../../q/patches/qemu-0.9.0-big_endian_display4.diff 39 42 40 43 #qemu gcc4 patches … … 50 53 51 54 patch -p1 -u < ../../q/patches/qemu-0.8.0-osx-bugfix.patch 52 53 #qemu rgb support for intel54 cd hw55 patch -p0 -u < ../../../q/patches/q_vga.c_02.diff56 cd ..57 55 58 56 #qemu add 2nd Bootdevice -
trunk/build_ppc.sh
r86 r93 37 37 patch -p0 -u < ../../q/patches/q_host-cocoa_02.diff 38 38 39 #qemu hotfixfor qcow239 #qemu cvs backport for qcow2 40 40 patch -p0 -u < ../../q/patches/qemu-0.9.0-qcow2.diff 41 41 42 #qemu rgb support for intel 43 cd hw 44 #patch -p0 -u < ../../../q/patches/q_vga.c_02.diff 45 cd .. 42 #qemu cvs backport rgb support for bigendian 43 patch -p1 -u < ../../q/patches/qemu-0.9.0-big_endian_display4.diff 46 44 47 45 #qemu add 2nd Bootdevice -
trunk/changelog.txt
r90 r93 1 Q-0.9.0d90 1 Q-0.9.0d93 2 [fix] remove crashed/stray guests from doServer (#15) 3 [fix] Q Control: StopPC Icon is a forcequit if task is not responding or doServer is not responding (#15) 4 [fix] Fullscreen: alt-tabing back to Q brings you back to FS Guest (#32) 5 [fix] Fullscreen: switching animation always vertical 6 [fix] Fullscreen: honor aspect ratio, only factors of 1/1.25/1.5/1.75/2.0/3.0/4.0... (#18) 7 [fix] doServer: added missing dealloc 8 [fix] quartz: panther compiling 9 [fix] quartz: small drawspeed improvements 10 [fix] backport bgr support for bigendians (andreasf) (#14) 11 [new] Q Control: EditPC can be used (read only) when guest is running (#23) 12 [new] Q Control: commandline as tooltips of guests (#23) 13 [new] Q icon 14 15 Q-0.9.0d92 2 16 [fix] ARM emulation on Q GUI breaks (Chocobo) (#17) 3 17 [fix] Editing a PC inserts incorrect spaces into argument (andreasf) (#13) 4 18 [fix] Starting guest can display screenshot of previous session (andreasf) (#28) 5 19 [fix] Edit PC window title inconsistent (andreasf) (#26) 20 21 Q-0.9.0d91 22 branch Q-0.9.0a89 6 23 7 24 Q-0.9.0d89 -
trunk/host-cocoa/cocoaQemu.m
r90 r93 3 3 * 4 4 * Copyright (c) 2005 - 2007 Pierre d'Herbemont 5 * Mike Kronenberg6 * many code/inspiration from SDL 1.2 code (LGPL)5 * Mike Kronenberg 6 * many code/inspiration from SDL 1.2 code (LGPL) 7 7 * 8 8 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 49 49 /* 50 50 ------------------------------------------------------ 51 Headers52 51 Headers 52 53 53 ------------------------------------------------------ 54 54 */ 55 55 /* 56 56 ------------------------------------------------------ 57 QemuCocoa Video Driver57 QemuCocoa Video Driver 58 58 ------------------------------------------------------ 59 59 */ … … 66 66 /* 67 67 ------------------------------------------------------ 68 QemuCocoa CD-ROM Driver68 QemuCocoa CD-ROM Driver 69 69 ------------------------------------------------------ 70 70 */ … … 76 76 /* 77 77 ------------------------------------------------------ 78 Implementations79 78 Implementations 79 80 80 ------------------------------------------------------ 81 81 */ 82 82 /* 83 83 ------------------------------------------------------ 84 cocoaQemu84 cocoaQemu 85 85 ------------------------------------------------------ 86 86 */ … … 89 89 -(id) init 90 90 { 91 // NSLog(@"cocoaQemu: init");92 93 if ((self = [super init])) {94 /* set allowed filetypes */95 fileTypes = [[NSArray arrayWithObjects:@"qcow2", @"qcow", @"raw", @"cow", @"vmdk", @"cloop", @"img", @"iso", @"dsk", @"dmg", @"cdr", @"toast", @"flp", @"fs", nil] retain];96 97 /* pc */98 pcName = [@"" retain];99 pcWindowName = [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"] retain];100 pcPath = [[@"~/Documents/QEMU/temp.qvm" stringByExpandingTildeInPath] retain];101 pcTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector( liveThumbnail ) userInfo:nil repeats:YES];102 [self liveThumbnail];103 pcDialogs = YES;104 pc = self;105 106 /* set openGL as default */107 pcOpenGLView = true;108 109 /* setup progressWindow */110 progressWindow = [[cocoaQemuProgressWindow alloc] init];111 112 /* setup Q distributed object Client */113 qdoserver = [[NSConnection rootProxyForConnectionWithRegisteredName:@"qdoserver" host:nil] retain];114 [qdoserver setProtocolForProxy:@protocol(cocoaControlDOServerProto)];115 116 /* Pasteboard *//*117 bios_dir = [[NSString stringWithFormat:@"%@/qemu", [[NSBundle mainBundle] resourcePath]] cString];118 kbd_layout = init_keyboard_layout("de-ch");119 */ 120 return self;121 }122 return nil;91 // NSLog(@"cocoaQemu: init"); 92 93 if ((self = [super init])) { 94 /* set allowed filetypes */ 95 fileTypes = [[NSArray arrayWithObjects:@"qcow2", @"qcow", @"raw", @"cow", @"vmdk", @"cloop", @"img", @"iso", @"dsk", @"dmg", @"cdr", @"toast", @"flp", @"fs", nil] retain]; 96 97 /* pc */ 98 pcName = [@"" retain]; 99 pcWindowName = [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"] retain]; 100 pcPath = [[@"~/Documents/QEMU/temp.qvm" stringByExpandingTildeInPath] retain]; 101 pcTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector( liveThumbnail ) userInfo:nil repeats:YES]; 102 [self liveThumbnail]; 103 pcDialogs = YES; 104 pc = self; 105 106 /* set openGL as default */ 107 pcOpenGLView = true; 108 109 /* setup progressWindow */ 110 progressWindow = [[cocoaQemuProgressWindow alloc] init]; 111 112 /* setup Q distributed object Client */ 113 qdoserver = [[NSConnection rootProxyForConnectionWithRegisteredName:@"qdoserver" host:nil] retain]; 114 [qdoserver setProtocolForProxy:@protocol(cocoaControlDOServerProto)]; 115 116 /* Pasteboard *//* 117 bios_dir = [[NSString stringWithFormat:@"%@/qemu", [[NSBundle mainBundle] resourcePath]] cString]; 118 kbd_layout = init_keyboard_layout("de-ch"); 119 */ 120 return self; 121 } 122 return nil; 123 123 } 124 124 125 125 - (void) dealloc 126 126 { 127 // NSLog(@"cocoaQemu: dealloc");128 129 [super dealloc];127 // NSLog(@"cocoaQemu: dealloc"); 128 129 [super dealloc]; 130 130 } 131 131 … … 133 133 - (BOOL) guestOrderFrontRegardless 134 134 { 135 // NSLog(@"cocoaQemu: guestOrderFrontRegardless");136 137 [pcWindow orderFrontRegardless];138 return true;135 // NSLog(@"cocoaQemu: guestOrderFrontRegardless"); 136 137 [pcWindow orderFrontRegardless]; 138 return true; 139 139 } 140 140 141 141 - (int) guestWindowLevel 142 142 { 143 // NSLog(@"cocoaQemu: guestWindowLevel");144 145 return [pcWindow level];143 // NSLog(@"cocoaQemu: guestWindowLevel"); 144 145 return [pcWindow level]; 146 146 } 147 147 148 148 - (int) guestWindowNumber 149 149 { 150 // NSLog(@"cocoaQemu: guestWindowNumber");151 152 return [pcWindow windowNumber];150 // NSLog(@"cocoaQemu: guestWindowNumber"); 151 152 return [pcWindow windowNumber]; 153 153 } 154 154 155 155 - (BOOL) guestOrderWindow:(NSWindowOrderingMode)place relativeTo:(int)otherWindowNumber 156 156 { 157 // NSLog(@"cocoaQemu: guestOrderWindow");158 159 [pcWindow orderWindow:place relativeTo:otherWindowNumber];160 return true;157 // NSLog(@"cocoaQemu: guestOrderWindow"); 158 159 [pcWindow orderWindow:place relativeTo:otherWindowNumber]; 160 return true; 161 161 } 162 162 163 163 - (BOOL) guestHide; 164 164 { 165 // NSLog(@"cocoaQemu: guestHide");166 167 [NSApp hide:self];168 return true;165 // NSLog(@"cocoaQemu: guestHide"); 166 167 [NSApp hide:self]; 168 return true; 169 169 } 170 170 171 171 - (BOOL) guestUnhide; 172 172 { 173 // NSLog(@"cocoaQemu: guestUnhide");174 175 [NSApp unhide:self];176 return true;173 // NSLog(@"cocoaQemu: guestUnhide"); 174 175 [NSApp unhide:self]; 176 return true; 177 177 } 178 178 179 179 - (BOOL) guestPause; 180 180 { 181 // NSLog(@"cocoaQemu: guestPause");182 183 [self pausePlay:self];184 return true;181 // NSLog(@"cocoaQemu: guestPause"); 182 183 [self pausePlay:self]; 184 return true; 185 185 } 186 186 187 187 - (BOOL) guestStop; 188 188 { 189 // NSLog(@"cocoaQemu: guestStop");190 191 [self shutdownPC];192 return true;189 // NSLog(@"cocoaQemu: guestStop"); 190 191 [self shutdownPC]; 192 return true; 193 193 } 194 194 … … 196 196 - (NSString *) pcName 197 197 { 198 // NSLog(@"cocoaQemu: pcName");199 200 return pcName;198 // NSLog(@"cocoaQemu: pcName"); 199 200 return pcName; 201 201 } 202 202 203 203 - (NSString *) pcWindowName 204 204 { 205 // NSLog(@"cocoaQemu: pcWindowName");206 207 return pcWindowName;205 // NSLog(@"cocoaQemu: pcWindowName"); 206 207 return pcWindowName; 208 208 } 209 209 210 210 -(NSString *) smbPath 211 211 { 212 // NSLog(@"cocoaQemu: smbPath");213 214 return smbPath;212 // NSLog(@"cocoaQemu: smbPath"); 213 214 return smbPath; 215 215 } 216 216 217 217 - (id) qdoserver 218 218 { 219 // NSLog(@"cocoaQemu: qdoserver");219 // NSLog(@"cocoaQemu: qdoserver"); 220 220 221 221 return qdoserver; … … 224 224 - (BOOL) fullscreen 225 225 { 226 // NSLog(@"cocoaQemu: fullscreen");227 228 return fullscreen;226 // NSLog(@"cocoaQemu: fullscreen"); 227 228 return fullscreen; 229 229 } 230 230 231 231 - (void) setFullscreen:(BOOL)val 232 232 { 233 // NSLog(@"cocoaQemu: setFullscreen");234 235 fullscreen = val;233 // NSLog(@"cocoaQemu: setFullscreen"); 234 235 fullscreen = val; 236 236 } 237 237 … … 259 259 - (BOOL) grab 260 260 { 261 // NSLog(@"cocoaQemu: grab");262 263 return grab;261 // NSLog(@"cocoaQemu: grab"); 262 263 return grab; 264 264 } 265 265 266 266 - (BOOL) absolute_enabled 267 267 { 268 // NSLog(@"cocoaQemu: absolute_enabled");269 270 return absolute_enabled;268 // NSLog(@"cocoaQemu: absolute_enabled"); 269 270 return absolute_enabled; 271 271 } 272 272 273 273 - (BOOL) tablet_enabled 274 274 { 275 // NSLog(@"cocoaQemu: tablet_enabled");276 277 return tablet_enabled;275 // NSLog(@"cocoaQemu: tablet_enabled"); 276 277 return tablet_enabled; 278 278 } 279 279 280 280 - (BOOL) wMStopWhenInactive 281 281 { 282 // NSLog(@"cocoaQemu: wMStopWhenInactive");283 284 return WMStopWhenInactive;282 // NSLog(@"cocoaQemu: wMStopWhenInactive"); 283 284 return WMStopWhenInactive; 285 285 } 286 286 287 287 - (BOOL) wMPaused 288 288 { 289 // NSLog(@"cocoaQemu: wMPaused");290 291 return vm_running;289 // NSLog(@"cocoaQemu: wMPaused"); 290 291 return vm_running; 292 292 } 293 293 294 294 - (BOOL) wMPausedByUser 295 295 { 296 // NSLog(@"cocoaQemu: wMPausedByUser");297 298 return wMPausedByUser;296 // NSLog(@"cocoaQemu: wMPausedByUser"); 297 298 return wMPausedByUser; 299 299 } 300 300 301 301 - (void) setGrab:(BOOL)val 302 302 { 303 // NSLog(@"cocoaQemu: setGrab");304 305 grab = val;303 // NSLog(@"cocoaQemu: setGrab"); 304 305 grab = val; 306 306 } 307 307 308 308 - (void) setAbsolute_enabled:(BOOL)val 309 309 { 310 // NSLog(@"cocoaQemu: setAbsolute_enabled");311 312 absolute_enabled = val;310 // NSLog(@"cocoaQemu: setAbsolute_enabled"); 311 312 absolute_enabled = val; 313 313 } 314 314 315 315 - (void) setTablet_enabled:(BOOL)val 316 316 { 317 // NSLog(@"cocoaQemu: setTablet_enabled");318 319 tablet_enabled = val;317 // NSLog(@"cocoaQemu: setTablet_enabled"); 318 319 tablet_enabled = val; 320 320 } 321 321 322 322 - (void) grabMouse 323 323 { 324 // NSLog(@"cocoaQemu: grabMouse");325 326 if (!grab) {327 grab = YES;328 [pcWindow setTitle: [NSString stringWithFormat: NSLocalizedStringFromTable(@"grabMouse:title", @"Localizable", @"cocoaQemu"), pcWindowName, pcName]];329 [NSCursor hide];330 CGAssociateMouseAndMouseCursorPosition ( FALSE );331 }324 // NSLog(@"cocoaQemu: grabMouse"); 325 326 if (!grab) { 327 grab = YES; 328 [pcWindow setTitle: [NSString stringWithFormat: NSLocalizedStringFromTable(@"grabMouse:title", @"Localizable", @"cocoaQemu"), pcWindowName, pcName]]; 329 [NSCursor hide]; 330 CGAssociateMouseAndMouseCursorPosition ( FALSE ); 331 } 332 332 } 333 333 334 334 - (void) ungrabMouse 335 335 { 336 // NSLog(@"cocoaQemu: ungrabMouse");337 338 if (grab) {339 grab = NO;340 [pcWindow setTitle: [NSString stringWithFormat:@"%@ - %@", pcWindowName, pcName]];341 [NSCursor unhide];342 CGAssociateMouseAndMouseCursorPosition ( TRUE );343 }336 // NSLog(@"cocoaQemu: ungrabMouse"); 337 338 if (grab) { 339 grab = NO; 340 [pcWindow setTitle: [NSString stringWithFormat:@"%@ - %@", pcWindowName, pcName]]; 341 [NSCursor unhide]; 342 CGAssociateMouseAndMouseCursorPosition ( TRUE ); 343 } 344 344 } 345 345 346 346 - (int) modifierAtIndex:(int)index 347 347 { 348 // NSLog(@"cocoaQemu: modifierAtIndex");349 350 return modifiers_state[index];348 // NSLog(@"cocoaQemu: modifierAtIndex"); 349 350 return modifiers_state[index]; 351 351 } 352 352 353 353 - (void) setModifierAtIndex:(int)index to:(int)value 354 354 { 355 // NSLog(@"cocoaQemu: setModifierAtIndex");356 357 modifiers_state[index] = value;355 // NSLog(@"cocoaQemu: setModifierAtIndex"); 356 357 modifiers_state[index] = value; 358 358 } 359 359 360 360 - (void) resetModifiers 361 361 { 362 // NSLog(@"cocoaQemu: resetModifiers");363 364 int i;365 for(i = 0; i < 256; i++) {366 if (modifiers_state[i]) {367 if (i & 0x80)368 kbd_put_keycode(0xe0);369 kbd_put_keycode(i | 0x80);370 modifiers_state[i] = 0;371 }372 }362 // NSLog(@"cocoaQemu: resetModifiers"); 363 364 int i; 365 for(i = 0; i < 256; i++) { 366 if (modifiers_state[i]) { 367 if (i & 0x80) 368 kbd_put_keycode(0xe0); 369 kbd_put_keycode(i | 0x80); 370 modifiers_state[i] = 0; 371 } 372 } 373 373 } 374 374 375 375 - (id) pcWindow 376 376 { 377 // NSLog(@"cocoaQemu: pcWindow");378 379 return pcWindow;377 // NSLog(@"cocoaQemu: pcWindow"); 378 379 return pcWindow; 380 380 } 381 381 382 382 - (id) contentView 383 383 { 384 // NSLog(@"cocoaQemu: contentView");385 386 return contentView;384 // NSLog(@"cocoaQemu: contentView"); 385 386 return contentView; 387 387 } 388 388 389 389 - (void) liveThumbnail 390 390 { 391 // NSLog(@"cocoaQemu: liveThumbnail <%@>", pcPath);392 393 if (![pcName isEqual:@""]) {394 /* create liveThumbnail */395 NSBitmapImageRep *bitmapImageRep = [NSBitmapImageRep imageRepWithData: [[contentView screenshot:NSMakeSize(100,75)] TIFFRepresentation]];396 NSData *data = [bitmapImageRep representationUsingType: NSPNGFileType properties: nil];397 [data writeToFile: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath] atomically: YES];398 }391 // NSLog(@"cocoaQemu: liveThumbnail <%@>", pcPath); 392 393 if (![pcName isEqual:@""]) { 394 /* create liveThumbnail */ 395 NSBitmapImageRep *bitmapImageRep = [NSBitmapImageRep imageRepWithData: [[contentView screenshot:NSMakeSize(100,75)] TIFFRepresentation]]; 396 NSData *data = [bitmapImageRep representationUsingType: NSPNGFileType properties: nil]; 397 [data writeToFile: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath] atomically: YES]; 398 } 399 399 } 400 400 401 401 - (void) stopVM 402 402 { 403 // NSLog(@"cocoaQemu: stopVM");404 405 if (vm_running)406 vm_stop(0);407 [pcWindow display];403 // NSLog(@"cocoaQemu: stopVM"); 404 405 if (vm_running) 406 vm_stop(0); 407 [pcWindow display]; 408 408 } 409 409 410 410 - (void) startVM 411 411 { 412 // NSLog(@"cocoaQemu: startVM");413 414 if (!vm_running)415 vm_start();416 [pcWindow display];412 // NSLog(@"cocoaQemu: startVM"); 413 414 if (!vm_running) 415 vm_start(); 416 [pcWindow display]; 417 417 } 418 418 419 419 - (void) saveVM 420 420 { 421 // NSLog(@"cocoaQemu: saveVM"); 422 423 /* show progressWindow */ 424 [progressWindow showProgressWindow:pcWindow text: NSLocalizedStringFromTable(@"saveVM:text", @"Localizable", @"cocoaQemu") name:pcName]; 425 426 /* stop VM */ 427 vm_stop(0); 428 429 /* generate Preview */ 430 NSBitmapImageRep *bitmapImageRep = [NSBitmapImageRep imageRepWithData: [[contentView screenshot:NSMakeSize(100,75)] TIFFRepresentation]]; 431 NSData *data = [bitmapImageRep representationUsingType: NSPNGFileType properties: nil]; 432 [data writeToFile: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath] atomically: YES]; 433 434 /* save VM */ 435 // qemu_savevm( [[NSString stringWithFormat: @"%@/saved.vm", pcPath] cString]); 436 do_savevm([@"kju" cString]); 437 438 /* hide progressWindow */ 439 [progressWindow hideProgressWindow]; 421 // NSLog(@"cocoaQemu: saveVM"); 422 423 /* show progressWindow */ 424 [progressWindow showProgressWindow:pcWindow text: NSLocalizedStringFromTable(@"saveVM:text", @"Localizable", @"cocoaQemu") name:pcName]; 425 426 /* stop VM */ 427 vm_stop(0); 428 429 /* generate Preview */ 430 NSBitmapImageRep *bitmapImageRep = [NSBitmapImageRep imageRepWithData: [[contentView screenshot:NSMakeSize(100,75)] TIFFRepresentation]]; 431 NSData *data = [bitmapImageRep representationUsingType: NSPNGFileType properties: nil]; 432 [data writeToFile: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath] atomically: YES]; 433 434 /* save VM */ 435 do_savevm([@"kju" cString]); 436 437 /* hide progressWindow */ 438 [progressWindow hideProgressWindow]; 440 439 } 441 440 442 441 - (void) closeProgressWindow 443 442 { 444 // NSLog(@"cocoaQemu: closeProgressWindow");445 446 if (vm_running) {447 [progressWindowTimer invalidate];448 [progressWindow hideProgressWindow];449 450 }443 // NSLog(@"cocoaQemu: closeProgressWindow"); 444 445 if (vm_running) { 446 [progressWindowTimer invalidate]; 447 [progressWindow hideProgressWindow]; 448 449 } 451 450 } 452 451 … … 454 453 - (void) startPCWithArgs:(id)arguments 455 454 { 456 // NSLog(@"cocoaQemu: startPCWithArgs"); 457 458 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 459 460 /* overrun defaults for bios_dir, so we can run qemu everywhere */ 461 bios_dir = [[NSString stringWithFormat:@"%@/qemu", [[NSBundle mainBundle] resourcePath]] cString]; 462 463 /* setup QEMU Window */ 464 pcWindow = [[cocoaQemuWindow alloc] initWithSender:self]; 465 if ([arguments containsObject:@"-cocoaquickdraw"]) { 466 contentView = [[[cocoaQemuQuickDrawView alloc] initWithFrame:NSMakeRect(0,0,640,400) sender:self] autorelease]; 467 } else if ([arguments containsObject:@"-cocoaquartz"]) { 468 contentView = [[[cocoaQemuQuartzView alloc] initWithFrame:NSMakeRect(0,0,640,400) sender:self] autorelease]; 469 } else { 470 contentView = [[[cocoaQemuOpenGLView alloc] initWithFrame:NSMakeRect(0,0,640,400) sender:self] autorelease]; 471 } 472 473 [contentView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; 474 475 /* scrollview */ 476 /* NSScrollView * scrollView = [[NSScrollView alloc] init]; 477 [scrollView setHasVerticalScroller:TRUE]; 478 [scrollView setHasHorizontalScroller:TRUE]; 479 [scrollView setAutohidesScrollers:FALSE]; 480 [scrollView setScrollsDynamically:TRUE]; // 481 [scrollView setBorderType:NSLineBorder]; 482 [scrollView setDocumentView:contentView]; 483 [pcWindow setContentView:scrollView];*/ 484 485 486 [pcWindow setContentView:contentView]; 487 [pcWindow setMyContentView:contentView]; 488 489 /* filter cocoa arguments */ 490 int i; 491 int i2 = 0; 492 char **argv2 = (char**)malloc( sizeof(char*)*[arguments count] ); 493 494 for (i = 0; i < [arguments count]; i++) { 495 // NSLog(@"Arguments: %@", [arguments objectAtIndex:i]); 496 497 if ( [[arguments objectAtIndex:i] isEqual:@"-cocoaquickdraw"] ) { 498 pcOpenGLView = false; 499 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoaquartz"] ) { 500 pcOpenGLView = false; 501 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoaname"] ) { 502 i++; 503 pcName = [arguments objectAtIndex:i]; 504 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoawindowname"] ) { 505 i++; 506 pcWindowName = [arguments objectAtIndex:i]; 507 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoapath"] ) { 508 i++; 509 pcPath = [arguments objectAtIndex:i]; 510 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoalivethumbnail"] ) { 511 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoanodialogs"] ) { 512 pcDialogs = NO; 513 NSLog(@"pcDialogs: %d\n", pcDialogs); 514 } else if ( [[arguments objectAtIndex:i] isEqual:@"-wmstopwheninactive"] ) { 515 WMStopWhenInactive = true; 516 } else if ( [[arguments objectAtIndex:i] isEqual:@"-full-screen"] ) { 517 fullscreen = [contentView toggleFullScreen]; 518 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cdrom"] ) { 519 if ( [[arguments objectAtIndex:i+1] isEqual:@"/dev/cdrom"] ) { 520 kern_return_t kernResult; 521 io_iterator_t mediaIterator; 522 char bsdPath[MAXPATHLEN]; 523 524 kernResult = FindEjectableCDMedia( &mediaIterator ); 525 kernResult = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) ); 526 527 if ( bsdPath[0] == '\0' ) { 528 i++; 529 } else { 530 asprintf(&argv2[i2], "%s", [[arguments objectAtIndex:i] cString]); 531 i2++; 532 i++; 533 asprintf(&argv2[i2], "%s", [[arguments objectAtIndex:i] cString]); 534 i2++; 535 } 536 537 if ( mediaIterator ) 538 IOObjectRelease( mediaIterator ); 539 } else { 540 asprintf(&argv2[i2], "%s", [[arguments objectAtIndex:i] cString]); 541 i2++; 542 i++; 543 asprintf(&argv2[i2], "%s", [[arguments objectAtIndex:i] cString]); 544 i2++; 545 } 546 } else { 547 if ([[arguments objectAtIndex:i] isEqual:@"-smb"]) 548 smbPath = [[NSString alloc] initWithString:[arguments objectAtIndex:i + 1]]; 549 550 if ([[arguments objectAtIndex:i] isEqual:@"-hda"]) 455 // NSLog(@"cocoaQemu: startPCWithArgs"); 456 457 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 458 459 /* overrun defaults for bios_dir, so we can run qemu everywhere */ 460 bios_dir = [[NSString stringWithFormat:@"%@/qemu", [[NSBundle mainBundle] resourcePath]] cString]; 461 462 /* setup QEMU Window */ 463 pcWindow = [[cocoaQemuWindow alloc] initWithSender:self]; 464 if ([arguments containsObject:@"-cocoaquickdraw"]) { 465 contentView = [[[cocoaQemuQuickDrawView alloc] initWithFrame:NSMakeRect(0,0,640,400) sender:self] autorelease]; 466 } else if ([arguments containsObject:@"-cocoaquartz"]) { 467 contentView = [[[cocoaQemuQuartzView alloc] initWithFrame:NSMakeRect(0,0,640,400) sender:self] autorelease]; 468 } else { 469 contentView = [[[cocoaQemuOpenGLView alloc] initWithFrame:NSMakeRect(0,0,640,400) sender:self] autorelease]; 470 } 471 [contentView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; 472 473 /* scrollview */ 474 /* NSScrollView * scrollView = [[NSScrollView alloc] init]; 475 [scrollView setHasVerticalScroller:TRUE]; 476 [scrollView setHasHorizontalScroller:TRUE]; 477 [scrollView setAutohidesScrollers:FALSE]; 478 [scrollView setScrollsDynamically:TRUE]; // 479 [scrollView setBorderType:NSLineBorder]; 480 [scrollView setDocumentView:contentView]; 481 [pcWindow setContentView:scrollView];*/ 482 483 484 [pcWindow setContentView:contentView]; 485 [pcWindow setMyContentView:contentView]; 486 487 /* filter cocoa arguments */ 488 int i; 489 int i2 = 0; 490 char **argv2 = (char**)malloc( sizeof(char*)*[arguments count] ); 491 492 for (i = 0; i < [arguments count]; i++) { 493 // NSLog(@"Arguments: %@", [arguments objectAtIndex:i]); 494 495 if ( [[arguments objectAtIndex:i] isEqual:@"-cocoaquickdraw"] ) { 496 pcOpenGLView = false; 497 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoaquartz"] ) { 498 pcOpenGLView = false; 499 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoaname"] ) { 500 i++; 501 pcName = [arguments objectAtIndex:i]; 502 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoawindowname"] ) { 503 i++; 504 pcWindowName = [arguments objectAtIndex:i]; 505 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoapath"] ) { 506 i++; 507 pcPath = [arguments objectAtIndex:i]; 508 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoalivethumbnail"] ) { 509 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cocoanodialogs"] ) { 510 pcDialogs = NO; 511 NSLog(@"pcDialogs: %d\n", pcDialogs); 512 } else if ( [[arguments objectAtIndex:i] isEqual:@"-wmstopwheninactive"] ) { 513 WMStopWhenInactive = true; 514 } else if ( [[arguments objectAtIndex:i] isEqual:@"-full-screen"] ) { 515 fullscreen = [contentView toggleFullScreen]; 516 } else if ( [[arguments objectAtIndex:i] isEqual:@"-cdrom"] ) { 517 if ( [[arguments objectAtIndex:i+1] isEqual:@"/dev/cdrom"] ) { 518 kern_return_t kernResult; 519 io_iterator_t mediaIterator; 520 char bsdPath[MAXPATHLEN]; 521 522 kernResult = FindEjectableCDMedia( &mediaIterator ); 523 kernResult = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) ); 524 525 if ( bsdPath[0] == '\0' ) { 526 i++; 527 } else { 528 asprintf(&argv2[i2], "%s", [[arguments objectAtIndex:i] cString]); 529 i2++; 530 i++; 531 asprintf(&argv2[i2], "%s", [[arguments objectAtIndex:i] cString]); 532 i2++; 533 } 534 535 if ( mediaIterator ) 536 IOObjectRelease( mediaIterator ); 537 } else { 538 asprintf(&argv2[i2], "%s", [[arguments objectAtIndex:i] cString]); 539 i2++; 540 i++; 541 asprintf(&argv2[i2], "%s", [[arguments objectAtIndex:i] cString]); 542 i2++; 543 } 544 } else { 545 if ([[arguments objectAtIndex:i] isEqual:@"-smb"]) 546 smbPath = [[NSString alloc] initWithString:[arguments objectAtIndex:i + 1]]; 547 548 if ([[arguments objectAtIndex:i] isEqual:@"-hda"]) 551 549 if ([[arguments objectAtIndex:i+1] rangeOfString:@"qcow2"].length > 0) 552 550 WMSupportsSnapshots = TRUE; 553 asprintf(&argv2[i2], "%s", [[arguments objectAtIndex:i] cString]);554 i2++;555 }556 }557 558 // for (i = 0; i < i2; i++)559 // NSLog(@"Argv :%s\n", argv2[i]);560 561 /* set window- and frameAutosaveName */562 [pcWindow setFrameAutosaveName: [NSString stringWithFormat:@"%@ - %@",pcWindowName, pcName]];563 [pcWindow setTitle: [NSString stringWithFormat:@"%@ - %@",pcWindowName, pcName]];564 565 /* show progressWindow */566 [progressWindow showProgressWindow:pcWindow text: NSLocalizedStringFromTable(@"startPCWithArgs:text", @"Localizable", @"cocoaQemu") name:pcName];567 568 /* register with Q distributed objects server */569 if (![qdoserver guestRegister: self withName:pcName]) {570 [qdoserver release];571 qdoserver = nil;572 NSLog(@"KO");573 }574 575 /* update status */576 pcStatus = @"running";577 578 /* hide progressWindow */579 progressWindowTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector( closeProgressWindow ) userInfo:nil repeats:YES];580 581 /* launch VM, QEMU is up and running here */582 qemu_main(i2, argv2);583 584 /* remove pcWindow */585 [pcWindow close];586 587 [pool release];588 589 /* unregister with Q distributed objects server */590 if (![qdoserver guestUnregisterWithName:pcName]) {591 NSLog(@"KO");592 }593 [qdoserver release];594 qdoserver = nil;595 596 /* saved: return 2, so qemu-control knows */597 if ([pcStatus isEqual:@"saved"]) {598 exit(2);599 } else {600 [NSApp terminate:self];601 }551 asprintf(&argv2[i2], "%s", [[arguments objectAtIndex:i] cString]); 552 i2++; 553 } 554 } 555 556 // for (i = 0; i < i2; i++) 557 // NSLog(@"Argv :%s\n", argv2[i]); 558 559 /* set window- and frameAutosaveName */ 560 [pcWindow setFrameAutosaveName: [NSString stringWithFormat:@"%@ - %@",pcWindowName, pcName]]; 561 [pcWindow setTitle: [NSString stringWithFormat:@"%@ - %@",pcWindowName, pcName]]; 562 563 /* show progressWindow */ 564 [progressWindow showProgressWindow:pcWindow text: NSLocalizedStringFromTable(@"startPCWithArgs:text", @"Localizable", @"cocoaQemu") name:pcName]; 565 566 /* register with Q distributed objects server */ 567 if (![qdoserver guestRegister: self withName:pcName]) { 568 [qdoserver release]; 569 qdoserver = nil; 570 NSLog(@"KO"); 571 } 572 573 /* update status */ 574 pcStatus = @"running"; 575 576 /* hide progressWindow */ 577 progressWindowTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector( closeProgressWindow ) userInfo:nil repeats:YES]; 578 579 /* launch VM, QEMU is up and running here */ 580 qemu_main(i2, argv2); 581 582 /* remove pcWindow */ 583 [pcWindow close]; 584 585 [pool release]; 586 587 /* unregister with Q distributed objects server */ 588 if (![qdoserver guestUnregisterWithName:pcName]) { 589 NSLog(@"KO"); 590 } 591 [qdoserver release]; 592 qdoserver = nil; 593 594 /* saved: return 2, so qemu-control knows */ 595 if ([pcStatus isEqual:@"saved"]) { 596 exit(2); 597 } else { 598 [NSApp terminate:self]; 599 } 602 600 } 603 601 604 602 - (void) changeFda:(id)sender 605 603 { 606 // NSLog(@"cocoaQemu: changeFda");607 608 NSOpenPanel *op = [[NSOpenPanel alloc] init];609 [op setPrompt: NSLocalizedStringFromTable(@"changeFda:prompt", @"Localizable", @"cocoaQemu")];610 [op setMessage: NSLocalizedStringFromTable(@"changeFda:message", @"Localizable", @"cocoaQemu")];611 [op beginSheetForDirectory:nil612 file:nil613 types:fileTypes614 modalForWindow:pcWindow615 modalDelegate:self616 didEndSelector:@selector(changeDeviceSheetDidEnd:returnCode:contextInfo:)617 contextInfo:@"fda"];604 // NSLog(@"cocoaQemu: changeFda"); 605 606 NSOpenPanel *op = [[NSOpenPanel alloc] init]; 607 [op setPrompt: NSLocalizedStringFromTable(@"changeFda:prompt", @"Localizable", @"cocoaQemu")]; 608 [op setMessage: NSLocalizedStringFromTable(@"changeFda:message", @"Localizable", @"cocoaQemu")]; 609 [op beginSheetForDirectory:nil 610 file:nil 611 types:fileTypes 612 modalForWindow:pcWindow 613 modalDelegate:self 614 didEndSelector:@selector(changeDeviceSheetDidEnd:returnCode:contextInfo:) 615 contextInfo:@"fda"]; 618 616 } 619 617 620 618 - (void) changeFdb:(id)sender 621 619 { 622 // NSLog(@"cocoaQemu: changeFdb");623 624 NSOpenPanel *op = [[NSOpenPanel alloc] init];625 [op setPrompt: NSLocalizedStringFromTable(@"changeFdb:prompt", @"Localizable", @"cocoaQemu")];626 [op setMessage: NSLocalizedStringFromTable(@"changeFdb:message", @"Localizable", @"cocoaQemu")];627 [op beginSheetForDirectory:nil628 file:nil629 types:fileTypes630 modalForWindow:pcWindow631 modalDelegate:self632 didEndSelector:@selector(changeDeviceSheetDidEnd:returnCode:contextInfo:)633 contextInfo:@"fdb"];620 // NSLog(@"cocoaQemu: changeFdb"); 621 622 NSOpenPanel *op = [[NSOpenPanel alloc] init]; 623 [op setPrompt: NSLocalizedStringFromTable(@"changeFdb:prompt", @"Localizable", @"cocoaQemu")]; 624 [op setMessage: NSLocalizedStringFromTable(@"changeFdb:message", @"Localizable", @"cocoaQemu")]; 625 [op beginSheetForDirectory:nil 626 file:nil 627 types:fileTypes 628 modalForWindow:pcWindow 629 modalDelegate:self 630 didEndSelector:@selector(changeDeviceSheetDidEnd:returnCode:contextInfo:) 631 contextInfo:@"fdb"]; 634 632 } 635 633 636 634 - (void) changeCdrom:(id)sender 637 635 { 638 // NSLog(@"cocoaQemu: changeCdrom");639 640 NSOpenPanel *op = [[NSOpenPanel alloc] init];641 [op setPrompt: NSLocalizedStringFromTable(@"changeCdrom:prompt", @"Localizable", @"cocoaQemu")];642 [op setMessage: NSLocalizedStringFromTable(@"changeCdrom:message", @"Localizable", @"cocoaQemu")];643 [op beginSheetForDirectory:nil644 file:nil645 types:fileTypes646 modalForWindow:pcWindow647 modalDelegate:self648 didEndSelector:@selector(changeDeviceSheetDidEnd:returnCode:contextInfo:)649 contextInfo:@"cdrom"];636 // NSLog(@"cocoaQemu: changeCdrom"); 637 638 NSOpenPanel *op = [[NSOpenPanel alloc] init]; 639 [op setPrompt: NSLocalizedStringFromTable(@"changeCdrom:prompt", @"Localizable", @"cocoaQemu")]; 640 [op setMessage: NSLocalizedStringFromTable(@"changeCdrom:message", @"Localizable", @"cocoaQemu")]; 641 [op beginSheetForDirectory:nil 642 file:nil 643 types:fileTypes 644 modalForWindow:pcWindow 645 modalDelegate:self 646 didEndSelector:@selector(changeDeviceSheetDidEnd:returnCode:contextInfo:) 647 contextInfo:@"cdrom"]; 650 648 } 651 649 652 650 - (void)changeDeviceSheetDidEnd: (NSOpenPanel *)sheet 653 returnCode:(int)returnCode654 contextInfo:(NSString *)contextInfo655 { 656 // NSLog(@"cocoaQemu: changeDeviceSheetDidEnd");657 658 if(returnCode == NSOKButton)659 [self changeDeviceImage:[contextInfo cString] filename:[[sheet filename] cString] withForce:1];651 returnCode:(int)returnCode 652 contextInfo:(NSString *)contextInfo 653 { 654 // NSLog(@"cocoaQemu: changeDeviceSheetDidEnd"); 655 656 if(returnCode == NSOKButton) 657 [self changeDeviceImage:[contextInfo cString] filename:[[sheet filename] cString] withForce:1]; 660 658 } 661 659 662 660 - (void) useCdrom: (id)sender 663 661 { 664 // NSLog(@"cocoaQemu: useCdrom");665 666 [self changeDeviceImage:[@"cdrom" cString] filename:[@"/dev/cdrom" cString] withForce:1];662 // NSLog(@"cocoaQemu: useCdrom"); 663 664 [self changeDeviceImage:[@"cdrom" cString] filename:[@"/dev/cdrom" cString] withForce:1]; 667 665 } 668 666 669 667 - (void) ejectFda: (id)sender 670 668 { 671 // NSLog(@"cocoaQemu: ejectFda");672 673 [self ejectImage:[@"fda" cString] withForce:1];669 // NSLog(@"cocoaQemu: ejectFda"); 670 671 [self ejectImage:[@"fda" cString] withForce:1]; 674 672 } 675 673 676 674 - (void) ejectFdb: (id)sender 677 675 { 678 // NSLog(@"cocoaQemu: ejectFdb");679 680 [self ejectImage:[@"fdb" cString] withForce:1];676 // NSLog(@"cocoaQemu: ejectFdb"); 677 678 [self ejectImage:[@"fdb" cString] withForce:1]; 681 679 } 682 680 683 681 - (void) ejectCdrom: (id)sender 684 682 { 685 // NSLog(@"cocoaQemu: ejectCdrom");686 687 [self ejectImage:[@"cdrom" cString] withForce:1];683 // NSLog(@"cocoaQemu: ejectCdrom"); 684 685 [self ejectImage:[@"cdrom" cString] withForce:1]; 688 686 } 689 687 690 688 /* copied and adapted from monitor.c */ 691 689 - (int) ejectDevice: (BlockDriverState *) bs 692 withForce: (int) force693 { 694 if (bdrv_is_inserted(bs)) {695 if (!force) {696 if (!bdrv_is_removable(bs)) {697 printf("device is not removable\n");698 return -1;699 }700 if (bdrv_is_locked(bs)) {701 printf("device is locked\n");702 return -1;703 }704 }705 bdrv_close(bs);706 }707 return 0;690 withForce: (int) force 691 { 692 if (bdrv_is_inserted(bs)) { 693 if (!force) { 694 if (!bdrv_is_removable(bs)) { 695 printf("device is not removable\n"); 696 return -1; 697 } 698 if (bdrv_is_locked(bs)) { 699 printf("device is locked\n"); 700 return -1; 701 } 702 } 703 bdrv_close(bs); 704 } 705 return 0; 708 706 } 709 707 710 708 - (void) ejectImage:(const char *) filename 711 withForce: (int) force712 { 713 BlockDriverState *bs;714 715 bs = bdrv_find(filename);716 if (!bs) {717 printf("device not found\n");718 return;719 }720 [self ejectDevice:bs withForce:force];709 withForce: (int) force 710 { 711 BlockDriverState *bs; 712 713 bs = bdrv_find(filename); 714 if (!bs) { 715 printf("device not found\n"); 716 return; 717 } 718 [self ejectDevice:bs withForce:force]; 721 719 } 722 720 723 721 - (void) changeDeviceImage: (const char *) device 724 filename: (const char *) filename725 withForce: (int) force726 { 727 BlockDriverState *bs;728 int i;729 char password[256];730 731 bs = bdrv_find(device);732 if (!bs) {733 printf("device not found\n");734 return;735 }736 if ([self ejectDevice:bs withForce:force] < 0)737 return;738 bdrv_open(bs, filename, 0);739 if (bdrv_is_encrypted(bs)) {740 printf("%s is encrypted.\n", device);741 for(i = 0; i < 3; i++) {742 monitor_readline("Password: ", 1, password, sizeof(password));743 if (bdrv_set_key(bs, password) == 0)744 break;745 printf("invalid password\n");746 }747 }722 filename: (const char *) filename 723 withForce: (int) force 724 { 725 BlockDriverState *bs; 726 int i; 727 char password[256]; 728 729 bs = bdrv_find(device); 730 if (!bs) { 731 printf("device not found\n"); 732 return; 733 } 734 if ([self ejectDevice:bs withForce:force] < 0) 735 return; 736 bdrv_open(bs, filename, 0); 737 if (bdrv_is_encrypted(bs)) { 738 printf("%s is encrypted.\n", device); 739 for(i = 0; i < 3; i++) { 740 monitor_readline("Password: ", 1, password, sizeof(password)); 741 if (bdrv_set_key(bs, password) == 0) 742 break; 743 printf("invalid password\n"); 744 } 745 } 748 746 } 749 747 750 748 - (void) pausePlay: (id)sender 751 749 { 752 // NSLog(@"cocoaQemu: pausePlay");753 754 if (vm_running) {755 [self stopVM];756 wMPausedByUser = TRUE;757 } else {758 [self startVM];759 wMPausedByUser = FALSE;760 }750 // NSLog(@"cocoaQemu: pausePlay"); 751 752 if (vm_running) { 753 [self stopVM]; 754 wMPausedByUser = TRUE; 755 } else { 756 [self startVM]; 757 wMPausedByUser = FALSE; 758 } 761 759 } 762 760 763 761 - (void) ctrlAltDel: (id)sender 764 762 { 765 // NSLog(@"cocoaQemu: ctrlAltDel");766 767 /* press keys */768 if (56 & 0x80) /* ctrl */769 kbd_put_keycode(0xe0);770 kbd_put_keycode(56 & 0x7f);771 if (29 & 0x80) /* alt */772 kbd_put_keycode(0xe0);773 kbd_put_keycode(29 & 0x7f);774 if (211 & 0x80) /* del */775 kbd_put_keycode(0xe0);776 kbd_put_keycode(211 & 0x7f);777 778 /* release keys */779 if (56 & 0x80) /* ctrl */780 kbd_put_keycode(0xe0);781 kbd_put_keycode(56 | 0x80);782 if (29 & 0x80) /* alt */783 kbd_put_keycode(0xe0);784 kbd_put_keycode(29 | 0x80);785 if (211 & 0x80) /* del */786 kbd_put_keycode(0xe0);787 kbd_put_keycode(211 | 0x80);763 // NSLog(@"cocoaQemu: ctrlAltDel"); 764 765 /* press keys */ 766 if (56 & 0x80) /* ctrl */ 767 kbd_put_keycode(0xe0); 768 kbd_put_keycode(56 & 0x7f); 769 if (29 & 0x80) /* alt */ 770 kbd_put_keycode(0xe0); 771 kbd_put_keycode(29 & 0x7f); 772 if (211 & 0x80) /* del */ 773 kbd_put_keycode(0xe0); 774 kbd_put_keycode(211 & 0x7f); 775 776 /* release keys */ 777 if (56 & 0x80) /* ctrl */ 778 kbd_put_keycode(0xe0); 779 kbd_put_keycode(56 | 0x80); 780 if (29 & 0x80) /* alt */ 781 kbd_put_keycode(0xe0); 782 kbd_put_keycode(29 | 0x80); 783 if (211 & 0x80) /* del */ 784 kbd_put_keycode(0xe0); 785 kbd_put_keycode(211 | 0x80); 788 786 } 789 787 790 788 - (void) shutdownPC 791 789 { 792 // NSLog(@"cocoaQemu: shutdownPC");790 // NSLog(@"cocoaQemu: shutdownPC"); 793 791 794 792 /* exit fullscreen */ … … 796 794 [pc setFullscreen:[[pc contentView] toggleFullScreen]]; 797 795 798 if (!pcDialogs) {799 pcStatus = @"shutdown";800 qemu_system_shutdown_request();801 } else if ( !WMSupportsSnapshots ) {802 NSAlert *alert = [NSAlert alertWithMessageText: NSLocalizedStringFromTable(@"shutdownPC:text:1", @"Localizable", @"cocoaQemu")803 defaultButton: NSLocalizedStringFromTable(@"shutdownPC:defaultButton:1", @"Localizable", @"cocoaQemu")804 alternateButton: NSLocalizedStringFromTable(@"shutdownPC:alternateButton:1", @"Localizable", @"cocoaQemu")805 otherButton:@""806 informativeTextWithFormat: NSLocalizedStringFromTable(@"shutdownPC:informativeTextWithFormat:1", @"Localizable", @"cocoaQemu")];807 [alert beginSheetModalForWindow:pcWindow808 modalDelegate:self809 didEndSelector:@selector(shutdownPC2SheetDidEnd:returnCode:contextInfo:)810 contextInfo:nil];811 } else {812 NSAlert *alert = [NSAlert alertWithMessageText: NSLocalizedStringFromTable(@"shutdownPC:text:2", @"Localizable", @"cocoaQemu")813 defaultButton: NSLocalizedStringFromTable(@"shutdownPC:defaultButton:2", @"Localizable", @"cocoaQemu")814 alternateButton: NSLocalizedStringFromTable(@"shutdownPC:alternateButton:2", @"Localizable", @"cocoaQemu")815 otherButton: NSLocalizedStringFromTable(@"shutdownPC:otherButton:2", @"Localizable", @"cocoaQemu")816 informativeTextWithFormat: NSLocalizedStringFromTable(@"shutdownPC:informativeTextWithFormat:2", @"Localizable", @"cocoaQemu")];817 [alert beginSheetModalForWindow:pcWindow818 modalDelegate:self819 didEndSelector:@selector(shutdownPCSheetDidEnd:returnCode:contextInfo:)820 contextInfo:nil];821 }796 if (!pcDialogs) { 797 pcStatus = @"shutdown"; 798 qemu_system_shutdown_request(); 799 } else if ( !WMSupportsSnapshots ) { 800 NSAlert *alert = [NSAlert alertWithMessageText: NSLocalizedStringFromTable(@"shutdownPC:text:1", @"Localizable", @"cocoaQemu") 801 defaultButton: NSLocalizedStringFromTable(@"shutdownPC:defaultButton:1", @"Localizable", @"cocoaQemu") 802 alternateButton: NSLocalizedStringFromTable(@"shutdownPC:alternateButton:1", @"Localizable", @"cocoaQemu") 803 otherButton:@"" 804 informativeTextWithFormat: NSLocalizedStringFromTable(@"shutdownPC:informativeTextWithFormat:1", @"Localizable", @"cocoaQemu")]; 805 [alert beginSheetModalForWindow:pcWindow 806 modalDelegate:self 807 didEndSelector:@selector(shutdownPC2SheetDidEnd:returnCode:contextInfo:) 808 contextInfo:nil]; 809 } else { 810 NSAlert *alert = [NSAlert alertWithMessageText: NSLocalizedStringFromTable(@"shutdownPC:text:2", @"Localizable", @"cocoaQemu") 811 defaultButton: NSLocalizedStringFromTable(@"shutdownPC:defaultButton:2", @"Localizable", @"cocoaQemu") 812 alternateButton: NSLocalizedStringFromTable(@"shutdownPC:alternateButton:2", @"Localizable", @"cocoaQemu") 813 otherButton: NSLocalizedStringFromTable(@"shutdownPC:otherButton:2", @"Localizable", @"cocoaQemu") 814 informativeTextWithFormat: NSLocalizedStringFromTable(@"shutdownPC:informativeTextWithFormat:2", @"Localizable", @"cocoaQemu")]; 815 [alert beginSheetModalForWindow:pcWindow 816 modalDelegate:self 817 didEndSelector:@selector(shutdownPCSheetDidEnd:returnCode:contextInfo:) 818 contextInfo:nil]; 819 } 822 820 } 823 821 824 822 - (void) shutdownPCSheetDidEnd: (NSWindow *)sheet 825 returnCode: (int)returnCode 826 contextInfo: (void *)contextInfo 827 { 828 // NSLog(@"cocoaQemu: shutdownPCSheetDidEnd"); 829 830 [[sheet window] orderOut:self]; 831 if (returnCode == NSAlertDefaultReturn) 832 { 833 [self saveVM]; 834 pcStatus = @"saved"; 835 qemu_system_shutdown_request(); 836 vm_start(); 837 } 838 else if (returnCode == NSAlertOtherReturn) 839 { 840 pcStatus = @"shutdown"; 841 if([[NSFileManager defaultManager] fileExistsAtPath: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath]]) [[NSFileManager defaultManager] removeFileAtPath: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath] handler: nil]; 842 qemu_system_shutdown_request(); 843 vm_start(); 844 } 823 returnCode: (int)returnCode 824 contextInfo: (void *)contextInfo 825 { 826 // NSLog(@"cocoaQemu: shutdownPCSheetDidEnd"); 827 828 [[sheet window] orderOut:self]; 829 if (returnCode == NSAlertDefaultReturn) { 830 [self saveVM]; 831 pcStatus = @"saved"; 832 qemu_system_shutdown_request(); 833 vm_start(); 834 } else if (returnCode == NSAlertOtherReturn) { 835 pcStatus = @"shutdown"; 836 if([[NSFileManager defaultManager] fileExistsAtPath: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath]]) [[NSFileManager defaultManager] removeFileAtPath: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath] handler: nil]; 837 qemu_system_shutdown_request(); 838 vm_start(); 839 } 845 840 } 846 841 847 842 - (void) shutdownPC2SheetDidEnd: (NSWindow *)sheet 848 returnCode: (int)returnCode 849 contextInfo: (void *)contextInfo 850 { 851 // NSLog(@"cocoaQemu: shutdownPC2SheetDidEnd"); 852 853 [[sheet window] orderOut:self]; 854 if (returnCode == NSAlertDefaultReturn) 855 { 856 } 857 else 858 { 859 if ( [pcStatus isEqual: @"running"] ) 860 pcStatus = @"shutdown"; 861 if([[NSFileManager defaultManager] fileExistsAtPath: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath]]) [[NSFileManager defaultManager] removeFileAtPath: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath] handler: nil]; 862 qemu_system_shutdown_request(); 863 vm_start(); 864 } 843 returnCode: (int)returnCode 844 contextInfo: (void *)contextInfo 845 { 846 // NSLog(@"cocoaQemu: shutdownPC2SheetDidEnd"); 847 848 [[sheet window] orderOut:self]; 849 if (returnCode == NSAlertDefaultReturn) { 850 } else { 851 if ( [pcStatus isEqual: @"running"] ) 852 pcStatus = @"shutdown"; 853 if([[NSFileManager defaultManager] fileExistsAtPath: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath]]) [[NSFileManager defaultManager] removeFileAtPath: [NSString stringWithFormat: @"%@/thumbnail.png", pcPath] handler: nil]; 854 qemu_system_shutdown_request(); 855 vm_start(); 856 } 865 857 } 866 858 867 859 - (void) resetPC 868 860 { 869 // NSLog(@"cocoaQemu: resetPC");870 871 qemu_system_reset_request();861 // NSLog(@"cocoaQemu: resetPC"); 862 863 qemu_system_reset_request(); 872 864 } 873 865 874 866 - (void) screenshot 875 867 { 876 // NSLog(@"screenshot: resetPC");877 878 /* generate Screenshot */ 879 NSBitmapImageRep *bitmapImageRep = [NSBitmapImageRep imageRepWithData: [[contentView screenshot:[contentView frame].size] TIFFRepresentation]];880 NSData *data = [bitmapImageRep representationUsingType: NSPNGFileType properties: nil];881 882 /* save it to the desktop */883 NSFileManager *fileManager = [NSFileManager defaultManager];884 int i = 1;885 while ([fileManager fileExistsAtPath:[NSString stringWithFormat:@"%@/Q Screenshot %D.png", [@"~/Desktop" stringByExpandingTildeInPath], i]])886 i++;887 888 [data writeToFile: [NSString stringWithFormat:@"%@/Q Screenshot %D.png", [@"~/Desktop" stringByExpandingTildeInPath], i] atomically: YES];868 // NSLog(@"screenshot: resetPC"); 869 870 /* generate Screenshot */ 871 NSBitmapImageRep *bitmapImageRep = [NSBitmapImageRep imageRepWithData: [[contentView screenshot:[contentView frame].size] TIFFRepresentation]]; 872 NSData *data = [bitmapImageRep representationUsingType: NSPNGFileType properties: nil]; 873 874 /* save it to the desktop */ 875 NSFileManager *fileManager = [NSFileManager defaultManager]; 876 int i = 1; 877 while ([fileManager fileExistsAtPath:[NSString stringWithFormat:@"%@/Q Screenshot %D.png", [@"~/Desktop" stringByExpandingTildeInPath], i]]) 878 i++; 879 880 [data writeToFile: [NSString stringWithFormat:@"%@/Q Screenshot %D.png", [@"~/Desktop" stringByExpandingTildeInPath], i] atomically: YES]; 889 881 } 890 882 @end … … 894 886 /* 895 887 ------------------------------------------------------ 896 keymap conversion888 keymap conversion 897 889 ------------------------------------------------------ 898 890 */ … … 900 892 int keymap[] = 901 893 { 902 // SdlI macI macH SdlH 104xtH 104xtCsdl903 30, // 0 0x00 0x1e AQZ_a904 31, // 1 0x01 0x1f SQZ_s905 32, // 2 0x02 0x20 DQZ_d906 33, // 3 0x03 0x21 FQZ_f907 35, // 4 0x04 0x23 HQZ_h908 34, // 5 0x05 0x22 GQZ_g909 44, // 6 0x06 0x2c ZQZ_z910 45, // 7 0x07 0x2d XQZ_x911 46, // 8 0x08 0x2e CQZ_c912 47, // 9 0x09 0x2f VQZ_v913 0, // 10 0x0AUndefined914 48, // 11 0x0B 0x30 BQZ_b915 16, // 12 0x0C 0x10 QQZ_q916 17, // 13 0x0D 0x11 WQZ_w917 18, // 14 0x0E 0x12 EQZ_e918 19, // 15 0x0F 0x13 RQZ_r919 21, // 16 0x10 0x15 YQZ_y920 20, // 17 0x11 0x14 TQZ_t921 2, // 18 0x12 0x02 1QZ_1922 3, // 19 0x13 0x03 2QZ_2923 4, // 20 0x14 0x04 3QZ_3924 5, // 21 0x15 0x05 4QZ_4925 7, // 22 0x16 0x07 6QZ_6926 6, // 23 0x17 0x06 5QZ_5927 13, // 24 0x18 0x0d =QZ_EQUALS928 10, // 25 0x19 0x0a 9QZ_9929 8, // 26 0x1A 0x08 7QZ_7930 12, // 27 0x1B 0x0c -QZ_MINUS931 9, // 28 0x1C 0x09 8QZ_8932 11, // 29 0x1D 0x0b 0QZ_0933 27, // 30 0x1E 0x1b ]QZ_RIGHTBRACKET934 24, // 31 0x1F 0x18 OQZ_o935 22, // 32 0x20 0x16 UQZ_u936 26, // 33 0x21 0x1a [QZ_LEFTBRACKET937 23, // 34 0x22 0x17 IQZ_i938 25, // 35 0x23 0x19 PQZ_p939 28, // 36 0x24 0x1c ENTERQZ_RETURN940 38, // 37 0x25 0x26 LQZ_l941 36, // 38 0x26 0x24 JQZ_j942 40, // 39 0x27 0x28 'QZ_QUOTE943 37, // 40 0x28 0x25 KQZ_k944 39, // 41 0x29 0x27 ;QZ_SEMICOLON945 43, // 42 0x2A 0x2b \QZ_BACKSLASH946 51, // 43 0x2B 0x33 ,QZ_COMMA947 53, // 44 0x2C 0x35 /QZ_SLASH948 49, // 45 0x2D 0x31 NQZ_n949 50, // 46 0x2E 0x32 MQZ_m950 52, // 47 0x2F 0x34 .QZ_PERIOD951 15, // 48 0x30 0x0f TABQZ_TAB952 57, // 49 0x31 0x39 SPACEQZ_SPACE953 41, // 50 0x32 0x29 `QZ_BACKQUOTE954 14, // 51 0x33 0x0e BKSPQZ_BACKSPACE955 0, // 52 0x34Undefined956 1, // 53 0x35 0x01 ESCQZ_ESCAPE957 0, // 54 0x36QZ_RMETA958 0, // 55 0x37QZ_LMETA959 42, // 56 0x38 0x2a L SHFTQZ_LSHIFT960 58, // 57 0x39 0x3a CAPSQZ_CAPSLOCK961 56, // 58 0x3A 0x38 L ALTQZ_LALT962 29, // 59 0x3B 0x1d L CTRLQZ_LCTRL963 54, // 60 0x3C 0x36 R SHFTQZ_RSHIFT964 184, // 61 0x3D 0xb8 E0,38 R ALTQZ_RALT965 157, // 62 0x3E 0x9d E0,1D R CTRLQZ_RCTRL966 0, // 63 0x3FUndefined967 0, // 64 0x40Undefined968 0, // 65 0x41Undefined969 0, // 66 0x42Undefined970 55, // 67 0x43 0x37 KP *QZ_KP_MULTIPLY971 0, // 68 0x44Undefined972 78, // 69 0x45 0x4e KP +QZ_KP_PLUS973 0, // 70 0x46Undefined974 69, // 71 0x47 0x45 NUMQZ_NUMLOCK975 0, // 72 0x48Undefined976 0, // 73 0x49Undefined977 0, // 74 0x4AUndefined978 181, // 75 0x4B 0xb5 E0,35 KP /QZ_KP_DIVIDE979 152, // 76 0x4C 0x9c E0,1C KP ENQZ_KP_ENTER980 0, // 77 0x4Dundefined981 74, // 78 0x4E 0x4a KP -QZ_KP_MINUS982 0, // 79 0x4FUndefined983 0, // 80 0x50Undefined984 0, // 81 0x51QZ_KP_EQUALS985 82, // 82 0x52 0x52 KP 0QZ_KP0986 79, // 83 0x53 0x4f KP 1QZ_KP1987 80, // 84 0x54 0x50 KP 2QZ_KP2988 81, // 85 0x55 0x51 KP 3QZ_KP3989 75, // 86 0x56 0x4b KP 4QZ_KP4990 76, // 87 0x57 0x4c KP 5QZ_KP5991 77, // 88 0x58 0x4d KP 6QZ_KP6992 71, // 89 0x59 0x47 KP 7QZ_KP7993 0, // 90 0x5AUndefined994 72, // 91 0x5B 0x48 KP 8QZ_KP8995 73, // 92 0x5C 0x49 KP 9QZ_KP9996 125, // 93 0x5DBackslash (NIP)997 115, // 94 0x5EUnderline (NIP)998 0, // 95 0x5FUndefined999 63, // 96 0x60 0x3f F5QZ_F51000 64, // 97 0x61 0x40 F6QZ_F61001 65, // 98 0x62 0x41 F7QZ_F71002 61, // 99 0x63 0x3d F3QZ_F31003 66, // 100 0x64 0x42 F8QZ_F81004 67, // 101 0x65 0x43 F9QZ_F91005 0, // 102 0x66Undefined1006 87, // 103 0x67 0x57 F11QZ_F111007 0, // 104 0x68Undefined1008 183, // 105 0x69 0xb7QZ_PRINT1009 0, // 106 0x6AUndefined1010 70, // 107 0x6B 0x46 SCROLLQZ_SCROLLOCK1011 0, // 108 0x6CUndefined1012 68, // 109 0x6D 0x44 F10QZ_F101013 0, // 110 0x6EUndefined1014 88, // 111 0x6F 0x58 F12QZ_F121015 0, // 112 0x70Undefined1016 110, // 113 0x71 0x0QZ_PAUSE1017 210, // 114 0x72 0xd2 E0,52 INSERTQZ_INSERT1018 199, // 115 0x73 0xc7 E0,47 HOMEQZ_HOME1019 201, // 116 0x74 0xc9 E0,49 PG UPQZ_PAGEUP1020 211, // 117 0x75 0xd3 E0,53 DELETEQZ_DELETE1021 62, // 118 0x76 0x3e F4QZ_F41022 207, // 119 0x77 0xcf E0,4f ENDQZ_END1023 60, // 120 0x78 0x3c F2QZ_F21024 209, // 121 0x79 0xd1 E0,51 PG DNQZ_PAGEDOWN1025 59, // 122 0x7A 0x3b F1QZ_F11026 203, // 123 0x7B 0xcb e0,4BL ARROW QZ_LEFT1027 205, // 124 0x7C 0xcd e0,4DR ARROW QZ_RIGHT1028 208, // 125 0x7D 0xd0 E0,50D ARROW QZ_DOWN1029 200, // 126 0x7E 0xc8 E0,48U ARROW QZ_UP1030 /* completed according to http: //www.libsdl.org/cgi/cvsweb.cgi/SDL12/src/video/quartz/SDL_QuartzKeys.h?rev=1.6&content-type=text/x-cvsweb-markup */894 // SdlI macI macH SdlH 104xtH 104xtC sdl 895 30, // 0 0x00 0x1e A QZ_a 896 31, // 1 0x01 0x1f S QZ_s 897 32, // 2 0x02 0x20 D QZ_d 898 33, // 3 0x03 0x21 F QZ_f 899 35, // 4 0x04 0x23 H QZ_h 900 34, // 5 0x05 0x22 G QZ_g 901 44, // 6 0x06 0x2c Z QZ_z 902 45, // 7 0x07 0x2d X QZ_x 903 46, // 8 0x08 0x2e C QZ_c 904 47, // 9 0x09 0x2f V QZ_v 905 0, // 10 0x0A Undefined 906 48, // 11 0x0B 0x30 B QZ_b 907 16, // 12 0x0C 0x10 Q QZ_q 908 17, // 13 0x0D 0x11 W QZ_w 909 18, // 14 0x0E 0x12 E QZ_e 910 19, // 15 0x0F 0x13 R QZ_r 911 21, // 16 0x10 0x15 Y QZ_y 912 20, // 17 0x11 0x14 T QZ_t 913 2, // 18 0x12 0x02 1 QZ_1 914 3, // 19 0x13 0x03 2 QZ_2 915 4, // 20 0x14 0x04 3 QZ_3 916 5, // 21 0x15 0x05 4 QZ_4 917 7, // 22 0x16 0x07 6 QZ_6 918 6, // 23 0x17 0x06 5 QZ_5 919 13, // 24 0x18 0x0d = QZ_EQUALS 920 10, // 25 0x19 0x0a 9 QZ_9 921 8, // 26 0x1A 0x08 7 QZ_7 922 12, // 27 0x1B 0x0c - QZ_MINUS 923 9, // 28 0x1C 0x09 8 QZ_8 924 11, // 29 0x1D 0x0b 0 QZ_0 925 27, // 30 0x1E 0x1b ] QZ_RIGHTBRACKET 926 24, // 31 0x1F 0x18 O QZ_o 927 22, // 32 0x20 0x16 U QZ_u 928 26, // 33 0x21 0x1a [ QZ_LEFTBRACKET 929 23, // 34 0x22 0x17 I QZ_i 930 25, // 35 0x23 0x19 P QZ_p 931 28, // 36 0x24 0x1c ENTER QZ_RETURN 932 38, // 37 0x25 0x26 L QZ_l 933 36, // 38 0x26 0x24 J QZ_j 934 40, // 39 0x27 0x28 ' QZ_QUOTE 935 37, // 40 0x28 0x25 K QZ_k 936 39, // 41 0x29 0x27 ; QZ_SEMICOLON 937 43, // 42 0x2A 0x2b \ QZ_BACKSLASH 938 51, // 43 0x2B 0x33 , QZ_COMMA 939 53, // 44 0x2C 0x35 / QZ_SLASH 940 49, // 45 0x2D 0x31 N QZ_n 941 50, // 46 0x2E 0x32 M QZ_m 942 52, // 47 0x2F 0x34 . QZ_PERIOD 943 15, // 48 0x30 0x0f TAB QZ_TAB 944 57, // 49 0x31 0x39 SPACE QZ_SPACE 945 41, // 50 0x32 0x29 ` QZ_BACKQUOTE 946 14, // 51 0x33 0x0e BKSP QZ_BACKSPACE 947 0, // 52 0x34 Undefined 948 1, // 53 0x35 0x01 ESC QZ_ESCAPE 949 0, // 54 0x36 QZ_RMETA 950 0, // 55 0x37 QZ_LMETA 951 42, // 56 0x38 0x2a L SHFT QZ_LSHIFT 952 58, // 57 0x39 0x3a CAPS QZ_CAPSLOCK 953 56, // 58 0x3A 0x38 L ALT QZ_LALT 954 29, // 59 0x3B 0x1d L CTRL QZ_LCTRL 955 54, // 60 0x3C 0x36 R SHFT QZ_RSHIFT 956 184, // 61 0x3D 0xb8 E0,38 R ALT QZ_RALT 957 157, // 62 0x3E 0x9d E0,1D R CTRL QZ_RCTRL 958 0, // 63 0x3F Undefined 959 0, // 64 0x40 Undefined 960 0, // 65 0x41 Undefined 961 0, // 66 0x42 Undefined 962 55, // 67 0x43 0x37 KP * QZ_KP_MULTIPLY 963 0, // 68 0x44 Undefined 964 78, // 69 0x45 0x4e KP + QZ_KP_PLUS 965 0, // 70 0x46 Undefined 966 69, // 71 0x47 0x45 NUM QZ_NUMLOCK 967 0, // 72 0x48 Undefined 968 0, // 73 0x49 Undefined 969 0, // 74 0x4A Undefined 970 181, // 75 0x4B 0xb5 E0,35 KP / QZ_KP_DIVIDE 971 152, // 76 0x4C 0x9c E0,1C KP EN QZ_KP_ENTER 972 0, // 77 0x4D undefined 973 74, // 78 0x4E 0x4a KP - QZ_KP_MINUS 974 0, // 79 0x4F Undefined 975 0, // 80 0x50 Undefined 976 0, // 81 0x51 QZ_KP_EQUALS 977 82, // 82 0x52 0x52 KP 0 QZ_KP0 978 79, // 83 0x53 0x4f KP 1 QZ_KP1 979 80, // 84 0x54 0x50 KP 2 QZ_KP2 980 81, // 85 0x55 0x51 KP 3 QZ_KP3 981 75, // 86 0x56 0x4b KP 4 QZ_KP4 982 76, // 87 0x57 0x4c KP 5 QZ_KP5 983 77, // 88 0x58 0x4d KP 6 QZ_KP6 984 71, // 89 0x59 0x47 KP 7 QZ_KP7 985 0, // 90 0x5A Undefined 986 72, // 91 0x5B 0x48 KP 8 QZ_KP8 987 73, // 92 0x5C 0x49 KP 9 QZ_KP9 988 125, // 93 0x5D Backslash (NIP) 989 115, // 94 0x5E Underline (NIP) 990 0, // 95 0x5F Undefined 991 63, // 96 0x60 0x3f F5 QZ_F5 992 64, // 97 0x61 0x40 F6 QZ_F6 993 65, // 98 0x62 0x41 F7 QZ_F7 994 61, // 99 0x63 0x3d F3 QZ_F3 995 66, // 100 0x64 0x42 F8 QZ_F8 996 67, // 101 0x65 0x43 F9 QZ_F9 997 0, // 102 0x66 Undefined 998 87, // 103 0x67 0x57 F11 QZ_F11 999 0, // 104 0x68 Undefined 1000 183, // 105 0x69 0xb7 QZ_PRINT 1001 0, // 106 0x6A Undefined 1002 70, // 107 0x6B 0x46 SCROLL QZ_SCROLLOCK 1003 0, // 108 0x6C Undefined 1004 68, // 109 0x6D 0x44 F10 QZ_F10 1005 0, // 110 0x6E Undefined 1006 88, // 111 0x6F 0x58 F12 QZ_F12 1007 0, // 112 0x70 Undefined 1008 110, // 113 0x71 0x0 QZ_PAUSE 1009 210, // 114 0x72 0xd2 E0,52 INSERT QZ_INSERT 1010 199, // 115 0x73 0xc7 E0,47 HOME QZ_HOME 1011 201, // 116 0x74 0xc9 E0,49 PG UP QZ_PAGEUP 1012 211, // 117 0x75 0xd3 E0,53 DELETE QZ_DELETE 1013 62, // 118 0x76 0x3e F4 QZ_F4 1014 207, // 119 0x77 0xcf E0,4f END QZ_END 1015 60, // 120 0x78 0x3c F2 QZ_F2 1016 209, // 121 0x79 0xd1 E0,51 PG DN QZ_PAGEDOWN 1017 59, // 122 0x7A 0x3b F1 QZ_F1 1018 203, // 123 0x7B 0xcb e0,4B L ARROW QZ_LEFT 1019 205, // 124 0x7C 0xcd e0,4D R ARROW QZ_RIGHT 1020 208, // 125 0x7D 0xd0 E0,50 D ARROW QZ_DOWN 1021 200, // 126 0x7E 0xc8 E0,48 U ARROW QZ_UP 1022 /* completed according to http: //www.libsdl.org/cgi/cvsweb.cgi/SDL12/src/video/quartz/SDL_QuartzKeys.h?rev=1.6&content-type=text/x-cvsweb-markup */ 1031 1023 1032 /* Aditional 104 Key XP-Keyboard Scancodes from http: //www.computer-engineering.org/ps2keyboard/scancodes1.html */1024 /* Aditional 104 Key XP-Keyboard Scancodes from http: //www.computer-engineering.org/ps2keyboard/scancodes1.html */ 1033 1025 /* 1034 219, // 0xdb e0,5b L GUI 1035 220, // 0xdc e0,5c R GUI 1036 221, // 0xdd e0,5d APPS 1037 // E0,2A,E0,37 PRNT SCRN 1038 // E1,1D,45,E1,9D,C5 PAUSE 1039 83, // 0x53 0x53 KP . 1040 // ACPI Scan Codes 1041 222, // 0xde E0, 5E Power 1042 223, // 0xdf E0, 5F Sleep 1043 227, // 0xe3 E0, 63 Wake 1044 // Windows Multimedia Scan Codes 1045 153, // 0x99 E0, 19 Next Track 1046 144, // 0x90 E0, 10 Previous Track 1047 164, // 0xa4 E0, 24 Stop 1048 162, // 0xa2 E0, 22 Play/Pause 1049 160, // 0xa0 E0, 20 Mute 1050 176, // 0xb0 E0, 30 Volume Up 1051 174, // 0xae E0, 2EVolume Down1052 237, // 0xed E0, 6D Media Select 1053 236, // 0xec E0, 6C E-Mail 1054 161, // 0xa1 E0, 21 Calculator 1055 235, // 0xeb E0, 6BMy Computer1056 229, // 0xe5 E0, 65 WWW Search 1057 178, // 0xb2 E0, 32 WWW Home 1058 234, // 0xea E0, 6A WWW Back 1059 233, // 0xe9 E0, 69WWW Forward1060 232, // 0xe8 E0, 68 WWW Stop 1061 231, // 0xe7 E0, 67WWW Refresh1062 230 // 0xe6 E0, 66 WWW Favorites 1026 219, // 0xdb e0,5b L GUI 1027 220, // 0xdc e0,5c R GUI 1028 221, // 0xdd e0,5d APPS 1029 // E0,2A,E0,37 PRNT SCRN 1030 // E1,1D,45,E1,9D,C5 PAUSE 1031 83, // 0x53 0x53 KP . 1032 // ACPI Scan Codes 1033 222, // 0xde E0, 5E Power 1034 223, // 0xdf E0, 5F Sleep 1035 227, // 0xe3 E0, 63 Wake 1036 // Windows Multimedia Scan Codes 1037 153, // 0x99 E0, 19 Next Track 1038 144, // 0x90 E0, 10 Previous Track 1039 164, // 0xa4 E0, 24 Stop 1040 162, // 0xa2 E0, 22 Play/Pause 1041 160, // 0xa0 E0, 20 Mute 1042 176, // 0xb0 E0, 30 Volume Up 1043 174, // 0xae E0, 2E Volume Down 1044 237, // 0xed E0, 6D Media Select 1045 236, // 0xec E0, 6C E-Mail 1046 161, // 0xa1 E0, 21 Calculator 1047 235, // 0xeb E0, 6B My Computer 1048 229, // 0xe5 E0, 65 WWW Search 1049 178, // 0xb2 E0, 32 WWW Home 1050 234, // 0xea E0, 6A WWW Back 1051 233, // 0xe9 E0, 69 WWW Forward 1052 232, // 0xe8 E0, 68 WWW Stop 1053 231, // 0xe7 E0, 67 WWW Refresh 1054 230 // 0xe6 E0, 66 WWW Favorites 1063 1055 */ 1064 1056 }; … … 1066 1058 int cocoa_keycode_to_qemu(int keycode) 1067 1059 { 1068 if((sizeof(keymap)/sizeof(int)) <= keycode)1069 {1070 printf("(cocoa) warning unknow keycode 0x%x\n", keycode);1071 return 0;1072 }1073 return keymap[keycode];1060 if((sizeof(keymap)/sizeof(int)) <= keycode) 1061 { 1062 printf("(cocoa) warning unknow keycode 0x%x\n", keycode); 1063 return 0; 1064 } 1065 return keymap[keycode]; 1074 1066 } 1075 1067 … … 1078 1070 /* 1079 1071 ------------------------------------------------------ 1080 Qemu Video Driver1081 1072 Qemu Video Driver 1073 1082 1074 ------------------------------------------------------ 1083 1075 */ 1084 1076 void cocoa_update(DisplayState *ds, int x, int y, int w, int h) 1085 1077 { 1086 // NSLog(@"cocoa: update");1078 // NSLog(@"cocoa: update"); 1087 1079 1088 1080 if ([[[pc contentView] class] isEqual:[cocoaQemuQuartzView class]]) { 1081 1089 1082 /* new selective drawing code (draws only dirty rectangles) */ 1090 float dx;1091 float dy;1092 1093 dx = [[pc contentView] frame].size.width / (float)ds->width;1094 dy = [[pc contentView] frame].size.height / (float)ds->height;1095 1096 1083 [[pc contentView] setNeedsDisplayInRect:NSMakeRect( 1097 x * dx, 1098 [[pc contentView] frame].size.height - (h + y) * dy, 1099 w * dx, 1100 h * dy 1101 )]; 1084 x * [[pc contentView] cdx], 1085 [[pc contentView] frame].size.height - (h + y) * [[pc contentView] cdy], 1086 w * [[pc contentView] cdx], 1087 h * [[pc contentView] cdy] 1088 )]; 1089 1102 1090 } else { 1103 1091 1104 1092 /* old drawing code (draws everything) */ 1105 1093 [[pc contentView] drawContent:ds]; … … 1110 1098 void cocoa_resize(DisplayState *ds, int w, int h) 1111 1099 { 1112 // NSLog(@"cocoa: resize\n");1113 1114 [[pc contentView] resizeContent:ds width:w height:h];1100 // NSLog(@"cocoa: resize\n"); 1101 1102 [[pc contentView] resizeContent:ds width:w height:h]; 1115 1103 } 1116 1104 1117 1105 void cocoa_refresh(DisplayState *ds) 1118 1106 { 1119 // NSLog(@"cocoa: refresh\n");1120 1121 if (kbd_mouse_is_absolute()) {1122 if (![pc absolute_enabled]) {1123 if ([pc grab]) {1124 [pc ungrabMouse];1125 }1126 }1127 [pc setAbsolute_enabled:1];1128 }1129 1130 NSEvent *event;1131 do {1132 event = [ NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[ NSDate distantPast ]1133 inMode: NSDefaultRunLoopMode dequeue:YES ];1134 if (event != nil) {1135 switch ([event type])1136 {1137 1138 case NSFlagsChanged:1139 {1140 int keycode = cocoa_keycode_to_qemu([event keyCode]);1141 [pc setModifierAtIndex:keycode to: ([pc modifierAtIndex:keycode] == 0) ? 1 : 0];1142 1143 if ( [pc modifierAtIndex:keycode] ) { /* Keydown */1144 if (keycode & 0x80)1145 kbd_put_keycode(0xe0);1146 kbd_put_keycode(keycode & 0x7f);1147 } else { /* Keyup */1148 if (keycode & 0x80)1149 kbd_put_keycode(0xe0);1150 kbd_put_keycode(keycode | 0x80);1151 }1152 1153 /* emulate caps lock and num lock keyup */1154 if ((keycode == 58) || (keycode == 69))1155 {1156 [pc setModifierAtIndex:keycode to:0];1157 if (keycode & 0x80)1158 kbd_put_keycode(0xe0);1159 kbd_put_keycode(keycode | 0x80);1160 }1161 1162 /* release Mouse grab when pressing ctrl+alt */1163 if ((![pc fullscreen]) && ([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask))1164 [pc ungrabMouse];1165 }1166 break;1167 1168 case NSKeyDown:1169 {1170 int keycode = cocoa_keycode_to_qemu([event keyCode]); 1171 1172 /* handle command Key Combos */1173 if ([event modifierFlags] & NSCommandKeyMask) {1174 switch ([event keyCode]) {1175 1176 /* toggle fullscreen */1177 case 3: /* f key */1178 // show hint to exit fullscreen, fast os switch, toolbar1179 if(![pc fullscreen]) {1180 #if kju_debug1181 NSLog(@"init FSController");1182 #endif1183 NSBeginAlertSheet(NSLocalizedStringFromTable(@"cocoa_refresh:showFullscreen:standardAlert", @"Localizable", @"cocoaQemu"),NSLocalizedStringFromTable(@"cocoa_refresh:showFullscreen:defaultButton", @"Localizable", @"cocoaQemu"),nil,nil,[pc pcWindow],pc,@selector(showFullscreenAlertSheetDidEnd:returnCode:contextInfo:),nil,nil,NSLocalizedStringFromTable(@"cocoa_refresh:showFullscreen:informativeText", @"Localizable", @"cocoaQemu"));1184 [pc setFullscreenController:[[FSController alloc] initWithSender:pc]];1185 } else {1186 #if kju_debug1187 NSLog(@"release FSController");1188 #endif1189 [pc setFullscreen:[[pc contentView] toggleFullScreen]];1190 [[pc fullscreenController] release];1191 }1192 return;1193 1194 // /* paste text in Host Clipboard to Guest */1195 // case 9: /* v key */1196 // {1197 // NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];1198 // NSString *string = [NSString stringWithString:[pasteboard stringForType:NSStringPboardType]];1199 // if (string) {1200 // NSLog(@"PASTE: %@", string);1201 // int ii;1202 // int maxChars = 24;1203 // if ([string length] < maxChars)1204 // maxChars = [string length];1205 // for (ii=0; ii<maxChars; ii++) {1206 // /* keycode */1207 // keycode = keysym2scancode(kbd_layout, [string characterAtIndex:ii]);1107 // NSLog(@"cocoa: refresh\n"); 1108 1109 if (kbd_mouse_is_absolute()) { 1110 if (![pc absolute_enabled]) { 1111 if ([pc grab]) { 1112 [pc ungrabMouse]; 1113 } 1114 } 1115 [pc setAbsolute_enabled:1]; 1116 } 1117 1118 NSEvent *event; 1119 do { 1120 event = [ NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[ NSDate distantPast ] 1121 inMode: NSDefaultRunLoopMode dequeue:YES ]; 1122 if (event != nil) { 1123 switch ([event type]) 1124 { 1125 1126 case NSFlagsChanged: 1127 { 1128 int keycode = cocoa_keycode_to_qemu([event keyCode]); 1129 [pc setModifierAtIndex:keycode to: ([pc modifierAtIndex:keycode] == 0) ? 1 : 0]; 1130 1131 if ( [pc modifierAtIndex:keycode] ) { /* Keydown */ 1132 if (keycode & 0x80) 1133 kbd_put_keycode(0xe0); 1134 kbd_put_keycode(keycode & 0x7f); 1135 } else { /* Keyup */ 1136 if (keycode & 0x80) 1137 kbd_put_keycode(0xe0); 1138 kbd_put_keycode(keycode | 0x80); 1139 } 1140 1141 /* emulate caps lock and num lock keyup */ 1142 if ((keycode == 58) || (keycode == 69)) 1143 { 1144 [pc setModifierAtIndex:keycode to:0]; 1145 if (keycode & 0x80) 1146 kbd_put_keycode(0xe0); 1147 kbd_put_keycode(keycode | 0x80); 1148 } 1149 1150 /* release Mouse grab when pressing ctrl+alt */ 1151 if ((![pc fullscreen]) && ([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) 1152 [pc ungrabMouse]; 1153 } 1154 break; 1155 1156 case NSKeyDown: 1157 { 1158 int keycode = cocoa_keycode_to_qemu([event keyCode]); 1159 1160 /* handle command Key Combos */ 1161 if ([event modifierFlags] & NSCommandKeyMask) { 1162 switch ([event keyCode]) { 1163 1164 /* toggle fullscreen */ 1165 case 3: /* f key */ 1166 // show hint to exit fullscreen, fast os switch, toolbar 1167 if(![pc fullscreen]) { 1168 #if kju_debug 1169 NSLog(@"init FSController"); 1170 #endif 1171 NSBeginAlertSheet(NSLocalizedStringFromTable(@"cocoa_refresh:showFullscreen:standardAlert", @"Localizable", @"cocoaQemu"),NSLocalizedStringFromTable(@"cocoa_refresh:showFullscreen:defaultButton", @"Localizable", @"cocoaQemu"),nil,nil,[pc pcWindow],pc,@selector(showFullscreenAlertSheetDidEnd:returnCode:contextInfo:),nil,nil,NSLocalizedStringFromTable(@"cocoa_refresh:showFullscreen:informativeText", @"Localizable", @"cocoaQemu")); 1172 [pc setFullscreenController:[[FSController alloc] initWithSender:pc]]; 1173 } else { 1174 #if kju_debug 1175 NSLog(@"release FSController"); 1176 #endif 1177 [pc setFullscreen:[[pc contentView] toggleFullScreen]]; 1178 [[pc fullscreenController] release]; 1179 } 1180 return; 1181 1182 // /* paste text in Host Clipboard to Guest */ 1183 // case 9: /* v key */ 1184 // { 1185 // NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; 1186 // NSString *string = [NSString stringWithString:[pasteboard stringForType:NSStringPboardType]]; 1187 // if (string) { 1188 // NSLog(@"PASTE: %@", string); 1189 // int ii; 1190 // int maxChars = 24; 1191 // if ([string length] < maxChars) 1192 // maxChars = [string length]; 1193 // for (ii=0; ii<maxChars; ii++) { 1194 // /* keycode */ 1195 // keycode = keysym2scancode(kbd_layout, [string characterAtIndex:ii]); 1208 1196 // 1209 // if (keycode!=0) {1210 // /* key down events */1211 // if (keycode & 0x80)1212 // kbd_put_keycode(0xe0);1213 // kbd_put_keycode(keycode & 0x7f);1214 // 1215 // /* key up events */1216 // if (keycode & 0x80)1217 // kbd_put_keycode(0xe0);1218 // kbd_put_keycode(keycode | 0x80);1219 // }1220 // }1221 // [string release];1222 // }1223 // return;1224 // }1225 1226 /* quit */1227 case 12: /* q key */1228 /* switch to windowed View */1229 if ([pc fullscreen]) {1230 [pc setFullscreen:[[pc contentView] toggleFullScreen]];1231 [[pc fullscreenController] release];1232 }1233 [[pc pcWindow] performClose:nil];1234 return;1235 1236 /* minimize Window */1237 case 46: /* m key */1238 if ([pc fullscreen])1239 [pc setFullscreen:[[pc contentView] toggleFullScreen]];1240 [[pc pcWindow] miniaturize:nil];1241 return;1242 1243 // /* app switch *//* does not work, as dock is ogging command-tab */1244 // case 48: /* tab key */1245 // if ([pc fullscreen])1246 // [pc setFullscreen:[[pc contentView] toggleFullScreen]];1247 // return;1248 1249 /* window switch */1250 case 50: /* backquote key */1251 if ([event modifierFlags] & NSShiftKeyMask) { /* previous Window */1197 // if (keycode!=0) { 1198 // /* key down events */ 1199 // if (keycode & 0x80) 1200 // kbd_put_keycode(0xe0); 1201 // kbd_put_keycode(keycode & 0x7f); 1202 // 1203 // /* key up events */ 1204 // if (keycode & 0x80) 1205 // kbd_put_keycode(0xe0); 1206 // kbd_put_keycode(keycode | 0x80); 1207 // } 1208 // } 1209 // [string release]; 1210 // } 1211 // return; 1212 // } 1213 1214 /* quit */ 1215 case 12: /* q key */ 1216 /* switch to windowed View */ 1217 if ([pc fullscreen]) { 1218 [pc setFullscreen:[[pc contentView] toggleFullScreen]]; 1219 [[pc fullscreenController] release]; 1220 } 1221 [[pc pcWindow] performClose:nil]; 1222 return; 1223 1224 /* minimize Window */ 1225 case 46: /* m key */ 1226 if ([pc fullscreen]) 1227 [pc setFullscreen:[[pc contentView] toggleFullScreen]]; 1228 [[pc pcWindow] miniaturize:nil]; 1229 return; 1230 1231 // /* app switch *//* does not work, as dock is ogging command-tab */ 1232 // case 48: /* tab key */ 1233 // if ([pc fullscreen]) 1234 // [pc setFullscreen:[[pc contentView] toggleFullScreen]]; 1235 // return; 1236 1237 /* window switch */ 1238 case 50: /* backquote key */ 1239 if ([event modifierFlags] & NSShiftKeyMask) { /* previous Window */ 1252 1240 if ([[pc qdoserver] guestSwitch:[pc pcName] fullscreen:[pc fullscreen] previousGuestName:nil]) 1253 1241 return; … … 1260 1248 break; 1261 1249 } 1250 1262 1251 /* fullscreen toolbar */ 1263 1252 case 11: /* B-key */ … … 1268 1257 break; 1269 1258 } 1270 } 1271 } 1272 1273 /* handle control + alt Key Combos */ 1274 if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { 1275 switch (keycode) { 1276 /* toggle Monitor */ 1277 case 0x02 ... 0x0a: /* '1' to '9' keys */ 1278 { 1259 1260 } 1261 } 1262 1263 /* handle control + alt Key Combos */ 1264 if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { 1265 switch (keycode) { 1266 /* toggle Monitor */ 1267 case 0x02 ... 0x0a: /* '1' to '9' keys */ 1268 { 1279 1269 /* setup transition */ 1280 1270 CGSConnection cid = _CGSDefaultConnection(); 1281 1271 int transitionHandle = -1; 1282 1272 CGSTransitionSpec transitionSpecifications; 1283 1273 1284 1274 transitionSpecifications.type = 9; //transition; 1285 1275 if (keycode - 0x02 == 0) … … 1289 1279 transitionSpecifications.wid = [[pc pcWindow] windowNumber]; //wid 1290 1280 transitionSpecifications.backColour = 0; //background color 1291 1281 1292 1282 /* freeze desktop: OSStatus CGSNewTransition(const CGSConnection cid, const CGSTransitionSpec* transitionSpecifications, int *transitionHandle) */ 1293 1283 CGSNewTransition(cid, &transitionSpecifications, &transitionHandle); 1294 1284 1295 1285 /* change monitor */ 1296 1286 console_select(keycode - 0x02); 1297 1287 vga_hw_update(); 1298 1288 1299 1289 /* wait */ 1300 1290 usleep(10000); 1301 1291 1302 1292 /* run transition: OSStatus CGSInvokeTransition(const CGSConnection cid, int transitionHandle, float duration) */ 1303 1293 CGSInvokeTransition(cid, transitionHandle, 1.0); 1304 1294 1305 1295 break; 1306 1296 } 1307 // console_select(keycode - 0x02);1308 // break;1309 /* toggle Fullscreen */1310 case 0x21: /* 'f' key */1311 // show hint to exit fullscreen, fast os switch, toolbar1312 if(![pc fullscreen]) {1313 NSBeginAlertSheet(NSLocalizedStringFromTable(@"cocoa_refresh:showFullscreen:standardAlert", @"Localizable", @"cocoaQemu"),NSLocalizedStringFromTable(@"cocoa_refresh:showFullscreen:defaultButton", @"Localizable", @"cocoaQemu"),nil,nil,[pc pcWindow],pc,@selector(showFullscreenAlertSheetDidEnd:returnCode:contextInfo:),nil,nil,NSLocalizedStringFromTable(@"cocoa_refresh:showFullscreen:informativeText", @"Localizable", @"cocoaQemu"));1314 } else {1315 [pc setFullscreen:[[pc contentView] toggleFullScreen]];1316 }1317 break;1318 }1319 } else {1320 /* handle standard key events */1321 if (is_graphic_console()) {1322 if (keycode & 0x80) //check bit for e0 in front1323 kbd_put_keycode(0xe0);1324 kbd_put_keycode(keycode & 0x7f); //remove e0 bit in front1325 /* handle monitor key events */1326 } else {1327 switch([event keyCode]) {1328 case 123:1329 kbd_put_keysym(QEMU_KEY_LEFT);1330 break;1331 case 124:1332 kbd_put_keysym(QEMU_KEY_RIGHT);1333 break;1334 case 125:1335 kbd_put_keysym(QEMU_KEY_DOWN);1336 break;1337 case 126:1338 kbd_put_keysym(QEMU_KEY_UP);1339 break;1340 default:1341 {1342 NSString *ks = [event characters];1343 if ([ks length] > 0)1344 kbd_put_keysym([ks characterAtIndex:0]);1345 }1346 }1347 }1348 }1349 }1350 break;1351 1352 case NSKeyUp:1353 {1354 int keycode = cocoa_keycode_to_qemu([event keyCode]);1355 if (is_graphic_console()) {1356 if (keycode & 0x80)1357 kbd_put_keycode(0xe0);1358 kbd_put_keycode(keycode | 0x80); //add 128 to signal release of key1359 }1360 }1361 break;1362 1363 case NSMouseMoved:1364 if ([pc absolute_enabled]) {1365 NSPoint p = [event locationInWindow];1366 if (p.x < 0 || p.x > ds->width || p.y < 0 || p.y > ds->height || ![[pc pcWindow] isKeyWindow]) {1367 if ([pc tablet_enabled])1368 [NSCursor unhide];1369 [pc setTablet_enabled:0];1370 } else {1371 if (![pc tablet_enabled])1372 [NSCursor hide];1373 [pc setTablet_enabled:1];1374 int dx = p.x * 0x7FFF / ds->width;1375 int dy = (ds->height - p.y) * 0x7FFF / ds->height;1376 int dz = [event deltaZ];1377 int buttons = 0;1378 kbd_mouse_event(dx, dy, dz, buttons);1379 }1380 } else if ([pc grab]) {1381 int dx = [event deltaX];1382 int dy = [event deltaY];1383 int dz = [event deltaZ];1384 int buttons = 0;1385 kbd_mouse_event(dx, dy, dz, buttons);1386 }1387 break;1388 1389 case NSLeftMouseDown:1390 if ([pc grab]||[pc tablet_enabled]) {1391 int buttons = 0;1392 1393 /* leftclick+command simulates rightclick */1394 &nbs
