From: Javier S. Pedro Date: Sun, 3 Jan 2010 02:33:26 +0000 (+0100) Subject: adding exit button X-Git-Tag: drnoksnes_1_3_0~30 X-Git-Url: https://vcs.maemo.org/git/?p=drnoksnes;a=commitdiff_plain;h=ed0378fbba2197526e02534425ead21101b2e0f9 adding exit button --- diff --git a/Makefile b/Makefile index 2b8efa4..3af4d90 100644 --- a/Makefile +++ b/Makefile @@ -67,12 +67,18 @@ endif ifeq ($(CONF_HD), 1) CPPFLAGS += -DCONF_HD=1 OBJS += platform/sdlvhildon.o + CONF_EXIT_BUTTON ?= 1 endif ifeq ($(CONF_HGW), 1) CPPFLAGS += -DCONF_HGW=1 -I/usr/include/hgw LDLIBS += -lhgw OBJS += platform/hgw.o endif +ifeq ($(CONF_EXIT_BUTTON), 1) + CPPFLAGS += -DCONF_EXIT_BUTTON=1 + LDLIBS += -lSDL_image + OBJS += platform/sdlvexit.o +endif # automatic dependencies DEPS := $(OBJS:.o=.d) diff --git a/debian/control.m4 b/debian/control.m4 index 80b184b..9b8f330 100644 --- a/debian/control.m4 +++ b/debian/control.m4 @@ -4,7 +4,7 @@ Priority: extra Maintainer: Javier S. Pedro Build-Depends: debhelper (>= 5), pkg-config, maemo-version, m4, libsdl1.2-dev, libx11-dev, x11proto-core-dev, libxsp-dev, libpopt-dev, zlib1g-dev, gnupg, - hildon-games-wrapper-dev, libosso-dev, osso-games-startup-dev, + hildon-games-wrapper-dev, libosso-dev, osso-games-startup-dev, libsdl-image1.2, libhildonfm2-dev, libosso-gnomevfs2-dev, libhildonmime-dev, maemo-optify Standards-Version: 3.7.2 diff --git a/platform/sdli.cpp b/platform/sdli.cpp index 86b3223..73abc80 100644 --- a/platform/sdli.cpp +++ b/platform/sdli.cpp @@ -68,6 +68,12 @@ 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! */ + if (Config.fullscreen && x > (800 - 100) && y < 50 && pressed > 0) { + S9xDoAction(kActionQuit); + } +#endif if (Config.touchscreenInput) { if (pressed < 0) { // Button up. @@ -199,6 +205,8 @@ void S9xInitInputDevices() { joypads[0] = 0; joypads[1] = 0; + mouse.enabled = false; + mouse.pressed = false; switch (Settings.ControllerOption) { case SNES_JOYPAD: diff --git a/platform/sdlv.cpp b/platform/sdlv.cpp index 535a899..66ff48a 100644 --- a/platform/sdlv.cpp +++ b/platform/sdlv.cpp @@ -113,6 +113,9 @@ static void setupVideoSurface() GUI.Width = gameWidth; GUI.Height = gameHeight; #endif +#if CONF_EXIT_BUTTON + exitReset(); +#endif // Safeguard if (gameHeight > GUI.Height || gameWidth > GUI.Width) @@ -160,14 +163,15 @@ static void drawOnscreenControls() { if (Config.touchscreenInput) { S9xInputScreenChanged(); - if (Config.touchscreenShow) { - scaler->pause(); - SDL_FillRect(screen, NULL, 0); - S9xInputScreenDraw(Settings.SixteenBit ? 2 : 1, - screen->pixels, screen->pitch); - SDL_Flip(screen); - scaler->resume(); - } + } + + if (Config.touchscreenShow) { + scaler->pause(); + SDL_FillRect(screen, NULL, 0); + S9xInputScreenDraw(Settings.SixteenBit ? 2 : 1, + screen->pixels, screen->pitch); + SDL_Flip(screen); + scaler->resume(); } } @@ -239,6 +243,15 @@ bool8_32 S9xDeinitUpdate (int width, int height, bool8_32 sixteenBit) { scaler->finish(); +#if CONF_EXIT_BUTTON + if (exitRequiresDraw()) { + //scaler->pause(); + exitDraw(screen); + SDL_Flip(screen); + //scaler->resume(); + } +#endif + return TRUE; } diff --git a/platform/sdlv.h b/platform/sdlv.h index 94031f1..b090adc 100644 --- a/platform/sdlv.h +++ b/platform/sdlv.h @@ -47,4 +47,10 @@ extern void hd_set_non_compositing(bool enable); #endif +#if defined(MAEMO) && MAEMO_VERSION >= 5 +extern void exitReset(); +extern bool exitRequiresDraw(); +extern void exitDraw(SDL_Surface* where); +#endif + #endif diff --git a/platform/sdlvexit.cpp b/platform/sdlvexit.cpp new file mode 100644 index 0000000..f23af90 --- /dev/null +++ b/platform/sdlvexit.cpp @@ -0,0 +1,49 @@ +#include +#include + +#include "platform.h" +#include "sdlv.h" + +#define DIE(format, ...) do { \ + fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \ + fprintf(stderr, format "\n", ## __VA_ARGS__); \ + abort(); \ + } while (0); + +static SDL_Surface* buttonSrf = 0; +static SDL_Rect buttonRect; + +static const unsigned long totalAnimLen = 1; + +static unsigned long frameCounter = 0; + +void exitReset() +{ + frameCounter = 0; + if (!buttonSrf) { + buttonSrf = IMG_Load("/usr/share/icons/hicolor/scalable/hildon/general_overlay_back.png"); + } + + buttonRect.x = GUI.Width - buttonSrf->w; + buttonRect.y = 0; + buttonRect.w = buttonSrf->w; + buttonRect.h = buttonSrf->h; +} + +bool exitRequiresDraw() +{ + if (!Config.fullscreen) return false; + if (frameCounter > totalAnimLen) { + return false; + } else { + frameCounter++; + return true; + } + +}; + +void exitDraw(SDL_Surface* where) +{ + SDL_BlitSurface(buttonSrf, 0, where, &buttonRect); +}; +