using new sdl_haa library
[drnoksnes] / platform / sdli.cpp
index 86b3223..ecd7f63 100644 (file)
@@ -4,6 +4,7 @@
 #include "platform.h"
 #include "snes9x.h"
 #include "display.h"
+#include "sdlv.h" // Dispatching video-related events
 
 struct TouchButton {
        unsigned short mask;
@@ -68,6 +69,13 @@ static inline void press(TouchButton* b) {
 
 static void processMouse(unsigned int x, unsigned int y, int pressed = 0)
 {
+#if CONF_EXIT_BUTTON
+       /* no fullscreen escape button, we have to simulate one! */
+       /* TODO: don't hardcode sizes */
+       if (Config.fullscreen && x > (800 - 100) && y < 50 && pressed > 0) {
+               S9xDoAction(kActionQuit);
+       }
+#endif
        if (Config.touchscreenInput) {
                if (pressed < 0) {
                        // Button up.
@@ -125,30 +133,29 @@ static void processEvent(const SDL_Event& event)
 {
        switch (event.type) 
        {
-       case SDL_KEYDOWN:
-               if (Config.action[event.key.keysym.scancode]) 
-                       S9xDoAction(Config.action[event.key.keysym.scancode]);
-               joypads[0] |= Config.joypad1Mapping[event.key.keysym.scancode];
-               break;
-       case SDL_KEYUP:
-               joypads[0] &= ~Config.joypad1Mapping[event.key.keysym.scancode];
-               break;
-       case SDL_MOUSEBUTTONUP:
-       case SDL_MOUSEBUTTONDOWN:
-               processMouse(event.button.x, event.button.y,
-                               (event.button.state == SDL_PRESSED) ? 1 : - 1);
-               break;
-       case SDL_MOUSEMOTION:
-               processMouse(event.motion.x, event.motion.y);
-               break;
-       case SDL_ACTIVEEVENT:
-               if (event.active.state & SDL_APPINPUTFOCUS) {
-                       S9xVideoOutputFocus(event.active.gain);
-               }
-               break;
-       case SDL_QUIT:
-               Config.quitting = true;
-               break;
+               case SDL_KEYDOWN:
+                       if (Config.action[event.key.keysym.scancode]) 
+                               S9xDoAction(Config.action[event.key.keysym.scancode]);
+                       joypads[0] |= Config.joypad1Mapping[event.key.keysym.scancode];
+                       break;
+               case SDL_KEYUP:
+                       joypads[0] &= ~Config.joypad1Mapping[event.key.keysym.scancode];
+                       break;
+               case SDL_MOUSEBUTTONUP:
+               case SDL_MOUSEBUTTONDOWN:
+                       processMouse(event.button.x, event.button.y,
+                                       (event.button.state == SDL_PRESSED) ? 1 : - 1);
+                       break;
+               case SDL_MOUSEMOTION:
+                       processMouse(event.motion.x, event.motion.y);
+                       break;
+               case SDL_QUIT:
+                       Config.quitting = true;
+                       break;
+               case SDL_ACTIVEEVENT:
+               case SDL_SYSWMEVENT:
+                       processVideoEvent(event);
+                       break;
        }
 }
 
@@ -199,6 +206,8 @@ void S9xInitInputDevices()
 {
        joypads[0] = 0;
        joypads[1] = 0;
+       mouse.enabled = false;
+       mouse.pressed = false;
 
        switch (Settings.ControllerOption) {
                case SNES_JOYPAD: