ES-DE/es-core/src/utils/PlatformUtil.h

81 lines
2.3 KiB
C
Raw Normal View History

// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// Platform.h
//
// Platform utility functions.
//
2022-01-10 17:56:04 +00:00
#ifndef ES_CORE_UTILS_PLATFORM_UTIL_H
#define ES_CORE_UTILS_PLATFORM_UTIL_H
2017-11-01 22:21:10 +00:00
#include <string>
#if defined(_WIN64)
#include <windows.h>
2012-09-10 18:48:00 +00:00
#endif
#if defined(__ANDROID__)
#include <jni.h>
#endif
namespace Utils
{
namespace Platform
{
enum QuitMode {
QUIT = 0,
REBOOT = 1,
POWEROFF = 2
};
int runRebootCommand();
int runPoweroffCommand();
// 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);
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,
bool runInBackground,
bool hideWindow);
unsigned int getTaskbarState();
void hideTaskbar();
void revertTaskbarState(unsigned int& state);
// Clean, normal shutdown.
int quitES(QuitMode mode = QuitMode::QUIT);
void processQuitMode();
// Immediately shut down the application as cleanly as possible.
void emergencyShutdown();
#if defined(__ANDROID__)
namespace Android
{
bool requestStoragePermission();
bool checkEmulatorInstalled(const std::string& packageName,
const std::string& activity);
int launchGame(const std::string& packageName,
const std::string& activity,
const std::string& action,
std::vector<std::pair<std::string, std::string>>& extras);
} // namespace Android
#endif
static QuitMode sQuitMode = QuitMode::QUIT;
// This is simply to get rid of a GCC false positive -Wunused-variable compiler warning.
static QuitMode sQuitModeDummy = sQuitMode;
} // namespace Platform
} // namespace Utils
2022-01-10 17:56:04 +00:00
#endif // ES_CORE_UTILS_PLATFORM_UTIL_H