Merge pull request #17801 from endragor/android-input-checks
Add safety checks when handling Android input
This commit is contained in:
commit
bba80721dc
1 changed files with 23 additions and 4 deletions
|
@ -936,6 +936,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *en
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jobject obj) {
|
||||
if (step == 0)
|
||||
return;
|
||||
|
||||
os_android->main_loop_request_go_back();
|
||||
}
|
||||
|
||||
|
@ -976,6 +979,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job
|
|||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch(JNIEnv *env, jobject obj, jint ev, jint pointer, jint count, jintArray positions) {
|
||||
|
||||
if (step == 0)
|
||||
return;
|
||||
|
||||
Vector<OS_Android::TouchPos> points;
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
|
@ -1250,6 +1256,8 @@ static unsigned int android_get_keysym(unsigned int p_code) {
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jobject obj, jint p_device, jint p_button, jboolean p_pressed) {
|
||||
if (step == 0)
|
||||
return;
|
||||
|
||||
OS_Android::JoypadEvent jevent;
|
||||
jevent.device = p_device;
|
||||
|
@ -1261,6 +1269,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jobject obj, jint p_device, jint p_axis, jfloat p_value) {
|
||||
if (step == 0)
|
||||
return;
|
||||
|
||||
OS_Android::JoypadEvent jevent;
|
||||
jevent.device = p_device;
|
||||
|
@ -1272,6 +1282,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env,
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, jobject obj, jint p_device, jint p_hat_x, jint p_hat_y) {
|
||||
if (step == 0)
|
||||
return;
|
||||
|
||||
OS_Android::JoypadEvent jevent;
|
||||
jevent.device = p_device;
|
||||
jevent.type = OS_Android::JOY_EVENT_HAT;
|
||||
|
@ -1301,6 +1314,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jobject obj, jint p_scancode, jint p_unicode_char, jboolean p_pressed) {
|
||||
if (step == 0)
|
||||
return;
|
||||
|
||||
Ref<InputEventKey> ievent;
|
||||
ievent.instance();
|
||||
|
@ -1344,14 +1359,18 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env
|
|||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jobject obj) {
|
||||
|
||||
if (os_android && step > 0)
|
||||
os_android->main_loop_focusin();
|
||||
if (step == 0)
|
||||
return;
|
||||
|
||||
os_android->main_loop_focusin();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jobject obj) {
|
||||
|
||||
if (os_android && step > 0)
|
||||
os_android->main_loop_focusout();
|
||||
if (step == 0)
|
||||
return;
|
||||
|
||||
os_android->main_loop_focusout();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_audio(JNIEnv *env, jobject obj) {
|
||||
|
|
Loading…
Reference in a new issue