trying to use osso-games-startup as gui
authorJavier S. Pedro <maemo@javispedro.com>
Sun, 16 Aug 2009 01:17:21 +0000 (03:17 +0200)
committerJavier S. Pedro <maemo@javispedro.com>
Sun, 16 Aug 2009 01:17:21 +0000 (03:17 +0200)
25 files changed:
Makefile
debian/control
debian/dirs
debian/postinst [new file with mode: 0644]
debian/postinst.ex [deleted file]
gui/Makefile [new file with mode: 0644]
gui/drnoksnes.conf.m4 [new file with mode: 0755]
gui/drnoksnes.desktop.m4 [new file with mode: 0644]
gui/drnoksnes.game.m4 [new file with mode: 0644]
gui/drnoksnes.service.m4 [new file with mode: 0644]
gui/drnoksnes.startup.service.m4 [new file with mode: 0644]
gui/drnoksnes_plugin.so [new file with mode: 0755]
gui/icons/banner.inkscape.svg [new file with mode: 0644]
gui/icons/banner.png [new file with mode: 0644]
gui/icons/main.svg [new file with mode: 0644]
gui/icons/main.svg.inkscape [new file with mode: 0644]
gui/icons/main_26.png [new file with mode: 0644]
gui/icons/main_40.png [new file with mode: 0644]
gui/icons/main_64.png [new file with mode: 0644]
gui/plugin.c [new file with mode: 0644]
platform/config.cpp
platform/hgw.cpp [new file with mode: 0644]
platform/hgw.h [new file with mode: 0644]
platform/platform.h
platform/sdl.cpp

index f5be69a..d7f7a0f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,17 @@
 #!/usr/bin/make
 
-CPPFLAGS := -I. $(shell sdl-config --cflags) $(shell pkg-config --cflags x11 xsp)
-LDLIBS := -lz $(shell sdl-config --libs) $(shell pkg-config --libs x11 xsp) -lpopt
+CPPFLAGS := -I. $(shell sdl-config --cflags) $(shell pkg-config --cflags x11 xsp) -I/usr/include/hgw
+LDLIBS := -lz $(shell sdl-config --libs) $(shell pkg-config --libs x11 xsp) -lpopt -lhgw
 
 # Default CFLAGS for building in N8x0
 CFLAGS ?= -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp -Os -g -Wall -static-libgcc
 ASFLAGS ?= -march=armv6j -mfpu=vfp -mfloat-abi=softfp
 CXXFLAGS ?= $(CFLAGS)
 
+GAME_VERSION ?= 0.9.3
+export GAME_VERSION
+export DESTDIR
+
 # SNES stuff
 OBJS = 2xsaiwin.o apu.o c4.o c4emu.o cheats.o cheats2.o clip.o cpu.o cpuexec.o data.o
 OBJS += dma.o dsp1.o fxemu.o fxinst.o gfx.o globals.o loadzip.o memmap.o ppu.o
@@ -23,13 +27,14 @@ OBJS += hacks.o
 # the glue code that sticks it all together in a monstruous way
 OBJS += platform/path.o platform/statef.o platform/config.o
 OBJS += platform/sdl.o platform/sdlv.o platform/sdla.o platform/sdli.o
+OBJS += platform/hgw.o
 
 # automatic dependencies
 DEPS := $(OBJS:.o=.d)
 
-all: drnoksnes
+all: drnoksnes gui
 
