2020-09-16 20:14:35 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-21 12:25:28 +00:00
|
|
|
//
|
2020-09-16 20:14:35 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// Platform.h
|
|
|
|
//
|
2022-01-10 17:43:17 +00:00
|
|
|
// Platform utility functions.
|
2020-06-21 12:25:28 +00:00
|
|
|
//
|
|
|
|
|
2022-01-10 17:56:04 +00:00
|
|
|
#ifndef ES_CORE_UTILS_PLATFORM_UTIL_H
|
|
|
|
#define ES_CORE_UTILS_PLATFORM_UTIL_H
|
2017-10-31 17:12:50 +00:00
|
|
|
|
2017-11-01 22:21:10 +00:00
|
|
|
#include <string>
|
|
|
|
|
2020-08-23 15:04:30 +00:00
|
|
|
#if defined(_WIN64)
|
2020-09-16 20:14:35 +00:00
|
|
|
#include <windows.h>
|
2012-09-10 18:48:00 +00:00
|
|
|
#endif
|
2013-05-13 19:53:28 +00:00
|
|
|
|
2023-11-25 09:31:09 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
#include <jni.h>
|
|
|
|
#endif
|
|
|
|
|
2022-01-10 17:43:17 +00:00
|
|
|
namespace Utils
|
|
|
|
{
|
|
|
|
namespace Platform
|
|
|
|
{
|
|
|
|
enum QuitMode {
|
2022-06-05 10:36:55 +00:00
|
|
|
QUIT = 0,
|
2022-01-10 17:43:17 +00:00
|
|
|
REBOOT = 1,
|
|
|
|
POWEROFF = 2
|
|
|
|
};
|
2019-08-14 23:50:23 +00:00
|
|
|
|
2022-01-10 17:43:17 +00:00
|
|
|
int runRebootCommand();
|
|
|
|
int runPoweroffCommand();
|
2020-07-07 19:25:15 +00:00
|
|
|
|
2022-01-10 17:43:17 +00:00
|
|
|
// Uses UTF-8 for Unix and does a UTF-16/wstring conversion for Windows.
|
|
|
|
int runSystemCommand(const std::string& cmd_utf8);
|
|
|
|
// Windows specific UTF-16/wstring function. (FOR FUTURE USE)
|
|
|
|
int runSystemCommand(const std::wstring& cmd_utf16);
|
2020-07-07 19:25:15 +00:00
|
|
|
|
2022-04-30 18:43:29 +00:00
|
|
|
int launchGameUnix(const std::string& cmd_utf8,
|
|
|
|
const std::string& startDirectory,
|
|
|
|
bool runInBackground);
|
|
|
|
int launchGameWindows(const std::wstring& cmd_utf16,
|
2022-04-30 19:19:15 +00:00
|
|
|
const std::wstring& startDirectory,
|
2022-04-30 18:43:29 +00:00
|
|
|
bool runInBackground,
|
|
|
|
bool hideWindow);
|
2020-07-18 11:21:44 +00:00
|
|
|
|
2022-01-10 17:43:17 +00:00
|
|
|
unsigned int getTaskbarState();
|
|
|
|
void hideTaskbar();
|
|
|
|
void revertTaskbarState(unsigned int& state);
|
2021-07-07 18:31:46 +00:00
|
|
|
|
2022-01-10 17:43:17 +00:00
|
|
|
// Clean, normal shutdown.
|
|
|
|
int quitES(QuitMode mode = QuitMode::QUIT);
|
2022-01-10 18:53:23 +00:00
|
|
|
void processQuitMode();
|
2022-01-10 17:43:17 +00:00
|
|
|
|
|
|
|
// Immediately shut down the application as cleanly as possible.
|
|
|
|
void emergencyShutdown();
|
|
|
|
|
2023-11-25 09:31:09 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
namespace Android
|
|
|
|
{
|
|
|
|
bool requestStoragePermission();
|
2023-11-26 12:32:11 +00:00
|
|
|
bool checkEmulatorInstalled(const std::string& packageName,
|
2023-11-26 21:19:24 +00:00
|
|
|
const std::string& activity);
|
2023-11-26 12:32:11 +00:00
|
|
|
int launchGame(const std::string& packageName,
|
2023-11-26 21:19:24 +00:00
|
|
|
const std::string& activity,
|
|
|
|
const std::string& action,
|
2023-11-26 12:32:11 +00:00
|
|
|
std::vector<std::pair<std::string, std::string>>& extras);
|
|
|
|
} // namespace Android
|
2023-11-25 09:31:09 +00:00
|
|
|
#endif
|
|
|
|
|
2022-01-10 18:53:23 +00:00
|
|
|
static QuitMode sQuitMode = QuitMode::QUIT;
|
|
|
|
// This is simply to get rid of a GCC false positive -Wunused-variable compiler warning.
|
|
|
|
static QuitMode sQuitModeDummy = sQuitMode;
|
2022-01-10 17:43:17 +00:00
|
|
|
|
|
|
|
} // namespace Platform
|
|
|
|
|
|
|
|
} // namespace Utils
|
2017-10-31 17:12:50 +00:00
|
|
|
|
2022-01-10 17:56:04 +00:00
|
|
|
#endif // ES_CORE_UTILS_PLATFORM_UTIL_H
|