diff options
Diffstat (limited to 'src/sdl/action.c')
-rw-r--r-- | src/sdl/action.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/sdl/action.c b/src/sdl/action.c index 8307f19..84f415a 100644 --- a/src/sdl/action.c +++ b/src/sdl/action.c @@ -13,13 +13,27 @@ case SDLK_8: \ case SDLK_9: +#define CASE_DIR \ + case SDLK_UP: \ + case SDLK_DOWN: \ + case SDLK_LEFT: \ + case SDLK_RIGHT: \ + case SDLK_h: \ + case SDLK_j: \ + case SDLK_k: \ + case SDLK_l: + static const sok_dir_t keycode_to_dir(const SDL_Keycode code) { switch (code) { case SDLK_UP: return SOK_DIR_UP; + case SDLK_k: return SOK_DIR_UP; case SDLK_LEFT: return SOK_DIR_LEFT; + case SDLK_h: return SOK_DIR_LEFT; case SDLK_DOWN: return SOK_DIR_DOWN; + case SDLK_j: return SOK_DIR_DOWN; case SDLK_RIGHT: return SOK_DIR_RIGHT; + case SDLK_l: return SOK_DIR_RIGHT; default: return SOK_DIR_LAST; } } @@ -32,17 +46,14 @@ get_key_action( case SDLK_ESCAPE: case SDLK_q: return (action_t) { .type = ACTION_QUIT }; - case SDLK_UP: - case SDLK_DOWN: - case SDLK_LEFT: - case SDLK_RIGHT: + CASE_DIR return (action_t) { .type = ACTION_MOVE, .data = keycode_to_dir(code) }; case SDLK_u: return (action_t) { .type = ACTION_UNDO }; - case SDLK_n: + case SDLK_SPACE: return (action_t) { .type = ACTION_NEXT }; CASE_DIGIT return (action_t) { @@ -53,9 +64,9 @@ get_key_action( return (action_t) { .type = ACTION_WARP_BUF_POP }; case SDLK_RETURN: return (action_t) { .type = ACTION_WARP }; - case 'r': + case SDLK_r: return (action_t) { .type = ACTION_RESET }; - case 's': + case SDLK_s: return (action_t) { .type = ACTION_SOLVE }; default: return (action_t) { .type = ACTION_NONE }; |