aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/android
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/android')
-rw-r--r--backends/platform/android/android.cpp23
-rw-r--r--backends/platform/android/android.h17
-rw-r--r--backends/platform/android/android.mk196
-rw-r--r--backends/platform/android/asset-archive.cpp7
-rw-r--r--backends/platform/android/asset-archive.h4
-rw-r--r--backends/platform/android/events.cpp119
-rw-r--r--backends/platform/android/gfx.cpp27
-rw-r--r--backends/platform/android/jni.cpp52
-rw-r--r--backends/platform/android/jni.h8
-rw-r--r--backends/platform/android/org/scummvm/scummvm/MouseHelper.java18
-rw-r--r--backends/platform/android/org/scummvm/scummvm/PluginProvider.java63
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVM.java15
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java39
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java31
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java28
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMEventsHoneycomb.java25
-rw-r--r--backends/platform/android/org/scummvm/scummvm/Unpacker.java388
-rw-r--r--backends/platform/android/texture.cpp33
-rw-r--r--backends/platform/android/texture.h16
19 files changed, 350 insertions, 759 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index f06e4be19e..798772cc24 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -8,12 +8,12 @@
* 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
+ * 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.
@@ -146,7 +146,8 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
_touchpad_scale(66),
_dpad_scale(4),
_fingersDown(0),
- _trackball_scale(2) {
+ _trackball_scale(2),
+ _joystick_scale(10) {
_fsFactory = new POSIXFilesystemFactory();
@@ -395,12 +396,6 @@ void OSystem_Android::initBackend() {
EventsBaseBackend::initBackend();
}
-void OSystem_Android::addPluginDirectories(Common::FSList &dirs) const {
- ENTER();
-
- JNI::getPluginDirectories(dirs);
-}
-
bool OSystem_Android::hasFeature(Feature f) {
return (f == kFeatureFullscreenMode ||
f == kFeatureAspectRatioCorrection ||
@@ -450,7 +445,7 @@ bool OSystem_Android::getFeatureState(Feature f) {
}
}
-uint32 OSystem_Android::getMillis() {
+uint32 OSystem_Android::getMillis(bool skipRecord) {
timeval curTime;
gettimeofday(&curTime, 0);
@@ -599,10 +594,4 @@ Common::String OSystem_Android::getSystemProperty(const char *name) const {
return Common::String(value, len);
}
-#ifdef DYNAMIC_MODULES
-void AndroidPluginProvider::addCustomDirectories(Common::FSList &dirs) const {
- ((OSystem_Android *)g_system)->addPluginDirectories(dirs);
-}
-#endif
-
#endif
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 5f2f40b726..ade84dd42d 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -8,12 +8,12 @@
* 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
+ * 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.
@@ -96,13 +96,6 @@ extern void checkGlError(const char *expr, const char *file, int line);
#define GLTHREADCHECK do { } while (false)
#endif
-#ifdef DYNAMIC_MODULES
-class AndroidPluginProvider : public POSIXPluginProvider {
-protected:
- virtual void addCustomDirectories(Common::FSList &dirs) const;
-};
-#endif
-
class OSystem_Android : public EventsBaseBackend, public PaletteManager {
private:
// passed from the dark side
@@ -177,7 +170,6 @@ public:
virtual ~OSystem_Android();
virtual void initBackend();
- void addPluginDirectories(Common::FSList &dirs) const;
void enableZoning(bool enable) { _enable_zoning = enable; }
virtual bool hasFeature(Feature f);
@@ -231,6 +223,7 @@ private:
int _touchpad_scale;
int _trackball_scale;
int _dpad_scale;
+ int _joystick_scale;
int _fingersDown;
void clipMouse(Common::Point &p);
@@ -274,7 +267,7 @@ public:
virtual void setCursorPalette(const byte *colors, uint start, uint num);
virtual bool pollEvent(Common::Event &event);
- virtual uint32 getMillis();
+ virtual uint32 getMillis(bool skipRecord = false);
virtual void delayMillis(uint msecs);
virtual MutexRef createMutex(void);
diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk
index f498c671de..e11ad0724e 100644
--- a/backends/platform/android/android.mk
+++ b/backends/platform/android/android.mk
@@ -2,196 +2,106 @@
# These must be incremented for each market upload
ANDROID_VERSIONCODE = 6
-ANDROID_PLUGIN_VERSIONCODE = 6
-JAVA_FILES = \
- ScummVM.java \
- ScummVMEvents.java \
- ScummVMApplication.java \
- ScummVMActivity.java \
- EditableSurfaceView.java \
- MouseHelper.java \
- Unpacker.java
+ANDROID_TARGET_VERSION = 14
-JAVA_FILES_PLUGIN = \
- PluginProvider.java
-
-JAVA_FILES_GEN = \
- Manifest.java \
- R.java
+NDK_BUILD = $(ANDROID_NDK)/ndk-build APP_ABI=$(ABI)
+SDK_ANDROID = $(ANDROID_SDK)/tools/android
PATH_DIST = $(srcdir)/dists/android
PATH_RESOURCES = $(PATH_DIST)/res
PORT_DISTFILES = $(PATH_DIST)/README.Android
+DIST_JAVA_SRC_DIR = $(srcdir)/backends/platform/android/org
RESOURCES = \
- $(PATH_RESOURCES)/values/strings.xml \
- $(PATH_RESOURCES)/layout/main.xml \
- $(PATH_RESOURCES)/layout/splash.xml \
- $(PATH_RESOURCES)/drawable/gradient.xml \
- $(PATH_RESOURCES)/drawable/scummvm.png \
- $(PATH_RESOURCES)/drawable/scummvm_big.png
-
-PLUGIN_RESOURCES = \
- $(PATH_RESOURCES)/values/strings.xml \
- $(PATH_RESOURCES)/drawable/scummvm.png
-
-# FIXME: find/mark plugin entry points and add all this back again:
-#LDFLAGS += -Wl,--gc-sections
-#CXXFLAGS += -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden
-
-AAPT = $(ANDROID_SDK)/platform-tools/aapt
-ADB = $(ANDROID_SDK)/platform-tools/adb
-DX = $(ANDROID_SDK)/platform-tools/dx
-APKBUILDER = $(ANDROID_SDK)/tools/apkbuilder
-JAVAC ?= javac
-JAVACFLAGS = -source 1.5 -target 1.5
-
-ANDROID_JAR = $(ANDROID_SDK)/platforms/android-14/android.jar
+ $(PATH_BUILD_RES)/values/strings.xml \
+ $(PATH_BUILD_RES)/values-television/margins.xml \
+ $(PATH_BUILD_RES)/layout/main.xml \
+ $(PATH_BUILD_RES)/drawable/scummvm.png \
+ $(PATH_BUILD_RES)/drawable/scummvm_big.png \
+ $(PATH_BUILD_RES)/drawable-xhdpi/ouya_icon.png
+
+DIST_ANDROID_MK = $(PATH_DIST)/jni/Android.mk
+DIST_BUILD_XML = $(PATH_DIST)/custom_rules.xml
PATH_BUILD = ./build.tmp
PATH_BUILD_ASSETS = $(PATH_BUILD)/assets
-PATH_BUILD_CLASSES_MAIN_TOP = $(PATH_BUILD)/classes.main
-PATH_BUILD_CLASSES_PLUGIN_TOP = $(PATH_BUILD)/classes.plugin
-
-PATH_STAGE_PREFIX = build.stage
-PATH_STAGE_MAIN = $(PATH_STAGE_PREFIX).main
-
-PATH_REL = org/scummvm/scummvm
-PATH_SRC_TOP = $(srcdir)/backends/platform/android
-PATH_SRC = $(PATH_SRC_TOP)/$(PATH_REL)
-
-PATH_GEN_TOP = $(PATH_BUILD)/java
-PATH_GEN = $(PATH_GEN_TOP)/$(PATH_REL)
-PATH_CLASSES_MAIN = $(PATH_BUILD_CLASSES_MAIN_TOP)/$(PATH_REL)
-PATH_CLASSES_PLUGIN = $(PATH_BUILD_CLASSES_PLUGIN_TOP)/$(PATH_REL)
+PATH_BUILD_RES = $(PATH_BUILD)/res
+PATH_BUILD_LIBSCUMMVM = $(PATH_BUILD)/lib/$(ABI)/libscummvm.so
FILE_MANIFEST_SRC = $(srcdir)/dists/android/AndroidManifest.xml
FILE_MANIFEST = $(PATH_BUILD)/AndroidManifest.xml
-FILE_DEX = $(PATH_BUILD)/classes.dex
-FILE_DEX_PLUGIN = $(PATH_BUILD)/plugins/classes.dex
-FILE_RESOURCES = resources.ap_
-FILE_RESOURCES_MAIN = $(PATH_BUILD)/$(FILE_RESOURCES)
-
-SRC_GEN = $(addprefix $(PATH_GEN)/, $(JAVA_FILES_GEN))
-CLASSES_MAIN = $(addprefix $(PATH_CLASSES_MAIN)/, $(JAVA_FILES:%.java=%.class))
-CLASSES_GEN = $(addprefix $(PATH_CLASSES_MAIN)/, $(JAVA_FILES_GEN:%.java=%.class))
-CLASSES_PLUGIN = $(addprefix $(PATH_CLASSES_PLUGIN)/, $(JAVA_FILES_PLUGIN:%.java=%.class))
+APK_MAIN = ScummVM-debug.apk
+APK_MAIN_RELEASE = ScummVM-release-unsigned.apk
-APK_MAIN = scummvm.apk
-APK_PLUGINS = $(patsubst plugins/lib%.so, scummvm-engine-%.apk, $(PLUGINS))
-
-$(FILE_MANIFEST): $(FILE_MANIFEST_SRC)
+$(FILE_MANIFEST): $(FILE_MANIFEST_SRC) | $(PATH_BUILD)
@$(MKDIR) -p $(@D)
sed "s/@ANDROID_VERSIONCODE@/$(ANDROID_VERSIONCODE)/" < $< > $@
-$(SRC_GEN): $(FILE_MANIFEST) $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR)
- @$(MKDIR) -p $(PATH_GEN_TOP)
- $(AAPT) package -m -J $(PATH_GEN_TOP) -M $< -S $(PATH_RESOURCES) -I $(ANDROID_JAR)
-
-$(PATH_CLASSES_MAIN)/%.class: $(PATH_GEN)/%.java $(SRC_GEN)
+$(PATH_BUILD)/res/%: $(PATH_DIST)/res/% | $(PATH_BUILD)
@$(MKDIR) -p $(@D)
- $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP) -d $(PATH_BUILD_CLASSES_MAIN_TOP) -bootclasspath $(ANDROID_JAR) $<
+ $(CP) $< $@
-$(PATH_CLASSES_MAIN)/%.class: $(PATH_SRC)/%.java $(SRC_GEN)
+$(PATH_BUILD)/libs/%: $(PATH_DIST)/libs/% | $(PATH_BUILD)
@$(MKDIR) -p $(@D)
- $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP):$(PATH_GEN_TOP) -d $(PATH_BUILD_CLASSES_MAIN_TOP) -bootclasspath $(ANDROID_JAR) $<
+ $(CP) $< $@
-$(PATH_CLASSES_PLUGIN)/%.class: $(PATH_SRC)/%.java
- @$(MKDIR) -p $(@D)
- $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP) -d $(PATH_BUILD_CLASSES_PLUGIN_TOP) -bootclasspath $(ANDROID_JAR) $<
+$(PATH_BUILD_ASSETS): $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_SHADERS) $(DIST_BUILD_XML) | $(PATH_BUILD)
+ $(INSTALL) -d $(PATH_BUILD_ASSETS)
+ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(PATH_BUILD_ASSETS)/
+ $(INSTALL) -d $(PATH_BUILD)/jni
+ $(INSTALL) -c -m 644 $(DIST_ANDROID_MK) $(PATH_BUILD)/jni
+ $(INSTALL) -c -m 644 $(DIST_BUILD_XML) $(PATH_BUILD)
-$(FILE_DEX): $(CLASSES_MAIN) $(CLASSES_GEN)
- $(DX) --dex --output=$@ $(PATH_BUILD_CLASSES_MAIN_TOP)
+$(PATH_BUILD): $(DIST_ANDROID_MK)
+ $(MKDIR) -p $(PATH_BUILD) $(PATH_BUILD)/res
+ $(MKDIR) -p $(PATH_BUILD)/libs
-$(FILE_DEX_PLUGIN): $(CLASSES_PLUGIN)
- @$(MKDIR) -p $(@D)
- $(DX) --dex --output=$@ $(PATH_BUILD_CLASSES_PLUGIN_TOP)
+$(PATH_BUILD_LIBSCUMMVM): libscummvm.so | $(PATH_BUILD)
+ $(INSTALL) -c -m 644 libscummvm.so $(PATH_BUILD)
+ $(STRIP) $(PATH_BUILD)/libscummvm.so
+ cd $(PATH_BUILD); $(NDK_BUILD)
-$(PATH_BUILD)/%/AndroidManifest.xml: $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $(PATH_DIST)/plugin-manifest.xml
- @$(MKDIR) -p $(@D)
- $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $* $(PATH_DIST)/plugin-manifest.xml $(ANDROID_PLUGIN_VERSIONCODE) $@
+$(PATH_BUILD_RES): $(RESOURCES) | $(PATH_BUILD)
-$(PATH_STAGE_PREFIX).%/res/values/strings.xml: $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $(PATH_DIST)/plugin-manifest.xml
- @$(MKDIR) -p $(@D)
- $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $* $(PATH_DIST)/plugin-strings.xml $(ANDROID_PLUGIN_VERSIONCODE) $@
+setupapk: $(FILE_MANIFEST) $(PATH_BUILD_RES) $(PATH_BUILD_ASSETS) $(PATH_BUILD_LIBSCUMMVM) | $(PATH_BUILD)
+ $(SDK_ANDROID) update project -p $(PATH_BUILD) -t android-$(ANDROID_TARGET_VERSION) -n ScummVM
-$(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png: $(PATH_RESOURCES)/drawable/scummvm.png
- @$(MKDIR) -p $(@D)
- $(CP) $< $@
+$(APK_MAIN): setupapk | $(PATH_BUILD)
+ (cd $(PATH_BUILD); ant debug -Dsource.dir="$(realpath $(DIST_JAVA_SRC_DIR))")
+ $(CP) $(PATH_BUILD)/bin/ScummVM-debug.apk $@
-$(FILE_RESOURCES_MAIN): $(FILE_MANIFEST) $(RESOURCES) $(ANDROID_JAR) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA)
- $(INSTALL) -d $(PATH_BUILD_ASSETS)
- $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(PATH_BUILD_ASSETS)/
- work_dir=`pwd`; \
- for i in $(PATH_BUILD_ASSETS)/*.zip; do \
- echo "recompress $$i"; \
- cd "$$work_dir"; \
- $(RM) -rf $(PATH_BUILD_ASSETS)/tmp; \
- $(MKDIR) $(PATH_BUILD_ASSETS)/tmp; \
- unzip -q $$i -d $(PATH_BUILD_ASSETS)/tmp; \
- cd $(PATH_BUILD_ASSETS)/tmp; \
- zip -r ../`basename $$i` *; \
- done
- @$(RM) -rf $(PATH_BUILD_ASSETS)/tmp
- $(AAPT) package -f -0 zip -M $< -S $(PATH_RESOURCES) -A $(PATH_BUILD_ASSETS) -I $(ANDROID_JAR) -F $@
-
-$(PATH_BUILD)/%/$(FILE_RESOURCES): $(PATH_BUILD)/%/AndroidManifest.xml $(PATH_STAGE_PREFIX).%/res/values/strings.xml $(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png plugins/lib%.so $(ANDROID_JAR)
- $(AAPT) package -f -M $< -S $(PATH_STAGE_PREFIX).$*/res -I $(ANDROID_JAR) -F $@
-
-# Package installer won't delete old libscummvm.so on upgrade so
-# replace it with a zero size file
-$(APK_MAIN): $(EXECUTABLE) $(FILE_RESOURCES_MAIN) $(FILE_DEX)
- $(INSTALL) -d $(PATH_STAGE_MAIN)/common/lib/armeabi
- touch $(PATH_STAGE_MAIN)/common/lib/armeabi/libscummvm.so
- $(INSTALL) -d $(PATH_STAGE_MAIN)/common/mylib/armeabi
- $(INSTALL) -c -m 644 libscummvm.so $(PATH_STAGE_MAIN)/common/mylib/armeabi/
- $(STRIP) $(PATH_STAGE_MAIN)/common/mylib/armeabi/libscummvm.so
- $(APKBUILDER) $@ -z $(FILE_RESOURCES_MAIN) -f $(FILE_DEX) -rf $(PATH_STAGE_MAIN)/common || { $(RM) $@; exit 1; }
-
-scummvm-engine-%.apk: plugins/lib%.so $(PATH_BUILD)/%/$(FILE_RESOURCES) $(FILE_DEX_PLUGIN)
- $(INSTALL) -d $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/
- $(INSTALL) -c -m 644 plugins/lib$*.so $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/
- $(STRIP) $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/lib$*.so
- $(APKBUILDER) $@ -z $(PATH_BUILD)/$*/$(FILE_RESOURCES) -f $(FILE_DEX_PLUGIN) -rf $(PATH_STAGE_PREFIX).$*/apk || { $(RM) $@; exit 1; }
-
-all: $(APK_MAIN) $(APK_PLUGINS)
+$(APK_MAIN_RELEASE): setupapk | $(PATH_BUILD)
+ (cd $(PATH_BUILD); ant release -Dsource.dir="$(realpath $(DIST_JAVA_SRC_DIR))")
+ $(CP) $(PATH_BUILD)/bin/ScummVM-release-unsigned.apk $@
+
+all: $(APK_MAIN)
clean: androidclean
androidclean:
- @$(RM) -rf $(PATH_BUILD) $(PATH_STAGE_PREFIX).* *.apk release
-
-# remove debugging signature
-release/%.apk: %.apk
- @$(MKDIR) -p $(@D)
- @$(RM) $@
- $(CP) $< $@.tmp
- zip -d $@.tmp META-INF/\*
- jarsigner $(JARSIGNER_FLAGS) $@.tmp release
- zipalign 4 $@.tmp $@
- $(RM) $@.tmp
+ @$(RM) -rf $(PATH_BUILD) *.apk release
-androidrelease: $(addprefix release/, $(APK_MAIN) $(APK_PLUGINS))
+androidrelease: $(APK_MAIN_RELEASE)
androidtestmain: $(APK_MAIN)
$(ADB) install -r $(APK_MAIN)
- $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.Unpacker
+ $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.ScummVMActivity
-androidtest: $(APK_MAIN) $(APK_PLUGINS)
+androidtest: $(APK_MAIN)
@set -e; for apk in $^; do \
$(ADB) install -r $$apk; \
done
- $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.Unpacker
+ $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.ScummVMActivity
# used by buildbot!
androiddistdebug: all
$(MKDIR) debug
- $(CP) $(APK_MAIN) $(APK_PLUGINS) debug/
+ $(CP) $(APK_MAIN) debug/
for i in $(DIST_FILES_DOCS) $(PORT_DISTFILES); do \
sed 's/$$/\r/' < $$i > debug/`basename $$i`.txt; \
done
-.PHONY: androidrelease androidtest
+.PHONY: androidrelease androidtest $(PATH_BUILD_SRC)
diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp
index da378fb082..6680081c16 100644
--- a/backends/platform/android/asset-archive.cpp
+++ b/backends/platform/android/asset-archive.cpp
@@ -8,12 +8,12 @@
* 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.
@@ -295,7 +295,6 @@ AssetFdReadStream::AssetFdReadStream(JNIEnv *env, jobject assetfd) :
jclass cls = env->GetObjectClass(_assetfd);
MID_close = env->GetMethodID(cls, "close", "()V");
assert(MID_close);
- env->DeleteLocalRef(cls);
jmethodID MID_getStartOffset =
env->GetMethodID(cls, "getStartOffset", "()J");
@@ -321,6 +320,8 @@ AssetFdReadStream::AssetFdReadStream(JNIEnv *env, jobject assetfd) :
_fd = env->GetIntField(javafd, FID_descriptor);
env->DeleteLocalRef(javafd);
+
+ env->DeleteLocalRef(cls);
}
AssetFdReadStream::~AssetFdReadStream() {
diff --git a/backends/platform/android/asset-archive.h b/backends/platform/android/asset-archive.h
index c5e43555e0..6a0033d24e 100644
--- a/backends/platform/android/asset-archive.h
+++ b/backends/platform/android/asset-archive.h
@@ -8,12 +8,12 @@
* 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.
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index db1261e432..8039981a92 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -8,12 +8,12 @@
* 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
+ * 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.
@@ -64,6 +64,10 @@ enum {
JE_RMB_DOWN = 11,
JE_RMB_UP = 12,
JE_MOUSE_MOVE = 13,
+ JE_GAMEPAD = 14,
+ JE_JOYSTICK = 15,
+ JE_MMB_DOWN = 16,
+ JE_MMB_UP = 17,
JE_QUIT = 0x1000
};
@@ -109,6 +113,25 @@ enum {
JKEYCODE_DPAD_CENTER = 23
};
+// gamepad
+enum {
+ JKEYCODE_BUTTON_A = 96,
+ JKEYCODE_BUTTON_B = 97,
+ JKEYCODE_BUTTON_C = 98,
+ JKEYCODE_BUTTON_X = 99,
+ JKEYCODE_BUTTON_Y = 100,
+ JKEYCODE_BUTTON_Z = 101,
+ JKEYCODE_BUTTON_L1 = 102,
+ JKEYCODE_BUTTON_R1 = 103,
+ JKEYCODE_BUTTON_L2 = 104,
+ JKEYCODE_BUTTON_R2 = 105,
+ JKEYCODE_BUTTON_THUMBL = 106,
+ JKEYCODE_BUTTON_THUMBR = 107,
+ JKEYCODE_BUTTON_START = 108,
+ JKEYCODE_BUTTON_SELECT = 109,
+ JKEYCODE_BUTTON_MODE = 110,
+};
+
// meta modifier
enum {
JMETA_SHIFT = 0x01,
@@ -240,7 +263,7 @@ void OSystem_Android::setupKeymapper() {
Action *act;
act = new Action(globalMap, "VIRT", "Display keyboard");
- act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));
+ act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, KBD_CTRL));
mapper->addGlobalKeymap(globalMap);
@@ -827,6 +850,94 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
return;
+ case JE_GAMEPAD:
+ switch (arg1) {
+ case JACTION_DOWN:
+ e.type = Common::EVENT_KEYDOWN;
+ break;
+ case JACTION_UP:
+ e.type = Common::EVENT_KEYUP;
+ break;
+ default:
+ LOGE("unhandled jaction on gamepad key: %d", arg1);
+ return;
+ }
+
+ switch (arg2) {
+ case JKEYCODE_BUTTON_A:
+ case JKEYCODE_BUTTON_B:
+ switch (arg1) {
+ case JACTION_DOWN:
+ e.type = (arg2 == JKEYCODE_BUTTON_A?
+ Common::EVENT_LBUTTONDOWN :
+ Common::EVENT_RBUTTONDOWN);
+ break;
+ case JACTION_UP:
+ e.type = (arg2 == JKEYCODE_BUTTON_A?
+ Common::EVENT_LBUTTONUP :
+ Common::EVENT_RBUTTONUP);
+ break;
+ }
+
+ e.mouse = getEventManager()->getMousePos();
+
+ break;
+
+ case JKEYCODE_BUTTON_X:
+ e.kbd.keycode = Common::KEYCODE_ESCAPE;
+ e.kbd.ascii = Common::ASCII_ESCAPE;
+ break;
+
+ default:
+ LOGW("unmapped gamepad key: %d", arg2);
+ return;
+ }
+
+ lockMutex(_event_queue_lock);
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+
+ break;
+
+ case JE_JOYSTICK:
+ e.mouse = getEventManager()->getMousePos();
+
+ switch (arg1) {
+ case JACTION_MULTIPLE:
+ e.type = Common::EVENT_MOUSEMOVE;
+
+ // already multiplied by 100
+ e.mouse.x += arg2 * _joystick_scale / _eventScaleX;
+ e.mouse.y += arg3 * _joystick_scale / _eventScaleY;
+
+ clipMouse(e.mouse);
+
+ break;
+ default:
+ LOGE("unhandled jaction on joystick: %d", arg1);
+ return;
+ }
+
+ lockMutex(_event_queue_lock);
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+
+ return;
+
+ case JE_MMB_DOWN:
+ e.type = Common::EVENT_MAINMENU;
+
+ lockMutex(_event_queue_lock);
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+
+ return;
+
+ case JE_MMB_UP:
+ // No action
+
+ return;
+
case JE_QUIT:
e.type = Common::EVENT_QUIT;
diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index cd0fd88484..d7713f99d8 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -8,12 +8,12 @@
* 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
+ * 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.
@@ -94,6 +94,7 @@ Common::List<Graphics::PixelFormat> OSystem_Android::getSupportedFormats() const
Common::List<Graphics::PixelFormat> res;
res.push_back(GLES565Texture::pixelFormat());
res.push_back(GLES5551Texture::pixelFormat());
+ res.push_back(GLES8888Texture::pixelFormat());
res.push_back(GLES4444Texture::pixelFormat());
res.push_back(Graphics::PixelFormat::createFormatCLUT8());
@@ -147,6 +148,8 @@ void OSystem_Android::initTexture(GLESBaseTexture **texture,
*texture = new GLES565Texture();
else if (format_new == GLES5551Texture::pixelFormat())
*texture = new GLES5551Texture();
+ else if (format_new == GLES8888Texture::pixelFormat())
+ *texture = new GLES8888Texture();
else if (format_new == GLES4444Texture::pixelFormat())
*texture = new GLES4444Texture();
else {
@@ -233,7 +236,7 @@ void OSystem_Android::initViewport() {
GLCALL(glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST));
GLCALL(glEnable(GL_BLEND));
- GLCALL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
+ GLCALL(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
GLCALL(glEnableClientState(GL_VERTEX_ARRAY));
GLCALL(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
@@ -552,7 +555,7 @@ Graphics::Surface *OSystem_Android::lockScreen() {
GLTHREADCHECK;
Graphics::Surface *surface = _game_texture->surface();
- assert(surface->pixels);
+ assert(surface->getPixels());
return surface;
}
@@ -645,7 +648,7 @@ void OSystem_Android::grabOverlay(void *buf, int pitch) {
assert(surface->format.bytesPerPixel == sizeof(uint16));
byte *dst = (byte *)buf;
- const byte *src = (const byte *)surface->pixels;
+ const byte *src = (const byte *)surface->getPixels();
uint h = surface->h;
do {
@@ -726,7 +729,7 @@ void OSystem_Android::setMouseCursor(const void *buf, uint w, uint h,
_mouse_keycolor = keycolor;
p = _mouse_texture_palette->palette() + _mouse_keycolor * 2;
- WRITE_UINT16(p, READ_UINT16(p) & ~1);
+ WRITE_UINT16(p, 0);
}
if (w == 0 || h == 0)
@@ -752,12 +755,12 @@ void OSystem_Android::setMouseCursor(const void *buf, uint w, uint h,
return;
}
- uint16 *s = (uint16 *)buf;
+ const uint16 *s = (const uint16 *)buf;
uint16 *d = (uint16 *)tmp;
for (uint16 y = 0; y < h; ++y, d += pitch / 2 - w)
for (uint16 x = 0; x < w; ++x, d++)
- if (*s++ != (keycolor & 0xffff))
- *d |= 1;
+ if (*s++ == (keycolor & 0xffff))
+ *d = 0;
_mouse_texture->updateBuffer(0, 0, w, h, tmp, pitch);
@@ -779,7 +782,7 @@ void OSystem_Android::setCursorPaletteInternal(const byte *colors,
WRITE_UINT16(p, pf.RGBToColor(colors[0], colors[1], colors[2]));
p = _mouse_texture_palette->palette() + _mouse_keycolor * 2;
- WRITE_UINT16(p, READ_UINT16(p) & ~1);
+ WRITE_UINT16(p, 0);
}
void OSystem_Android::setCursorPalette(const byte *colors,
@@ -821,7 +824,7 @@ void OSystem_Android::disableCursorPalette() {
}
byte *p = _mouse_texture_palette->palette() + _mouse_keycolor * 2;
- WRITE_UINT16(p, READ_UINT16(p) & ~1);
+ WRITE_UINT16(p, 0);
}
}
diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp
index 2b738dd63f..22e6a749c2 100644
--- a/backends/platform/android/jni.cpp
+++ b/backends/platform/android/jni.cpp
@@ -8,12 +8,12 @@
* 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
+ * 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.
@@ -79,7 +79,6 @@ jmethodID JNI::_MID_displayMessageOnOSD = 0;
jmethodID JNI::_MID_setWindowCaption = 0;
jmethodID JNI::_MID_showVirtualKeyboard = 0;
jmethodID JNI::_MID_getSysArchives = 0;
-jmethodID JNI::_MID_getPluginDirectories = 0;
jmethodID JNI::_MID_initSurface = 0;
jmethodID JNI::_MID_deinitSurface = 0;
@@ -293,46 +292,6 @@ void JNI::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
}
}
-void JNI::getPluginDirectories(Common::FSList &dirs) {
- JNIEnv *env = JNI::getEnv();
-
- jobjectArray array =
- (jobjectArray)env->CallObjectMethod(_jobj, _MID_getPluginDirectories);
-
- if (env->ExceptionCheck()) {
- LOGE("Error finding plugin directories");
-
- env->ExceptionDescribe();
- env->ExceptionClear();
-
- return;
- }
-
- jsize size = env->GetArrayLength(array);
- for (jsize i = 0; i < size; ++i) {
- jstring path_obj = (jstring)env->GetObjectArrayElement(array, i);
-
- if (path_obj == 0)
- continue;
-
- const char *path = env->GetStringUTFChars(path_obj, 0);
-
- if (path == 0) {
- LOGE("Error getting string characters from plugin directory");
-
- env->ExceptionClear();
- env->DeleteLocalRef(path_obj);
-
- continue;
- }
-
- dirs.push_back(Common::FSNode(path));
-
- env->ReleaseStringUTFChars(path_obj, path);
- env->DeleteLocalRef(path_obj);
- }
-}
-
bool JNI::initSurface() {
JNIEnv *env = JNI::getEnv();
@@ -454,7 +413,6 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
FIND_METHOD(, displayMessageOnOSD, "(Ljava/lang/String;)V");
FIND_METHOD(, showVirtualKeyboard, "(Z)V");
FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
- FIND_METHOD(, getPluginDirectories, "()[Ljava/lang/String;");
FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
FIND_METHOD(, deinitSurface, "()V");
@@ -543,10 +501,6 @@ jint JNI::main(JNIEnv *env, jobject self, jobjectArray args) {
env->DeleteLocalRef(arg);
}
-#ifdef DYNAMIC_MODULES
- PluginManager::instance().addPluginProvider(new AndroidPluginProvider());
-#endif
-
LOGI("Entering scummvm_main with %d args", argc);
res = scummvm_main(argc, argv);
diff --git a/backends/platform/android/jni.h b/backends/platform/android/jni.h
index 52698e0f35..70feaaf72a 100644
--- a/backends/platform/android/jni.h
+++ b/backends/platform/android/jni.h
@@ -8,12 +8,12 @@
* 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
+ * 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.
@@ -55,7 +55,6 @@ public:
static void setReadyForEvents(bool ready);
- static void getPluginDirectories(Common::FSList &dirs);
static void setWindowCaption(const char *caption);
static void getDPI(float *values);
static void displayMessageOnOSD(const char *msg);
@@ -93,7 +92,6 @@ private:
static jmethodID _MID_setWindowCaption;
static jmethodID _MID_showVirtualKeyboard;
static jmethodID _MID_getSysArchives;
- static jmethodID _MID_getPluginDirectories;
static jmethodID _MID_initSurface;
static jmethodID _MID_deinitSurface;
diff --git a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
index 999815593f..8990515b84 100644
--- a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
+++ b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java
@@ -14,6 +14,7 @@ public class MouseHelper {
private long _rmbGuardTime;
private boolean _rmbPressed;
private boolean _lmbPressed;
+ private boolean _mmbPressed;
/**
* Class initialization fails when this throws an exception.
@@ -114,6 +115,23 @@ public class MouseHelper {
_rmbPressed = false;
}
+ boolean mmbDown = (buttonState & MotionEvent.BUTTON_TERTIARY) == MotionEvent.BUTTON_TERTIARY;
+ if (mmbDown) {
+ if (!_mmbPressed) {
+ // middle mouse button was pressed just now
+ _scummvm.pushEvent(ScummVMEvents.JE_MMB_DOWN, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0);
+ }
+
+ _mmbPressed = true;
+ } else {
+ if (_mmbPressed) {
+ // middle mouse button was released just now
+ _scummvm.pushEvent(ScummVMEvents.JE_MMB_UP, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0);
+ }
+
+ _mmbPressed = false;
+ }
+
return true;
}
diff --git a/backends/platform/android/org/scummvm/scummvm/PluginProvider.java b/backends/platform/android/org/scummvm/scummvm/PluginProvider.java
deleted file mode 100644
index e27e8d41a8..0000000000
--- a/backends/platform/android/org/scummvm/scummvm/PluginProvider.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.scummvm.scummvm;
-
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-
-import java.util.ArrayList;
-
-public class PluginProvider extends BroadcastReceiver {
- private final static String LOG_TAG = "ScummVM";
-
- public final static String META_UNPACK_LIB =
- "org.scummvm.scummvm.meta.UNPACK_LIB";
-
- public void onReceive(Context context, Intent intent) {
- if (!intent.getAction().equals(ScummVMApplication.ACTION_PLUGIN_QUERY))
- return;
-
- Bundle extras = getResultExtras(true);
-
- final ActivityInfo info;
- final PackageInfo pinfo;
- try {
- info = context.getPackageManager()
- .getReceiverInfo(new ComponentName(context, this.getClass()),
- PackageManager.GET_META_DATA);
- pinfo = context.getPackageManager()
- .getPackageInfo(context.getPackageName(), 0);
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(LOG_TAG, "Error finding my own info?", e);
- return;
- }
-
- String host_version = extras.getString(ScummVMApplication.EXTRA_VERSION);
- if (!pinfo.versionName.equals(host_version)) {
- Log.e(LOG_TAG, "Plugin version " + pinfo.versionName + " is not equal to ScummVM version " + host_version);
- return;
- }
-
- String mylib = info.metaData.getString(META_UNPACK_LIB);
- if (mylib != null) {
- ArrayList<String> all_libs =
- extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS);
- all_libs.add(new Uri.Builder()
- .scheme("plugin")
- .authority(context.getPackageName())
- .path(mylib)
- .toString());
-
- extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS,
- all_libs);
- }
-
- setResultExtras(extras);
- }
-}
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index 3a25b54eeb..3b370a583d 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -54,7 +54,6 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
abstract protected void getDPI(float[] values);
abstract protected void displayMessageOnOSD(String msg);
abstract protected void setWindowCaption(String caption);
- abstract protected String[] getPluginDirectories();
abstract protected void showVirtualKeyboard(boolean enable);
abstract protected String[] getSysArchives();
@@ -86,13 +85,15 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
Log.d(LOG_TAG, String.format("surfaceChanged: %dx%d (%d)",
width, height, format));
+ // store values for the native code
+ // make sure to do it before notifying the lock
+ // as it leads to a race condition otherwise
+ setSurface(width, height);
+
synchronized(_sem_surface) {
_surface_holder = holder;
_sem_surface.notifyAll();
}
-
- // store values for the native code
- setSurface(width, height);
}
// SurfaceHolder callback
@@ -442,10 +443,6 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
}
}
- File cache_dir = ScummVMApplication.getLastCacheDir();
- String libname = System.mapLibraryName("scummvm");
- File libpath = new File(cache_dir, libname);
-
- System.load(libpath.getPath());
+ System.loadLibrary("scummvm");
}
}
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 829a948435..5b2dcae175 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -3,7 +3,9 @@ package org.scummvm.scummvm;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
+import android.content.Intent;
import android.media.AudioManager;
+import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.util.DisplayMetrics;
@@ -82,13 +84,6 @@ public class ScummVMActivity extends Activity {
}
@Override
- protected String[] getPluginDirectories() {
- String[] dirs = new String[1];
- dirs[0] = ScummVMApplication.getLastCacheDir().getPath();
- return dirs;
- }
-
- @Override
protected void showVirtualKeyboard(final boolean enable) {
runOnUiThread(new Runnable() {
public void run() {
@@ -169,7 +164,14 @@ public class ScummVMActivity extends Activity {
_mouseHelper.attach(main_surface);
}
- _events = new ScummVMEvents(this, _scummvm, _mouseHelper);
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1)
+ {
+ _events = new ScummVMEvents(this, _scummvm, _mouseHelper);
+ }
+ else
+ {
+ _events = new ScummVMEventsHoneycomb(this, _scummvm, _mouseHelper);
+ }
main_surface.setOnKeyListener(_events);
main_surface.setOnTouchListener(_events);
@@ -193,6 +195,7 @@ public class ScummVMActivity extends Activity {
if (_scummvm != null)
_scummvm.setPause(false);
+ showMouseCursor(false);
}
@Override
@@ -203,6 +206,7 @@ public class ScummVMActivity extends Activity {
if (_scummvm != null)
_scummvm.setPause(true);
+ showMouseCursor(true);
}
@Override
@@ -240,6 +244,14 @@ public class ScummVMActivity extends Activity {
return false;
}
+ @Override
+ public boolean onGenericMotionEvent(final MotionEvent e) {
+ if (_events != null)
+ return _events.onGenericMotionEvent(e);
+
+ return false;
+ }
+
private void showKeyboard(boolean show) {
SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface);
InputMethodManager imm = (InputMethodManager)
@@ -251,4 +263,15 @@ public class ScummVMActivity extends Activity {
imm.hideSoftInputFromWindow(main_surface.getWindowToken(),
InputMethodManager.HIDE_IMPLICIT_ONLY);
}
+
+ private void showMouseCursor(boolean show) {
+ /* Currently hiding the system mouse cursor is only
+ supported on OUYA. If other systems provide similar
+ intents, please add them here as well */
+ Intent intent =
+ new Intent(show?
+ "tv.ouya.controller.action.SHOW_CURSOR" :
+ "tv.ouya.controller.action.HIDE_CURSOR");
+ sendBroadcast(intent);
+ }
}
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java b/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java
deleted file mode 100644
index 0adc166222..0000000000
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.scummvm.scummvm;
-
-import android.app.Application;
-
-import java.io.File;
-
-public class ScummVMApplication extends Application {
- public final static String ACTION_PLUGIN_QUERY = "org.scummvm.scummvm.action.PLUGIN_QUERY";
- public final static String EXTRA_UNPACK_LIBS = "org.scummvm.scummvm.extra.UNPACK_LIBS";
- public final static String EXTRA_VERSION = "org.scummvm.scummvm.extra.VERSION";
-
- private static File _cache_dir;
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- // This is still on /data :(
- _cache_dir = getCacheDir();
- // This is mounted noexec :(
- //cache_dir = new File(Environment.getExternalStorageDirectory(),
- // "/.ScummVM.tmp");
- // This is owned by download manager and requires special
- // permissions to access :(
- //cache_dir = Environment.getDownloadCacheDirectory();
- }
-
- public static File getLastCacheDir() {
- return _cache_dir;
- }
-}
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
index 5f51ffac6c..32c65d3395 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
@@ -9,6 +9,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.GestureDetector;
+import android.view.InputDevice;
import android.view.inputmethod.InputMethodManager;
public class ScummVMEvents implements
@@ -31,6 +32,10 @@ public class ScummVMEvents implements
public static final int JE_RMB_DOWN = 11;
public static final int JE_RMB_UP = 12;
public static final int JE_MOUSE_MOVE = 13;
+ public static final int JE_GAMEPAD = 14;
+ public static final int JE_JOYSTICK = 15;
+ public static final int JE_MMB_DOWN = 16;
+ public static final int JE_MMB_UP = 17;
public static final int JE_QUIT = 0x1000;
final protected Context _context;
@@ -63,6 +68,10 @@ public class ScummVMEvents implements
return true;
}
+ public boolean onGenericMotionEvent(MotionEvent e) {
+ return false;
+ }
+
final static int MSG_MENU_LONG_PRESS = 1;
final private Handler keyHandler = new Handler() {
@@ -177,6 +186,25 @@ public class ScummVMEvents implements
(int)(e.getEventTime() - e.getDownTime()),
e.getRepeatCount(), 0);
return true;
+ case KeyEvent.KEYCODE_BUTTON_A:
+ case KeyEvent.KEYCODE_BUTTON_B:
+ case KeyEvent.KEYCODE_BUTTON_C:
+ case KeyEvent.KEYCODE_BUTTON_X:
+ case KeyEvent.KEYCODE_BUTTON_Y:
+ case KeyEvent.KEYCODE_BUTTON_Z:
+ case KeyEvent.KEYCODE_BUTTON_L1:
+ case KeyEvent.KEYCODE_BUTTON_R1:
+ case KeyEvent.KEYCODE_BUTTON_L2:
+ case KeyEvent.KEYCODE_BUTTON_R2:
+ case KeyEvent.KEYCODE_BUTTON_THUMBL:
+ case KeyEvent.KEYCODE_BUTTON_THUMBR:
+ case KeyEvent.KEYCODE_BUTTON_START:
+ case KeyEvent.KEYCODE_BUTTON_SELECT:
+ case KeyEvent.KEYCODE_BUTTON_MODE:
+ _scummvm.pushEvent(JE_GAMEPAD, action, keyCode,
+ (int)(e.getEventTime() - e.getDownTime()),
+ e.getRepeatCount(), 0);
+ return true;
}
_scummvm.pushEvent(JE_KEY, action, keyCode,
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsHoneycomb.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsHoneycomb.java
new file mode 100644
index 0000000000..ab85429040
--- /dev/null
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsHoneycomb.java
@@ -0,0 +1,25 @@
+package org.scummvm.scummvm;
+
+import android.content.Context;
+import android.view.MotionEvent;
+import android.view.InputDevice;
+
+public class ScummVMEventsHoneycomb extends ScummVMEvents {
+
+ public ScummVMEventsHoneycomb(Context context, ScummVM scummvm, MouseHelper mouseHelper) {
+ super(context, scummvm, mouseHelper);
+ }
+
+ @Override
+ public boolean onGenericMotionEvent(MotionEvent e) {
+ if((e.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
+ _scummvm.pushEvent(JE_JOYSTICK, e.getAction(),
+ (int)(e.getAxisValue(MotionEvent.AXIS_X)*100),
+ (int)(e.getAxisValue(MotionEvent.AXIS_Y)*100),
+ 0, 0);
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/backends/platform/android/org/scummvm/scummvm/Unpacker.java b/backends/platform/android/org/scummvm/scummvm/Unpacker.java
deleted file mode 100644
index da76ceb5e5..0000000000
--- a/backends/platform/android/org/scummvm/scummvm/Unpacker.java
+++ /dev/null
@@ -1,388 +0,0 @@
-package org.scummvm.scummvm;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.ActivityNotFoundException;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.ContextWrapper;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.util.Log;
-import android.widget.ProgressBar;
-
-import java.io.IOException;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipEntry;
-
-public class Unpacker extends Activity {
- protected final static String LOG_TAG = "ScummVM";
- // TODO don't hardcode this
- private final static boolean PLUGINS_ENABLED = false;
- private final static String META_NEXT_ACTIVITY =
- "org.scummvm.unpacker.nextActivity";
- private ProgressBar mProgress;
- private File mUnpackDest; // location to unpack into
- private AsyncTask<String, Integer, Void> mUnpacker;
- private final static int REQUEST_MARKET = 1;
-
- // Android 3.1+ only
- public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 32;
-
- private static class UnpackJob {
- public ZipFile zipfile;
- public Set<String> paths;
-
- public UnpackJob(ZipFile zipfile, Set<String> paths) {
- this.zipfile = zipfile;
- this.paths = paths;
- }
-
- public long UnpackSize() {
- long size = 0;
- for (String path: paths) {
- ZipEntry entry = zipfile.getEntry(path);
- if (entry != null) size += entry.getSize();
- }
- return size;
- }
- }
-
- private class UnpackTask extends AsyncTask<String, Integer, Void> {
- @Override
- protected void onProgressUpdate(Integer... progress) {
- mProgress.setIndeterminate(false);
- mProgress.setMax(progress[1]);
- mProgress.setProgress(progress[0]);
- mProgress.postInvalidate();
- }
-
- @Override
- protected void onPostExecute(Void result) {
- Bundle md = getMetaData();
- String nextActivity = md.getString(META_NEXT_ACTIVITY);
- if (nextActivity != null) {
- final ComponentName cn =
- ComponentName.unflattenFromString(nextActivity);
- if (cn != null) {
- final Intent origIntent = getIntent();
- Intent intent = new Intent();
- intent.setComponent(cn);
- if (origIntent.getExtras() != null)
- intent.putExtras(origIntent.getExtras());
- intent.putExtra(Intent.EXTRA_INTENT, origIntent);
- intent.setDataAndType(origIntent.getData(),
- origIntent.getType());
- //intent.fillIn(getIntent(), 0);
- intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
- Log.i(LOG_TAG,
- "Starting next activity with intent " + intent);
- startActivity(intent);
- } else {
- Log.w(LOG_TAG,
- "Unable to extract a component name from " + nextActivity);
- }
- }
-
- finish();
- }
-
- @Override
- protected Void doInBackground(String... all_libs) {
- // This will contain all unpack jobs
- Map<String, UnpackJob> unpack_jobs =
- new HashMap<String, UnpackJob>(all_libs.length);
-
- // This will contain all unpack filenames (so we can
- // detect stale files in the unpack directory)
- Set<String> all_files = new HashSet<String>(all_libs.length);
-
- for (String lib: all_libs) {
- final Uri uri = Uri.parse(lib);
- final String pkg = uri.getAuthority();
- final String path = uri.getPath().substring(1); // skip first /
-
- all_files.add(new File(path).getName());
-
- UnpackJob job = unpack_jobs.get(pkg);
- if (job == null) {
- try {
- // getPackageResourcePath is hidden in Context,
- // but exposed in ContextWrapper...
- ContextWrapper context =
- new ContextWrapper(createPackageContext(pkg, 0));
- ZipFile zipfile =
- new ZipFile(context.getPackageResourcePath());
- job = new UnpackJob(zipfile, new HashSet<String>(1));
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(LOG_TAG, "Package " + pkg +
- " not found", e);
- continue;
- } catch (IOException e) {
- // FIXME: show some sort of GUI error dialog
- Log.e(LOG_TAG,
- "Error opening ZIP for package " + pkg, e);
- continue;
- }
- unpack_jobs.put(pkg, job);
- }
- job.paths.add(path);
- }
-
- // Delete stale filenames from mUnpackDest
- for (File file: mUnpackDest.listFiles()) {
- if (!all_files.contains(file.getName())) {
- Log.i(LOG_TAG,
- "Deleting stale cached file " + file);
- file.delete();
- }
- }
-
- int total_size = 0;
- for (UnpackJob job: unpack_jobs.values())
- total_size += job.UnpackSize();
-
- publishProgress(0, total_size);
-
- mUnpackDest.mkdirs();
-
- int progress = 0;
-
- for (UnpackJob job: unpack_jobs.values()) {
- try {
- ZipFile zipfile = job.zipfile;
- for (String path: job.paths) {
- ZipEntry zipentry = zipfile.getEntry(path);
- if (zipentry == null)
- throw new FileNotFoundException(
- "Couldn't find " + path + " in zip");
- File dest = new File(mUnpackDest, new File(path).getName());
- if (dest.exists() &&
- dest.lastModified() == zipentry.getTime() &&
- dest.length() == zipentry.getSize()) {
- // Already unpacked
- progress += zipentry.getSize();
- } else {
- if (dest.exists())
- Log.d(LOG_TAG,
- "Replacing " + dest.getPath() +
- " old.mtime=" + dest.lastModified() +
- " new.mtime=" + zipentry.getTime() +
- " old.size=" + dest.length() +
- " new.size=" + zipentry.getSize());
- else
- Log.i(LOG_TAG,
- "Extracting " + zipentry.getName() +
- " from " + zipfile.getName() +
- " to " + dest.getPath());
-
- long next_update = progress;
-
- InputStream in = zipfile.getInputStream(zipentry);
- OutputStream out = new FileOutputStream(dest);
- int len;
- byte[] buffer = new byte[4096];
- while ((len = in.read(buffer)) != -1) {
- out.write(buffer, 0, len);
- progress += len;
- if (progress >= next_update) {
- publishProgress(progress, total_size);
- // Arbitrary limit of 2% update steps
- next_update += total_size / 50;
- }
- }
-
- in.close();
- out.close();
- dest.setLastModified(zipentry.getTime());
- }
- publishProgress(progress, total_size);
- }
-
- zipfile.close();
- } catch (IOException e) {
- // FIXME: show some sort of GUI error dialog
- Log.e(LOG_TAG, "Error unpacking plugin", e);
- }
- }
-
- if (progress != total_size)
- Log.d(LOG_TAG, "Ended with progress " + progress +
- " != total size " + total_size);
-
- setResult(RESULT_OK);
-
- return null;
- }
- }
-
- private class PluginBroadcastReciever extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (!intent.getAction()
- .equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) {
- Log.e(LOG_TAG,
- "Received unexpected action " + intent.getAction());
- return;
- }
-
- Bundle extras = getResultExtras(false);
- if (extras == null) {
- // Nothing for us to do.
- Unpacker.this.setResult(RESULT_OK);
- finish();
- }
-
- ArrayList<String> unpack_libs =
- extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS);
-
- if (unpack_libs != null && !unpack_libs.isEmpty()) {
- final String[] libs =
- unpack_libs.toArray(new String[unpack_libs.size()]);
- mUnpacker = new UnpackTask().execute(libs);
- }
- }
- }
-
- private void initPlugins() {
- Bundle extras = new Bundle(1);
-
- ArrayList<String> unpack_libs = new ArrayList<String>(1);
- // This is the common ScummVM code (not really a "plugin" as such)
- unpack_libs.add(new Uri.Builder()
- .scheme("plugin")
- .authority(getPackageName())
- .path("mylib/armeabi/libscummvm.so")
- .toString());
- extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS,
- unpack_libs);
-
- final PackageInfo info;
- try {
- info = getPackageManager().getPackageInfo(getPackageName(), 0);
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(LOG_TAG, "Error finding my own info?", e);
- return;
- }
- extras.putString(ScummVMApplication.EXTRA_VERSION, info.versionName);
-
- Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY);
- // Android 3.1 defaults to FLAG_EXCLUDE_STOPPED_PACKAGES, and since
- // none of our plugins will ever be running, that is not helpful
- intent.setFlags(FLAG_INCLUDE_STOPPED_PACKAGES);
- sendOrderedBroadcast(intent, Manifest.permission.SCUMMVM_PLUGIN,
- new PluginBroadcastReciever(),
- null, RESULT_OK, null, extras);
- }
-
- @Override
- public void onCreate(Bundle b) {
- super.onCreate(b);
-
- mUnpackDest = ScummVMApplication.getLastCacheDir();
-
- setContentView(R.layout.splash);
- mProgress = (ProgressBar)findViewById(R.id.progress);
-
- setResult(RESULT_CANCELED);
-
- tryUnpack();
- }
-
- private void tryUnpack() {
- Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY);
- List<ResolveInfo> plugins = getPackageManager()
- .queryBroadcastReceivers(intent, 0);
- if (PLUGINS_ENABLED && plugins.isEmpty()) {
- // No plugins installed
- AlertDialog.Builder alert = new AlertDialog.Builder(this)
- .setTitle(R.string.no_plugins_title)
- .setMessage(R.string.no_plugins_found)
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setOnCancelListener(new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- finish();
- }
- })
- .setNegativeButton(R.string.quit,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- finish();
- }
- });
-
- final Uri uri = Uri.parse("market://search?q=ScummVM plugin");
- final Intent market_intent = new Intent(Intent.ACTION_VIEW, uri);
- if (getPackageManager().resolveActivity(market_intent, 0) != null) {
- alert.setPositiveButton(R.string.to_market,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- try {
- startActivityForResult(market_intent,
- REQUEST_MARKET);
- } catch (ActivityNotFoundException e) {
- Log.e(LOG_TAG,
- "Error starting market", e);
- }
- }
- });
- }
-
- alert.show();
-
- } else {
- // Already have at least one plugin installed
- initPlugins();
- }
- }
-
- @Override
- public void onStop() {
- if (mUnpacker != null)
- mUnpacker.cancel(true);
- super.onStop();
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode,
- Intent data) {
- switch (requestCode) {
- case REQUEST_MARKET:
- if (resultCode != RESULT_OK)
- Log.w(LOG_TAG, "Market returned " + resultCode);
- tryUnpack();
- break;
- }
- }
-
- private Bundle getMetaData() {
- try {
- ActivityInfo ai = getPackageManager()
- .getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
- return ai.metaData;
- } catch (PackageManager.NameNotFoundException e) {
- Log.w(LOG_TAG, "Unable to find my own meta-data", e);
- return new Bundle();
- }
- }
-}
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp
index b174e93191..165396b82b 100644
--- a/backends/platform/android/texture.cpp
+++ b/backends/platform/android/texture.cpp
@@ -8,12 +8,12 @@
* 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
+ * 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.
@@ -233,7 +233,7 @@ void GLESTexture::allocBuffer(GLuint w, GLuint h) {
_pixels = new byte[w * h * _surface.format.bytesPerPixel];
assert(_pixels);
- _surface.pixels = _pixels;
+ _surface.setPixels(_pixels);
fillBuffer(0);
@@ -256,14 +256,18 @@ void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h,
}
void GLESTexture::fillBuffer(uint32 color) {
- assert(_surface.pixels);
+ assert(_surface.getPixels());
if (_pixelFormat.bytesPerPixel == 1 ||
- ((color & 0xff) == ((color >> 8) & 0xff)))
+ (_pixelFormat.bytesPerPixel == 2 &&
+ ((color & 0xff) == ((color >> 8) & 0xff))))
memset(_pixels, color & 0xff, _surface.pitch * _surface.h);
- else
- Common::fill(_pixels, _pixels + _surface.pitch * _surface.h,
+ else if (_pixelFormat.bytesPerPixel == 2)
+ Common::fill((uint16 *)_pixels, (uint16 *)(_pixels + _surface.pitch * _surface.h),
(uint16)color);
+ else
+ Common::fill((uint32 *)_pixels, (uint32 *)(_pixels + _surface.pitch * _surface.h),
+ color);
setDirty();
}
@@ -334,6 +338,13 @@ GLES565Texture::GLES565Texture() :
GLES565Texture::~GLES565Texture() {
}
+GLES8888Texture::GLES8888Texture() :
+ GLESTexture(GL_RGBA, GL_UNSIGNED_BYTE, pixelFormat()) {
+}
+
+GLES8888Texture::~GLES8888Texture() {
+}
+
GLESFakePaletteTexture::GLESFakePaletteTexture(GLenum glFormat, GLenum glType,
Graphics::PixelFormat pixelFormat) :
GLESBaseTexture(glFormat, glType, pixelFormat),
@@ -377,7 +388,7 @@ void GLESFakePaletteTexture::allocBuffer(GLuint w, GLuint h) {
assert(_pixels);
// fixup surface, for the outside this is a CLUT8 surface
- _surface.pixels = _pixels;
+ _surface.setPixels(_pixels);
fillBuffer(0);
@@ -386,8 +397,8 @@ void GLESFakePaletteTexture::allocBuffer(GLuint w, GLuint h) {
}
void GLESFakePaletteTexture::fillBuffer(uint32 color) {
- assert(_surface.pixels);
- memset(_surface.pixels, color & 0xff, _surface.pitch * _surface.h);
+ assert(_surface.getPixels());
+ memset(_surface.getPixels(), color & 0xff, _surface.pitch * _surface.h);
setDirty();
}
diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h
index 4307b5a1bc..4b05dfd5d4 100644
--- a/backends/platform/android/texture.h
+++ b/backends/platform/android/texture.h
@@ -8,12 +8,12 @@
* 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.
@@ -224,6 +224,18 @@ public:
}
};
+// RGBA8888 texture
+class GLES8888Texture : public GLESTexture {
+public:
+ GLES8888Texture();
+ virtual ~GLES8888Texture();
+
+ static inline Graphics::PixelFormat pixelFormat() {
+ // We assume LE since all Android platforms are LE.
+ return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
+ }
+};
+
class GLESFakePaletteTexture : public GLESBaseTexture {
protected:
GLESFakePaletteTexture(GLenum glFormat, GLenum glType,