diff options
author | Johannes Schickel | 2010-10-13 03:57:44 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-10-13 03:57:44 +0000 |
commit | 75e8452b6e6a2bf4fb2f588aa00b428a60d873b5 (patch) | |
tree | f29541d55309487a94bd1d38e8b53bb3dde9aec6 /backends/platform/openpandora | |
parent | 48ee83b88957dab86bc763e9ef21a70179fa8679 (diff) | |
parent | e9f50882ea5b6beeefa994040be9d3bab6a1f107 (diff) | |
download | scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.gz scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.bz2 scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.zip |
OPENGL: Merged from trunk, from rev 52105 to 53396.
This includes an rather hacky attempt to merge all the recent gp2x backend
changes into the branch. I suppose the gp2x backend and probably all new
backends, i.e. gph, dingux etc., might not compile anymore.
Since I have no way of testing those it would be nice if porters could look
into getting those up to speed in this branch.
svn-id: r53399
Diffstat (limited to 'backends/platform/openpandora')
21 files changed, 1032 insertions, 0 deletions
diff --git a/backends/platform/openpandora/build/PXML.xml b/backends/platform/openpandora/build/PXML.xml new file mode 100755 index 0000000000..f4d2e2a595 --- /dev/null +++ b/backends/platform/openpandora/build/PXML.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<PXML xmlns="http://openpandora.org/namespaces/PXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PXML_schema.xsd"> + + <application id="scummvm.djwillis.0001" appdata="scummvm"> + + <title lang="en_US">ScummVM</title> + + <exec command="./runscummvm.sh"/> + <icon src="icon/scummvm.png"/> + + <previewpics> + <pic src="icon/preview-pic.png"/> + </previewpics> + + <info name="ScummVM Documentation" type="text/html" src="docs/index.html"/> + + <description lang="en_US">Point & click game interpreter.</description> + + <author name="DJWillis" website="http://www.scummvm.org/"/> + + <version major="1" minor="1" release="1" build="1"/><!--This programs version--> + <osversion major="1" minor="0" release="0" build="0"/><!--The minimum OS version required--> + + <categories> + <category name="Game"><!--category like "Games", "Graphics", "Internet" etc--> + <subcategory name="Adventure Games"/><!--subcategory, like "Board Games", "Strategy", "First Person Shooters"--> + </category> + </categories> + + <clockspeed frequency="500"/><!--Frequency in Hz--> + + </application> + +</PXML> diff --git a/backends/platform/openpandora/build/README-OPENPANDORA b/backends/platform/openpandora/build/README-OPENPANDORA new file mode 100755 index 0000000000..c3aa5e8ea9 --- /dev/null +++ b/backends/platform/openpandora/build/README-OPENPANDORA @@ -0,0 +1,19 @@ +ScummVM - OPENPANDORA SPECIFIC README - HEAD SVN +------------------------------------------------------------------------ +Please refer to the: + +ScummVM Forum: <http://forums.scummvm.org/> +WiKi: <http://wiki.scummvm.org/index.php/OpenPandora> + +for the most current information on the port and any updates to this +documentation. + +The wiki includes detailed instructions on how to use the port and +control information. + +------------------------------------------------------------------------ +Credits + +Core ScummVM code (c) The ScummVM Team +OpenPandora backend (c) John Willis +Detailed (c) information can be found within the source code diff --git a/backends/platform/openpandora/build/README-PND.txt b/backends/platform/openpandora/build/README-PND.txt new file mode 100755 index 0000000000..942c3a43e2 --- /dev/null +++ b/backends/platform/openpandora/build/README-PND.txt @@ -0,0 +1,38 @@ +ScummVM - OPENPANDORA README - HOW TO INSTALL +------------------------------------------------------------------------ + +Please refer to the: + +ScummVM Forum: <http://forums.scummvm.org/> +WiKi: <http://wiki.scummvm.org/index.php/OpenPandora> + +for the most current information on the port and any updates to this +documentation. + +------------------------------------------------------------------------ +Installing: + +This archive contains ScummVM in a PND format ready to be copied to the +OpenPandora and used. + +To install just copy the .pnd file from this archive to your device. + +You will need to place the .pnd file in a suitable location on your SD +card. + +/pandora/desktop <- place here if you wish the icon to show on the + desktop. Documentation will show in the menu. + +/pandora/menu <- place here if you wish the icon to show on the + Xfce menu. Documentation will show in the menu. + +/pandora/apps <- place here if you wish the icon to show on the + desktop and in the menu. Documentation will show + in the menu. + +------------------------------------------------------------------------ +Credits + +Core ScummVM code (c) The ScummVM Team +OpenPandora backend (c) John Willis +Detailed (c) information can be found within the source code diff --git a/backends/platform/openpandora/build/build.sh b/backends/platform/openpandora/build/build.sh new file mode 100755 index 0000000000..10b98fe092 --- /dev/null +++ b/backends/platform/openpandora/build/build.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +echo Quick script to make building all the time less painful. + +. /usr/local/angstrom/arm/environment-setup + +CROSS_COMPILE=arm-angstrom-linux-gnueabi- +export CROSS_COMPILE + +# Export the tool names for cross-compiling +export CXX=arm-angstrom-linux-gnueabi-g++ +export CC=arm-angstrom-linux-gnueabi-gcc +export DEFINES=-DNDEBUG + +cd ../../../.. + +echo Building ScummVM/OpenPandora. +make + +echo Build for OpenPandora complete - Please check build logs. diff --git a/backends/platform/openpandora/build/bundle.sh b/backends/platform/openpandora/build/bundle.sh new file mode 100755 index 0000000000..12d34380bc --- /dev/null +++ b/backends/platform/openpandora/build/bundle.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +. /usr/local/angstrom/arm/environment-setup + +CROSS_COMPILE=arm-angstrom-linux-gnueabi- +export CROSS_COMPILE + +echo Quick script to make building a distribution of the OpenPanodra backend more consistent. + +cd ../../../.. + +make op-bundle +make op-pnd diff --git a/backends/platform/openpandora/build/clean.sh b/backends/platform/openpandora/build/clean.sh new file mode 100755 index 0000000000..3574db2298 --- /dev/null +++ b/backends/platform/openpandora/build/clean.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +echo Quick script to make building all the time less painful. + +. /usr/local/angstrom/arm/environment-setup + +cd ../../../.. + +echo Cleaning ScummVM for the OpenPandora. +make clean diff --git a/backends/platform/openpandora/build/config-alleng.sh b/backends/platform/openpandora/build/config-alleng.sh new file mode 100755 index 0000000000..cd9a17ef40 --- /dev/null +++ b/backends/platform/openpandora/build/config-alleng.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +echo Quick script to make running configure all the time less painful +echo and let all the build work be done from the backend/build folder. + +. /usr/local/angstrom/arm/environment-setup + +CROSS_COMPILE=arm-angstrom-linux-gnueabi- +export CROSS_COMPILE + +# Export the tool names for cross-compiling +export CXX=arm-angstrom-linux-gnueabi-g++ +export CPPFLAGS=-I/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include +export LDFLAGS=-L/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/lib + +export DEFINES=-DNDEBUG + +# Edit the configure line to suit. +cd ../../../.. +./configure --backend=openpandora --host=openpandora --disable-nasm --with-sdl-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/bin --with-mpeg2-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --disable-vorbis --enable-tremor --with-tremor-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --enable-zlib --with-zlib-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --enable-mad --with-mad-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --enable-all-engines --enable-plugins --default-dynamic + +echo Generating config for OpenPandora complete. Check for errors. diff --git a/backends/platform/openpandora/build/config.sh b/backends/platform/openpandora/build/config.sh new file mode 100755 index 0000000000..8be16f1317 --- /dev/null +++ b/backends/platform/openpandora/build/config.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +echo Quick script to make running configure all the time less painful +echo and let all the build work be done from the backend/build folder. + +. /usr/local/angstrom/arm/environment-setup + +CROSS_COMPILE=arm-angstrom-linux-gnueabi- +export CROSS_COMPILE + +# Export the tool names for cross-compiling +export CXX=arm-angstrom-linux-gnueabi-g++ +export CPPFLAGS=-I/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/include +export LDFLAGS=-L/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/lib + +export DEFINES=-DNDEBUG + +# Edit the configure line to suit. +cd ../../../.. +./configure --backend=openpandora --host=openpandora --disable-nasm --with-sdl-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/bin --with-mpeg2-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --disable-vorbis --enable-tremor --with-tremor-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --enable-zlib --with-zlib-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --enable-mad --with-mad-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --enable-plugins --default-dynamic + +echo Generating config for OpenPandora complete. Check for errors. diff --git a/backends/platform/openpandora/build/icon/preview-pic.png b/backends/platform/openpandora/build/icon/preview-pic.png Binary files differnew file mode 100755 index 0000000000..2f4a536d30 --- /dev/null +++ b/backends/platform/openpandora/build/icon/preview-pic.png diff --git a/backends/platform/openpandora/build/icon/scummvm.png b/backends/platform/openpandora/build/icon/scummvm.png Binary files differnew file mode 100755 index 0000000000..128e59efc4 --- /dev/null +++ b/backends/platform/openpandora/build/icon/scummvm.png diff --git a/backends/platform/openpandora/build/index.html b/backends/platform/openpandora/build/index.html new file mode 100755 index 0000000000..34d381d0f8 --- /dev/null +++ b/backends/platform/openpandora/build/index.html @@ -0,0 +1,26 @@ +<html> + +<h3> + <p>Welcome to the ScummVM!</p> +</h3> + +<h4> + <p>ScummVM: OpenPandora Specific Documentation</p> +</h4> + +<A href="docs/README-OPENPANDORA">ScummVM OpenPandora README</a><br/> +<A href="http://scummvm.distant-earth.com/">ScummVM OpenPandora Website</a><br/> +<A href="http://wiki.scummvm.org/index.php/OpenPandora">ScummVM OpenPandora WiKi</a><br/> + +<h4> + <p>ScummVM: General Documentation</p> +</h4> + +<A href="http://www.scummvm.org/">ScummVM website</a><br/> +<A href="docs/README">ScummVM README</a><br/> +<A href="docs/NEWS">ScummVM NEWS</a><br/> +<A href="docs/AUTHORS">ScummVM Authors</a><br/> +<A href="docs/COPYRIGHT">ScummVM Copyright</a><br/> +<A href="docs/COPYING">GPL Licence</a><br/> + +</html> diff --git a/backends/platform/openpandora/build/pnd_make.sh b/backends/platform/openpandora/build/pnd_make.sh new file mode 100755 index 0000000000..b19de87bb4 --- /dev/null +++ b/backends/platform/openpandora/build/pnd_make.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +######adjust path of genpxml.sh if you want to use that "feture"##### + +TEMP=`getopt -o p:d:x:i:c -- "$@"` + +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + +eval set -- "$TEMP" +while true ; do + case "$1" in + -p) echo "PNDNAME set to $2" ;PNDNAME=$2;shift 2;; + -d) echo "FOLDER set to $2" ;FOLDER=$2;shift 2 ;; + -x) echo "PXML set to $2" ;PXML=$2;shift 2 ;; + -i) echo "ICON set to $2" ;ICON=$2;shift 2 ;; + -c) echo "-c set, will create compressed squasfs image instead of iso $2" ;SQUASH=1;shift 1 ;; + --) shift ; break ;; + *) echo "Error while parsing arguments! $2" ; exit 1 ;; + esac +done + +rnd=$RANDOM; # random number for genpxml and index$rnd.xml + +#generate pxml if guess or empty +if [ ! $PXML ] || [ $PXML = "guess" ] && [ $PNDNAME ] && [ $FOLDER ]; then + PXMLtxt=$(/home/user/libpnd/pandora-libraries/testdata/scripts/genpxml.sh $FOLDER $ICON) + PXML=$FOLDER/PXML.xml + echo "$PXMLtxt" > $FOLDER/PXML.xml +fi + +#check arguments +if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; then + echo " Usage: pnd_make.sh -p your.pnd -d folder/containing/your/app/ -x + your.pxml (or \"guess\" to try to generate it from the folder) -i icon.png" + exit 1 +fi +if [ ! -d $FOLDER ]; then echo "$FOLDER doesnt exist"; exit 1; fi #check if folder actually exists +if [ ! -f $PXML ]; then echo "$PXML doesnt exist"; exit 1; fi #check if pxml actually exists + +#make iso from folder +if [ ! $SQUASH ]; then + mkisofs -o $PNDNAME.iso -R $FOLDER +else + if [ $(mksquashfs -version | awk '{if ($3 >= 4) print 1}') = 1 ]; then + echo "your squashfs version is older then version 4, please upgrade to 4.0 or later" + exit 1 + fi + mksquashfs -no-recovery -nopad $FOLDER $PNDNAME.iso +fi +#append pxml to iso +cat $PNDNAME.iso $PXML > $PNDNAME +rm $PNDNAME.iso #cleanup + +#append icon if specified +if [ $ICON ]; then # check if we want to add an icon + if [ ! -f $ICON ]; then #does the icon actually exist? + echo "$ICON doesnt exist" + else # yes + mv $PNDNAME $PNDNAME.tmp + cat $PNDNAME.tmp $ICON > $PNDNAME # append icon + rm $PNDNAME.tmp #cleanup + fi +fi + +if [ $PXML = "guess" ];then rm $FOLDER/PXML.xml; fi #cleanup diff --git a/backends/platform/openpandora/build/runscummvm.sh b/backends/platform/openpandora/build/runscummvm.sh new file mode 100755 index 0000000000..48d24a2b81 --- /dev/null +++ b/backends/platform/openpandora/build/runscummvm.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# Make sure any extra libs not in the firmware are pulled in. +LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../lib +export LD_LIBRARY_PATH + +# Ensure we have a folder to store save games on the SD card. +mkdir saves + +# make a runtime dir, just incase it creates anything in CWD +mkdir runtime +cd runtime + +../bin/scummvm --fullscreen --gfx-mode=2x --config=../scummvm.config diff --git a/backends/platform/openpandora/module.mk b/backends/platform/openpandora/module.mk new file mode 100755 index 0000000000..1e5f6bcd69 --- /dev/null +++ b/backends/platform/openpandora/module.mk @@ -0,0 +1,16 @@ +MODULE := backends/platform/openpandora + +MODULE_OBJS := \ + op-graphics.o \ + op-events.o \ + op-options.o \ + op-main.o + +MODULE_DIRS += \ + backends/platform/openpandora/ + +# We don't use the rules.mk here on purpose +OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) $(OBJS) + +# Hack to ensure the SDL backend is built so we can use OSystem_SDL. +-include $(srcdir)/backends/platform/sdl/module.mk diff --git a/backends/platform/openpandora/op-bundle.mk b/backends/platform/openpandora/op-bundle.mk new file mode 100755 index 0000000000..163f4711ce --- /dev/null +++ b/backends/platform/openpandora/op-bundle.mk @@ -0,0 +1,85 @@ +# Special target to create bundles and PND's for the OpenPandora. + +#bundle_name = release/scummvm-op-`date '+%Y-%m-%d'` +bundle_name = release/scummvm-op +f=$(shell which $(STRIP)) +libloc = $(shell dirname $(f)) + +op-bundle: $(EXECUTABLE) + $(MKDIR) "$(bundle_name)" + $(MKDIR) "$(bundle_name)/scummvm" + $(MKDIR) "$(bundle_name)/scummvm/bin" + $(MKDIR) "$(bundle_name)/scummvm/data" + $(MKDIR) "$(bundle_name)/scummvm/docs" + $(MKDIR) "$(bundle_name)/scummvm/icon" + $(MKDIR) "$(bundle_name)/scummvm/lib" + + $(CP) $(srcdir)/backends/platform/openpandora/build/runscummvm.sh $(bundle_name)/scummvm/ + $(CP) $(srcdir)/backends/platform/openpandora/build/PXML.xml $(bundle_name)/scummvm/data/ + + $(CP) $(srcdir)/backends/platform/openpandora/build/icon/scummvm.png $(bundle_name)/scummvm/icon/ + $(CP) $(srcdir)/backends/platform/openpandora/build/icon/preview-pic.png $(bundle_name)/scummvm/icon/ + + + $(CP) $(srcdir)/backends/platform/openpandora/build/README-OPENPANDORA $(bundle_name)/scummvm/docs/ + $(CP) $(srcdir)/backends/platform/openpandora/build/index.html $(bundle_name)/scummvm/docs/ + + $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/docs/ + + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/data/ + $(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) $(bundle_name)/scummvm/data/ + + $(STRIP) $(EXECUTABLE) -o $(bundle_name)/scummvm/bin/$(EXECUTABLE) + +ifdef DYNAMIC_MODULES + $(INSTALL) -d "$(bundle_name)/scummvm/plugins" + $(INSTALL) -c -m 644 $(PLUGINS) "$(bundle_name)/scummvm/plugins" + $(STRIP) $(bundle_name)/scummvm/plugins/* +endif + + $(CP) $(libloc)/../arm-angstrom-linux-gnueabi/usr/lib/libFLAC.so.8.2.0 $(bundle_name)/scummvm/lib/libFLAC.so.8 + tar -C $(bundle_name) -cvjf $(bundle_name).tar.bz2 . + rm -R ./$(bundle_name) + +op-pnd: $(EXECUTABLE) + $(MKDIR) "$(bundle_name)" + $(MKDIR) "$(bundle_name)/scummvm" + $(MKDIR) "$(bundle_name)/scummvm/bin" + $(MKDIR) "$(bundle_name)/scummvm/data" + $(MKDIR) "$(bundle_name)/scummvm/docs" + $(MKDIR) "$(bundle_name)/scummvm/icon" + $(MKDIR) "$(bundle_name)/scummvm/lib" + + $(CP) $(srcdir)/backends/platform/openpandora/build/runscummvm.sh $(bundle_name)/scummvm/ + $(CP) $(srcdir)/backends/platform/openpandora/build/PXML.xml $(bundle_name)/scummvm/data/ + + $(CP) $(srcdir)/backends/platform/openpandora/build/icon/scummvm.png $(bundle_name)/scummvm/icon/ + $(CP) $(srcdir)/backends/platform/openpandora/build/icon/preview-pic.png $(bundle_name)/scummvm/icon/ + + + $(CP) $(srcdir)/backends/platform/openpandora/build/README-OPENPANDORA $(bundle_name)/scummvm/docs/ + $(CP) $(srcdir)/backends/platform/openpandora/build/index.html $(bundle_name)/scummvm/docs/ + + $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/docs/ + + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/data/ + $(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) $(bundle_name)/scummvm/data/ + + $(STRIP) $(EXECUTABLE) -o $(bundle_name)/scummvm/bin/$(EXECUTABLE) + +ifdef DYNAMIC_MODULES + $(INSTALL) -d "$(bundle_name)/scummvm/plugins" + $(INSTALL) -c -m 644 $(PLUGINS) "$(bundle_name)/scummvm/plugins" + $(STRIP) $(bundle_name)/scummvm/plugins/* +endif + + $(CP) $(libloc)/../arm-angstrom-linux-gnueabi/usr/lib/libFLAC.so.8.2.0 $(bundle_name)/scummvm/lib/libFLAC.so.8 + + $(srcdir)/backends/platform/openpandora/build/pnd_make.sh -p $(bundle_name).pnd -d $(bundle_name)/scummvm -x $(bundle_name)/scummvm/data/PXML.xml -i $(bundle_name)/scummvm/icon/scummvm.png + + $(CP) $(srcdir)/backends/platform/openpandora/build/README-PND.txt $(bundle_name) + tar -cvjf $(bundle_name)-pnd.tar.bz2 $(bundle_name).pnd $(bundle_name)/README-PND.txt + rm -R ./$(bundle_name) +# rm $(bundle_name).pnd + +.PHONY: op-bundle op-pnd diff --git a/backends/platform/openpandora/op-events.cpp b/backends/platform/openpandora/op-events.cpp new file mode 100755 index 0000000000..24283aa8ba --- /dev/null +++ b/backends/platform/openpandora/op-events.cpp @@ -0,0 +1,176 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* + * OpenPandora: Device Specific Event Handling. + * + */ + +#include "backends/platform/openpandora/op-sdl.h" +#include "backends/platform/openpandora/op-options.h" + +/* Quick default button states for modifiers. */ +int BUTTON_STATE_L = false; + +enum { + /* Touchscreen TapMode */ + TAPMODE_LEFT = 0, + TAPMODE_RIGHT = 1, + TAPMODE_HOVER = 2 +}; + +/* On the OpenPandora by default the ABXY and L/R Trigger buttons are returned by SDL as + (A): SDLK_HOME (B): SDLK_END (X): SDLK_PAGEDOWN (Y): SDLK_PAGEUP (L): SDLK_RSHIFT (R): SDLK_RCTRL +*/ + +bool OSystem_OP::handleKeyDown(SDL_Event &ev, Common::Event &event) { + switch (ev.key.keysym.sym) { + case SDLK_HOME: + event.type = Common::EVENT_LBUTTONDOWN; + fillMouseEvent(event, _km.x, _km.y); + return true; + break; + case SDLK_END: + event.type = Common::EVENT_RBUTTONDOWN; + fillMouseEvent(event, _km.x, _km.y); + return true; + break; + case SDLK_PAGEDOWN: + event.type = Common::EVENT_MAINMENU; + return true; + break; + case SDLK_PAGEUP: + OP::ToggleTapMode(); + if (OP::tapmodeLevel == TAPMODE_LEFT) { + displayMessageOnOSD("Touchscreen 'Tap Mode' - Left Click"); + } else if (OP::tapmodeLevel == TAPMODE_RIGHT) { + displayMessageOnOSD("Touchscreen 'Tap Mode' - Right Click"); + } else if (OP::tapmodeLevel == TAPMODE_HOVER) { + displayMessageOnOSD("Touchscreen 'Tap Mode' - Hover (No Click)"); + } + break; + case SDLK_RSHIFT: + BUTTON_STATE_L = true; + break; + case SDLK_RCTRL: + break; + default: + return OSystem_SDL::handleKeyDown(ev, event); + break; + } + return false; +} + +bool OSystem_OP::handleKeyUp(SDL_Event &ev, Common::Event &event) { + switch (ev.key.keysym.sym) { + case SDLK_HOME: + event.type = Common::EVENT_LBUTTONUP; + fillMouseEvent(event, _km.x, _km.y); + return true; + break; + case SDLK_END: + event.type = Common::EVENT_RBUTTONUP; + fillMouseEvent(event, _km.x, _km.y); + return true; + break; + case SDLK_PAGEDOWN: + event.type = Common::EVENT_MAINMENU; + return true; + break; + case SDLK_PAGEUP: + break; + case SDLK_RSHIFT: + BUTTON_STATE_L = false; + break; + case SDLK_RCTRL: + break; + default: + return OSystem_SDL::handleKeyUp(ev, event); + break; + } + return false; +} + +/* Custom handleMouseButtonDown/handleMouseButtonUp to deal with 'Tap Mode' for the touchscreen */ + +bool OSystem_OP::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { + if (ev.button.button == SDL_BUTTON_LEFT){ + if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */ + event.type = Common::EVENT_RBUTTONDOWN; + else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */ + event.type = Common::EVENT_LBUTTONDOWN; + else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */ + event.type = Common::EVENT_RBUTTONDOWN; + else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ + event.type = Common::EVENT_MOUSEMOVE; + else + event.type = Common::EVENT_LBUTTONDOWN; /* For normal mice etc. */ + } + else if (ev.button.button == SDL_BUTTON_RIGHT) + event.type = Common::EVENT_RBUTTONDOWN; +#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN) + else if (ev.button.button == SDL_BUTTON_WHEELUP) + event.type = Common::EVENT_WHEELUP; + else if (ev.button.button == SDL_BUTTON_WHEELDOWN) + event.type = Common::EVENT_WHEELDOWN; +#endif +#if defined(SDL_BUTTON_MIDDLE) + else if (ev.button.button == SDL_BUTTON_MIDDLE) + event.type = Common::EVENT_MBUTTONDOWN; +#endif + else + return false; + + fillMouseEvent(event, ev.button.x, ev.button.y); + + return true; +} + +bool OSystem_OP::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { + if (ev.button.button == SDL_BUTTON_LEFT){ + if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */ + event.type = Common::EVENT_RBUTTONUP; + else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */ + event.type = Common::EVENT_LBUTTONUP; + else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */ + event.type = Common::EVENT_RBUTTONUP; + else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ + event.type = Common::EVENT_MOUSEMOVE; + else + event.type = Common::EVENT_LBUTTONUP; /* For normal mice etc. */ + } + else if (ev.button.button == SDL_BUTTON_RIGHT) + event.type = Common::EVENT_RBUTTONUP; +#if defined(SDL_BUTTON_MIDDLE) + else if (ev.button.button == SDL_BUTTON_MIDDLE) + event.type = Common::EVENT_MBUTTONUP; +#endif + else + return false; + + fillMouseEvent(event, ev.button.x, ev.button.y); + + return true; +} diff --git a/backends/platform/openpandora/op-graphics.cpp b/backends/platform/openpandora/op-graphics.cpp new file mode 100755 index 0000000000..ef95f52e99 --- /dev/null +++ b/backends/platform/openpandora/op-graphics.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "backends/platform/openpandora/op-sdl.h" +#include "common/mutex.h" +#include "common/translation.h" +#include "common/util.h" + +#include "graphics/scaler/aspect.h" +#include "graphics/surface.h" + +bool OSystem_OP::loadGFXMode() { + /* FIXME: For now we just cheat and set the overlay to 640*480 not 800*480 and let SDL + deal with the boarders (it saves cleaning up the overlay when the game screen is + smaller than the overlay ;) + */ + _videoMode.overlayWidth = 640; + _videoMode.overlayHeight = 480; + _videoMode.fullscreen = true; + + if (_videoMode.screenHeight != 200 && _videoMode.screenHeight != 400) + _videoMode.aspectRatioCorrection = false; + + OSystem_SDL::loadGFXMode(); + + return true; + +} diff --git a/backends/platform/openpandora/op-main.cpp b/backends/platform/openpandora/op-main.cpp new file mode 100755 index 0000000000..4febd404c3 --- /dev/null +++ b/backends/platform/openpandora/op-main.cpp @@ -0,0 +1,265 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/scummsys.h" +#include <SDL/SDL.h> + +#include "backends/platform/openpandora/op-sdl.h" +#include "backends/plugins/posix/posix-provider.h" +#include "base/main.h" + +#include "common/archive.h" +#include "common/config-manager.h" +#include "common/debug.h" +#include "common/events.h" +#include "common/util.h" + +#include "common/file.h" +#include "base/main.h" + +#include "backends/saves/default/default-saves.h" + +#include "backends/timer/default/default-timer.h" +#include "sound/mixer_intern.h" + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <limits.h> +#include <errno.h> +#include <sys/stat.h> +#include <time.h> // for getTimeAndDate() + +/* Dump console info to files. */ +#define DUMP_STDOUT + +static SDL_Cursor *hiddenCursor; + +int main(int argc, char *argv[]) { + g_system = new OSystem_OP(); + assert(g_system); + +#ifdef DYNAMIC_MODULES + PluginManager::instance().addPluginProvider(new POSIXPluginProvider()); +#endif + + // Invoke the actual ScummVM main entry point: + int res = scummvm_main(argc, argv); + g_system->quit(); + + return res; +} + +static Uint32 timer_handler(Uint32 interval, void *param) { + ((DefaultTimerManager *)param)->handler(); + return interval; +} + +void OSystem_OP::initBackend() { + + assert(!_inited); + + uint8_t hiddenCursorData = 0; + + int joystick_num = ConfMan.getInt("joystick_num"); + uint32 sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER; + + if (ConfMan.hasKey("disable_sdl_parachute")) + sdlFlags |= SDL_INIT_NOPARACHUTE; + + if (joystick_num > -1) + sdlFlags |= SDL_INIT_JOYSTICK; + + if (SDL_Init(sdlFlags) == -1) { + error("Could not initialize SDL: %s", SDL_GetError()); + } + + hiddenCursor = SDL_CreateCursor(&hiddenCursorData, &hiddenCursorData, 8, 1, 0, 0); + + /* Setup default save path to be workingdir/saves */ + + char savePath[PATH_MAX+1]; + char workDirName[PATH_MAX+1]; + + if (getcwd(workDirName, PATH_MAX) == NULL) { + error("Could not obtain current working directory."); + } else { + printf("Current working directory: %s\n", workDirName); + } + + strcpy(savePath, workDirName); + strcat(savePath, "/../saves"); + printf("Current save directory: %s\n", savePath); + struct stat sb; + if (stat(savePath, &sb) == -1) + if (errno == ENOENT) // Create the dir if it does not exist + if (mkdir(savePath, 0755) != 0) + warning("mkdir for '%s' failed!", savePath); + + _savefile = new DefaultSaveFileManager(savePath); + + #ifdef DUMP_STDOUT + // The OpenPandora has a serial console on the EXT connection but most users do not use this so we + // output all our STDOUT and STDERR to files for debug purposes. + char STDOUT_FILE[PATH_MAX+1]; + char STDERR_FILE[PATH_MAX+1]; + + strcpy(STDOUT_FILE, workDirName); + strcpy(STDERR_FILE, workDirName); + strcat(STDOUT_FILE, "/scummvm.stdout.txt"); + strcat(STDERR_FILE, "/scummvm.stderr.txt"); + + // Flush the output in case anything is queued + fclose(stdout); + fclose(stderr); + + // Redirect standard input and standard output + FILE *newfp = freopen(STDOUT_FILE, "w", stdout); + if (newfp == NULL) { + #if !defined(stdout) + stdout = fopen(STDOUT_FILE, "w"); + #else + newfp = fopen(STDOUT_FILE, "w"); + if (newfp) { + *stdout = *newfp; + } + #endif + } + + newfp = freopen(STDERR_FILE, "w", stderr); + if (newfp == NULL) { + #if !defined(stderr) + stderr = fopen(STDERR_FILE, "w"); + #else + newfp = fopen(STDERR_FILE, "w"); + if (newfp) { + *stderr = *newfp; + } + #endif + } + + setbuf(stderr, NULL); + printf("%s\n", "Debug: STDOUT and STDERR redirected to text files."); + #endif /* DUMP_STDOUT */ + + /* Trigger autosave every 4 minutes. */ + ConfMan.registerDefault("autosave_period", 4 * 60); + + ConfMan.registerDefault("fullscreen", true); + + /* Make sure that aspect ratio correction is enabled on the 1st run to stop + users asking me what the 'wasted space' at the bottom is ;-). */ + ConfMan.registerDefault("aspect_ratio", true); + + /* Make sure SDL knows that we have a joystick we want to use. */ + ConfMan.setInt("joystick_num", 0); + + _graphicsMutex = createMutex(); + + /* On the OpenPandora we need to work around an SDL assumption that + returns relative mouse coordinates when you get to the screen + edges using the touchscreen. The workaround is to set a blank + SDL cursor and not disable it (Hackish I know). + + The root issues likes in the Windows Manager GRAB code in SDL. + That is why the issue is not seen on framebuffer devices like the + GP2X (there is no X window manager ;)). + */ + SDL_ShowCursor(SDL_ENABLE); + SDL_SetCursor(hiddenCursor); + + // Enable unicode support if possible + SDL_EnableUNICODE(1); + + memset(&_oldVideoMode, 0, sizeof(_oldVideoMode)); + memset(&_videoMode, 0, sizeof(_videoMode)); + memset(&_transactionDetails, 0, sizeof(_transactionDetails)); + + _videoMode.mode = GFX_DOUBLESIZE; + _videoMode.scaleFactor = 2; + _videoMode.aspectRatioCorrection = ConfMan.getBool("aspect_ratio"); + _scalerProc = Normal2x; + _scalerType = 0; + + _videoMode.fullscreen = true; + + // enable joystick + if (joystick_num > -1 && SDL_NumJoysticks() > 0) { + printf("Using joystick: %s\n", SDL_JoystickName(0)); + _joystick = SDL_JoystickOpen(joystick_num); + } + + setupMixer(); + + // Note: We could implement a custom SDLTimerManager by using + // SDL_AddTimer. That might yield better timer resolution, but it would + // also change the semantics of a timer: Right now, ScummVM timers + // *never* run in parallel, due to the way they are implemented. If we + // switched to SDL_AddTimer, each timer might run in a separate thread. + // However, not all our code is prepared for that, so we can't just + // switch. Still, it's a potential future change to keep in mind. + _timer = new DefaultTimerManager(); + _timerID = SDL_AddTimer(10, &timer_handler, _timer); + + // Invoke parent implementation of this method + OSystem::initBackend(); + + _inited = true; +} + +void OSystem_OP::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { + + /* Setup default extra data paths for engine data files and plugins */ + + char workDirName[PATH_MAX+1]; + + if (getcwd(workDirName, PATH_MAX) == NULL) { + error("Error: Could not obtain current working directory."); + } + + char enginedataPath[PATH_MAX+1]; + + strcpy(enginedataPath, workDirName); + strcat(enginedataPath, "/../data"); + printf("Default engine data directory: %s\n", enginedataPath); + + Common::FSNode engineNode(enginedataPath); + if (engineNode.exists() && engineNode.isDirectory()) { + s.add("__OP_ENGDATA__", new Common::FSDirectory(enginedataPath), priority); + } +} + +void OSystem_OP::quit() { + + SDL_FreeCursor(hiddenCursor); + + #ifdef DUMP_STDOUT + printf("%s\n", "Debug: STDOUT and STDERR text files closed."); + fclose(stdout); + fclose(stderr); + #endif /* DUMP_STDOUT */ + + OSystem_SDL::quit(); +} diff --git a/backends/platform/openpandora/op-options.cpp b/backends/platform/openpandora/op-options.cpp new file mode 100755 index 0000000000..f8711b868a --- /dev/null +++ b/backends/platform/openpandora/op-options.cpp @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* + * OpenPandora: Options, custom code and hardware stuff. + * + */ + +#include "backends/platform/openpandora/op-options.h" + +namespace OP { + +enum { + /* Touchscreen TapMode */ + TAPMODE_LEFT = 0, + TAPMODE_RIGHT = 1, + TAPMODE_HOVER = 2 +}; + +int tapmodeLevel = TAPMODE_LEFT; + +void ToggleTapMode() { + if (tapmodeLevel == TAPMODE_LEFT) { + tapmodeLevel = TAPMODE_RIGHT; + } else if (tapmodeLevel == TAPMODE_RIGHT) { + tapmodeLevel = TAPMODE_HOVER; + } else if (tapmodeLevel == TAPMODE_HOVER) { + tapmodeLevel = TAPMODE_LEFT; + } else { + tapmodeLevel = TAPMODE_LEFT; + } +} + +} /* namespace OP */ diff --git a/backends/platform/openpandora/op-options.h b/backends/platform/openpandora/op-options.h new file mode 100755 index 0000000000..8c2bb1cc89 --- /dev/null +++ b/backends/platform/openpandora/op-options.h @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* + * OpenPandora: Options, custom code and hardware stuff. + * + */ + +#ifndef OP_OPTIONS_H +#define OP_OPTIONS_H + +namespace OP { + +extern int tapmodeLevel; + +extern void ToggleTapMode(); + +} /* namespace OP */ + +#endif //OP_OPTIONS_H diff --git a/backends/platform/openpandora/op-sdl.h b/backends/platform/openpandora/op-sdl.h new file mode 100755 index 0000000000..8561b42498 --- /dev/null +++ b/backends/platform/openpandora/op-sdl.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef OP_SDL_H +#define OP_SDL_H + +#include "backends/platform/sdl/sdl.h" + +#define __OPENPANDORA__ +#define MIXER_DOUBLE_BUFFERING 1 + +#ifndef PATH_MAX + #define PATH_MAX 255 +#endif + +class OSystem_OP : public OSystem_SDL { +public: + OSystem_OP() {} + + /* Events */ + bool handleKeyDown(SDL_Event &ev, Common::Event &event); + bool handleKeyUp(SDL_Event &ev, Common::Event &event); + bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event); + bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event); + + /* Graphics */ + bool loadGFXMode(); + + /* Platform Setup Stuff */ + void addSysArchivesToSearchSet(Common::SearchSet &s, int priority); + void initBackend(); + void quit(); + +protected: + +}; +#endif |