diff options
Diffstat (limited to 'backends/platform/android')
-rw-r--r-- | backends/platform/android/android.cpp | 1 | ||||
-rw-r--r-- | backends/platform/android/android.h | 2 | ||||
-rw-r--r-- | backends/platform/android/asset-archive.cpp | 8 | ||||
-rw-r--r-- | backends/platform/android/asset-archive.h | 6 | ||||
-rw-r--r-- | backends/platform/android/events.cpp | 42 | ||||
-rw-r--r-- | backends/platform/android/texture.cpp | 2 |
6 files changed, 40 insertions, 21 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index aba31320ea..902599d50f 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -134,6 +134,7 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) : _enable_zoning(false), _mixer(0), _shake_offset(0), + _queuedEventTime(0), _event_queue_lock(createMutex()), _touch_pt_down(), _touch_pt_scroll(), diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index f39a8f1144..47a6515a2a 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -220,6 +220,8 @@ public: private: Common::Queue<Common::Event> _event_queue; + Common::Event _queuedEvent; + uint32 _queuedEventTime; MutexRef _event_queue_lock; Common::Point _touch_pt_down, _touch_pt_scroll, _touch_pt_dt; diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp index fe52a3d8d4..14840de996 100644 --- a/backends/platform/android/asset-archive.cpp +++ b/backends/platform/android/asset-archive.cpp @@ -103,7 +103,7 @@ JavaInputStream::JavaInputStream(JNIEnv *env, jobject is) : MID_mark = env->GetMethodID(cls, "mark", "(I)V"); assert(MID_mark); MID_available = env->GetMethodID(cls, "available", "()I"); - assert(MID_mark); + assert(MID_available); MID_close = env->GetMethodID(cls, "close", "()V"); assert(MID_close); MID_read = env->GetMethodID(cls, "read", "([BII)I"); @@ -389,7 +389,7 @@ AndroidAssetArchive::~AndroidAssetArchive() { env->DeleteGlobalRef(_am); } -bool AndroidAssetArchive::hasFile(const Common::String &name) { +bool AndroidAssetArchive::hasFile(const Common::String &name) const { JNIEnv *env = JNI::getEnv(); jstring path = env->NewStringUTF(name.c_str()); jobject result = env->CallObjectMethod(_am, MID_open, path, ACCESS_UNKNOWN); @@ -409,7 +409,7 @@ bool AndroidAssetArchive::hasFile(const Common::String &name) { return true; } -int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) { +int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) const { JNIEnv *env = JNI::getEnv(); Common::List<Common::String> dirlist; dirlist.push_back(""); @@ -466,7 +466,7 @@ int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) { return count; } -Common::ArchiveMemberPtr AndroidAssetArchive::getMember(const Common::String &name) { +const Common::ArchiveMemberPtr AndroidAssetArchive::getMember(const Common::String &name) const { return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); } diff --git a/backends/platform/android/asset-archive.h b/backends/platform/android/asset-archive.h index 9216412e0a..c5e43555e0 100644 --- a/backends/platform/android/asset-archive.h +++ b/backends/platform/android/asset-archive.h @@ -37,9 +37,9 @@ public: AndroidAssetArchive(jobject am); virtual ~AndroidAssetArchive(); - virtual bool hasFile(const Common::String &name); - virtual int listMembers(Common::ArchiveMemberList &list); - virtual Common::ArchiveMemberPtr getMember(const Common::String &name); + virtual bool hasFile(const Common::String &name) const; + virtual int listMembers(Common::ArchiveMemberList &list) const; + virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; private: diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index 2a16e69411..21d2344fa7 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -211,36 +211,35 @@ static const Common::KeyCode jkeymap[] = { }; // floating point. use sparingly -template <class T> +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(); - HardwareKeySet *keySet = new HardwareKeySet(); + HardwareInputSet *inputSet = new HardwareInputSet(); - keySet->addHardwareKey( - new HardwareKey("n", KeyState(KEYCODE_n), "n (vk)", - kTriggerLeftKeyType, - kVirtualKeyboardActionType)); + keySet->addHardwareInput( + new HardwareInput("n", KeyState(KEYCODE_n), "n (vk)")); - mapper->registerHardwareKeySet(keySet); + mapper->registerHardwareInputSet(inputSet); - Keymap *globalMap = new Keymap("global"); + Keymap *globalMap = new Keymap(kGlobalKeymapName); Action *act; - act = new Action(globalMap, "VIRT", "Display keyboard", - kVirtualKeyboardActionType); + act = new Action(globalMap, "VIRT", "Display keyboard"); act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0)); mapper->addGlobalKeymap(globalMap); - mapper->pushKeymap("global"); + mapper->pushKeymap(kGlobalKeymapName); #endif } @@ -601,13 +600,18 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, lockMutex(_event_queue_lock); + if (_queuedEventTime) + _event_queue.push(_queuedEvent); + if (!_touchpad_mode) _event_queue.push(e); e.type = down; _event_queue.push(e); + e.type = up; - _event_queue.push(e); + _queuedEvent = e; + _queuedEventTime = getMillis() + kQueuedInputEventDelay; unlockMutex(_event_queue_lock); } @@ -702,9 +706,14 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, lockMutex(_event_queue_lock); + if (_queuedEventTime) + _event_queue.push(_queuedEvent); + _event_queue.push(e); + e.type = up; - _event_queue.push(e); + _queuedEvent = e; + _queuedEventTime = getMillis() + kQueuedInputEventDelay; unlockMutex(_event_queue_lock); return; @@ -800,6 +809,13 @@ bool OSystem_Android::pollEvent(Common::Event &event) { lockMutex(_event_queue_lock); + if (_queuedEventTime && (getMillis() > _queuedEventTime)) { + event = _queuedEvent; + _queuedEventTime = 0; + unlockMutex(_event_queue_lock); + return true; + } + if (_event_queue.empty()) { unlockMutex(_event_queue_lock); return false; diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index e211e5941f..95c96e0d25 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -61,7 +61,7 @@ static inline GLfixed xdiv(int numerator, int denominator) { return (numerator << 16) / denominator; } -template <class T> +template<class T> static T nextHigher2(T k) { if (k == 0) return 1; |