JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jobject obj, jint p_scancode, jint p_unicode_char, jboolean p_pressed) { Ref<InputEventKey> ievent; int val = p_unicode_char; int scancode = android_get_keysym(p_scancode); ievent->set_scancode(scancode); ievent->set_unicode(val); ievent->set_pressed(p_pressed); print_line("Scancode: " + String::num(p_scancode) + ":" + String::num(ievent->get_scancode()) + " Unicode: " + String::num(val)); if (val == '\n') { ievent->set_scancode(KEY_ENTER); } else if (val == 61448) { ievent->set_scancode(KEY_BACKSPACE); ievent->set_unicode(KEY_BACKSPACE); } else if (val == 61453) { ievent->set_scancode(KEY_ENTER); ievent->set_unicode(KEY_ENTER); } else if (p_scancode == 4) { go_back_request = true; } input_mutex->lock(); key_events.push_back(ievent); input_mutex->unlock(); }
JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_key(JNIEnv * env, jobject obj, jint p_scancode, jint p_unicode_char, jboolean p_pressed) { InputEvent ievent; ievent.type = InputEvent::KEY; ievent.device = 0; int val = p_unicode_char; int scancode = android_get_keysym(p_scancode); ievent.key.scancode = scancode; ievent.key.unicode = val; ievent.key.pressed = p_pressed; print_line("Scancode: " + String::num(p_scancode) + ":" + String::num(ievent.key.scancode) + " Unicode: " + String::num(val)); ievent.key.mod.shift=false; ievent.key.mod.alt=false; ievent.key.mod.control=false; ievent.key.echo=false; if (val == '\n') { ievent.key.scancode = KEY_ENTER; }else if (val == 61448) { ievent.key.scancode = KEY_BACKSPACE; ievent.key.unicode = KEY_BACKSPACE; } else if (val == 61453) { ievent.key.scancode = KEY_ENTER; ievent.key.unicode = KEY_ENTER; } input_mutex->lock(); key_events.push_back(ievent); input_mutex->unlock(); };