write to both IDE drives - return 0 for not present drives
[qemu] / sdl.c
diff --git a/sdl.c b/sdl.c
index e9c28f2..5f1538f 100644 (file)
--- a/sdl.c
+++ b/sdl.c
@@ -42,8 +42,8 @@
 
 #include <SDL.h>
 
-#include "cpu-i386.h"
-#include "exec.h"
+#include "cpu.h"
+#include "exec-all.h"
 
 #include "vl.h"
 
@@ -52,6 +52,7 @@ static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
 
 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);
 }
 
@@ -195,10 +196,12 @@ 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);
 }
 
@@ -255,6 +258,11 @@ static void sdl_refresh(DisplayState *ds)
     }
 }
 
+static void sdl_cleanup(void) 
+{
+    SDL_Quit();
+}
+
 void sdl_display_init(DisplayState *ds)
 {
     int flags;
@@ -264,6 +272,10 @@ void sdl_display_init(DisplayState *ds)
         fprintf(stderr, "Could not initialize SDL - exiting\n");
         exit(1);
     }
+    /* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */
+    signal(SIGINT, SIG_DFL);
+    signal(SIGQUIT, SIG_DFL);
+
     ds->dpy_update = sdl_update;
     ds->dpy_resize = sdl_resize;
     ds->dpy_refresh = sdl_refresh;
@@ -272,4 +284,6 @@ void sdl_display_init(DisplayState *ds)
     SDL_WM_SetCaption("QEMU", "QEMU");
     SDL_EnableKeyRepeat(250, 50);
     gui_grab = 0;
+
+    atexit(sdl_cleanup);
 }