X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fdos%2Finput.c;fp=src%2Fdos%2Finput.c;h=34632b6de9017684f895754708680a8484a8e2f3;hb=214a070238552de6167bbf506cbc23006969a182;hp=4b36e4a38947510c13be9281988f39bc1921b12e;hpb=d3c8a942b99443abf0c11d9759994022ed6da597;p=oftp diff --git a/src/dos/input.c b/src/dos/input.c index 4b36e4a..34632b6 100644 --- a/src/dos/input.c +++ b/src/dos/input.c @@ -10,11 +10,61 @@ void cleanup_input(void) { } +static int conv_special(int key) +{ + switch(key) { + case 72: + return KB_UP; + case 80: + return KB_DOWN; + case 75: + return KB_LEFT; + case 77: + return KB_RIGHT; + case 71: + return KB_HOME; + case 79: + return KB_END; + case 82: + return KB_INS; + case 83: + return KB_DEL; + case 73: + return KB_PGUP; + case 81: + return KB_PGDN; + default: + break; + } + + if(key >= 58 && key <= 70) { + return KB_F1 + (key - 59); + } + + return -1; +} + int poll_input(union event *ev) { + static int special; + if(have_input()) { ev->type = EV_KEY; - ev->key.key = getch(); + if((ev->key.key = getch()) == 0) { + special = 1; + return 0; + } + + if(special) { + special = 0; + if((ev->key.key = conv_special(ev->key.key)) == -1) { + return 0; + } + } else { + if(ev->key.key == '\r') { + ev->key.key = '\n'; + } + } return 1; } return 0;