Ensure the joystick is usable in the title screen.

This commit is contained in:
Guus Sliepen 2013-07-13 15:10:29 +02:00
parent 8810b090fa
commit c357c28966
1 changed files with 13 additions and 4 deletions

View File

@ -358,12 +358,21 @@ void getPlayerInput()
break;
case SDL_JOYAXISMOTION:
static bool prevjoyup, prevjoydown, prevjoyleft, prevjoyright;
if (engine.event.jaxis.axis & 1) {
engine.keyState[SDLK_UP] = engine.event.jaxis.value < -16384;
engine.keyState[SDLK_DOWN] = engine.event.jaxis.value >= 16384;
bool joyup = engine.event.jaxis.value < -16384;
bool joydown = engine.event.jaxis.value >= 16384;
if(joyup != prevjoyup)
engine.keyState[SDLK_UP] = prevjoyup = joyup;
if(joydown != prevjoydown)
engine.keyState[SDLK_DOWN] = prevjoydown = joydown;
} else {
engine.keyState[SDLK_LEFT] = engine.event.jaxis.value < -16384;
engine.keyState[SDLK_RIGHT] = engine.event.jaxis.value >= 16384;
bool joyleft = engine.event.jaxis.value < -16384;
bool joyright = engine.event.jaxis.value >= 16384;
if(joyleft != prevjoyleft)
engine.keyState[SDLK_LEFT] = prevjoyleft = joyleft;
if(joyright != prevjoyright)
engine.keyState[SDLK_RIGHT] = prevjoyright = joyright;
}
break;