From a8083b96845c81ca035f618c195a03fb9abebde5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 8 May 2018 23:05:09 +0200 Subject: [PATCH] Android: Only keep the screen bright ingame. --- Core/System.cpp | 11 +++++++++++ android/src/org/ppsspp/ppsspp/NativeActivity.java | 12 +++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Core/System.cpp b/Core/System.cpp index cc559308c4..777804999f 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -30,6 +30,7 @@ #include #include "base/timeutil.h" +#include "base/NativeApp.h" #include "math/math_util.h" #include "thread/threadutil.h" #include "util/text/utf8.h" @@ -106,6 +107,16 @@ void UpdateUIState(GlobalUIState newState) { if (globalUIState != newState && globalUIState != UISTATE_EXIT) { globalUIState = newState; host->UpdateDisassembly(); + const char *state = nullptr; + switch (globalUIState) { + case UISTATE_EXIT: state = "exit"; break; + case UISTATE_INGAME: state = "ingame"; break; + case UISTATE_MENU: state = "menu"; break; + case UISTATE_PAUSEMENU: state = "pausemenu"; break; + } + if (state) { + System_SendMessage("uistate", state); + } } } diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index b524887241..b43328a7b1 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -476,9 +476,6 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C updateScreenRotation("onCreate"); updateSustainedPerformanceMode(); - // Keep the screen bright - very annoying if it goes dark when tilting away - Window window = this.getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setVolumeControlStream(AudioManager.STREAM_MUSIC); gainAudioFocus(this.audioManager, this.audioFocusChangeListener); @@ -1290,6 +1287,15 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C } else if (mCameraHelper != null && params.equals("stopVideo")) { mCameraHelper.stopCamera(); } + } else if (command.equals("uistate")) { + Window window = this.getWindow(); + if (params.equals("ingame")) { + // Keep the screen bright - very annoying if it goes dark when tilting away + window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } else { + // Only keep the screen bright ingame. + window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } } return false; }