src/core/android/SDL_android.c
changeset 11655 ccf47d584003
parent 11653 4130b92b6be4
child 11662 a996f135cc81
equal deleted inserted replaced
11654:64ae77236054 11655:ccf47d584003
    28 #ifdef __ANDROID__
    28 #ifdef __ANDROID__
    29 
    29 
    30 #include "SDL_system.h"
    30 #include "SDL_system.h"
    31 #include "SDL_android.h"
    31 #include "SDL_android.h"
    32 #include <EGL/egl.h>
    32 #include <EGL/egl.h>
       
    33 
       
    34 #include "keyinfotable.h"
    33 
    35 
    34 #include "../../events/SDL_events_c.h"
    36 #include "../../events/SDL_events_c.h"
    35 #include "../../video/android/SDL_androidkeyboard.h"
    37 #include "../../video/android/SDL_androidkeyboard.h"
    36 #include "../../video/android/SDL_androidmouse.h"
    38 #include "../../video/android/SDL_androidmouse.h"
    37 #include "../../video/android/SDL_androidtouch.h"
    39 #include "../../video/android/SDL_androidtouch.h"
   747     SDL_SendKeyboardText(utftext);
   749     SDL_SendKeyboardText(utftext);
   748 
   750 
   749     (*env)->ReleaseStringUTFChars(env, text, utftext);
   751     (*env)->ReleaseStringUTFChars(env, text, utftext);
   750 }
   752 }
   751 
   753 
       
   754 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar)(
       
   755                                     JNIEnv* env, jclass cls,
       
   756                                     jchar chUnicode)
       
   757 {
       
   758     SDL_Scancode code = SDL_SCANCODE_UNKNOWN;
       
   759     uint16_t mod = 0;
       
   760 
       
   761     // We do not care about bigger than 127.
       
   762     if (chUnicode < 127) {
       
   763         AndroidKeyInfo info = unicharToAndroidKeyInfoTable[chUnicode];
       
   764         code = info.code;
       
   765         mod = info.mod;
       
   766     }
       
   767 
       
   768     if (mod & KMOD_SHIFT) {
       
   769         /* If character uses shift, press shift down */
       
   770         SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
       
   771     }
       
   772 
       
   773     /* send a keydown and keyup even for the character */
       
   774     SDL_SendKeyboardKey(SDL_PRESSED, code);
       
   775     SDL_SendKeyboardKey(SDL_RELEASED, code);
       
   776 
       
   777     if (mod & KMOD_SHIFT) {
       
   778         /* If character uses shift, press shift back up */
       
   779         SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
       
   780     }
       
   781 }
       
   782 
       
   783 
   752 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)(
   784 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)(
   753                                     JNIEnv* env, jclass cls,
   785                                     JNIEnv* env, jclass cls,
   754                                     jstring text, jint newCursorPosition)
   786                                     jstring text, jint newCursorPosition)
   755 {
   787 {
   756     const char *utftext = (*env)->GetStringUTFChars(env, text, NULL);
   788     const char *utftext = (*env)->GetStringUTFChars(env, text, NULL);