Added MENU_BACK button (i.e. B on Xbox360 controller)
authorIngo Ruhnke <grumbel@gmail.com>
Wed, 6 Aug 2014 04:37:29 +0000 (06:37 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Wed, 6 Aug 2014 04:37:29 +0000 (06:37 +0200)
src/control/controller.cpp
src/control/controller.hpp
src/control/game_controller_manager.cpp
src/gui/menu.cpp

index 93d6536..6a3882e 100644 (file)
@@ -25,6 +25,7 @@ const char* Controller::controlNames[] = {
   "action",
   "pause-menu",
   "menu-select",
+  "menu-back",
   "console",
   "peek-left",
   "peek-right",
index 5bec758..b73695d 100644 (file)
@@ -33,6 +33,7 @@ public:
 
     PAUSE_MENU,
     MENU_SELECT,
+    MENU_BACK,
 
     CONSOLE,
 
index 160e598..b76d41f 100644 (file)
@@ -49,6 +49,7 @@ GameControllerManager::process_button_event(const SDL_ControllerButtonEvent& ev)
       break;
 
     case SDL_CONTROLLER_BUTTON_B:
+      controller->set_control(Controller::MENU_BACK, ev.state);
       break;
 
     case SDL_CONTROLLER_BUTTON_X:
index e3fce4b..c2917e7 100644 (file)
@@ -273,7 +273,8 @@ Menu::update()
      || controller->pressed(Controller::MENU_SELECT)) {
     menuaction = MENU_ACTION_HIT;
   }
-  if(controller->pressed(Controller::PAUSE_MENU)) {
+  if(controller->pressed(Controller::PAUSE_MENU)
+    || controller->pressed(Controller::MENU_BACK)) {
     menuaction = MENU_ACTION_BACK;
   }