-clean:
+clean: gui_clean
        rm -f drnoksnes *.o *.d platform/*.o platform/*.d
        rm -f build-stamp configure-stamp
 
@@ -42,6 +47,7 @@ drnoksnes: $(OBJS)
 
 install: drnoksnes
        install drnoksnes $(DESTDIR)/usr/games
+       $(MAKE) -C gui install
 
 deps: $(DEPS)
 %.d: %.cpp
@@ -51,4 +57,10 @@ deps: $(DEPS)
 %.d: %.s
        @touch $@
 
-.PHONY: all clean remake deps install
+gui:
+       $(MAKE) -C gui all
+       
+gui_clean:
+       $(MAKE) -C gui clean
+       
+.PHONY: all clean remake deps install gui gui_clean
index 176f9ea..615c748 100644 (file)
@@ -2,13 +2,14 @@ Source: drnoksnes
 Section: user/games
 Priority: extra
 Maintainer: Javier S. Pedro <maemo@javispedro.com>
-Build-Depends: debhelper (>= 5), pkg-config, maemo-version, libsdl1.2-dev,
+Build-Depends: debhelper (>= 5), pkg-config, maemo-version, m4, libsdl1.2-dev,
  libx11-dev, x11proto-core-dev, libxsp-dev, libpopt-dev, zlib1g-dev
 Standards-Version: 3.7.2
 
 Package: drnoksnes
 Architecture: armel
 Depends: ${shlibs:Depends}, ${misc:Depends}
+Pre-Depends: maemo-select-menu-location
 Description: Super Nintendo Entertainment System emulator
  A Super NES emulator, currently without interface but plan on adding one.
 
index 33359b8..8935047 100644 (file)
@@ -1 +1,11 @@
 usr/games
+usr/games/wrapper/games
+usr/lib
+usr/share
+usr/share/games
+usr/share/applications/hildon
+usr/share/dbus-1/services
+usr/share/icons/hicolor/26x26/hildon
+usr/share/icons/hicolor/40x40/hildon
+usr/share/icons/hicolor/scalable/hildon
+usr/share/pixmaps
diff --git a/debian/postinst b/debian/postinst
new file mode 100644 (file)
index 0000000..8d2ad0f
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+# postinst script for drnoksnes
+#
+# see: dh_installdeb(1)
+
+set -e
+
+case "$1" in
+    configure)
+       oldversion="$2"
+       if [ -z "$oldversion" ]; then
+               gtk-update-icon-cache -f /usr/share/icons/hicolor
+               maemo-select-menu-location drnoksnes.desktop
+       fi
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+
diff --git a/debian/postinst.ex b/debian/postinst.ex
deleted file mode 100644 (file)
index 5bc9484..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# postinst script for drnoksnes
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# summary of how this script can be called:
-#        * <postinst> `configure' <most-recently-configured-version>
-#        * <old-postinst> `abort-upgrade' <new version>
-#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-#          <new-version>
-#        * <postinst> `abort-remove'
-#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-#          <failed-install-package> <version> `removing'
-#          <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-
-case "$1" in
-    configure)
-    ;;
-
-    abort-upgrade|abort-remove|abort-deconfigure)
-    ;;
-
-    *)
-        echo "postinst called with unknown argument \`$1'" >&2
-        exit 1
-    ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
-
-
diff --git a/gui/Makefile b/gui/Makefile
new file mode 100644 (file)
index 0000000..7a3ea3e
--- /dev/null
@@ -0,0 +1,52 @@
+PKGS:=gtk+-2.0 hildon-1 hildon-fm-2 gconf-2.0
+CPPFLAGS:=$(shell pkg-config --cflags $(PKGS)) 
+CFLAGS?=-g -Os -Wall
+CFLAGS+=-fpic -shared
+LDLIBS:=$(shell pkg-config --libs $(PKGS))
+LDFLAGS:=-export-dynamic -avoid-version -module -shared
+
+#GAME_VERSION
+GAME_SHARE_PATH=/usr/share/games/drnoksnes/
+GAME_PLUGIN_PATH=/usr/lib/drnoksnes_plugin.so
+GAME_CONF_PATH=/usr/share/games/drnoksnes/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)
+
+DATA_FILES:=drnoksnes.conf drnoksnes.desktop drnoksnes.game 
+DATA_FILES+=drnoksnes.service drnoksnes.startup.service
+
+all: drnoksnes_plugin.so data
+
+drnoksnes_plugin.so: plugin.o
+       $(CC) $(LDFLAGS) $^ $(LDLIBS)-o $@
+       
+clean: 
+       rm -f noksnes_plugin.so *.o
+       rm -f $(DATA_FILES)
+
+%: %.m4
+       $(M4) $(M4DEFS) $^ > $@
+
+data: $(DATA_FILES)
+       
+install: all
+       mkdir -p $(DESTDIR)$(GAME_SHARE_PATH)
+       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
+       install -m 0644 icons/main_40.png $(DESTDIR)/usr/share/icons/hicolor/40x40/hildon/drnoksnes.png
+       install -m 0644 icons/main_64.png $(DESTDIR)/usr/share/icons/hicolor/scalable/hildon/drnoksnes.png
+       install -m 0644 icons/banner.png $(DESTDIR)$(GAME_BANNER_PATH)
+       
+.PHONY: all clean data install
+
diff --git a/gui/drnoksnes.conf.m4 b/gui/drnoksnes.conf.m4
new file mode 100755 (executable)
index 0000000..c372e9f
--- /dev/null
@@ -0,0 +1,10 @@
+[Startup Entry] 
+Name=drnoksnes
+Version=GAME_VERSION
+Title=DrNokSnes
+PluginPath=GAME_PLUGIN_PATH
+Image=GAME_BANNER_PATH
+ServiceName=com.javispedro.drnoksnes
+PathName=/com/javispedro/drnoksnes
+InterfaceName=com.javispedro.drnoksnes
+
diff --git a/gui/drnoksnes.desktop.m4 b/gui/drnoksnes.desktop.m4
new file mode 100644 (file)
index 0000000..9c860bd
--- /dev/null
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=GAME_VERSION
+Type=Application
+Name=DrNokSnes
+Exec=/usr/bin/osso_games_startup GAME_CONF_PATH
+Icon=drnoksnes
+X-Window-Icon=drnoksnes
+X-Window-Icon-Dimmed=drnoksnes
+X-Osso-Service=com.javispedro.drnoksnes.startup
+X-Osso-Type=application/x-executable
+X-HildonDesk-ShowInToolbar=true
+StartupWMClass=drnoksnes_startup
+
diff --git a/gui/drnoksnes.game.m4 b/gui/drnoksnes.game.m4
new file mode 100644 (file)
index 0000000..b276f23
--- /dev/null
@@ -0,0 +1,6 @@
+drnoksnes
+GAME_BIN_PATH
+com.javispedro.drnoksnes
+/com/javispedro/drnoksnes
+com.javispedro.drnoksnes
+GAME_VERSION
diff --git a/gui/drnoksnes.service.m4 b/gui/drnoksnes.service.m4
new file mode 100644 (file)
index 0000000..4f89aad
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=com.javispedro.drnoksnes
+Exec=/usr/games/wrapper/wrapper GAME_GAME_PATH
diff --git a/gui/drnoksnes.startup.service.m4 b/gui/drnoksnes.startup.service.m4
new file mode 100644 (file)
index 0000000..ed005c3
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=com.javispedro.drnoksnes.startup
+Exec=/usr/bin/osso_games_startup GAME_CONF_PATH
diff --git a/gui/drnoksnes_plugin.so b/gui/drnoksnes_plugin.so
new file mode 100755 (executable)
index 0000000..4803714
Binary files /dev/null and b/gui/drnoksnes_plugin.so differ
diff --git a/gui/icons/banner.inkscape.svg b/gui/icons/banner.inkscape.svg
new file mode 100644 (file)
index 0000000..16f5dc4
--- /dev/null
@@ -0,0 +1,216 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="648"
+   height="180"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   version="1.0"
+   sodipodi:docname="banner.inkscape.svg"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape"
+   inkscape:export-filename="/home/javier/Proyectos/Maemo/ports/snes/drnoksnes/gui/icons/banner.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <defs
+     id="defs4">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 526.18109 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+       id="perspective10" />
+    <linearGradient
+       gradientUnits="userSpaceOnUse"
+       xlink:href="#linearGradient3307"
+       id="linearGradient3313"
+       y2="77.016953"
+       x2="119.27966"
+       y1="77.016953"
+       x1="73.262711" />
+    <linearGradient
+       gradientUnits="userSpaceOnUse"
+       xlink:href="#linearGradient3299"
+       id="linearGradient3305"
+       y2="77.016953"
+       x2="119.27966"
+       y1="77.016953"
+       x1="73.262711" />
+    <linearGradient
+       gradientUnits="userSpaceOnUse"
+       xlink:href="#linearGradient3291"
+       id="linearGradient3297"
+       y2="77.016953"
+       x2="119.27966"
+       y1="77.016953"
+       x1="73.262711" />
+    <linearGradient
+       gradientUnits="userSpaceOnUse"
+       xlink:href="#linearGradient3283"
+       id="linearGradient3289"
+       y2="77.016953"
+       x2="119.27966"
+       y1="77.016953"
+       x1="73.262711" />
+    <linearGradient
+       id="linearGradient3283">
+      <stop
+         offset="0"
+         style="stop-color:#005dc7;stop-opacity:1"
+         id="stop3285" />
+      <stop
+         offset="1"
+         style="stop-color:#005dc7;stop-opacity:0"
+         id="stop3287" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3291">
+      <stop
+         offset="0"
+         style="stop-color:#00b386;stop-opacity:1"
+         id="stop3293" />
+      <stop
+         offset="1"
+         style="stop-color:#00b386;stop-opacity:0"
+         id="stop3295" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3299">
+      <stop
+         offset="0"
+         style="stop-color:#ffe867;stop-opacity:1"
+         id="stop3301" />
+      <stop
+         offset="1"
+         style="stop-color:#ffe867;stop-opacity:0"
+         id="stop3303" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3307">
+      <stop
+         offset="0"
+         style="stop-color:#ff4e60;stop-opacity:1"
+         id="stop3309" />
+      <stop
+         offset="1"
+         style="stop-color:#ff4e60;stop-opacity:0"
+         id="stop3311" />
+    </linearGradient>
+    <inkscape:perspective
+       id="perspective2481"
+       inkscape:persp3d-origin="64 : 42.666667 : 1"
+       inkscape:vp_z="128 : 64 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 64 : 1"
+       sodipodi:type="inkscape:persp3d" />
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="1.095679"
+     inkscape:cx="319.44914"
+     inkscape:cy="90"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:window-width="805"
+     inkscape:window-height="639"
+     inkscape:window-x="2023"
+     inkscape:window-y="176" />
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Capa 1"
+     inkscape:groupmode="layer"
+     id="layer1">
+    <path
+       sodipodi:type="arc"
+       style="opacity:0.40000000000000002;fill:#dfdbce;fill-opacity:1;stroke:#0b0b0b;stroke-opacity:0.19607843000000000"
+       id="path2508"
+       sodipodi:cx="109.52113"
+       sodipodi:cy="91.470421"
+       sodipodi:rx="85.79155"
+       sodipodi:ry="76.664787"
+       d="M 195.31268,91.470421 A 85.79155,76.664787 0 1 1 23.729584,91.470421 A 85.79155,76.664787 0 1 1 195.31268,91.470421 z" />
+    <g
+       id="g2500"
+       transform="translate(39.960361,22.115786)">
+      <path
+         style="opacity:0.7;fill:#e5dfd2;fill-opacity:1"
+         id="path3171"
+         transform="matrix(0.4890652,-0.6548594,0.4711844,8.998679e-2,5.297721,67.202483)"
+         d="M 105,44 C 105,79.898509 75.226936,109 38.5,109 C 1.7730641,109 -28,79.898509 -28,44 C -28,8.1014913 1.7730641,-21 38.5,-21 C 75.226936,-21 105,8.1014913 105,44 L 105,44 z" />
+      <path
+         style="opacity:1;fill:url(#linearGradient3297);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843"
+         id="path2383"
+         transform="matrix(0.9779006,0,0,0.9779006,-70.210358,-7.1517458)"
+         d="M 118.77966,77.016953 C 118.77966,89.44804 108.70227,99.525427 96.271186,99.525427 C 83.840099,99.525427 73.762712,89.44804 73.762712,77.016953 C 73.762712,64.585866 83.840099,54.508479 96.271186,54.508479 C 108.70227,54.508479 118.77966,64.585866 118.77966,77.016953 L 118.77966,77.016953 z" />
+      <path
+         style="opacity:0.4;fill:#e5dfd2;fill-opacity:1"
+         id="path3173"
+         transform="matrix(0.5635548,-0.5919725,0.4571188,0.1454466,40.171857,101.58554)"
+         d="M 105,44 C 105,79.898509 75.226936,109 38.5,109 C 1.7730641,109 -28,79.898509 -28,44 C -28,8.1014913 1.7730641,-21 38.5,-21 C 75.226936,-21 105,8.1014913 105,44 L 105,44 z" />
+      <path
+         style="fill:url(#linearGradient3305);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843"
+         id="path2387"
+         transform="matrix(0.9561694,0,0,0.9561694,-36.690798,30.535717)"
+         d="M 118.77966,77.016953 C 118.77966,89.44804 108.70227,99.525427 96.271186,99.525427 C 83.840099,99.525427 73.762712,89.44804 73.762712,77.016953 C 73.762712,64.585866 83.840099,54.508479 96.271186,54.508479 C 108.70227,54.508479 118.77966,64.585866 118.77966,77.016953 L 118.77966,77.016953 z" />
+      <path
+         style="fill:url(#linearGradient3313);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843"
+         id="path2397"
+         transform="matrix(1.1517496,0,0,1.1517496,-10.293958,-18.584689)"
+         d="M 118.77966,77.016953 C 118.77966,89.44804 108.70227,99.525427 96.271186,99.525427 C 83.840099,99.525427 73.762712,89.44804 73.762712,77.016953 C 73.762712,64.585866 83.840099,54.508479 96.271186,54.508479 C 108.70227,54.508479 118.77966,64.585866 118.77966,77.016953 L 118.77966,77.016953 z" />
+      <path
+         style="fill:url(#linearGradient3289);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843"
+         id="path2399"
+         transform="matrix(1.1734807,0,0,1.1734807,-50.037163,-61.797716)"
+         d="M 118.77966,77.016953 C 118.77966,89.44804 108.70227,99.525427 96.271186,99.525427 C 83.840099,99.525427 73.762712,89.44804 73.762712,77.016953 C 73.762712,64.585866 83.840099,54.508479 96.271186,54.508479 C 108.70227,54.508479 118.77966,64.585866 118.77966,77.016953 L 118.77966,77.016953 z" />
+    </g>
+    <text
+       xml:space="preserve"
+       style="font-size:48px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Droid Sans;-inkscape-font-specification:Droid Sans"
+       x="241.85916"
+       y="60.439438"
+       id="text3280"><tspan
+         sodipodi:role="line"
+         id="tspan3282"
+         x="241.85916"
+         y="60.439438">DrNokSnes</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-size:12px;font-style:normal;font-weight:normal;fill:#505050;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+       x="309.39719"
+       y="141.66762"
+       id="text3348"><tspan
+         sodipodi:role="line"
+         id="tspan3350"
+         x="309.39719"
+         y="141.66762">Based on DrPocketSnes, SquidgeSNES, PocketSNES,</tspan><tspan
+         sodipodi:role="line"
+         x="309.39719"
+         y="156.66762"
+         id="tspan3352">snes9x,  OpenSnes9x...</tspan></text>
+  </g>
+</svg>
diff --git a/gui/icons/banner.png b/gui/icons/banner.png
new file mode 100644 (file)
index 0000000..e0a3c29
Binary files /dev/null and b/gui/icons/banner.png differ
diff --git a/gui/icons/main.svg b/gui/icons/main.svg
new file mode 100644 (file)
index 0000000..3a00dd3
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   version="1.0"
+   width="128"
+   height="128"
+   id="svg2">
+  <defs
+     id="defs4">
+    <linearGradient
+       id="linearGradient3307">
+      <stop
+         id="stop3309"
+         style="stop-color:#ff4e60;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop3311"
+         style="stop-color:#ff4e60;stop-opacity:0"
+         offset="1" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3299">
+      <stop
+         id="stop3301"
+         style="stop-color:#ffe867;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop3303"
+         style="stop-color:#ffe867;stop-opacity:0"
+         offset="1" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3291">
+      <stop
+         id="stop3293"
+         style="stop-color:#00b386;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop3295"
+         style="stop-color:#00b386;stop-opacity:0"
+         offset="1" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3283">
+      <stop
+         id="stop3285"
+         style="stop-color:#005dc7;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop3287"
+         style="stop-color:#005dc7;stop-opacity:0"
+         offset="1" />
+    </linearGradient>
+    <linearGradient
+       x1="73.262711"
+       y1="77.016953"
+       x2="119.27966"
+       y2="77.016953"
+       id="linearGradient3289"
+       xlink:href="#linearGradient3283"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       x1="73.262711"
+       y1="77.016953"
+       x2="119.27966"
+       y2="77.016953"
+       id="linearGradient3297"
+       xlink:href="#linearGradient3291"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       x1="73.262711"
+       y1="77.016953"
+       x2="119.27966"
+       y2="77.016953"
+       id="linearGradient3305"
+       xlink:href="#linearGradient3299"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       x1="73.262711"
+       y1="77.016953"
+       x2="119.27966"
+       y2="77.016953"
+       id="linearGradient3313"
+       xlink:href="#linearGradient3307"
+       gradientUnits="userSpaceOnUse" />
+  </defs>
+  <g
+     id="layer1">
+    <path
+       d="M 105,44 A 66.5,65 0 1 1 -28,44 A 66.5,65 0 1 1 105,44 z"
+       transform="matrix(0.4890652,-0.6548594,0.4711844,8.998679e-2,5.297721,67.202483)"
+       id="path3171"
+       style="opacity:0.7;fill:#e5dfd2;fill-opacity:1" />
+    <path
+       d="M 118.77966,77.016953 A 22.508474,22.508474 0 1 1 73.762712,77.016953 A 22.508474,22.508474 0 1 1 118.77966,77.016953 z"
+       transform="matrix(0.9779006,0,0,0.9779006,-70.210358,-7.1517458)"
+       id="path2383"
+       style="opacity:1;fill:url(#linearGradient3297);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843" />
+    <path
+       d="M 105,44 A 66.5,65 0 1 1 -28,44 A 66.5,65 0 1 1 105,44 z"
+       transform="matrix(0.5635548,-0.5919725,0.4571188,0.1454466,40.171857,101.58554)"
+       id="path3173"
+       style="opacity:0.4;fill:#e5dfd2;fill-opacity:1" />
+    <path
+       d="M 118.77966,77.016953 A 22.508474,22.508474 0 1 1 73.762712,77.016953 A 22.508474,22.508474 0 1 1 118.77966,77.016953 z"
+       transform="matrix(0.9561694,0,0,0.9561694,-36.690798,30.535717)"
+       id="path2387"
+       style="fill:url(#linearGradient3305);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843" />
+    <path
+       d="M 118.77966,77.016953 A 22.508474,22.508474 0 1 1 73.762712,77.016953 A 22.508474,22.508474 0 1 1 118.77966,77.016953 z"
+       transform="matrix(1.1517496,0,0,1.1517496,-10.293958,-18.584689)"
+       id="path2397"
+       style="fill:url(#linearGradient3313);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843" />
+    <path
+       d="M 118.77966,77.016953 A 22.508474,22.508474 0 1 1 73.762712,77.016953 A 22.508474,22.508474 0 1 1 118.77966,77.016953 z"
+       transform="matrix(1.1734807,0,0,1.1734807,-50.037163,-61.797716)"
+       id="path2399"
+       style="fill:url(#linearGradient3289);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843" />
+  </g>
+</svg>
diff --git a/gui/icons/main.svg.inkscape b/gui/icons/main.svg.inkscape
new file mode 100644 (file)
index 0000000..15629c4
--- /dev/null
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="128"
+   height="128"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   version="1.0"
+   sodipodi:docname="main.svg.inkscape"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape"
+   inkscape:export-filename="/home/javier/Proyectos/Maemo/ports/snes/drnoksnes/gui/icons/main_26.png"
+   inkscape:export-xdpi="18.28125"
+   inkscape:export-ydpi="18.28125">
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.5"
+     inkscape:cx="64.997303"
+     inkscape:cy="64.121418"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     width="128px"
+     inkscape:window-width="1021"
+     inkscape:window-height="769"
+     inkscape:window-x="339"
+     inkscape:window-y="155" />
+  <defs
+     id="defs4">
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient3307">
+      <stop
+         style="stop-color:#ff4e60;stop-opacity:1;"
+         offset="0"
+         id="stop3309" />
+      <stop
+         style="stop-color:#ff4e60;stop-opacity:0;"
+         offset="1"
+         id="stop3311" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient3299">
+      <stop
+         style="stop-color:#ffe867;stop-opacity:1;"
+         offset="0"
+         id="stop3301" />
+      <stop
+         style="stop-color:#ffe867;stop-opacity:0;"
+         offset="1"
+         id="stop3303" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient3291">
+      <stop
+         style="stop-color:#00b386;stop-opacity:1;"
+         offset="0"
+         id="stop3293" />
+      <stop
+         style="stop-color:#00b386;stop-opacity:0;"
+         offset="1"
+         id="stop3295" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       id="linearGradient3283">
+      <stop
+         style="stop-color:#005dc7;stop-opacity:1;"
+         offset="0"
+         id="stop3285" />
+      <stop
+         style="stop-color:#005dc7;stop-opacity:0;"
+         offset="1"
+         id="stop3287" />
+    </linearGradient>
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 526.18109 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+       id="perspective10" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3283"
+       id="linearGradient3289"
+       x1="73.262712"
+       y1="77.016953"
+       x2="119.27966"
+       y2="77.016953"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3291"
+       id="linearGradient3297"
+       x1="73.262712"
+       y1="77.016953"
+       x2="119.27966"
+       y2="77.016953"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3299"
+       id="linearGradient3305"
+       x1="73.262712"
+       y1="77.016953"
+       x2="119.27966"
+       y2="77.016953"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3307"
+       id="linearGradient3313"
+       x1="73.262712"
+       y1="77.016953"
+       x2="119.27966"
+       y2="77.016953"
+       gradientUnits="userSpaceOnUse" />
+  </defs>
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Capa 1"
+     inkscape:groupmode="layer"
+     id="layer1">
+    <path
+       sodipodi:type="arc"
+       style="fill:#e5dfd2;fill-opacity:1;opacity:0.7"
+       id="path3171"
+       sodipodi:cx="38.5"
+       sodipodi:cy="44"
+       sodipodi:rx="66.5"
+       sodipodi:ry="65"
+       d="M 105,44 A 66.5,65 0 1 1 -28,44 A 66.5,65 0 1 1 105,44 z"
+       transform="matrix(0.4890652,-0.6548594,0.4711844,8.998679e-2,5.297721,67.202483)" />
+    <path
+       sodipodi:type="arc"
+       style="opacity:1;fill:url(#linearGradient3297);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843"
+       id="path2383"
+       sodipodi:cx="96.271187"
+       sodipodi:cy="77.016953"
+       sodipodi:rx="22.508474"
+       sodipodi:ry="22.508474"
+       d="M 118.77966,77.016953 A 22.508474,22.508474 0 1 1 73.762712,77.016953 A 22.508474,22.508474 0 1 1 118.77966,77.016953 z"
+       transform="matrix(0.9779006,0,0,0.9779006,-70.210358,-7.1517458)" />
+    <path
+       transform="matrix(0.5635548,-0.5919725,0.4571188,0.1454466,40.171857,101.58554)"
+       d="M 105,44 A 66.5,65 0 1 1 -28,44 A 66.5,65 0 1 1 105,44 z"
+       sodipodi:ry="65"
+       sodipodi:rx="66.5"
+       sodipodi:cy="44"
+       sodipodi:cx="38.5"
+       id="path3173"
+       style="fill:#e5dfd2;fill-opacity:1;opacity:0.4"
+       sodipodi:type="arc" />
+    <path
+       transform="matrix(0.9561694,0,0,0.9561694,-36.690798,30.535717)"
+       d="M 118.77966,77.016953 A 22.508474,22.508474 0 1 1 73.762712,77.016953 A 22.508474,22.508474 0 1 1 118.77966,77.016953 z"
+       sodipodi:ry="22.508474"
+       sodipodi:rx="22.508474"
+       sodipodi:cy="77.016953"
+       sodipodi:cx="96.271187"
+       id="path2387"
+       style="fill:url(#linearGradient3305);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843"
+       sodipodi:type="arc" />
+    <path
+       sodipodi:type="arc"
+       style="fill:url(#linearGradient3313);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843"
+       id="path2397"
+       sodipodi:cx="96.271187"
+       sodipodi:cy="77.016953"
+       sodipodi:rx="22.508474"
+       sodipodi:ry="22.508474"
+       d="M 118.77966,77.016953 A 22.508474,22.508474 0 1 1 73.762712,77.016953 A 22.508474,22.508474 0 1 1 118.77966,77.016953 z"
+       transform="matrix(1.1517496,0,0,1.1517496,-10.293958,-18.584689)" />
+    <path
+       transform="matrix(1.1734807,0,0,1.1734807,-50.037163,-61.797716)"
+       d="M 118.77966,77.016953 A 22.508474,22.508474 0 1 1 73.762712,77.016953 A 22.508474,22.508474 0 1 1 118.77966,77.016953 z"
+       sodipodi:ry="22.508474"
+       sodipodi:rx="22.508474"
+       sodipodi:cy="77.016953"
+       sodipodi:cx="96.271187"
+       id="path2399"
+       style="fill:url(#linearGradient3289);fill-opacity:1;fill-rule:evenodd;stroke:#0b0b0b;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.19607843"
+       sodipodi:type="arc" />
+  </g>
+</svg>
diff --git a/gui/icons/main_26.png b/gui/icons/main_26.png
new file mode 100644 (file)
index 0000000..82404cd
Binary files /dev/null and b/gui/icons/main_26.png differ
diff --git a/gui/icons/main_40.png b/gui/icons/main_40.png
new file mode 100644 (file)
index 0000000..16031e6
Binary files /dev/null and b/gui/icons/main_40.png differ
diff --git a/gui/icons/main_64.png b/gui/icons/main_64.png
new file mode 100644 (file)
index 0000000..a16850a
Binary files /dev/null and b/gui/icons/main_64.png differ
diff --git a/gui/plugin.c b/gui/plugin.c
new file mode 100644 (file)
index 0000000..ca51188
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+* This file is part of DrNokSnes
+*
+* Copyright (C) 2005 INdT - Instituto Nokia de Tecnologia
+* http://www.indt.org/maemo
+* Copyright (C) 2009 Javier S. Pedro <maemo@javispedro.com>
+*
+* This software is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public License
+* as published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*
+*/
+
+#include <stdio.h>
+#include <gtk/gtk.h>
+#include <startup_plugin.h>
+#include <gconf/gconf.h>
+#include <gconf/gconf-client.h>
+#include <hildon/hildon-file-chooser-dialog.h>
+
+#include "../platform/hgw.h"
+
+static GtkWidget * load_plugin(void);
+static void unload_plugin(void);
+static void write_config(void);
+static GtkWidget ** load_menu(guint *);
+static void update_menu(void);
+static void plugin_callback(GtkWidget * menu_item, gpointer data);
+
+GConfClient *gcc = NULL;
+static GameStartupInfo gs;
+GtkWidget *menu_items[2];
+
+static StartupPluginInfo plugin_info = {
+  load_plugin,
+  unload_plugin,
+  write_config,
+  load_menu,
+  update_menu,
+  plugin_callback
+};
+
+STARTUP_INIT_PLUGIN(plugin_info, gs, FALSE, TRUE)
+
+// Yes, I'm using the label not only to show but also save the current value.
+static GtkLabel * rom_label;
+
+static gchar *
+interface_file_chooser
+(GtkWindow * parent, GtkFileChooserAction action, const gchar * extension)
+{
+       GtkWidget * dialog;
+       GtkFileFilter * filter;
+       gchar * filename = NULL;
+
+       filter = gtk_file_filter_new();
+       gtk_file_filter_add_pattern(GTK_FILE_FILTER(filter), extension);
+
+       dialog = hildon_file_chooser_dialog_new_with_properties(parent, 
+               "action", action, "local_only", TRUE, "filter", filter, NULL);
+       gtk_widget_show_all(GTK_WIDGET(dialog));
+
+       if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+               filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+       }
+       
+       gtk_widget_destroy(dialog);
+       
+       return filename;
+}
+
+static void select_rom_callback(GtkWidget * button, gpointer data)
+{
+       gchar * filename = interface_file_chooser(
+               GTK_WINDOW(gtk_widget_get_parent_window(button)),
+               GTK_FILE_CHOOSER_ACTION_OPEN,
+               "*.smc");
+               
+       if (!filename) return;
+       
+       gtk_label_set_text(rom_label, filename);
+       
+       g_free(filename);
+}
+
+static GtkWidget * load_plugin(void)
+{
+       g_type_init();
+       gcc = gconf_client_get_default();
+
+       GtkWidget* parent = gtk_vbox_new(FALSE, HILDON_MARGIN_DEFAULT);
+       GtkWidget* parent_hbox = gtk_hbox_new(FALSE, HILDON_MARGIN_DEFAULT);
+       GtkWidget* selectRomBtn = gtk_button_new_with_label("Select ROM...");
+       rom_label = GTK_LABEL(gtk_label_new(NULL));
+       
+       gtk_widget_set_size_request(GTK_WIDGET(selectRomBtn),
+                                                               180, 50);
+                                                               
+       gtk_label_set_text(rom_label,
+                                               gconf_client_get_string(gcc, kGConfRomFile, NULL));
+                                                               
+
+       g_signal_connect(G_OBJECT(selectRomBtn), "clicked",
+                                       G_CALLBACK (select_rom_callback), NULL);
+
+       gtk_box_pack_start(GTK_BOX(parent_hbox), selectRomBtn, FALSE, FALSE, 0);
+       gtk_box_pack_end(GTK_BOX(parent_hbox), GTK_WIDGET(rom_label), TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(parent), parent_hbox, FALSE, FALSE, 0);
+
+       return parent;
+}
+
+static void unload_plugin(void)
+{
+       g_object_unref(gcc);
+}
+
+static void write_config(void)
+{
+       gconf_client_set_string(gcc, kGConfRomFile,
+        gtk_label_get_text(GTK_LABEL(rom_label)), NULL);
+}
+
+static GtkWidget **load_menu(guint *nitems)
+{
+       *nitems = 0;
+       
+       return NULL;
+}
+
+static void update_menu(void)
+{
+
+}
+
+static void plugin_callback(GtkWidget * menu_item, gpointer data)
+{
+
+}
+
index f21fd7d..4a186b5 100644 (file)
@@ -7,6 +7,7 @@
 #include "port.h"
 #include "snes9x.h"
 #include "display.h"
