#include "input.h" #include void handleKeyboardEvent(int *action_states, SDL_Event event) { if (event.key.repeat != 0) return; switch (event.type) { case SDL_QUIT: action_states[ACTION_QUIT] = 1; break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_q: action_states[ACTION_QUIT] = 1; break; case SDLK_w: action_states[ACTION_MOVE_UP] = 1; break; case SDLK_s: action_states[ACTION_MOVE_DOWN] = 1; break; case SDLK_a: action_states[ACTION_MOVE_LEFT] = 1; break; case SDLK_d: action_states[ACTION_MOVE_RIGHT] = 1; break; } break; case SDL_KEYUP: switch (event.key.keysym.sym) { case SDLK_w: action_states[ACTION_MOVE_UP] = 0; break; case SDLK_s: action_states[ACTION_MOVE_DOWN] = 0; break; case SDLK_a: action_states[ACTION_MOVE_LEFT] = 0; break; case SDLK_d: action_states[ACTION_MOVE_RIGHT] = 0; break; } break; } } /* int action_status(enum Actions action) */ /* { */ /* return actions_state[action]; */ /* } */ /* void action_toggle(enum Actions action) */ /* { */ /* printf("%d", actions_state[action]); */ /* actions_state[action] = 1; */ /* printf("%d", actions_state[action]); */ /* } */