From e34e40f4c19de5a2976aab5124e66384d815db6d Mon Sep 17 00:00:00 2001 From: pelya Date: Mon, 20 Dec 2010 11:18:27 +0000 Subject: [PATCH] Fix for on-screen keymapping dialog, it's still buggy yet --- project/java/Settings.java | 8 +++++--- project/jni/sdl-1.3/src/video/android/SDL_androidinput.c | 2 ++ .../sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c | 9 ++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/project/java/Settings.java b/project/java/Settings.java index 7ed80735d..7c3050cb5 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -1099,7 +1099,7 @@ class Settings nativeSetTouchscreenKeyboardUsed(); nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize, Globals.TouchscreenKeyboardTheme, - 7, // Globals.AppTouchscreenKeyboardKeysAmount, - set later by nativeSetScreenKbKeyUsed() + 8, // Globals.AppTouchscreenKeyboardKeysAmount, - set later by nativeSetScreenKbKeyUsed() Globals.AppTouchscreenKeyboardKeysAmountAutoFire, 1, //Globals.AppNeedsArrowKeys ? 1 : 0, 1 ); //Globals.AppNeedsTextInput ? 1 : 0 ); @@ -1113,8 +1113,10 @@ class Settings for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ ) { nativeSetScreenKbKeyUsed(i, Globals.ScreenKbControlsShown[i] ? 1 : 0); - if( i >= 2 ) - nativeSetKeymapKeyScreenKb(i, SDL_Keys.values[Globals.RemapScreenKbKeycode[i-2]]); + } + for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ ) + { + nativeSetKeymapKeyScreenKb(i, SDL_Keys.values[Globals.RemapScreenKbKeycode[i]]); } String lang = new String(Locale.getDefault().getLanguage()); diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c index a792119b4..55a851973 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c @@ -1329,6 +1329,7 @@ JAVA_EXPORT_NAME(Settings_nativeGetKeymapKeyScreenKb) ( JNIEnv* env, jobject th JNIEXPORT void JNICALL JAVA_EXPORT_NAME(Settings_nativeSetKeymapKeyScreenKb) ( JNIEnv* env, jobject thiz, jint keynum, jint key) { + __android_log_print(ANDROID_LOG_INFO, "libSDL", "nativeSetKeymapKeyScreenKb(): %d %d", keynum, key); if( keynum < 0 || keynum > SDL_ANDROID_SCREENKEYBOARD_BUTTON_5 - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0 + 4 ) return; @@ -1340,6 +1341,7 @@ JNIEXPORT void JNICALL JAVA_EXPORT_NAME(Settings_nativeSetScreenKbKeyUsed) ( JNIEnv* env, jobject thiz, jint keynum, jint used) { SDL_Rect rect = {0, 0, 0, 0}; + __android_log_print(ANDROID_LOG_INFO, "libSDL", "nativeSetScreenKbKeyUsed(): %d %d", keynum, used); int key = -1; if( keynum == 0 ) key = SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD; diff --git a/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c b/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c index 7b77d5a63..54d3e0ac1 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c +++ b/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c @@ -649,7 +649,7 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi int i, ii; int nbuttons1row, nbuttons2row; touchscreenKeyboardTheme = theme; - if( _nbuttons > MAX_BUTTONS ) + if( _nbuttons >= MAX_BUTTONS ) _nbuttons = MAX_BUTTONS; AutoFireButtonsNum = nbuttonsAutoFire; if( AutoFireButtonsNum > MAX_BUTTONS_AUTOFIRE ) @@ -736,6 +736,8 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi buttons[6].h = SDL_ANDROID_sWindowHeight/10; } + for( i = 0; i < MAX_BUTTONS; i++ ) + __android_log_print(ANDROID_LOG_INFO, "libSDL", "Settings_nativeSetupScreenKeyboard(): button %d pos %d %d %d %d", i, (int)buttons[i].x, (int)buttons[i].y, (int)buttons[i].w, (int)buttons[i].h); if( !showArrows ) { arrows.w = 0; @@ -761,6 +763,8 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi buttonsAutoFireRect[i].x = buttons[i].x - buttons[i].w / 2; buttonsAutoFireRect[i].y = buttons[i].y - buttons[i].h / 2; } + for( i = 0; i < MAX_BUTTONS; i++ ) + __android_log_print(ANDROID_LOG_INFO, "libSDL", "Settings_nativeSetupScreenKeyboard() 2: button %d pos %d %d %d %d", i, (int)buttons[i].x, (int)buttons[i].y, (int)buttons[i].w, (int)buttons[i].h); }; @@ -855,6 +859,7 @@ int SDL_ANDROID_SetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos) if( buttonId == SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD ) { arrows = *pos; + __android_log_print(ANDROID_LOG_INFO, "libSDL", "SetScreenKeyboardButtonPos(): arrows %dx%d-%dx%d", (int)pos->x, (int)pos->y, (int)pos->w, (int)pos->h); if(touchscreenKeyboardTheme == 0) { prepareFontCharWireframe(FONT_LEFT, arrows.w / 2, arrows.h / 2); @@ -866,6 +871,7 @@ int SDL_ANDROID_SetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos) else { buttons[buttonId - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0] = *pos; + __android_log_print(ANDROID_LOG_INFO, "libSDL", "SetScreenKeyboardButtonPos(): button %d %dx%d-%dx%d", buttonId - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, (int)pos->x, (int)pos->y, (int)pos->w, (int)pos->h); if(touchscreenKeyboardTheme == 0) { int i = buttonId - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0; @@ -895,6 +901,7 @@ int SDL_ANDROID_SetScreenKeyboardButtonKey(int buttonId, SDLKey key) { if( buttonId < SDL_ANDROID_SCREENKEYBOARD_BUTTON_0 || buttonId > SDL_ANDROID_SCREENKEYBOARD_BUTTON_5 || ! key ) return 0; + __android_log_print(ANDROID_LOG_INFO, "libSDL", "SetScreenKeyboardButtonKey(): %d %d", buttonId - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, key); buttonKeysyms[buttonId - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0] = key; return 1; };