+#include "hgw.h"
 
 #define DIE(format, ...) do { \
                fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \
@@ -36,7 +37,7 @@ static const struct poptOption optionsTable[] = {
        { "turbo", 't', POPT_ARG_NONE, 0, 9,
        "Turbo mode (do not try to sleep between frames)", 0 },
        { "conf", 'c', POPT_ARG_STRING, 0, 10,
-       "Load extra configuration file", "FILE" },
+       "Extra configuration file to load", "FILE" },
        { "scancode", '\0', POPT_ARG_INT, 0, 100,
        "Scancode to map", "CODE" },
        { "button", '\0', POPT_ARG_STRING, 0, 101,
@@ -179,7 +180,7 @@ static void loadDefaults()
        Settings.AutoSaveDelay = 15*60; // Autosave each 15 minutes.
 }
 
-static void setRomFile(const char * path)
+void S9xSetRomFile(const char * path)
 {
        char drive[1], dir[PATH_MAX], fname[PATH_MAX], ext[PATH_MAX];
        
@@ -213,7 +214,7 @@ static void setHacks(const char * value)
                // Hack: the user probably wants to enable hacks
                // and use this argument as the ROM file.
                // Wonder why popt does not support this or if there's a better way.
-               setRomFile(value);
+               S9xSetRomFile(value);
        }
 }
 
