Added support to exit a game on Android device when Back button is

clicked
This commit is contained in:
abdelrahman committed 2023-02-12 23:05:33 +00:00
1 parent ad88083f53
commit 6d3440ba1f
1 file changed
+8
+8
View File
@@ -7,6 +7,7 @@
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_hints.h" #include "SDL_hints.h"
#include "SDL_image.h" #include "SDL_image.h"
#include "SDL_keycode.h"
#include "SDL_mixer.h" #include "SDL_mixer.h"
#include "SDL_pixels.h" #include "SDL_pixels.h"
#include "SDL_platform.h" #include "SDL_platform.h"
@@ -757,6 +758,13 @@ void handle_events() {
switch (GameEngine.event.type) { switch (GameEngine.event.type) {
case SDL_QUIT: case SDL_QUIT:
GameEngine.running = false; GameEngine.running = false;
break;
case SDL_KEYUP:
if (GameEngine.event.key.keysym.sym == SDLK_AC_BACK) {
// Handle Android's back button
GameEngine.running = false;
}
break; break;
} }