aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Cawley2019-08-18 22:58:13 +0100
committerFilippos Karapetis2019-08-20 14:32:50 +0300
commit12c232eefc7c78f7d40da9894e395dee4ce6d8c2 (patch)
tree5a00b4bb1754d4fe6d2f6608851312206475f313
parentc2054682f0f20ad284582b0717d0298df401a228 (diff)
downloadscummvm-rg350-12c232eefc7c78f7d40da9894e395dee4ce6d8c2.tar.gz
scummvm-rg350-12c232eefc7c78f7d40da9894e395dee4ce6d8c2.tar.bz2
scummvm-rg350-12c232eefc7c78f7d40da9894e395dee4ce6d8c2.zip
ANDROID: Add a button to show the virtual keyboard
-rw-r--r--backends/platform/android/android.cpp13
-rw-r--r--backends/platform/android/android.mk6
-rw-r--r--backends/platform/android/jni.cpp15
-rw-r--r--backends/platform/android/jni.h2
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVM.java1
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java44
-rwxr-xr-xdists/android/res/drawable-hdpi/ic_action_settings.pngbin0 -> 437 bytes
-rwxr-xr-xdists/android/res/drawable-mdpi/ic_action_settings.pngbin0 -> 310 bytes
-rwxr-xr-xdists/android/res/drawable-xhdpi/ic_action_settings.pngbin0 -> 471 bytes
-rwxr-xr-xdists/android/res/drawable-xxhdpi/ic_action_settings.pngbin0 -> 672 bytes
-rw-r--r--dists/android/res/layout/main.xml21
11 files changed, 99 insertions, 3 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index f3dc0b5876..2ae36c8073 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -350,6 +350,7 @@ void OSystem_Android::initBackend() {
ConfMan.registerDefault("fullscreen", true);
ConfMan.registerDefault("aspect_ratio", true);
ConfMan.registerDefault("touchpad_mouse_mode", true);
+ ConfMan.registerDefault("onscreen_control", true);
ConfMan.setInt("autosave_period", 0);
ConfMan.setBool("FM_high_quality", false);
@@ -360,6 +361,11 @@ void OSystem_Android::initBackend() {
else
ConfMan.setBool("touchpad_mouse_mode", true);
+ if (ConfMan.hasKey("onscreen_control"))
+ JNI::showKeyboardControl(ConfMan.getBool("onscreen_control"));
+ else
+ ConfMan.setBool("onscreen_control", true);
+
// must happen before creating TimerManager to avoid race in
// creating EventManager
setupKeymapper();
@@ -411,6 +417,7 @@ bool OSystem_Android::hasFeature(Feature f) {
f == kFeatureOverlaySupportsAlpha ||
f == kFeatureOpenUrl ||
f == kFeatureTouchpadMode ||
+ f == kFeatureOnScreenControl ||
f == kFeatureClipboardSupport);
}
@@ -439,6 +446,10 @@ void OSystem_Android::setFeatureState(Feature f, bool enable) {
ConfMan.setBool("touchpad_mouse_mode", enable);
_touchpad_mode = enable;
break;
+ case kFeatureOnScreenControl:
+ ConfMan.setBool("onscreen_control", enable);
+ JNI::showKeyboardControl(enable);
+ break;
default:
break;
}
@@ -456,6 +467,8 @@ bool OSystem_Android::getFeatureState(Feature f) {
return _use_mouse_palette;
case kFeatureTouchpadMode:
return ConfMan.getBool("touchpad_mouse_mode");
+ case kFeatureOnScreenControl:
+ return ConfMan.getBool("onscreen_control");
default:
return false;
}
diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk
index b5f559c3a4..eaae5dd3dd 100644
--- a/backends/platform/android/android.mk
+++ b/backends/platform/android/android.mk
@@ -21,7 +21,11 @@ RESOURCES = \
$(PATH_BUILD_RES)/drawable/scummvm.png \
$(PATH_BUILD_RES)/drawable/scummvm_big.png \
$(PATH_BUILD_RES)/drawable-xhdpi/leanback_icon.png \
- $(PATH_BUILD_RES)/drawable-xhdpi/ouya_icon.png
+ $(PATH_BUILD_RES)/drawable-xhdpi/ouya_icon.png \
+ $(PATH_BUILD_RES)/drawable-hdpi/ic_action_settings.png \
+ $(PATH_BUILD_RES)/drawable-mdpi/ic_action_settings.png \
+ $(PATH_BUILD_RES)/drawable-xhdpi/ic_action_settings.png \
+ $(PATH_BUILD_RES)/drawable-xxhdpi/ic_action_settings.png
DIST_ANDROID_MK = $(PATH_DIST)/jni/Android.mk
DIST_BUILD_XML = $(PATH_DIST)/custom_rules.xml
diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp
index ffe60062fb..905423a5a6 100644
--- a/backends/platform/android/jni.cpp
+++ b/backends/platform/android/jni.cpp
@@ -84,6 +84,7 @@ jmethodID JNI::_MID_setTextInClipboard = 0;
jmethodID JNI::_MID_isConnectionLimited = 0;
jmethodID JNI::_MID_setWindowCaption = 0;
jmethodID JNI::_MID_showVirtualKeyboard = 0;
+jmethodID JNI::_MID_showKeyboardControl = 0;
jmethodID JNI::_MID_getSysArchives = 0;
jmethodID JNI::_MID_initSurface = 0;
jmethodID JNI::_MID_deinitSurface = 0;
@@ -361,6 +362,19 @@ void JNI::showVirtualKeyboard(bool enable) {
}
}
+void JNI::showKeyboardControl(bool enable) {
+ JNIEnv *env = JNI::getEnv();
+
+ env->CallVoidMethod(_jobj, _MID_showKeyboardControl, enable);
+
+ if (env->ExceptionCheck()) {
+ LOGE("Error trying to show virtual keyboard control");
+
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ }
+}
+
void JNI::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
JNIEnv *env = JNI::getEnv();
@@ -517,6 +531,7 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
FIND_METHOD(, setTextInClipboard, "([B)Z");
FIND_METHOD(, isConnectionLimited, "()Z");
FIND_METHOD(, showVirtualKeyboard, "(Z)V");
+ FIND_METHOD(, showKeyboardControl, "(Z)V");
FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
FIND_METHOD(, deinitSurface, "()V");
diff --git a/backends/platform/android/jni.h b/backends/platform/android/jni.h
index e65e7f5dc8..aa89174dfc 100644
--- a/backends/platform/android/jni.h
+++ b/backends/platform/android/jni.h
@@ -64,6 +64,7 @@ public:
static bool setTextInClipboard(const Common::String &text);
static bool isConnectionLimited();
static void showVirtualKeyboard(bool enable);
+ static void showKeyboardControl(bool enable);
static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
static inline bool haveSurface();
@@ -101,6 +102,7 @@ private:
static jmethodID _MID_isConnectionLimited;
static jmethodID _MID_setWindowCaption;
static jmethodID _MID_showVirtualKeyboard;
+ static jmethodID _MID_showKeyboardControl;
static jmethodID _MID_getSysArchives;
static jmethodID _MID_initSurface;
static jmethodID _MID_deinitSurface;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index 7b6627f667..37fe76ebda 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -61,6 +61,7 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
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();
public ScummVM(AssetManager asset_manager, SurfaceHolder holder) {
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 58af703d56..7bb0fe8057 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -15,10 +15,12 @@ import android.os.Environment;
import android.text.ClipboardManager;
import android.util.DisplayMetrics;
import android.util.Log;
+import android.view.View;
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 java.io.File;
@@ -39,6 +41,17 @@ public class ScummVMActivity extends Activity {
}
}
+ public View.OnClickListener keyboardBtnOnClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ runOnUiThread(new Runnable() {
+ public void run() {
+ toggleKeyboard();
+ }
+ });
+ }
+ };
+
private class MyScummVM extends ScummVM {
private boolean usingSmallScreen() {
// Multiple screen sizes came in with Android 1.6. Have
@@ -151,6 +164,15 @@ public class ScummVMActivity extends Activity {
}
@Override
+ protected void showKeyboardControl(final boolean enable) {
+ runOnUiThread(new Runnable() {
+ public void run() {
+ showKeyboardView(enable);
+ }
+ });
+ }
+
+ @Override
protected String[] getSysArchives() {
return new String[0];
}
@@ -233,6 +255,9 @@ public class ScummVMActivity extends Activity {
_events = new ScummVMEventsHoneycomb(this, _scummvm, _mouseHelper);
}
+ // On screen button listener
+ ((ImageView)findViewById(R.id.show_keyboard)).setOnClickListener(keyboardBtnOnClickListener);
+
main_surface.setOnKeyListener(_events);
main_surface.setOnTouchListener(_events);
@@ -324,6 +349,25 @@ public class ScummVMActivity extends Activity {
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
diff --git a/dists/android/res/drawable-hdpi/ic_action_settings.png b/dists/android/res/drawable-hdpi/ic_action_settings.png
new file mode 100755
index 0000000000..d9733250f5
--- /dev/null
+++ b/dists/android/res/drawable-hdpi/ic_action_settings.png
Binary files differ
diff --git a/dists/android/res/drawable-mdpi/ic_action_settings.png b/dists/android/res/drawable-mdpi/ic_action_settings.png
new file mode 100755
index 0000000000..8987358021
--- /dev/null
+++ b/dists/android/res/drawable-mdpi/ic_action_settings.png
Binary files differ
diff --git a/dists/android/res/drawable-xhdpi/ic_action_settings.png b/dists/android/res/drawable-xhdpi/ic_action_settings.png
new file mode 100755
index 0000000000..fb8f3343c8
--- /dev/null
+++ b/dists/android/res/drawable-xhdpi/ic_action_settings.png
Binary files differ
diff --git a/dists/android/res/drawable-xxhdpi/ic_action_settings.png b/dists/android/res/drawable-xxhdpi/ic_action_settings.png
new file mode 100755
index 0000000000..51f7527789
--- /dev/null
+++ b/dists/android/res/drawable-xxhdpi/ic_action_settings.png
Binary files differ
diff --git a/dists/android/res/layout/main.xml b/dists/android/res/layout/main.xml
index 8b0d515d62..fa4bb66af9 100644
--- a/dists/android/res/layout/main.xml
+++ b/dists/android/res/layout/main.xml
@@ -1,12 +1,29 @@
<?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.scummvm.scummvm.EditableSurfaceView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_surface"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
+ 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/show_keyboard"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentRight="true"
+ android:layout_marginRight="10dp"
+ android:layout_marginTop="10dp" />
+
+</RelativeLayout>