static void toggle_full_screen(DisplayState *ds) { gui_fullscreen = !gui_fullscreen; if (gui_fullscreen) { gui_saved_width = real_screen->w; gui_saved_height = real_screen->h; gui_saved_scaling = scaling_active; do_sdl_resize(ds_get_width(ds), ds_get_height(ds), ds_get_bits_per_pixel(ds)); scaling_active = 0; gui_saved_grab = gui_grab; sdl_grab_start(); } else { if (gui_saved_scaling) { sdl_scale(ds, gui_saved_width, gui_saved_height); } else { do_sdl_resize(ds_get_width(ds), ds_get_height(ds), 0); } if (!gui_saved_grab || !is_graphic_console()) { sdl_grab_end(); } } vga_hw_invalidate(); vga_hw_update(); }
static void toggle_full_screen(void) { int width = surface_width(surface); int height = surface_height(surface); int bpp = surface_bits_per_pixel(surface); gui_fullscreen = !gui_fullscreen; if (gui_fullscreen) { gui_saved_width = real_screen->w; gui_saved_height = real_screen->h; gui_saved_scaling = scaling_active; do_sdl_resize(width, height, bpp); scaling_active = 0; gui_saved_grab = gui_grab; sdl_grab_start(); } else { if (gui_saved_scaling) { sdl_scale(gui_saved_width, gui_saved_height); } else { do_sdl_resize(width, height, 0); } if (!gui_saved_grab || !qemu_console_is_graphic(NULL)) { sdl_grab_end(); } } graphic_hw_invalidate(NULL); graphic_hw_update(NULL); }
static void handle_keydown(DisplayState *ds, SDL_Event *ev) { int mod_state; int keycode; if (alt_grab) { mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) == (gui_grab_code | KMOD_LSHIFT); } else if (ctrl_grab) { mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL; } else { mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code; } gui_key_modifier_pressed = mod_state; if (gui_key_modifier_pressed) { keycode = sdl_keyevent_to_keycode(&ev->key); switch (keycode) { case 0x21: /* 'f' key on US keyboard */ toggle_full_screen(ds); gui_keysym = 1; break; case 0x16: /* 'u' key on US keyboard */ if (scaling_active) { scaling_active = 0; sdl_resize(ds); vga_hw_invalidate(); vga_hw_update(); } gui_keysym = 1; break; case 0x02 ... 0x0a: /* '1' to '9' keys */ /* Reset the modifiers sent to the current console */ reset_keys(); console_select(keycode - 0x02); gui_keysym = 1; if (gui_fullscreen) { break; } if (!is_graphic_console()) { /* release grab if going to a text console */ if (gui_grab) { sdl_grab_end(); } else if (absolute_enabled) { sdl_show_cursor(); } } else if (absolute_enabled) { sdl_hide_cursor(); absolute_mouse_grab(); } break; case 0x1b: /* '+' */ case 0x35: /* '-' */ if (!gui_fullscreen) { int width = MAX(real_screen->w + (keycode == 0x1b ? 50 : -50), 160); int height = (ds_get_height(ds) * width) / ds_get_width(ds); sdl_scale(ds, width, height); vga_hw_invalidate(); vga_hw_update(); gui_keysym = 1; } default: break; } } else if (!is_graphic_console()) {
static void handle_keydown(DisplayState *ds, SDL_Event *ev) { int mod_state; int keycode; if (alt_grab) { // LOGV("Found alt grab\n"); mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) == (gui_grab_code | KMOD_LSHIFT); } else if (ctrl_grab) { // LOGV("Found ctrl grab\n"); mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL; } else { // LOGV("Default grab\n"); mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code; } gui_key_modifier_pressed = mod_state; if (gui_key_modifier_pressed) { keycode = sdl_keyevent_to_keycode(&ev->key); // LOGV("Found modifier pressed for key/keycode = %d/%d\n", ev->key.keysym.sym, keycode); switch (keycode) { case 1: /* 'f' key on US keyboard */ LOGV("Keycode Pressed 'f' Fullscreen\n"); toggle_full_screen(ds); gui_keysym = 1; break; case 16: /* 'u' key on US keyboard */ LOGV("Keycode Pressed 'u' unset Scale\n"); if (scaling_active) { LOGV("Found scaling active Unsetting...\n"); scaling_active = 0; sdl_resize(ds); vga_hw_invalidate(); vga_hw_update(); reset_keys(); } gui_keysym = 1; break; case 22 ... 23: /* '1' to '9' keys */ //MK hack /* Reset the modifiers sent to the current console */ LOGV("Keycode Pressed '1-9' console\n"); reset_keys(); console_select(keycode - 22); gui_keysym = 1; // if (gui_fullscreen) { // LOGV("Found fullscreen breaking...\n"); // break; // } if (!is_graphic_console()) { /* release grab if going to a text console */ LOGV("Found text console releasing grab...\n"); if (gui_grab) { LOGV("Found grab, grab ending...\n"); sdl_grab_end(); } else if (absolute_enabled) { LOGV("Found absolute_enabled, show cursor...\n"); sdl_show_cursor(); } } else if (absolute_enabled) { LOGV("Found absolute_enabled, hiding cursor and grabing mouse...\n"); sdl_hide_cursor(); absolute_mouse_grab(); } break; case 24: /* '4' Zoom In */ case 25: /* '3' Zoom Out*/ LOGV("Keycode Pressed '3/4' Zoom\n"); // if (!gui_fullscreen) { { int width = MAX(real_screen->w + (keycode == 25 ? 50 : -50), 160); int height = (ds_get_height(ds) * width) / ds_get_width(ds); LOGV("Found no fullscreen, scaling to: %dx%d \n", width, height); sdl_scale(ds, width, height); vga_hw_invalidate(); vga_hw_update(); reset_keys(); gui_keysym = 1; } // } break; case 26: /* Fit to Screen */ LOGV("Keycode Pressed '5' Fit to Screen\n"); // if (!gui_fullscreen) { { int width; int height; AndroidGetWindowSize(&width, &height); LOGV("Got Android window size=%dx%d", width, height); LOGV("Got VM resolution=%dx%d", ds_get_width(ds), ds_get_height(ds)); float aspectRatio = (float) ds_get_height(ds) / (float) ds_get_width(ds); LOGV("Got aspectRatio=%f", aspectRatio); int new_width = (int) (height / aspectRatio); if(new_width > width){ LOGV("Width is overrun, modifying height"); new_width = width; height = width * aspectRatio; } LOGV("Found no fullscreen, Fit To Screen: %dx%d \n", new_width, height); sdl_scale(ds, new_width, height); vga_hw_invalidate(); vga_hw_update(); reset_keys(); gui_keysym = 1; } // } break; case 27: /* Stretch to Screen */ LOGV("Keycode Pressed '6' Fit to Screen\n"); // if (!gui_fullscreen) { { int width; int height; AndroidGetWindowSize(&width, &height); LOGV("Found no fullscreen, Fit To Screen: %dx%d \n", width, height); sdl_scale(ds, width, height); vga_hw_invalidate(); vga_hw_update(); reset_keys(); gui_keysym = 1; } // } break; default: LOGV("Default\n"); break; } } else if (!is_graphic_console()) {