Add arrow keys return values

This commit is contained in:
Paul_Arutyunov 2018-10-13 13:45:27 +03:00
parent 42aa4c8cf1
commit 28cd69b501

View File

@ -21,6 +21,7 @@ struct gfx_state* gfx_init(struct gamestate *g)
{ {
initscr(); initscr();
cbreak(); cbreak();
keypad(stdscr, true);
noecho(); noecho();
curs_set(FALSE); curs_set(FALSE);
refresh(); refresh();
@ -116,7 +117,27 @@ int gfx_getch(struct gfx_state *s)
nodelay(s->window, TRUE); nodelay(s->window, TRUE);
while (wgetch(s->window) != ERR); while (wgetch(s->window) != ERR);
nodelay(s->window, FALSE); nodelay(s->window, FALSE);
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; return c;
break;
}
} }
void gfx_sleep(int ms) void gfx_sleep(int ms)