diff --git a/Common/System/NativeApp.h b/Common/System/NativeApp.h index 4bf2e995bf..9b69b7f179 100644 --- a/Common/System/NativeApp.h +++ b/Common/System/NativeApp.h @@ -20,11 +20,6 @@ class GraphicsContext; // This might get called multiple times in some implementations, you must be able to handle that. void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, bool *landscape, std::string *version); -// Easy way for the Java side to ask the C++ side for configuration options, such as -// the rotation lock which must be controlled from Java on Android. -// It is currently not called on non-Android platforms. -std::string NativeQueryConfig(std::string query); - // For the back button to work right, this should return true on your main or title screen. // Otherwise, just return false. bool NativeIsAtTopLevel(); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index ad47de968b..fab19c2b81 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -216,44 +216,6 @@ public: static LogListener *logger = nullptr; Path boot_filename; -std::string NativeQueryConfig(std::string query) { - char temp[128]; - if (query == "screenRotation") { - INFO_LOG(G3D, "g_Config.screenRotation = %d", g_Config.iScreenRotation); - snprintf(temp, sizeof(temp), "%d", g_Config.iScreenRotation); - return std::string(temp); - } else if (query == "immersiveMode") { - return std::string(g_Config.bImmersiveMode ? "1" : "0"); - } else if (query == "hwScale") { - int scale = g_Config.iAndroidHwScale; - // Override hw scale for TV type devices. - if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) - scale = 0; - - if (scale == 1) { - // If g_Config.iInternalResolution is also set to Auto (1), we fall back to "Device resolution" (0). It works out. - scale = g_Config.iInternalResolution; - } else if (scale >= 2) { - scale -= 1; - } - - int max_res = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES)) / 480 + 1; - snprintf(temp, sizeof(temp), "%d", std::min(scale, max_res)); - return std::string(temp); - } else if (query == "sustainedPerformanceMode") { - return std::string(g_Config.bSustainedPerformanceMode ? "1" : "0"); - } else if (query == "androidJavaGL") { - // If we're using Vulkan, we say no... need C++ to use Vulkan. - if (GetGPUBackend() == GPUBackend::VULKAN) { - return "false"; - } - // Otherwise, some devices prefer the Java init so play it safe. - return "true"; - } else { - return ""; - } -} - int NativeMix(short *audio, int numSamples, int sampleRateHz) { return __AudioMix(audio, numSamples, sampleRateHz); } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index bc4626d175..401fcbf086 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -610,10 +610,50 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_audioConfig optimalSampleRate = optimalSR; } +// Easy way for the Java side to ask the C++ side for configuration options, such as +// the rotation lock which must be controlled from Java on Android. +static std::string QueryConfig(std::string query) { + char temp[128]; + if (query == "screenRotation") { + INFO_LOG(G3D, "g_Config.screenRotation = %d", g_Config.iScreenRotation); + snprintf(temp, sizeof(temp), "%d", g_Config.iScreenRotation); + return std::string(temp); + } else if (query == "immersiveMode") { + return std::string(g_Config.bImmersiveMode ? "1" : "0"); + } else if (query == "hwScale") { + int scale = g_Config.iAndroidHwScale; + // Override hw scale for TV type devices. + if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) + scale = 0; + + if (scale == 1) { + // If g_Config.iInternalResolution is also set to Auto (1), we fall back to "Device resolution" (0). It works out. + scale = g_Config.iInternalResolution; + } else if (scale >= 2) { + scale -= 1; + } + + int max_res = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES)) / 480 + 1; + snprintf(temp, sizeof(temp), "%d", std::min(scale, max_res)); + return std::string(temp); + } else if (query == "sustainedPerformanceMode") { + return std::string(g_Config.bSustainedPerformanceMode ? "1" : "0"); + } else if (query == "androidJavaGL") { + // If we're using Vulkan, we say no... need C++ to use Vulkan. + if (GetGPUBackend() == GPUBackend::VULKAN) { + return "false"; + } + // Otherwise, some devices prefer the Java init so play it safe. + return "true"; + } else { + return ""; + } +} + extern "C" jstring Java_org_ppsspp_ppsspp_NativeApp_queryConfig (JNIEnv *env, jclass, jstring jquery) { std::string query = GetJavaString(env, jquery); - std::string result = NativeQueryConfig(query); + std::string result = QueryConfig(query); jstring jresult = env->NewStringUTF(result.c_str()); return jresult; }