Working back button
This commit is contained in:
parent
55208b9487
commit
206fac9ab4
|
@ -2552,7 +2552,7 @@ void titleinput(void)
|
||||||
|
|
||||||
//In the menu system, all keypresses are single taps rather than holds. Therefore this test has to be done for all presses
|
//In the menu system, all keypresses are single taps rather than holds. Therefore this test has to be done for all presses
|
||||||
if (!game.press_action && !game.press_left && !game.press_right && !key.isDown(27) && !key.isDown(game.controllerButton_esc)
|
if (!game.press_action && !game.press_left && !game.press_right && !key.isDown(27) && !key.isDown(game.controllerButton_esc)
|
||||||
&& !touch::button_tapped(TOUCH_BUTTON_CANCEL))
|
&& !touch::button_tapped(TOUCH_BUTTON_CANCEL) && !key.pressed_android_back)
|
||||||
{
|
{
|
||||||
game.jumpheld = false;
|
game.jumpheld = false;
|
||||||
}
|
}
|
||||||
|
@ -2562,7 +2562,7 @@ void titleinput(void)
|
||||||
if (!game.jumpheld && graphics.fademode == FADE_NONE)
|
if (!game.jumpheld && graphics.fademode == FADE_NONE)
|
||||||
{
|
{
|
||||||
if (game.press_action || game.press_left || game.press_right || game.press_map || key.isDown(27) || key.isDown(game.controllerButton_esc)
|
if (game.press_action || game.press_left || game.press_right || game.press_map || key.isDown(27) || key.isDown(game.controllerButton_esc)
|
||||||
|| touch::button_tapped(TOUCH_BUTTON_CANCEL))
|
|| touch::button_tapped(TOUCH_BUTTON_CANCEL) || key.pressed_android_back)
|
||||||
{
|
{
|
||||||
game.jumpheld = true;
|
game.jumpheld = true;
|
||||||
}
|
}
|
||||||
|
@ -2581,7 +2581,7 @@ void titleinput(void)
|
||||||
|
|
||||||
if (game.menustart
|
if (game.menustart
|
||||||
&& game.menucountdown <= 0
|
&& game.menucountdown <= 0
|
||||||
&& (key.isDown(27) || key.isDown(game.controllerButton_esc) || touch::button_tapped(TOUCH_BUTTON_CANCEL)))
|
&& (key.isDown(27) || key.isDown(game.controllerButton_esc) || touch::button_tapped(TOUCH_BUTTON_CANCEL) || key.pressed_android_back))
|
||||||
{
|
{
|
||||||
if (game.currentmenuname == Menu::language && loc::pre_title_lang_menu)
|
if (game.currentmenuname == Menu::language && loc::pre_title_lang_menu)
|
||||||
{
|
{
|
||||||
|
@ -2601,8 +2601,16 @@ void titleinput(void)
|
||||||
}
|
}
|
||||||
else if (game.currentmenuname == Menu::mainmenu)
|
else if (game.currentmenuname == Menu::mainmenu)
|
||||||
{
|
{
|
||||||
game.createmenu(Menu::youwannaquit);
|
if (key.pressed_android_back)
|
||||||
map.nexttowercolour();
|
{
|
||||||
|
// Minimize the game!!! (Android only)
|
||||||
|
SDL_MinimizeWindow(gameScreen.m_window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
game.createmenu(Menu::youwannaquit);
|
||||||
|
map.nexttowercolour();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -252,6 +252,8 @@ void KeyPoll::Poll(void)
|
||||||
|
|
||||||
touch::reset();
|
touch::reset();
|
||||||
|
|
||||||
|
pressed_android_back = false;
|
||||||
|
|
||||||
while (SDL_PollEvent(&evt))
|
while (SDL_PollEvent(&evt))
|
||||||
{
|
{
|
||||||
switch (evt.type)
|
switch (evt.type)
|
||||||
|
@ -266,6 +268,11 @@ void KeyPoll::Poll(void)
|
||||||
pressedbackspace = true;
|
pressedbackspace = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (evt.key.keysym.sym == SDLK_AC_BACK)
|
||||||
|
{
|
||||||
|
pressed_android_back = true;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__ /* OSX prefers the command keys over the alt keys. -flibit */
|
#ifdef __APPLE__ /* OSX prefers the command keys over the alt keys. -flibit */
|
||||||
altpressed = keymap[SDLK_LGUI] || keymap[SDLK_RGUI];
|
altpressed = keymap[SDLK_LGUI] || keymap[SDLK_RGUI];
|
||||||
#else
|
#else
|
||||||
|
@ -605,9 +612,9 @@ void KeyPoll::Poll(void)
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
if (evt.key.keysym.sym != SDLK_AC_BACK)
|
if (evt.key.keysym.sym != SDLK_AC_BACK)
|
||||||
{
|
{
|
||||||
// If we hit the back button on Android, this doesn't mean we're not using touch
|
|
||||||
using_touch = false;
|
using_touch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.key.repeat == 0)
|
if (evt.key.repeat == 0)
|
||||||
{
|
{
|
||||||
hidemouse = true;
|
hidemouse = true;
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
bool linealreadyemptykludge;
|
bool linealreadyemptykludge;
|
||||||
|
|
||||||
bool using_touch;
|
bool using_touch;
|
||||||
|
bool pressed_android_back;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<SDL_JoystickID, SDL_GameController*> controllers;
|
std::map<SDL_JoystickID, SDL_GameController*> controllers;
|
||||||
|
|
|
@ -567,6 +567,9 @@ int main(int argc, char *argv[])
|
||||||
/* We already do the button swapping in ButtonGlyphs, disable SDL's swapping */
|
/* We already do the button swapping in ButtonGlyphs, disable SDL's swapping */
|
||||||
SDL_SetHintWithPriority(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0", SDL_HINT_OVERRIDE);
|
SDL_SetHintWithPriority(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0", SDL_HINT_OVERRIDE);
|
||||||
|
|
||||||
|
/* We want to capture back inputs */
|
||||||
|
SDL_SetHintWithPriority(SDL_HINT_ANDROID_TRAP_BACK_BUTTON, "1", SDL_HINT_OVERRIDE);
|
||||||
|
|
||||||
if(!FILESYSTEM_init(argv[0], baseDir, assetsPath, langDir, fontsDir))
|
if(!FILESYSTEM_init(argv[0], baseDir, assetsPath, langDir, fontsDir))
|
||||||
{
|
{
|
||||||
vlog_error("Unable to initialize filesystem!");
|
vlog_error("Unable to initialize filesystem!");
|
||||||
|
|
Loading…
Reference in New Issue