1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Improve touchpad and mouse support for the Android editor

This commit is contained in:
Fredia Huya-Kouadio
2023-05-12 06:11:27 -07:00
parent a810c8c5f6
commit ccd36e0dbe
5 changed files with 60 additions and 15 deletions

View File

@@ -47,6 +47,8 @@ GodotJavaViewWrapper::GodotJavaViewWrapper(jobject godot_view) {
_request_pointer_capture = env->GetMethodID(_cls, "requestPointerCapture", "()V");
_release_pointer_capture = env->GetMethodID(_cls, "releasePointerCapture", "()V");
}
_can_capture_pointer = env->GetMethodID(_cls, "canCapturePointer", "()Z");
}
bool GodotJavaViewWrapper::can_update_pointer_icon() const {
@@ -54,7 +56,16 @@ bool GodotJavaViewWrapper::can_update_pointer_icon() const {
}
bool GodotJavaViewWrapper::can_capture_pointer() const {
return _request_pointer_capture != nullptr && _release_pointer_capture != nullptr;
// We can capture the pointer if the other jni capture method ids are initialized,
// and GodotView#canCapturePointer() returns true.
if (_request_pointer_capture != nullptr && _release_pointer_capture != nullptr && _can_capture_pointer != nullptr) {
JNIEnv *env = get_jni_env();
ERR_FAIL_NULL_V(env, false);
return env->CallBooleanMethod(_godot_view, _can_capture_pointer);
}
return false;
}
void GodotJavaViewWrapper::request_pointer_capture() {