Commit 457831f4bcf20d1fd5d80d7a0b946bdaf6f56059

Authored by bellard
1 parent 2571929a

virtual console support


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1022 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 65 additions and 11 deletions
... ... @@ -65,6 +65,8 @@ static void sdl_resize(DisplayState *ds, int w, int h)
65 65 ds->data = screen->pixels;
66 66 ds->linesize = screen->pitch;
67 67 ds->depth = screen->format->BitsPerPixel;
  68 + ds->width = w;
  69 + ds->height = h;
68 70 }
69 71  
70 72 #ifdef CONFIG_SDL_GENERIC_KBD
... ... @@ -408,7 +410,9 @@ static void sdl_refresh(DisplayState *ds)
408 410 sdl_update_caption();
409 411 }
410 412  
411   - vga_update_display();
  413 + if (is_active_console(vga_console))
  414 + vga_update_display();
  415 +
412 416 while (SDL_PollEvent(ev)) {
413 417 switch (ev->type) {
414 418 case SDL_VIDEOEXPOSE:
... ... @@ -420,19 +424,68 @@ static void sdl_refresh(DisplayState *ds)
420 424 mod_state = (SDL_GetModState() & (KMOD_LSHIFT | KMOD_LCTRL)) ==
421 425 (KMOD_LSHIFT | KMOD_LCTRL);
422 426 gui_key_modifier_pressed = mod_state;
423   - if (gui_key_modifier_pressed &&
424   - ev->key.keysym.sym == SDLK_f) {
425   - gui_keysym = ev->key.keysym.sym;
  427 + if (gui_key_modifier_pressed) {
  428 + switch(ev->key.keysym.sym) {
  429 + case SDLK_f:
  430 + toggle_full_screen(ds);
  431 + gui_keysym = 1;
  432 + break;
  433 + case SDLK_F1 ... SDLK_F12:
  434 + console_select(ev->key.keysym.sym - SDLK_F1);
  435 + if (is_active_console(vga_console)) {
  436 + /* tell the vga console to redisplay itself */
  437 + vga_invalidate_display();
  438 + } else {
  439 + /* display grab if going to a text console */
  440 + if (gui_grab)
  441 + sdl_grab_end();
  442 + }
  443 + gui_keysym = 1;
  444 + break;
  445 + default:
  446 + break;
  447 + }
  448 + }
  449 + if (!is_active_console(vga_console)) {
  450 + int keysym;
  451 + keysym = 0;
  452 + if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
  453 + switch(ev->key.keysym.sym) {
  454 + case SDLK_UP: keysym = QEMU_KEY_CTRL_UP; break;
  455 + case SDLK_DOWN: keysym = QEMU_KEY_CTRL_DOWN; break;
  456 + case SDLK_LEFT: keysym = QEMU_KEY_CTRL_LEFT; break;
  457 + case SDLK_RIGHT: keysym = QEMU_KEY_CTRL_RIGHT; break;
  458 + case SDLK_HOME: keysym = QEMU_KEY_CTRL_HOME; break;
  459 + case SDLK_END: keysym = QEMU_KEY_CTRL_END; break;
  460 + case SDLK_PAGEUP: keysym = QEMU_KEY_CTRL_PAGEUP; break;
  461 + case SDLK_PAGEDOWN: keysym = QEMU_KEY_CTRL_PAGEDOWN; break;
  462 + default: break;
  463 + }
  464 + } else {
  465 + switch(ev->key.keysym.sym) {
  466 + case SDLK_UP: keysym = QEMU_KEY_UP; break;
  467 + case SDLK_DOWN: keysym = QEMU_KEY_DOWN; break;
  468 + case SDLK_LEFT: keysym = QEMU_KEY_LEFT; break;
  469 + case SDLK_RIGHT: keysym = QEMU_KEY_RIGHT; break;
  470 + case SDLK_HOME: keysym = QEMU_KEY_HOME; break;
  471 + case SDLK_END: keysym = QEMU_KEY_END; break;
  472 + case SDLK_PAGEUP: keysym = QEMU_KEY_PAGEUP; break;
  473 + case SDLK_PAGEDOWN: keysym = QEMU_KEY_PAGEDOWN; break;
  474 + case SDLK_BACKSPACE: keysym = QEMU_KEY_BACKSPACE; break; case SDLK_DELETE: keysym = QEMU_KEY_DELETE; break;
  475 + default: break;
  476 + }
  477 + }
  478 + if (keysym) {
  479 + kbd_put_keysym(keysym);
  480 + } else if (ev->key.keysym.unicode != 0) {
  481 + kbd_put_keysym(ev->key.keysym.unicode);
  482 + }
426 483 }
427 484 } else if (ev->type == SDL_KEYUP) {
428 485 mod_state = (SDL_GetModState() & (KMOD_LSHIFT | KMOD_LCTRL));
429 486 if (!mod_state) {
430 487 if (gui_key_modifier_pressed) {
431   - switch(gui_keysym) {
432   - case SDLK_f:
433   - toggle_full_screen(ds);
434   - break;
435   - case 0:
  488 + if (gui_keysym == 0) {
436 489 /* exit/enter grab if pressing Ctrl-Shift */
437 490 if (!gui_grab)
438 491 sdl_grab_start();
... ... @@ -445,7 +498,8 @@ static void sdl_refresh(DisplayState *ds)
445 498 }
446 499 }
447 500 }
448   - sdl_process_key(&ev->key);
  501 + if (is_active_console(vga_console))
  502 + sdl_process_key(&ev->key);
449 503 break;
450 504 case SDL_QUIT:
451 505 qemu_system_shutdown_request();
... ... @@ -495,7 +549,6 @@ void sdl_display_init(DisplayState *ds)
495 549 fprintf(stderr, "Could not initialize SDL - exiting\n");
496 550 exit(1);
497 551 }
498   -
499 552 #ifndef _WIN32
500 553 /* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */
501 554 signal(SIGINT, SIG_DFL);
... ... @@ -509,6 +562,7 @@ void sdl_display_init(DisplayState *ds)
509 562 sdl_resize(ds, 640, 400);
510 563 sdl_update_caption();
511 564 SDL_EnableKeyRepeat(250, 50);
  565 + SDL_EnableUNICODE(1);
512 566 gui_grab = 0;
513 567  
514 568 atexit(sdl_cleanup);
... ...