Minor cleanup, and more terrifying orientation hackery

This commit is contained in:
Henrik Rydgård committed 2017-11-16 15:00:27 +01:00
1 parent a1e593b6ba
commit 5675e8a816
2 files changed
+8 -10

No files matched your search

+2 -7
View File
@@ -302,12 +302,6 @@ bool CheckFontIsUsable(const wchar_t *fontFace) {
#endif
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir, bool fs) {
#ifdef ANDROID_NDK_PROFILER
setenv("CPUPROFILE_FREQUENCY", "500", 1);
setenv("CPUPROFILE", "/sdcard/gmon.out", 1);
monstartup("ppsspp_jni.so");
#endif
net::Init(); // This needs to happen before we load the config. So on Windows we also run it in Main. It's fine to call multiple times.
InitFastMath(cpu_info.bNEON);
@@ -442,6 +436,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
}
} else {
if (boot_filename.empty()) {
ILOG("Boot filename found in args: %s", argv[i]);
boot_filename = argv[i];
#ifdef _WIN32
boot_filename = ReplaceAll(boot_filename, "\\", "/");
@@ -460,7 +455,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
}
}
if (fileToLog != NULL)
if (fileToLog)
LogManager::GetInstance()->ChangeFileLog(fileToLog);
#ifndef _WIN32
@@ -520,7 +520,7 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
}
private Point desiredSize = new Point();
private int badOrientationCount = 0;
@Override
public void surfaceCreated(SurfaceHolder holder) {
pixelWidth = holder.getSurfaceFrame().width();
@@ -530,10 +530,13 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
int requestedOr = getRequestedOrientation();
boolean requestedPortrait = requestedOr == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || requestedOr == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
boolean detectedPortrait = pixelHeight > pixelWidth;
if (requestedPortrait != detectedPortrait) {
Log.e(TAG, "Bad orientation detected! Recreating activity.");
if (badOrientationCount < 3 && requestedPortrait != detectedPortrait) {
Log.e(TAG, "Bad orientation detected (w=" + pixelWidth + " h=" + pixelHeight + "! Recreating activity.");
badOrientationCount++;
recreate();;
return;
} else if (requestedPortrait == detectedPortrait) {
badOrientationCount = 0;
}
Log.d(TAG, "Surface created. pixelWidth=" + pixelWidth + ", pixelHeight=" + pixelHeight + " holder: " + holder.toString() + " or: " + requestedOr);