diff options
author | Alfred E. Heggestad <aeh@db.org> | 2016-06-08 15:20:05 +0200 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2016-06-08 15:20:05 +0200 |
commit | 249f349e7470c59809b2566238426213c9a3cce0 (patch) | |
tree | e6a8ed7c831f41c162acb19ad4580b0a91adf4ed | |
parent | f4856b5be22030624f95e29bf6c3ebc4d4005aba (diff) |
wincons: use ReadConsoleInput, thanks to GGGO (fixes #139)
-rw-r--r-- | modules/wincons/wincons.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/modules/wincons/wincons.c b/modules/wincons/wincons.c index f8e1340..5ac63f9 100644 --- a/modules/wincons/wincons.c +++ b/modules/wincons/wincons.c @@ -85,23 +85,30 @@ static DWORD WINAPI input_thread(LPVOID arg) while (st->run) { - char buf[4]; + INPUT_RECORD buf[4]; DWORD i, count = 0; - ReadConsole(st->hstdin, buf, sizeof(buf), &count, NULL); + ReadConsoleInput(st->hstdin, buf, ARRAY_SIZE(buf), &count); for (i=0; i<count; i++) { - int ch = buf[i]; - if (ch == '\r') - ch = '\n'; + if (buf[i].EventType != KEY_EVENT) + continue; - /* - * The keys are read from a thread so we have - * to send them to the RE main event loop via - * a message queue - */ - mqueue_push(st->mq, ch, 0); + if (buf[i].Event.KeyEvent.bKeyDown) { + + int ch = buf[i].Event.KeyEvent.uChar.AsciiChar; + + if (ch == '\r') + ch = '\n'; + + /* + * The keys are read from a thread so we have + * to send them to the RE main event loop via + * a message queue + */ + mqueue_push(st->mq, ch, 0); + } } } |