Add hand-built on-screen keyboard to the OpenXR menu quad
build / build (push) Successful in 1m45s

MenuOverlay's key grid forwards every press to the game as real input:
non-printable keys (Esc/Enter/Backspace) as an SDLActivity.onNativeKeyDown()/
onNativeKeyUp() pair, and printable keys (letters, Space) as a synthesized
SDL_TEXTINPUT event pushed directly from native code, since the engine's
pump_events() only picks up printable ASCII from that event type, not from
SDL_KEYDOWN. Confirmed on-device, including that Space now correctly skips
the intro cutscene alongside Esc/Enter.
This commit is contained in:
ml
2026-08-05 08:11:16 +02:00
parent 1be0bebda2
commit 2d8fb49bf5
4 changed files with 269 additions and 31 deletions
@@ -7,9 +7,32 @@
#include <jni.h>
#include <unistd.h>
#include <SDL.h>
JNIEXPORT void JNICALL
Java_de_ladkau_questshock_QuestShockActivity_nativeChdir(JNIEnv *env, jclass clazz, jstring path) {
const char *cpath = (*env)->GetStringUTFChars(env, path, NULL);
chdir(cpath);
(*env)->ReleaseStringUTFChars(env, path, cpath);
}
// MenuOverlay's hand-built on-screen keyboard (see
// MenuOverlay.commitPrintableChar()) has no real Android IME session behind
// it, so printable characters can't reach the game via Android's usual IME
// path - instead this builds and pushes an SDL_TEXTINPUT event directly,
// the same event type/shape SDL's own Android backend pushes for typed
// text, using only the public SDL_Event/SDL_PushEvent API. The engine's
// pump_events() (sdl_events.c) only picks up printable characters from
// this event, not from SDL_KEYDOWN (see handleKeyPress() in MenuOverlay.java
// for why).
JNIEXPORT void JNICALL
Java_de_ladkau_questshock_MenuOverlay_nativeSendPrintableChar(JNIEnv *env, jclass clazz, jchar c) {
SDL_Event event;
SDL_zero(event);
event.type = SDL_TEXTINPUT;
event.text.timestamp = SDL_GetTicks();
event.text.windowID = 0;
event.text.text[0] = (char)c;
event.text.text[1] = '\0';
SDL_PushEvent(&event);
}