Refactored code to send scancodes for an ASCII on-screen keyboard key

This commit is contained in:
Sam Lantinga
2022-06-29 17:26:09 -07:00
parent a054a5f7f2
commit 0ad65277ce
7 changed files with 205 additions and 405 deletions

View File

@@ -31,8 +31,6 @@
#include "SDL_system.h"
#include "SDL_android.h"
#include "keyinfotable.h"
#include "../../events/SDL_events_c.h"
#include "../../video/android/SDL_androidkeyboard.h"
#include "../../video/android/SDL_androidmouse.h"
@@ -1270,29 +1268,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancod
JNIEnv *env, jclass cls,
jchar chUnicode)
{
SDL_Scancode code = SDL_SCANCODE_UNKNOWN;
uint16_t mod = 0;
/* We do not care about bigger than 127. */
if (chUnicode < 127) {
AndroidKeyInfo info = unicharToAndroidKeyInfoTable[chUnicode];
code = info.code;
mod = info.mod;
}
if (mod & KMOD_SHIFT) {
/* If character uses shift, press shift down */
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
}
/* send a keydown and keyup even for the character */
SDL_SendKeyboardKey(SDL_PRESSED, code);
SDL_SendKeyboardKey(SDL_RELEASED, code);
if (mod & KMOD_SHIFT) {
/* If character uses shift, press shift back up */
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
}
SDL_SendKeyboardUnicodeKey(chUnicode);
}
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)(