Fixed some bugs with gamepad controls.

Included a bug where axis controls got stuck after the end of a mission,
and one where hat controls caused massive movement speed.
This commit is contained in:
Layla Marchant 2020-07-16 11:43:45 -04:00
parent 13a2f0fba5
commit 9a5076bb93
1 changed files with 6 additions and 4 deletions

View File

@ -310,10 +310,10 @@ void player_getInput()
break;
case SDL_JOYHATMOTION:
engine.keyState[KEY_UP] = engine.event.jhat.value & SDL_HAT_UP;
engine.keyState[KEY_DOWN] = engine.event.jhat.value & SDL_HAT_DOWN;
engine.keyState[KEY_LEFT] = engine.event.jhat.value & SDL_HAT_LEFT;
engine.keyState[KEY_RIGHT] = engine.event.jhat.value & SDL_HAT_RIGHT;
engine.keyState[KEY_UP] = (engine.event.jhat.value & SDL_HAT_UP ? 1 : 0);
engine.keyState[KEY_DOWN] = (engine.event.jhat.value & SDL_HAT_DOWN ? 1 : 0);
engine.keyState[KEY_LEFT] = (engine.event.jhat.value & SDL_HAT_LEFT ? 1 : 0);
engine.keyState[KEY_RIGHT] = (engine.event.jhat.value & SDL_HAT_RIGHT ? 1 : 0);
break;
case SDL_JOYAXISMOTION:
@ -389,6 +389,8 @@ void player_leaveSector()
engine.keyState[KEY_RIGHT] = 0;
engine.keyState[KEY_FIRE] = 0;
engine.keyState[KEY_ALTFIRE] = 0;
engine.xaxis = 0;
engine.yaxis = 0;
if (engine.done == ENGINE_RUNNING)
engine.done = ENGINE_FORMATION;