removed dependency on hildon-games-wrapper
authorJavier S. Pedro <maemo@javispedro.com>
Sun, 31 Jan 2010 23:30:47 +0000 (00:30 +0100)
committerJavier S. Pedro <maemo@javispedro.com>
Sun, 31 Jan 2010 23:30:47 +0000 (00:30 +0100)
Using GLib now. This was going to happen either way
if I wanted to link with libzeemote.

19 files changed:
Makefile
configure
debian/changelog
debian/control.m4
debian/rules
display.h
gui/Makefile
gui/drnoksnes.game.m4 [deleted file]
gui/drnoksnes.service.m4
gui/i18n/drnoksnes_plugin.pot
gui/i18n/es.po
gui/keys.c
platform/config.cpp
platform/osso.cpp
platform/osso.h
platform/platform.h
platform/sdl.cpp
platform/sdli.cpp
platform/sdlv.cpp

index e807f91..38cb343 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,8 +7,6 @@ LDLIBS := -lz $(shell sdl-config --libs) $(shell pkg-config --libs x11) -lpopt
 
 # Sane defaults
 CONF_GUI?=1
-# Use Hildon Games Wrapper library
-CONF_HGW?=$(CONF_GUI)
 ifeq ($(ARCH),armel)
        CONF_BUILD_ASM_CPU?=1
        CONF_BUILD_ASM_SPC700?=1
@@ -69,10 +67,10 @@ ifeq ($(CONF_HD), 1)
        LDLIBS += -lSDL_haa
        CONF_EXIT_BUTTON ?= 1
 endif
-ifeq ($(CONF_HGW), 1)
-       CPPFLAGS += -DCONF_HGW=1 -I/usr/include/hgw $(shell pkg-config --cflags gconf-2.0)
-       LDLIBS += -lhgw $(shell pkg-config --libs gconf-2.0)
-       OBJS += platform/hgw.o
+ifeq ($(CONF_GUI), 1)
+       CPPFLAGS += -DCONF_GUI=1 $(shell pkg-config --cflags libosso gconf-2.0)
+       LDLIBS += $(shell pkg-config --libs libosso gconf-2.0)
+       OBJS += platform/osso.o
 endif
 ifeq ($(CONF_EXIT_BUTTON), 1)
        CPPFLAGS += -DCONF_EXIT_BUTTON=1
index 19eb0c1..ece9ea2 100755 (executable)
--- a/configure
+++ b/configure
@@ -12,7 +12,6 @@ ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH)
 GAME_VERSION=$(head -n 1 debian/changelog | sed 's/[^0-9.-]//g')
 
 echo ARCH="${ARCH}" > config.mk
-echo CONF_HGW=0 >> config.mk
 echo CONF_GUI=0 >> config.mk
 echo CONF_XSP=0 >> config.mk
 echo ASFLAGS="" >> config.mk
index 01c3010..bca1564 100644 (file)
@@ -2,9 +2,9 @@ drnoksnes (1.2.6) unstable; urgency=low
 
   * Using SDL_haa for scaling in Fremantle now.
   * Reworked GUI key mapping gconf entries.
-  * Using GConfClient instead of HGW.
+  * Using GConfClient instead of HGW. Removing dependency on hgw.
 
- -- Javier S. Pedro <maemo@javispedro.com>  Sat, 23 Jan 2010 20:24:58 +0100
+ -- Javier S. Pedro <maemo@javispedro.com>  Mon,  1 Feb 2010 00:27:45 +0100
 
 drnoksnes (1.2.5) unstable; urgency=low
 
index 3242abf..8eb1ab1 100644 (file)
@@ -4,9 +4,8 @@ Priority: extra
 Maintainer: Javier S. Pedro <maemo@javispedro.com>
 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,
- libhildonfm2-dev, libosso-gnomevfs2-dev, libhildonmime-dev, maemo-optify,
- libsdl-image1.2-dev
+ libosso-dev, osso-games-startup-dev, libsdl-image1.2-dev,
+ libhildonfm2-dev, libosso-gnomevfs2-dev, libhildonmime-dev
 Standards-Version: 3.7.2
 
 Package: drnoksnes
index ceb692f..5d3025f 100755 (executable)
@@ -64,7 +64,6 @@ configure-stamp:
        
        echo ARCH="$(ARCH)" > config.mk
        echo CONF_GUI=1 >> config.mk
