From: Ingo Ruhnke Date: Sun, 18 Jan 2004 13:30:10 +0000 (+0000) Subject: - fixed joystick support a bit for analog joysticks, menu is still not really useable... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4df3a7a4f12219c2ef3632fb717f8d4051b3bdbf;p=supertux.git - fixed joystick support a bit for analog joysticks, menu is still not really useable with them, but at least it will not go completly crazy SVN-Revision: 96 --- diff --git a/src/gameloop.c b/src/gameloop.c index 3f7065888..b9f95960c 100644 --- a/src/gameloop.c +++ b/src/gameloop.c @@ -217,20 +217,21 @@ void game_event(void) switch(event.jaxis.axis) { case JOY_X: - if (event.jaxis.value < -256) + printf("X: %d\n", event.jaxis.value); + if (event.jaxis.value < -1024) tux.input.left = DOWN; - else + else if (event.jaxis.value > 1024) tux.input.left = UP; - if (event.jaxis.value > 256) + if (event.jaxis.value > 1024) tux.input.right = DOWN; - else + else if (event.jaxis.value < -1024) tux.input.right = UP; break; case JOY_Y: - if (event.jaxis.value > 256) + if (event.jaxis.value > 1024) tux.input.down = DOWN; - else + else if (event.jaxis.value < -1024) tux.input.down = UP; /* Handle joystick for the menu */ diff --git a/src/title.c b/src/title.c index 0c66575a9..a7f5a3e53 100644 --- a/src/title.c +++ b/src/title.c @@ -109,11 +109,11 @@ int title(void) } } #ifdef JOY_YES - else if (event.type == SDL_JOYAXISMOTION) + else if (event.type == SDL_JOYAXISMOTION && event.jaxis.axis == JOY_Y) { - if (event.jaxis.value > 256) + if (event.jaxis.value > 1024) menuaction = MN_DOWN; - else + else if (event.jaxis.value < -1024) menuaction = MN_UP; } else if (event.type == SDL_JOYBUTTONDOWN)