mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Make a dedicated system request KEEP_SCREEN_BRIGHT, unify behavior between Windows and Android more
This commit is contained in:
parent
ab598f37f6
commit
5042555d7b
@ -164,6 +164,10 @@ inline void System_NotifyUIState(std::string_view state) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::NOTIFY_UI_STATE, NO_REQUESTER_TOKEN, nullptr, nullptr, state, "", 0);
|
||||
}
|
||||
|
||||
inline void System_SetKeepScreenBright(bool keepScreenBright) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::SET_KEEP_SCREEN_BRIGHT, NO_REQUESTER_TOKEN, nullptr, nullptr, "", "", (int64_t)keepScreenBright);
|
||||
}
|
||||
|
||||
inline void System_SetWindowTitle(std::string_view param) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::SET_WINDOW_TITLE, NO_REQUESTER_TOKEN, nullptr, nullptr, param, "", 0);
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ enum class SystemRequestType {
|
||||
SEND_DEBUG_SCREENSHOT,
|
||||
|
||||
NOTIFY_UI_STATE, // Used on Android only. Not a SystemNotification since it takes a parameter.
|
||||
SET_KEEP_SCREEN_BRIGHT,
|
||||
|
||||
// High-level hardware control
|
||||
CAMERA_COMMAND,
|
||||
|
@ -128,17 +128,7 @@ void UpdateUIState(GlobalUIState newState) {
|
||||
if (globalUIState != newState && globalUIState != UISTATE_EXIT) {
|
||||
globalUIState = newState;
|
||||
System_Notify(SystemNotification::DISASSEMBLY);
|
||||
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;
|
||||
case UISTATE_EXCEPTION: state = "exception"; break;
|
||||
}
|
||||
if (state) {
|
||||
System_NotifyUIState(state);
|
||||
}
|
||||
System_SetKeepScreenBright(globalUIState == UISTATE_INGAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1126,7 +1126,7 @@ void MainScreen::CreateViews() {
|
||||
ScrollView *scrollHomebrew = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
|
||||
scrollHomebrew->SetTag("MainScreenHomebrew");
|
||||
|
||||
#ifdef PPSSPP_PLATFORM(IOS)
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
std::string_view getGamesUri = "https://www.ppsspp.org/getgames_ios";
|
||||
std::string_view getHomebrewUri = "https://www.ppsspp.org/gethomebrew_ios";
|
||||
#else
|
||||
|
@ -137,6 +137,7 @@ namespace MainWindow
|
||||
static bool inResizeMove = false;
|
||||
static bool hasFocus = true;
|
||||
static bool g_isFullscreen = false;
|
||||
static bool g_keepScreenBright = false;
|
||||
|
||||
static bool disasmMapLoadPending = false;
|
||||
static bool memoryMapLoadPending = false;
|
||||
@ -161,6 +162,10 @@ namespace MainWindow
|
||||
return hwndDisplay;
|
||||
}
|
||||
|
||||
void SetKeepScreenBright(bool keepBright) {
|
||||
g_keepScreenBright = keepBright;
|
||||
}
|
||||
|
||||
void Init(HINSTANCE hInstance) {
|
||||
// Register classes - Main Window
|
||||
WNDCLASSEX wcex;
|
||||
@ -1083,16 +1088,25 @@ namespace MainWindow
|
||||
trapMouse = true;
|
||||
break;
|
||||
|
||||
// Turn off the screensaver.
|
||||
// Turn off the screensaver if in-game.
|
||||
// Note that if there's a screensaver password, this simple method
|
||||
// doesn't work on Vista or higher.
|
||||
case WM_SYSCOMMAND:
|
||||
{
|
||||
switch (wParam) {
|
||||
case SC_SCREENSAVE:
|
||||
return 0;
|
||||
case SC_MONITORPOWER:
|
||||
return 0;
|
||||
if (g_keepScreenBright) {
|
||||
switch (wParam) {
|
||||
case SC_SCREENSAVE:
|
||||
return 0;
|
||||
case SC_MONITORPOWER:
|
||||
if (lParam == 1 || lParam == 2) {
|
||||
return 0;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// fall down to DefWindowProc
|
||||
break;
|
||||
}
|
||||
}
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ namespace MainWindow
|
||||
void SetInternalResolution(int res = -1);
|
||||
void SetWindowSize(int zoom);
|
||||
void RunCallbackInWndProc(void (*callback)(void *window, void *userdata), void *userdata);
|
||||
void SetKeepScreenBright(bool keepBright);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -528,6 +528,11 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0);
|
||||
return true;
|
||||
}
|
||||
case SystemRequestType::SET_KEEP_SCREEN_BRIGHT:
|
||||
{
|
||||
MainWindow::SetKeepScreenBright(param3 != 0);
|
||||
return true;
|
||||
}
|
||||
case SystemRequestType::INPUT_TEXT_MODAL:
|
||||
std::thread([=] {
|
||||
std::string out;
|
||||
|
@ -1156,8 +1156,8 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
case SystemRequestType::SHARE_TEXT:
|
||||
PushCommand("share_text", param1);
|
||||
return true;
|
||||
case SystemRequestType::NOTIFY_UI_STATE:
|
||||
PushCommand("uistate", param1);
|
||||
case SystemRequestType::SET_KEEP_SCREEN_BRIGHT:
|
||||
PushCommand("set_keep_screen_bright", param3 ? "on" : "off");
|
||||
return true;
|
||||
case SystemRequestType::SHOW_FILE_IN_FOLDER:
|
||||
PushCommand("show_folder", param1);
|
||||
|
@ -1631,10 +1631,10 @@ public abstract class NativeActivity extends Activity {
|
||||
} else if (params.equals("stopRecording")) {
|
||||
NativeApp.audioRecording_Stop();
|
||||
}
|
||||
} else if (command.equals("uistate")) {
|
||||
} else if (command.equals("set_keep_screen_bright")) {
|
||||
Window window = this.getWindow();
|
||||
if (params.equals("ingame")) {
|
||||
// Keep the screen bright - very annoying if it goes dark when tilting away
|
||||
if (params.equals("on")) {
|
||||
// Keep the screen bright - very annoying if it goes dark when using tilt or a joystick
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
updateSustainedPerformanceMode();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user