-       echo CONF_HGW=1 >> config.mk
 ifeq ($(shell expr "$(MAEMO_VERSION)" ">" 4), 1)
        # Maemo 5 devices do not support Xsp
        # But they support hildon compositing stuff
index 5d25932..49fa741 100644 (file)
--- a/display.h
+++ b/display.h
@@ -53,22 +53,12 @@ uint32 S9xReadJoypad (int which1_0_to_4);
 bool8_32 S9xReadMousePosition (int which1_0_to_1, int &x, int &y, uint32 &buttons);
 bool8_32 S9xReadSuperScopePosition (int &x, int &y, uint32 &buttons);
 
-void S9xUsage ();
-void S9xInitDisplay (int argc, const char **argv);
-void S9xDeinitDisplay ();
-void S9xInitInputDevices ();
-void S9xSetTitle (const char *title);
-void S9xProcessEvents (bool8_32 block);
-void S9xPutImage (int width, int height);
-void S9xParseDisplayArg (char **argv, int &index, int argc);
-void S9xToggleSoundChannel (int channel);
 void S9xSetInfoString (const char * fmt, ...);
-int S9xMinCommandLineArgs ();
+
 void S9xNextController ();
 
 bool8_32 S9xOpenSnapshotFile (const char *base, bool8_32 read_only, STREAM *file);
 void S9xCloseSnapshotFile (STREAM file);
-
 END_EXTERN_C
 
 #endif
index 266b950..0071ab8 100644 (file)
@@ -17,13 +17,12 @@ GAME_SHARE_PATH=/usr/share/games/drnoksnes
 GAME_PLUGIN_PATH=/usr/lib/drnoksnes_plugin.so
 GAME_CONF_PATH=$(GAME_SHARE_PATH)/drnoksnes.conf
 GAME_BIN_PATH=/usr/games/drnoksnes
-GAME_GAME_PATH=/usr/games/wrapper/games/drnoksnes.game
 GAME_BANNER_PATH=/usr/share/pixmaps/osso-games-startup-drnoksnes.png
 
 M4:=m4
 M4DEFS:= -DGAME_VERSION=$(GAME_VERSION) -DGAME_PLUGIN_PATH=$(GAME_PLUGIN_PATH)
 M4DEFS+= -DGAME_CONF_PATH=$(GAME_CONF_PATH) -DGAME_BIN_PATH=$(GAME_BIN_PATH)
-M4DEFS+= -DGAME_GAME_PATH=$(GAME_GAME_PATH) -DGAME_BANNER_PATH=$(GAME_BANNER_PATH)
+M4DEFS+= -DGAME_BANNER_PATH=$(GAME_BANNER_PATH)
 ifdef MAEMO_VERSION
 M4DEFS+= -DMAEMO -DMAEMO_MAJOR=$(MAEMO_VERSION)
 endif
@@ -38,12 +37,12 @@ SRCS:=plugin.c state.c save.c controls.c keys.c settings.c about.c \
         cellrendererkey.c
 OBJS:=$(SRCS:.c=.o)
 
