From 79d991081dbeaddd0294c6bbf01675d1ec1fbb72 Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 13 Mar 2011 22:31:28 +0100 Subject: ANDROID: Add support for video feature flags kFeatureFullscreenMode and kFeatureAspectRatioCorrection are supported now. The former prevents scaling to the full display - it scales one axis and keeps the game AR. --- backends/platform/android/jni.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'backends/platform/android/jni.cpp') diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp index 6bfe9c2095..0628d92a2f 100644 --- a/backends/platform/android/jni.cpp +++ b/backends/platform/android/jni.cpp @@ -65,6 +65,7 @@ jfieldID JNI::_FID_Event_mouse_x = 0; jfieldID JNI::_FID_Event_mouse_y = 0; jfieldID JNI::_FID_Event_mouse_relative = 0; +jmethodID JNI::_MID_getDPI = 0; jmethodID JNI::_MID_displayMessageOnOSD = 0; jmethodID JNI::_MID_setWindowCaption = 0; jmethodID JNI::_MID_showVirtualKeyboard = 0; @@ -214,6 +215,35 @@ void JNI::throwRuntimeException(JNIEnv *env, const char *msg) { // calls to the dark side +void JNI::getDPI(float *values) { + values[0] = 0.0; + values[1] = 0.0; + + JNIEnv *env = JNI::getEnv(); + + jfloatArray array = env->NewFloatArray(2); + + env->CallVoidMethod(_jobj, _MID_getDPI, array); + + if (env->ExceptionCheck()) { + LOGE("Failed to get DPIs"); + + env->ExceptionDescribe(); + env->ExceptionClear(); + } else { + jfloat *res = env->GetFloatArrayElements(array, 0); + + if (res) { + values[0] = res[0]; + values[1] = res[1]; + + env->ReleaseFloatArrayElements(array, res, 0); + } + } + + env->DeleteLocalRef(array); +} + void JNI::displayMessageOnOSD(const char *msg) { JNIEnv *env = JNI::getEnv(); jstring java_msg = env->NewStringUTF(msg); @@ -445,6 +475,7 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager, } while (0) FIND_METHOD(, setWindowCaption, "(Ljava/lang/String;)V"); + FIND_METHOD(, getDPI, "([F)V"); FIND_METHOD(, displayMessageOnOSD, "(Ljava/lang/String;)V"); FIND_METHOD(, showVirtualKeyboard, "(Z)V"); FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;"); -- cgit v1.2.3