From 249f349e7470c59809b2566238426213c9a3cce0 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 8 Jun 2016 15:20:05 +0200 Subject: wincons: use ReadConsoleInput, thanks to GGGO (fixes #139) --- modules/wincons/wincons.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'modules/wincons/wincons.c') 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; imq, 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); + } } } -- cgit v1.2.3