mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05: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__)
|
||||
#include "InputOverlay.h"
|
||||
#include "utils/PlatformUtilAndroid.h"
|
||||
#endif
|
||||
|
||||
#include <SDL2/SDL_events.h>
|
||||
|
@ -76,8 +77,11 @@ GuiMenu::GuiMenu()
|
|||
|
||||
if (!Settings::getInstance()->getBool("ForceKiosk") &&
|
||||
Settings::getInstance()->getString("UIMode") != "kiosk") {
|
||||
#if defined(__APPLE__) || defined(__ANDROID__)
|
||||
#if defined(__APPLE__)
|
||||
addEntry("QUIT ES-DE", mMenuColorPrimary, false, [this] { openQuitMenu(); });
|
||||
#elif defined(__ANDROID__)
|
||||
if (!AndroidVariables::sIsHomeApp)
|
||||
addEntry("QUIT ES-DE", mMenuColorPrimary, false, [this] { openQuitMenu(); });
|
||||
#else
|
||||
if (Settings::getInstance()->getBool("ShowQuitMenu"))
|
||||
addEntry("QUIT", mMenuColorPrimary, true, [this] { openQuitMenu(); });
|
||||
|
@ -1791,16 +1795,31 @@ void GuiMenu::openOtherOptions()
|
|||
#endif
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
// Whether swiping or pressing back should exit the application.
|
||||
auto backEventAppExit = std::make_shared<SwitchComponent>();
|
||||
backEventAppExit->setState(Settings::getInstance()->getBool("BackEventAppExit"));
|
||||
s->addWithLabel("BACK BUTTON/BACK SWIPE EXITS APP", backEventAppExit);
|
||||
s->addSaveFunc([backEventAppExit, s] {
|
||||
if (backEventAppExit->getState() != Settings::getInstance()->getBool("BackEventAppExit")) {
|
||||
Settings::getInstance()->setBool("BackEventAppExit", backEventAppExit->getState());
|
||||
s->setNeedsSaving();
|
||||
}
|
||||
});
|
||||
if (!AndroidVariables::sIsHomeApp) {
|
||||
// Whether swiping or pressing back should exit the application.
|
||||
auto backEventAppExit = std::make_shared<SwitchComponent>();
|
||||
backEventAppExit->setState(Settings::getInstance()->getBool("BackEventAppExit"));
|
||||
s->addWithLabel("BACK BUTTON/BACK SWIPE EXITS APP", backEventAppExit);
|
||||
s->addSaveFunc([backEventAppExit, s] {
|
||||
if (backEventAppExit->getState() !=
|
||||
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
|
||||
|
||||
if (Settings::getInstance()->getBool("DebugFlag")) {
|
||||
|
|
|
@ -701,6 +701,14 @@ int main(int argc, char* argv[])
|
|||
LOG(LogInfo) << applicationName << " " << PROGRAM_VERSION_STRING << "-"
|
||||
<< ANDROID_VERSION_CODE << " (r" << PROGRAM_RELEASE_NUMBER << "), built "
|
||||
<< PROGRAM_BUILT_STRING;
|
||||
|
||||
if (AndroidVariables::sIsHomeApp) {
|
||||
LOG(LogInfo) << "Running as the Android home app";
|
||||
}
|
||||
else {
|
||||
LOG(LogInfo) << "Running as a regular Android app";
|
||||
}
|
||||
|
||||
#else
|
||||
LOG(LogInfo) << applicationName << " " << PROGRAM_VERSION_STRING << " (r"
|
||||
<< PROGRAM_RELEASE_NUMBER << "), built " << PROGRAM_BUILT_STRING;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#if defined(__ANDROID__)
|
||||
#define TOUCH_GUID_STRING "-3"
|
||||
#include "utils/PlatformUtilAndroid.h"
|
||||
#endif
|
||||
|
||||
namespace
|
||||
|
@ -477,9 +478,11 @@ bool InputManager::parseEvent(const SDL_Event& event)
|
|||
return false;
|
||||
|
||||
#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 &&
|
||||
Settings::getInstance()->getBool("BackEventAppExit")) {
|
||||
Settings::getInstance()->getBool("BackEventAppExit") &&
|
||||
!AndroidVariables::sIsHomeApp) {
|
||||
SDL_Event quit {};
|
||||
quit.type = SDL_QUIT;
|
||||
SDL_PushEvent(&quit);
|
||||
|
@ -493,7 +496,7 @@ bool InputManager::parseEvent(const SDL_Event& event)
|
|||
#if defined(__APPLE__)
|
||||
if (quitShortcut != "CmdQ") {
|
||||
#elif defined(__ANDROID__)
|
||||
if (true) {
|
||||
if (!AndroidVariables::sIsHomeApp) {
|
||||
#else
|
||||
if (quitShortcut != "AltF4") {
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue