ANDROID: Add a button to show the virtual keyboard
This commit is contained in:
parent
c2054682f0
commit
12c232eefc
11 changed files with 99 additions and 3 deletions
|
@ -350,6 +350,7 @@ void OSystem_Android::initBackend() {
|
||||||
ConfMan.registerDefault("fullscreen", true);
|
ConfMan.registerDefault("fullscreen", true);
|
||||||
ConfMan.registerDefault("aspect_ratio", true);
|
ConfMan.registerDefault("aspect_ratio", true);
|
||||||
ConfMan.registerDefault("touchpad_mouse_mode", true);
|
ConfMan.registerDefault("touchpad_mouse_mode", true);
|
||||||
|
ConfMan.registerDefault("onscreen_control", true);
|
||||||
|
|
||||||
ConfMan.setInt("autosave_period", 0);
|
ConfMan.setInt("autosave_period", 0);
|
||||||
ConfMan.setBool("FM_high_quality", false);
|
ConfMan.setBool("FM_high_quality", false);
|
||||||
|
@ -360,6 +361,11 @@ void OSystem_Android::initBackend() {
|
||||||
else
|
else
|
||||||
ConfMan.setBool("touchpad_mouse_mode", true);
|
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
|
// must happen before creating TimerManager to avoid race in
|
||||||
// creating EventManager
|
// creating EventManager
|
||||||
setupKeymapper();
|
setupKeymapper();
|
||||||
|
@ -411,6 +417,7 @@ bool OSystem_Android::hasFeature(Feature f) {
|
||||||
f == kFeatureOverlaySupportsAlpha ||
|
f == kFeatureOverlaySupportsAlpha ||
|
||||||
f == kFeatureOpenUrl ||
|
f == kFeatureOpenUrl ||
|
||||||
f == kFeatureTouchpadMode ||
|
f == kFeatureTouchpadMode ||
|
||||||
|
f == kFeatureOnScreenControl ||
|
||||||
f == kFeatureClipboardSupport);
|
f == kFeatureClipboardSupport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,6 +446,10 @@ void OSystem_Android::setFeatureState(Feature f, bool enable) {
|
||||||
ConfMan.setBool("touchpad_mouse_mode", enable);
|
ConfMan.setBool("touchpad_mouse_mode", enable);
|
||||||
_touchpad_mode = enable;
|
_touchpad_mode = enable;
|
||||||
break;
|
break;
|
||||||
|
case kFeatureOnScreenControl:
|
||||||
|
ConfMan.setBool("onscreen_control", enable);
|
||||||
|
JNI::showKeyboardControl(enable);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -456,6 +467,8 @@ bool OSystem_Android::getFeatureState(Feature f) {
|
||||||
return _use_mouse_palette;
|
return _use_mouse_palette;
|
||||||
case kFeatureTouchpadMode:
|
case kFeatureTouchpadMode:
|
||||||
return ConfMan.getBool("touchpad_mouse_mode");
|
return ConfMan.getBool("touchpad_mouse_mode");
|
||||||
|
case kFeatureOnScreenControl:
|
||||||
|
return ConfMan.getBool("onscreen_control");
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,11 @@ RESOURCES = \
|
||||||
$(PATH_BUILD_RES)/drawable/scummvm.png \
|
$(PATH_BUILD_RES)/drawable/scummvm.png \
|
||||||
$(PATH_BUILD_RES)/drawable/scummvm_big.png \
|
$(PATH_BUILD_RES)/drawable/scummvm_big.png \
|
||||||
$(PATH_BUILD_RES)/drawable-xhdpi/leanback_icon.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_ANDROID_MK = $(PATH_DIST)/jni/Android.mk
|
||||||
DIST_BUILD_XML = $(PATH_DIST)/custom_rules.xml
|
DIST_BUILD_XML = $(PATH_DIST)/custom_rules.xml
|
||||||
|
|
|
@ -84,6 +84,7 @@ jmethodID JNI::_MID_setTextInClipboard = 0;
|
||||||
jmethodID JNI::_MID_isConnectionLimited = 0;
|
jmethodID JNI::_MID_isConnectionLimited = 0;
|
||||||
jmethodID JNI::_MID_setWindowCaption = 0;
|
jmethodID JNI::_MID_setWindowCaption = 0;
|
||||||
jmethodID JNI::_MID_showVirtualKeyboard = 0;
|
jmethodID JNI::_MID_showVirtualKeyboard = 0;
|
||||||
|
jmethodID JNI::_MID_showKeyboardControl = 0;
|
||||||
jmethodID JNI::_MID_getSysArchives = 0;
|
jmethodID JNI::_MID_getSysArchives = 0;
|
||||||
jmethodID JNI::_MID_initSurface = 0;
|
jmethodID JNI::_MID_initSurface = 0;
|
||||||
jmethodID JNI::_MID_deinitSurface = 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) {
|
void JNI::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
|
||||||
JNIEnv *env = JNI::getEnv();
|
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(, setTextInClipboard, "([B)Z");
|
||||||
FIND_METHOD(, isConnectionLimited, "()Z");
|
FIND_METHOD(, isConnectionLimited, "()Z");
|
||||||
FIND_METHOD(, showVirtualKeyboard, "(Z)V");
|
FIND_METHOD(, showVirtualKeyboard, "(Z)V");
|
||||||
|
FIND_METHOD(, showKeyboardControl, "(Z)V");
|
||||||
FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
|
FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
|
||||||
FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
|
FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
|
||||||
FIND_METHOD(, deinitSurface, "()V");
|
FIND_METHOD(, deinitSurface, "()V");
|
||||||
|
|
|
@ -64,6 +64,7 @@ public:
|
||||||
static bool setTextInClipboard(const Common::String &text);
|
static bool setTextInClipboard(const Common::String &text);
|
||||||
static bool isConnectionLimited();
|
static bool isConnectionLimited();
|
||||||
static void showVirtualKeyboard(bool enable);
|
static void showVirtualKeyboard(bool enable);
|
||||||
|
static void showKeyboardControl(bool enable);
|
||||||
static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
|
static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
|
||||||
|
|
||||||
static inline bool haveSurface();
|
static inline bool haveSurface();
|
||||||
|
@ -101,6 +102,7 @@ private:
|
||||||
static jmethodID _MID_isConnectionLimited;
|
static jmethodID _MID_isConnectionLimited;
|
||||||
static jmethodID _MID_setWindowCaption;
|
static jmethodID _MID_setWindowCaption;
|
||||||
static jmethodID _MID_showVirtualKeyboard;
|
static jmethodID _MID_showVirtualKeyboard;
|
||||||
|
static jmethodID _MID_showKeyboardControl;
|
||||||
static jmethodID _MID_getSysArchives;
|
static jmethodID _MID_getSysArchives;
|
||||||
static jmethodID _MID_initSurface;
|
static jmethodID _MID_initSurface;
|
||||||
static jmethodID _MID_deinitSurface;
|
static jmethodID _MID_deinitSurface;
|
||||||
|
|
|
@ -61,6 +61,7 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
|
||||||
abstract protected boolean isConnectionLimited();
|
abstract protected boolean isConnectionLimited();
|
||||||
abstract protected void setWindowCaption(String caption);
|
abstract protected void setWindowCaption(String caption);
|
||||||
abstract protected void showVirtualKeyboard(boolean enable);
|
abstract protected void showVirtualKeyboard(boolean enable);
|
||||||
|
abstract protected void showKeyboardControl(boolean enable);
|
||||||
abstract protected String[] getSysArchives();
|
abstract protected String[] getSysArchives();
|
||||||
|
|
||||||
public ScummVM(AssetManager asset_manager, SurfaceHolder holder) {
|
public ScummVM(AssetManager asset_manager, SurfaceHolder holder) {
|
||||||
|
|
|
@ -15,10 +15,12 @@ import android.os.Environment;
|
||||||
import android.text.ClipboardManager;
|
import android.text.ClipboardManager;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.io.File;
|
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 class MyScummVM extends ScummVM {
|
||||||
private boolean usingSmallScreen() {
|
private boolean usingSmallScreen() {
|
||||||
// Multiple screen sizes came in with Android 1.6. Have
|
// Multiple screen sizes came in with Android 1.6. Have
|
||||||
|
@ -150,6 +163,15 @@ public class ScummVMActivity extends Activity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void showKeyboardControl(final boolean enable) {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
showKeyboardView(enable);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getSysArchives() {
|
protected String[] getSysArchives() {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
|
@ -233,6 +255,9 @@ public class ScummVMActivity extends Activity {
|
||||||
_events = new ScummVMEventsHoneycomb(this, _scummvm, _mouseHelper);
|
_events = new ScummVMEventsHoneycomb(this, _scummvm, _mouseHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On screen button listener
|
||||||
|
((ImageView)findViewById(R.id.show_keyboard)).setOnClickListener(keyboardBtnOnClickListener);
|
||||||
|
|
||||||
main_surface.setOnKeyListener(_events);
|
main_surface.setOnKeyListener(_events);
|
||||||
main_surface.setOnTouchListener(_events);
|
main_surface.setOnTouchListener(_events);
|
||||||
|
|
||||||
|
@ -324,6 +349,25 @@ public class ScummVMActivity extends Activity {
|
||||||
InputMethodManager.HIDE_IMPLICIT_ONLY);
|
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) {
|
private void showMouseCursor(boolean show) {
|
||||||
/* Currently hiding the system mouse cursor is only
|
/* Currently hiding the system mouse cursor is only
|
||||||
supported on OUYA. If other systems provide similar
|
supported on OUYA. If other systems provide similar
|
||||||
|
|
BIN
dists/android/res/drawable-hdpi/ic_action_settings.png
Executable file
BIN
dists/android/res/drawable-hdpi/ic_action_settings.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 437 B |
BIN
dists/android/res/drawable-mdpi/ic_action_settings.png
Executable file
BIN
dists/android/res/drawable-mdpi/ic_action_settings.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 310 B |
BIN
dists/android/res/drawable-xhdpi/ic_action_settings.png
Executable file
BIN
dists/android/res/drawable-xhdpi/ic_action_settings.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 471 B |
BIN
dists/android/res/drawable-xxhdpi/ic_action_settings.png
Executable file
BIN
dists/android/res/drawable-xxhdpi/ic_action_settings.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 672 B |
|
@ -1,12 +1,29 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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
|
<org.scummvm.scummvm.EditableSurfaceView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/main_surface"
|
android:id="@+id/main_surface"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:keepScreenOn="true"
|
android:keepScreenOn="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:focusableInTouchMode="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>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue