SDL: new API to show built-in SDL keyboard, fixed built-in QWERTY keyboard

This commit is contained in:
Sergii Pylypenko
2015-11-02 21:57:22 +02:00
parent bdab723f36
commit 84765b2f5c
11 changed files with 309 additions and 81 deletions

View File

@@ -1,13 +1,12 @@
--- a/project/AndroidManifest.xml 2014-11-24 19:30:31.003274516 +0200
+++ b/project/AndroidManifest.xml 2014-11-24 19:30:33.547274398 +0200
@@ -28,7 +28,9 @@
@@ -45,6 +45,9 @@
<!-- <uses-permission android:name="android.permission.VIBRATE"></uses-permission> --> <!-- Vibrator not supported yet by SDL -->
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="21"/>
<!-- ==INTERNET== --> <uses-permission android:name="android.permission.INTERNET"></uses-permission>
-
+ <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
+ <uses-permission android:name="android.permission.CAMERA" />
+ <uses-feature android:name="android.hardware.camera" android:required="false" />
<!-- <uses-permission android:name="android.permission.VIBRATE"></uses-permission> --> <!-- Vibrator not supported yet by SDL -->
<uses-feature android:name="android.hardware.touchscreen" android:required="false" /> <!-- Allow TV boxes -->
<!-- ==SCREEN-SIZE-NORMAL== --> <supports-screens android:smallScreens="false" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />

View File

@@ -117,6 +117,16 @@ extern DECLSPEC int SDLCALL SDL_ANDROID_ToggleScreenKeyboardTextInput(const char
/* Show only the bare Android QWERTY keyboard without any text input field, so it won't cover the screen */
extern DECLSPEC int SDLCALL SDL_ANDROID_ToggleScreenKeyboardWithoutTextInput(void);
typedef enum
{
SDL_KEYBOARD_QWERTY = 1,
SDL_KEYBOARD_COMMODORE = 2,
SDL_KEYBOARD_AMIGA = 3,
SDL_KEYBOARD_ATARI800 = 4,
} SDL_InternalKeyboard_t;
/* Show internal keyboard, built into SDL */
extern DECLSPEC int SDLCALL SDL_ANDROID_ToggleInternalScreenKeyboard(SDL_InternalKeyboard_t keyboard);
/* Show Android QWERTY keyboard, and pass entered text back to application in a buffer,
using buffer contents as previous text (UTF-8 encoded), the buffer may be of any size -
this call will block until user typed all text. */

View File

@@ -72,6 +72,7 @@ static jobject JavaRenderer = NULL;
static jmethodID JavaSwapBuffers = NULL;
static jmethodID JavaShowScreenKeyboard = NULL;
static jmethodID JavaToggleScreenKeyboardWithoutTextInput = NULL;
static jmethodID JavaToggleInternalScreenKeyboard = NULL;
static jmethodID JavaHideScreenKeyboard = NULL;
static jmethodID JavaIsScreenKeyboardShown = NULL;
static jmethodID JavaSetScreenKeyboardHintMessage = NULL;
@@ -238,6 +239,12 @@ int SDL_ANDROID_ToggleScreenKeyboardWithoutTextInput(void)
return 1;
}
int SDL_ANDROID_ToggleInternalScreenKeyboard(SDL_InternalKeyboard_t keyboard)
{
(*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaToggleInternalScreenKeyboard, (jint)keyboard );
return 1;
}
#if SDL_VERSION_ATLEAST(1,3,0)
#else
extern int SDL_Flip(SDL_Surface *screen);
@@ -333,6 +340,7 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
JavaSwapBuffers = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "swapBuffers", "()I");
JavaShowScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboard", "(Ljava/lang/String;I)V");
JavaToggleScreenKeyboardWithoutTextInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboardWithoutTextInputField", "()V");
JavaToggleInternalScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showInternalScreenKeyboard", "(I)V");
JavaHideScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "hideScreenKeyboard", "()V");
JavaIsScreenKeyboardShown = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "isScreenKeyboardShown", "()I");
JavaSetScreenKeyboardHintMessage = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "setScreenKeyboardHintMessage", "(Ljava/lang/String;)V");

View File

@@ -241,6 +241,9 @@ void SDL_android_init_keymap(SDLKey *SDL_android_keymap)
keymap[KEYCODE_BUTTON_14] = SDL_KEY(N);
keymap[KEYCODE_BUTTON_15] = SDL_KEY(O);
keymap[KEYCODE_BUTTON_16] = SDL_KEY(P);
keymap[KEYCODE_MEDIA_TOP_MENU] = SDL_KEY(MENU);
keymap[KEYCODE_TV_CONTENTS_MENU] = SDL_KEY(MENU);
keymap[KEYCODE_TV_MEDIA_CONTEXT_MENU] = SDL_KEY(MENU);
keymap[KEYCODE_MOUSE_LEFT] = SDL_KEY(MOUSE_LEFT);
keymap[KEYCODE_MOUSE_MIDDLE] = SDL_KEY(MOUSE_MIDDLE);