static void curses_refresh(DisplayChangeListener *dcl) { int chr, nextchr, keysym, keycode, keycode_alt; if (invalidate) { clear(); refresh(); curses_calc_pad(); vga_hw_invalidate(); invalidate = 0; } vga_hw_text_update(screen); nextchr = ERR; while (1) { /* while there are any pending key strokes to process */ if (nextchr == ERR) chr = getch(); else { chr = nextchr; nextchr = ERR; } if (chr == ERR) break; #ifdef KEY_RESIZE /* this shouldn't occur when we use a custom SIGWINCH handler */ if (chr == KEY_RESIZE) { clear(); refresh(); curses_calc_pad(); curses_update(dcl, 0, 0, width, height); continue; } #endif keycode = curses2keycode[chr]; keycode_alt = 0; /* alt key */ if (keycode == 1) { nextchr = getch(); if (nextchr != ERR) { chr = nextchr; keycode_alt = ALT; keycode = curses2keycode[nextchr]; nextchr = ERR; if (keycode != -1) { keycode |= ALT; /* process keys reserved for qemu */ if (keycode >= QEMU_KEY_CONSOLE0 && keycode < QEMU_KEY_CONSOLE0 + 9) { erase(); wnoutrefresh(stdscr); console_select(keycode - QEMU_KEY_CONSOLE0); invalidate = 1; continue; } } } } if (kbd_layout) { keysym = -1; if (chr < CURSES_KEYS) keysym = curses2keysym[chr]; if (keysym == -1) { if (chr < ' ') { keysym = chr + '@'; if (keysym >= 'A' && keysym <= 'Z') keysym += 'a' - 'A'; keysym |= KEYSYM_CNTRL; } else keysym = chr; } keycode = keysym2scancode(kbd_layout, keysym & KEYSYM_MASK); if (keycode == 0) continue; keycode |= (keysym & ~KEYSYM_MASK) >> 16; keycode |= keycode_alt; } if (keycode == -1) continue; if (is_graphic_console()) { /* since terminals don't know about key press and release * events, we need to emit both for each key received */ if (keycode & SHIFT) kbd_put_keycode(SHIFT_CODE); if (keycode & CNTRL) kbd_put_keycode(CNTRL_CODE); if (keycode & ALT) kbd_put_keycode(ALT_CODE); if (keycode & ALTGR) { kbd_put_keycode(SCANCODE_EMUL0); kbd_put_keycode(ALT_CODE); } if (keycode & GREY) kbd_put_keycode(GREY_CODE); kbd_put_keycode(keycode & KEY_MASK); if (keycode & GREY) kbd_put_keycode(GREY_CODE); kbd_put_keycode((keycode & KEY_MASK) | KEY_RELEASE); if (keycode & ALTGR) { kbd_put_keycode(SCANCODE_EMUL0); kbd_put_keycode(ALT_CODE | KEY_RELEASE); } if (keycode & ALT) kbd_put_keycode(ALT_CODE | KEY_RELEASE); if (keycode & CNTRL) kbd_put_keycode(CNTRL_CODE | KEY_RELEASE); if (keycode & SHIFT) kbd_put_keycode(SHIFT_CODE | KEY_RELEASE); } else { keysym = curses2qemu[chr]; if (keysym == -1) keysym = chr; kbd_put_keysym(keysym); } } }
static void sdl_refresh(DisplayState *ds) { SDL_Event ev1, *ev = &ev1; int mod_state; if (last_vm_running != vm_running) { last_vm_running = vm_running; sdl_update_caption(); } vga_hw_update(); while (SDL_PollEvent(ev)) { switch (ev->type) { case SDL_VIDEOEXPOSE: sdl_update(ds, 0, 0, screen->w, screen->h); break; case SDL_KEYDOWN: case SDL_KEYUP: if (ev->type == SDL_KEYDOWN) { if (!alt_grab) { mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code; } else { mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) == (gui_grab_code | KMOD_LSHIFT); } gui_key_modifier_pressed = mod_state; if (gui_key_modifier_pressed) { int keycode; 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 0x02 ... 0x0a: /* '1' to '9' keys */ /* Reset the modifiers sent to the current console */ reset_keys(); console_select(keycode - 0x02); if (!is_graphic_console()) { /* display grab if going to a text console */ if (gui_grab) sdl_grab_end(); } gui_keysym = 1; break; default: break; } } else if (!is_graphic_console()) { int keysym; keysym = 0; if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) { switch(ev->key.keysym.sym) { case SDLK_UP: keysym = QEMU_KEY_CTRL_UP; break; case SDLK_DOWN: keysym = QEMU_KEY_CTRL_DOWN; break; case SDLK_LEFT: keysym = QEMU_KEY_CTRL_LEFT; break; case SDLK_RIGHT: keysym = QEMU_KEY_CTRL_RIGHT; break; case SDLK_HOME: keysym = QEMU_KEY_CTRL_HOME; break; case SDLK_END: keysym = QEMU_KEY_CTRL_END; break; case SDLK_PAGEUP: keysym = QEMU_KEY_CTRL_PAGEUP; break; case SDLK_PAGEDOWN: keysym = QEMU_KEY_CTRL_PAGEDOWN; break; default: break; } } else { switch(ev->key.keysym.sym) { case SDLK_UP: keysym = QEMU_KEY_UP; break; case SDLK_DOWN: keysym = QEMU_KEY_DOWN; break; case SDLK_LEFT: keysym = QEMU_KEY_LEFT; break; case SDLK_RIGHT: keysym = QEMU_KEY_RIGHT; break; case SDLK_HOME: keysym = QEMU_KEY_HOME; break; case SDLK_END: keysym = QEMU_KEY_END; break; case SDLK_PAGEUP: keysym = QEMU_KEY_PAGEUP; break; case SDLK_PAGEDOWN: keysym = QEMU_KEY_PAGEDOWN; break; case SDLK_BACKSPACE: keysym = QEMU_KEY_BACKSPACE; break; case SDLK_DELETE: keysym = QEMU_KEY_DELETE; break; default: break; } } if (keysym) { kbd_put_keysym(keysym); } else if (ev->key.keysym.unicode != 0) { kbd_put_keysym(ev->key.keysym.unicode); } } } else if (ev->type == SDL_KEYUP) { if (!alt_grab) { mod_state = (ev->key.keysym.mod & gui_grab_code); } else { mod_state = (ev->key.keysym.mod & (gui_grab_code | KMOD_LSHIFT)); } if (!mod_state) { if (gui_key_modifier_pressed) { gui_key_modifier_pressed = 0; if (gui_keysym == 0) { /* exit/enter grab if pressing Ctrl-Alt */ if (!gui_grab) { /* if the application is not active, do not try to enter grab state. It prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the application (SDL bug). */ if (SDL_GetAppState() & SDL_APPACTIVE) sdl_grab_start(); } else { sdl_grab_end(); } /* SDL does not send back all the modifiers key, so we must correct it */ reset_keys(); break; } gui_keysym = 0; } } } if (is_graphic_console() && !gui_keysym) sdl_process_key(&ev->key); break; case SDL_QUIT: if (!no_quit) { qemu_system_shutdown_request(); vm_start(); /* In case we're paused */ } break; case SDL_MOUSEMOTION: if (gui_grab || kbd_mouse_is_absolute() || absolute_enabled) { sdl_send_mouse_event(0); } break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { SDL_MouseButtonEvent *bev = &ev->button; if (!gui_grab && !kbd_mouse_is_absolute()) { if (ev->type == SDL_MOUSEBUTTONDOWN && (bev->state & SDL_BUTTON_LMASK)) { /* start grabbing all events */ sdl_grab_start(); } } else { int dz; dz = 0; #ifdef SDL_BUTTON_WHEELUP if (bev->button == SDL_BUTTON_WHEELUP && ev->type == SDL_MOUSEBUTTONDOWN) { dz = -1; } else if (bev->button == SDL_BUTTON_WHEELDOWN && ev->type == SDL_MOUSEBUTTONDOWN) { dz = 1; } #endif sdl_send_mouse_event(dz); } } break; case SDL_ACTIVEEVENT: if (gui_grab && ev->active.state == SDL_APPINPUTFOCUS && !ev->active.gain && !gui_fullscreen_initial_grab) { sdl_grab_end(); } break; default: break; }
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 curses_refresh(DisplayChangeListener *dcl) { int chr, keysym, keycode, keycode_alt; curses_winch_check(); if (invalidate) { clear(); refresh(); curses_calc_pad(); graphic_hw_invalidate(NULL); invalidate = 0; } graphic_hw_text_update(NULL, screen); while (1) { /* while there are any pending key strokes to process */ chr = getch(); if (chr == ERR) break; #ifdef KEY_RESIZE /* this shouldn't occur when we use a custom SIGWINCH handler */ if (chr == KEY_RESIZE) { clear(); refresh(); curses_calc_pad(); curses_update(dcl, 0, 0, width, height); continue; } #endif keycode = curses2keycode[chr]; keycode_alt = 0; /* alt key */ if (keycode == 1) { int nextchr = getch(); if (nextchr != ERR) { chr = nextchr; keycode_alt = ALT; keycode = curses2keycode[chr]; if (keycode != -1) { keycode |= ALT; /* process keys reserved for qemu */ if (keycode >= QEMU_KEY_CONSOLE0 && keycode < QEMU_KEY_CONSOLE0 + 9) { erase(); wnoutrefresh(stdscr); console_select(keycode - QEMU_KEY_CONSOLE0); invalidate = 1; continue; } } } } if (kbd_layout) { keysym = -1; if (chr < CURSES_KEYS) keysym = curses2keysym[chr]; if (keysym == -1) { if (chr < ' ') { keysym = chr + '@'; if (keysym >= 'A' && keysym <= 'Z') keysym += 'a' - 'A'; keysym |= KEYSYM_CNTRL; } else keysym = chr; } keycode = keysym2scancode(kbd_layout, keysym & KEYSYM_MASK, false, false, false); if (keycode == 0) continue; keycode |= (keysym & ~KEYSYM_MASK) >> 16; keycode |= keycode_alt; } if (keycode == -1) continue; if (qemu_console_is_graphic(NULL)) { /* since terminals don't know about key press and release * events, we need to emit both for each key received */ if (keycode & SHIFT) { qemu_input_event_send_key_number(NULL, SHIFT_CODE, true); qemu_input_event_send_key_delay(0); } if (keycode & CNTRL) { qemu_input_event_send_key_number(NULL, CNTRL_CODE, true); qemu_input_event_send_key_delay(0); } if (keycode & ALT) { qemu_input_event_send_key_number(NULL, ALT_CODE, true); qemu_input_event_send_key_delay(0); } if (keycode & ALTGR) { qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, true); qemu_input_event_send_key_delay(0); } qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, true); qemu_input_event_send_key_delay(0); qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, false); qemu_input_event_send_key_delay(0); if (keycode & ALTGR) { qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, false); qemu_input_event_send_key_delay(0); } if (keycode & ALT) { qemu_input_event_send_key_number(NULL, ALT_CODE, false); qemu_input_event_send_key_delay(0); } if (keycode & CNTRL) { qemu_input_event_send_key_number(NULL, CNTRL_CODE, false); qemu_input_event_send_key_delay(0); } if (keycode & SHIFT) { qemu_input_event_send_key_number(NULL, SHIFT_CODE, false); qemu_input_event_send_key_delay(0); } } else { keysym = -1; if (chr < CURSES_KEYS) { keysym = curses2qemu[chr]; } if (keysym == -1) keysym = chr; kbd_put_keysym(keysym); } } }
static void curses_refresh(DisplayState *ds) { int chr, nextchr, keysym, keycode; if (invalidate) { clear(); refresh(); curses_calc_pad(); ds->surface->width = FONT_WIDTH * width; ds->surface->height = FONT_HEIGHT * height; vga_hw_invalidate(); invalidate = 0; } vga_hw_text_update(screen); nextchr = ERR; while (1) { /* while there are any pending key strokes to process */ if (nextchr == ERR) chr = getch(); else { chr = nextchr; nextchr = ERR; } if (chr == ERR) break; #ifdef KEY_RESIZE /* this shouldn't occur when we use a custom SIGWINCH handler */ if (chr == KEY_RESIZE) { clear(); refresh(); curses_calc_pad(); curses_update(ds, 0, 0, width, height); ds->surface->width = FONT_WIDTH * width; ds->surface->height = FONT_HEIGHT * height; continue; } #endif keycode = curses2keycode[chr]; if (keycode == -1) continue; /* alt key */ if (keycode == 1) { nextchr = getch(); if (nextchr != ERR) { keycode = curses2keycode[nextchr]; nextchr = ERR; if (keycode == -1) continue; keycode |= ALT; /* process keys reserved for qemu */ if (keycode >= QEMU_KEY_CONSOLE0 && keycode < QEMU_KEY_CONSOLE0 + 9) { erase(); wnoutrefresh(stdscr); console_select(keycode - QEMU_KEY_CONSOLE0); invalidate = 1; continue; } } } if (kbd_layout && !(keycode & GREY)) { keysym = keycode2keysym[keycode & KEY_MASK]; if (keysym == -1) keysym = chr; keycode &= ~KEY_MASK; keycode |= keysym2scancode(kbd_layout, keysym); } if (is_graphic_console()) { /* since terminals don't know about key press and release * events, we need to emit both for each key received */ if (keycode & SHIFT) kbd_put_keycode(SHIFT_CODE); if (keycode & CNTRL) kbd_put_keycode(CNTRL_CODE); if (keycode & ALT) kbd_put_keycode(ALT_CODE); if (keycode & GREY) kbd_put_keycode(GREY_CODE); kbd_put_keycode(keycode & KEY_MASK); if (keycode & GREY) kbd_put_keycode(GREY_CODE); kbd_put_keycode((keycode & KEY_MASK) | KEY_RELEASE); if (keycode & ALT) kbd_put_keycode(ALT_CODE | KEY_RELEASE); if (keycode & CNTRL) kbd_put_keycode(CNTRL_CODE | KEY_RELEASE); if (keycode & SHIFT) kbd_put_keycode(SHIFT_CODE | KEY_RELEASE); } else { keysym = curses2keysym[chr]; if (keysym == -1) keysym = chr; kbd_put_keysym(keysym); } } }
static void sdl_refresh(DisplayState *ds) { SDL_Event ev1, *ev = &ev1; int mod_state; int buttonstate = SDL_GetMouseState(NULL, NULL); if (last_vm_running != vm_running) { last_vm_running = vm_running; sdl_update_caption(); } vga_hw_update(); SDL_EnableUNICODE(!is_graphic_console()); while (SDL_PollEvent(ev)) { switch (ev->type) { case SDL_VIDEOEXPOSE: sdl_update(ds, 0, 0, real_screen->w, real_screen->h); break; case SDL_KEYDOWN: case SDL_KEYUP: if (ev->type == SDL_KEYDOWN) { 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) { int keycode; 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 */ scaling_active = 0; sdl_resize(ds); vga_hw_invalidate(); vga_hw_update(); break; case 0x02 ... 0x0a: /* '1' to '9' keys */ /* Reset the modifiers sent to the current console */ reset_keys(); console_select(keycode - 0x02); if (!is_graphic_console()) { /* display grab if going to a text console */ if (gui_grab) sdl_grab_end(); } gui_keysym = 1; break; default: break; } } else if (!is_graphic_console()) { int keysym; keysym = 0; if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) { switch(ev->key.keysym.sym) { case SDLK_UP: keysym = QEMU_KEY_CTRL_UP; break; case SDLK_DOWN: keysym = QEMU_KEY_CTRL_DOWN; break; case SDLK_LEFT: keysym = QEMU_KEY_CTRL_LEFT; break; case SDLK_RIGHT: keysym = QEMU_KEY_CTRL_RIGHT; break; case SDLK_HOME: keysym = QEMU_KEY_CTRL_HOME; break; case SDLK_END: keysym = QEMU_KEY_CTRL_END; break; case SDLK_PAGEUP: keysym = QEMU_KEY_CTRL_PAGEUP; break; case SDLK_PAGEDOWN: keysym = QEMU_KEY_CTRL_PAGEDOWN; break; default: break; } } else { switch(ev->key.keysym.sym) { case SDLK_UP: keysym = QEMU_KEY_UP; break; case SDLK_DOWN: keysym = QEMU_KEY_DOWN; break; case SDLK_LEFT: keysym = QEMU_KEY_LEFT; break; case SDLK_RIGHT: keysym = QEMU_KEY_RIGHT; break; case SDLK_HOME: keysym = QEMU_KEY_HOME; break; case SDLK_END: keysym = QEMU_KEY_END; break; case SDLK_PAGEUP: keysym = QEMU_KEY_PAGEUP; break; case SDLK_PAGEDOWN: keysym = QEMU_KEY_PAGEDOWN; break; case SDLK_BACKSPACE: keysym = QEMU_KEY_BACKSPACE; break; case SDLK_DELETE: keysym = QEMU_KEY_DELETE; break; default: break; } } if (keysym) { kbd_put_keysym(keysym); } else if (ev->key.keysym.unicode != 0) { kbd_put_keysym(ev->key.keysym.unicode); } } } else if (ev->type == SDL_KEYUP) { if (!alt_grab) { mod_state = (ev->key.keysym.mod & gui_grab_code); } else { mod_state = (ev->key.keysym.mod & (gui_grab_code | KMOD_LSHIFT)); } if (!mod_state) { if (gui_key_modifier_pressed) { gui_key_modifier_pressed = 0; if (gui_keysym == 0) { /* exit/enter grab if pressing Ctrl-Alt */ if (!gui_grab) { /* if the application is not active, do not try to enter grab state. It prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the application (SDL bug). */ if (SDL_GetAppState() & SDL_APPACTIVE) sdl_grab_start(); } else { sdl_grab_end(); } /* SDL does not send back all the modifiers key, so we must correct it */ reset_keys(); break; } gui_keysym = 0; } } } if (is_graphic_console() && !gui_keysym) sdl_process_key(&ev->key); break; case SDL_QUIT: if (!no_quit) qemu_system_shutdown_request(); break; case SDL_MOUSEMOTION: if (gui_grab || kbd_mouse_is_absolute() || absolute_enabled) { sdl_send_mouse_event(ev->motion.xrel, ev->motion.yrel, 0, ev->motion.x, ev->motion.y, ev->motion.state); } break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { SDL_MouseButtonEvent *bev = &ev->button; if (!gui_grab && !kbd_mouse_is_absolute()) { if (ev->type == SDL_MOUSEBUTTONDOWN && (bev->button == SDL_BUTTON_LEFT)) { /* start grabbing all events */ sdl_grab_start(); } } else { int dz; dz = 0; if (ev->type == SDL_MOUSEBUTTONDOWN) { buttonstate |= SDL_BUTTON(bev->button); } else { buttonstate &= ~SDL_BUTTON(bev->button); } #ifdef SDL_BUTTON_WHEELUP if (bev->button == SDL_BUTTON_WHEELUP && ev->type == SDL_MOUSEBUTTONDOWN) { dz = -1; } else if (bev->button == SDL_BUTTON_WHEELDOWN && ev->type == SDL_MOUSEBUTTONDOWN) { dz = 1; } #endif sdl_send_mouse_event(0, 0, dz, bev->x, bev->y, buttonstate); } } break; case SDL_ACTIVEEVENT: if (gui_grab && ev->active.state == SDL_APPINPUTFOCUS && !ev->active.gain && !gui_fullscreen_initial_grab) { sdl_grab_end(); } if (ev->active.state & SDL_APPACTIVE) { if (ev->active.gain) { /* Back to default interval */ dcl->gui_timer_interval = 0; dcl->idle = 0; } else { /* Sleeping interval */ dcl->gui_timer_interval = 500; dcl->idle = 1; } } break; case SDL_VIDEORESIZE: { SDL_ResizeEvent *rev = &ev->resize; int bpp = real_screen->format->BitsPerPixel; if (bpp != 16 && bpp != 32) bpp = 32; do_sdl_resize(rev->w, rev->h, bpp); scaling_active = 1; if (!is_buffer_shared(ds->surface)) { ds->surface = qemu_resize_displaysurface(ds, ds_get_width(ds), ds_get_height(ds)); dpy_resize(ds); } vga_hw_invalidate(); vga_hw_update(); break; } default: break; }
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()) {
void simple_file_selector(EFI_HANDLE *im, CHAR16 **title, CHAR16 *name, CHAR16 *filter, CHAR16 **result) { EFI_STATUS status; CHAR16 **entries = NULL; EFI_FILE_INFO *dmp; int count, select, len; CHAR16 *newname, *selected; *result = NULL; if (!name) name = L"\\"; if (!filter) filter = L""; if (!*im) { EFI_HANDLE h; CHAR16 *volname; simple_volume_selector(title, &volname, &h); if (!volname) return; FreePool(volname); *im = h; } newname = AllocatePool((StrLen(name) + 1)*sizeof(CHAR16)); if (!newname) return; StrCpy(newname, name); name = newname; redo: status = simple_dir_filter(*im, name, filter, &entries, &count, &dmp); if (status != EFI_SUCCESS) goto out_free_name; select = console_select(title, entries, 0); if (select < 0) /* ESC key */ goto out_free; selected = entries[select]; /* note that memory used by selected is valid until dmp is freed */ len = StrLen(selected); if (selected[len - 1] == '/') { CHAR16 *newname; /* stay where we are */ if (StrCmp(selected, L"./") == 0) { free_entries(entries, count); FreePool(entries); entries = NULL; FreePool(dmp); goto redo; } else if (StrCmp(selected, L"../") == 0) { int i; i = StrLen(name) - 1; for (i = StrLen(name); i > 0; --i) { if (name[i] == '\\') break; } if (i == 0) i = 1; if (StrCmp(name, L"\\") != 0 && StrCmp(&name[i], L"..") != 0) { name[i] = '\0'; free_entries(entries, count); FreePool(entries); entries = NULL; FreePool(dmp); goto redo; } } newname = AllocatePool((StrLen(name) + len + 2)*sizeof(CHAR16)); if (!newname) goto out_free; StrCpy(newname, name); if (name[StrLen(name) - 1] != '\\') StrCat(newname, L"\\"); StrCat(newname, selected); /* remove trailing / */ newname[StrLen(newname) - 1] = '\0'; free_entries(entries, count); FreePool(entries); entries = NULL; FreePool(dmp); FreePool(name); name = newname; goto redo; } *result = AllocatePool((StrLen(name) + len + 2)*sizeof(CHAR16)); if (*result) { StrCpy(*result, name); if (name[StrLen(name) - 1] != '\\') StrCat(*result, L"\\"); StrCat(*result, selected); } out_free: FreePool(dmp); if (entries) { free_entries(entries, count); FreePool(entries); } out_free_name: FreePool(name); }
EFI_STATUS simple_volume_selector(CHAR16 **title, CHAR16 **selected, EFI_HANDLE *h) { UINTN count, i; EFI_HANDLE *vol_handles = NULL; EFI_STATUS status; CHAR16 **entries; int val; uefi_call_wrapper(BS->LocateHandleBuffer, 5, ByProtocol, &SIMPLE_FS_PROTOCOL, NULL, &count, &vol_handles); if (!count || !vol_handles) return EFI_NOT_FOUND; entries = AllocatePool(sizeof(CHAR16 *) * (count+1)); if (!entries) return EFI_OUT_OF_RESOURCES; for (i = 0; i < count; i++) { char buf[4096]; UINTN size = sizeof(buf); EFI_FILE_SYSTEM_INFO *fi = (void *)buf; EFI_FILE *root; CHAR16 *name; EFI_FILE_IO_INTERFACE *drive; status = uefi_call_wrapper(BS->HandleProtocol, 3, vol_handles[i], &SIMPLE_FS_PROTOCOL, (void **)&drive); if (status != EFI_SUCCESS || !drive) continue; status = uefi_call_wrapper(drive->OpenVolume, 2, drive, &root); if (status != EFI_SUCCESS) continue; status = uefi_call_wrapper(root->GetInfo, 4, root, &FS_INFO, &size, fi); if (status != EFI_SUCCESS) continue; name = fi->VolumeLabel; if (!name || StrLen(name) == 0 || StrCmp(name, L" ") == 0) name = DevicePathToStr(DevicePathFromHandle(vol_handles[i])); entries[i] = AllocatePool((StrLen(name) + 2) * sizeof(CHAR16)); if (!entries[i]) break; StrCpy(entries[i], name); } entries[i] = NULL; val = console_select(title, entries, 0); if (val >= 0) { *selected = AllocatePool((StrLen(entries[val]) + 1) * sizeof(CHAR16)); if (*selected) { StrCpy(*selected , entries[val]); } *h = vol_handles[val]; } else { *selected = NULL; *h = 0; } for (i = 0; i < count; i++) { if (entries[i]) FreePool(entries[i]); } FreePool(entries); FreePool(vol_handles); return EFI_SUCCESS; }
static void sdl_refresh(DisplayState *ds) { SDL_Event ev1, *ev = &ev1; int mod_state; if (last_vm_running != vm_running) { last_vm_running = vm_running; sdl_update_caption(); } vga_hw_update(); while (SDL_PollEvent(ev)) { switch (ev->type) { case SDL_VIDEOEXPOSE: sdl_update(ds, 0, 0, screen->w, screen->h); break; case SDL_KEYDOWN: case SDL_KEYUP: if (ev->type == SDL_KEYDOWN) { mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code; gui_key_modifier_pressed = mod_state; if (gui_key_modifier_pressed) { int keycode; 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 0x02 ... 0x0a: /* '1' to '9' keys */ /* Reset the modifiers sent to the current console */ reset_keys(); console_select(keycode - 0x02); if (!is_graphic_console()) { /* display grab if going to a text console */ if (gui_grab) sdl_grab_end(); } gui_keysym = 1; break; default: break; } } else if (!is_graphic_console()) { int keysym; keysym = 0; if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) { switch(ev->key.keysym.sym) { case SDLK_UP: keysym = QEMU_KEY_CTRL_UP; break; case SDLK_DOWN: keysym = QEMU_KEY_CTRL_DOWN; break; case SDLK_LEFT: keysym = QEMU_KEY_CTRL_LEFT; break; case SDLK_RIGHT: keysym = QEMU_KEY_CTRL_RIGHT; break; case SDLK_HOME: keysym = QEMU_KEY_CTRL_HOME; break; case SDLK_END: keysym = QEMU_KEY_CTRL_END; break; case SDLK_PAGEUP: keysym = QEMU_KEY_CTRL_PAGEUP; break; case SDLK_PAGEDOWN: keysym = QEMU_KEY_CTRL_PAGEDOWN; break; default: break; } } else { switch(ev->key.keysym.sym) { case SDLK_UP: keysym = QEMU_KEY_UP; break; case SDLK_DOWN: keysym = QEMU_KEY_DOWN; break; case SDLK_LEFT: keysym = QEMU_KEY_LEFT; break; case SDLK_RIGHT: keysym = QEMU_KEY_RIGHT; break; case SDLK_HOME: keysym = QEMU_KEY_HOME; break; case SDLK_END: keysym = QEMU_KEY_END; break; case SDLK_PAGEUP: keysym = QEMU_KEY_PAGEUP; break; case SDLK_PAGEDOWN: keysym = QEMU_KEY_PAGEDOWN; break; case SDLK_BACKSPACE: keysym = QEMU_KEY_BACKSPACE; break; case SDLK_DELETE: keysym = QEMU_KEY_DELETE; break; default: break; } } if (keysym) { kbd_put_keysym(keysym); } else if (ev->key.keysym.unicode != 0) { kbd_put_keysym(ev->key.keysym.unicode); } } } else if (ev->type == SDL_KEYUP) {