Skip to content

Commit

Permalink
Minor cleanup, and more terrifying orientation hackery
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Nov 16, 2017
1 parent a1e593b commit 5675e8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 2 additions & 7 deletions UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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, "\\", "/");
Expand All @@ -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
Expand Down
9 changes: 6 additions & 3 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public void onCreate(Bundle savedInstanceState) {
}

private Point desiredSize = new Point();

private int badOrientationCount = 0;
@Override
public void surfaceCreated(SurfaceHolder holder) {
pixelWidth = holder.getSurfaceFrame().width();
Expand All @@ -530,10 +530,13 @@ public void surfaceCreated(SurfaceHolder holder) {
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);
Expand Down

0 comments on commit 5675e8a

Please sign in to comment.