@@ -312,7 +313,7 @@ static void parseArgs(poptContext optCon)
        /* if there's an extra unparsed arg it's our rom file */
        const char * extra_arg = poptGetArg(optCon);
        if (extra_arg) 
-               setRomFile(extra_arg);
+               S9xSetRomFile(extra_arg);
 }
 
 void S9xLoadConfig(int argc, const char ** argv)
@@ -332,7 +333,9 @@ void S9xLoadConfig(int argc, const char ** argv)
        // Command line parameters (including --conf args)
        parseArgs(optCon);
 
-       if (!gotRomFile()) {
+       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); 
diff --git a/platform/hgw.cpp b/platform/hgw.cpp
new file mode 100644 (file)
index 0000000..9243f1b
--- /dev/null
@@ -0,0 +1,92 @@
+#include <stdio.h>
+#include <hgw/hgw.h>
+
+#include "platform.h"
+#include "hgw.h"
+#include "snes9x.h"
+
+#define DIE(format, ...) do { \
+               fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \
+               fprintf(stderr, format "\n", ## __VA_ARGS__); \
+               abort(); \
+       } while (0);
+
+
+
+bool hgwLaunched;
+static HgwContext *hgw;
+
+void HgwInit()
+{
+       char* service = getenv("HGW_EXEC_SERVICE");
+       
+       if (!service) {
+               // Not launched from hildon-games-wrapper
+               hgwLaunched = false;
+               return;
+       }
+       
+       hgw = hgw_context_init();
+       
+       if (!hgw) {
+               fprintf(stderr, "Error opening hgw context\n");
+               hgwLaunched = false;
+       }
+       
+       hgwLaunched = true;
+       HgwStartCommand cmd = hgw_context_get_start_command(hgw);
+       // TODO Handle cmd in some way other than assuming HGW_COMM_RESTART
+       cmd;
+       
+       
+       
+}
+
+void HgwDeinit()
+{
+       if (!hgwLaunched) return;
+       
+       hgw_context_destroy(hgw, HGW_BYE_PAUSED);  // TODO
+       hgw = 0;
+}
+
+void HgwConfig()
+{
+       if (!hgwLaunched) return;
+       
+       Config.fullscreen = true;
+       
+       char romFile[PATH_MAX];
+       if (hgw_conf_request_string(hgw, kGConfRomFile, romFile) == HGW_ERR_NONE) {
+               S9xSetRomFile(romFile);
+       } else {
+               DIE("No Rom in Gconf!");
+       }
+}
+
+void HgwPollEvents()
+{
+       if (!hgwLaunched) return;
+       
+       HgwMessage *msg = 0;
+       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;
+               }
+               
+               hgw_msg_free_data(msg);
+       }
+}
+
+
diff --git a/platform/hgw.h b/platform/hgw.h
new file mode 100644 (file)
index 0000000..2b299ed
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _PLATFORM_HGW_H_
+#define _PLATFORM_HGW_H_
+
+#ifdef __cplusplus
+extern bool hgwLaunched;
+
+void HgwInit();
+void HgwDeinit();
+void HgwConfig();
+void HgwPollEvents();
+#endif
+
+#define kGConfPath "/apps/maemo/drnoksnes/"
+#define kGConfRomFile kGConfPath "rom"
+
+#endif
+
index b5d62b7..e4b73b9 100644 (file)
@@ -5,6 +5,7 @@
 
 // Configuration and command line parsing
 void S9xLoadConfig(int argc, const char ** argv);
