* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <getopt.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <time.h>
-#include <sys/time.h>
-#include <malloc.h>
-#include <termios.h>
-#include <sys/poll.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <netinet/in.h>
+#include "vl.h"
#include <SDL.h>
-#include "cpu.h"
-#include "exec-all.h"
-
-#include "vl.h"
+#ifndef _WIN32
+#include <signal.h>
+#endif
static SDL_Surface *screen;
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
+static int last_vm_running;
static void sdl_update(DisplayState *ds, int x, int y, int w, int h)
{
+ // printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h);
SDL_UpdateRect(screen, x, y, w, h);
}
/* XXX: not portable, but avoids complicated mappings */
keycode = ev->keysym.scancode;
+#ifdef _WIN32
+ if (keycode < 97) {
+ /* nothing to do */
+ } else
+#else
if (keycode < 9) {
keycode = 0;
} else if (keycode < 97) {
keycode -= 8; /* just an offset */
- } else if (keycode < 158) {
+ } else
+#endif
+ if (keycode < 158) {
/* use conversion table */
keycode = x_keycode_to_pc_keycode[keycode - 97];
} else {
}
}
+static void sdl_update_caption(void)
+{
+ char buf[1024];
+ strcpy(buf, "QEMU");
+ if (!vm_running) {
+ strcat(buf, " [Stopped]");
+ }
+ if (gui_grab) {
+ strcat(buf, " - Press Ctrl-Shift to exit grab");
+ }
+ SDL_WM_SetCaption(buf, "QEMU");
+}
+
static void sdl_grab_start(void)
{
- SDL_WM_SetCaption("QEMU - Press Ctrl-Shift to exit grab", "QEMU");
SDL_ShowCursor(0);
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_end(void)
{
- SDL_WM_SetCaption("QEMU", "QEMU");
SDL_WM_GrabInput(SDL_GRAB_OFF);
SDL_ShowCursor(1);
gui_grab = 0;
+ sdl_update_caption();
}
static void sdl_send_mouse_event(void)
buttons |= MOUSE_EVENT_MBUTTON;
/* XXX: test wheel */
dz = 0;
+#ifdef SDL_BUTTON_WHEELUP
if (state & SDL_BUTTON(SDL_BUTTON_WHEELUP))
dz--;
if (state & SDL_BUTTON(SDL_BUTTON_WHEELDOWN))
dz++;
+#endif
kbd_mouse_event(dx, dy, dz, buttons);
}
{
SDL_Event ev1, *ev = &ev1;
+ if (last_vm_running != vm_running) {
+ last_vm_running = vm_running;
+ sdl_update_caption();
+ }
+
vga_update_display();
while (SDL_PollEvent(ev)) {
switch (ev->type) {
}
}
+static void sdl_cleanup(void)
+{
+ SDL_Quit();
+}
+
void sdl_display_init(DisplayState *ds)
{
int flags;
fprintf(stderr, "Could not initialize SDL - exiting\n");
exit(1);
}
+
+#ifndef _WIN32
/* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
+#endif
ds->dpy_update = sdl_update;
ds->dpy_resize = sdl_resize;
ds->dpy_refresh = sdl_refresh;
sdl_resize(ds, 640, 400);
- SDL_WM_SetCaption("QEMU", "QEMU");
+ sdl_update_caption();
SDL_EnableKeyRepeat(250, 50);
gui_grab = 0;
+
+ atexit(sdl_cleanup);
}