-POT:=$(GETTEXT_PACKAGE).pot
+POT:=i18n/$(GETTEXT_PACKAGE).pot
 PO_FILES:=$(wildcard i18n/*.po)
 MO_FILES:=$(PO_FILES:.po=.mo)
 LANGS:=$(basename $(notdir $(PO_FILES)))
 
-DATA_FILES:=drnoksnes.conf drnoksnes.desktop drnoksnes.game 
+DATA_FILES:=drnoksnes.conf drnoksnes.desktop
 DATA_FILES+=drnoksnes.service drnoksnes.startup.service
 DATA_FILES+=drnoksnes.schemas
 
@@ -64,7 +63,7 @@ $(PO_FILES): %: $(POT)
        
 clean: 
        rm -f drnoksnes_plugin.so *.o
-       rm -f $(POT) $(MO_FILES)
+       rm -f $(MO_FILES)
        rm -f $(DATA_FILES)
 
 %: %.m4
@@ -75,7 +74,6 @@ install: all
        install drnoksnes_plugin.so $(DESTDIR)$(GAME_PLUGIN_PATH)
        install -m 0644 drnoksnes.conf $(DESTDIR)$(GAME_CONF_PATH)
        install -m 0644 drnoksnes.desktop $(DESTDIR)/usr/share/applications/hildon/
-       install -m 0644 drnoksnes.game $(DESTDIR)$(GAME_GAME_PATH)
        install -m 0644 drnoksnes.service $(DESTDIR)/usr/share/dbus-1/services/
        install -m 0644 drnoksnes.startup.service $(DESTDIR)/usr/share/dbus-1/services/
        install -m 0644 icons/main_26.png $(DESTDIR)/usr/share/icons/hicolor/26x26/hildon/drnoksnes.png
diff --git a/gui/drnoksnes.game.m4 b/gui/drnoksnes.game.m4
deleted file mode 100644 (file)
index b276f23..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-drnoksnes
-GAME_BIN_PATH
-com.javispedro.drnoksnes
-/com/javispedro/drnoksnes
-com.javispedro.drnoksnes
-GAME_VERSION
index 4f89aad..9168e07 100644 (file)
@@ -1,3 +1,4 @@
 [D-BUS Service]
 Name=com.javispedro.drnoksnes
-Exec=/usr/games/wrapper/wrapper GAME_GAME_PATH
+Exec=/usr/bin/env DRNOKSNES_DBUS=y GAME_BIN_PATH
+
index 6ecb37a..266bb2f 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: maemo@javispedro.com\n"
-"POT-Creation-Date: 2010-01-26 20:44+0100\n"
+"POT-Creation-Date: 2010-01-28 01:47+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -149,12 +149,12 @@ msgstr ""
 msgid "Zeemote"
 msgstr ""
 
-#: keys.c:267
+#: keys.c:266
 #, c-format
 msgid "Player %d keys"
 msgstr ""
 
-#: keys.c:270
+#: keys.c:269
 msgid "Defaults"
 msgstr ""
 
index 0d75992..9b6a502 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: DrNokSnes 1.2.5\n"
 "Report-Msgid-Bugs-To: maemo@javispedro.com\n"
-"POT-Creation-Date: 2010-01-23 20:44+0100\n"
+"POT-Creation-Date: 2010-01-28 01:46+0100\n"
 "PO-Revision-Date: 2010-01-07 03:11+0100\n"
 "Last-Translator: Javier <javier@javispedro.com>\n"
 "Language-Team: Spanish <maemo@javispedro.com>\n"
@@ -153,12 +153,12 @@ msgstr ""
 msgid "Zeemote"
 msgstr ""
 
-#: keys.c:267
+#: keys.c:266
 #, fuzzy, c-format
 msgid "Player %d keys"
 msgstr "Jugador 1"
 
-#: keys.c:270
+#: keys.c:269
 msgid "Defaults"
 msgstr ""
 
index 1a998c5..d9335b3 100644 (file)
@@ -30,7 +30,6 @@
 #include <hildon/hildon-check-button.h>
 #endif
 
-#include "../platform/hgw.h"
 #include "plugin.h"
 #include "gconf.h"
 #include "cellrendererkey.h"
index 82a5b6c..2486dd6 100644 (file)
@@ -7,7 +7,10 @@
 #include "port.h"
 #include "snes9x.h"
 #include "display.h"
-#include "hgw.h"
+
+#if CONF_GUI
+#include "osso.h"
+#endif
 
 #define DIE(format, ...) do { \
                fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \
@@ -407,41 +410,35 @@ static void parseArgs(poptContext optCon)
                S9xSetRomFile(extra_arg);
 }
 
-void S9xLoadConfig(int argc, const char ** argv)
+void S9xLoadConfig(int argc, char ** argv)
 {
-       poptContext optCon =
-               poptGetContext("drnoksnes", argc, argv, optionsTable, 0);
+       poptContext optCon = poptGetContext("drnoksnes",
+               argc, const_cast<const char **>(argv), optionsTable, 0);
        poptSetOtherOptionHelp(optCon, "<rom>");
 
        // Builtin defaults
        loadDefaults();
 
-       // Read config file ~/apps/DrNokSnes.txt
+       // Read config file ~/.config/drnoksnes.conf
        char defConfFile[PATH_MAX];
-       sprintf(defConfFile, "%s/%s", getenv("HOME"), "apps/DrNokSnes.txt");
+       sprintf(defConfFile, "%s/%s", getenv("HOME"), ".config/drnoksnes.conf");
        loadConfig(optCon, defConfFile);
 
        // Command line parameters (including --conf args)
        parseArgs(optCon);
 
-#if CONF_HGW
-       if (!gotRomFile() && !hgwLaunched) {
-               // User did not specify a ROM file, 
-               // and we're not being launched from D-Bus.
-               fprintf(stderr, "You need to specify a ROM, like this:\n");
-               poptPrintUsage(optCon, stdout, 0);
-               poptFreeContext(optCon);
-               exit(2);
-       }
-#else
-       if (!gotRomFile()) {
-               // User did not specify a ROM file
-               fprintf(stderr, "You need to specify a ROM, like this:\n");
-               poptPrintUsage(optCon, stdout, 0);
-               poptFreeContext(optCon);
-               exit(2);
-       }
+#if CONF_GUI
+       if (!OssoOk())
 #endif
+       {
+               if (!gotRomFile()) {
+                       // User did not specify a ROM file in the command line
+                       fprintf(stderr, "You need to specify a ROM, like this:\n");
+                       poptPrintUsage(optCon, stdout, 0);
+                       poptFreeContext(optCon);
+                       exit(2);
+               }
+       }
 
        poptFreeContext(optCon);
 }
index bf19736..b967018 100644 (file)
 #include <stdio.h>
-#include <libgen.h>
-#include <hgw/hgw.h>
 
 #include "snes9x.h"
 
 #include <glib.h>
+#include <libosso.h>
 #include <gconf/gconf.h>
 #include <gconf/gconf-client.h>
 
 #include "platform.h"
-#include "hgw.h"
+#include "osso.h"
 #include "../gui/gconf.h"
 
-#define DIE(format, ...) do { \
-               fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \
-               fprintf(stderr, format "\n", ## __VA_ARGS__); \
-               abort(); \
-       } while (0);
+static GMainContext *mainContext;
+static GMainLoop *mainLoop;
+osso_context_t *ossoContext;
 
-bool hgwLaunched;
-static HgwContext *hgw;
+static volatile enum {
+       STARTUP_COMMAND_INVALID = -1,
+       STARTUP_COMMAND_UNKNOWN = 0,
+       STARTUP_COMMAND_RUN,
+       STARTUP_COMMAND_CONTINUE,
+       STARTUP_COMMAND_RESTART,
+       STARTUP_COMMAND_QUIT
+} startupCommand;
 
 static void createActionMappingsOnly();
 static void parseGConfKeyMappings(GConfClient* gcc);
 
-void HgwInit()
+static gint ossoAppCallback(const gchar *interface, const gchar *method,
+  GArray *arguments, gpointer data, osso_rpc_t *retval)
 {
-       // hildon-games-wrapper sets this env variable for itself.
-       char* service = getenv("HGW_EXEC_SERVICE");
+       retval->type = DBUS_TYPE_BOOLEAN;
+
+       if (startupCommand == STARTUP_COMMAND_UNKNOWN) {
+               // Only if we haven't received the startup command yet.
+               printf("Osso: Startup method is: %s\n", method);
+
+               if (strcmp(method, "game_run") == 0) {
+                       startupCommand = STARTUP_COMMAND_RUN;
+                       retval->value.b = TRUE;
+               } else if (strcmp(method, "game_continue") == 0) {
+                       startupCommand = STARTUP_COMMAND_CONTINUE;
+                       retval->value.b = TRUE;
+               } else if (strcmp(method, "game_restart") == 0) {
+                       startupCommand = STARTUP_COMMAND_RESTART;
+                       retval->value.b = TRUE;
+               } else if (strcmp(method, "game_close") == 0) {
+                       // A bit weird, but could happen
+                       startupCommand = STARTUP_COMMAND_QUIT;
+                       retval->value.b = TRUE;
+               } else {
+                       startupCommand = STARTUP_COMMAND_INVALID;
+                       retval->value.b = FALSE;
+               }
+       } else {
+               if (strcmp(method, "game_close") == 0) {
+                       printf("Osso: quitting because of D-Bus close message\n");
+                       S9xDoAction(kActionQuit);
+                       retval->value.b = TRUE;
+               } else {
+                       retval->value.b = FALSE;
+               }
+       }
 
-       if (!service) {
-               // Not launched from hildon-games-wrapper
-               hgwLaunched = false;
+       return OSSO_OK;
+}
+
+/** Called from main(), initializes Glib & libosso stuff if needed. */
+void OssoInit()
+{
+       char *dbusLaunch = getenv("DRNOKSNES_DBUS");
+
+       if (!dbusLaunch || dbusLaunch[0] != 'y') {
+               // Not launched from GUI, so we don't assume GUI features.
+               ossoContext = 0;
                return;
        }
 
        g_type_init();
-       hgw = hgw_context_init();
+       mainContext = g_main_context_default();
+       mainLoop = g_main_loop_new(mainContext, FALSE);
+       ossoContext = osso_initialize("com.javispedro.drnoksnes", "1", 0, 0);
 
-       if (!hgw) {
-               fprintf(stderr, "Error opening hgw context\n");
-               hgwLaunched = false;
+       if (!ossoContext) {
+               fprintf(stderr, "Error initializing libosso\n");
+               exit(2);
        }
 
-       hgwLaunched = true;
-       printf("Loading in HGW mode\n");
+       // At this point, we still don't know what the startup command is
+       startupCommand = STARTUP_COMMAND_UNKNOWN;
+
+       osso_return_t ret;
+       ret = osso_rpc_set_default_cb_f(ossoContext, ossoAppCallback, 0);
+       g_assert(ret == OSSO_OK);
+
+       printf("Osso: Initialized libosso\n");
 }
 
-void HgwDeinit()
+static osso_return_t invokeLauncherMethod(const char *method, osso_rpc_t *retval)
 {
-       if (!hgwLaunched) return;
+       // The launcher seems to assume there is at least one parameter,
+       // even if the method doesn't actually require one.
+       return osso_rpc_run(ossoContext, "com.javispedro.drnoksnes.startup",
+               "/com/javispedro/drnoksnes/startup", "com.javispedro.drnoksnes.startup",
+               method, retval, DBUS_TYPE_INVALID);
+}
+
+void OssoDeinit()
+{
+       if (!OssoOk()) return;
+
+       // Send a goodbye message to the launcher
+       osso_return_t ret;
+       osso_rpc_t retval = { 0 };
+       if (Config.snapshotSave) {
+               // If we saved game state, notify launcher to enter "paused" status.
+               ret = invokeLauncherMethod("game_pause", &retval);
+       } else {
+               ret = invokeLauncherMethod("game_close", &retval);
+       }
+       if (ret != OSSO_OK) {
+               printf("Osso: failed to notify launcher\n");
+       }
+       osso_rpc_free_val(&retval);
 
-       hgw_context_destroy(hgw,
-               (Config.snapshotSave ? HGW_BYE_PAUSED : HGW_BYE_INACTIVE));
+       osso_deinitialize(ossoContext);
+       g_main_loop_unref(mainLoop);
+       g_main_context_unref(mainContext);
 
-       hgw = 0;
+       ossoContext = 0;
 }
 
-void HgwConfig()
+/** Called after loading the config file, loads settings from gconf. */
+void OssoConfig()
 {
-       if (!hgwLaunched) return;
+       if (!OssoOk()) return;
 
        GConfClient *gcc = gconf_client_get_default();
 
+       // GUI only allows fullscreen
        Config.fullscreen = true;
 
-       char romFile[PATH_MAX + 1];
-       if (hgw_conf_request_string(hgw, kGConfRomFile, romFile) == HGW_ERR_NONE
-               && strlen(romFile) > 0) {
+       // Get ROM filename from Gconf
+       gchar *romFile = gconf_client_get_string(gcc, kGConfRomFile, 0);
+       if (romFile && strlen(romFile) > 0) {
                S9xSetRomFile(romFile);
        } else {
                printf("Exiting gracefully because there's no ROM in Gconf\n");
-               HgwDeinit();
+               OssoDeinit();
                exit(0);
        }
 
-       char sound = FALSE;
-       if (hgw_conf_request_bool(hgw, kGConfSound, &sound) == HGW_ERR_NONE) {
-               Config.enableAudio = sound ? true : false;
-       }
-
-       char turbo = FALSE;
-       if (hgw_conf_request_bool(hgw, kGConfTurboMode, &turbo) == HGW_ERR_NONE) {
-               Settings.TurboMode = turbo ? TRUE : FALSE;
-       }
+       // Read most of the non-player specific settings
+       Config.enableAudio = gconf_client_get_bool(gcc, kGConfSound, 0);
+       Settings.TurboMode = gconf_client_get_bool(gcc, kGConfTurboMode, 0);
+       Settings.Transparency = gconf_client_get_bool(gcc, kGConfTransparency, 0);
+       Settings.DisplayFrameRate = gconf_client_get_bool(gcc, kGConfDisplayFramerate, 0);
 
-       int frameskip = 0;
-       if (hgw_conf_request_int(hgw, kGConfFrameskip, &frameskip) == HGW_ERR_NONE) {
-               Settings.SkipFrames = (frameskip > 0 ? frameskip : AUTO_FRAMERATE);
-       }
-
-       char transparency = FALSE;
-       if (hgw_conf_request_bool(hgw, kGConfTransparency, &transparency) == HGW_ERR_NONE) {
-               Settings.Transparency = transparency ? TRUE : FALSE;
-       }
+       int frameskip = gconf_client_get_int(gcc, kGConfFrameskip, 0);
+       Settings.SkipFrames = (frameskip > 0 ? frameskip : AUTO_FRAMERATE);
 
-       char scaler[NAME_MAX];
-       if (hgw_conf_request_string(hgw, kGConfScaler, scaler) == HGW_ERR_NONE
-               && strlen(scaler) > 0) {
+       gchar *scaler = gconf_client_get_string(gcc, kGConfScaler, 0);
+       if (scaler && strlen(scaler) > 0) {
                free(Config.scaler);
                Config.scaler = strdup(scaler);
        }
-
-       char displayFramerate = FALSE;
-       if (hgw_conf_request_bool(hgw, kGConfDisplayFramerate, &displayFramerate) == HGW_ERR_NONE) {
-               Settings.DisplayFrameRate = displayFramerate ? TRUE : FALSE;
-       }
-
-#if TODO
-       char displayControls = FALSE;
-       if (hgw_conf_request_bool(hgw, kGConfDisplayControls, &displayControls) == HGW_ERR_NONE) {
-               Config.touchscreenShow = displayControls ? true : false;
+       g_free(scaler);
+
+       int speedhacks = gconf_client_get_int(gcc, kGConfSpeedhacks, 0);
+       if (speedhacks <= 0) {
+               Settings.HacksEnabled = FALSE;
+               Settings.HacksFilter = FALSE;
+       } else if (speedhacks == 1) {
+               Settings.HacksEnabled = TRUE;
+               Settings.HacksFilter = TRUE;
+       } else {
+               Settings.HacksEnabled = TRUE;
+               Settings.HacksFilter = FALSE;
        }
-#endif
 
-       int speedhacks = 0;
-       if (hgw_conf_request_int(hgw, kGConfSpeedhacks, &speedhacks) == HGW_ERR_NONE) {
-               if (speedhacks <= 0) {
-                       Settings.HacksEnabled = FALSE;
-                       Settings.HacksFilter = FALSE;
-               } else if (speedhacks == 1) {
-                       Settings.HacksEnabled = TRUE;
-                       Settings.HacksFilter = TRUE;
-               } else {
-                       Settings.HacksEnabled = TRUE;
-                       Settings.HacksFilter = FALSE;
-               }
-       }
        if (Settings.HacksEnabled && !Config.hacksFile) {
                // Provide a default speedhacks file
-               if (asprintf(&Config.hacksFile, "%s/snesadvance.dat", dirname(romFile))
+               gchar *romDir = g_path_get_dirname(romFile);
+               if (asprintf(&Config.hacksFile, "%s/snesadvance.dat", romDir)
                                < 0) {
                        Config.hacksFile = 0; // malloc error.
                }
-               // remember that dirname garbles romFile.
+               g_free(romDir);
        }
 
+       g_free(romFile);
+
        gchar key[kGConfPlayerPathBufferLen];
        gchar *relKey = key + sprintf(key, kGConfPlayerPath, 1);
 
@@ -146,77 +201,51 @@ void HgwConfig()
                createActionMappingsOnly();
        }
 
-       HgwStartCommand cmd = hgw_context_get_start_command(hgw);
-       switch (cmd) {
-               default:
-               case HGW_COMM_NONE:     // called from libosso
-               case HGW_COMM_CONT:
-                       Config.snapshotLoad = true;
+       // Iterate the event loop since we want to catch the initial dbus messages
+       while (startupCommand == STARTUP_COMMAND_UNKNOWN) {
+               // This is not busylooping since we are blocking here
+               g_main_context_iteration(mainContext, TRUE);
+       }
+
+       switch (startupCommand) {
+               case STARTUP_COMMAND_RUN:
+               case STARTUP_COMMAND_RESTART:
+                       Config.snapshotLoad = false;
                        Config.snapshotSave = true;
                        break;
-               case HGW_COMM_RESTART:
-                       Config.snapshotLoad = false;
+               case STARTUP_COMMAND_CONTINUE:
+                       Config.snapshotLoad = true;
                        Config.snapshotSave = true;
                        break;
-               case HGW_COMM_QUIT:
-                       // hum, what?
+               case STARTUP_COMMAND_QUIT:
                        Config.snapshotLoad = false;
                        Config.snapshotSave = false;
                        Config.quitting = true;
                        break;
+               default:
+                       Config.snapshotLoad = false;
+                       Config.snapshotSave = false;
+                       break;
        }
 
        g_object_unref(G_OBJECT(gcc));
 }
 
-void HgwPollEvents()
+void OssoPollEvents()
 {
-       if (!hgwLaunched) return;
-       
-       HgwMessage msg;
-       HgwMessageFlags flags = HGW_MSG_FLAG_NONE;
-       
-       if ( hgw_msg_check_incoming(hgw, &msg, flags) == HGW_ERR_COMMUNICATION ) {
-               // Message Incoming, process msg
-               
-               switch (msg.type) {
-                       case HGW_MSG_TYPE_CBREQ:
-                               switch (msg.e_val) {
-                                       case HGW_CB_QUIT:
-                                       case HGW_CB_EXIT:
-                                               Config.quitting = true;
-                                               break;
-                               }
-                               break;
-                       case HGW_MSG_TYPE_DEVSTATE:
-                               switch (msg.e_val) {
-                                       case HGW_DEVICE_STATE_SHUTDOWN:
-                                               Config.quitting = true; // try to quit gracefully
-                                               break;
-                               }
-                               break;
-                       default:
-                               // do nothing
-                               break;
-               }
-               
-               hgw_msg_free_data(&msg);
-       }
+       if (!OssoOk()) return;
+
+       //g_main_context_iteration(mainContext, FALSE);
 }
 
-// For now, please keep this in sync with ../gui/controls.c
 typedef struct ButtonEntry {
        const char * gconf_key;
        unsigned long mask;
        bool is_action;
 } ButtonEntry;
-#define BUTTON_INITIALIZER(button, name) \
-       { kGConfKeysPath "/" name, SNES_##button##_MASK, false }
-#define ACTION_INITIALIZER(action, name) \
-       { kGConfKeysPath "/" name, kAction##action, true }
-#define BUTTON_LAST    \
-       { 0 }
 
+/** This arrays contains generic info about each of the mappable buttons the
+       GUI shows */
 static const ButtonEntry buttons[] = {
 #define HELP(...)
 #define P(x) SNES_##x##_MASK
index f4f9be5..93085cf 100644 (file)
@@ -1,16 +1,25 @@
-#ifndef _PLATFORM_GUICONF_H_
-#define _PLATFORM_GUICONF_H_
+#ifndef _PLATFORM_OSSO_H_
+#define _PLATFORM_OSSO_H_
+
+#include <libosso.h>
 
 START_EXTERN_C
 
+extern osso_context_t *ossoContext;
+
+static inline int OssoOk()
+{
+       return ossoContext != NULL;
+}
+
 /** Called from main() before loading config; connects to DBus. */
-void GuiConfInit();
+void OssoInit();
 /** Called from main() before closing. */
-void HgwDeinit();
+void OssoDeinit();
 /** Called from main() after loading user config; loads GUI settings. */
-void HgwConfig();
+void OssoConfig();
 /** Called from main() in the event loop; polls DBus. */
-void GuiConfigPollEvents();
+void OssoPollEvents();
 
 END_EXTERN_C
 
index 8e510a6..41e7f62 100644 (file)
@@ -4,7 +4,7 @@
 #include "port.h"
 
 // Configuration and command line parsing
-void S9xLoadConfig(int argc, const char ** argv);
+void S9xLoadConfig(int argc, char ** argv);
 void S9xUnloadConfig();
 void S9xSetRomFile(const char * file);
 extern struct config {
@@ -41,7 +41,11 @@ extern struct gui {
        /** Scaling ratio */
        float ScaleX, ScaleY;
 } GUI;
+
+void S9xInitDisplay(int argc, char **argv);
+void S9xDeinitDisplay();
 void S9xVideoToggleFullscreen();
+void S9xSetTitle (const char *title);
 
 // Audio output
 void S9xInitAudioOutput();
@@ -49,10 +53,11 @@ void S9xDeinitAudioOutput();
 void S9xAudioOutputEnable(bool enable);
 
 // Input devices
-EXTERN_C void S9xInitInputDevices();
+void S9xInitInputDevices();
 void S9xDeinitInputDevices();
 void S9xInputScreenChanged();
 void S9xInputScreenDraw(int pixelSize, void * buffer, int pitch);
+void S9xProcessEvents(bool block);
 
 // Input actions
 #define kActionNone                                            0
index 8cab4cc..b07adbf 100644 (file)
 #include "soundux.h"
 #include "hacks.h"
 #include "snapshot.h"
-#include "hgw.h"
+#include "osso.h"
 
 #define kPollEveryNFrames              5               //Poll input only every this many frames
-#define kPollHgwEveryNFrames   10              //Poll dbus only every this many frames
+#define kPollOssoEveryNFrames  10              //Poll dbus only every this many frames
 
 #define TRACE printf("trace: %s:%s\n", __FILE__, __func__);
 #define DIE(format, ...) do { \
@@ -186,37 +186,37 @@ static inline void pollEvents() {
        static int frames = 0;
        
        if (++frames > kPollEveryNFrames) {
-               S9xProcessEvents(FALSE);
+               S9xProcessEvents(false);
                frames = 0;
        }
 }
 
-#if CONF_HGW
-/** Wraps HgwPollEvents, taking care of kPollHgwEveryNFrames */
-static inline void pollHgwEvents() {
+#if CONF_GUI
+/** Wraps OssoPollEvents, taking care of kPollOssoEveryNFrames */
+static inline void pollOssoEvents() {
        static int frames = 0;
        
-       if (!hgwLaunched) return;
+       if (!OssoOk()) return;
        
-       if (++frames > kPollHgwEveryNFrames) {
-               HgwPollEvents();
+       if (++frames > kPollOssoEveryNFrames) {
+               OssoPollEvents();
                frames = 0;
        }
 }
 #endif
 
-int main(int argc, const char ** argv) {       
+int main(int argc, char ** argv) {
        // Initialise SDL
        if (SDL_Init(0) < 0) 
                DIE("SDL_Init: %s", SDL_GetError());
 
        // Configure snes9x
-#if CONF_HGW
-       HgwInit();                                              // Hildon-games-wrapper initialization.
+#if CONF_GUI
+       OssoInit();                                             // Hildon-games-wrapper initialization.
 #endif
        S9xLoadConfig(argc, argv);              // Load config files and parse cmd line.
-#if CONF_HGW
-       HgwConfig();                                    // Apply specific hildon-games config.
+#if CONF_GUI
+       OssoConfig();                                   // Apply specific hildon-games config.
 #endif
 
        // S9x initialization
@@ -242,8 +242,8 @@ int main(int argc, const char ** argv) {
                frameSync();                    // May block, or set frameskip to true.
                S9xMainLoop();                  // Does CPU things, renders if needed.
                pollEvents();
-#if CONF_HGW
-               pollHgwEvents();
+#if CONF_GUI
+               pollOssoEvents();
 #endif
        } while (!Config.quitting);
        
@@ -261,8 +261,8 @@ int main(int argc, const char ** argv) {
        S9xGraphicsDeinit();
        Memory.Deinit();
        S9xUnloadConfig();
-#if CONF_HGW
-       HgwDeinit();
+#if CONF_GUI
+       OssoDeinit();
 #endif
 
        SDL_Quit();
index ecd7f63..e7dd266 100644 (file)
@@ -188,7 +188,7 @@ bool8 S9xReadSuperScopePosition(int& x, int& y, uint32& buttons)
        return TRUE;
 }
 
-void S9xProcessEvents(bool8_32 block)
+void S9xProcessEvents(bool block)
 {
        SDL_Event event;
 
index 180b795..0d9ff32 100644 (file)
@@ -174,7 +174,7 @@ static void drawOnscreenControls()
        }
 }
 
-void S9xInitDisplay(int argc, const char ** argv)
+void S9xInitDisplay(int argc, char ** argv)
 {      
        if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) 
                DIE("SDL_InitSubSystem(VIDEO): %s", SDL_GetError());