diff --git a/backends/graphics/android/android-graphics.cpp b/backends/graphics/android/android-graphics.cpp index 27d1e7bb3fb..2e76100bc58 100644 --- a/backends/graphics/android/android-graphics.cpp +++ b/backends/graphics/android/android-graphics.cpp @@ -161,6 +161,25 @@ bool AndroidGraphicsManager::showMouse(bool visible) { return last; } +void AndroidGraphicsManager::showOverlay() { + if (_overlayVisible) + return; + + _old_touch_3d_mode = JNI::getTouch3DMode(); + JNI::setTouch3DMode(false); + + OpenGL::OpenGLGraphicsManager::showOverlay(); +} + +void AndroidGraphicsManager::hideOverlay() { + if (!_overlayVisible) + return; + + JNI::setTouch3DMode(_old_touch_3d_mode); + + OpenGL::OpenGLGraphicsManager::hideOverlay(); +} + float AndroidGraphicsManager::getHiDPIScreenFactor() const { // TODO: Use JNI to get DisplayMetrics.density, which according to the documentation // seems to be what we want. diff --git a/backends/graphics/android/android-graphics.h b/backends/graphics/android/android-graphics.h index 76e493acc50..beb0a58ae58 100644 --- a/backends/graphics/android/android-graphics.h +++ b/backends/graphics/android/android-graphics.h @@ -91,6 +91,10 @@ protected: void setSystemMousePosition(const int x, const int y) override {} bool showMouse(bool visible) override; + void showOverlay() override; + void hideOverlay() override; + + bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format) override; void refreshScreen() override; @@ -99,6 +103,7 @@ protected: private: OpenGL::Surface *_touchcontrols; + bool _old_touch_3d_mode; }; #endif diff --git a/backends/graphics3d/android/android-graphics3d.cpp b/backends/graphics3d/android/android-graphics3d.cpp index b53980f3434..ea78e61b755 100644 --- a/backends/graphics3d/android/android-graphics3d.cpp +++ b/backends/graphics3d/android/android-graphics3d.cpp @@ -92,7 +92,8 @@ AndroidGraphics3dManager::AndroidGraphics3dManager() : _mouse_hotspot(), _mouse_dont_scale(false), _show_mouse(false), - _touchcontrols_texture(nullptr) { + _touchcontrols_texture(nullptr), + _old_touch_3d_mode(false) { if (JNI::egl_bits_per_pixel == 16) { // We default to RGB565 and RGBA5551 which is closest to what we setup in Java side @@ -456,6 +457,7 @@ void AndroidGraphics3dManager::showOverlay() { return; } + _old_touch_3d_mode = JNI::getTouch3DMode(); JNI::setTouch3DMode(false); _show_overlay = true; @@ -502,7 +504,7 @@ void AndroidGraphics3dManager::hideOverlay() { _overlay_background->release(); - JNI::setTouch3DMode(true); + JNI::setTouch3DMode(_old_touch_3d_mode); warpMouse(_game_texture->width() / 2, _game_texture->height() / 2); diff --git a/backends/graphics3d/android/android-graphics3d.h b/backends/graphics3d/android/android-graphics3d.h index c61cba89754..616d80fc0d1 100644 --- a/backends/graphics3d/android/android-graphics3d.h +++ b/backends/graphics3d/android/android-graphics3d.h @@ -185,6 +185,7 @@ private: // Touch controls layer GLESTexture *_touchcontrols_texture; + bool _old_touch_3d_mode; }; #endif diff --git a/backends/platform/android/jni-android.cpp b/backends/platform/android/jni-android.cpp index 98b00cf1d65..d8eb3d689eb 100644 --- a/backends/platform/android/jni-android.cpp +++ b/backends/platform/android/jni-android.cpp @@ -89,6 +89,7 @@ jmethodID JNI::_MID_showVirtualKeyboard = 0; jmethodID JNI::_MID_showKeyboardControl = 0; jmethodID JNI::_MID_getBitmapResource = 0; jmethodID JNI::_MID_setTouch3DMode = 0; +jmethodID JNI::_MID_getTouch3DMode = 0; jmethodID JNI::_MID_showSAFRevokePermsControl = 0; jmethodID JNI::_MID_getSysArchives = 0; jmethodID JNI::_MID_getAllStorageLocations = 0; @@ -464,13 +465,28 @@ void JNI::setTouch3DMode(bool touch3DMode) { env->CallVoidMethod(_jobj, _MID_setTouch3DMode, touch3DMode); if (env->ExceptionCheck()) { - LOGE("Error trying to show virtual keyboard control"); + LOGE("Error trying to set touch controls mode"); env->ExceptionDescribe(); env->ExceptionClear(); } } +bool JNI::getTouch3DMode() { + JNIEnv *env = JNI::getEnv(); + + bool enabled = env->CallBooleanMethod(_jobj, _MID_getTouch3DMode); + + if (env->ExceptionCheck()) { + LOGE("Error trying to get touch controls status"); + + env->ExceptionDescribe(); + env->ExceptionClear(); + } + + return enabled; +} + void JNI::showSAFRevokePermsControl(bool enable) { #ifndef BACKEND_ANDROID3D JNIEnv *env = JNI::getEnv(); @@ -658,6 +674,7 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager, FIND_METHOD(, showKeyboardControl, "(Z)V"); FIND_METHOD(, getBitmapResource, "(I)Landroid/graphics/Bitmap;"); FIND_METHOD(, setTouch3DMode, "(Z)V"); + FIND_METHOD(, getTouch3DMode, "()Z"); FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;"); FIND_METHOD(, getAllStorageLocations, "()[Ljava/lang/String;"); FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;"); diff --git a/backends/platform/android/jni-android.h b/backends/platform/android/jni-android.h index ad4c63ac7b9..d3afb71f2e7 100644 --- a/backends/platform/android/jni-android.h +++ b/backends/platform/android/jni-android.h @@ -78,6 +78,7 @@ public: static void showKeyboardControl(bool enable); static Graphics::Surface *getBitmapResource(BitmapResources resource); static void setTouch3DMode(bool touch3DMode); + static bool getTouch3DMode(); static void showSAFRevokePermsControl(bool enable); static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority); @@ -126,6 +127,7 @@ private: static jmethodID _MID_showKeyboardControl; static jmethodID _MID_getBitmapResource; static jmethodID _MID_setTouch3DMode; + static jmethodID _MID_getTouch3DMode; static jmethodID _MID_showSAFRevokePermsControl; static jmethodID _MID_getSysArchives; static jmethodID _MID_getAllStorageLocations; diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java index 41dca1cab89..c042a9d6183 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java @@ -75,6 +75,7 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable { abstract protected void showKeyboardControl(boolean enable); abstract protected Bitmap getBitmapResource(int resource); abstract protected void setTouch3DMode(boolean touch3DMode); + abstract protected boolean getTouch3DMode(); abstract protected void showSAFRevokePermsControl(boolean enable); abstract protected String[] getSysArchives(); abstract protected String[] getAllStorageLocations(); diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java index 23e565abfef..18b537643ee 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java @@ -751,6 +751,11 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis }); } + @Override + protected boolean getTouch3DMode() { + return _events.getTouch3DMode(); + } + @Override protected void showSAFRevokePermsControl(final boolean enable) { runOnUiThread(new Runnable() {