applied netsrot's patch
authorMatthias Braun <matze@braunis.de>
Wed, 8 Sep 2004 17:32:32 +0000 (17:32 +0000)
committerMatthias Braun <matze@braunis.de>
Wed, 8 Sep 2004 17:32:32 +0000 (17:32 +0000)
SVN-Revision: 1877

lib/gui/menu.cpp
src/gameloop.cpp
src/tile.cpp
src/worldmap.cpp

index ddddbb7..fcd60a4 100644 (file)
@@ -846,6 +846,13 @@ Menu::event(SDL_Event& event)
             joystick_timer.stop();
         }
       break;
+    case SDL_JOYHATMOTION:
+      if(event.jhat.value & SDL_HAT_UP) {
+          menuaction = MENU_ACTION_UP;
+      } else if(event.jhat.value & SDL_HAT_DOWN) {
+          menuaction = MENU_ACTION_DOWN;
+      }
+      break;
     case  SDL_JOYBUTTONDOWN:
       if (item.size() > 0 && item[active_item].kind == MN_CONTROLFIELD_JS)
         {
index 97cecb9..76995bb 100644 (file)
@@ -431,6 +431,27 @@ GameSession::process_events()
                         tux.input.down = UP;
                     }
                   break;
+
+                case SDL_JOYHATMOTION:
+                  if(event.jhat.value & SDL_HAT_UP) {
+                    tux.input.up = DOWN;
+                    tux.input.down = UP;
+                  } else if(event.jhat.value & SDL_HAT_DOWN) {
+                    tux.input.up = UP;
+                    tux.input.down = DOWN;
+                  } else if(event.jhat.value & SDL_HAT_LEFT) {
+                    tux.input.left = DOWN;
+                    tux.input.right = UP;
+                  } else if(event.jhat.value & SDL_HAT_RIGHT) {
+                    tux.input.left = UP;
+                    tux.input.right = DOWN;
+                  } else if(event.jhat.value == SDL_HAT_CENTERED) {
+                    tux.input.left = UP;
+                    tux.input.right = UP;
+                    tux.input.up = UP;
+                    tux.input.down = UP;
+                  }
+                  break;
             
                 case SDL_JOYBUTTONDOWN:
                   if (event.jbutton.button == joystick_keymap.a_button)
index 2bd161d..8919f69 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <cmath>
 #include <cassert>
+#include <cmath>
 #include <iostream>
 
 #include "app/globals.h"
index f524e95..a00932b 100644 (file)
@@ -684,6 +684,18 @@ WorldMap::get_input()
                   break;
                 }
               break;
+
+            case SDL_JOYHATMOTION:
+              if(event.jhat.value & SDL_HAT_UP) {
+                tux->set_direction(D_NORTH);
+              } else if(event.jhat.value & SDL_HAT_DOWN) {
+                tux->set_direction(D_SOUTH);
+              } else if(event.jhat.value & SDL_HAT_LEFT) {
+                tux->set_direction(D_WEST);
+              } else if(event.jhat.value & SDL_HAT_RIGHT) {
+                tux->set_direction(D_EAST);
+              }
+              break;
           
             case SDL_JOYAXISMOTION:
               if (event.jaxis.axis == joystick_keymap.x_axis)