Beispiel #1
0
static void sdl_send_mouse_event(int dz)
{
    int dx, dy, state, buttons;
    state = SDL_GetRelativeMouseState(&dx, &dy);
    buttons = 0;
    if (state & SDL_BUTTON(SDL_BUTTON_LEFT))
        buttons |= MOUSE_EVENT_LBUTTON;
    if (state & SDL_BUTTON(SDL_BUTTON_RIGHT))
        buttons |= MOUSE_EVENT_RBUTTON;
    if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE))
        buttons |= MOUSE_EVENT_MBUTTON;

    if (kbd_mouse_is_absolute()) {
        if (!absolute_enabled) {
            sdl_hide_cursor();
            if (gui_grab) {
                sdl_grab_end();
            }
            absolute_enabled = 1;
        }

        SDL_GetMouseState(&dx, &dy);
        dx = dx * 0x7FFF / width;
        dy = dy * 0x7FFF / height;
    } else if (absolute_enabled) {
        sdl_show_cursor();
        absolute_enabled = 0;
    }

    kbd_mouse_event(dx, dy, dz, buttons);
}
Beispiel #2
0
static void sdl_grab_start(struct sdl2_console *scon)
{
    QemuConsole *con = scon ? scon->dcl.con : NULL;

    if (!con || !qemu_console_is_graphic(con)) {
        return;
    }
    /*
     * If the application is not active, do not try to enter grab state. This
     * prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the
     * application (SDL bug).
     */
    if (!(SDL_GetWindowFlags(scon->real_window) & SDL_WINDOW_INPUT_FOCUS)) {
        return;
    }
    if (guest_cursor) {
        SDL_SetCursor(guest_sprite);
        if (!qemu_input_is_absolute() && !absolute_enabled) {
            SDL_WarpMouseInWindow(scon->real_window, guest_x, guest_y);
        }
    } else {
        sdl_hide_cursor();
    }
    SDL_SetWindowGrab(scon->real_window, SDL_TRUE);
    gui_grab = 1;
    sdl_update_caption(scon);
}
Beispiel #3
0
Datei: sdl.c Projekt: CPFL/gxen
static void sdl_send_mouse_event(int dx, int dy, int dz, int state)
{
    int buttons = 0;
    if (state & SDL_BUTTON(SDL_BUTTON_LEFT))
        buttons |= MOUSE_EVENT_LBUTTON;
    if (state & SDL_BUTTON(SDL_BUTTON_RIGHT))
        buttons |= MOUSE_EVENT_RBUTTON;
    if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE))
        buttons |= MOUSE_EVENT_MBUTTON;

    if (kbd_mouse_is_absolute()) {
	if (!absolute_enabled) {
	    sdl_hide_cursor();
	    if (gui_grab) {
		sdl_grab_end();
	    }
	    absolute_enabled = 1;
	}

	SDL_GetMouseState(&dx, &dy);
        dx = dx * 0x7FFF / (real_screen->w - 1);
        dy = dy * 0x7FFF / (real_screen->h - 1);
    } else if (absolute_enabled) {
	sdl_show_cursor();
	absolute_enabled = 0;
    }

    kbd_mouse_event(dx, dy, dz, buttons);
}
Beispiel #4
0
Datei: sdl.c Projekt: CPFL/gxen
static void sdl_grab_start(void)
{
    sdl_hide_cursor();
    SDL_WM_GrabInput(SDL_GRAB_ON);
    gui_grab = 1;
    sdl_update_caption();
}
Beispiel #5
0
static void sdl_grab_start(void)
{
    sdl_hide_cursor();
    SDL_WM_GrabInput(SDL_GRAB_ON);
    /* dummy read to avoid moving the mouse */
    SDL_GetRelativeMouseState(NULL, NULL);
    gui_grab = 1;
    sdl_update_caption();
}
static void sdl_grab_start(void)
{
    if (guest_cursor) {
        SDL_SetCursor(guest_sprite);
        SDL_WarpMouse(guest_x, guest_y);
    } else
        sdl_hide_cursor();
    SDL_WM_GrabInput(SDL_GRAB_ON);
    gui_grab = 1;
    sdl_update_caption();
}
Beispiel #7
0
static void sdl_grab_start(void)
{
    if (guest_cursor) {
        SDL_SetCursor(guest_sprite);
        SDL_WarpMouse(guest_x, guest_y);
    } else
        sdl_hide_cursor();
    SDL_WM_GrabInput(SDL_GRAB_ON);
    /* dummy read to avoid moving the mouse */
    SDL_GetRelativeMouseState(NULL, NULL);
    gui_grab = 1;
    sdl_update_caption();
}
Beispiel #8
0
static void sdl_grab_start(void)
{
    if (guest_cursor) {
        SDL_SetCursor(guest_sprite);
        if (!kbd_mouse_is_absolute() && !absolute_enabled)
            SDL_WarpMouse(guest_x, guest_y);
    } else
        sdl_hide_cursor();

    if (SDL_WM_GrabInput(SDL_GRAB_ON) == SDL_GRAB_ON) {
        gui_grab = 1;
        sdl_update_caption();
    } else
        sdl_show_cursor();
}
Beispiel #9
0
static void sdl_mouse_mode_change(Notifier *notify)
{
    if (kbd_mouse_is_absolute()) {
        if (!absolute_enabled) {
            sdl_hide_cursor();
            if (gui_grab) {
                sdl_grab_end();
            }
            absolute_enabled = 1;
        }
    } else if (absolute_enabled) {
	sdl_show_cursor();
	absolute_enabled = 0;
    }
}
Beispiel #10
0
static void sdl_grab_start(void)
{
    /*
     * If the application is not active, do not try to enter grab state. This
     * prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the
     * application (SDL bug).
     */
    if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) {
        return;
    }
    if (guest_cursor) {
        SDL_SetCursor(guest_sprite);
        if (!kbd_mouse_is_absolute() && !absolute_enabled)
            SDL_WarpMouse(guest_x, guest_y);
    } else
        sdl_hide_cursor();
    SDL_WM_GrabInput(SDL_GRAB_ON);
    gui_grab = 1;
    sdl_update_caption();
}
Beispiel #11
0
static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int state)
{
    int buttons;
    buttons = 0;
    if (state & SDL_BUTTON(SDL_BUTTON_LEFT))
        buttons |= MOUSE_EVENT_LBUTTON;
    if (state & SDL_BUTTON(SDL_BUTTON_RIGHT))
        buttons |= MOUSE_EVENT_RBUTTON;
    if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE))
        buttons |= MOUSE_EVENT_MBUTTON;

    if (kbd_mouse_is_absolute()) {
	if (!absolute_enabled) {
	    sdl_hide_cursor();
	    if (gui_grab) {
		sdl_grab_end();
	    }
	    absolute_enabled = 1;
	}

       dx = x * 0x7FFF / (width - 1);
       dy = y * 0x7FFF / (height - 1);
    } else if (absolute_enabled) {
	sdl_show_cursor();
	absolute_enabled = 0;
    } else if (guest_cursor) {
        x -= guest_x;
        y -= guest_y;
        guest_x += x;
        guest_y += y;
        dx = x;
        dy = y;
    }

    kbd_mouse_event(dx, dy, dz, buttons);
}
Beispiel #12
0
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()) {