diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-02-04 11:51:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-04 11:51:07 +0100 |
commit | d235c1bb1964b80d776a64aa2a1b198a8e52bf72 (patch) | |
tree | 5580b3e38c269efb494b20d54ae6a3e355d2dd58 /platform/android/java_godot_io_wrapper.cpp | |
parent | 85f6151e9d4ce9ecc4fe587cc6e76356b49e8a43 (diff) | |
parent | 54dec44dbae4859842c6d99aafaafd186b33fee4 (diff) |
Merge pull request #57335 from jordigcs/display-refresh-rate
Diffstat (limited to 'platform/android/java_godot_io_wrapper.cpp')
-rw-r--r-- | platform/android/java_godot_io_wrapper.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/platform/android/java_godot_io_wrapper.cpp b/platform/android/java_godot_io_wrapper.cpp index e0a535f16e..8a2788e848 100644 --- a/platform/android/java_godot_io_wrapper.cpp +++ b/platform/android/java_godot_io_wrapper.cpp @@ -53,6 +53,7 @@ GodotIOJavaWrapper::GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instanc _get_locale = p_env->GetMethodID(cls, "getLocale", "()Ljava/lang/String;"); _get_model = p_env->GetMethodID(cls, "getModel", "()Ljava/lang/String;"); _get_screen_DPI = p_env->GetMethodID(cls, "getScreenDPI", "()I"); + _get_screen_refresh_rate = p_env->GetMethodID(cls, "getScreenRefreshRate", "(D)D"); _screen_get_usable_rect = p_env->GetMethodID(cls, "screenGetUsableRect", "()[I"), _get_unique_id = p_env->GetMethodID(cls, "getUniqueID", "()Ljava/lang/String;"); _show_keyboard = p_env->GetMethodID(cls, "showKeyboard", "(Ljava/lang/String;ZIII)V"); @@ -136,6 +137,19 @@ int GodotIOJavaWrapper::get_screen_dpi() { } } +float GodotIOJavaWrapper::get_screen_refresh_rate(float fallback) { + if (_get_screen_refresh_rate) { + JNIEnv *env = get_jni_env(); + if (env == nullptr) { + ERR_PRINT("An error occured while trying to get screen refresh rate."); + return fallback; + } + return (float)env->CallDoubleMethod(godot_io_instance, _get_screen_refresh_rate, (double)fallback); + } + ERR_PRINT("An error occured while trying to get the screen refresh rate."); + return fallback; +} + void GodotIOJavaWrapper::screen_get_usable_rect(int (&p_rect_xywh)[4]) { if (_screen_get_usable_rect) { JNIEnv *env = get_jni_env(); |