mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
(Android) Added experimental support for running ES-DE as the home app
This commit is contained in:
parent
5bad361121
commit
05e641c04e
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
#include "InputOverlay.h"
|
#include "InputOverlay.h"
|
||||||
|
#include "utils/PlatformUtilAndroid.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <SDL2/SDL_events.h>
|
#include <SDL2/SDL_events.h>
|
||||||
|
@ -76,8 +77,11 @@ GuiMenu::GuiMenu()
|
||||||
|
|
||||||
if (!Settings::getInstance()->getBool("ForceKiosk") &&
|
if (!Settings::getInstance()->getBool("ForceKiosk") &&
|
||||||
Settings::getInstance()->getString("UIMode") != "kiosk") {
|
Settings::getInstance()->getString("UIMode") != "kiosk") {
|
||||||
#if defined(__APPLE__) || defined(__ANDROID__)
|
#if defined(__APPLE__)
|
||||||
addEntry("QUIT ES-DE", mMenuColorPrimary, false, [this] { openQuitMenu(); });
|
addEntry("QUIT ES-DE", mMenuColorPrimary, false, [this] { openQuitMenu(); });
|
||||||
|
#elif defined(__ANDROID__)
|
||||||
|
if (!AndroidVariables::sIsHomeApp)
|
||||||
|
addEntry("QUIT ES-DE", mMenuColorPrimary, false, [this] { openQuitMenu(); });
|
||||||
#else
|
#else
|
||||||
if (Settings::getInstance()->getBool("ShowQuitMenu"))
|
if (Settings::getInstance()->getBool("ShowQuitMenu"))
|
||||||
addEntry("QUIT", mMenuColorPrimary, true, [this] { openQuitMenu(); });
|
addEntry("QUIT", mMenuColorPrimary, true, [this] { openQuitMenu(); });
|
||||||
|
@ -1791,16 +1795,31 @@ void GuiMenu::openOtherOptions()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
// Whether swiping or pressing back should exit the application.
|
if (!AndroidVariables::sIsHomeApp) {
|
||||||
auto backEventAppExit = std::make_shared<SwitchComponent>();
|
// Whether swiping or pressing back should exit the application.
|
||||||
backEventAppExit->setState(Settings::getInstance()->getBool("BackEventAppExit"));
|
auto backEventAppExit = std::make_shared<SwitchComponent>();
|
||||||
s->addWithLabel("BACK BUTTON/BACK SWIPE EXITS APP", backEventAppExit);
|
backEventAppExit->setState(Settings::getInstance()->getBool("BackEventAppExit"));
|
||||||
s->addSaveFunc([backEventAppExit, s] {
|
s->addWithLabel("BACK BUTTON/BACK SWIPE EXITS APP", backEventAppExit);
|
||||||
if (backEventAppExit->getState() != Settings::getInstance()->getBool("BackEventAppExit")) {
|
s->addSaveFunc([backEventAppExit, s] {
|
||||||
Settings::getInstance()->setBool("BackEventAppExit", backEventAppExit->getState());
|
if (backEventAppExit->getState() !=
|
||||||
s->setNeedsSaving();
|
Settings::getInstance()->getBool("BackEventAppExit")) {
|
||||||
}
|
Settings::getInstance()->setBool("BackEventAppExit", backEventAppExit->getState());
|
||||||
});
|
s->setNeedsSaving();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// If we're running as the Android home app then we don't allow the application to quit,
|
||||||
|
// so simply add a disabled dummy switch in this case.
|
||||||
|
auto backEventAppExit = std::make_shared<SwitchComponent>();
|
||||||
|
s->addWithLabel("BACK BUTTON/BACK SWIPE EXITS APP", backEventAppExit);
|
||||||
|
backEventAppExit->setEnabled(false);
|
||||||
|
backEventAppExit->setState(false);
|
||||||
|
backEventAppExit->setOpacity(DISABLED_OPACITY);
|
||||||
|
backEventAppExit->getParent()
|
||||||
|
->getChild(backEventAppExit->getChildIndex() - 1)
|
||||||
|
->setOpacity(DISABLED_OPACITY);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DebugFlag")) {
|
if (Settings::getInstance()->getBool("DebugFlag")) {
|
||||||
|
|
|
@ -701,6 +701,14 @@ int main(int argc, char* argv[])
|
||||||
LOG(LogInfo) << applicationName << " " << PROGRAM_VERSION_STRING << "-"
|
LOG(LogInfo) << applicationName << " " << PROGRAM_VERSION_STRING << "-"
|
||||||
<< ANDROID_VERSION_CODE << " (r" << PROGRAM_RELEASE_NUMBER << "), built "
|
<< ANDROID_VERSION_CODE << " (r" << PROGRAM_RELEASE_NUMBER << "), built "
|
||||||
<< PROGRAM_BUILT_STRING;
|
<< PROGRAM_BUILT_STRING;
|
||||||
|
|
||||||
|
if (AndroidVariables::sIsHomeApp) {
|
||||||
|
LOG(LogInfo) << "Running as the Android home app";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG(LogInfo) << "Running as a regular Android app";
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
LOG(LogInfo) << applicationName << " " << PROGRAM_VERSION_STRING << " (r"
|
LOG(LogInfo) << applicationName << " " << PROGRAM_VERSION_STRING << " (r"
|
||||||
<< PROGRAM_RELEASE_NUMBER << "), built " << PROGRAM_BUILT_STRING;
|
<< PROGRAM_RELEASE_NUMBER << "), built " << PROGRAM_BUILT_STRING;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
#define TOUCH_GUID_STRING "-3"
|
#define TOUCH_GUID_STRING "-3"
|
||||||
|
#include "utils/PlatformUtilAndroid.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -477,9 +478,11 @@ bool InputManager::parseEvent(const SDL_Event& event)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
// Quit application if the back button is pressed or if the back gesture is used.
|
// Quit application if the back button is pressed or if the back gesture is used,
|
||||||
|
// unless we're set as the Android home app.
|
||||||
if (event.key.keysym.sym == SDLK_AC_BACK &&
|
if (event.key.keysym.sym == SDLK_AC_BACK &&
|
||||||
Settings::getInstance()->getBool("BackEventAppExit")) {
|
Settings::getInstance()->getBool("BackEventAppExit") &&
|
||||||
|
!AndroidVariables::sIsHomeApp) {
|
||||||
SDL_Event quit {};
|
SDL_Event quit {};
|
||||||
quit.type = SDL_QUIT;
|
quit.type = SDL_QUIT;
|
||||||
SDL_PushEvent(&quit);
|
SDL_PushEvent(&quit);
|
||||||
|
@ -493,7 +496,7 @@ bool InputManager::parseEvent(const SDL_Event& event)
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
if (quitShortcut != "CmdQ") {
|
if (quitShortcut != "CmdQ") {
|
||||||
#elif defined(__ANDROID__)
|
#elif defined(__ANDROID__)
|
||||||
if (true) {
|
if (!AndroidVariables::sIsHomeApp) {
|
||||||
#else
|
#else
|
||||||
if (quitShortcut != "AltF4") {
|
if (quitShortcut != "AltF4") {
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue