aboutsummaryrefslogtreecommitdiff
path: root/src/sdl/action.c
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2019-01-13 09:32:37 -0500
committerPaul Duncan <pabs@pablotron.org>2019-01-13 09:32:37 -0500
commite4f70b11a2f91b47f474fa9e5e4e89978a57472a (patch)
tree3f568bb5eca3c99d470fc451314997a10f59bf46 /src/sdl/action.c
parent3441e42dd23f7b951e83a902cb2a3fa758341638 (diff)
downloadsok-e4f70b11a2f91b47f474fa9e5e4e89978a57472a.tar.bz2
sok-e4f70b11a2f91b47f474fa9e5e4e89978a57472a.zip
add vi navigation keys
Diffstat (limited to 'src/sdl/action.c')
-rw-r--r--src/sdl/action.c25
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 };