git repos / blockattack-game

commit 146ce3eb

sago007 · 2018-06-30 11:46
146ce3eb57e1dd5d9d583722d32a41e3b39828c1 patch · browse files
parent ede1d46c0f8c3bfa4f1158195df1206efb164f73

The back button on the gamepad now works

Changed files

M source/code/MenuSystem.cpp before
M source/code/main.cpp before
diff --git a/source/code/MenuSystem.cpp b/source/code/MenuSystem.cpp index 4fe273e..67abb78 100644 --- a/source/code/MenuSystem.cpp +++ b/source/code/MenuSystem.cpp
@@ -290,7 +290,7 @@ bool isEscapeEvent(const SDL_Event& event) {
}
}
if (event.type == SDL_CONTROLLERBUTTONDOWN) {
- if (event.cbutton.button == SDL_CONTROLLER_BUTTON_Y ) {
+ if (event.cbutton.button == SDL_CONTROLLER_BUTTON_Y || event.cbutton.button == SDL_CONTROLLER_BUTTON_BACK ) {
return true;
}
}
diff --git a/source/code/main.cpp b/source/code/main.cpp index aa8deb5..25fe404 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -1333,6 +1333,13 @@ int runGame(Gametype gametype, int level) {
done = 1;
}
+ if (event.type == SDL_CONTROLLERBUTTONDOWN) {
+ if ( event.cbutton.button == SDL_CONTROLLER_BUTTON_BACK ) {
+ done=1;
+ DrawBackground(globalData.screen);
+ }
+ }
+
if ( event.type == SDL_KEYDOWN ) {
if ( event.key.keysym.sym == SDLK_ESCAPE || ( event.key.keysym.sym == SDLK_RETURN && theGame.isGameOver() ) ) {
done=1;