X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Funix%2Finput.c;fp=src%2Funix%2Finput.c;h=92c1dccfed21ad5215a1f25dfc87822a2109be90;hb=e0c59f7f4ddb73390dc9c16569254c0e2a921931;hp=6cb91d81380b355eedde4ff4651923aae0b26282;hpb=e8982df3e97d30c1f339d71f2eef924931a11040;p=oftp diff --git a/src/unix/input.c b/src/unix/input.c index 6cb91d8..92c1dcc 100644 --- a/src/unix/input.c +++ b/src/unix/input.c @@ -5,7 +5,6 @@ int init_input(void) { - nodelay(stdscr, TRUE); return 0; } @@ -13,10 +12,44 @@ void cleanup_input(void) { } +static int convkey(int key) +{ + switch(key) { + case KEY_DC: + return KB_DEL; + case KEY_IC: + return KB_INS; + case KEY_UP: + return KB_UP; + case KEY_DOWN: + return KB_DOWN; + case KEY_LEFT: + return KB_LEFT; + case KEY_RIGHT: + return KB_RIGHT; + case KEY_HOME: + return KB_HOME; + case KEY_END: + return KB_END; + case KEY_PPAGE: + return KB_PGUP; + case KEY_NPAGE: + return KB_PGDN; + default: + break; + } + if(key < 128) { + return key; + } + return -1; +} + int poll_input(union event *ev) { ev->type = EV_KEY; - ev->key.key = getch(); + if((ev->key.key = convkey(getch())) == -1) { + return 0; + } return 1; }