[Scummvm-git-logs] scummvm master -> 6fbd4a3abcb613b8a506ad35e9030536e551ed26
aquadran
noreply at scummvm.org
Sat Feb 5 20:50:03 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6fbd4a3abc ANDROID3D: Remove deprecated backend
Commit: 6fbd4a3abcb613b8a506ad35e9030536e551ed26
https://github.com/scummvm/scummvm/commit/6fbd4a3abcb613b8a506ad35e9030536e551ed26
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-02-05T21:50:00+01:00
Commit Message:
ANDROID3D: Remove deprecated backend
Changed paths:
R backends/platform/android3d/android.cpp
R backends/platform/android3d/android.h
R backends/platform/android3d/android.mk
R backends/platform/android3d/asset-archive.cpp
R backends/platform/android3d/asset-archive.h
R backends/platform/android3d/events.cpp
R backends/platform/android3d/events.h
R backends/platform/android3d/graphics.cpp
R backends/platform/android3d/graphics.h
R backends/platform/android3d/jni-android.cpp
R backends/platform/android3d/jni-android.h
R backends/platform/android3d/module.mk
R backends/platform/android3d/org/residualvm/residualvm/EditableSurfaceView.java
R backends/platform/android3d/org/residualvm/residualvm/ExternalStorage.java
R backends/platform/android3d/org/residualvm/residualvm/MouseHelper.java
R backends/platform/android3d/org/residualvm/residualvm/ResidualVM.java
R backends/platform/android3d/org/residualvm/residualvm/ResidualVMActivity.java
R backends/platform/android3d/org/residualvm/residualvm/ResidualVMEvents.java
R backends/platform/android3d/portdefs.h
R backends/platform/android3d/snprintf.cpp
R backends/platform/android3d/texture.cpp
R backends/platform/android3d/texture.h
R backends/platform/android3d/touchcontrols.cpp
R backends/platform/android3d/touchcontrols.h
R dists/android3d/AndroidManifest.xml
R dists/android3d/assets/arrows.tga
R dists/android3d/build.gradle
R dists/android3d/gradle/wrapper/gradle-wrapper.jar
R dists/android3d/gradle/wrapper/gradle-wrapper.properties
R dists/android3d/gradlew
R dists/android3d/jni/Android.mk
R dists/android3d/res/drawable-hdpi/ic_action_keyboard.png
R dists/android3d/res/drawable-hdpi/ic_action_settings.png
R dists/android3d/res/drawable-mdpi/ic_action_keyboard.png
R dists/android3d/res/drawable-mdpi/ic_action_settings.png
R dists/android3d/res/drawable-xhdpi/ic_action_keyboard.png
R dists/android3d/res/drawable-xhdpi/ic_action_settings.png
R dists/android3d/res/drawable-xxhdpi/ic_action_keyboard.png
R dists/android3d/res/drawable-xxhdpi/ic_action_settings.png
R dists/android3d/res/drawable/residualvm.png
R dists/android3d/res/drawable/residualvm_big.png
R dists/android3d/res/layout/main.xml
R dists/android3d/res/values/strings.xml
backends/module.mk
backends/platform/android/asset-archive.cpp
backends/platform/android/jni-android.cpp
configure
diff --git a/backends/module.mk b/backends/module.mk
index 96982f931e2..00e808d2ac0 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -246,11 +246,6 @@ MODULE_OBJS += \
mutex/pthread/pthread-mutex.o
endif
-ifeq ($(BACKEND),android3d)
-MODULE_OBJS += \
- mutex/pthread/pthread-mutex.o
-endif
-
ifeq ($(BACKEND),androidsdl)
MODULE_OBJS += \
events/androidsdl/androidsdl-events.o
diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp
index 73f650d6972..adc42e4ceb4 100644
--- a/backends/platform/android/asset-archive.cpp
+++ b/backends/platform/android/asset-archive.cpp
@@ -134,10 +134,6 @@ int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) con
int count = 0;
Common::List<Common::String> dirs;
dirs.push_back("");
-#ifdef BACKEND_ANDROID3D
- // ResidualVM specific: multiple directories
- dirs.push_back("shaders");
-#endif
for (const auto& currentDir : dirs) {
AAssetDir *dir = AAssetManager_openDir(_am, "");
const char *file = AAssetDir_getNextFileName(dir);
diff --git a/backends/platform/android/jni-android.cpp b/backends/platform/android/jni-android.cpp
index d8eb3d689eb..2140e881b68 100644
--- a/backends/platform/android/jni-android.cpp
+++ b/backends/platform/android/jni-android.cpp
@@ -146,11 +146,7 @@ jint JNI::onLoad(JavaVM *vm) {
if (_vm->GetEnv((void **)&env, JNI_VERSION_1_2))
return JNI_ERR;
-#ifdef BACKEND_ANDROID3D
- jclass cls = env->FindClass("org/residualvm/residualvm/ResidualVM");
-#else
jclass cls = env->FindClass("org/scummvm/scummvm/ScummVM");
-#endif
if (cls == 0)
return JNI_ERR;
@@ -488,7 +484,6 @@ bool JNI::getTouch3DMode() {
}
void JNI::showSAFRevokePermsControl(bool enable) {
-#ifndef BACKEND_ANDROID3D
JNIEnv *env = JNI::getEnv();
env->CallVoidMethod(_jobj, _MID_showSAFRevokePermsControl, enable);
@@ -499,7 +494,6 @@ void JNI::showSAFRevokePermsControl(bool enable) {
env->ExceptionDescribe();
env->ExceptionClear();
}
-#endif
}
// The following adds assets folder to search set.
@@ -679,13 +673,11 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
FIND_METHOD(, getAllStorageLocations, "()[Ljava/lang/String;");
FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
FIND_METHOD(, deinitSurface, "()V");
-#ifndef BACKEND_ANDROID3D
FIND_METHOD(, showSAFRevokePermsControl, "(Z)V");
FIND_METHOD(, createDirectoryWithSAF, "(Ljava/lang/String;)Z");
FIND_METHOD(, createFileWithSAF, "(Ljava/lang/String;)Ljava/lang/String;");
FIND_METHOD(, closeFileWithSAF, "(Ljava/lang/String;)V");
FIND_METHOD(, isDirectoryWritableWithSAF, "(Ljava/lang/String;)Z");
-#endif
_jobj_egl = env->NewGlobalRef(egl);
_jobj_egl_display = env->NewGlobalRef(egl_display);
@@ -841,13 +833,6 @@ void JNI::setPause(JNIEnv *env, jobject self, jboolean value) {
JNI::_pauseToken = g_engine->pauseEngine();
else
JNI::_pauseToken.clear();
-
-#ifdef BACKEND_ANDROID3D
- if (value &&
- g_engine->hasFeature(Engine::kSupportsSavingDuringRuntime) &&
- g_engine->canSaveGameStateCurrently())
- g_engine->saveGameState(0, "Android parachute");
-#endif
}
pause = value;
@@ -918,7 +903,6 @@ Common::Array<Common::String> JNI::getAllStorageLocations() {
}
bool JNI::createDirectoryWithSAF(const Common::String &dirPath) {
-#ifndef BACKEND_ANDROID3D
JNIEnv *env = JNI::getEnv();
jstring javaDirPath = env->NewStringUTF(dirPath.c_str());
@@ -933,13 +917,9 @@ bool JNI::createDirectoryWithSAF(const Common::String &dirPath) {
}
return created;
-#else
- return false;
-#endif
}
Common::U32String JNI::createFileWithSAF(const Common::String &filePath) {
-#ifndef BACKEND_ANDROID3D
JNIEnv *env = JNI::getEnv();
jstring javaFilePath = env->NewStringUTF(filePath.c_str());
@@ -959,13 +939,9 @@ Common::U32String JNI::createFileWithSAF(const Common::String &filePath) {
env->DeleteLocalRef(hackyFilenameJSTR);
return hackyFilenameStr;
-#else
- return Common::U32String();
-#endif
}
void JNI::closeFileWithSAF(const Common::String &hackyFilename) {
-#ifndef BACKEND_ANDROID3D
JNIEnv *env = JNI::getEnv();
jstring javaHackyFilename = env->NewStringUTF(hackyFilename.c_str());
@@ -977,11 +953,9 @@ void JNI::closeFileWithSAF(const Common::String &hackyFilename) {
env->ExceptionDescribe();
env->ExceptionClear();
}
-#endif
}
bool JNI::isDirectoryWritableWithSAF(const Common::String &dirPath) {
-#ifndef BACKEND_ANDROID3D
JNIEnv *env = JNI::getEnv();
jstring javaDirPath = env->NewStringUTF(dirPath.c_str());
@@ -996,9 +970,6 @@ bool JNI::isDirectoryWritableWithSAF(const Common::String &dirPath) {
}
return isWritable;
-#else
- return false;
-#endif
}
#endif
diff --git a/backends/platform/android3d/android.cpp b/backends/platform/android3d/android.cpp
deleted file mode 100644
index 7625d0f8890..00000000000
--- a/backends/platform/android3d/android.cpp
+++ /dev/null
@@ -1,590 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#if defined(__ANDROID__)
-
-#define FORBIDDEN_SYMBOL_EXCEPTION_getenv(a)
-
-// Allow use of stuff in <time.h>
-#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
-
-// Disable printf override in common/forbidden.h to avoid
-// clashes with log.h from the Android SDK.
-// That header file uses
-// __attribute__ ((format(printf, 3, 4)))
-// which gets messed up by our override mechanism; this could
-// be avoided by either changing the Android SDK to use the equally
-// legal and valid
-// __attribute__ ((format(printf, 3, 4)))
-// or by refining our printf override to use a varadic macro
-// (which then wouldn't be portable, though).
-// Anyway, for now we just disable the printf override globally
-// for the Android port
-#define FORBIDDEN_SYMBOL_EXCEPTION_printf
-
-#include <EGL/egl.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/system_properties.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "common/util.h"
-#include "common/textconsole.h"
-#include "common/rect.h"
-#include "common/queue.h"
-#include "common/mutex.h"
-#include "common/events.h"
-#include "common/config-manager.h"
-
-#include "backends/audiocd/default/default-audiocd.h"
-#include "backends/events/default/default-events.h"
-#include "backends/mutex/pthread/pthread-mutex.h"
-#include "backends/saves/default/default-saves.h"
-#include "backends/timer/default/default-timer.h"
-
-#include "backends/keymapper/keymapper.h"
-#include "backends/keymapper/keymapper-defaults.h"
-#include "backends/keymapper/standard-actions.h"
-
-#include "backends/platform/android3d/jni-android.h"
-#include "backends/platform/android3d/android.h"
-#include "backends/platform/android3d/graphics.h"
-
-const char *android_log_tag = "ResidualVM";
-
-// This replaces the bionic libc assert functions with something that
-// actually prints the assertion failure before aborting.
-extern "C" {
- void __assert(const char *file, int line, const char *expr) {
- __android_log_assert(expr, android_log_tag,
- "Assertion failure: '%s' in %s:%d",
- expr, file, line);
- }
-
- void __assert2(const char *file, int line, const char *func,
- const char *expr) {
- __android_log_assert(expr, android_log_tag,
- "Assertion failure: '%s' in %s:%d (%s)",
- expr, file, line, func);
- }
-}
-
-#ifdef ANDROID_DEBUG_GL
-static const char *getGlErrStr(GLenum error) {
- switch (error) {
- case GL_INVALID_ENUM:
- return "GL_INVALID_ENUM";
- case GL_INVALID_VALUE:
- return "GL_INVALID_VALUE";
- case GL_INVALID_OPERATION:
- return "GL_INVALID_OPERATION";
- case GL_STACK_OVERFLOW:
- return "GL_STACK_OVERFLOW";
- case GL_STACK_UNDERFLOW:
- return "GL_STACK_UNDERFLOW";
- case GL_OUT_OF_MEMORY:
- return "GL_OUT_OF_MEMORY";
- }
-
- static char buf[40];
- snprintf(buf, sizeof(buf), "(Unknown GL error code 0x%x)", error);
-
- return buf;
-}
-
-void checkGlError(const char *expr, const char *file, int line) {
- GLenum error = glGetError();
-
- if (error != GL_NO_ERROR)
- LOGE("GL ERROR: %s on %s (%s:%d)", getGlErrStr(error), expr, file, line);
-}
-#endif
-
-void *androidGLgetProcAddress(const char *name) {
- // This exists since Android 2.3 (API Level 9)
- return (void *)eglGetProcAddress(name);
-}
-
-OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
- _audio_sample_rate(audio_sample_rate),
- _audio_buffer_size(audio_buffer_size),
- _screen_changeid(0),
- _mixer(0),
- _queuedEventTime(0),
- _event_queue_lock(0),
- _touch_pt_down(),
- _touch_pt_scroll(),
- _touch_pt_dt(),
- _eventScaleX(100),
- _eventScaleY(100),
- // TODO put these values in some option dlg?
- _touchpad_mode(true),
- _touchpad_scale(66),
- _dpad_scale(4),
- _fingersDown(0),
- _trackball_scale(2) {
-
- _fsFactory = new POSIXFilesystemFactory();
-
- LOGI("Running on: [%s] [%s] [%s] [%s] [%s] SDK:%s ABI:%s",
- getSystemProperty("ro.product.manufacturer").c_str(),
- getSystemProperty("ro.product.model").c_str(),
- getSystemProperty("ro.product.brand").c_str(),
- getSystemProperty("ro.build.fingerprint").c_str(),
- getSystemProperty("ro.build.display.id").c_str(),
- getSystemProperty("ro.build.version.sdk").c_str(),
- getSystemProperty("ro.product.cpu.abi").c_str());
-}
-
-OSystem_Android::~OSystem_Android() {
- ENTER();
- // _audiocdManager should be deleted before _mixer!
- // It is normally deleted in proper order in the OSystem destructor.
- // However, currently _mixer is deleted here (OSystem_Android)
- // and in the ModularBackend destructor,
- // hence unless _audiocdManager is deleted here first,
- // it will cause a crash for the Android app (arm64 v8a) upon exit
- // -- when the audio cd manager was actually used eg. audio cd test of the testbed
- // FIXME: A more proper fix would probably be to:
- // - delete _mixer in the base class (OSystem) after _audiocdManager (this is already the current behavior)
- // - remove its deletion from OSystem_Android and ModularBackend (this is what needs to be fixed).
- delete _audiocdManager;
- _audiocdManager = 0;
- delete _mixer;
- _mixer = 0;
- delete _fsFactory;
- _fsFactory = 0;
- delete _timerManager;
- _timerManager = 0;
-
- delete _event_queue_lock;
-
- delete _savefileManager;
- _savefileManager = 0;
-}
-
-void *OSystem_Android::timerThreadFunc(void *arg) {
- OSystem_Android *system = (OSystem_Android *)arg;
- DefaultTimerManager *timer = (DefaultTimerManager *)(system->_timerManager);
-
- // renice this thread to boost the audio thread
- if (setpriority(PRIO_PROCESS, 0, 19) < 0)
- LOGW("couldn't renice the timer thread");
-
- JNI::attachThread();
-
- struct timespec tv;
- tv.tv_sec = 0;
- tv.tv_nsec = 10 * 1000 * 1000; // 10ms
-
- while (!system->_timer_thread_exit) {
- if (JNI::pause) {
- LOGD("timer thread going to sleep");
- sem_wait(&JNI::pause_sem);
- LOGD("timer thread woke up");
- }
-
- timer->handler();
- nanosleep(&tv, 0);
- }
-
- JNI::detachThread();
-
- return 0;
-}
-
-void *OSystem_Android::audioThreadFunc(void *arg) {
- JNI::attachThread();
-
- OSystem_Android *system = (OSystem_Android *)arg;
- Audio::MixerImpl *mixer = system->_mixer;
-
- uint buf_size = system->_audio_buffer_size;
-
- JNIEnv *env = JNI::getEnv();
-
- jbyteArray bufa = env->NewByteArray(buf_size);
-
- bool paused = true;
-
- int offset, left, written, i;
-
- struct timespec tv_delay;
- tv_delay.tv_sec = 0;
- tv_delay.tv_nsec = 20 * 1000 * 1000;
-
- uint msecs_full = buf_size * 1000 / (mixer->getOutputRate() * 2 * 2);
-
- struct timespec tv_full;
- tv_full.tv_sec = 0;
- tv_full.tv_nsec = msecs_full * 1000 * 1000;
-
- uint silence_count = 33;
-
- while (!system->_audio_thread_exit) {
- if (JNI::pause) {
- JNI::setAudioStop();
-
- paused = true;
- silence_count = 33;
-
- LOGD("audio thread going to sleep");
- sem_wait(&JNI::pause_sem);
- LOGD("audio thread woke up");
- }
-
- byte *buf = (byte *)env->GetPrimitiveArrayCritical(bufa, 0);
- assert(buf);
-
- int samples = mixer->mixCallback(buf, buf_size);
-
- bool silence = samples < 1;
-
- // looks stupid, and it is, but currently there's no way to detect
- // silence-only buffers from the mixer
- if (!silence) {
- silence = true;
-
- for (i = 0; i < samples; i += 2)
- // SID streams constant crap
- if (READ_UINT16(buf + i) > 32) {
- silence = false;
- break;
- }
- }
-
- env->ReleasePrimitiveArrayCritical(bufa, buf, 0);
-
- if (silence) {
- if (!paused)
- silence_count++;
-
- // only pause after a while to prevent toggle mania
- if (silence_count > 32) {
- if (!paused) {
- LOGD("AudioTrack pause");
-
- JNI::setAudioPause();
- paused = true;
- }
-
- nanosleep(&tv_full, 0);
-
- continue;
- }
- }
-
- if (paused) {
- LOGD("AudioTrack play");
-
- JNI::setAudioPlay();
- paused = false;
-
- silence_count = 0;
- }
-
- offset = 0;
- left = buf_size;
- written = 0;
-
- while (left > 0) {
- written = JNI::writeAudio(env, bufa, offset, left);
-
- if (written < 0) {
- LOGE("AudioTrack error: %d", written);
- break;
- }
-
- // buffer full
- if (written < left)
- nanosleep(&tv_delay, 0);
-
- offset += written;
- left -= written;
- }
-
- if (written < 0)
- break;
-
- // prepare the next buffer, and run into the blocking AudioTrack.write
- }
-
- JNI::setAudioStop();
-
- env->DeleteLocalRef(bufa);
-
- JNI::detachThread();
-
- return 0;
-}
-
-void OSystem_Android::initBackend() {
- ENTER();
-
- _main_thread = pthread_self();
-
- ConfMan.registerDefault("fullscreen", true);
- ConfMan.registerDefault("aspect_ratio", true);
- ConfMan.registerDefault("touchpad_mouse_mode", true);
-
- ConfMan.registerDefault("autosave_period", 0);
- ConfMan.setBool("FM_high_quality", false);
- ConfMan.setBool("FM_medium_quality", true);
- ConfMan.set("browser_lastpath", ConfMan.get("path"));
-
- if (ConfMan.hasKey("touchpad_mouse_mode"))
- _touchpad_mode = ConfMan.getBool("touchpad_mouse_mode");
- else
- ConfMan.setBool("touchpad_mouse_mode", true);
-
- // must happen before creating TimerManager to avoid race in
- // creating EventManager
- setupKeymapper();
-
- // BUG: "transient" ConfMan settings get nuked by the options
- // screen. Passing the savepath in this way makes it stick
- // (via ConfMan.registerDefault)
- _savefileManager = new DefaultSaveFileManager(ConfMan.get("savepath"));
- // TODO remove the debug message eventually
- LOGD("Setting DefaultSaveFileManager path to: %s", ConfMan.get("savepath").c_str());
-
- _timerManager = new DefaultTimerManager();
-
- _event_queue_lock = new Common::Mutex();
-
- gettimeofday(&_startTime, 0);
-
- _mixer = new Audio::MixerImpl(_audio_sample_rate, _audio_buffer_size);
- _mixer->setReady(true);
-
- _timer_thread_exit = false;
- pthread_create(&_timer_thread, 0, timerThreadFunc, this);
-
- _audio_thread_exit = false;
- pthread_create(&_audio_thread, 0, audioThreadFunc, this);
-
- _graphicsManager = new AndroidGraphicsManager();
-
- dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->initSurface();
-
- // renice this thread to boost the audio thread
- if (setpriority(PRIO_PROCESS, 0, 19) < 0)
- warning("couldn't renice the main thread");
-
- JNI::setReadyForEvents(true);
-
- _eventManager = new DefaultEventManager(this);
- _audiocdManager = new DefaultAudioCDManager();
-
- BaseBackend::initBackend();
-}
-
-bool OSystem_Android::hasFeature(Feature f) {
- if (f == kFeatureVirtualKeyboard ||
- f == kFeatureOpenUrl ||
- f == kFeatureTouchpadMode ||
- f == kFeatureOnScreenControl ||
- f == kFeatureClipboardSupport ||
- f == kFeatureOpenGLForGame ||
- f == kFeatureOverlaySupportsAlpha ||
- f == kFeatureClipboardSupport) {
- return true;
- }
- return ModularGraphicsBackend::hasFeature(f);
-}
-
-void OSystem_Android::setFeatureState(Feature f, bool enable) {
- ENTER("%d, %d", f, enable);
-
- switch (f) {
- case kFeatureVirtualKeyboard:
- _virtkeybd_on = enable;
- showVirtualKeyboard(enable);
- break;
- case kFeatureTouchpadMode:
- ConfMan.setBool("touchpad_mouse_mode", enable);
- _touchpad_mode = enable;
- break;
- case kFeatureOnScreenControl:
- ConfMan.setBool("onscreen_control", enable);
- JNI::showKeyboardControl(enable);
- break;
- default:
- ModularGraphicsBackend::setFeatureState(f, enable);
- break;
- }
-}
-
-bool OSystem_Android::getFeatureState(Feature f) {
- switch (f) {
- case kFeatureVirtualKeyboard:
- return _virtkeybd_on;
- case kFeatureTouchpadMode:
- return ConfMan.getBool("touchpad_mouse_mode");
- case kFeatureOnScreenControl:
- return ConfMan.getBool("onscreen_control");
- default:
- return ModularGraphicsBackend::getFeatureState(f);
- }
-}
-
-Common::KeymapperDefaultBindings *OSystem_Android::getKeymapperDefaultBindings() {
- Common::KeymapperDefaultBindings *keymapperDefaultBindings = new Common::KeymapperDefaultBindings();
-
- // The swap_menu_and_back is a legacy configuration key
- // It is only checked here for compatibility with old config files
- // where it may have been set as "true"
- // TODO Why not just ignore it entirely anyway?
- if (ConfMan.hasKey("swap_menu_and_back") && ConfMan.getBool("swap_menu_and_back")) {
- keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "MENU", "AC_BACK");
- keymapperDefaultBindings->setDefaultBinding("engine-default", Common::kStandardActionSkip, "MENU");
- keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, "CLOS", "MENU");
- } else {
- keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "MENU", "MENU");
- keymapperDefaultBindings->setDefaultBinding("engine-default", Common::kStandardActionSkip, "AC_BACK");
- keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, "CLOS", "AC_BACK");
- }
-
- return keymapperDefaultBindings;
-}
-
-uint32 OSystem_Android::getMillis(bool skipRecord) {
- timeval curTime;
-
- gettimeofday(&curTime, 0);
-
- return (uint32)(((curTime.tv_sec - _startTime.tv_sec) * 1000) +
- ((curTime.tv_usec - _startTime.tv_usec) / 1000));
-}
-
-void OSystem_Android::delayMillis(uint msecs) {
- usleep(msecs * 1000);
-}
-
-Common::MutexInternal *OSystem_Android::createMutex() {
- return createPthreadMutexInternal();
-}
-
-void OSystem_Android::quit() {
- ENTER();
-
- JNI::setReadyForEvents(false);
-
- _audio_thread_exit = true;
- pthread_join(_audio_thread, 0);
-
- _timer_thread_exit = true;
- pthread_join(_timer_thread, 0);
-
- dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->deinitSurface();
-}
-
-void OSystem_Android::setWindowCaption(const Common::U32String &caption) {
- JNI::setWindowCaption(caption);
-}
-
-void OSystem_Android::showVirtualKeyboard(bool enable) {
- ENTER("%d", enable);
-
- JNI::showVirtualKeyboard(enable);
-}
-
-Audio::Mixer *OSystem_Android::getMixer() {
- assert(_mixer);
- return _mixer;
-}
-
-void OSystem_Android::getTimeAndDate(TimeDate &td, bool skipRecord) const {
- struct tm tm;
- const time_t curTime = time(0);
-
- localtime_r(&curTime, &tm);
- td.tm_sec = tm.tm_sec;
- td.tm_min = tm.tm_min;
- td.tm_hour = tm.tm_hour;
- td.tm_mday = tm.tm_mday;
- td.tm_mon = tm.tm_mon;
- td.tm_year = tm.tm_year;
- td.tm_wday = tm.tm_wday;
-}
-
-void OSystem_Android::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
- ENTER("");
-
- JNI::addSysArchivesToSearchSet(s, priority);
-}
-
-void OSystem_Android::logMessage(LogMessageType::Type type, const char *message) {
- switch (type) {
- case LogMessageType::kInfo:
- __android_log_write(ANDROID_LOG_INFO, android_log_tag, message);
- break;
-
- case LogMessageType::kDebug:
- __android_log_write(ANDROID_LOG_DEBUG, android_log_tag, message);
- break;
-
- case LogMessageType::kWarning:
- __android_log_write(ANDROID_LOG_WARN, android_log_tag, message);
- break;
-
- case LogMessageType::kError:
- __android_log_write(ANDROID_LOG_ERROR, android_log_tag, message);
- break;
- }
-}
-
-Common::String OSystem_Android::getSystemLanguage() const {
- return Common::String::format("%s_%s",
- getSystemProperty("persist.sys.language").c_str(),
- getSystemProperty("persist.sys.country").c_str());
-}
-
-bool OSystem_Android::openUrl(const Common::String &url) {
- return JNI::openUrl(url);
-}
-
-bool OSystem_Android::hasTextInClipboard() {
- return JNI::hasTextInClipboard();
-}
-
-Common::U32String OSystem_Android::getTextFromClipboard() {
- return JNI::getTextFromClipboard();
-}
-
-bool OSystem_Android::setTextInClipboard(const Common::U32String &text) {
- return JNI::setTextInClipboard(text);
-}
-
-bool OSystem_Android::isConnectionLimited() {
- return JNI::isConnectionLimited();
-}
-
-Common::String OSystem_Android::getSystemProperty(const char *name) const {
- char value[PROP_VALUE_MAX];
-
- int len = __system_property_get(name, value);
-
- return Common::String(value, len);
-}
-
-#endif
diff --git a/backends/platform/android3d/android.h b/backends/platform/android3d/android.h
deleted file mode 100644
index d1cfa9c1745..00000000000
--- a/backends/platform/android3d/android.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef _ANDROID_H_
-#define _ANDROID_H_
-
-#if defined(__ANDROID__)
-
-#include "backends/platform/android3d/portdefs.h"
-#include "common/fs.h"
-#include "common/archive.h"
-#include "common/mutex.h"
-#include "common/ustr.h"
-#include "audio/mixer_intern.h"
-#include "graphics/palette.h"
-#include "graphics/surface.h"
-#include "graphics/opengl/system_headers.h"
-#include "backends/graphics3d/opengl/framebuffer.h"
-#include "backends/modular-backend.h"
-#include "backends/plugins/posix/posix-provider.h"
-#include "backends/fs/posix/posix-fs-factory.h"
-
-#include "backends/platform/android3d/events.h"
-#include "backends/platform/android3d/texture.h"
-#include "backends/platform/android3d/graphics.h"
-#include "backends/platform/android3d/touchcontrols.h"
-
-#include <pthread.h>
-
-#include <android/log.h>
-
-// toggles start
-//#define ANDROID_DEBUG_ENTER
-//#define ANDROID_DEBUG_GL
-//#define ANDROID_DEBUG_GL_CALLS
-// toggles end
-
-extern const char *android_log_tag;
-
-#define _ANDROID_LOG(prio, fmt, args...) __android_log_print(prio, android_log_tag, fmt, ## args)
-#define LOGD(fmt, args...) _ANDROID_LOG(ANDROID_LOG_DEBUG, fmt, ##args)
-#define LOGI(fmt, args...) _ANDROID_LOG(ANDROID_LOG_INFO, fmt, ##args)
-#define LOGW(fmt, args...) _ANDROID_LOG(ANDROID_LOG_WARN, fmt, ##args)
-#define LOGE(fmt, args...) _ANDROID_LOG(ANDROID_LOG_ERROR, fmt, ##args)
-
-#ifdef ANDROID_DEBUG_ENTER
-#define ENTER(fmt, args...) LOGD("%s(" fmt ")", __FUNCTION__, ##args)
-#else
-#define ENTER(fmt, args...) do { } while (false)
-#endif
-
-#ifdef ANDROID_DEBUG_GL
-extern void checkGlError(const char *expr, const char *file, int line);
-
-#ifdef ANDROID_DEBUG_GL_CALLS
-#define GLCALLLOG(x, before) \
- do { \
- if (before) \
- LOGD("calling '%s' (%s:%d)", x, __FILE__, __LINE__); \
- else \
- LOGD("returned from '%s' (%s:%d)", x, __FILE__, __LINE__); \
- } while (false)
-#else
-#define GLCALLLOG(x, before) do { } while (false)
-#endif
-
-#define GLCALL(x) \
- do { \
- GLCALLLOG(#x, true); \
- (x); \
- GLCALLLOG(#x, false); \
- checkGlError(#x, __FILE__, __LINE__); \
- } while (false)
-
-#define GLTHREADCHECK \
- do { \
- assert(pthread_self() == _main_thread); \
- } while (false)
-
-#else
-#define GLCALL(x) do { (x); } while (false)
-#define GLTHREADCHECK do { } while (false)
-#endif
-
-void *androidGLgetProcAddress(const char *name);
-
-class OSystem_Android : public ModularGraphicsBackend, Common::EventSource {
-private:
- // passed from the dark side
- int _audio_sample_rate;
- int _audio_buffer_size;
-
- int _screen_changeid;
-
- pthread_t _main_thread;
-
- bool _timer_thread_exit;
- pthread_t _timer_thread;
- static void *timerThreadFunc(void *arg);
-
- bool _audio_thread_exit;
- pthread_t _audio_thread;
- static void *audioThreadFunc(void *arg);
-
- bool _virtkeybd_on;
-
- Audio::MixerImpl *_mixer;
- timeval _startTime;
-
- Common::String getSystemProperty(const char *name) const;
-
- void setupKeymapper();
-
-public:
- OSystem_Android(int audio_sample_rate, int audio_buffer_size);
- virtual ~OSystem_Android();
-
- virtual void initBackend();
-
- virtual bool hasFeature(OSystem::Feature f);
- virtual void setFeatureState(OSystem::Feature f, bool enable);
- virtual bool getFeatureState(OSystem::Feature f);
-
-public:
- void pushEvent(int type, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6);
-
-private:
- Common::Queue<Common::Event> _event_queue;
- Common::Event _queuedEvent;
- uint32 _queuedEventTime;
- Common::Mutex *_event_queue_lock;
-
- Common::Point _touch_pt_down, _touch_pt_scroll, _touch_pt_dt;
- int _eventScaleX;
- int _eventScaleY;
- bool _touchpad_mode;
- int _touchpad_scale;
- int _trackball_scale;
- int _dpad_scale;
- int _fingersDown;
-
- void clipMouse(Common::Point &p);
- void scaleMouse(Common::Point &p, int x, int y, bool touchpadMode = false);
- void disableCursorPalette();
-
- TouchControls _touchControls;
-
-public:
-
- virtual void pushEvent(const Common::Event &event);
- virtual void pushKeyPressEvent(Common::Event &event);
- virtual bool pollEvent(Common::Event &event);
- virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings();
-
- virtual uint32 getMillis(bool skipRecord = false);
- virtual void delayMillis(uint msecs);
- virtual Common::MutexInternal *createMutex();
-
- virtual void quit();
-
- virtual void setWindowCaption(const Common::U32String &caption);
- virtual void showVirtualKeyboard(bool enable);
-
- virtual Audio::Mixer *getMixer();
- virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const;
- virtual void logMessage(LogMessageType::Type type, const char *message);
- virtual void addSysArchivesToSearchSet(Common::SearchSet &s,
- int priority = 0);
- virtual bool openUrl(const Common::String &url);
- virtual bool hasTextInClipboard();
- virtual Common::U32String getTextFromClipboard();
- virtual bool setTextInClipboard(const Common::U32String &text);
- virtual bool isConnectionLimited();
- virtual Common::String getSystemLanguage() const;
-
- void updateEventScale(const GLESBaseTexture *tex);
- TouchControls* getTouchControls() { return &_touchControls; }
-};
-
-#endif
-#endif
diff --git a/backends/platform/android3d/android.mk b/backends/platform/android3d/android.mk
deleted file mode 100644
index 8dd4c689029..00000000000
--- a/backends/platform/android3d/android.mk
+++ /dev/null
@@ -1,87 +0,0 @@
-# Android specific build targets
-PATH_DIST = $(srcdir)/dists/android3d
-
-DIST_ANDROID_CONTROLS = $(PATH_DIST)/assets/arrows.tga
-
-GRADLE_FILES = $(shell find $(PATH_DIST)/gradle -type f) $(PATH_DIST)/gradlew $(PATH_DIST)/build.gradle
-
-PATH_BUILD = ./android_project
-PATH_BUILD_GRADLE = $(PATH_BUILD)/build.gradle
-PATH_BUILD_ASSETS = $(PATH_BUILD)/assets
-PATH_BUILD_LIB = $(PATH_BUILD)/lib/$(ABI)
-PATH_BUILD_LIBSCUMMVM = $(PATH_BUILD)/lib/$(ABI)/libscummvm.so
-
-APK_MAIN = ResidualVM-debug.apk
-APK_MAIN_RELEASE = ResidualVM-release-unsigned.apk
-
-$(PATH_BUILD):
- $(MKDIR) $(PATH_BUILD)
-
-$(PATH_BUILD_GRADLE): $(GRADLE_FILES) | $(PATH_BUILD)
- $(CP) -r $(PATH_DIST)/gradle/ $(PATH_BUILD)/gradle/
- $(INSTALL) -c -m 755 $(PATH_DIST)/gradlew $(PATH_BUILD)
- $(INSTALL) -c -m 644 $(PATH_DIST)/build.gradle $(PATH_BUILD)
- $(ECHO) "srcdir=$(realpath $(srcdir))\n" > $(PATH_BUILD)/gradle.properties
- $(ECHO) "org.gradle.jvmargs=-Xmx4096m\n" >> $(PATH_BUILD)/gradle.properties
-# $(ECHO) "android.useAndroidX=true\n" >> $(PATH_BUILD)/gradle.properties
-# $(ECHO) "android.enableJetifier=true\n" >> $(PATH_BUILD)/gradle.properties
- $(ECHO) "sdk.dir=$(realpath $(ANDROID_SDK_ROOT))\n" > $(PATH_BUILD)/local.properties
- $(ECHO) "ndk.dir=$(realpath $(ANDROID_NDK_ROOT))\n" >> $(PATH_BUILD)/local.properties
-
-$(PATH_BUILD_ASSETS): $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_NETWORKING) $(DIST_FILES_VKEYBD) $(DIST_FILES_DOCS) $(DIST_ANDROID_CONTROLS) | $(PATH_BUILD)
- $(INSTALL) -d $(PATH_BUILD_ASSETS)
- $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_NETWORKING) $(DIST_FILES_VKEYBD) $(DIST_FILES_DOCS) $(DIST_ANDROID_CONTROLS) $(PATH_BUILD_ASSETS)/
-ifneq ($(DIST_FILES_SHADERS),)
- $(INSTALL) -d $(PATH_BUILD_ASSETS)/shaders
- $(INSTALL) -c -m 644 $(DIST_FILES_SHADERS) $(PATH_BUILD_ASSETS)/shaders
-endif
-
-$(PATH_BUILD_LIBSCUMMVM): libscummvm.so | $(PATH_BUILD)
- $(INSTALL) -d $(PATH_BUILD_LIB)
- $(INSTALL) -c -m 644 libscummvm.so $(PATH_BUILD_LIBSCUMMVM)
-
-$(APK_MAIN): $(PATH_BUILD_GRADLE) $(PATH_BUILD_ASSETS) $(PATH_BUILD_LIBSCUMMVM) | $(PATH_BUILD)
- (cd $(PATH_BUILD); ./gradlew assembleDebug)
- $(CP) $(PATH_BUILD)/build/outputs/apk/debug/ResidualVM-debug.apk $@
-
-$(APK_MAIN_RELEASE): $(PATH_BUILD_GRADLE) $(PATH_BUILD_ASSETS) $(PATH_BUILD_LIBSCUMMVM) | $(PATH_BUILD)
- (cd $(PATH_BUILD); ./gradlew build)
- $(CP) $(PATH_BUILD)/build/outputs/apk/release/ResidualVM-release-unsigned.apk $@
-
-all: $(APK_MAIN)
-
-clean: androidclean
-
-androidclean:
- @$(RM) -rf $(PATH_BUILD) *.apk
-
-androidrelease: $(APK_MAIN_RELEASE)
-
-androidtestmain: $(APK_MAIN)
- (cd $(PATH_BUILD); ./gradlew installDebug)
- # $(ADB) install -g -r $(APK_MAIN)
- # $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.residualvm.residualvm/.ResidualVMActivity
-
-androidtest: $(APK_MAIN)
- # @set -e; for apk in $^; do \
- # $(ADB) install -g -r $$apk; \
- # done
- # $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.residualvm.residualvm/.ResidualVMActivity
- (cd $(PATH_BUILD); ./gradlew installDebug)
-
-# used by buildbot!
-androiddistdebug: all
- $(MKDIR) debug
- $(CP) $(APK_MAIN) debug/
- for i in $(DIST_FILES_DOCS); do \
- sed 's/$$/\r/' < $$i > debug/`basename $$i`.txt; \
- done
-
-androiddistrelease: androidrelease
- $(MKDIR) release
- $(CP) $(APK_MAIN_RELEASE) release/
- for i in $(DIST_FILES_DOCS); do \
- sed 's/$$/\r/' < $$i > release/`basename $$i`.txt; \
- done
-
-.PHONY: androidrelease androidtest $(PATH_BUILD_SRC)
diff --git a/backends/platform/android3d/asset-archive.cpp b/backends/platform/android3d/asset-archive.cpp
deleted file mode 100644
index db57f1ff491..00000000000
--- a/backends/platform/android3d/asset-archive.cpp
+++ /dev/null
@@ -1,2 +0,0 @@
-#define BACKEND_ANDROID3D
-#include "../android/asset-archive.cpp"
diff --git a/backends/platform/android3d/asset-archive.h b/backends/platform/android3d/asset-archive.h
deleted file mode 100644
index a4122645457..00000000000
--- a/backends/platform/android3d/asset-archive.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../android/asset-archive.h"
diff --git a/backends/platform/android3d/events.cpp b/backends/platform/android3d/events.cpp
deleted file mode 100644
index 4a7727dd79d..00000000000
--- a/backends/platform/android3d/events.cpp
+++ /dev/null
@@ -1,699 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#if defined(__ANDROID__)
-
-// Allow use of stuff in <time.h>
-#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
-
-// Disable printf override in common/forbidden.h to avoid
-// clashes with log.h from the Android SDK.
-// That header file uses
-// __attribute__ ((format(printf, 3, 4)))
-// which gets messed up by our override mechanism; this could
-// be avoided by either changing the Android SDK to use the equally
-// legal and valid
-// __attribute__ ((format(printf, 3, 4)))
-// or by refining our printf override to use a varadic macro
-// (which then wouldn't be portable, though).
-// Anyway, for now we just disable the printf override globally
-// for the Android port
-#define FORBIDDEN_SYMBOL_EXCEPTION_printf
-
-#include "backends/platform/android3d/android.h"
-#include "backends/platform/android3d/graphics.h"
-#include "backends/platform/android3d/events.h"
-#include "backends/platform/android3d/jni-android.h"
-
-#include "engines/engine.h"
-#include "gui/gui-manager.h"
-
-// floating point. use sparingly
-template<class T>
-static inline T scalef(T in, float numerator, float denominator) {
- return static_cast<float>(in) * numerator / denominator;
-}
-
-static const int kQueuedInputEventDelay = 50;
-
-void OSystem_Android::setupKeymapper() {
-#ifdef ENABLE_KEYMAPPER
- using namespace Common;
-
- Keymapper *mapper = getEventManager()->getKeymapper();
-
- HardwareInputSet *inputSet = new HardwareInputSet();
-
- keySet->addHardwareInput(
- new HardwareInput("n", KeyState(KEYCODE_n), "n (vk)"));
-
- mapper->registerHardwareInputSet(inputSet);
-
- Keymap *globalMap = new Keymap(kGlobalKeymapName);
- Action *act;
-
- act = new Action(globalMap, "VIRT", "Display keyboard");
- act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, KBD_CTRL));
-
- mapper->addGlobalKeymap(globalMap);
-
- mapper->pushKeymap(kGlobalKeymapName);
-#endif
-}
-
-void OSystem_Android::clipMouse(Common::Point &p) {
- dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->clipMouse(p);
-}
-
-void OSystem_Android::scaleMouse(Common::Point &p, int x, int y, bool touchpadMode) {
- const GLESBaseTexture *tex =
- dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getActiveTexture();
-
- const Common::Rect &r = tex->getDrawRect();
-
- if (touchpadMode) {
- x = x * 100 / _touchpad_scale;
- y = y * 100 / _touchpad_scale;
- }
-
- p.x = scalef(x, tex->width(), r.width());
- p.y = scalef(y, tex->height(), r.height());
-}
-
-void OSystem_Android::updateEventScale(const GLESBaseTexture *tex) {
- if (tex && (tex->height() != 0) && (tex->width() != 0)) {
- _eventScaleY = 100 * 480 / tex->height();
- _eventScaleX = 100 * 640 / tex->width();
- }
-}
-
-void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
- int arg4, int arg5, int arg6) {
- Common::Event e;
-
- switch (type) {
- case JE_SYS_KEY:
- 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 system key: %d", arg1);
- return;
- }
-
- switch (arg2) {
-
- // special case. we'll only get it's up event
- case JKEYCODE_BACK:
- e.kbd.keycode = Common::KEYCODE_ESCAPE;
- e.kbd.ascii = Common::ASCII_ESCAPE;
-
- _event_queue_lock->lock();
- e.type = Common::EVENT_KEYDOWN;
- _event_queue.push(e);
- e.type = Common::EVENT_KEYUP;
- _event_queue.push(e);
- _event_queue_lock->unlock();
-
- return;
-
- // special case. we'll only get it's up event
- case JKEYCODE_MENU:
- e.type = Common::EVENT_MAINMENU;
-
- pushEvent(e);
-
- return;
-
- case JKEYCODE_MEDIA_PAUSE:
- case JKEYCODE_MEDIA_PLAY:
- case JKEYCODE_MEDIA_PLAY_PAUSE:
- if (arg1 == JACTION_DOWN) {
- e.type = Common::EVENT_MAINMENU;
-
- pushEvent(e);
- }
-
- return;
-
- case JKEYCODE_CAMERA:
- case JKEYCODE_SEARCH:
- if (arg1 == JACTION_DOWN)
- e.type = Common::EVENT_RBUTTONDOWN;
- else
- e.type = Common::EVENT_RBUTTONUP;
-
- e.mouse = dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getMousePosition();
-
- pushEvent(e);
-
- return;
-
- default:
- LOGW("unmapped system key: %d", arg2);
- return;
- }
-
- break;
-
- case JE_KEY:
- 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 key: %d", arg1);
- return;
- }
-
- if (arg2 < 1 || arg2 > ARRAYSIZE(jkeymap)) {
- if (arg3 < 1) {
- LOGE("received invalid keycode: %d (%d)", arg2, arg3);
- return;
- } else {
- // lets bet on the ascii code
- e.kbd.keycode = Common::KEYCODE_INVALID;
- }
- } else {
- e.kbd.keycode = jkeymap[arg2];
- }
-
- if (arg5 > 0)
- e.kbdRepeat = true;
-
- // map special keys to 'our' ascii codes
- switch (e.kbd.keycode) {
- case Common::KEYCODE_BACKSPACE:
- e.kbd.ascii = Common::ASCII_BACKSPACE;
- break;
- case Common::KEYCODE_TAB:
- e.kbd.ascii = Common::ASCII_TAB;
- break;
- case Common::KEYCODE_RETURN:
- e.kbd.ascii = Common::ASCII_RETURN;
- break;
- case Common::KEYCODE_ESCAPE:
- e.kbd.ascii = Common::ASCII_ESCAPE;
- break;
- case Common::KEYCODE_SPACE:
- e.kbd.ascii = Common::ASCII_SPACE;
- break;
- case Common::KEYCODE_F1:
- e.kbd.ascii = Common::ASCII_F1;
- break;
- case Common::KEYCODE_F2:
- e.kbd.ascii = Common::ASCII_F2;
- break;
- case Common::KEYCODE_F3:
- e.kbd.ascii = Common::ASCII_F3;
- break;
- case Common::KEYCODE_F4:
- e.kbd.ascii = Common::ASCII_F4;
- break;
- case Common::KEYCODE_F5:
- e.kbd.ascii = Common::ASCII_F5;
- break;
- case Common::KEYCODE_F6:
- e.kbd.ascii = Common::ASCII_F6;
- break;
- case Common::KEYCODE_F7:
- e.kbd.ascii = Common::ASCII_F7;
- break;
- case Common::KEYCODE_F8:
- e.kbd.ascii = Common::ASCII_F8;
- break;
- case Common::KEYCODE_F9:
- e.kbd.ascii = Common::ASCII_F9;
- break;
- case Common::KEYCODE_F10:
- e.kbd.ascii = Common::ASCII_F10;
- break;
- case Common::KEYCODE_F11:
- e.kbd.ascii = Common::ASCII_F11;
- break;
- case Common::KEYCODE_F12:
- e.kbd.ascii = Common::ASCII_F12;
- break;
- default:
- e.kbd.ascii = arg3;
- break;
- }
-
- if (arg4 & JMETA_SHIFT)
- e.kbd.flags |= Common::KBD_SHIFT;
- // JMETA_ALT is Fn on physical keyboards!
- // when mapping this to ALT - as we know it from PC keyboards - all
- // Fn combos will be broken (like Fn+q, which needs to end as 1 and
- // not ALT+1). Do not want.
- //if (arg4 & JMETA_ALT)
- // e.kbd.flags |= Common::KBD_ALT;
- if (arg4 & (JMETA_SYM | JMETA_CTRL))
- e.kbd.flags |= Common::KBD_CTRL;
-
- pushEvent(e);
-
- return;
-
- case JE_DPAD:
- switch (arg2) {
- case JKEYCODE_DPAD_UP:
- case JKEYCODE_DPAD_DOWN:
- case JKEYCODE_DPAD_LEFT:
- case JKEYCODE_DPAD_RIGHT:
- if (arg1 != JACTION_DOWN)
- return;
-
- e.type = Common::EVENT_MOUSEMOVE;
-
- e.mouse = dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getMousePosition();
-
- {
- int16 *c;
- int s;
-
- if (arg2 == JKEYCODE_DPAD_UP || arg2 == JKEYCODE_DPAD_DOWN) {
- c = &e.mouse.y;
- s = _eventScaleY;
- } else {
- c = &e.mouse.x;
- s = _eventScaleX;
- }
-
- // the longer the button held, the faster the pointer is
- // TODO put these values in some option dlg?
- int f = CLIP(arg4, 1, 8) * _dpad_scale * 100 / s;
-
- if (arg2 == JKEYCODE_DPAD_UP || arg2 == JKEYCODE_DPAD_LEFT)
- *c -= f;
- else
- *c += f;
- }
-
- clipMouse(e.mouse);
-
- pushEvent(e);
-
- return;
-
- case JKEYCODE_DPAD_CENTER:
- switch (arg1) {
- case JACTION_DOWN:
- e.type = Common::EVENT_LBUTTONDOWN;
- break;
- case JACTION_UP:
- e.type = Common::EVENT_LBUTTONUP;
- break;
- default:
- LOGE("unhandled jaction on dpad key: %d", arg1);
- return;
- }
-
- e.mouse = dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getMousePosition();
-
- pushEvent(e);
-
- return;
- }
-
- case JE_DOWN:
- _touch_pt_down = dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getMousePosition();
- _touch_pt_scroll.x = -1;
- _touch_pt_scroll.y = -1;
- break;
-
- case JE_SCROLL:
- e.type = Common::EVENT_MOUSEMOVE;
-
- if (_touchpad_mode) {
- if (_touch_pt_scroll.x == -1 && _touch_pt_scroll.y == -1) {
- _touch_pt_scroll.x = arg3;
- _touch_pt_scroll.y = arg4;
- return;
- }
-
- scaleMouse(e.mouse, arg3 - _touch_pt_scroll.x,
- arg4 - _touch_pt_scroll.y, true);
- e.mouse += _touch_pt_down;
- scaleMouse(e.relMouse, arg3 - _touch_pt_scroll.x,
- arg4 - _touch_pt_scroll.y, true);
- } else {
- scaleMouse(e.mouse, arg3, arg4);
- }
-
- pushEvent(e);
-
- return;
-
- case JE_TAP:
- if (_fingersDown > 0) {
- _fingersDown = 0;
- return;
- }
-
- e.type = Common::EVENT_MOUSEMOVE;
-
- if (_touchpad_mode) {
- e.mouse = dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getMousePosition();
- } else {
- scaleMouse(e.mouse, arg1, arg2);
- }
-
- {
- Common::EventType down, up;
-
- // TODO put these values in some option dlg?
- if (arg3 > 1000) {
- down = Common::EVENT_MBUTTONDOWN;
- up = Common::EVENT_MBUTTONUP;
- } else if (arg3 > 500) {
- down = Common::EVENT_RBUTTONDOWN;
- up = Common::EVENT_RBUTTONUP;
- } else {
- down = Common::EVENT_LBUTTONDOWN;
- up = Common::EVENT_LBUTTONUP;
- }
-
- _event_queue_lock->lock();
-
- if (_queuedEventTime)
- _event_queue.push(_queuedEvent);
-
- if (!_touchpad_mode)
- _event_queue.push(e);
-
- e.type = down;
- _event_queue.push(e);
-
- e.type = up;
- _queuedEvent = e;
- _queuedEventTime = getMillis() + kQueuedInputEventDelay;
-
- _event_queue_lock->unlock();
- }
-
- return;
-
- case JE_DOUBLE_TAP:
- e.type = Common::EVENT_MOUSEMOVE;
-
- if (_touchpad_mode) {
- e.mouse = dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getMousePosition();
- } else {
- scaleMouse(e.mouse, arg1, arg2);
- }
-
- {
- Common::EventType dptype = Common::EVENT_INVALID;
-
- switch (arg3) {
- case JACTION_DOWN:
- dptype = Common::EVENT_LBUTTONDOWN;
- _touch_pt_dt.x = -1;
- _touch_pt_dt.y = -1;
- break;
- case JACTION_UP:
- dptype = Common::EVENT_LBUTTONUP;
- break;
- // held and moved
- case JACTION_MULTIPLE:
- if (_touch_pt_dt.x == -1 && _touch_pt_dt.y == -1) {
- _touch_pt_dt.x = arg1;
- _touch_pt_dt.y = arg2;
- return;
- }
-
- dptype = Common::EVENT_MOUSEMOVE;
-
- if (_touchpad_mode) {
- scaleMouse(e.mouse, arg1 - _touch_pt_dt.x,
- arg2 - _touch_pt_dt.y, true);
- e.mouse += _touch_pt_down;
- }
-
- break;
- default:
- LOGE("unhandled jaction on double tap: %d", arg3);
- return;
- }
-
- _event_queue_lock->lock();
- _event_queue.push(e);
- e.type = dptype;
- _event_queue.push(e);
- _event_queue_lock->unlock();
- }
-
- return;
-
-
- case JE_TOUCH:
- case JE_MULTI:
- switch (arg2) {
- case JACTION_POINTER_DOWN:
- if (arg1 > _fingersDown)
- _fingersDown = arg1;
-
- return;
-
- case JACTION_POINTER_UP:
- if (arg1 != _fingersDown)
- return;
-
- {
- Common::EventType up;
-
- switch (_fingersDown) {
- case 1:
- e.type = Common::EVENT_RBUTTONDOWN;
- up = Common::EVENT_RBUTTONUP;
- break;
- case 2:
- e.type = Common::EVENT_MBUTTONDOWN;
- up = Common::EVENT_MBUTTONUP;
- break;
- default:
- LOGD("unmapped multi tap: %d", _fingersDown);
- return;
- }
-
- e.mouse = dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getMousePosition();
-
- _event_queue_lock->lock();
-
- if (_queuedEventTime)
- _event_queue.push(_queuedEvent);
-
- _event_queue.push(e);
-
- e.type = up;
- _queuedEvent = e;
- _queuedEventTime = getMillis() + kQueuedInputEventDelay;
-
- _event_queue_lock->unlock();
- return;
-
- default:
- LOGE("unhandled jaction on multi tap: %d", arg2);
- return;
- }
- }
-
- return;
-
- case JE_BALL:
- e.mouse = dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getMousePosition();
-
- switch (arg1) {
- case JACTION_DOWN:
- e.type = Common::EVENT_LBUTTONDOWN;
- break;
- case JACTION_UP:
- e.type = Common::EVENT_LBUTTONUP;
- break;
- case JACTION_MULTIPLE:
- e.type = Common::EVENT_MOUSEMOVE;
-
- // already multiplied by 100
- e.mouse.x += arg2 * _trackball_scale / _eventScaleX;
- e.mouse.y += arg3 * _trackball_scale / _eventScaleY;
-
- clipMouse(e.mouse);
-
- break;
- default:
- LOGE("unhandled jaction on system key: %d", arg1);
- return;
- }
-
- pushEvent(e);
-
- return;
-
- case JE_MOUSE_MOVE:
- e.type = Common::EVENT_MOUSEMOVE;
- scaleMouse(e.mouse, arg1, arg2);
-
- pushEvent(e);
-
- return;
-
- case JE_LMB_DOWN:
- e.type = Common::EVENT_LBUTTONDOWN;
- scaleMouse(e.mouse, arg1, arg2);
-
- pushEvent(e);
-
- return;
-
- case JE_LMB_UP:
- e.type = Common::EVENT_LBUTTONUP;
- scaleMouse(e.mouse, arg1, arg2);
-
- pushEvent(e);
-
- return;
-
- case JE_RMB_DOWN:
- e.type = Common::EVENT_RBUTTONDOWN;
- scaleMouse(e.mouse, arg1, arg2);
-
- pushEvent(e);
-
- return;
-
- case JE_RMB_UP:
- e.type = Common::EVENT_RBUTTONUP;
- scaleMouse(e.mouse, arg1, arg2);
-
- pushEvent(e);
-
- return;
-
- case JE_MMB_DOWN:
- e.type = Common::EVENT_MAINMENU;
-
- pushEvent(e);
-
- return;
-
- case JE_MMB_UP:
- // No action
-
- return;
-
- case JE_QUIT:
- e.type = Common::EVENT_QUIT;
-
- pushEvent(e);
-
- return;
-
- default:
- LOGE("unknown jevent type: %d", type);
-
- break;
- }
-}
-
-bool OSystem_Android::pollEvent(Common::Event &event) {
- //ENTER();
-
- if (pthread_self() == _main_thread) {
- if (_screen_changeid != JNI::surface_changeid) {
- _screen_changeid = JNI::surface_changeid;
-
- if (JNI::egl_surface_width > 0 && JNI::egl_surface_height > 0) {
- // surface changed
- dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->deinitSurface();
- dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->initSurface();
- _touchControls.init(JNI::egl_surface_width, JNI::egl_surface_height);
-
- event.type = Common::EVENT_SCREEN_CHANGED;
-
- return true;
- } else {
- // surface lost
- dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->deinitSurface();
- }
- }
-
- if (JNI::pause) {
- LOGD("main thread going to sleep");
- sem_wait(&JNI::pause_sem);
- LOGD("main thread woke up");
- }
- }
-
- _event_queue_lock->lock();
-
- if (_queuedEventTime && (getMillis() > _queuedEventTime)) {
- event = _queuedEvent;
- _queuedEventTime = 0;
- // _event_queue_lock->unlock();
- // return true;
- } else if (_event_queue.empty()) {
- _event_queue_lock->unlock();
- return false;
- } else {
- event = _event_queue.pop();
- }
-
- _event_queue_lock->unlock();
-
- switch (event.type) {
- case Common::EVENT_MOUSEMOVE:
- case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_LBUTTONUP:
- case Common::EVENT_RBUTTONDOWN:
- case Common::EVENT_RBUTTONUP:
- if (_graphicsManager)
- return dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->notifyMousePosition(event.mouse);
- break;
- default:
- break;
- }
-
- return true;
-}
-
-void OSystem_Android::pushEvent(const Common::Event &event) {
- _event_queue_lock->lock();
- _event_queue.push(event);
- _event_queue_lock->unlock();
-}
-
-void OSystem_Android::pushKeyPressEvent(Common::Event &event) {
- _event_queue_lock->lock();
- event.type = Common::EVENT_KEYDOWN;
- _event_queue.push(event);
- event.type = Common::EVENT_KEYUP;
- _event_queue.push(event);
- _event_queue_lock->unlock();
-}
-
-#endif
diff --git a/backends/platform/android3d/events.h b/backends/platform/android3d/events.h
deleted file mode 100644
index 01d3d086690..00000000000
--- a/backends/platform/android3d/events.h
+++ /dev/null
@@ -1,284 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef ANDROID_EVENTS_H
-#define ANDROID_EVENTS_H
-
-#include "common/events.h"
-
-// $ANDROID_NDK/platforms/android-9/arch-arm/usr/include/android/keycodes.h
-// http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=libs/ui/Input.cpp
-// http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/view/KeyEvent.java
-
-// event type
-enum {
- JE_SYS_KEY = 0,
- JE_KEY = 1,
- JE_DPAD = 2,
- JE_DOWN = 3,
- JE_SCROLL = 4,
- JE_TAP = 5,
- JE_DOUBLE_TAP = 6,
- JE_MULTI = 7,
- JE_BALL = 8,
- JE_LMB_DOWN = 9,
- JE_LMB_UP = 10,
- 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_TOUCH = 18,
- JE_LONG = 19,
- JE_FLING = 20,
- JE_QUIT = 0x1000
-};
-
-// action type
-enum {
- JACTION_DOWN = 0,
- JACTION_UP = 1,
- JACTION_MULTIPLE = 2,
- JACTION_POINTER_DOWN = 5,
- JACTION_POINTER_UP = 6
-};
-
-// system keys
-enum {
- JKEYCODE_SOFT_RIGHT = 2,
- JKEYCODE_HOME = 3,
- JKEYCODE_BACK = 4,
- JKEYCODE_CALL = 5,
- JKEYCODE_ENDCALL = 6,
- JKEYCODE_VOLUME_UP = 24,
- JKEYCODE_VOLUME_DOWN = 25,
- JKEYCODE_POWER = 26,
- JKEYCODE_CAMERA = 27,
- JKEYCODE_HEADSETHOOK = 79,
- JKEYCODE_FOCUS = 80,
- JKEYCODE_MENU = 82,
- JKEYCODE_SEARCH = 84,
- JKEYCODE_MUTE = 91,
- JKEYCODE_MEDIA_PLAY_PAUSE = 85,
- JKEYCODE_MEDIA_STOP = 86,
- JKEYCODE_MEDIA_NEXT = 87,
- JKEYCODE_MEDIA_PREVIOUS = 88,
- JKEYCODE_MEDIA_REWIND = 89,
- JKEYCODE_MEDIA_FAST_FORWARD = 90,
- JKEYCODE_MEDIA_PLAY = 126,
- JKEYCODE_MEDIA_PAUSE = 127
-};
-
-// five-way navigation control
-enum {
- JKEYCODE_DPAD_UP = 19,
- JKEYCODE_DPAD_DOWN = 20,
- JKEYCODE_DPAD_LEFT = 21,
- JKEYCODE_DPAD_RIGHT = 22,
- 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,
- JMETA_ALT = 0x02,
- JMETA_SYM = 0x04,
- JMETA_CTRL = 0x1000
-};
-
-// map android key codes to our kbd codes
-static const Common::KeyCode jkeymap[] = {
- Common::KEYCODE_INVALID, // KEYCODE_UNKNOWN
- Common::KEYCODE_INVALID, // KEYCODE_SOFT_LEFT
- Common::KEYCODE_INVALID, // KEYCODE_SOFT_RIGHT
- Common::KEYCODE_INVALID, // KEYCODE_HOME
- Common::KEYCODE_INVALID, // KEYCODE_BACK
- Common::KEYCODE_INVALID, // KEYCODE_CALL
- Common::KEYCODE_INVALID, // KEYCODE_ENDCALL
- Common::KEYCODE_0, // KEYCODE_0
- Common::KEYCODE_1, // KEYCODE_1
- Common::KEYCODE_2, // KEYCODE_2
- Common::KEYCODE_3, // KEYCODE_3
- Common::KEYCODE_4, // KEYCODE_4
- Common::KEYCODE_5, // KEYCODE_5
- Common::KEYCODE_6, // KEYCODE_6
- Common::KEYCODE_7, // KEYCODE_7
- Common::KEYCODE_8, // KEYCODE_8
- Common::KEYCODE_9, // KEYCODE_9
- Common::KEYCODE_ASTERISK, // KEYCODE_STAR
- Common::KEYCODE_HASH, // KEYCODE_POUND
- Common::KEYCODE_INVALID, // KEYCODE_DPAD_UP
- Common::KEYCODE_INVALID, // KEYCODE_DPAD_DOWN
- Common::KEYCODE_INVALID, // KEYCODE_DPAD_LEFT
- Common::KEYCODE_INVALID, // KEYCODE_DPAD_RIGHT
- Common::KEYCODE_INVALID, // KEYCODE_DPAD_CENTER
- Common::KEYCODE_INVALID, // KEYCODE_VOLUME_UP
- Common::KEYCODE_INVALID, // KEYCODE_VOLUME_DOWN
- Common::KEYCODE_INVALID, // KEYCODE_POWER
- Common::KEYCODE_INVALID, // KEYCODE_CAMERA
- Common::KEYCODE_INVALID, // KEYCODE_CLEAR
- Common::KEYCODE_a, // KEYCODE_A
- Common::KEYCODE_b, // KEYCODE_B
- Common::KEYCODE_c, // KEYCODE_C
- Common::KEYCODE_d, // KEYCODE_D
- Common::KEYCODE_e, // KEYCODE_E
- Common::KEYCODE_f, // KEYCODE_F
- Common::KEYCODE_g, // KEYCODE_G
- Common::KEYCODE_h, // KEYCODE_H
- Common::KEYCODE_i, // KEYCODE_I
- Common::KEYCODE_j, // KEYCODE_J
- Common::KEYCODE_k, // KEYCODE_K
- Common::KEYCODE_l, // KEYCODE_L
- Common::KEYCODE_m, // KEYCODE_M
- Common::KEYCODE_n, // KEYCODE_N
- Common::KEYCODE_o, // KEYCODE_O
- Common::KEYCODE_p, // KEYCODE_P
- Common::KEYCODE_q, // KEYCODE_Q
- Common::KEYCODE_r, // KEYCODE_R
- Common::KEYCODE_s, // KEYCODE_S
- Common::KEYCODE_t, // KEYCODE_T
- Common::KEYCODE_u, // KEYCODE_U
- Common::KEYCODE_v, // KEYCODE_V
- Common::KEYCODE_w, // KEYCODE_W
- Common::KEYCODE_x, // KEYCODE_X
- Common::KEYCODE_y, // KEYCODE_Y
- Common::KEYCODE_z, // KEYCODE_Z
- Common::KEYCODE_COMMA, // KEYCODE_COMMA
- Common::KEYCODE_PERIOD, // KEYCODE_PERIOD
- Common::KEYCODE_LALT, // KEYCODE_ALT_LEFT
- Common::KEYCODE_RALT, // KEYCODE_ALT_RIGHT
- Common::KEYCODE_LSHIFT, // KEYCODE_SHIFT_LEFT
- Common::KEYCODE_RSHIFT, // KEYCODE_SHIFT_RIGHT
- Common::KEYCODE_TAB, // KEYCODE_TAB
- Common::KEYCODE_SPACE, // KEYCODE_SPACE
- Common::KEYCODE_LCTRL, // KEYCODE_SYM
- Common::KEYCODE_INVALID, // KEYCODE_EXPLORER
- Common::KEYCODE_INVALID, // KEYCODE_ENVELOPE
- Common::KEYCODE_RETURN, // KEYCODE_ENTER
- Common::KEYCODE_BACKSPACE, // KEYCODE_DEL
- Common::KEYCODE_BACKQUOTE, // KEYCODE_GRAVE
- Common::KEYCODE_MINUS, // KEYCODE_MINUS
- Common::KEYCODE_EQUALS, // KEYCODE_EQUALS
- Common::KEYCODE_LEFTPAREN, // KEYCODE_LEFT_BRACKET
- Common::KEYCODE_RIGHTPAREN, // KEYCODE_RIGHT_BRACKET
- Common::KEYCODE_BACKSLASH, // KEYCODE_BACKSLASH
- Common::KEYCODE_SEMICOLON, // KEYCODE_SEMICOLON
- Common::KEYCODE_QUOTE, // KEYCODE_APOSTROPHE
- Common::KEYCODE_SLASH, // KEYCODE_SLASH
- Common::KEYCODE_AT, // KEYCODE_AT
- Common::KEYCODE_INVALID, // KEYCODE_NUM
- Common::KEYCODE_INVALID, // KEYCODE_HEADSETHOOK
- Common::KEYCODE_INVALID, // KEYCODE_FOCUS
- Common::KEYCODE_PLUS, // KEYCODE_PLUS
- Common::KEYCODE_INVALID, // KEYCODE_MENU
- Common::KEYCODE_INVALID, // KEYCODE_NOTIFICATION
- Common::KEYCODE_INVALID, // KEYCODE_SEARCH
- Common::KEYCODE_INVALID, // KEYCODE_MEDIA_PLAY_PAUSE
- Common::KEYCODE_INVALID, // KEYCODE_MEDIA_STOP
- Common::KEYCODE_INVALID, // KEYCODE_MEDIA_NEXT
- Common::KEYCODE_INVALID, // KEYCODE_MEDIA_PREVIOUS
- Common::KEYCODE_INVALID, // KEYCODE_MEDIA_REWIND
- Common::KEYCODE_INVALID, // KEYCODE_MEDIA_FAST_FORWARD
- Common::KEYCODE_INVALID, // KEYCODE_MUTE
- Common::KEYCODE_PAGEUP, // KEYCODE_PAGE_UP
- Common::KEYCODE_PAGEDOWN, // KEYCODE_PAGE_DOWN
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- // 96 and up: OUYA buttons.
- Common::KEYCODE_RETURN, // 96: OUYA O
- Common::KEYCODE_p, // 97: OUYA A
- Common::KEYCODE_INVALID,
- Common::KEYCODE_u, // 99: OUYA U
- Common::KEYCODE_i, // 100: OUYA Y
- Common::KEYCODE_INVALID,
- Common::KEYCODE_PAGEUP, // 102: OUYA L1
- Common::KEYCODE_PAGEDOWN, // 103: OUYA R1
- Common::KEYCODE_LSHIFT, // 104: OUYA L2
- Common::KEYCODE_LSHIFT, // 105: OUYA R2
- Common::KEYCODE_ESCAPE, // 106: Press left stick
- Common::KEYCODE_DELETE, // 107: Press right stick
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID, // 110
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID, // 120
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID, // 130
- Common::KEYCODE_F1, // 131 : F1 key
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID, // 140
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID,
- Common::KEYCODE_INVALID, // 150
-};
-
-#endif
diff --git a/backends/platform/android3d/graphics.cpp b/backends/platform/android3d/graphics.cpp
deleted file mode 100644
index c5cd0f6a8d4..00000000000
--- a/backends/platform/android3d/graphics.cpp
+++ /dev/null
@@ -1,882 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#if defined(__ANDROID__)
-
-// Allow use of stuff in <time.h>
-#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
-
-// Disable printf override in common/forbidden.h to avoid
-// clashes with log.h from the Android SDK.
-// That header file uses
-// __attribute__ ((format(printf, 3, 4)))
-// which gets messed up by our override mechanism; this could
-// be avoided by either changing the Android SDK to use the equally
-// legal and valid
-// __attribute__ ((format(printf, 3, 4)))
-// or by refining our printf override to use a varadic macro
-// (which then wouldn't be portable, though).
-// Anyway, for now we just disable the printf override globally
-// for the Android port
-#define FORBIDDEN_SYMBOL_EXCEPTION_printf
-
-#include "common/tokenizer.h"
-#include "graphics/conversion.h"
-#include "graphics/opengl/shader.h"
-#include "graphics/opengl/context.h"
-
-#include "backends/platform/android3d/android.h"
-#include "backends/platform/android3d/events.h"
-#include "backends/platform/android3d/graphics.h"
-#include "backends/platform/android3d/jni-android.h"
-
-AndroidGraphicsManager::AndroidGraphicsManager() :
- _screenChangeID(0),
- _graphicsMode(0),
- _opengl(false),
- _fullscreen(true),
- _ar_correction(true),
- _force_redraw(false),
- _game_texture(0),
- _game_pbuf(),
- _frame_buffer(0),
- _cursorX(0),
- _cursorY(0),
- _overlay_texture(0),
- _show_overlay(false),
- _mouse_texture(0),
- _mouse_texture_palette(0),
- _mouse_texture_rgb(0),
- _mouse_hotspot(),
- _mouse_keycolor(0),
- _show_mouse(false),
- _use_mouse_palette(false)
-{
- _game_texture = new GLESFakePalette565Texture();
- _overlay_texture = new GLES4444Texture();
- _mouse_texture_palette = new GLESFakePalette5551Texture();
- _mouse_texture = _mouse_texture_palette;
-
-}
-
-AndroidGraphicsManager::~AndroidGraphicsManager() {
- delete _game_texture;
- delete _overlay_texture;
- delete _mouse_texture_palette;
- delete _mouse_texture_rgb;
-
-}
-
-static void logExtensions() {
- const char *ext_string =
- reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
-
- LOGI("Extensions:");
-
- Common::String exts;
- Common::StringTokenizer tokenizer(ext_string, " ");
- while (!tokenizer.empty()) {
- Common::String token = tokenizer.nextToken();
-
- exts += token + " ";
- if (exts.size() > 100) {
- LOGI("\t%s", exts.c_str());
- exts = "";
- }
- }
-
- if (exts.size() > 0)
- LOGI("\t%s", exts.c_str());
-}
-
-
-void AndroidGraphicsManager::initSurface() {
- LOGD("initializing surface");
-
- assert(!JNI::haveSurface());
-
- JNI::initSurface();
-
- _screenChangeID = JNI::surface_changeid;
-
- // Initialize OpenGLES context.
- OpenGLContext.initialize(OpenGL::kOGLContextGLES2);
- logExtensions();
- GLESTexture::initGL();
-
- if (_game_texture)
- _game_texture->reinit();
-
- if (_overlay_texture) {
- _overlay_texture->reinit();
- initOverlay();
- }
-
- if (_mouse_texture)
- _mouse_texture->reinit();
-
- initViewport();
- updateScreenRect();
- // double buffered, flip twice
- clearScreen(kClearUpdate, 2);
- updateEventScale();
-}
-
-void AndroidGraphicsManager::deinitSurface() {
- if (!JNI::haveSurface())
- return;
-
- LOGD("deinitializing surface");
-
- _screenChangeID = JNI::surface_changeid;
-
- // release texture resources
- if (_game_texture)
- _game_texture->release();
-
- if (_overlay_texture)
- _overlay_texture->release();
-
- if (_mouse_texture)
- _mouse_texture->release();
-
- OpenGL::ContextGL::destroy();
-
- JNI::deinitSurface();
-}
-
-void AndroidGraphicsManager::updateScreen() {
- //ENTER();
-
- GLTHREADCHECK;
-
- if (!JNI::haveSurface())
- return;
-
- if (_game_pbuf) {
- int pitch = _game_texture->width() * _game_texture->getPixelFormat().bytesPerPixel;
- _game_texture->updateBuffer(0, 0, _game_texture->width(), _game_texture->height(),
- _game_pbuf.getRawBuffer(), pitch);
- }
-
- if (!_force_redraw &&
- !_game_texture->dirty() &&
- !_overlay_texture->dirty() &&
- !_mouse_texture->dirty())
- return;
-
- _force_redraw = false;
-
- if (_frame_buffer) {
- _frame_buffer->detach();
- glViewport(0,0, JNI::egl_surface_width, JNI::egl_surface_height);
- }
-
- // clear pointer leftovers in dead areas
- clearScreen(kClear);
-
- _game_texture->drawTextureRect();
- if (!_show_overlay) {
- glEnable(GL_BLEND);
- dynamic_cast<OSystem_Android *>(g_system)->getTouchControls()->draw();
- }
-
- int cs = _mouse_targetscale;
-
- if (_show_overlay) {
- // ugly, but the modern theme sets a wacko factor, only god knows why
- cs = 1;
-
- GLCALL(_overlay_texture->drawTextureRect());
- }
-
- if (_show_mouse && !_mouse_texture->isEmpty()) {
- const Common::Point &mouse = g_system->getEventManager()->getMousePos();
- if (_show_overlay) {
- _mouse_texture->drawTexture(mouse.x * cs, mouse.y * cs, _mouse_texture->width(), _mouse_texture->height());
- }
- }
-
- if (!JNI::swapBuffers())
- LOGW("swapBuffers failed: 0x%x", glGetError());
-
- if (_frame_buffer)
- _frame_buffer->attach();
-}
-
-void AndroidGraphicsManager::displayMessageOnOSD(const Common::U32String &msg) {
- ENTER("%s", msg.encode().c_str());
-
- JNI::displayMessageOnOSD(msg);
-}
-
-bool AndroidGraphicsManager::notifyMousePosition(Common::Point &mouse) {
- clipMouse(mouse);
- setMousePosition(mouse.x, mouse.y);
- return true;
-}
-
-const OSystem::GraphicsMode *AndroidGraphicsManager::getSupportedGraphicsModes() const {
- static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
- { "default", "Default", 0 },
- { 0, 0, 0 },
- };
-
- return s_supportedGraphicsModes;
-}
-
-int AndroidGraphicsManager::getDefaultGraphicsMode() const {
- return 0;
-}
-
-bool AndroidGraphicsManager::setGraphicsMode(int mode, uint flags) {
- return true;
-}
-
-int AndroidGraphicsManager::getGraphicsMode() const {
- return _graphicsMode;
-}
-
-bool AndroidGraphicsManager::hasFeature(OSystem::Feature f) const {
- if (f == OSystem::kFeatureCursorPalette ||
- f == OSystem::kFeatureFullscreenMode ||
- f == OSystem::kFeatureAspectRatioCorrection) {
- return true;
- }
- return false;
-}
-
-void AndroidGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
- switch (f) {
- case OSystem::kFeatureCursorPalette:
- _use_mouse_palette = enable;
- if (!enable)
- disableCursorPalette();
- break;
- case OSystem::kFeatureFullscreenMode:
- _fullscreen = enable;
- updateScreenRect();
- break;
- case OSystem::kFeatureAspectRatioCorrection:
- _ar_correction = enable;
- updateScreenRect();
- break;
- default:
- break;
- }
-}
-
-bool AndroidGraphicsManager::getFeatureState(OSystem::Feature f) const {
- switch (f) {
- case OSystem::kFeatureCursorPalette:
- return _use_mouse_palette;
- case OSystem::kFeatureFullscreenMode:
- return _fullscreen;
- case OSystem::kFeatureAspectRatioCorrection:
- return _ar_correction;
- default:
- return false;
- }
-}
-
-void AndroidGraphicsManager::showOverlay() {
- ENTER();
-
- _show_overlay = true;
- _force_redraw = true;
-
- updateEventScale();
-
- warpMouse(_overlay_texture->width() / 2, _overlay_texture->height() / 2);
-
- GLCALL(glDisable(GL_SCISSOR_TEST));
-}
-
-void AndroidGraphicsManager::hideOverlay() {
- ENTER();
-
- _show_overlay = false;
-
- updateEventScale();
-
- warpMouse(_game_texture->width() / 2, _game_texture->height() / 2);
-
- // double buffered, flip twice
- clearScreen(kClearUpdate, 2);
-
- GLCALL(glEnable(GL_SCISSOR_TEST));
-}
-
-void AndroidGraphicsManager::clearOverlay() {
- ENTER();
-
- GLTHREADCHECK;
-
- _overlay_texture->fillBuffer(0);
-}
-
-void AndroidGraphicsManager::grabOverlay(Graphics::Surface &surface) const {
- GLTHREADCHECK;
-
- const Graphics::Surface *overlaySurface = _overlay_texture->surface_const();
-
- assert(surface.w >= overlaySurface->w);
- assert(surface.h >= overlaySurface->h);
- assert(surface.format.bytesPerPixel == sizeof(uint16));
- assert(overlaySurface->format.bytesPerPixel == sizeof(uint16));
-
- const byte *src = (const byte *)overlaySurface->getPixels();
- byte *dst = (byte *)surface.getPixels();
- Graphics::copyBlit(dst, src, surface.pitch, overlaySurface->pitch, surface.w, surface.h, sizeof(uint16));
-}
-
-void AndroidGraphicsManager::copyRectToOverlay(const void *buf, int pitch,
- int x, int y, int w, int h) {
- ENTER("%p, %d, %d, %d, %d, %d", buf, pitch, x, y, w, h);
-
- GLTHREADCHECK;
-
- _overlay_texture->updateBuffer(x, y, w, h, buf, pitch);
-}
-
-int16 AndroidGraphicsManager::getOverlayHeight() const {
- return _overlay_texture->height();
-}
-
-int16 AndroidGraphicsManager::getOverlayWidth() const {
- return _overlay_texture->width();
-}
-
-Graphics::PixelFormat AndroidGraphicsManager::getOverlayFormat() const {
- return _overlay_texture->getPixelFormat();
-}
-
-int16 AndroidGraphicsManager::getHeight() const {
- return _game_texture->height();
-}
-
-int16 AndroidGraphicsManager::getWidth() const {
- return _game_texture->width();
-}
-
-void AndroidGraphicsManager::setPalette(const byte *colors, uint start, uint num) {
- ENTER("%p, %u, %u", colors, start, num);
-
-#ifdef USE_RGB_COLOR
- assert(_game_texture->hasPalette());
-#endif
-
- GLTHREADCHECK;
-
- if (!_use_mouse_palette)
- setCursorPaletteInternal(colors, start, num);
-
- const Graphics::PixelFormat &pf = _game_texture->getPalettePixelFormat();
- byte *p = _game_texture->palette() + start * 2;
-
- for (uint i = 0; i < num; ++i, colors += 3, p += 2)
- WRITE_UINT16(p, pf.RGBToColor(colors[0], colors[1], colors[2]));
-}
-
-void AndroidGraphicsManager::grabPalette(byte *colors, uint start, uint num) const {
- ENTER("%p, %u, %u", colors, start, num);
-
-#ifdef USE_RGB_COLOR
- assert(_game_texture->hasPalette());
-#endif
-
- GLTHREADCHECK;
-
- const Graphics::PixelFormat &pf = _game_texture->getPalettePixelFormat();
- const byte *p = _game_texture->palette_const() + start * 2;
-
- for (uint i = 0; i < num; ++i, colors += 3, p += 2)
- pf.colorToRGB(READ_UINT16(p), colors[0], colors[1], colors[2]);
-}
-
-Graphics::Surface *AndroidGraphicsManager::lockScreen() {
- ENTER();
-
- GLTHREADCHECK;
-
- Graphics::Surface *surface = _game_texture->surface();
- assert(surface->getPixels());
-
- return surface;
-}
-
-void AndroidGraphicsManager::unlockScreen() {
- ENTER();
-
- GLTHREADCHECK;
-
- assert(_game_texture->dirty());
-}
-
-void AndroidGraphicsManager::fillScreen(uint32 col) {
- ENTER("%u", col);
-
- GLTHREADCHECK;
-
- _game_texture->fillBuffer(col);
-}
-
-void AndroidGraphicsManager::copyRectToScreen(const void *buf, int pitch,
- int x, int y, int w, int h) {
- ENTER("%p, %d, %d, %d, %d, %d", buf, pitch, x, y, w, h);
-
- GLTHREADCHECK;
-
- _game_texture->updateBuffer(x, y, w, h, buf, pitch);
-}
-
-void AndroidGraphicsManager::initSize(uint width, uint height,
- const Graphics::PixelFormat *format) {
- setupScreen(width, height, true, true);
-}
-
-void AndroidGraphicsManager::initSizeIntern(uint width, uint height,
- const Graphics::PixelFormat *format) {
- ENTER("%d, %d, %p", width, height, format);
-
- GLTHREADCHECK;
-
-#ifdef USE_RGB_COLOR
- initTexture(&_game_texture, width, height, format);
-#else
- _game_texture->allocBuffer(width, height);
-#endif
-#if USE_FORCED_GLES2
- _frame_buffer = new OpenGL::FrameBuffer(_game_texture->getTextureName(), _game_texture->width(), _game_texture->height(), _game_texture->texWidth(), _game_texture->texHeight());
- _frame_buffer->attach();
-#endif
-
- updateScreenRect();
- updateEventScale();
-
- // Don't know mouse size yet - it gets reallocated in
- // setMouseCursor. We need the palette allocated before
- // setMouseCursor however, so just take a guess at the desired
- // size (it's small).
- _mouse_texture_palette->allocBuffer(20, 20);
-
- clearScreen(kClear);
-}
-
-int AndroidGraphicsManager::getScreenChangeID() const {
- return _screenChangeID;
-}
-
-bool AndroidGraphicsManager::showMouse(bool visible) {
- ENTER("%d", visible);
-
- _show_mouse = visible;
-
- return true;
-}
-
-void AndroidGraphicsManager::warpMouse(int x, int y) {
- ENTER("%d, %d", x, y);
-
- Common::Event e;
-
- e.type = Common::EVENT_MOUSEMOVE;
- e.mouse.x = x;
- e.mouse.y = y;
-
- clipMouse(e.mouse);
-
- setMousePosition(e.mouse.x, e.mouse.y);
-
- dynamic_cast<OSystem_Android *>(g_system)->pushEvent(e);
-}
-
-void AndroidGraphicsManager::setMouseCursor(const void *buf, uint w, uint h,
- int hotspotX, int hotspotY,
- uint32 keycolor, bool dontScale,
- const Graphics::PixelFormat *format) {
- ENTER("%p, %u, %u, %d, %d, %u, %d, %p", buf, w, h, hotspotX, hotspotY,
- keycolor, dontScale, format);
-
- GLTHREADCHECK;
-
-#ifdef USE_RGB_COLOR
- if (format && format->bytesPerPixel > 1) {
- if (_mouse_texture != _mouse_texture_rgb) {
- LOGD("switching to rgb mouse cursor");
-
- assert(!_mouse_texture_rgb);
- _mouse_texture_rgb = new GLES5551Texture();
- _mouse_texture_rgb->setLinearFilter(_graphicsMode == 1);
- }
-
- _mouse_texture = _mouse_texture_rgb;
- } else {
- if (_mouse_texture != _mouse_texture_palette)
- LOGD("switching to paletted mouse cursor");
-
- _mouse_texture = _mouse_texture_palette;
-
- delete _mouse_texture_rgb;
- _mouse_texture_rgb = 0;
- }
-#endif
-
- _mouse_texture->allocBuffer(w, h);
-
- if (_mouse_texture == _mouse_texture_palette) {
- assert(keycolor < 256);
-
- byte *p = _mouse_texture_palette->palette() + _mouse_keycolor * 2;
- WRITE_UINT16(p, READ_UINT16(p) | 1);
-
- _mouse_keycolor = keycolor;
-
- p = _mouse_texture_palette->palette() + _mouse_keycolor * 2;
- WRITE_UINT16(p, READ_UINT16(p) & ~1);
- }
-
- if (w == 0 || h == 0)
- return;
-
- if (_mouse_texture == _mouse_texture_palette) {
- _mouse_texture->updateBuffer(0, 0, w, h, buf, w);
- } else {
- uint16 pitch = _mouse_texture->pitch();
-
- byte *tmp = new byte[pitch * h];
-
- // meh, a 16bit cursor without alpha bits... this is so silly
- if (!crossBlit(tmp, (const byte *)buf, pitch, w * 2, w, h,
- _mouse_texture->getPixelFormat(),
- *format)) {
- LOGE("crossblit failed");
-
- delete[] tmp;
-
- _mouse_texture->allocBuffer(0, 0);
-
- return;
- }
-
- 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 = 0;
-
- _mouse_texture->updateBuffer(0, 0, w, h, tmp, pitch);
-
- delete[] tmp;
- }
-
- _mouse_hotspot = Common::Point(hotspotX, hotspotY);
- // TODO: Adapt to the new "do not scale" cursor logic.
- _mouse_targetscale = 1;
-}
-
-void AndroidGraphicsManager::setCursorPaletteInternal(const byte *colors,
- uint start, uint num) {
- const Graphics::PixelFormat &pf =
- _mouse_texture_palette->getPalettePixelFormat();
- byte *p = _mouse_texture_palette->palette() + start * 2;
-
- for (uint i = 0; i < num; ++i, colors += 3, p += 2)
- 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);
-}
-
-void AndroidGraphicsManager::setCursorPalette(const byte *colors,
- uint start, uint num) {
- ENTER("%p, %u, %u", colors, start, num);
-
- GLTHREADCHECK;
-
- if (!_mouse_texture->hasPalette()) {
- LOGD("switching to paletted mouse cursor");
-
- _mouse_texture = _mouse_texture_palette;
-
- delete _mouse_texture_rgb;
- _mouse_texture_rgb = 0;
- }
-
- setCursorPaletteInternal(colors, start, num);
- _use_mouse_palette = true;
-}
-
-void AndroidGraphicsManager::disableCursorPalette() {
- // when disabling the cursor palette, and we're running a clut8 game,
- // it expects the game palette to be used for the cursor
- if (_game_texture->hasPalette()) {
- const byte *src = _game_texture->palette_const();
- byte *dst = _mouse_texture_palette->palette();
-
- const Graphics::PixelFormat &pf_src =
- _game_texture->getPalettePixelFormat();
- const Graphics::PixelFormat &pf_dst =
- _mouse_texture_palette->getPalettePixelFormat();
-
- uint8 r, g, b;
-
- for (uint i = 0; i < 256; ++i, src += 2, dst += 2) {
- pf_src.colorToRGB(READ_UINT16(src), r, g, b);
- WRITE_UINT16(dst, pf_dst.RGBToColor(r, g, b));
- }
-
- byte *p = _mouse_texture_palette->palette() + _mouse_keycolor * 2;
- WRITE_UINT16(p, READ_UINT16(p) & ~1);
- }
-}
-
-bool AndroidGraphicsManager::lockMouse(bool lock) {
- _show_mouse = lock;
- return true;
-}
-
-void AndroidGraphicsManager::setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d) {
- setupScreen(screenW, screenH, fullscreen, accel3d, true);
-}
-
-void AndroidGraphicsManager::setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d, bool isGame) {
- _opengl = accel3d;
- initViewport();
-
- if (_opengl) {
- // resize game texture
- initSizeIntern(screenW, screenH, 0);
- if (isGame)
- _game_texture->setGameTexture();
- // format is not used by the gfx_opengl driver, use fake format
- _game_pbuf.set(Graphics::PixelFormat(), 0);
-
- } else {
- Graphics::PixelFormat format = GLES565Texture::pixelFormat();
- initSizeIntern(screenW, screenH, &format);
- // as there is no support for the texture surface's lock/unlock mechanism in gfx_tinygl/...
- // do not use _game_texture->surface()->pixels directly
- _game_pbuf.create(_game_texture->getPixelFormat(),
- _game_texture->width() * _game_texture->height(), DisposeAfterUse::YES);
- }
-}
-
-void AndroidGraphicsManager::clipMouse(Common::Point &p) const {
- const GLESBaseTexture *tex = getActiveTexture();
-
- p.x = CLIP(p.x, tex->getDrawRect().left, tex->getDrawRect().right);
- p.y = CLIP(p.y, tex->getDrawRect().top, tex->getDrawRect().bottom);
-}
-
-#ifdef USE_RGB_COLOR
-Graphics::PixelFormat AndroidGraphicsManager::getScreenFormat() const {
- return _game_texture->getPixelFormat();
-}
-
-Common::List<Graphics::PixelFormat> AndroidGraphicsManager::getSupportedFormats() const {
- Common::List<Graphics::PixelFormat> res;
- res.push_back(GLES565Texture::pixelFormat());
- res.push_back(GLES5551Texture::pixelFormat());
- res.push_back(GLES4444Texture::pixelFormat());
- res.push_back(Graphics::PixelFormat::createFormatCLUT8());
-
- return res;
-}
-#endif
-
-void AndroidGraphicsManager::updateScreenRect() {
- Common::Rect rect(0, 0, JNI::egl_surface_width, JNI::egl_surface_height);
-
- _overlay_texture->setDrawRect(rect);
-
- uint16 w = _game_texture->width();
- uint16 h = _game_texture->height();
-
- if (w && h && _ar_correction) {
-
- float dpi[2];
- JNI::getDPI(dpi);
-
- float screen_ar;
- if (dpi[0] != 0.0 && dpi[1] != 0.0) {
- // horizontal orientation
- screen_ar = (dpi[1] * JNI::egl_surface_width) /
- (dpi[0] * JNI::egl_surface_height);
- } else {
- screen_ar = float(JNI::egl_surface_width) / float(JNI::egl_surface_height);
- }
-
- float game_ar = float(w) / float(h);
-
- if (screen_ar > game_ar) {
- rect.setWidth(round(JNI::egl_surface_height * game_ar));
- rect.moveTo((JNI::egl_surface_width - rect.width()) / 2, 0);
- } else {
- rect.setHeight(round(JNI::egl_surface_width / game_ar));
- rect.moveTo((JNI::egl_surface_height - rect.height()) / 2, 0);
- }
- }
-
- _game_texture->setDrawRect(rect);
-}
-
-const GLESBaseTexture *AndroidGraphicsManager::getActiveTexture() const {
- if (_show_overlay)
- return _overlay_texture;
- else
- return _game_texture;
-}
-
-void AndroidGraphicsManager::initOverlay() {
- // minimum of 320x200
- // (surface can get smaller when opening the virtual keyboard on *QVGA*)
- int overlay_width = MAX(JNI::egl_surface_width, 320);
- int overlay_height = MAX(JNI::egl_surface_height, 200);
-
- // the 'normal' theme layout uses a max height of 400 pixels. if the
- // surface is too big we use only a quarter of the size so that the widgets
- // don't get too small. if the surface height has less than 800 pixels, this
- // enforces the 'lowres' layout, which will be scaled back up by factor 2x,
- // but this looks way better than the 'normal' layout scaled by some
- // calculated factors
-// while (overlay_height > 480) {
-// overlay_width /= 2;
-// overlay_height /= 2;
-// }
-
- LOGI("overlay size is %ux%u", overlay_width, overlay_height);
-
- _overlay_texture->allocBuffer(overlay_width, overlay_height);
- _overlay_texture->setDrawRect(0, 0,
- JNI::egl_surface_width, JNI::egl_surface_height);
-}
-
-void AndroidGraphicsManager::initViewport() {
- LOGD("initializing viewport");
-
- assert(JNI::haveSurface());
-
- GLCALL(glDisable(GL_CULL_FACE));
- GLCALL(glDisable(GL_DEPTH_TEST));
-
- GLCALL(glEnable(GL_BLEND));
- GLCALL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
-
- GLCALL(glViewport(0, 0, JNI::egl_surface_width, JNI::egl_surface_height));
- LOGD("viewport size: %dx%d", JNI::egl_surface_width, JNI::egl_surface_height);
-}
-
-void AndroidGraphicsManager::updateEventScale() {
- dynamic_cast<OSystem_Android *>(g_system)->updateEventScale(getActiveTexture());
-}
-
-void AndroidGraphicsManager::clearScreen(FixupType type, byte count) {
- assert(count > 0);
-
- bool sm = _show_mouse;
- _show_mouse = false;
-
- GLCALL(glDisable(GL_SCISSOR_TEST));
-
- for (byte i = 0; i < count; ++i) {
- // clear screen
- GLCALL(glClearColor(0, 0, 0, 1 << 16));
- if (_opengl) {
- GLCALL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
- } else {
- GLCALL(glClear(GL_COLOR_BUFFER_BIT));
- }
-
- switch (type) {
- case kClear:
- break;
-
- case kClearSwap:
- JNI::swapBuffers();
- break;
-
- case kClearUpdate:
- _force_redraw = true;
- updateScreen();
- break;
- }
- }
-
- if (!_show_overlay)
- GLCALL(glEnable(GL_SCISSOR_TEST));
-
- _show_mouse = sm;
- _force_redraw = true;
-}
-
-#ifdef USE_RGB_COLOR
-void AndroidGraphicsManager::initTexture(GLESBaseTexture **texture,
- uint width, uint height,
- const Graphics::PixelFormat *format) {
- assert(texture);
- Graphics::PixelFormat format_clut8 =
- Graphics::PixelFormat::createFormatCLUT8();
- Graphics::PixelFormat format_current;
- Graphics::PixelFormat format_new;
-
- if (*texture)
- format_current = (*texture)->getPixelFormat();
- else
- format_current = Graphics::PixelFormat();
-
- if (format)
- format_new = *format;
- else
- format_new = format_clut8;
-
- if (format_current != format_new) {
- if (*texture)
- LOGD("switching pixel format from: %s",
- (*texture)->getPixelFormat().toString().c_str());
-
- delete *texture;
-
- if (format_new == GLES565Texture::pixelFormat())
- *texture = new GLES565Texture();
- else if (format_new == GLES5551Texture::pixelFormat())
- *texture = new GLES5551Texture();
- else if (format_new == GLES4444Texture::pixelFormat())
- *texture = new GLES4444Texture();
- else {
- // TODO what now?
- if (format_new != format_clut8)
- LOGE("unsupported pixel format: %s",
- format_new.toString().c_str());
-
- *texture = new GLESFakePalette565Texture;
- }
-
- LOGD("new pixel format: %s",
- (*texture)->getPixelFormat().toString().c_str());
- }
-
- (*texture)->allocBuffer(width, height);
-}
-#endif
-
-#endif
diff --git a/backends/platform/android3d/graphics.h b/backends/platform/android3d/graphics.h
deleted file mode 100644
index 8fa5c35178e..00000000000
--- a/backends/platform/android3d/graphics.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef ANDROID_GRAPHICS_H
-#define ANDROID_GRAPHICS_H
-
-#include "common/scummsys.h"
-#include "backends/graphics/graphics.h"
-#include "graphics/tinygl/pixelbuffer.h"
-
-class AndroidGraphicsManager : public GraphicsManager {
-public:
- AndroidGraphicsManager();
- virtual ~AndroidGraphicsManager();
-
- void initSurface();
- void deinitSurface();
-
- void updateScreen() override;
-
- void displayMessageOnOSD(const Common::U32String &msg);
-
- bool notifyMousePosition(Common::Point &mouse);
- Common::Point getMousePosition() { return Common::Point(_cursorX, _cursorY); }
- void setMousePosition(int x, int y) { _cursorX = x; _cursorY = y; }
-
- virtual void beginGFXTransaction() {}
- virtual OSystem::TransactionError endGFXTransaction() { return OSystem::kTransactionSuccess; }
-
- const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
- int getDefaultGraphicsMode() const override;
- bool setGraphicsMode(int mode, uint flags = OSystem::kGfxModeNoFlags) override;
- int getGraphicsMode() const override;
-
- bool hasFeature(OSystem::Feature f) const override;
- void setFeatureState(OSystem::Feature f, bool enable) override;
- bool getFeatureState(OSystem::Feature f) const override;
-
- void showOverlay() override;
- void hideOverlay() override;
- void clearOverlay() override;
- void grabOverlay(Graphics::Surface &surface) const override;
- virtual void copyRectToOverlay(const void *buf, int pitch,
- int x, int y, int w, int h) override;
- int16 getOverlayHeight() const override;
- int16 getOverlayWidth() const override;
- Graphics::PixelFormat getOverlayFormat() const override;
- bool isOverlayVisible() const override { return _show_overlay; }
-
- int16 getHeight() const override;
- int16 getWidth() const override;
-
- // PaletteManager API
- void setPalette(const byte *colors, uint start, uint num) override;
- void grabPalette(byte *colors, uint start, uint num) const override;
- virtual void copyRectToScreen(const void *buf, int pitch, int x, int y,
- int w, int h) override;
- Graphics::Surface *lockScreen() override;
- void unlockScreen() override;
- virtual void fillScreen(uint32 col);
-
- virtual void setShakePos(int shakeXOffset, int shakeYOffset) {};
- virtual void setFocusRectangle(const Common::Rect& rect) {}
- virtual void clearFocusRectangle() {}
-
- virtual void initSize(uint width, uint height,
- const Graphics::PixelFormat *format) override;
- int getScreenChangeID() const override;
-
- bool showMouse(bool visible) override;
- void warpMouse(int x, int y) override;
- bool lockMouse(bool lock) override;
- virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX,
- int hotspotY, uint32 keycolor,
- bool dontScale,
- const Graphics::PixelFormat *format) override;
- void setCursorPalette(const byte *colors, uint start, uint num) override;
-
-
- void setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d);
-
- void setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d, bool isGame);
- void updateScreenRect();
- const GLESBaseTexture *getActiveTexture() const;
- void clipMouse(Common::Point &p) const;
-
-#ifdef USE_RGB_COLOR
- Graphics::PixelFormat getScreenFormat() const override;
- Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
-#endif
-
-protected:
- void setSystemMousePosition(int x, int y) {}
-
- bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format);
-
- void refreshScreen();
-
-private:
- void setCursorPaletteInternal(const byte *colors, uint start, uint num);
- void disableCursorPalette();
- void initOverlay();
- void initViewport();
- void updateEventScale();
- void initSizeIntern(uint width, uint height, const Graphics::PixelFormat *format);
-
- enum FixupType {
- kClear = 0, // glClear
- kClearSwap, // glClear + swapBuffers
- kClearUpdate // glClear + updateScreen
- };
-
- void clearScreen(FixupType type, byte count = 1);
-#ifdef USE_RGB_COLOR
- void initTexture(GLESBaseTexture **texture, uint width, uint height,
- const Graphics::PixelFormat *format);
-#endif
-
-private:
- int _screenChangeID;
- int _graphicsMode;
- bool _opengl;
- bool _fullscreen;
- bool _ar_correction;
- bool _force_redraw;
-
- // Game layer
- GLESBaseTexture *_game_texture;
- Graphics::PixelBuffer _game_pbuf;
- OpenGL::FrameBuffer *_frame_buffer;
-
- /**
- * The position of the mouse cursor, in window coordinates.
- */
- int _cursorX, _cursorY;
-
- // Overlay layer
- GLES4444Texture *_overlay_texture;
- bool _show_overlay;
-
- // Mouse layer
- GLESBaseTexture *_mouse_texture;
- GLESBaseTexture *_mouse_texture_palette;
- GLES5551Texture *_mouse_texture_rgb;
- Common::Point _mouse_hotspot;
- uint32 _mouse_keycolor;
- int _mouse_targetscale;
- bool _show_mouse;
- bool _use_mouse_palette;
-};
-
-#endif
diff --git a/backends/platform/android3d/jni-android.cpp b/backends/platform/android3d/jni-android.cpp
deleted file mode 100644
index 43e53908aa8..00000000000
--- a/backends/platform/android3d/jni-android.cpp
+++ /dev/null
@@ -1,2 +0,0 @@
-#define BACKEND_ANDROID3D
-#include "../android/jni-android.cpp"
diff --git a/backends/platform/android3d/jni-android.h b/backends/platform/android3d/jni-android.h
deleted file mode 100644
index 7db23636139..00000000000
--- a/backends/platform/android3d/jni-android.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../android/jni-android.h"
diff --git a/backends/platform/android3d/module.mk b/backends/platform/android3d/module.mk
deleted file mode 100644
index 11bbbff4f43..00000000000
--- a/backends/platform/android3d/module.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-MODULE := backends/platform/android3d
-
-MODULE_OBJS := \
- jni-android.o \
- texture.o \
- asset-archive.o \
- android.o \
- graphics.o \
- events.o \
- snprintf.o \
- touchcontrols.o
-
-# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
-MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
-OBJS := $(MODULE_OBJS) $(OBJS)
-MODULE_DIRS += $(sort $(dir $(MODULE_OBJS)))
diff --git a/backends/platform/android3d/org/residualvm/residualvm/EditableSurfaceView.java b/backends/platform/android3d/org/residualvm/residualvm/EditableSurfaceView.java
deleted file mode 100644
index 9a22fbd7f04..00000000000
--- a/backends/platform/android3d/org/residualvm/residualvm/EditableSurfaceView.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.residualvm.residualvm;
-
-import android.content.Context;
-import android.text.InputType;
-import android.util.AttributeSet;
-import android.view.SurfaceView;
-import android.view.inputmethod.BaseInputConnection;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputConnection;
-import android.view.inputmethod.InputMethodManager;
-
-public class EditableSurfaceView extends SurfaceView {
- public EditableSurfaceView(Context context) {
- super(context);
- }
-
- public EditableSurfaceView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public EditableSurfaceView(Context context, AttributeSet attrs,
- int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- public boolean onCheckIsTextEditor() {
- return false;
- }
-
- private class MyInputConnection extends BaseInputConnection {
- public MyInputConnection() {
- super(EditableSurfaceView.this, false);
- }
-
- @Override
- public boolean performEditorAction(int actionCode) {
- if (actionCode == EditorInfo.IME_ACTION_DONE) {
- InputMethodManager imm = (InputMethodManager)
- getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(getWindowToken(), 0);
- }
-
- // Sends enter key
- return super.performEditorAction(actionCode);
- }
- }
-
- @Override
- public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
- outAttrs.initialCapsMode = 0;
- outAttrs.initialSelEnd = outAttrs.initialSelStart = -1;
- outAttrs.inputType = (InputType.TYPE_CLASS_TEXT |
- InputType.TYPE_TEXT_VARIATION_NORMAL |
- InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
- outAttrs.imeOptions = (EditorInfo.IME_ACTION_DONE |
- EditorInfo.IME_FLAG_NO_EXTRACT_UI);
-
- return new MyInputConnection();
- }
-}
diff --git a/backends/platform/android3d/org/residualvm/residualvm/ExternalStorage.java b/backends/platform/android3d/org/residualvm/residualvm/ExternalStorage.java
deleted file mode 100644
index 40abe9895f2..00000000000
--- a/backends/platform/android3d/org/residualvm/residualvm/ExternalStorage.java
+++ /dev/null
@@ -1,496 +0,0 @@
-package org.residualvm.residualvm;
-
-import android.os.Environment;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Scanner;
-
-import android.text.TextUtils;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Locale;
-import java.util.regex.Pattern;
-import android.util.Log;
-import android.os.Build;
-
-
-/**
- * Contains helper methods to get list of available media
- */
-public class ExternalStorage {
- public static final String SD_CARD = "sdCard";
- public static final String EXTERNAL_SD_CARD = "externalSdCard";
- public static final String DATA_DIRECTORY = "ResidualVM data directory";
-
-
- // Find candidate removable sd card paths
- // Code reference: https://stackoverflow.com/a/54411385
- private static final String ANDROID_DIR = File.separator + "Android";
-
- private static String ancestor(File dir) {
- // getExternalFilesDir() and getExternalStorageDirectory()
- // may return something app-specific like:
- // /storage/sdcard1/Android/data/com.mybackuparchives.android/files
- // so we want the great-great-grandparent folder.
- if (dir == null) {
- return null;
- } else {
- String path = dir.getAbsolutePath();
- int i = path.indexOf(ANDROID_DIR);
- if (i == -1) {
- return path;
- } else {
- return path.substring(0, i);
- }
- }
- }
-
- private static Pattern
- /** Pattern that SD card device should match */
- devicePattern = Pattern.compile("/dev/(block/.*vold.*|fuse)|/mnt/.*"),
- /** Pattern that SD card mount path should match */
- pathPattern = Pattern.compile("/(mnt|storage|external_sd|extsd|_ExternalSD|Removable|.*MicroSD).*", Pattern.CASE_INSENSITIVE),
- /** Pattern that the mount path should not match.
- * 'emulated' indicates an internal storage location, so skip it.
- * 'asec' is an encrypted package file, decrypted and mounted as a directory. */
- pathAntiPattern = Pattern.compile(".*(/secure|/asec|/emulated).*"),
- /** These are expected fs types, including vfat. tmpfs is not OK.
- * fuse can be removable SD card (as on Moto E or Asus ZenPad), or can be internal (Huawei G610). */
- fsTypePattern = Pattern.compile(".*(fat|msdos|ntfs|ext[34]|fuse|sdcard|esdfs).*");
-
- /** Common paths for microSD card. **/
- private static String[] commonPaths = {
- // Some of these taken from
- // https://stackoverflow.com/questions/13976982/removable-storage-external-sdcard-path-by-manufacturers
- // These are roughly in order such that the earlier ones, if they exist, are more sure
- // to be removable storage than the later ones.
- "/mnt/Removable/MicroSD",
- "/storage/removable/sdcard1", // !< Sony Xperia Z1
- "/Removable/MicroSD", // Asus ZenPad C
- "/removable/microsd",
- "/external_sd", // Samsung
- "/_ExternalSD", // some LGs
- "/storage/extSdCard", // later Samsung
- "/storage/extsdcard", // Main filesystem is case-sensitive; FAT isn't.
- "/mnt/extsd", // some Chinese tablets, e.g. Zeki
- "/storage/sdcard1", // If this exists it's more likely than sdcard0 to be removable.
- "/mnt/extSdCard",
- "/mnt/sdcard/external_sd",
- "/mnt/external_sd",
- "/storage/external_SD",
- "/storage/ext_sd", // HTC One Max
- "/mnt/sdcard/_ExternalSD",
- "/mnt/sdcard-ext",
-
- "/sdcard2", // HTC One M8s
- "/sdcard1", // Sony Xperia Z
- "/mnt/media_rw/sdcard1", // 4.4.2 on CyanogenMod S3
- "/mnt/sdcard", // This can be built-in storage (non-removable).
- "/sdcard",
- "/storage/sdcard0",
- "/emmc",
- "/mnt/emmc",
- "/sdcard/sd",
- "/mnt/sdcard/bpemmctest",
- "/mnt/external1",
- "/data/sdext4",
- "/data/sdext3",
- "/data/sdext2",
- "/data/sdext",
- "/storage/microsd" //ASUS ZenFone 2
-
- // If we ever decide to support USB OTG storage, the following paths could be helpful:
- // An LG Nexus 5 apparently uses usb://1002/UsbStorage/ as a URI to access an SD
- // card over OTG cable. Other models, like Galaxy S5, use /storage/UsbDriveA
- // "/mnt/usb_storage",
- // "/mnt/UsbDriveA",
- // "/mnt/UsbDriveB",
- };
-
- /** Find path to removable SD card. */
- public static LinkedHashSet<File> findSdCardPath() {
- String[] mountFields;
- BufferedReader bufferedReader = null;
- String lineRead = null;
-
- /** Possible SD card paths */
- LinkedHashSet<File> candidatePaths = new LinkedHashSet<File>();
-
- /** Build a list of candidate paths, roughly in order of preference. That way if
- * we can't definitively detect removable storage, we at least can pick a more likely
- * candidate. */
-
- // Could do: use getExternalStorageState(File path), with and without an argument, when
- // available. With an argument is available since API level 21.
- // This may not be necessary, since we also check whether a directory exists and has contents,
- // which would fail if the external storage state is neither MOUNTED nor MOUNTED_READ_ONLY.
-
- // I moved hard-coded paths toward the end, but we need to make sure we put the ones in
- // backwards order that are returned by the OS. And make sure the iterators respect
- // the order!
- // This is because when multiple "external" storage paths are returned, it's always (in
- // experience, but not guaranteed by documentation) with internal/emulated storage
- // first, removable storage second.
-
- // Add value of environment variables as candidates, if set:
- // EXTERNAL_STORAGE, SECONDARY_STORAGE, EXTERNAL_SDCARD_STORAGE
- // But note they are *not* necessarily *removable* storage! Especially EXTERNAL_STORAGE.
- // And they are not documented (API) features. Typically useful only for old versions of Android.
-
- String val = System.getenv("SECONDARY_STORAGE");
- if (!TextUtils.isEmpty(val)) {
- addPath(val, candidatePaths);
- }
-
- val = System.getenv("EXTERNAL_SDCARD_STORAGE");
- if (!TextUtils.isEmpty(val)) {
- addPath(val, candidatePaths);
- }
-
- // Get listing of mounted devices with their properties.
- ArrayList<File> mountedPaths = new ArrayList<File>();
- try {
- // Note: Despite restricting some access to /proc (http://stackoverflow.com/a/38728738/423105),
- // Android 7.0 does *not* block access to /proc/mounts, according to our test on George's Alcatel A30 GSM.
- bufferedReader = new BufferedReader(new FileReader("/proc/mounts"));
-
- // Iterate over each line of the mounts listing.
- while ((lineRead = bufferedReader.readLine()) != null) {
-// Log.d(ResidualVM.LOG_TAG, "\nMounts line: " + lineRead);
- mountFields = lineRead.split(" ");
-
- // columns: device, mountpoint, fs type, options... Example:
- // /dev/block/vold/179:97 /storage/sdcard1 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
- String device = mountFields[0], path = mountFields[1], fsType = mountFields[2];
-
- // The device, path, and fs type must conform to expected patterns.
- // mtdblock is internal, I'm told.
- // Check for disqualifying patterns in the path.
- // If this mounts line fails our tests, skip it.
- if (!(devicePattern.matcher(device).matches()
- && pathPattern.matcher(path).matches()
- && fsTypePattern.matcher(fsType).matches())
- || device.contains("mtdblock")
- || pathAntiPattern.matcher(path).matches()
- ) {
- continue;
- }
-
- // TODO maybe: check options to make sure it's mounted RW?
- // The answer at http://stackoverflow.com/a/13648873/423105 does.
- // But it hasn't seemed to be necessary so far in my testing.
-
- // This line met the criteria so far, so add it to candidate list.
- addPath(path, mountedPaths);
- }
- } catch (IOException ignored) { }
- finally {
- if (bufferedReader != null) {
- try {
- bufferedReader.close();
- } catch (IOException ignored) { }
- }
- }
-
- // Append the paths from mount table to candidate list, in reverse order.
- if (!mountedPaths.isEmpty()) {
- // See https://stackoverflow.com/a/5374346/423105 on why the following is necessary.
- // Basically, .toArray() needs its parameter to know what type of array to return.
- File[] mountedPathsArray = mountedPaths.toArray(new File[mountedPaths.size()]);
- addAncestors(mountedPathsArray, candidatePaths);
- }
-
- // Add hard-coded known common paths to candidate list:
- addStrings(commonPaths, candidatePaths);
-
- // If the above doesn't work we could try the following other options, but in my experience they
- // haven't added anything helpful yet.
-
- // getExternalFilesDir() and getExternalStorageDirectory() typically something app-specific like
- // /storage/sdcard1/Android/data/com.mybackuparchives.android/files
- // so we want the great-great-grandparent folder.
-
- // This may be non-removable.
- Log.d(ResidualVM.LOG_TAG, "Environment.getExternalStorageDirectory():");
- addPath(ancestor(Environment.getExternalStorageDirectory()), candidatePaths);
-
- // TODO maybe: use getExternalStorageState(File path), with and without an argument, when
- // available. With an argument is available since API level 21.
- // This may not be necessary, since we also check whether a directory exists,
- // which would fail if the external storage state is neither MOUNTED nor MOUNTED_READ_ONLY.
-
- // A "public" external storage directory. But in my experience it doesn't add anything helpful.
- // Note that you can't pass null, or you'll get an NPE.
- final File publicDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
- // Take the parent, because we tend to get a path like /pathTo/sdCard/Music.
- addPath(publicDirectory.getParentFile().getAbsolutePath(), candidatePaths);
- // EXTERNAL_STORAGE: may not be removable.
- val = System.getenv("EXTERNAL_STORAGE");
- if (!TextUtils.isEmpty(val)) {
- addPath(val, candidatePaths);
- }
-
- if (candidatePaths.isEmpty()) {
- Log.w(ResidualVM.LOG_TAG, "No removable microSD card found.");
- return candidatePaths;
- } else {
- Log.i(ResidualVM.LOG_TAG, "\nFound potential removable storage locations: " + candidatePaths);
- }
-
- // Accept or eliminate candidate paths if we can determine whether they're removable storage.
- // In Lollipop and later, we can check isExternalStorageRemovable() status on each candidate.
- if (Build.VERSION.SDK_INT >= 21) {
- Iterator<File> itf = candidatePaths.iterator();
- while (itf.hasNext()) {
- File dir = itf.next();
- // handle illegalArgumentException if the path is not a valid storage device.
- try {
- if (Environment.isExternalStorageRemovable(dir)) {
- Log.i(ResidualVM.LOG_TAG, dir.getPath() + " is removable external storage");
- addPath(dir.getAbsolutePath(), candidatePaths);
- } else if (Environment.isExternalStorageEmulated(dir)) {
- Log.d(ResidualVM.LOG_TAG, "Removing emulated external storage dir " + dir);
- itf.remove();
- }
- } catch (IllegalArgumentException e) {
- Log.d(ResidualVM.LOG_TAG, "isRemovable(" + dir.getPath() + "): not a valid storage device.", e);
- }
- }
- }
-
- // Continue trying to accept or eliminate candidate paths based on whether they're removable storage.
- // On pre-Lollipop, we only have singular externalStorage. Check whether it's removable.
- if (Build.VERSION.SDK_INT >= 9) {
- File externalStorage = Environment.getExternalStorageDirectory();
- Log.d(ResidualVM.LOG_TAG, String.format(Locale.ROOT, "findSDCardPath: getExternalStorageDirectory = %s", externalStorage.getPath()));
- if (Environment.isExternalStorageRemovable()) {
- // Make sure this is a candidate.
- // TODO: Does this contains() work? Should we be canonicalizing paths before comparing?
- if (candidatePaths.contains(externalStorage)) {
- Log.d(ResidualVM.LOG_TAG, "Using externalStorage dir " + externalStorage);
- // return externalStorage;
- addPath(externalStorage.getAbsolutePath(), candidatePaths);
- }
- } else if (Build.VERSION.SDK_INT >= 11 && Environment.isExternalStorageEmulated()) {
- Log.d(ResidualVM.LOG_TAG, "Removing emulated external storage dir " + externalStorage);
- candidatePaths.remove(externalStorage);
- }
- }
-
- return candidatePaths;
- }
-
-
- /** Add each path to the collection. */
- private static void addStrings(String[] newPaths, LinkedHashSet<File> candidatePaths) {
- for (String path : newPaths) {
- addPath(path, candidatePaths);
- }
- }
-
- /** Add ancestor of each File to the collection. */
- private static void addAncestors(File[] files, LinkedHashSet<File> candidatePaths) {
- for (int i = files.length - 1; i >= 0; i--) {
- addPath(ancestor(files[i]), candidatePaths);
- }
- }
-
- /**
- * Add a new candidate directory path to our list, if it's not obviously wrong.
- * Supply path as either String or File object.
- * @param strNew path of directory to add
- */
- private static void addPath(String strNew, Collection<File> paths) {
- // If one of the arguments is null, fill it in from the other.
- if (strNew != null && !strNew.isEmpty()) {
- File fileNew = new File(strNew);
-
- if (!paths.contains(fileNew) &&
- // Check for paths known not to be removable SD card.
- // The antipattern check can be redundant, depending on where this is called from.
- !pathAntiPattern.matcher(strNew).matches()) {
-
- // Eliminate candidate if not a directory or not fully accessible.
- if (fileNew.exists() && fileNew.isDirectory() && fileNew.canExecute()) {
- Log.d(ResidualVM.LOG_TAG, " Adding candidate path " + strNew);
- paths.add(fileNew);
- } else {
- Log.d(ResidualVM.LOG_TAG, String.format(Locale.ROOT, " Invalid path %s: exists: %b isDir: %b canExec: %b canRead: %b",
- strNew, fileNew.exists(), fileNew.isDirectory(), fileNew.canExecute(), fileNew.canRead()));
- }
- }
- }
- }
-
-
-
- /**
- * @return True if the external storage is available. False otherwise.
- */
- public static boolean isAvailable() {
- String state = Environment.getExternalStorageState();
- if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
- return true;
- }
- return false;
- }
-
- public static String getSdCardPath() {
- return Environment.getExternalStorageDirectory().getPath() + "/";
- }
-
- /**
- * @return True if the external storage is writable. False otherwise.
- */
- public static boolean isWritable() {
- String state = Environment.getExternalStorageState();
- if (Environment.MEDIA_MOUNTED.equals(state)) {
- return true;
- }
- return false;
-
- }
-
- /**
- * @return list of locations available. Odd elements are names, even are paths
- */
- public static List<String> getAllStorageLocations() {
- List<String> map = new ArrayList<String>(20);
-
- List<String> mMounts = new ArrayList<String>(10);
- List<String> mVold = new ArrayList<String>(10);
- mMounts.add("/mnt/sdcard");
- mVold.add("/mnt/sdcard");
-
- try {
- File mountFile = new File("/proc/mounts");
- if (mountFile.exists()) {
- Scanner scanner = new Scanner(mountFile);
- while (scanner.hasNext()) {
- String line = scanner.nextLine();
- if (line.startsWith("/dev/block/vold/")) {
- String[] lineElements = line.split(" ");
- String element = lineElements[1];
-
- // don't add the default mount path
- // it's already in the list.
- if (!element.equals("/mnt/sdcard"))
- mMounts.add(element);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- try {
- File voldFile = new File("/system/etc/vold.fstab");
- if (voldFile.exists()){
- Scanner scanner = new Scanner(voldFile);
- while (scanner.hasNext()) {
- String line = scanner.nextLine();
- if (line.startsWith("dev_mount")) {
- String[] lineElements = line.split(" ");
- String element = lineElements[2];
-
- if (element.contains(":"))
- element = element.substring(0, element.indexOf(":"));
- if (!element.equals("/mnt/sdcard"))
- mVold.add(element);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
-
- for (int i = 0; i < mMounts.size(); i++) {
- String mount = mMounts.get(i);
- if (!mVold.contains(mount))
- mMounts.remove(i--);
- }
- mVold.clear();
-
- List<String> mountHash = new ArrayList<String>(10);
-
- for (String mount : mMounts) {
- File root = new File(mount);
- if (root.exists() && root.isDirectory() && root.canRead()) {
- File[] list = root.listFiles();
- String hash = "[";
- if (list != null) {
- for (File f : list) {
- hash += f.getName().hashCode() + ":" + f.length() + ", ";
- }
- }
- hash += "]";
- if (!mountHash.contains(hash)) {
- String key = SD_CARD + "_" + (map.size() / 2);
- if (map.size() == 0) {
- key = SD_CARD;
- } else if (map.size() == 2) {
- key = EXTERNAL_SD_CARD;
- }
- mountHash.add(hash);
- map.add(key);
- map.add(root.getAbsolutePath());
- }
- }
- }
-
- mMounts.clear();
-
- map.add(DATA_DIRECTORY);
- map.add(Environment.getDataDirectory().getAbsolutePath());
-
- // Now go through the external storage
- if (isAvailable()) { // we can read the External Storage...
- // Retrieve the primary External Storage:
- File primaryExternalStorage = Environment.getExternalStorageDirectory();
-
- //Retrieve the External Storages root directory:
- String externalStorageRootDir;
- int count = 0;
- if ((externalStorageRootDir = primaryExternalStorage.getParent()) == null) { // no parent...
- String key = primaryExternalStorage.getAbsolutePath();
- if (!map.contains(key)) {
- map.add(key); // Make name as directory
- map.add(key);
- }
- } else {
- File externalStorageRoot = new File(externalStorageRootDir);
- File[] files = externalStorageRoot.listFiles();
-
- if (files != null) {
- for (final File file : files) {
- if (file.isDirectory() && file.canRead() && (file.listFiles().length > 0)) { // it is a real directory (not a USB drive)...
- String key = file.getAbsolutePath();
- if (!map.contains(key)) {
- map.add(key); // Make name as directory
- map.add(key);
- }
- }
- }
- }
- }
- }
-
- // Get candidates for removable external storage
- LinkedHashSet<File> candidateRemovableSdCardPaths = findSdCardPath();
- for (final File file : candidateRemovableSdCardPaths) {
- String key = file.getAbsolutePath();
- if (!map.contains(key)) {
- map.add(key); // Make name as directory
- map.add(key);
- }
- }
-
- return map;
- }
-}
diff --git a/backends/platform/android3d/org/residualvm/residualvm/MouseHelper.java b/backends/platform/android3d/org/residualvm/residualvm/MouseHelper.java
deleted file mode 100644
index 46b9c5c7920..00000000000
--- a/backends/platform/android3d/org/residualvm/residualvm/MouseHelper.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package org.residualvm.residualvm;
-
-import android.view.InputDevice;
-import android.view.MotionEvent;
-import android.view.SurfaceView;
-import android.view.View;
-
-/**
- * Contains helper methods for mouse/hover events that were introduced in Android 4.0.
- */
-public class MouseHelper {
- private View.OnHoverListener _listener;
- private ResidualVM _residualvm;
- private long _rmbGuardTime;
- private boolean _rmbPressed;
- private boolean _lmbPressed;
- private boolean _mmbPressed;
-
- /**
- * Class initialization fails when this throws an exception.
- * Checking hover availability is done on static class initialization for Android 1.6 compatibility.
- */
- static {
- try {
- Class.forName("android.view.View$OnHoverListener");
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Calling this forces class initialization
- */
- public static void checkHoverAvailable() {}
-
- public MouseHelper(ResidualVM residualvm) {
- _residualvm = residualvm;
- _listener = createListener();
- }
-
- private View.OnHoverListener createListener() {
- return new View.OnHoverListener() {
- @Override
- public boolean onHover(View view, MotionEvent e) {
- return onMouseEvent(e, true);
- }
- };
- }
-
- public void attach(SurfaceView main_surface) {
- main_surface.setOnHoverListener(_listener);
- }
-
- public static boolean isMouse(MotionEvent e) {
- if (e == null) {
- return false;
- }
-
- InputDevice device = e.getDevice();
-
- if (device == null) {
- return false;
- }
-
- int sources = device.getSources();
-
- return ((sources & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) ||
- ((sources & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS) ||
- ((sources & InputDevice.SOURCE_TOUCHPAD) == InputDevice.SOURCE_TOUCHPAD);
- }
-
- public boolean onMouseEvent(MotionEvent e, boolean hover) {
- _residualvm.pushEvent(ResidualVMEvents.JE_MOUSE_MOVE, (int)e.getX(), (int)e.getY(), 0, 0, 0, 0);
-
- int buttonState = e.getButtonState();
-
- boolean lmbDown = (buttonState & MotionEvent.BUTTON_PRIMARY) == MotionEvent.BUTTON_PRIMARY;
-
- if (!hover && e.getAction() != MotionEvent.ACTION_UP && buttonState == 0) {
- // On some device types, ButtonState is 0 even when tapping on the touchpad or using the stylus on the screen etc.
- lmbDown = true;
- }
-
- if (lmbDown) {
- if (!_lmbPressed) {
- // left mouse button was pressed just now
- _residualvm.pushEvent(ResidualVMEvents.JE_LMB_DOWN, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0, 0);
- }
-
- _lmbPressed = true;
- } else {
- if (_lmbPressed) {
- // left mouse button was released just now
- _residualvm.pushEvent(ResidualVMEvents.JE_LMB_UP, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0, 0);
- }
-
- _lmbPressed = false;
- }
-
- boolean rmbDown = (buttonState & MotionEvent.BUTTON_SECONDARY) == MotionEvent.BUTTON_SECONDARY;
- if (rmbDown) {
- if (!_rmbPressed) {
- // right mouse button was pressed just now
- _residualvm.pushEvent(ResidualVMEvents.JE_RMB_DOWN, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0, 0);
- }
-
- _rmbPressed = true;
- } else {
- if (_rmbPressed) {
- // right mouse button was released just now
- _residualvm.pushEvent(ResidualVMEvents.JE_RMB_UP, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0, 0);
- _rmbGuardTime = System.currentTimeMillis();
- }
-
- _rmbPressed = false;
- }
-
- boolean mmbDown = (buttonState & MotionEvent.BUTTON_TERTIARY) == MotionEvent.BUTTON_TERTIARY;
- if (mmbDown) {
- if (!_mmbPressed) {
- // middle mouse button was pressed just now
- _residualvm.pushEvent(ResidualVMEvents.JE_MMB_DOWN, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0, 0);
- }
-
- _mmbPressed = true;
- } else {
- if (_mmbPressed) {
- // middle mouse button was released just now
- _residualvm.pushEvent(ResidualVMEvents.JE_MMB_UP, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0, 0);
- }
-
- _mmbPressed = false;
- }
-
- return true;
- }
-
- /**
- * Checks whether right mouse button is pressed or was pressed just previously. This is used to prevent sending
- * extra back key on right mouse click which is the default behaviour in some platforms.
- *
- * @return true if right mouse button is (or was in the last 200ms) pressed
- */
- public boolean getRmbGuard() {
- return _rmbPressed || _rmbGuardTime + 200 > System.currentTimeMillis();
- }
-}
diff --git a/backends/platform/android3d/org/residualvm/residualvm/ResidualVM.java b/backends/platform/android3d/org/residualvm/residualvm/ResidualVM.java
deleted file mode 100644
index 79a1bc5c43b..00000000000
--- a/backends/platform/android3d/org/residualvm/residualvm/ResidualVM.java
+++ /dev/null
@@ -1,468 +0,0 @@
-package org.residualvm.residualvm;
-
-import android.util.Log;
-import android.content.res.AssetManager;
-import android.view.SurfaceHolder;
-import android.media.AudioFormat;
-import android.media.AudioManager;
-import android.media.AudioTrack;
-
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.egl.EGL10;
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.egl.EGLContext;
-import javax.microedition.khronos.egl.EGLDisplay;
-import javax.microedition.khronos.egl.EGLSurface;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.util.LinkedHashMap;
-import java.util.List;
-
- at SuppressWarnings("JniMissingFunction")
-public abstract class ResidualVM implements SurfaceHolder.Callback, Runnable {
- final protected static String LOG_TAG = "ResidualVM";
- final private AssetManager _asset_manager;
- final private Object _sem_surface;
-
- private EGL10 _egl;
- private EGLDisplay _egl_display = EGL10.EGL_NO_DISPLAY;
- private EGLConfig _egl_config;
- private EGLContext _egl_context = EGL10.EGL_NO_CONTEXT;
- private EGLSurface _egl_surface = EGL10.EGL_NO_SURFACE;
-
- private SurfaceHolder _surface_holder;
- private AudioTrack _audio_track;
- private int _sample_rate = 0;
- private int _buffer_size = 0;
-
- private String[] _args;
-
- final private native void create(AssetManager asset_manager,
- EGL10 egl, EGLDisplay egl_display,
- AudioTrack audio_track,
- int sample_rate, int buffer_size);
- final private native void destroy();
- final private native void setSurface(int width, int height);
- final private native int main(String[] args);
-
- // pause the engine and all native threads
- final public native void setPause(boolean pause);
- // Feed an event to ResidualVM. Safe to call from other threads.
- final public native void pushEvent(int type, int arg1, int arg2, int arg3,
- int arg4, int arg5, int arg6);
-
- final public native String getNativeVersionInfo();
-
- // Callbacks from C++ peer instance
- abstract protected void getDPI(float[] values);
- abstract protected void displayMessageOnOSD(String msg);
- abstract protected void openUrl(String url);
- abstract protected boolean hasTextInClipboard();
- abstract protected String getTextFromClipboard();
- abstract protected boolean setTextInClipboard(String text);
- abstract protected boolean isConnectionLimited();
- abstract protected void setWindowCaption(String caption);
- abstract protected void showVirtualKeyboard(boolean enable);
- abstract protected void showKeyboardControl(boolean enable);
- abstract protected String[] getSysArchives();
- abstract protected String[] getAllStorageLocations();
-
- public ResidualVM(AssetManager asset_manager, SurfaceHolder holder) {
- _asset_manager = asset_manager;
- _sem_surface = new Object();
-
- holder.addCallback(this);
- }
-
- // SurfaceHolder callback
- final public void surfaceCreated(SurfaceHolder holder) {
- Log.d(LOG_TAG, "surfaceCreated");
-
- // no need to do anything, surfaceChanged() will be called in any case
- }
-
- // SurfaceHolder callback
- final public void surfaceChanged(SurfaceHolder holder, int format,
- int width, int height) {
- // the orientation may reset on standby mode and the theme manager
- // could assert when using a portrait resolution. so lets not do that.
- if (height > width) {
- Log.d(LOG_TAG, String.format("Ignoring surfaceChanged: %dx%d (%d)",
- width, height, format));
- return;
- }
-
- 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();
- }
- }
-
- // SurfaceHolder callback
- final public void surfaceDestroyed(SurfaceHolder holder) {
- Log.d(LOG_TAG, "surfaceDestroyed");
-
- synchronized(_sem_surface) {
- _surface_holder = null;
- _sem_surface.notifyAll();
- }
-
- // clear values for the native code
- setSurface(0, 0);
- }
-
- final public void setArgs(String[] args) {
- _args = args;
- }
-
- final public void run() {
- try {
- initAudio();
- initEGL();
-
- // wait for the surfaceChanged callback
- synchronized(_sem_surface) {
- while (_surface_holder == null)
- _sem_surface.wait();
- }
- } catch (Exception e) {
- deinitEGL();
- deinitAudio();
-
- throw new RuntimeException("Error preparing the ResidualVM thread", e);
- }
-
- create(_asset_manager, _egl, _egl_display,
- _audio_track, _sample_rate, _buffer_size);
-
- int res = main(_args);
-
- deinitEGL();
- deinitAudio();
-
- destroy();
- // On exit, tear everything down for a fresh restart next time.
- System.exit(res);
- }
-
- final private void initEGL() throws Exception {
- _egl = (EGL10)EGLContext.getEGL();
- _egl_display = _egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
-
- int[] version = new int[2];
- _egl.eglInitialize(_egl_display, version);
-
- int[] num_config = new int[1];
- int[] config_attrib_list = {
- EGL10.EGL_RENDERABLE_TYPE, 4, // ES2
- EGL10.EGL_RED_SIZE, 5,
- EGL10.EGL_GREEN_SIZE, 6,
- EGL10.EGL_BLUE_SIZE, 5,
- EGL10.EGL_NONE
- };
- _egl.eglChooseConfig(_egl_display, config_attrib_list, null, 0, num_config);
-
- final int numConfigs = num_config[0];
-
- if (numConfigs <= 0)
- throw new IllegalArgumentException("No EGL configs");
-
- EGLConfig[] configs = new EGLConfig[numConfigs];
- _egl.eglChooseConfig(_egl_display, config_attrib_list, configs, numConfigs, num_config);
-
- _egl_config = chooseEglConfig(configs);
- int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
- int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2,
- EGL10.EGL_NONE };
- _egl_context = _egl.eglCreateContext(_egl_display, _egl_config,
- EGL10.EGL_NO_CONTEXT, attrib_list);
-
- if (_egl_context == EGL10.EGL_NO_CONTEXT)
- throw new Exception(String.format("Failed to create context: 0x%x",
- _egl.eglGetError()));
- }
-
- // Callback from C++ peer instance
- final protected EGLSurface initSurface() throws Exception {
- _egl_surface = _egl.eglCreateWindowSurface(_egl_display, _egl_config,
- _surface_holder, null);
-
- if (_egl_surface == EGL10.EGL_NO_SURFACE)
- throw new Exception(String.format(
- "eglCreateWindowSurface failed: 0x%x", _egl.eglGetError()));
-
- _egl.eglMakeCurrent(_egl_display, _egl_surface, _egl_surface,
- _egl_context);
-
- GL10 gl = (GL10)_egl_context.getGL();
-
- Log.i(LOG_TAG, String.format("Using EGL %s (%s); GL %s/%s (%s)",
- _egl.eglQueryString(_egl_display, EGL10.EGL_VERSION),
- _egl.eglQueryString(_egl_display, EGL10.EGL_VENDOR),
- gl.glGetString(GL10.GL_VERSION),
- gl.glGetString(GL10.GL_RENDERER),
- gl.glGetString(GL10.GL_VENDOR)));
-
- return _egl_surface;
- }
-
- // Callback from C++ peer instance
- final protected void deinitSurface() {
- if (_egl_display != EGL10.EGL_NO_DISPLAY) {
- _egl.eglMakeCurrent(_egl_display, EGL10.EGL_NO_SURFACE,
- EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
-
- if (_egl_surface != EGL10.EGL_NO_SURFACE)
- _egl.eglDestroySurface(_egl_display, _egl_surface);
- }
-
- _egl_surface = EGL10.EGL_NO_SURFACE;
- }
-
- final private void deinitEGL() {
- if (_egl_display != EGL10.EGL_NO_DISPLAY) {
- _egl.eglMakeCurrent(_egl_display, EGL10.EGL_NO_SURFACE,
- EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
-
- if (_egl_surface != EGL10.EGL_NO_SURFACE)
- _egl.eglDestroySurface(_egl_display, _egl_surface);
-
- if (_egl_context != EGL10.EGL_NO_CONTEXT)
- _egl.eglDestroyContext(_egl_display, _egl_context);
-
- _egl.eglTerminate(_egl_display);
- }
-
- _egl_surface = EGL10.EGL_NO_SURFACE;
- _egl_context = EGL10.EGL_NO_CONTEXT;
- _egl_config = null;
- _egl_display = EGL10.EGL_NO_DISPLAY;
- _egl = null;
- }
-
- final private void initAudio() throws Exception {
- _sample_rate = AudioTrack.getNativeOutputSampleRate(
- AudioManager.STREAM_MUSIC);
- // Maximum supported resampler rate (see LinearRateConverter)
- if (_sample_rate >= 131072)
- _sample_rate = 131071;
- _buffer_size = AudioTrack.getMinBufferSize(_sample_rate,
- AudioFormat.CHANNEL_CONFIGURATION_STEREO,
- AudioFormat.ENCODING_PCM_16BIT);
-
- // ~50ms
- int buffer_size_want = (_sample_rate * 2 * 2 / 20) & ~1023;
-
- if (_buffer_size < buffer_size_want) {
- Log.w(LOG_TAG, String.format(
- "adjusting audio buffer size (was: %d)", _buffer_size));
-
- _buffer_size = buffer_size_want;
- }
-
- Log.i(LOG_TAG, String.format("Using %d bytes buffer for %dHz audio",
- _buffer_size, _sample_rate));
-
- _audio_track = new AudioTrack(AudioManager.STREAM_MUSIC,
- _sample_rate,
- AudioFormat.CHANNEL_CONFIGURATION_STEREO,
- AudioFormat.ENCODING_PCM_16BIT,
- _buffer_size,
- AudioTrack.MODE_STREAM);
-
- if (_audio_track.getState() != AudioTrack.STATE_INITIALIZED)
- throw new Exception(
- String.format("Error initializing AudioTrack: %d",
- _audio_track.getState()));
- }
-
- final private void deinitAudio() {
- if (_audio_track != null)
- _audio_track.stop();
-
- _audio_track = null;
- _buffer_size = 0;
- _sample_rate = 0;
- }
-
- private static final int[] s_eglAttribs = {
- EGL10.EGL_CONFIG_ID,
- EGL10.EGL_BUFFER_SIZE,
- EGL10.EGL_RED_SIZE,
- EGL10.EGL_GREEN_SIZE,
- EGL10.EGL_BLUE_SIZE,
- EGL10.EGL_ALPHA_SIZE,
- EGL10.EGL_CONFIG_CAVEAT,
- EGL10.EGL_DEPTH_SIZE,
- EGL10.EGL_LEVEL,
- EGL10.EGL_MAX_PBUFFER_WIDTH,
- EGL10.EGL_MAX_PBUFFER_HEIGHT,
- EGL10.EGL_MAX_PBUFFER_PIXELS,
- EGL10.EGL_NATIVE_RENDERABLE,
- EGL10.EGL_NATIVE_VISUAL_ID,
- EGL10.EGL_NATIVE_VISUAL_TYPE,
- EGL10.EGL_SAMPLE_BUFFERS,
- EGL10.EGL_SAMPLES,
- EGL10.EGL_STENCIL_SIZE,
- EGL10.EGL_SURFACE_TYPE,
- EGL10.EGL_TRANSPARENT_TYPE,
- EGL10.EGL_TRANSPARENT_RED_VALUE,
- EGL10.EGL_TRANSPARENT_GREEN_VALUE,
- EGL10.EGL_TRANSPARENT_BLUE_VALUE
- };
-
- final private class EglAttribs extends LinkedHashMap<Integer, Integer> {
- public EglAttribs(EGLConfig config) {
- super(s_eglAttribs.length);
-
- int[] value = new int[1];
-
- for (int i : s_eglAttribs) {
- _egl.eglGetConfigAttrib(_egl_display, config, i, value);
-
- put(i, value[0]);
- }
- }
-
- private int weightBits(int attr, int size) {
- final int value = get(attr);
-
- int score = 0;
-
- if (value == size || (size > 0 && value > size))
- score += 10;
-
- // penalize for wasted bits
- score -= value - size;
-
- return score;
- }
-
- public int weight() {
- int score = 10000;
-
- if (get(EGL10.EGL_CONFIG_CAVEAT) != EGL10.EGL_NONE)
- score -= 1000;
-
- // less MSAA is better
- score -= get(EGL10.EGL_SAMPLES) * 100;
-
- // Must be at least 565, but then smaller is better
- score += weightBits(EGL10.EGL_RED_SIZE, 5);
- score += weightBits(EGL10.EGL_GREEN_SIZE, 6);
- score += weightBits(EGL10.EGL_BLUE_SIZE, 5);
- score += weightBits(EGL10.EGL_ALPHA_SIZE, 0);
- score += weightBits(EGL10.EGL_DEPTH_SIZE, 0);
- score += weightBits(EGL10.EGL_STENCIL_SIZE, 0);
-
- return score;
- }
-
- public String toString() {
- String s;
-
- if (get(EGL10.EGL_ALPHA_SIZE) > 0)
- s = String.format("[%d] RGBA%d%d%d%d",
- get(EGL10.EGL_CONFIG_ID),
- get(EGL10.EGL_RED_SIZE),
- get(EGL10.EGL_GREEN_SIZE),
- get(EGL10.EGL_BLUE_SIZE),
- get(EGL10.EGL_ALPHA_SIZE));
- else
- s = String.format("[%d] RGB%d%d%d",
- get(EGL10.EGL_CONFIG_ID),
- get(EGL10.EGL_RED_SIZE),
- get(EGL10.EGL_GREEN_SIZE),
- get(EGL10.EGL_BLUE_SIZE));
-
- if (get(EGL10.EGL_DEPTH_SIZE) > 0)
- s += String.format(" D%d", get(EGL10.EGL_DEPTH_SIZE));
-
- if (get(EGL10.EGL_STENCIL_SIZE) > 0)
- s += String.format(" S%d", get(EGL10.EGL_STENCIL_SIZE));
-
- if (get(EGL10.EGL_SAMPLES) > 0)
- s += String.format(" MSAAx%d", get(EGL10.EGL_SAMPLES));
-
- if ((get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_WINDOW_BIT) > 0)
- s += " W";
- if ((get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_PBUFFER_BIT) > 0)
- s += " P";
- if ((get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_PIXMAP_BIT) > 0)
- s += " X";
-
- switch (get(EGL10.EGL_CONFIG_CAVEAT)) {
- case EGL10.EGL_NONE:
- break;
-
- case EGL10.EGL_SLOW_CONFIG:
- s += " SLOW";
- break;
-
- case EGL10.EGL_NON_CONFORMANT_CONFIG:
- s += " NON_CONFORMANT";
-
- default:
- s += String.format(" unknown CAVEAT 0x%x",
- get(EGL10.EGL_CONFIG_CAVEAT));
- }
-
- return s;
- }
- };
-
- final private EGLConfig chooseEglConfig(EGLConfig[] configs) {
- EGLConfig res = configs[0];
- int bestScore = -1;
-
- Log.d(LOG_TAG, "EGL configs:");
-
- for (EGLConfig config : configs) {
- EglAttribs attr = new EglAttribs(config);
-
- // must have
- if ((attr.get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_WINDOW_BIT) == 0)
- continue;
-
- int score = attr.weight();
-
- Log.d(LOG_TAG, String.format("%s (%d)", attr.toString(), score));
-
- if (score > bestScore) {
- res = config;
- bestScore = score;
- }
- }
-
- if (bestScore < 0)
- Log.e(LOG_TAG,
- "Unable to find an acceptable EGL config, expect badness.");
-
- Log.d(LOG_TAG, String.format("Chosen EGL config: %s",
- new EglAttribs(res).toString()));
-
- return res;
- }
-
- static {
- // For grabbing with gdb...
- final boolean sleep_for_debugger = false;
- if (sleep_for_debugger) {
- try {
- Thread.sleep(20 * 1000);
- } catch (InterruptedException e) {
- }
- }
-
- System.loadLibrary("scummvm");
- }
-}
diff --git a/backends/platform/android3d/org/residualvm/residualvm/ResidualVMActivity.java b/backends/platform/android3d/org/residualvm/residualvm/ResidualVMActivity.java
deleted file mode 100644
index 6940483d6f9..00000000000
--- a/backends/platform/android3d/org/residualvm/residualvm/ResidualVMActivity.java
+++ /dev/null
@@ -1,474 +0,0 @@
-package org.residualvm.residualvm;
-
-import android.Manifest;
-import android.content.pm.PackageManager;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.media.AudioManager;
-import android.net.Uri;
-import android.net.wifi.WifiManager;
-import android.net.wifi.WifiInfo;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Environment;
-import android.text.ClipboardManager;
-import android.support.annotation.NonNull;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.View;
-import android.view.KeyEvent;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.SurfaceView;
-import android.view.SurfaceHolder;
-import android.view.MotionEvent;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.ImageView;
-import android.widget.Toast;
-import android.widget.Button;
-import android.widget.HorizontalScrollView;
-import android.widget.ImageView;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-public class ResidualVMActivity extends Activity {
-
- /* Establish whether the hover events are available */
- private static boolean _hoverAvailable;
-
- private ClipboardManager _clipboard;
-
- /**
- * Id to identify an external storage read request.
- */
- private static final int MY_PERMISSIONS_REQUEST_READ_EXT_STORAGE = 100; // is an app-defined int constant. The callback method gets the result of the request.
-
- static {
- try {
- MouseHelper.checkHoverAvailable(); // this throws exception if we're on too old version
- _hoverAvailable = true;
- } catch (Throwable t) {
- _hoverAvailable = false;
- }
- }
-
- public View.OnClickListener keyboardBtnOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- runOnUiThread(new Runnable() {
- public void run() {
- toggleKeyboard();
- }
- });
- }
- };
-
- // ResidualVM specific code start
- // The callbacks below implement the action buttons for Grim and EMI.
- // TODO: Replace by a more generic "touch controls" mechanism
- private boolean isBtnsShowing = false;
-
- public View.OnClickListener optionsBtnOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
- if(!isBtnsShowing)
- ((HorizontalScrollView)findViewById(R.id.btns_scrollview)).setVisibility(View.VISIBLE);
- else
- ((HorizontalScrollView)findViewById(R.id.btns_scrollview)).setVisibility(View.GONE);
-
- isBtnsShowing = !isBtnsShowing;
-
- }
- };
-
- private void emulateKeyPress(int keyCode){
- _residualvm.pushEvent(ResidualVMEvents.JE_KEY, KeyEvent.ACTION_DOWN, keyCode, 0, 0, 0, 0);
- _residualvm.pushEvent(ResidualVMEvents.JE_KEY, KeyEvent.ACTION_UP, keyCode, 0, 0, 0, 0);
- }
-
- public View.OnClickListener menuBtnOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- emulateKeyPress(KeyEvent.KEYCODE_F1);
- }
- };
-
- public View.OnClickListener inventoryBtnOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- emulateKeyPress(KeyEvent.KEYCODE_I);
- }
- };
-
- public View.OnClickListener lookAtBtnOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- emulateKeyPress(KeyEvent.KEYCODE_E);
- }
- };
-
- public View.OnClickListener useBtnOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- emulateKeyPress(KeyEvent.KEYCODE_ENTER);
- }
- };
-
- public View.OnClickListener pickUpBtnOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- emulateKeyPress(KeyEvent.KEYCODE_P);
- }
- };
- // ResidualVM specific code end
-
-
- private class MyResidualVM extends ResidualVM {
-
- public MyResidualVM(SurfaceHolder holder) {
- super(ResidualVMActivity.this.getAssets(), holder);
- }
-
- @Override
- protected void getDPI(float[] values) {
- DisplayMetrics metrics = new DisplayMetrics();
- getWindowManager().getDefaultDisplay().getMetrics(metrics);
-
- values[0] = metrics.xdpi;
- values[1] = metrics.ydpi;
- }
-
- @Override
- protected void displayMessageOnOSD(final String msg) {
- if (msg != null) {
- runOnUiThread(new Runnable() {
- public void run() {
- Toast.makeText(ResidualVMActivity.this, msg, Toast.LENGTH_SHORT).show();
- }
- });
- }
- }
-
- @Override
- protected void openUrl(String url) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
- }
-
- @Override
- protected boolean hasTextInClipboard() {
- return _clipboard.hasText();
- }
-
- @Override
- protected String getTextFromClipboard() {
- CharSequence text = _clipboard.getText();
- if (text != null) {
- return text.toString();
- }
- return null;
- }
-
- @Override
- protected boolean setTextInClipboard(String text) {
- _clipboard.setText(text);
- return true;
- }
-
- @Override
- protected boolean isConnectionLimited() {
- WifiManager wifiMgr = (WifiManager)getSystemService(Context.WIFI_SERVICE);
- if (wifiMgr != null && wifiMgr.isWifiEnabled()) {
- WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
- return (wifiInfo == null || wifiInfo.getNetworkId() == -1); //WiFi is on, but it's not connected to any network
- }
- return true;
- }
-
- @Override
- protected void setWindowCaption(final String caption) {
- runOnUiThread(new Runnable() {
- public void run() {
- setTitle(caption);
- }
- });
- }
-
- @Override
- protected void showVirtualKeyboard(final boolean enable) {
- runOnUiThread(new Runnable() {
- public void run() {
- showKeyboard(enable);
- }
- });
- }
-
- @Override
- protected void showKeyboardControl(final boolean enable) {
- runOnUiThread(new Runnable() {
- public void run() {
- showKeyboardView(enable);
- }
- });
- }
-
- @Override
- protected String[] getSysArchives() {
- return new String[0];
- }
-
- @Override
- protected String[] getAllStorageLocations() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
- && checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
- ) {
- requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXT_STORAGE);
- } else {
- return _externalStorage.getAllStorageLocations().toArray(new String[0]);
- }
- return new String[0]; // an array of zero length
- }
-
- }
-
- private MyResidualVM _residualvm;
- private ResidualVMEvents _events;
- private MouseHelper _mouseHelper;
- private Thread _residualvm_thread;
- private ExternalStorage _externalStorage;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setVolumeControlStream(AudioManager.STREAM_MUSIC);
-
- setContentView(R.layout.main);
- takeKeyEvents(true);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
- && checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
- ) {
- requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXT_STORAGE);
- }
-
- // This is a common enough error that we should warn about it
- // explicitly.
- if (!Environment.getExternalStorageDirectory().canRead()) {
- new AlertDialog.Builder(this)
- .setTitle(R.string.no_sdcard_title)
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setMessage(R.string.no_sdcard)
- .setNegativeButton(R.string.quit,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int which) {
- finish();
- }
- })
- .show();
-
- return;
- }
-
- SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface);
-
- main_surface.requestFocus();
-
- getFilesDir().mkdirs();
-
- // Store savegames on external storage if we can, which means they're
- // world-readable and don't get deleted on uninstall.
- String savePath = Environment.getExternalStorageDirectory() + "/ResidualVM/Saves/";
- File saveDir = new File(savePath);
- saveDir.mkdirs();
- if (!saveDir.isDirectory()) {
- // If it doesn't work, resort to the internal app path.
- savePath = getDir("saves", Context.MODE_PRIVATE).getPath();
- }
-
- _clipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
-
- // Start ResidualVM
- _residualvm = new MyResidualVM(main_surface.getHolder());
-
- _residualvm.setArgs(new String[] {
- "ResidualVM",
- "--config=" + getFileStreamPath("residualvmrc").getPath(),
- "--path=" + Environment.getExternalStorageDirectory().getPath(),
- "--gui-theme=residualvm",
- "--savepath=" + savePath
- });
-
- Log.d(ResidualVM.LOG_TAG, "Hover available: " + _hoverAvailable);
- if (_hoverAvailable) {
- _mouseHelper = new MouseHelper(_residualvm);
- _mouseHelper.attach(main_surface);
- }
-
- _events = new ResidualVMEvents(this, _residualvm, _mouseHelper);
-
- // On screen button listener
- ((ImageView)findViewById(R.id.show_keyboard)).setOnClickListener(keyboardBtnOnClickListener);
- // ResidualVM specific code start
- ((ImageView)findViewById(R.id.options)).setOnClickListener(optionsBtnOnClickListener);
- ((Button)findViewById(R.id.menu_btn)).setOnClickListener(menuBtnOnClickListener);
- ((Button)findViewById(R.id.inventory_btn)).setOnClickListener(inventoryBtnOnClickListener);
- ((Button)findViewById(R.id.use_btn)).setOnClickListener(useBtnOnClickListener);
- ((Button)findViewById(R.id.pick_up_btn)).setOnClickListener(pickUpBtnOnClickListener);
- ((Button)findViewById(R.id.look_at_btn)).setOnClickListener(lookAtBtnOnClickListener);
- // ResidualVM specific code end
-
- main_surface.setOnKeyListener(_events);
- main_surface.setOnTouchListener(_events);
-
- _residualvm_thread = new Thread(_residualvm, "ResidualVM");
- _residualvm_thread.start();
- }
-
- @Override
- public void onStart() {
- Log.d(ResidualVM.LOG_TAG, "onStart");
-
- super.onStart();
- }
-
- @Override
- public void onResume() {
- Log.d(ResidualVM.LOG_TAG, "onResume");
-
- super.onResume();
-
- if (_residualvm != null)
- _residualvm.setPause(false);
- showMouseCursor(false);
- }
-
- @Override
- public void onPause() {
- Log.d(ResidualVM.LOG_TAG, "onPause");
-
- super.onPause();
-
- if (_residualvm != null)
- _residualvm.setPause(true);
- showMouseCursor(true);
- }
-
- @Override
- public void onStop() {
- Log.d(ResidualVM.LOG_TAG, "onStop");
-
- super.onStop();
- }
-
- @Override
- public void onDestroy() {
- Log.d(ResidualVM.LOG_TAG, "onDestroy");
-
- super.onDestroy();
-
- if (_events != null) {
- _events.sendQuitEvent();
-
- try {
- // 1s timeout
- _residualvm_thread.join(1000);
- } catch (InterruptedException e) {
- Log.i(ResidualVM.LOG_TAG, "Error while joining ResidualVM thread", e);
- }
-
- _residualvm = null;
- }
- }
-
-
- @Override
- public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
- switch (requestCode) {
- case MY_PERMISSIONS_REQUEST_READ_EXT_STORAGE:
- // If request is cancelled, the result arrays are empty.
- if (grantResults.length > 0
- && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- // permission was granted
- Log.i(ResidualVM.LOG_TAG, "Read External Storage permission was granted at Runtime");
- } else {
- // permission denied! We won't be able to make use of functionality depending on this permission.
- Toast.makeText(this, "Until permission is granted, some storage locations may be inaccessible!", Toast.LENGTH_SHORT)
- .show();
- }
- break;
- default:
- break;
- }
- }
-
-
- @Override
- public boolean onTrackballEvent(MotionEvent e) {
- if (_events != null)
- return _events.onTrackballEvent(e);
-
- 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)
- getSystemService(INPUT_METHOD_SERVICE);
-
- if (show)
- imm.showSoftInput(main_surface, InputMethodManager.SHOW_IMPLICIT);
- else
- imm.hideSoftInputFromWindow(main_surface.getWindowToken(),
- InputMethodManager.HIDE_IMPLICIT_ONLY);
- }
-
- private void toggleKeyboard() {
- SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface);
- InputMethodManager imm = (InputMethodManager)
- getSystemService(INPUT_METHOD_SERVICE);
-
- imm.toggleSoftInputFromWindow(main_surface.getWindowToken(),
- InputMethodManager.SHOW_IMPLICIT,
- InputMethodManager.HIDE_IMPLICIT_ONLY);
- }
-
- private void showKeyboardView(boolean show) {
- ImageView keyboardBtn = (ImageView)findViewById(R.id.show_keyboard);
-
- if (show)
- keyboardBtn.setVisibility(View.VISIBLE);
- else
- keyboardBtn.setVisibility(View.GONE);
- }
-
- 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/android3d/org/residualvm/residualvm/ResidualVMEvents.java b/backends/platform/android3d/org/residualvm/residualvm/ResidualVMEvents.java
deleted file mode 100644
index bde2981307a..00000000000
--- a/backends/platform/android3d/org/residualvm/residualvm/ResidualVMEvents.java
+++ /dev/null
@@ -1,307 +0,0 @@
-package org.residualvm.residualvm;
-
-import android.os.Handler;
-import android.os.Message;
-import android.util.DisplayMetrics;
-import android.content.Context;
-import android.view.InputDevice;
-import android.view.KeyEvent;
-import android.view.KeyCharacterMap;
-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 ResidualVMEvents implements
- android.view.View.OnKeyListener,
- android.view.View.OnTouchListener,
- android.view.GestureDetector.OnGestureListener,
- android.view.GestureDetector.OnDoubleTapListener {
-
- public static final int JE_SYS_KEY = 0;
- public static final int JE_KEY = 1;
- public static final int JE_DPAD = 2;
- public static final int JE_DOWN = 3;
- public static final int JE_SCROLL = 4;
- public static final int JE_TAP = 5;
- public static final int JE_DOUBLE_TAP = 6;
- public static final int JE_MULTI = 7;
- public static final int JE_BALL = 8;
- public static final int JE_LMB_DOWN = 9;
- public static final int JE_LMB_UP = 10;
- 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_TOUCH = 18;
- public static final int JE_LONG = 19;
- public static final int JE_FLING = 20;
- public static final int JE_QUIT = 0x1000;
-
- final protected Context _context;
- final protected ResidualVM _residualvm;
- final protected GestureDetector _gd;
- final protected int _longPress;
- final protected MouseHelper _mouseHelper;
-
- public ResidualVMEvents(Context context, ResidualVM residualvm, MouseHelper mouseHelper) {
- _context = context;
- _residualvm = residualvm;
- _mouseHelper = mouseHelper;
-
- _gd = new GestureDetector(context, this);
- _gd.setOnDoubleTapListener(this);
- _gd.setIsLongpressEnabled(false);
-
- _longPress = ViewConfiguration.getLongPressTimeout();
- }
-
- final public void sendQuitEvent() {
- _residualvm.pushEvent(JE_QUIT, 0, 0, 0, 0, 0, 0);
- }
-
- public boolean onTrackballEvent(MotionEvent e) {
- _residualvm.pushEvent(JE_BALL, e.getAction(),
- (int)(e.getX() * e.getXPrecision() * 100),
- (int)(e.getY() * e.getYPrecision() * 100),
- 0, 0, 0);
- return true;
- }
-
- public boolean onGenericMotionEvent(MotionEvent e) {
- return false;
- }
-
- final static int MSG_MENU_LONG_PRESS = 1;
-
- final private Handler keyHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == MSG_MENU_LONG_PRESS) {
- InputMethodManager imm = (InputMethodManager)
- _context.getSystemService(Context.INPUT_METHOD_SERVICE);
-
- if (imm != null)
- imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
- }
- }
- };
-
- // OnKeyListener
- @Override
- final public boolean onKey(View v, int keyCode, KeyEvent e) {
- final int action = e.getAction();
-
- if (keyCode == 238) {
- // this (undocumented) event is sent when ACTION_HOVER_ENTER or ACTION_HOVER_EXIT occurs
- return false;
- }
-
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- if (action != KeyEvent.ACTION_UP) {
- // only send event from back button on up event, since down event is sent on right mouse click and
- // cannot be caught (thus rmb click would send escape key first)
- return true;
- }
-
- if (_mouseHelper != null) {
- if (_mouseHelper.getRmbGuard()) {
- // right mouse button was just clicked which sends an extra back button press
- return true;
- }
- }
- }
-
- if (e.isSystem()) {
- // filter what we handle
- switch (keyCode) {
- case KeyEvent.KEYCODE_BACK:
- case KeyEvent.KEYCODE_MENU:
- case KeyEvent.KEYCODE_CAMERA:
- case KeyEvent.KEYCODE_SEARCH:
- case KeyEvent.KEYCODE_MEDIA_PLAY:
- case KeyEvent.KEYCODE_MEDIA_PAUSE:
- break;
-
- default:
- return false;
- }
-
- // no repeats for system keys
- if (e.getRepeatCount() > 0)
- return false;
-
- // Have to reimplement hold-down-menu-brings-up-softkeybd
- // ourselves, since we are otherwise hijacking the menu key :(
- // See com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel()
- // for the usual Android implementation of this feature.
- if (keyCode == KeyEvent.KEYCODE_MENU) {
- final boolean fired =
- !keyHandler.hasMessages(MSG_MENU_LONG_PRESS);
-
- keyHandler.removeMessages(MSG_MENU_LONG_PRESS);
-
- if (action == KeyEvent.ACTION_DOWN) {
- keyHandler.sendMessageDelayed(keyHandler.obtainMessage(
- MSG_MENU_LONG_PRESS), _longPress);
- return true;
- }
-
- if (fired)
- return true;
-
- // only send up events of the menu button to the native side
- if (action != KeyEvent.ACTION_UP)
- return true;
- }
-
- _residualvm.pushEvent(JE_SYS_KEY, action, keyCode, 0, 0, 0, 0);
-
- return true;
- }
-
- // sequence of characters
- if (action == KeyEvent.ACTION_MULTIPLE &&
- keyCode == KeyEvent.KEYCODE_UNKNOWN) {
- final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId());
- final KeyEvent[] es = m.getEvents(e.getCharacters().toCharArray());
-
- if (es == null)
- return true;
-
- for (KeyEvent s : es) {
- _residualvm.pushEvent(JE_KEY, s.getAction(), s.getKeyCode(),
- s.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK,
- s.getMetaState(), s.getRepeatCount(), 0);
- }
-
- return true;
- }
-
- switch (keyCode) {
- case KeyEvent.KEYCODE_DPAD_UP:
- case KeyEvent.KEYCODE_DPAD_DOWN:
- case KeyEvent.KEYCODE_DPAD_LEFT:
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- case KeyEvent.KEYCODE_DPAD_CENTER:
- _residualvm.pushEvent(JE_DPAD, action, keyCode,
- (int)(e.getEventTime() - e.getDownTime()),
- e.getRepeatCount(), 0, 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:
- _residualvm.pushEvent(JE_GAMEPAD, action, keyCode,
- (int)(e.getEventTime() - e.getDownTime()),
- e.getRepeatCount(), 0, 0);
- return true;
- }
-
- _residualvm.pushEvent(JE_KEY, action, keyCode,
- e.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK,
- e.getMetaState(), e.getRepeatCount(), 0);
-
- return true;
- }
-
- // OnTouchListener
- @Override
- final public boolean onTouch(View v, MotionEvent e) {
- if (_mouseHelper != null) {
- boolean isMouse = MouseHelper.isMouse(e);
- if (isMouse) {
- // mouse button is pressed
- return _mouseHelper.onMouseEvent(e, false);
- }
- }
-
- final int action = e.getAction();
-
- // constants from APIv5:
- // (action & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_SHIFT
- final int pointer = (action & 0xff00) >> 8;
-
- if (pointer > 0) {
- _residualvm.pushEvent(JE_MULTI, pointer, action & 0xff, // ACTION_MASK
- (int)e.getX(), (int)e.getY(), 0, 0);
- return true;
- }
-
- return _gd.onTouchEvent(e);
- }
-
- // OnGestureListener
- @Override
- final public boolean onDown(MotionEvent e) {
- _residualvm.pushEvent(JE_DOWN, (int)e.getX(), (int)e.getY(), 0, 0, 0, 0);
- return true;
- }
-
- @Override
- final public boolean onFling(MotionEvent e1, MotionEvent e2,
- float velocityX, float velocityY) {
- return false;
- }
-
- @Override
- final public void onLongPress(MotionEvent e) {
- // disabled, interferes with drag&drop
- }
-
- @Override
- final public boolean onScroll(MotionEvent e1, MotionEvent e2,
- float distanceX, float distanceY) {
- _residualvm.pushEvent(JE_SCROLL, (int)e1.getX(), (int)e1.getY(),
- (int)e2.getX(), (int)e2.getY(), 0, 0);
-
- return true;
- }
-
- @Override
- final public void onShowPress(MotionEvent e) {
- }
-
- @Override
- final public boolean onSingleTapUp(MotionEvent e) {
- return false;
- }
-
- // OnDoubleTapListener
- @Override
- final public boolean onDoubleTap(MotionEvent e) {
- return false;
- }
-
- @Override
- final public boolean onDoubleTapEvent(MotionEvent e) {
- _residualvm.pushEvent(JE_DOUBLE_TAP, (int)e.getX(), (int)e.getY(),
- e.getAction(), 0, 0, 0);
-
- return true;
- }
-
- @Override
- final public boolean onSingleTapConfirmed(MotionEvent e) {
- _residualvm.pushEvent(JE_TAP, (int)e.getX(), (int)e.getY(),
- (int)(e.getEventTime() - e.getDownTime()), 0, 0, 0);
- return true;
- }
-
-}
diff --git a/backends/platform/android3d/portdefs.h b/backends/platform/android3d/portdefs.h
deleted file mode 100644
index 7a1402317f7..00000000000
--- a/backends/platform/android3d/portdefs.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "../android/portdefs.h"
-
diff --git a/backends/platform/android3d/snprintf.cpp b/backends/platform/android3d/snprintf.cpp
deleted file mode 100644
index c83afcc232a..00000000000
--- a/backends/platform/android3d/snprintf.cpp
+++ /dev/null
@@ -1,1322 +0,0 @@
-/*
- * Copyright (c) 1995 Patrick Powell.
- *
- * This code is based on code written by Patrick Powell <papowell at astart.com>.
- * It may be used for any purpose as long as this notice remains intact on all
- * source code distributions.
- */
-
-/*
- * Copyright (c) 2008 Holger Weiss.
- *
- * This version of the code is maintained by Holger Weiss <holger at jhweiss.de>.
- * My changes to the code may freely be used, modified and/or redistributed for
- * any purpose. It would be nice if additions and fixes to this file (including
- * trivial code cleanups) would be sent back in order to let me include them in
- * the version available at <http://www.jhweiss.de/software/snprintf.html>.
- * However, this is not a requirement for using or redistributing (possibly
- * modified) versions of this file, nor is leaving this notice intact mandatory.
- */
-
-/*
- * History
- *
- * 2008-01-20 Holger Weiss <holger at jhweiss.de> for C99-snprintf 1.1:
- *
- * Fixed the detection of infinite floating point values on IRIX (and
- * possibly other systems) and applied another few minor cleanups.
- *
- * 2008-01-06 Holger Weiss <holger at jhweiss.de> for C99-snprintf 1.0:
- *
- * Added a lot of new features, fixed many bugs, and incorporated various
- * improvements done by Andrew Tridgell <tridge at samba.org>, Russ Allbery
- * <rra at stanford.edu>, Hrvoje Niksic <hniksic at xemacs.org>, Damien Miller
- * <djm at mindrot.org>, and others for the Samba, INN, Wget, and OpenSSH
- * projects. The additions include: support the "e", "E", "g", "G", and
- * "F" conversion specifiers (and use conversion style "f" or "F" for the
- * still unsupported "a" and "A" specifiers); support the "hh", "ll", "j",
- * "t", and "z" length modifiers; support the "#" flag and the (non-C99)
- * "'" flag; use localeconv(3) (if available) to get both the current
- * locale's decimal point character and the separator between groups of
- * digits; fix the handling of various corner cases of field width and
- * precision specifications; fix various floating point conversion bugs;
- * handle infinite and NaN floating point values; don't attempt to write to
- * the output buffer (which may be NULL) if a size of zero was specified;
- * check for integer overflow of the field width, precision, and return
- * values and during the floating point conversion; use the OUTCHAR() macro
- * instead of a function for better performance; provide asprintf(3) and
- * vasprintf(3) functions; add new test cases. The replacement functions
- * have been renamed to use an "rpl_" prefix, the function calls in the
- * main project (and in this file) must be redefined accordingly for each
- * replacement function which is needed (by using Autoconf or other means).
- * Various other minor improvements have been applied and the coding style
- * was cleaned up for consistency.
- *
- * 2007-07-23 Holger Weiss <holger at jhweiss.de> for Mutt 1.5.13:
- *
- * C99 compliant snprintf(3) and vsnprintf(3) functions return the number
- * of characters that would have been written to a sufficiently sized
- * buffer (excluding the '\0'). The original code simply returned the
- * length of the resulting output string, so that's been fixed.
- *
- * 1998-03-05 Michael Elkins <me at mutt.org> for Mutt 0.90.8:
- *
- * The original code assumed that both snprintf(3) and vsnprintf(3) were
- * missing. Some systems only have snprintf(3) but not vsnprintf(3), so
- * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
- *
- * 1998-01-27 Thomas Roessler <roessler at does-not-exist.org> for Mutt 0.89i:
- *
- * The PGP code was using unsigned hexadecimal formats. Unfortunately,
- * unsigned formats simply didn't work.
- *
- * 1997-10-22 Brandon Long <blong at fiction.net> for Mutt 0.87.1:
- *
- * Ok, added some minimal floating point support, which means this probably
- * requires libm on most operating systems. Don't yet support the exponent
- * (e,E) and sigfig (g,G). Also, fmtint() was pretty badly broken, it just
- * wasn't being exercised in ways which showed it, so that's been fixed.
- * Also, formatted the code to Mutt conventions, and removed dead code left
- * over from the original. Also, there is now a builtin-test, run with:
- * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm && ./snprintf
- *
- * 2996-09-15 Brandon Long <blong at fiction.net> for Mutt 0.43:
- *
- * This was ugly. It is still ugly. I opted out of floating point
- * numbers, but the formatter understands just about everything from the
- * normal C string format, at least as far as I can tell from the Solaris
- * 2.5 printf(3S) man page.
- */
-
-/*
- * ToDo
- *
- * - Add wide character support.
- * - Add support for "%a" and "%A" conversions.
- * - Create test routines which predefine the expected results. Our test cases
- * usually expose bugs in system implementations rather than in ours :-)
- */
-
-/*
- * Usage
- *
- * 1) The following preprocessor macros should be defined to 1 if the feature or
- * file in question is available on the target system (by using Autoconf or
- * other means), though basic functionality should be available as long as
- * HAVE_STDARG_H and HAVE_STDLIB_H are defined correctly:
- *
- * HAVE_VSNPRINTF
- * HAVE_SNPRINTF
- * HAVE_VASPRINTF
- * HAVE_ASPRINTF
- * HAVE_STDARG_H
- * HAVE_STDDEF_H
- * HAVE_STDINT_H
- * HAVE_STDLIB_H
- * HAVE_FLOAT_H
- * HAVE_INTTYPES_H
- * HAVE_LOCALE_H
- * HAVE_LOCALECONV
- * HAVE_LCONV_DECIMAL_POINT
- * HAVE_LCONV_THOUSANDS_SEP
- * HAVE_LONG_DOUBLE
- * HAVE_LONG_LONG_INT
- * HAVE_UNSIGNED_LONG_LONG_INT
- * HAVE_INTMAX_T
- * HAVE_UINTMAX_T
- * HAVE_UINTPTR_T
- * HAVE_PTRDIFF_T
- * HAVE_VA_COPY
- * HAVE___VA_COPY
- *
- * 2) The calls to the functions which should be replaced must be redefined
- * throughout the project files (by using Autoconf or other means):
- *
- * #define vsnprintf rpl_vsnprintf
- * #define snprintf rpl_snprintf
- * #define vasprintf rpl_vasprintf
- * #define asprintf rpl_asprintf
- *
- * 3) The required replacement functions should be declared in some header file
- * included throughout the project files:
- *
- * #if HAVE_CONFIG_H
- * #include <config.h>
- * #endif
- * #if HAVE_STDARG_H
- * #include <stdarg.h>
- * #if !HAVE_VSNPRINTF
- * int rpl_vsnprintf(char *, size_t, const char *, va_list);
- * #endif
- * #if !HAVE_SNPRINTF
- * int rpl_snprintf(char *, size_t, const char *, ...);
- * #endif
- * #if !HAVE_VASPRINTF
- * int rpl_vasprintf(char **, const char *, va_list);
- * #endif
- * #if !HAVE_ASPRINTF
- * int rpl_asprintf(char **, const char *, ...);
- * #endif
- * #endif
- *
- * Autoconf macros for handling step 1 and step 2 are available at
- * <http://www.jhweiss.de/software/snprintf.html>.
- */
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#if defined(__ANDROID__)
-
-// Allow use of stuff in <time.h>
-#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
-
-// Disable printf override in common/forbidden.h to avoid
-// clashes with log.h from the Android SDK.
-// That header file uses
-// __attribute__ ((format(printf, 3, 4)))
-// which gets messed up by our override mechanism; this could
-// be avoided by either changing the Android SDK to use the equally
-// legal and valid
-// __attribute__ ((format(printf, 3, 4)))
-// or by refining our printf override to use a varadic macro
-// (which then wouldn't be portable, though).
-// Anyway, for now we just disable the printf override globally
-// for the Android port
-#define FORBIDDEN_SYMBOL_EXCEPTION_printf
-
-#include "backends/platform/android3d/portdefs.h"
-
-#include <errno.h> /* For ERANGE and errno. */
-#include <limits.h> /* For *_MAX. */
-#include <float.h> /* For *DBL_{MIN,MAX}_10_EXP. */
-
-#if HAVE_INTTYPES_H
-#include <inttypes.h> /* For intmax_t (if not defined in <stdint.h>). */
-#endif /* HAVE_INTTYPES_H */
-#if HAVE_LOCALE_H
-#include <locale.h> /* For localeconv(3). */
-#endif /* HAVE_LOCALE_H */
-#if HAVE_STDDEF_H
-#include <stddef.h> /* For ptrdiff_t. */
-#endif /* HAVE_STDDEF_H */
-#if HAVE_STDINT_H
-#include <stdint.h> /* For intmax_t. */
-#endif /* HAVE_STDINT_H */
-
-/* Support for unsigned long long int. We may also need ULLONG_MAX. */
-#ifndef ULONG_MAX /* We may need ULONG_MAX as a fallback. */
-#ifdef UINT_MAX
-#define ULONG_MAX UINT_MAX
-#else
-#define ULONG_MAX INT_MAX
-#endif /* defined(UINT_MAX) */
-#endif /* !defined(ULONG_MAX) */
-#ifdef ULLONG
-#undef ULLONG
-#endif /* defined(ULLONG) */
-#if HAVE_UNSIGNED_LONG_LONG_INT
-#define ULLONG unsigned long long int
-#ifndef ULLONG_MAX
-#define ULLONG_MAX ULONG_MAX
-#endif /* !defined(ULLONG_MAX) */
-#else
-#define ULLONG unsigned long int
-#ifdef ULLONG_MAX
-#undef ULLONG_MAX
-#endif /* defined(ULLONG_MAX) */
-#define ULLONG_MAX ULONG_MAX
-#endif /* HAVE_LONG_LONG_INT */
-
-/* Support for uintmax_t. We also need UINTMAX_MAX. */
-#ifdef UINTMAX_T
-#undef UINTMAX_T
-#endif /* defined(UINTMAX_T) */
-#if HAVE_UINTMAX_T || defined(uintmax_t)
-#define UINTMAX_T uintmax_t
-#ifndef UINTMAX_MAX
-#define UINTMAX_MAX ULLONG_MAX
-#endif /* !defined(UINTMAX_MAX) */
-#else
-#define UINTMAX_T ULLONG
-#ifdef UINTMAX_MAX
-#undef UINTMAX_MAX
-#endif /* defined(UINTMAX_MAX) */
-#define UINTMAX_MAX ULLONG_MAX
-#endif /* HAVE_UINTMAX_T || defined(uintmax_t) */
-
-/* Support for long double. */
-#ifndef LDOUBLE
-#if HAVE_LONG_DOUBLE
-#define LDOUBLE long double
-#define LDOUBLE_MIN_10_EXP LDBL_MIN_10_EXP
-#define LDOUBLE_MAX_10_EXP LDBL_MAX_10_EXP
-#else
-#define LDOUBLE double
-#define LDOUBLE_MIN_10_EXP DBL_MIN_10_EXP
-#define LDOUBLE_MAX_10_EXP DBL_MAX_10_EXP
-#endif /* HAVE_LONG_DOUBLE */
-#endif /* !defined(LDOUBLE) */
-
-/* Support for long long int. */
-#ifndef LLONG
-#if HAVE_LONG_LONG_INT
-#define LLONG long long int
-#else
-#define LLONG long int
-#endif /* HAVE_LONG_LONG_INT */
-#endif /* !defined(LLONG) */
-
-/* Support for intmax_t. */
-#ifndef INTMAX_T
-#if HAVE_INTMAX_T || defined(intmax_t)
-#define INTMAX_T intmax_t
-#else
-#define INTMAX_T LLONG
-#endif /* HAVE_INTMAX_T || defined(intmax_t) */
-#endif /* !defined(INTMAX_T) */
-
-/* Support for uintptr_t. */
-#ifndef UINTPTR_T
-#if HAVE_UINTPTR_T || defined(uintptr_t)
-#define UINTPTR_T uintptr_t
-#else
-#define UINTPTR_T unsigned long int
-#endif /* HAVE_UINTPTR_T || defined(uintptr_t) */
-#endif /* !defined(UINTPTR_T) */
-
-/* Support for ptrdiff_t. */
-#ifndef PTRDIFF_T
-#if HAVE_PTRDIFF_T || defined(ptrdiff_t)
-#define PTRDIFF_T ptrdiff_t
-#else
-#define PTRDIFF_T long int
-#endif /* HAVE_PTRDIFF_T || defined(ptrdiff_t) */
-#endif /* !defined(PTRDIFF_T) */
-
-/*
- * We need an unsigned integer type corresponding to ptrdiff_t (cf. C99:
- * 7.19.6.1, 7). However, we'll simply use PTRDIFF_T and convert it to an
- * unsigned type if necessary. This should work just fine in practice.
- */
-#ifndef UPTRDIFF_T
-#define UPTRDIFF_T PTRDIFF_T
-#endif /* !defined(UPTRDIFF_T) */
-
-/*
- * We need a signed integer type corresponding to size_t (cf. C99: 7.19.6.1, 7).
- * However, we'll simply use size_t and convert it to a signed type if
- * necessary. This should work just fine in practice.
- */
-#ifndef SSIZE_T
-#define SSIZE_T size_t
-#endif /* !defined(SSIZE_T) */
-
-
-/*
- * Buffer size to hold the octal string representation of UINT128_MAX without
- * nul-termination ("3777777777777777777777777777777777777777777").
- */
-#ifdef MAX_CONVERT_LENGTH
-#undef MAX_CONVERT_LENGTH
-#endif /* defined(MAX_CONVERT_LENGTH) */
-#define MAX_CONVERT_LENGTH 43
-
-/* Format read states. */
-#define PRINT_S_DEFAULT 0
-#define PRINT_S_FLAGS 1
-#define PRINT_S_WIDTH 2
-#define PRINT_S_DOT 3
-#define PRINT_S_PRECISION 4
-#define PRINT_S_MOD 5
-#define PRINT_S_CONV 6
-
-/* Format flags. */
-#define PRINT_F_MINUS (1 << 0)
-#define PRINT_F_PLUS (1 << 1)
-#define PRINT_F_SPACE (1 << 2)
-#define PRINT_F_NUM (1 << 3)
-#define PRINT_F_ZERO (1 << 4)
-#define PRINT_F_QUOTE (1 << 5)
-#define PRINT_F_UP (1 << 6)
-#define PRINT_F_UNSIGNED (1 << 7)
-#define PRINT_F_TYPE_G (1 << 8)
-#define PRINT_F_TYPE_E (1 << 9)
-
-/* Conversion flags. */
-#define PRINT_C_CHAR 1
-#define PRINT_C_SHORT 2
-#define PRINT_C_LONG 3
-#define PRINT_C_LLONG 4
-#define PRINT_C_LDOUBLE 5
-#define PRINT_C_SIZE 6
-#define PRINT_C_PTRDIFF 7
-#define PRINT_C_INTMAX 8
-
-#ifndef MAX
-#define MAX(x, y) ((x >= y) ? x : y)
-#endif /* !defined(MAX) */
-#ifndef CHARTOINT
-#define CHARTOINT(ch) (ch - '0')
-#endif /* !defined(CHARTOINT) */
-#ifndef ISDIGIT
-#define ISDIGIT(ch) ('0' <= (unsigned char)ch && (unsigned char)ch <= '9')
-#endif /* !defined(ISDIGIT) */
-#ifndef ISNAN
-#define ISNAN(x) (x != x)
-#endif /* !defined(ISNAN) */
-#ifndef ISINF
-#define ISINF(x) ((x < -1 || x > 1) && x + x == x)
-#endif /* !defined(ISINF) */
-
-#ifdef OUTCHAR
-#undef OUTCHAR
-#endif /* defined(OUTCHAR) */
-#define OUTCHAR(str, len, size, ch) \
-do { \
- if (len + 1 < size) \
- str[len] = ch; \
- (len)++; \
-} while (/* CONSTCOND */ 0)
-
-static void fmtstr(char *, size_t *, size_t, const char *, int, int, int);
-static void fmtint(char *, size_t *, size_t, INTMAX_T, int, int, int, int);
-static void fmtflt(char *, size_t *, size_t, LDOUBLE, int, int, int, int *);
-static void printsep(char *, size_t *, size_t);
-static int getnumsep(int);
-static int getexponent(LDOUBLE);
-static int convert(UINTMAX_T, char *, size_t, int, int);
-static UINTMAX_T cast(LDOUBLE);
-static UINTMAX_T myround(LDOUBLE);
-static LDOUBLE mypow10(int);
-
-//extern int errno;
-
-int rpl_vsnprintf(char *str, size_t size, const char *format, va_list args) {
- LDOUBLE fvalue;
- INTMAX_T value;
- unsigned char cvalue;
- const char *strvalue;
- INTMAX_T *intmaxptr;
- PTRDIFF_T *ptrdiffptr;
- SSIZE_T *sizeptr;
- LLONG *llongptr;
- long int *longptr;
- int *intptr;
- short int *shortptr;
- signed char *charptr;
- size_t len = 0;
- int overflow = 0;
- int base = 0;
- int cflags = 0;
- int flags = 0;
- int width = 0;
- int precision = -1;
- int state = PRINT_S_DEFAULT;
- char ch = *format++;
-
- /*
- * C99 says: "If `n' is zero, nothing is written, and `s' may be a null
- * pointer." (7.19.6.5, 2) We're forgiving and allow a NULL pointer
- * even if a size larger than zero was specified. At least NetBSD's
- * snprintf(3) does the same, as well as other versions of this file.
- * (Though some of these versions will write to a non-NULL buffer even
- * if a size of zero was specified, which violates the standard.)
- */
- if (str == NULL && size != 0)
- size = 0;
-
- while (ch != '\0')
- switch (state) {
- case PRINT_S_DEFAULT:
- if (ch == '%')
- state = PRINT_S_FLAGS;
- else
- OUTCHAR(str, len, size, ch);
- ch = *format++;
- break;
- case PRINT_S_FLAGS:
- switch (ch) {
- case '-':
- flags |= PRINT_F_MINUS;
- ch = *format++;
- break;
- case '+':
- flags |= PRINT_F_PLUS;
- ch = *format++;
- break;
- case ' ':
- flags |= PRINT_F_SPACE;
- ch = *format++;
- break;
- case '#':
- flags |= PRINT_F_NUM;
- ch = *format++;
- break;
- case '0':
- flags |= PRINT_F_ZERO;
- ch = *format++;
- break;
- case '\'': /* SUSv2 flag (not in C99). */
- flags |= PRINT_F_QUOTE;
- ch = *format++;
- break;
- default:
- state = PRINT_S_WIDTH;
- break;
- }
- break;
- case PRINT_S_WIDTH:
- if (ISDIGIT(ch)) {
- ch = CHARTOINT(ch);
- if (width > (INT_MAX - ch) / 10) {
- overflow = 1;
- goto out;
- }
- width = 10 * width + ch;
- ch = *format++;
- } else if (ch == '*') {
- /*
- * C99 says: "A negative field width argument is
- * taken as a `-' flag followed by a positive
- * field width." (7.19.6.1, 5)
- */
- if ((width = va_arg(args, int)) < 0) {
- flags |= PRINT_F_MINUS;
- width = -width;
- }
- ch = *format++;
- state = PRINT_S_DOT;
- } else
- state = PRINT_S_DOT;
- break;
- case PRINT_S_DOT:
- if (ch == '.') {
- state = PRINT_S_PRECISION;
- ch = *format++;
- } else
- state = PRINT_S_MOD;
- break;
- case PRINT_S_PRECISION:
- if (precision == -1)
- precision = 0;
- if (ISDIGIT(ch)) {
- ch = CHARTOINT(ch);
- if (precision > (INT_MAX - ch) / 10) {
- overflow = 1;
- goto out;
- }
- precision = 10 * precision + ch;
- ch = *format++;
- } else if (ch == '*') {
- /*
- * C99 says: "A negative precision argument is
- * taken as if the precision were omitted."
- * (7.19.6.1, 5)
- */
- if ((precision = va_arg(args, int)) < 0)
- precision = -1;
- ch = *format++;
- state = PRINT_S_MOD;
- } else
- state = PRINT_S_MOD;
- break;
- case PRINT_S_MOD:
- switch (ch) {
- case 'h':
- ch = *format++;
- if (ch == 'h') { /* It's a char. */
- ch = *format++;
- cflags = PRINT_C_CHAR;
- } else
- cflags = PRINT_C_SHORT;
- break;
- case 'l':
- ch = *format++;
- if (ch == 'l') { /* It's a long long. */
- ch = *format++;
- cflags = PRINT_C_LLONG;
- } else
- cflags = PRINT_C_LONG;
- break;
- case 'L':
- cflags = PRINT_C_LDOUBLE;
- ch = *format++;
- break;
- case 'j':
- cflags = PRINT_C_INTMAX;
- ch = *format++;
- break;
- case 't':
- cflags = PRINT_C_PTRDIFF;
- ch = *format++;
- break;
- case 'z':
- cflags = PRINT_C_SIZE;
- ch = *format++;
- break;
- }
- state = PRINT_S_CONV;
- break;
- case PRINT_S_CONV:
- switch (ch) {
- case 'd':
- /* FALLTHROUGH */
- case 'i':
- switch (cflags) {
- case PRINT_C_CHAR:
- value = (signed char)va_arg(args, int);
- break;
- case PRINT_C_SHORT:
- value = (short int)va_arg(args, int);
- break;
- case PRINT_C_LONG:
- value = va_arg(args, long int);
- break;
- case PRINT_C_LLONG:
- value = va_arg(args, LLONG);
- break;
- case PRINT_C_SIZE:
- value = va_arg(args, SSIZE_T);
- break;
- case PRINT_C_INTMAX:
- value = va_arg(args, INTMAX_T);
- break;
- case PRINT_C_PTRDIFF:
- value = va_arg(args, PTRDIFF_T);
- break;
- default:
- value = va_arg(args, int);
- break;
- }
- fmtint(str, &len, size, value, 10, width,
- precision, flags);
- break;
- case 'X':
- flags |= PRINT_F_UP;
- /* FALLTHROUGH */
- case 'x':
- base = 16;
- /* FALLTHROUGH */
- case 'o':
- if (base == 0)
- base = 8;
- /* FALLTHROUGH */
- case 'u':
- if (base == 0)
- base = 10;
- flags |= PRINT_F_UNSIGNED;
- switch (cflags) {
- case PRINT_C_CHAR:
- value = (unsigned char)va_arg(args,
- unsigned int);
- break;
- case PRINT_C_SHORT:
- value = (unsigned short int)va_arg(args,
- unsigned int);
- break;
- case PRINT_C_LONG:
- value = va_arg(args, unsigned long int);
- break;
- case PRINT_C_LLONG:
- value = va_arg(args, ULLONG);
- break;
- case PRINT_C_SIZE:
- value = va_arg(args, size_t);
- break;
- case PRINT_C_INTMAX:
- value = va_arg(args, UINTMAX_T);
- break;
- case PRINT_C_PTRDIFF:
- value = va_arg(args, UPTRDIFF_T);
- break;
- default:
- value = va_arg(args, unsigned int);
- break;
- }
- fmtint(str, &len, size, value, base, width,
- precision, flags);
- break;
- case 'A':
- /* Not yet supported, we'll use "%F". */
- /* FALLTHROUGH */
- case 'E':
- if (ch == 'E')
- flags |= PRINT_F_TYPE_E;
- /* FALLTHROUGH */
- case 'G':
- if (ch == 'G')
- flags |= PRINT_F_TYPE_G;
- /* FALLTHROUGH */
- case 'F':
- flags |= PRINT_F_UP;
- /* FALLTHROUGH */
- case 'a':
- /* Not yet supported, we'll use "%f". */
- /* FALLTHROUGH */
- case 'e':
- if (ch == 'e')
- flags |= PRINT_F_TYPE_E;
- /* FALLTHROUGH */
- case 'g':
- if (ch == 'g')
- flags |= PRINT_F_TYPE_G;
- /* FALLTHROUGH */
- case 'f':
- if (cflags == PRINT_C_LDOUBLE)
- fvalue = va_arg(args, LDOUBLE);
- else
- fvalue = va_arg(args, double);
- fmtflt(str, &len, size, fvalue, width,
- precision, flags, &overflow);
- if (overflow)
- goto out;
- break;
- case 'c':
- cvalue = va_arg(args, int);
- OUTCHAR(str, len, size, cvalue);
- break;
- case 's':
- strvalue = va_arg(args, char *);
- fmtstr(str, &len, size, strvalue, width,
- precision, flags);
- break;
- case 'p':
- /*
- * C99 says: "The value of the pointer is
- * converted to a sequence of printing
- * characters, in an implementation-defined
- * manner." (C99: 7.19.6.1, 8)
- */
- if ((strvalue = (const char *)va_arg(args, void *)) == NULL)
- /*
- * We use the glibc format. BSD prints
- * "0x0", SysV "0".
- */
- fmtstr(str, &len, size, "(nil)", width,
- -1, flags);
- else {
- /*
- * We use the BSD/glibc format. SysV
- * omits the "0x" prefix (which we emit
- * using the PRINT_F_NUM flag).
- */
- flags |= PRINT_F_NUM;
- flags |= PRINT_F_UNSIGNED;
- fmtint(str, &len, size,
- (UINTPTR_T)strvalue, 16, width,
- precision, flags);
- }
- break;
- case 'n':
- switch (cflags) {
- case PRINT_C_CHAR:
- charptr = va_arg(args, signed char *);
- *charptr = len;
- break;
- case PRINT_C_SHORT:
- shortptr = va_arg(args, short int *);
- *shortptr = len;
- break;
- case PRINT_C_LONG:
- longptr = va_arg(args, long int *);
- *longptr = len;
- break;
- case PRINT_C_LLONG:
- llongptr = va_arg(args, LLONG *);
- *llongptr = len;
- break;
- case PRINT_C_SIZE:
- /*
- * C99 says that with the "z" length
- * modifier, "a following `n' conversion
- * specifier applies to a pointer to a
- * signed integer type corresponding to
- * size_t argument." (7.19.6.1, 7)
- */
- sizeptr = va_arg(args, SSIZE_T *);
- *sizeptr = len;
- break;
- case PRINT_C_INTMAX:
- intmaxptr = va_arg(args, INTMAX_T *);
- *intmaxptr = len;
- break;
- case PRINT_C_PTRDIFF:
- ptrdiffptr = va_arg(args, PTRDIFF_T *);
- *ptrdiffptr = len;
- break;
- default:
- intptr = va_arg(args, int *);
- *intptr = len;
- break;
- }
- break;
- case '%': /* Print a "%" character verbatim. */
- OUTCHAR(str, len, size, ch);
- break;
- default: /* Skip other characters. */
- break;
- }
- ch = *format++;
- state = PRINT_S_DEFAULT;
- base = cflags = flags = width = 0;
- precision = -1;
- break;
- }
-out:
- if (len < size)
- str[len] = '\0';
- else if (size > 0)
- str[size - 1] = '\0';
-
- if (overflow || len > INT_MAX) {
- errno = EOVERFLOW;
- return -1;
- }
- return (int)len;
-}
-
-static void fmtstr(char *str, size_t *len, size_t size, const char *value, int width, int precision, int flags) {
- int padlen, strln; /* Amount to pad. */
- int noprecision = (precision == -1);
-
- if (value == NULL) /* We're forgiving. */
- value = "(null)";
-
- /* If a precision was specified, don't read the string past it. */
- for (strln = 0; value[strln] != '\0' &&
- (noprecision || strln < precision); strln++)
- continue;
-
- if ((padlen = width - strln) < 0)
- padlen = 0;
- if (flags & PRINT_F_MINUS) /* Left justify. */
- padlen = -padlen;
-
- while (padlen > 0) { /* Leading spaces. */
- OUTCHAR(str, *len, size, ' ');
- padlen--;
- }
- while (*value != '\0' && (noprecision || precision-- > 0)) {
- OUTCHAR(str, *len, size, *value);
- value++;
- }
- while (padlen < 0) { /* Trailing spaces. */
- OUTCHAR(str, *len, size, ' ');
- padlen++;
- }
-}
-
-static void fmtint(char *str, size_t *len, size_t size, INTMAX_T value, int base, int width, int precision, int flags) {
- UINTMAX_T uvalue;
- char iconvert[MAX_CONVERT_LENGTH];
- char sign = 0;
- char hexprefix = 0;
- int spadlen = 0; /* Amount to space pad. */
- int zpadlen = 0; /* Amount to zero pad. */
- int pos;
- int separators = (flags & PRINT_F_QUOTE);
- int noprecision = (precision == -1);
-
- if (flags & PRINT_F_UNSIGNED)
- uvalue = value;
- else {
- uvalue = (value >= 0) ? value : -value;
- if (value < 0)
- sign = '-';
- else if (flags & PRINT_F_PLUS) /* Do a sign. */
- sign = '+';
- else if (flags & PRINT_F_SPACE)
- sign = ' ';
- }
-
- pos = convert(uvalue, iconvert, sizeof(iconvert), base,
- flags & PRINT_F_UP);
-
- if (flags & PRINT_F_NUM && uvalue != 0) {
- /*
- * C99 says: "The result is converted to an `alternative form'.
- * For `o' conversion, it increases the precision, if and only
- * if necessary, to force the first digit of the result to be a
- * zero (if the value and precision are both 0, a single 0 is
- * printed). For `x' (or `X') conversion, a nonzero result has
- * `0x' (or `0X') prefixed to it." (7.19.6.1, 6)
- */
- switch (base) {
- case 8:
- if (precision <= pos)
- precision = pos + 1;
- break;
- case 16:
- hexprefix = (flags & PRINT_F_UP) ? 'X' : 'x';
- break;
- }
- }
-
- if (separators) /* Get the number of group separators we'll print. */
- separators = getnumsep(pos);
-
- zpadlen = precision - pos - separators;
- spadlen = width /* Minimum field width. */
- - separators /* Number of separators. */
- - MAX(precision, pos) /* Number of integer digits. */
- - ((sign != 0) ? 1 : 0) /* Will we print a sign? */
- - ((hexprefix != 0) ? 2 : 0); /* Will we print a prefix? */
-
- if (zpadlen < 0)
- zpadlen = 0;
- if (spadlen < 0)
- spadlen = 0;
-
- /*
- * C99 says: "If the `0' and `-' flags both appear, the `0' flag is
- * ignored. For `d', `i', `o', `u', `x', and `X' conversions, if a
- * precision is specified, the `0' flag is ignored." (7.19.6.1, 6)
- */
- if (flags & PRINT_F_MINUS) /* Left justify. */
- spadlen = -spadlen;
- else if (flags & PRINT_F_ZERO && noprecision) {
- zpadlen += spadlen;
- spadlen = 0;
- }
- while (spadlen > 0) { /* Leading spaces. */
- OUTCHAR(str, *len, size, ' ');
- spadlen--;
- }
- if (sign != 0) /* Sign. */
- OUTCHAR(str, *len, size, sign);
- if (hexprefix != 0) { /* A "0x" or "0X" prefix. */
- OUTCHAR(str, *len, size, '0');
- OUTCHAR(str, *len, size, hexprefix);
- }
- while (zpadlen > 0) { /* Leading zeros. */
- OUTCHAR(str, *len, size, '0');
- zpadlen--;
- }
- while (pos > 0) { /* The actual digits. */
- pos--;
- OUTCHAR(str, *len, size, iconvert[pos]);
- if (separators > 0 && pos > 0 && pos % 3 == 0)
- printsep(str, len, size);
- }
- while (spadlen < 0) { /* Trailing spaces. */
- OUTCHAR(str, *len, size, ' ');
- spadlen++;
- }
-}
-
-static void fmtflt(char *str, size_t *len, size_t size, LDOUBLE fvalue, int width, int precision, int flags, int *overflow) {
- LDOUBLE ufvalue;
- UINTMAX_T intpart;
- UINTMAX_T fracpart;
- UINTMAX_T mask;
- const char *infnan = NULL;
- char iconvert[MAX_CONVERT_LENGTH];
- char fconvert[MAX_CONVERT_LENGTH];
- char econvert[5]; /* "e-300" (without nul-termination). */
- char esign = 0;
- char sign = 0;
- int leadfraczeros = 0;
- int exponent = 0;
- int emitpoint = 0;
- int omitzeros = 0;
- int omitcount = 0;
- int padlen = 0;
- int epos = 0;
- int fpos = 0;
- int ipos = 0;
- int separators = (flags & PRINT_F_QUOTE);
- int estyle = (flags & PRINT_F_TYPE_E);
-#if HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT
- struct lconv *lc = localeconv();
-#endif /* HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT */
-
- /*
- * AIX' man page says the default is 0, but C99 and at least Solaris'
- * and NetBSD's man pages say the default is 6, and sprintf(3) on AIX
- * defaults to 6.
- */
- if (precision == -1)
- precision = 6;
-
- if (fvalue < 0.0)
- sign = '-';
- else if (flags & PRINT_F_PLUS) /* Do a sign. */
- sign = '+';
- else if (flags & PRINT_F_SPACE)
- sign = ' ';
-
- if (ISNAN(fvalue))
- infnan = (flags & PRINT_F_UP) ? "NAN" : "nan";
- else if (ISINF(fvalue))
- infnan = (flags & PRINT_F_UP) ? "INF" : "inf";
-
- if (infnan != NULL) {
- if (sign != 0)
- iconvert[ipos++] = sign;
- while (*infnan != '\0')
- iconvert[ipos++] = *infnan++;
- fmtstr(str, len, size, iconvert, width, ipos, flags);
- return;
- }
-
- /* "%e" (or "%E") or "%g" (or "%G") conversion. */
- if (flags & PRINT_F_TYPE_E || flags & PRINT_F_TYPE_G) {
- if (flags & PRINT_F_TYPE_G) {
- /*
- * If the precision is zero, it is treated as one (cf.
- * C99: 7.19.6.1, 8).
- */
- if (precision == 0)
- precision = 1;
- /*
- * For "%g" (and "%G") conversions, the precision
- * specifies the number of significant digits, which
- * includes the digits in the integer part. The
- * conversion will or will not be using "e-style" (like
- * "%e" or "%E" conversions) depending on the precision
- * and on the exponent. However, the exponent can be
- * affected by rounding the converted value, so we'll
- * leave this decision for later. Until then, we'll
- * assume that we're going to do an "e-style" conversion
- * (in order to get the exponent calculated). For
- * "e-style", the precision must be decremented by one.
- */
- precision--;
- /*
- * For "%g" (and "%G") conversions, trailing zeros are
- * removed from the fractional portion of the result
- * unless the "#" flag was specified.
- */
- if (!(flags & PRINT_F_NUM))
- omitzeros = 1;
- }
- exponent = getexponent(fvalue);
- estyle = 1;
- }
-
-again:
- /*
- * Sorry, we only support 9, 19, or 38 digits (that is, the number of
- * digits of the 32-bit, the 64-bit, or the 128-bit UINTMAX_MAX value
- * minus one) past the decimal point due to our conversion method.
- */
- switch (sizeof(UINTMAX_T)) {
- case 16:
- if (precision > 38)
- precision = 38;
- break;
- case 8:
- if (precision > 19)
- precision = 19;
- break;
- default:
- if (precision > 9)
- precision = 9;
- break;
- }
-
- ufvalue = (fvalue >= 0.0) ? fvalue : -fvalue;
- if (estyle) /* We want exactly one integer digit. */
- ufvalue /= mypow10(exponent);
-
- if ((intpart = cast(ufvalue)) == UINTMAX_MAX) {
- *overflow = 1;
- return;
- }
-
- /*
- * Factor of ten with the number of digits needed for the fractional
- * part. For example, if the precision is 3, the mask will be 1000.
- */
- mask = mypow10(precision);
- /*
- * We "cheat" by converting the fractional part to integer by
- * multiplying by a factor of ten.
- */
- if ((fracpart = myround(mask * (ufvalue - intpart))) >= mask) {
- /*
- * For example, ufvalue = 2.99962, intpart = 2, and mask = 1000
- * (because precision = 3). Now, myround(1000 * 0.99962) will
- * return 1000. So, the integer part must be incremented by one
- * and the fractional part must be set to zero.
- */
- intpart++;
- fracpart = 0;
- if (estyle && intpart == 10) {
- /*
- * The value was rounded up to ten, but we only want one
- * integer digit if using "e-style". So, the integer
- * part must be set to one and the exponent must be
- * incremented by one.
- */
- intpart = 1;
- exponent++;
- }
- }
-
- /*
- * Now that we know the real exponent, we can check whether or not to
- * use "e-style" for "%g" (and "%G") conversions. If we don't need
- * "e-style", the precision must be adjusted and the integer and
- * fractional parts must be recalculated from the original value.
- *
- * C99 says: "Let P equal the precision if nonzero, 6 if the precision
- * is omitted, or 1 if the precision is zero. Then, if a conversion
- * with style `E' would have an exponent of X:
- *
- * - if P > X >= -4, the conversion is with style `f' (or `F') and
- * precision P - (X + 1).
- *
- * - otherwise, the conversion is with style `e' (or `E') and precision
- * P - 1." (7.19.6.1, 8)
- *
- * Note that we had decremented the precision by one.
- */
- if (flags & PRINT_F_TYPE_G && estyle &&
- precision + 1 > exponent && exponent >= -4) {
- precision -= exponent;
- estyle = 0;
- goto again;
- }
-
- if (estyle) {
- if (exponent < 0) {
- exponent = -exponent;
- esign = '-';
- } else
- esign = '+';
-
- /*
- * Convert the exponent. The sizeof(econvert) is 5. So, the
- * econvert buffer can hold e.g. "e+999" and "e-999". We don't
- * support an exponent which contains more than three digits.
- * Therefore, the following stores are safe.
- */
- epos = convert(exponent, econvert, 3, 10, 0);
- /*
- * C99 says: "The exponent always contains at least two digits,
- * and only as many more digits as necessary to represent the
- * exponent." (7.19.6.1, 8)
- */
- if (epos == 1)
- econvert[epos++] = '0';
- econvert[epos++] = esign;
- econvert[epos++] = (flags & PRINT_F_UP) ? 'E' : 'e';
- }
-
- /* Convert the integer part and the fractional part. */
- ipos = convert(intpart, iconvert, sizeof(iconvert), 10, 0);
- if (fracpart != 0) /* convert() would return 1 if fracpart == 0. */
- fpos = convert(fracpart, fconvert, sizeof(fconvert), 10, 0);
-
- leadfraczeros = precision - fpos;
-
- if (omitzeros) {
- if (fpos > 0) /* Omit trailing fractional part zeros. */
- while (omitcount < fpos && fconvert[omitcount] == '0')
- omitcount++;
- else { /* The fractional part is zero, omit it completely. */
- omitcount = precision;
- leadfraczeros = 0;
- }
- precision -= omitcount;
- }
-
- /*
- * Print a decimal point if either the fractional part is non-zero
- * and/or the "#" flag was specified.
- */
- if (precision > 0 || flags & PRINT_F_NUM)
- emitpoint = 1;
- if (separators) /* Get the number of group separators we'll print. */
- separators = getnumsep(ipos);
-
- padlen = width /* Minimum field width. */
- - ipos /* Number of integer digits. */
- - epos /* Number of exponent characters. */
- - precision /* Number of fractional digits. */
- - separators /* Number of group separators. */
- - (emitpoint ? 1 : 0) /* Will we print a decimal point? */
- - ((sign != 0) ? 1 : 0); /* Will we print a sign character? */
-
- if (padlen < 0)
- padlen = 0;
-
- /*
- * C99 says: "If the `0' and `-' flags both appear, the `0' flag is
- * ignored." (7.19.6.1, 6)
- */
- if (flags & PRINT_F_MINUS) /* Left justifty. */
- padlen = -padlen;
- else if (flags & PRINT_F_ZERO && padlen > 0) {
- if (sign != 0) { /* Sign. */
- OUTCHAR(str, *len, size, sign);
- sign = 0;
- }
- while (padlen > 0) { /* Leading zeros. */
- OUTCHAR(str, *len, size, '0');
- padlen--;
- }
- }
- while (padlen > 0) { /* Leading spaces. */
- OUTCHAR(str, *len, size, ' ');
- padlen--;
- }
- if (sign != 0) /* Sign. */
- OUTCHAR(str, *len, size, sign);
- while (ipos > 0) { /* Integer part. */
- ipos--;
- OUTCHAR(str, *len, size, iconvert[ipos]);
- if (separators > 0 && ipos > 0 && ipos % 3 == 0)
- printsep(str, len, size);
- }
- if (emitpoint) { /* Decimal point. */
-#if HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT
- if (lc->decimal_point != NULL && *lc->decimal_point != '\0')
- OUTCHAR(str, *len, size, *lc->decimal_point);
- else /* We'll always print some decimal point character. */
-#endif /* HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT */
- OUTCHAR(str, *len, size, '.');
- }
- while (leadfraczeros > 0) { /* Leading fractional part zeros. */
- OUTCHAR(str, *len, size, '0');
- leadfraczeros--;
- }
- while (fpos > omitcount) { /* The remaining fractional part. */
- fpos--;
- OUTCHAR(str, *len, size, fconvert[fpos]);
- }
- while (epos > 0) { /* Exponent. */
- epos--;
- OUTCHAR(str, *len, size, econvert[epos]);
- }
- while (padlen < 0) { /* Trailing spaces. */
- OUTCHAR(str, *len, size, ' ');
- padlen++;
- }
-}
-
-static void printsep(char *str, size_t *len, size_t size) {
-#if HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP
- struct lconv *lc = localeconv();
- int i;
-
- if (lc->thousands_sep != NULL)
- for (i = 0; lc->thousands_sep[i] != '\0'; i++)
- OUTCHAR(str, *len, size, lc->thousands_sep[i]);
- else
-#endif /* HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP */
- OUTCHAR(str, *len, size, ',');
-}
-
-static int
-getnumsep(int digits)
-{
- int separators = (digits - ((digits % 3 == 0) ? 1 : 0)) / 3;
-#if HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP
- int strln;
- struct lconv *lc = localeconv();
-
- /* We support an arbitrary separator length (including zero). */
- if (lc->thousands_sep != NULL) {
- for (strln = 0; lc->thousands_sep[strln] != '\0'; strln++)
- continue;
- separators *= strln;
- }
-#endif /* HAVE_LOCALECONV && HAVE_LCONV_THOUSANDS_SEP */
- return separators;
-}
-
-static int getexponent(LDOUBLE value) {
- LDOUBLE tmp = (value >= 0.0) ? value : -value;
- int exponent = 0;
-
- /*
- * We check for LDOUBLE_MAX_10_EXP >= exponent >= LDOUBLE_MIN_10_EXP in
- * order to work around possible endless loops which could happen (at
- * least) in the second loop (at least) if we're called with an infinite
- * value. However, we checked for infinity before calling this function
- * using our ISINF() macro, so this might be somewhat paranoid.
- */
- while (tmp < 1.0 && tmp > 0.0 && --exponent >= LDOUBLE_MIN_10_EXP)
- tmp *= 10;
- while (tmp >= 10.0 && ++exponent <= LDOUBLE_MAX_10_EXP)
- tmp /= 10;
-
- return exponent;
-}
-
-static int convert(UINTMAX_T value, char *buf, size_t size, int base, int caps) {
- const char *digits = caps ? "0123456789ABCDEF" : "0123456789abcdef";
- size_t pos = 0;
-
- /* We return an unterminated buffer with the digits in reverse order. */
- do {
- buf[pos++] = digits[value % base];
- value /= base;
- } while (value != 0 && pos < size);
-
- return (int)pos;
-}
-
-static UINTMAX_T cast(LDOUBLE value) {
- UINTMAX_T result;
-
- /*
- * We check for ">=" and not for ">" because if UINTMAX_MAX cannot be
- * represented exactly as an LDOUBLE value (but is less than LDBL_MAX),
- * it may be increased to the nearest higher representable value for the
- * comparison (cf. C99: 6.3.1.4, 2). It might then equal the LDOUBLE
- * value although converting the latter to UINTMAX_T would overflow.
- */
- if (value >= UINTMAX_MAX)
- return UINTMAX_MAX;
-
- result = value;
- /*
- * At least on NetBSD/sparc64 3.0.2 and 4.99.30, casting long double to
- * an integer type converts e.g. 1.9 to 2 instead of 1 (which violates
- * the standard). Sigh.
- */
- return (result <= value) ? result : result - 1;
-}
-
-static UINTMAX_T myround(LDOUBLE value) {
- UINTMAX_T intpart = cast(value);
-
- return ((value -= intpart) < 0.5) ? intpart : intpart + 1;
-}
-
-static LDOUBLE mypow10(int exponent) {
- LDOUBLE result = 1;
-
- while (exponent > 0) {
- result *= 10;
- exponent--;
- }
- while (exponent < 0) {
- result /= 10;
- exponent++;
- }
- return result;
-}
-#endif // defined(__ANDROID__)
-/* vim: set joinspaces noexpandtab textwidth=80 cinoptions=(4,u0: */
diff --git a/backends/platform/android3d/texture.cpp b/backends/platform/android3d/texture.cpp
deleted file mode 100644
index 6654d3b1764..00000000000
--- a/backends/platform/android3d/texture.cpp
+++ /dev/null
@@ -1,498 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#if defined(__ANDROID__)
-
-// Allow use of stuff in <time.h>
-#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
-
-// Disable printf override in common/forbidden.h to avoid
-// clashes with log.h from the Android SDK.
-// That header file uses
-// __attribute__ ((format(printf, 3, 4)))
-// which gets messed up by our override mechanism; this could
-// be avoided by either changing the Android SDK to use the equally
-// legal and valid
-// __attribute__ ((format(printf, 3, 4)))
-// or by refining our printf override to use a varadic macro
-// (which then wouldn't be portable, though).
-// Anyway, for now we just disable the printf override globally
-// for the Android port
-#define FORBIDDEN_SYMBOL_EXCEPTION_printf
-
-#include "base/main.h"
-#include "graphics/surface.h"
-#include "graphics/opengl/shader.h"
-#include "graphics/opengl/context.h"
-
-#include "common/rect.h"
-#include "common/array.h"
-#include "common/util.h"
-
-#include "backends/platform/android3d/texture.h"
-#include "backends/platform/android3d/android.h"
-#include "backends/platform/android3d/jni-android.h"
-
-// Supported GL extensions
-static bool npot_supported = false;
-
-OpenGL::ShaderGL * g_box_shader;
-GLuint g_verticesVBO;
-
-template<class T>
-static T nextHigher2(T k) {
- if (k == 0)
- return 1;
- --k;
-
- for (uint i = 1; i < sizeof(T) * CHAR_BIT; i <<= 1)
- k = k | k >> i;
-
- return k + 1;
-}
-
-const GLfloat vertices[] = {
- 0.0, 0.0,
- 1.0, 0.0,
- 0.0, 1.0,
- 1.0, 1.0,
-};
-
-static const char *controlVertex =
- "#version 100\n"
- "attribute vec2 position;\n"
- "attribute vec2 texcoord;\n"
- "uniform vec2 offsetXY;\n"
- "uniform vec2 sizeWH;\n"
- "uniform vec4 clip;\n"
- "uniform bool flipY;\n"
- "varying vec2 Texcoord;\n"
- "void main() {\n"
- "Texcoord = clip.xy + texcoord * (clip.zw - clip.xy);\n"
- "vec2 pos = offsetXY + position * sizeWH;\n"
- "pos.x = pos.x * 2.0 - 1.0;\n"
- "pos.y = pos.y * 2.0 - 1.0;\n"
- "if (flipY)\n"
- "pos.y *= -1.0;\n"
- "gl_Position = vec4(pos, 0.0, 1.0);\n"
- "}\n";
-
-static const char *controlFragment =
- "#version 100\n"
- "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
- "precision highp float;\n"
- "#else\n"
- "precision mediump float;\n"
- "#endif\n"
- "varying vec2 Texcoord;\n"
- "uniform sampler2D tex;\n"
- "void main() {\n"
- "gl_FragColor = texture2D(tex, Texcoord);\n"
- "}\n";
-
-void GLESBaseTexture::initGL() {
- npot_supported = OpenGLContext.NPOTSupported;
-
- const char* attributes[] = { "position", "texcoord", NULL };
- g_box_shader = OpenGL::ShaderGL::fromStrings("control", controlVertex, controlFragment, attributes);
- g_verticesVBO = OpenGL::ShaderGL::createBuffer(GL_ARRAY_BUFFER, sizeof(vertices), vertices);
- g_box_shader->enableVertexAttribute("position", g_verticesVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
- g_box_shader->enableVertexAttribute("texcoord", g_verticesVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
-}
-
-GLESBaseTexture::GLESBaseTexture(GLenum glFormat, GLenum glType,
- Graphics::PixelFormat pixelFormat) :
- _glFormat(glFormat),
- _glType(glType),
- _glFilter(GL_NEAREST),
- _texture_name(0),
- _surface(),
- _texture_width(0),
- _texture_height(0),
- _draw_rect(),
- _all_dirty(false),
- _dirty_rect(),
- _pixelFormat(pixelFormat),
- _palettePixelFormat(),
- _is_game_texture(false)
-{
- GLCALL(glGenTextures(1, &_texture_name));
-}
-
-GLESBaseTexture::~GLESBaseTexture() {
- release();
-}
-
-void GLESBaseTexture::release() {
- if (_texture_name) {
- GLCALL(glDeleteTextures(1, &_texture_name));
- _texture_name = 0;
- }
-}
-
-void GLESBaseTexture::reinit() {
- GLCALL(glGenTextures(1, &_texture_name));
-
- initSize();
-
- setDirty();
-}
-
-void GLESBaseTexture::initSize() {
- // Allocate room for the texture now, but pixel data gets uploaded
- // later (perhaps with multiple TexSubImage2D operations).
- GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name));
- GLCALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
- GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _glFilter));
- GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _glFilter));
- GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
- GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
- GLCALL(glTexImage2D(GL_TEXTURE_2D, 0, _glFormat,
- _texture_width, _texture_height,
- 0, _glFormat, _glType, 0));
-}
-
-void GLESBaseTexture::setLinearFilter(bool value) {
- if (value)
- _glFilter = GL_LINEAR;
- else
- _glFilter = GL_NEAREST;
-
- GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name));
-
- GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _glFilter));
- GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _glFilter));
-}
-
-void GLESBaseTexture::allocBuffer(GLuint w, GLuint h) {
- _surface.w = w;
- _surface.h = h;
- _surface.format = _pixelFormat;
-
- if (w == _texture_width && h == _texture_height)
- return;
-
- if (npot_supported) {
- _texture_width = _surface.w;
- _texture_height = _surface.h;
- } else {
- _texture_width = nextHigher2(_surface.w);
- _texture_height = nextHigher2(_surface.h);
- }
-
- initSize();
-}
-
-void GLESBaseTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h, const Common::Rect &clip) {
-// LOGD("*** Texture %p: Drawing %dx%d rect to (%d,%d)", this, w, h, x, y);
-
- assert(g_box_shader);
- g_box_shader->use();
-
- GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name));
- const GLfloat offsetX = float(x) / float(JNI::egl_surface_width);
- const GLfloat offsetY = float(y) / float(JNI::egl_surface_height);
- const GLfloat sizeW = float(w) / float(JNI::egl_surface_width);
- const GLfloat sizeH = float(h) / float(JNI::egl_surface_height);
- Math::Vector4d clipV = Math::Vector4d(clip.left, clip.top, clip.right, clip.bottom);
- clipV.x() /= _texture_width; clipV.y() /= _texture_height;
- clipV.z() /= _texture_width; clipV.w() /= _texture_height;
-// LOGD("*** Drawing at (%f,%f) , size %f x %f", float(x) / float(_surface.w), float(y) / float(_surface.h), tex_width, tex_height);
-
- g_box_shader->setUniform("offsetXY", Math::Vector2d(offsetX, offsetY));
- g_box_shader->setUniform("sizeWH", Math::Vector2d(sizeW, sizeH));
- g_box_shader->setUniform("clip", clipV);
- g_box_shader->setUniform("flipY", !_is_game_texture);
-
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- clearDirty();
-}
-
-const Graphics::PixelFormat &GLESBaseTexture::getPixelFormat() const {
- return _pixelFormat;
-}
-
-GLESTexture::GLESTexture(GLenum glFormat, GLenum glType,
- Graphics::PixelFormat pixelFormat) :
- GLESBaseTexture(glFormat, glType, pixelFormat),
- _pixels(0),
- _buf(0) {
-}
-
-GLESTexture::~GLESTexture() {
- delete[] _buf;
- delete[] _pixels;
-}
-
-void GLESTexture::allocBuffer(GLuint w, GLuint h) {
- GLuint oldw = _surface.w;
- GLuint oldh = _surface.h;
-
- GLESBaseTexture::allocBuffer(w, h);
-
- _surface.pitch = w * _pixelFormat.bytesPerPixel;
-
- if (_surface.w == oldw && _surface.h == oldh) {
- fillBuffer(0);
- return;
- }
-
- delete[] _buf;
- delete[] _pixels;
-
- _pixels = new byte[w * h * _surface.format.bytesPerPixel];
- assert(_pixels);
-
- _surface.setPixels(_pixels);
-
- fillBuffer(0);
-
- _buf = new byte[w * h * _surface.format.bytesPerPixel];
- assert(_buf);
-}
-
-void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h,
- const void *buf, int pitch_buf) {
- setDirtyRect(Common::Rect(x, y, x + w, y + h));
-
- const byte *src = (const byte *)buf;
- byte *dst = _pixels + y * _surface.pitch + x * _surface.format.bytesPerPixel;
-
- do {
- memcpy(dst, src, w * _surface.format.bytesPerPixel);
- dst += _surface.pitch;
- src += pitch_buf;
- } while (--h);
-}
-
-void GLESTexture::fillBuffer(uint32 color) {
- assert(_surface.getPixels());
-
- if (_pixelFormat.bytesPerPixel == 1 ||
- ((color & 0xff) == ((color >> 8) & 0xff)))
- memset(_pixels, color & 0xff, _surface.pitch * _surface.h);
- else
- Common::fill(_pixels, _pixels + _surface.pitch * _surface.h,
- (uint16)color);
-
- setDirty();
-}
-
-void GLESTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h, const Common::Rect &clip) {
- if (_all_dirty) {
- _dirty_rect.top = 0;
- _dirty_rect.left = 0;
- _dirty_rect.bottom = _surface.h;
- _dirty_rect.right = _surface.w;
-
- _all_dirty = false;
- }
-
- if (!_dirty_rect.isEmpty()) {
- byte *_tex;
-
- int16 dwidth = _dirty_rect.width();
- int16 dheight = _dirty_rect.height();
-
- if (dwidth == _surface.w) {
- _tex = _pixels + _dirty_rect.top * _surface.pitch;
- } else {
- _tex = _buf;
-
- byte *src = _pixels + _dirty_rect.top * _surface.pitch +
- _dirty_rect.left * _surface.format.bytesPerPixel;
- byte *dst = _buf;
-
- uint16 l = dwidth * _surface.format.bytesPerPixel;
-
- for (uint16 i = 0; i < dheight; ++i) {
- memcpy(dst, src, l);
- src += _surface.pitch;
- dst += l;
- }
- }
-
- GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name));
- GLCALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
-
- GLCALL(glTexSubImage2D(GL_TEXTURE_2D, 0,
- _dirty_rect.left, _dirty_rect.top,
- dwidth, dheight, _glFormat, _glType, _tex));
- }
-
- GLESBaseTexture::drawTexture(x, y, w, h, clip);
-}
-
-GLES4444Texture::GLES4444Texture() :
- GLESTexture(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixelFormat()) {
-}
-
-GLES4444Texture::~GLES4444Texture() {
-}
-
-GLES8888Texture::GLES8888Texture() :
- GLESTexture(GL_RGBA, GL_UNSIGNED_BYTE, pixelFormat()) {
-}
-
-GLES8888Texture::~GLES8888Texture() {
-}
-
-GLES5551Texture::GLES5551Texture() :
- GLESTexture(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, pixelFormat()) {
-}
-
-GLES5551Texture::~GLES5551Texture() {
-}
-
-GLES565Texture::GLES565Texture() :
- GLESTexture(GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixelFormat()) {
-}
-
-GLES565Texture::~GLES565Texture() {
-}
-
-GLESFakePaletteTexture::GLESFakePaletteTexture(GLenum glFormat, GLenum glType,
- Graphics::PixelFormat pixelFormat) :
- GLESBaseTexture(glFormat, glType, pixelFormat),
- _palette(0),
- _pixels(0),
- _buf(0)
-{
- _palettePixelFormat = pixelFormat;
- _fake_format = Graphics::PixelFormat::createFormatCLUT8();
-
- _palette = new uint16[256]();
- assert(_palette);
-}
-
-GLESFakePaletteTexture::~GLESFakePaletteTexture() {
- delete[] _buf;
- delete[] _pixels;
- delete[] _palette;
-}
-
-void GLESFakePaletteTexture::allocBuffer(GLuint w, GLuint h) {
- GLuint oldw = _surface.w;
- GLuint oldh = _surface.h;
-
- GLESBaseTexture::allocBuffer(w, h);
-
- _surface.format = Graphics::PixelFormat::createFormatCLUT8();
- _surface.pitch = w;
-
- if (_surface.w == oldw && _surface.h == oldh) {
- fillBuffer(0);
- return;
- }
-
- delete[] _buf;
- delete[] _pixels;
-
- _pixels = new byte[w * h];
- assert(_pixels);
-
- // fixup surface, for the outside this is a CLUT8 surface
- _surface.setPixels(_pixels);
-
- fillBuffer(0);
-
- _buf = new uint16[w * h];
- assert(_buf);
-}
-
-void GLESFakePaletteTexture::fillBuffer(uint32 color) {
- assert(_surface.getPixels());
- memset(_surface.getPixels(), color & 0xff, _surface.pitch * _surface.h);
- setDirty();
-}
-
-void GLESFakePaletteTexture::updateBuffer(GLuint x, GLuint y, GLuint w,
- GLuint h, const void *buf,
- int pitch_buf) {
- setDirtyRect(Common::Rect(x, y, x + w, y + h));
-
- const byte *src = (const byte *)buf;
- byte *dst = _pixels + y * _surface.pitch + x;
-
- do {
- memcpy(dst, src, w);
- dst += _surface.pitch;
- src += pitch_buf;
- } while (--h);
-}
-
-void GLESFakePaletteTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h, const Common::Rect &clip) {
- if (_all_dirty) {
- _dirty_rect.top = 0;
- _dirty_rect.left = 0;
- _dirty_rect.bottom = _surface.h;
- _dirty_rect.right = _surface.w;
-
- _all_dirty = false;
- }
-
- if (!_dirty_rect.isEmpty()) {
- int16 dwidth = _dirty_rect.width();
- int16 dheight = _dirty_rect.height();
-
- byte *src = _pixels + _dirty_rect.top * _surface.pitch +
- _dirty_rect.left;
- uint16 *dst = _buf;
- uint pitch_delta = _surface.pitch - dwidth;
-
- for (uint16 j = 0; j < dheight; ++j) {
- for (uint16 i = 0; i < dwidth; ++i)
- *dst++ = _palette[*src++];
- src += pitch_delta;
- }
-
- GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name));
-
- GLCALL(glTexSubImage2D(GL_TEXTURE_2D, 0,
- _dirty_rect.left, _dirty_rect.top,
- dwidth, dheight, _glFormat, _glType, _buf));
- }
-
- GLESBaseTexture::drawTexture(x, y, w, h, clip);
-}
-
-const Graphics::PixelFormat &GLESFakePaletteTexture::getPixelFormat() const {
- return _fake_format;
-}
-
-GLESFakePalette565Texture::GLESFakePalette565Texture() :
- GLESFakePaletteTexture(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
- GLES565Texture::pixelFormat()) {
-}
-
-GLESFakePalette565Texture::~GLESFakePalette565Texture() {
-}
-
-GLESFakePalette5551Texture::GLESFakePalette5551Texture() :
- GLESFakePaletteTexture(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1,
- GLES5551Texture::pixelFormat()) {
-}
-
-GLESFakePalette5551Texture::~GLESFakePalette5551Texture() {
-}
-
-#endif
diff --git a/backends/platform/android3d/texture.h b/backends/platform/android3d/texture.h
deleted file mode 100644
index 169c9ca643b..00000000000
--- a/backends/platform/android3d/texture.h
+++ /dev/null
@@ -1,311 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef _ANDROID_TEXTURE_H_
-#define _ANDROID_TEXTURE_H_
-
-#if defined(__ANDROID__)
-
-#define GL_GLEXT_PROTOTYPES
-#include <GLES/gl.h>
-
-#include "graphics/surface.h"
-#include "graphics/pixelformat.h"
-
-#include "common/rect.h"
-#include "common/array.h"
-
-class GLESBaseTexture {
-public:
- static void initGL();
-
-protected:
- GLESBaseTexture(GLenum glFormat, GLenum glType,
- Graphics::PixelFormat pixelFormat);
-
-public:
- virtual ~GLESBaseTexture();
-
- void release();
- void reinit();
- void initSize();
-
- void setLinearFilter(bool value);
-
- virtual void allocBuffer(GLuint w, GLuint h);
-
- virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,
- const void *buf, int pitch_buf) = 0;
- virtual void fillBuffer(uint32 color) = 0;
-
- virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) {
- drawTexture(x, y, w, h, Common::Rect(0, 0, width(), height()));
- }
- virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h, const Common::Rect &clip);
-
-
- inline void setDrawRect(const Common::Rect &rect) {
- _draw_rect = rect;
- }
-
- inline void setDrawRect(int16 w, int16 h) {
- _draw_rect = Common::Rect(w, h);
- }
-
- inline void setDrawRect(int16 x1, int16 y1, int16 x2, int16 y2) {
- _draw_rect = Common::Rect(x1, y1, x2, y2);
- }
-
- inline const Common::Rect &getDrawRect() const {
- return _draw_rect;
- }
-
- inline void drawTextureRect() {
- drawTexture(_draw_rect.left, _draw_rect.top,
- _draw_rect.width(), _draw_rect.height());
- }
-
- inline void drawTextureOrigin() {
- drawTexture(0, 0, _surface.w, _surface.h);
- }
-
- inline GLuint width() const {
- return _surface.w;
- }
-
- inline GLuint height() const {
- return _surface.h;
- }
-
- inline GLuint texWidth() const {
- return _texture_width;
- }
-
- inline GLuint texHeight() const {
- return _texture_height;
- }
-
- inline uint16 pitch() const {
- return _surface.pitch;
- }
-
- inline bool isEmpty() const {
- return _surface.w == 0 || _surface.h == 0;
- }
-
- inline const Graphics::Surface *surface_const() const {
- return &_surface;
- }
-
- inline Graphics::Surface *surface() {
- setDirty();
- return &_surface;
- }
-
- virtual const byte *palette_const() const {
- return 0;
- };
-
- virtual byte *palette() {
- return 0;
- };
-
- inline bool hasPalette() const {
- return _palettePixelFormat.bytesPerPixel > 0;
- }
-
- inline bool dirty() const {
- return _all_dirty || !_dirty_rect.isEmpty();
- }
-
- virtual const Graphics::PixelFormat &getPixelFormat() const;
-
- inline const Graphics::PixelFormat &getPalettePixelFormat() const {
- return _palettePixelFormat;
- }
-
- GLuint getTextureName() const {
- return _texture_name;
- }
-
- void setGameTexture() {
- _is_game_texture = true;
- }
-
-protected:
- inline void setDirty() {
- _all_dirty = true;
- }
-
- inline void clearDirty() {
- _all_dirty = false;
- _dirty_rect.top = 0;
- _dirty_rect.left = 0;
- _dirty_rect.bottom = 0;
- _dirty_rect.right = 0;
- }
-
- inline void setDirtyRect(const Common::Rect& r) {
- if (!_all_dirty) {
- if (_dirty_rect.isEmpty())
- _dirty_rect = r;
- else
- _dirty_rect.extend(r);
- }
- }
-
- GLenum _glFormat;
- GLenum _glType;
- GLint _glFilter;
-
- GLuint _texture_name;
- Graphics::Surface _surface;
- GLuint _texture_width;
- GLuint _texture_height;
-
- Common::Rect _draw_rect;
-
- bool _all_dirty;
- Common::Rect _dirty_rect;
-
- Graphics::PixelFormat _pixelFormat;
- Graphics::PixelFormat _palettePixelFormat;
-
- bool _is_game_texture;
-};
-
-class GLESTexture : public GLESBaseTexture {
-protected:
- GLESTexture(GLenum glFormat, GLenum glType,
- Graphics::PixelFormat pixelFormat);
-
-public:
- virtual ~GLESTexture();
-
- virtual void allocBuffer(GLuint w, GLuint h);
-
- virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,
- const void *buf, int pitch_buf);
- virtual void fillBuffer(uint32 color);
-
- virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) {
- drawTexture(x, y, w, h, Common::Rect(0, 0, width(), height()));
- }
- virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h, const Common::Rect &clip);
-
-protected:
- byte *_pixels;
- byte *_buf;
-};
-
-class GLES8888Texture : public GLESTexture {
-public:
- GLES8888Texture();
- virtual ~GLES8888Texture();
-
- static Graphics::PixelFormat pixelFormat() {
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
- }
-};
-
-// RGBA4444 texture
-class GLES4444Texture : public GLESTexture {
-public:
- GLES4444Texture();
- virtual ~GLES4444Texture();
-
- static Graphics::PixelFormat pixelFormat() {
- return Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0);
- }
-};
-
-// RGBA5551 texture
-class GLES5551Texture : public GLESTexture {
-public:
- GLES5551Texture();
- virtual ~GLES5551Texture();
-
- static inline Graphics::PixelFormat pixelFormat() {
- return Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0);
- }
-};
-
-// RGB565 texture
-class GLES565Texture : public GLESTexture {
-public:
- GLES565Texture();
- virtual ~GLES565Texture();
-
- static inline Graphics::PixelFormat pixelFormat() {
- return Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
- }
-};
-
-class GLESFakePaletteTexture : public GLESBaseTexture {
-protected:
- GLESFakePaletteTexture(GLenum glFormat, GLenum glType,
- Graphics::PixelFormat pixelFormat);
-
-public:
- virtual ~GLESFakePaletteTexture();
-
- virtual void allocBuffer(GLuint w, GLuint h);
- virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,
- const void *buf, int pitch_buf);
- virtual void fillBuffer(uint32 color);
-
- virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) {
- drawTexture(x, y, w, h, Common::Rect(0, 0, width(), height()));
- }
- virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h, const Common::Rect &clip);
-
- virtual const byte *palette_const() const {
- return (byte *)_palette;
- };
-
- virtual byte *palette() {
- setDirty();
- return (byte *)_palette;
- };
-
- virtual const Graphics::PixelFormat &getPixelFormat() const;
-
-protected:
- Graphics::PixelFormat _fake_format;
- uint16 *_palette;
- byte *_pixels;
- uint16 *_buf;
-};
-
-class GLESFakePalette565Texture : public GLESFakePaletteTexture {
-public:
- GLESFakePalette565Texture();
- virtual ~GLESFakePalette565Texture();
-};
-
-class GLESFakePalette5551Texture : public GLESFakePaletteTexture {
-public:
- GLESFakePalette5551Texture();
- virtual ~GLESFakePalette5551Texture();
-};
-
-#endif
-#endif
diff --git a/backends/platform/android3d/touchcontrols.cpp b/backends/platform/android3d/touchcontrols.cpp
deleted file mode 100644
index 0b277e57f89..00000000000
--- a/backends/platform/android3d/touchcontrols.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#if defined(__ANDROID__)
-
-// Allow use of stuff in <time.h>
-#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
-
-//
-// Disable printf override in common/forbidden.h to avoid
-// clashes with log.h from the Android SDK.
-// That header file uses
-// __attribute__ ((format(printf, 3, 4)))
-// which gets messed up by our override mechanism; this could
-// be avoided by either changing the Android SDK to use the equally
-// legal and valid
-// __attribute__ ((format(printf, 3, 4)))
-// or by refining our printf override to use a varadic macro
-// (which then wouldn't be portable, though).
-// Anyway, for now we just disable the printf override globally
-// for the Android port
-#define FORBIDDEN_SYMBOL_EXCEPTION_printf
-
-#include "common/fs.h"
-#include "common/stream.h"
-#include "common/archive.h"
-#include "image/tga.h"
-
-#include "backends/platform/android3d/android.h"
-#include "backends/platform/android3d/events.h"
-#include "backends/platform/android3d/texture.h"
-#include "backends/platform/android3d/touchcontrols.h"
-
-static Common::Rect clipFor(const Common::KeyCode &cs) {
- switch (cs) {
- case Common::KEYCODE_UP:
- case Common::KEYCODE_PAGEUP:
- return Common::Rect(0, 0, 128, 128);
- case Common::KEYCODE_RIGHT:
- return Common::Rect(128, 0, 256, 128);
- case Common::KEYCODE_DOWN:
- case Common::KEYCODE_PAGEDOWN:
- return Common::Rect(256, 0, 384, 128);
- case Common::KEYCODE_LEFT:
- return Common::Rect(384, 0, 512, 128);
- case Common::KEYCODE_i:
- return Common::Rect(0, 128, 128, 256);
- case Common::KEYCODE_p:
- return Common::Rect(128, 128, 256, 256);
- case Common::KEYCODE_u:
- return Common::Rect(256, 128, 384, 256);
- case Common::KEYCODE_e:
- case Common::KEYCODE_l:
- return Common::Rect(384, 128, 512, 256);
- default: // unreachable
- return Common::Rect(0, 0, 1, 1);
- }
-}
-
-TouchControls::TouchControls() :
- _arrows_texture(NULL),
- _joystickPressing(Common::KEYCODE_INVALID),
- _centerPressing(Common::KEYCODE_INVALID),
- _rightPressing(Common::KEYCODE_INVALID),
- _screen_width(0),
- _screen_height(0) {
-
- for (int p = 0; p < kNumPointers; ++p) {
- Pointer &pp = _pointers[p];
- pp.currentX = pp.currentY = pp.startX = pp.startY = 0;
- pp.active = false;
- pp.function = kTouchAreaNone;
- }
-
- for (int i = 0; i < 4; ++i)
- _activePointers[i] = -1;
-}
-
-TouchControls::~TouchControls() {
- if (_arrows_texture) {
- delete _arrows_texture;
- _arrows_texture = 0;
- }
-}
-
-uint16 TouchControls::getTouchArea(int x, int y) {
- float xPercent = float(x) / _screen_width;
-
- if (xPercent < 0.3)
- return kTouchAreaJoystick;
- else if (xPercent < 0.8)
- return kTouchAreaCenter;
- else
- return kTouchAreaRight;
-}
-
-static Common::KeyCode determineKey(int dX, int dY, Common::KeyCode def = Common::KEYCODE_INVALID) {
- if (dX * dX + dY * dY < 50 * 50)
- return def;
-
- if (dY > abs(dX))
- return Common::KEYCODE_DOWN;
- if (dX > abs(dY))
- return Common::KEYCODE_RIGHT;
- if (-dY > abs(dX))
- return Common::KEYCODE_UP;
- if (-dX > abs(dY))
- return Common::KEYCODE_LEFT;
-
- return Common::KEYCODE_INVALID;
-}
-
-static GLES8888Texture *loadBuiltinTexture(const char *filename) {
- Common::ArchiveMemberPtr member = SearchMan.getMember(filename);
- Common::SeekableReadStream *str = member->createReadStream();
- Image::TGADecoder dec;
- dec.loadStream(*str);
- const void *pixels = dec.getSurface()->getPixels();
-
- GLES8888Texture *ret = new GLES8888Texture();
- uint16 w = dec.getSurface()->w;
- uint16 h = dec.getSurface()->h;
- uint16 pitch = dec.getSurface()->pitch;
- ret->allocBuffer(w, h);
- ret->updateBuffer(0, 0, w, h, pixels, pitch);
-
- delete str;
- return ret;
-}
-
-void TouchControls::init(int width, int height) {
- _arrows_texture = loadBuiltinTexture("arrows.tga");
- _screen_width = width;
- _screen_height = height;
-}
-
-const uint _numRightKeycodes = 4;
-const Common::KeyCode _rightKeycodes[] = { Common::KEYCODE_i, Common::KEYCODE_p, Common::KEYCODE_u, Common::KEYCODE_e };
-
-void TouchControls::draw() {
- if (_joystickPressing != Common::KEYCODE_INVALID) {
- Common::Rect clip = clipFor(_joystickPressing);
- _arrows_texture->drawTexture(2 * _screen_width / 10, _screen_height / 2, 64, 64, clip);
- }
-
- if (_centerPressing != Common::KEYCODE_INVALID) {
- Common::Rect clip = clipFor(_centerPressing);
- _arrows_texture->drawTexture(_screen_width / 2, _screen_height / 2, 64, 64, clip);
- }
-
- if (_rightPressing != Common::KEYCODE_INVALID) {
- Common::Rect clip = clipFor(_rightPressing);
- _arrows_texture->drawTexture( 8 * _screen_width / 10, _screen_height / 2, 64, 64, clip);
- }
-}
-
-void TouchControls::update(int ptr, int action, int x, int y) {
- if (ptr > kNumPointers)
- return;
-
- TouchArea touchArea = (TouchArea) getTouchArea(x, y);
-
- switch (action) {
- case JACTION_POINTER_DOWN:
- case JACTION_DOWN:
- if (touchArea > kTouchAreaNone && -1 == pointerFor(touchArea)) {
- pointerFor(touchArea) = ptr;
- _pointers[ptr].active = true;
- _pointers[ptr].function = touchArea;
- _pointers[ptr].startX = _pointers[ptr].currentX = x;
- _pointers[ptr].startY = _pointers[ptr].currentY = y;
- // fall through to move case to initialize _{joy,center,right}Pressing
- } else {
- return;
- }
-
- case JACTION_MULTIPLE: {
- _pointers[ptr].currentX = x;
- _pointers[ptr].currentY = y;
- int dX = x - _pointers[ptr].startX;
- int dY = y - _pointers[ptr].startY;
-
- switch (_pointers[ptr].function) {
- case kTouchAreaJoystick: {
- Common::KeyCode newPressing = determineKey(dX, dY);
- if (newPressing != _joystickPressing) {
- keyUp(_joystickPressing);
- keyDown(newPressing);
- _joystickPressing = newPressing;
- } else if(abs(dY) > 150) {
- keyDown(Common::KEYCODE_LSHIFT);
- } else if(abs(dY) <= 150){
- keyUp(Common::KEYCODE_LSHIFT);
- }
- return;
- }
-
- case kTouchAreaCenter:
- _centerPressing = determineKey(dX, dY, Common::KEYCODE_RETURN);
- return;
-
- case kTouchAreaRight:
- _rightPressing = determineKey(dX, dY, Common::KEYCODE_i);
- switch (_rightPressing) {
- case Common::KEYCODE_LEFT:
- case Common::KEYCODE_RIGHT:
- _rightPressing = _rightKeycodes[abs(dX / 100) % _numRightKeycodes];
- break;
-
- case Common::KEYCODE_UP:
- _rightPressing = Common::KEYCODE_PAGEUP;
- break;
-
- case Common::KEYCODE_DOWN:
- _rightPressing = Common::KEYCODE_PAGEDOWN;
- break;
-
- default:
- break;
- }
-
- default:
- return;
- }
- return;
- }
-
- case JACTION_UP:
- case JACTION_POINTER_UP: {
- switch (_pointers[ptr].function) {
- case kTouchAreaJoystick:
- pointerFor(kTouchAreaJoystick) = -1;
- if (_joystickPressing != Common::KEYCODE_INVALID) {
- keyUp(_joystickPressing);
- _joystickPressing = Common::KEYCODE_INVALID;
- keyUp(Common::KEYCODE_LSHIFT);
- }
- break;
-
- case kTouchAreaCenter:
- pointerFor(kTouchAreaCenter) = -1;
- keyPress(_centerPressing);
- _centerPressing = Common::KEYCODE_INVALID;
- break;
-
- case kTouchAreaRight:
- pointerFor(kTouchAreaRight) = -1;
- keyPress(_rightPressing);
- _rightPressing = Common::KEYCODE_INVALID;
- break;
-
- case kTouchAreaNone:
- default:
- break;
- }
- _pointers[ptr].active = false;
- _pointers[ptr].function = kTouchAreaNone;
- return;
- }
- }
-}
-
-int &TouchControls::pointerFor(TouchArea ta) {
- return _activePointers[ta - kTouchAreaNone];
-}
-
-void TouchControls::keyDown(Common::KeyCode kc) {
- Common::Event ev;
- ev.type = Common::EVENT_KEYDOWN;
- ev.kbd.keycode = kc;
- dynamic_cast<OSystem_Android *>(g_system)->pushEvent(ev);
-}
-
-void TouchControls::keyUp(Common::KeyCode kc) {
- Common::Event ev;
- ev.type = Common::EVENT_KEYUP;
- ev.kbd.keycode = kc;
- dynamic_cast<OSystem_Android *>(g_system)->pushEvent(ev);
-}
-
-void TouchControls::keyPress(Common::KeyCode kc) {
- Common::Event ev;
- ev.kbd.keycode = kc;
- dynamic_cast<OSystem_Android *>(g_system)->pushKeyPressEvent(ev);
-}
-
-#endif
diff --git a/backends/platform/android3d/touchcontrols.h b/backends/platform/android3d/touchcontrols.h
deleted file mode 100644
index dc20a379bcd..00000000000
--- a/backends/platform/android3d/touchcontrols.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef ANDROID_TOUCHCONTROLS_H_
-#define ANDROID_TOUCHCONTROLS_H_
-
-#if defined(__ANDROID__)
-
-#include "common/events.h"
-
-#include "backends/platform/android3d/events.h"
-#include "backends/platform/android3d/texture.h"
-
-class TouchControls {
-public:
- TouchControls();
- ~TouchControls();
-
- void init(int width, int height);
- void draw();
- void update(int ptr, int action, int x, int y);
-
-private:
- int _screen_width, _screen_height;
-
- enum TouchArea{
- kTouchAreaJoystick = 0xffff,
- kTouchAreaCenter = 0xfffe,
- kTouchAreaRight = 0xfffd,
- kTouchAreaNone = 0xfffc,
- };
-
- uint16 getTouchArea(int x, int y);
-
- struct Pointer {
- uint16 startX, startY;
- uint16 currentX, currentY;
- TouchArea function;
- bool active;
- };
-
- enum { kNumPointers = 5 };
- Pointer _pointers[kNumPointers];
- int _activePointers[4];
- Common::KeyCode _joystickPressing, _centerPressing, _rightPressing;
- int &pointerFor(TouchArea ta);
- GLESTexture *_arrows_texture;
- void keyDown(Common::KeyCode kc);
- void keyUp(Common::KeyCode kc);
- void keyPress(Common::KeyCode kc);
-};
-
-#endif
-
-#endif
diff --git a/configure b/configure
index a0f66a21fbc..8aad4338e86 100755
--- a/configure
+++ b/configure
@@ -3166,9 +3166,7 @@ if test -n "$_host"; then
append_var LDFLAGS "-static-libstdc++"
HOSTEXEPRE=lib
HOSTEXEEXT=.so
- if test "$_backend" != android3d; then
- _backend="android"
- fi
+ _backend="android"
_port_mk="backends/platform/$_backend/android.mk"
_build_aspect=no
_seq_midi=no
@@ -3632,7 +3630,7 @@ fi
case $_backend in
3ds)
;;
- android | android3d)
+ android)
append_var DEFINES "-DREDUCE_MEMORY_USAGE"
append_var DEFINES "-DNONSTANDARD_PORT"
append_var INCLUDES '-I$(srcdir)/backends/platform/'$_backend
@@ -3919,7 +3917,7 @@ fi
# Enable 16bit support only for backends which support it
#
case $_backend in
- 3ds | android | android3d | androidsdl | dingux | dc | ds | gph | iphone | ios7 | maemo | null | opendingux | openpandora | psp | psp2 | samsungtv | sdl | switch | wii)
+ 3ds | android | androidsdl | dingux | dc | ds | gph | iphone | ios7 | maemo | null | opendingux | openpandora | psp | psp2 | samsungtv | sdl | switch | wii)
if test "$_16bit" = auto ; then
_16bit=yes
else
@@ -5370,11 +5368,6 @@ if test "$_opengl_mode" != none ; then
_opengl_mode=gles2
_opengl_glad=yes
;;
- android3d)
- # We require API level 16 while GLES2 APIs have been added in level 8 so we are safe for compilation
- _opengl_mode=gles2
- _opengl_glad=yes
- ;;
openpandora)
# Enable GLES only if user explicitely requested it
# Backend is SDL based so GLAD is supported
diff --git a/dists/android3d/AndroidManifest.xml b/dists/android3d/AndroidManifest.xml
deleted file mode 100644
index 5c36e6c1a88..00000000000
--- a/dists/android3d/AndroidManifest.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- NB: android:versionCode needs to be bumped for formal releases -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.residualvm.residualvm"
- android:sharedUserId="org.residualvm.residualvm">
-
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:required="true"/>
-
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" android:required="true"/>
- <uses-feature android:glEsVersion="0x00020000" android:required="true" />
-
- <application
- android:label="@string/app_name"
- android:description="@string/app_desc"
- android:allowBackup="false"
- android:icon="@drawable/residualvm"
- android:extractNativeLibs="false"
- android:isGame="true">
- <activity android:name=".ResidualVMActivity"
- android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
- android:screenOrientation="landscape"
- android:configChanges="orientation|keyboardHidden"
- android:windowSoftInputMode="adjustResize">
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- <category android:name="tv.ouya.intent.category.GAME"/>
- </intent-filter>
- </activity>
-
- </application>
-
-</manifest>
diff --git a/dists/android3d/assets/arrows.tga b/dists/android3d/assets/arrows.tga
deleted file mode 100644
index 1e168d31ecf..00000000000
Binary files a/dists/android3d/assets/arrows.tga and /dev/null differ
diff --git a/dists/android3d/build.gradle b/dists/android3d/build.gradle
deleted file mode 100644
index 40884e17c91..00000000000
--- a/dists/android3d/build.gradle
+++ /dev/null
@@ -1,63 +0,0 @@
-buildscript {
- repositories {
- google()
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:4.0.1'
- }
-}
-
-dependencies {
- repositories {
- google()
- jcenter()
- }
-}
-
-// Enable to see use of depracted API
-// tasks.withType(JavaCompile) {
-// options.compilerArgs << "-Xlint:deprecation"
-// }
-
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 29
- buildToolsVersion "29.0.3"
- ndkVersion "21.3.6528147"
-
- defaultConfig {
- applicationId "org.residualvm.residualvm"
-
- setProperty("archivesBaseName", "ResidualVM")
-
- minSdkVersion 16
- targetSdkVersion 28
-
- versionName "0.4"
- versionCode 50000
- }
- buildTypes {
- release {
- minifyEnabled false
- }
- }
- sourceSets {
- main {
- assets.srcDirs 'assets/'
- java.srcDirs srcdir + '/backends/platform/android3d/'
- jniLibs.srcDirs 'lib/'
- res.srcDirs srcdir + '/dists/android3d/res/'
- manifest.srcFile srcdir + '/dists/android3d/AndroidManifest.xml'
- }
- }
- lintOptions {
- abortOnError false
- }
-}
-
-dependencies {
-// implementation "androidx.annotation:annotation:1.1.0"
- implementation "com.android.support:appcompat-v7:28.0.0"
-}
diff --git a/dists/android3d/gradle/wrapper/gradle-wrapper.jar b/dists/android3d/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index f6b961fd5a8..00000000000
Binary files a/dists/android3d/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/dists/android3d/gradle/wrapper/gradle-wrapper.properties b/dists/android3d/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 84337ad35f1..00000000000
--- a/dists/android3d/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
diff --git a/dists/android3d/gradlew b/dists/android3d/gradlew
deleted file mode 100755
index cccdd3d517f..00000000000
--- a/dists/android3d/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/dists/android3d/jni/Android.mk b/dists/android3d/jni/Android.mk
deleted file mode 100644
index 0b3ee4d22e2..00000000000
--- a/dists/android3d/jni/Android.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-APP_ABI := $(ABI)
-LOCAL_MODULE := scummvm
-LOCAL_SRC_FILES := ../libscummvm.so
-
-include $(PREBUILT_SHARED_LIBRARY)
diff --git a/dists/android3d/res/drawable-hdpi/ic_action_keyboard.png b/dists/android3d/res/drawable-hdpi/ic_action_keyboard.png
deleted file mode 100644
index 059b334604e..00000000000
Binary files a/dists/android3d/res/drawable-hdpi/ic_action_keyboard.png and /dev/null differ
diff --git a/dists/android3d/res/drawable-hdpi/ic_action_settings.png b/dists/android3d/res/drawable-hdpi/ic_action_settings.png
deleted file mode 100644
index 331417509e4..00000000000
Binary files a/dists/android3d/res/drawable-hdpi/ic_action_settings.png and /dev/null differ
diff --git a/dists/android3d/res/drawable-mdpi/ic_action_keyboard.png b/dists/android3d/res/drawable-mdpi/ic_action_keyboard.png
deleted file mode 100644
index facbdd7ef57..00000000000
Binary files a/dists/android3d/res/drawable-mdpi/ic_action_keyboard.png and /dev/null differ
diff --git a/dists/android3d/res/drawable-mdpi/ic_action_settings.png b/dists/android3d/res/drawable-mdpi/ic_action_settings.png
deleted file mode 100644
index 72a68e7e188..00000000000
Binary files a/dists/android3d/res/drawable-mdpi/ic_action_settings.png and /dev/null differ
diff --git a/dists/android3d/res/drawable-xhdpi/ic_action_keyboard.png b/dists/android3d/res/drawable-xhdpi/ic_action_keyboard.png
deleted file mode 100644
index a054a3cf1f0..00000000000
Binary files a/dists/android3d/res/drawable-xhdpi/ic_action_keyboard.png and /dev/null differ
diff --git a/dists/android3d/res/drawable-xhdpi/ic_action_settings.png b/dists/android3d/res/drawable-xhdpi/ic_action_settings.png
deleted file mode 100644
index 7abca30fb39..00000000000
Binary files a/dists/android3d/res/drawable-xhdpi/ic_action_settings.png and /dev/null differ
diff --git a/dists/android3d/res/drawable-xxhdpi/ic_action_keyboard.png b/dists/android3d/res/drawable-xxhdpi/ic_action_keyboard.png
deleted file mode 100644
index 524bbb9d267..00000000000
Binary files a/dists/android3d/res/drawable-xxhdpi/ic_action_keyboard.png and /dev/null differ
diff --git a/dists/android3d/res/drawable-xxhdpi/ic_action_settings.png b/dists/android3d/res/drawable-xxhdpi/ic_action_settings.png
deleted file mode 100644
index 21a00b785cb..00000000000
Binary files a/dists/android3d/res/drawable-xxhdpi/ic_action_settings.png and /dev/null differ
diff --git a/dists/android3d/res/drawable/residualvm.png b/dists/android3d/res/drawable/residualvm.png
deleted file mode 100644
index fab66c708d4..00000000000
Binary files a/dists/android3d/res/drawable/residualvm.png and /dev/null differ
diff --git a/dists/android3d/res/drawable/residualvm_big.png b/dists/android3d/res/drawable/residualvm_big.png
deleted file mode 100644
index dd4d12520fd..00000000000
Binary files a/dists/android3d/res/drawable/residualvm_big.png and /dev/null differ
diff --git a/dists/android3d/res/layout/main.xml b/dists/android3d/res/layout/main.xml
deleted file mode 100644
index dd6496b7c5d..00000000000
--- a/dists/android3d/res/layout/main.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
-<org.residualvm.residualvm.EditableSurfaceView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/main_surface"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:keepScreenOn="true"
- android:focusable="true"
- android:focusableInTouchMode="true"
-/>
-
-<ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/ic_action_settings"
- android:id="@+id/options"
- android:layout_alignParentTop="true"
- android:layout_alignParentRight="true"
- android:layout_marginRight="10dp"
- android:layout_marginTop="10dp" />
-
- <HorizontalScrollView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/btns_scrollview"
- android:layout_alignParentBottom="true"
- android:layout_centerHorizontal="true"
- android:visibility="gone">
-
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center">
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Menu"
- android:id="@+id/menu_btn"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Inventory"
- android:id="@+id/inventory_btn"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"/>
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Pick up"
- android:id="@+id/pick_up_btn"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"/>
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Use"
- android:id="@+id/use_btn"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"/>
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Look at"
- android:id="@+id/look_at_btn"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"/>
-
- <ImageView
- android:id="@+id/show_keyboard"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="10dp"
- android:layout_marginRight="10dp"
- android:src="@drawable/ic_action_keyboard" />
-
- </LinearLayout>
- </HorizontalScrollView>
-
-</RelativeLayout>
-
diff --git a/dists/android3d/res/values/strings.xml b/dists/android3d/res/values/strings.xml
deleted file mode 100644
index d827b6cd66e..00000000000
--- a/dists/android3d/res/values/strings.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">ResidualVM</string>
- <string name="app_desc">3D adventure game interpreter</string>
- <string name="quit">Quit</string>
- <string name="residualvm_perm_plugin_label">ResidualVM plugin</string>
- <string name="residualvm_perm_plugin_desc">Allows the application to
- provide a ResidualVM loadable plugin: code that will be executed in the
- ResidualVM application. Malicious plugins may do anything ResidualVM
- itself could do: write to your SD card, delete your savegames,
- change the ResidualVM background to puce, replace menu labels with rude
- words, etc.</string>
- <string name="no_sdcard_title">No SD card?</string>
- <string name="no_sdcard">Unable to read your SD card. This usually
- means you still have it mounted on your PC. Unmount, reinsert,
- whatever and then try again.</string>
- <string name="no_plugins_title">No plugins found</string>
- <string name="no_plugins_found">ResidualVM requires at least one <i>game
- engine</i> to be useful. Engines are available as separate plugin
- packages, from wherever you found ResidualVM.</string>
- <string name="to_market">To Market</string>
-</resources>
More information about the Scummvm-git-logs
mailing list