From 3f95b53036f456c2cff9ebc4fc6f26c36a1740eb Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Tue, 8 Jan 2019 21:36:39 -0500 Subject: add action.c, clean up key handling --- src/libsok/sok-ctx.c | 2 +- src/libsok/sok.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/libsok') diff --git a/src/libsok/sok-ctx.c b/src/libsok/sok-ctx.c index 460c7ad..d514fe3 100644 --- a/src/libsok/sok-ctx.c +++ b/src/libsok/sok-ctx.c @@ -333,7 +333,7 @@ sok_ctx_move_box( bool sok_ctx_is_done( - sok_ctx_t * const ctx + const sok_ctx_t * const ctx ) { return ctx->num_goals_left == 0; } diff --git a/src/libsok/sok.h b/src/libsok/sok.h index 3e64afd..a633d12 100644 --- a/src/libsok/sok.h +++ b/src/libsok/sok.h @@ -24,6 +24,14 @@ typedef enum { SOK_DIR_LAST, } sok_dir_t; +#define SOK_DIR_TO_STR(dir) ( \ + ((dir) == SOK_DIR_RIGHT) ? "r" : \ + (((dir) == SOK_DIR_UP) ? "u" : \ + ((((dir) == SOK_DIR_LEFT) ? "l" : \ + (((((dir) == SOK_DIR_DOWN) ? "d" : \ + "X" \ +))))))) + typedef struct { sok_pos_t pos; sok_dir_t dir; @@ -128,7 +136,7 @@ void sok_ctx_init(sok_ctx_t * const ctx, void *user_data); _Bool sok_ctx_set_level(sok_ctx_t * const ctx, const char * const level); -_Bool sok_ctx_is_done(sok_ctx_t * const); +_Bool sok_ctx_is_done(const sok_ctx_t * const); _Bool sok_ctx_move(sok_ctx_t * const, const sok_dir_t); _Bool sok_ctx_undo(sok_ctx_t * const); -- cgit v1.2.3