+void S9xSetRomFile(const char * file);
 extern struct config {
        char romFile[PATH_MAX];
        char hacksFile[PATH_MAX];
index b347748..73a22bc 100644 (file)
 #include "memmap.h"
 #include "soundux.h"
 #include "hacks.h"
+#include "hgw.h"
 
-#define kPollEveryNFrames      4               //Poll input only every this many frames
+#define kPollEveryNFrames              5               //Poll input only every this many frames
+#define kPollHgwEveryNFrames   10              //Poll osso only every this many frames
 
 #define TRACE printf("trace: %s:%s\n", __FILE__, __func__);
 #define DIE(format, ...) do { \
@@ -171,13 +173,27 @@ static inline void pollEvents() {
        }
 }
 
+/** Wraps HgwPollEvents, taking care of kPollHgwEveryNFrames */
+static inline void pollHgwEvents() {
+       static int frames = 0;
+       
+       if (!hgwLaunched) return;
+       
+       if (++frames > kPollHgwEveryNFrames) {
+               HgwPollEvents();
+               frames = 0;
+       }
+}
+
 int main(int argc, const char ** argv) {       
        // Initialise SDL
        if (SDL_Init(0) < 0) 
                DIE("SDL_Init: %s", SDL_GetError());
        
        // Configure snes9x
-       S9xLoadConfig(argc, argv);
+       HgwInit();                                              // Hildon-games-wrapper initialization.
+       S9xLoadConfig(argc, argv);              // Load config files and parse cmd line.
+       HgwConfig();                                    // Apply specific hildon-games config.
        
        // S9x initialization
        S9xInitDisplay(argc, argv);
@@ -201,6 +217,7 @@ int main(int argc, const char ** argv) {
                frameSync();                    // May block, or set frameskip to true.
                S9xMainLoop();                  // Does CPU things, renders if needed.
                pollEvents();
+               pollHgwEvents();
        } while (!Config.quitting);
        
        // Deinitialization
@@ -214,6 +231,7 @@ int main(int argc, const char ** argv) {
        // Late deinitialization
        S9xGraphicsDeinit();
        Memory.Deinit();
+       HgwDeinit();
 
        SDL_Quit();