From 818975b29799adc3ab5ec329a3ce5ad05ff871e3 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 8 Sep 2004 17:32:32 +0000 Subject: [PATCH] applied netsrot's patch SVN-Revision: 1877 --- lib/gui/menu.cpp | 7 +++++++ src/gameloop.cpp | 21 +++++++++++++++++++++ src/tile.cpp | 1 + src/worldmap.cpp | 12 ++++++++++++ 4 files changed, 41 insertions(+) diff --git a/lib/gui/menu.cpp b/lib/gui/menu.cpp index ddddbb7fe..fcd60a4cf 100644 --- a/lib/gui/menu.cpp +++ b/lib/gui/menu.cpp @@ -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) { diff --git a/src/gameloop.cpp b/src/gameloop.cpp index 97cecb9a8..76995bbab 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -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) diff --git a/src/tile.cpp b/src/tile.cpp index 2bd161d98..8919f6923 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include "app/globals.h" diff --git a/src/worldmap.cpp b/src/worldmap.cpp index f524e95f6..a00932b0b 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -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) -- 2.11.0