From 28cd69b501349227835026f424f943e320b36d68 Mon Sep 17 00:00:00 2001 From: Paul_Arutyunov Date: Sat, 13 Oct 2018 13:45:27 +0300 Subject: [PATCH] Add arrow keys return values --- src/gfx_curses.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/gfx_curses.c b/src/gfx_curses.c index 4db2467..bfa3ad0 100644 --- a/src/gfx_curses.c +++ b/src/gfx_curses.c @@ -21,6 +21,7 @@ struct gfx_state* gfx_init(struct gamestate *g) { initscr(); cbreak(); + keypad(stdscr, true); noecho(); curs_set(FALSE); refresh(); @@ -116,7 +117,27 @@ int gfx_getch(struct gfx_state *s) nodelay(s->window, TRUE); while (wgetch(s->window) != ERR); nodelay(s->window, FALSE); - return c; + + switch (c) + { + case KEY_UP: + return INPUT_UP; + break; + case KEY_DOWN: + return INPUT_DOWN; + break; + case KEY_RIGHT: + return INPUT_RIGHT; + break; + case KEY_LEFT: + return INPUT_LEFT; + break; + + default: + return c; + break; + + } } void gfx_sleep(int ms)