aboutsummaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-14 11:06:35 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-14 11:06:35 +1000
commit87911f4fcd86f7abc0aefba8e9cbec2ac9d127e4 (patch)
treec91a4a9a048f3cc2bdae47fa61a02db7a108170d /win32
parentba3cea41689d211093d914212de048cc06d976ce (diff)
parent9375ca983262075d8420fd0d88d00a088916fc10 (diff)
downloadbusybox-w32-87911f4fcd86f7abc0aefba8e9cbec2ac9d127e4.tar.gz
busybox-w32-87911f4fcd86f7abc0aefba8e9cbec2ac9d127e4.tar.bz2
busybox-w32-87911f4fcd86f7abc0aefba8e9cbec2ac9d127e4.zip
Merge branch 'ash'
Diffstat (limited to 'win32')
-rw-r--r--win32/termios.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/win32/termios.c b/win32/termios.c
index 0aba48546..6d85ff98e 100644
--- a/win32/termios.c
+++ b/win32/termios.c
@@ -1,4 +1,4 @@
1#include "busybox.h" 1#include "libbb.h"
2 2
3int tcsetattr(int fd UNUSED_PARAM, int mode UNUSED_PARAM, const struct termios *t UNUSED_PARAM) 3int tcsetattr(int fd UNUSED_PARAM, int mode UNUSED_PARAM, const struct termios *t UNUSED_PARAM)
4{ 4{
@@ -9,3 +9,28 @@ int tcgetattr(int fd UNUSED_PARAM, struct termios *t UNUSED_PARAM)
9{ 9{
10 return -1; 10 return -1;
11} 11}
12
13int64_t FAST_FUNC read_key(int fd, char *buf, int timeout UNUSED_PARAM)
14{
15 static int initialized = 0;
16 HANDLE cin = GetStdHandle(STD_INPUT_HANDLE);
17 INPUT_RECORD record;
18 DWORD nevent_out;
19
20 if (fd != 0)
21 bb_error_msg_and_die("read_key only works on stdin");
22 if (cin == INVALID_HANDLE_VALUE)
23 return -1;
24 if (!initialized) {
25 SetConsoleMode(cin, ENABLE_ECHO_INPUT);
26 initialized = 1;
27 }
28
29 while (1) {
30 if (!ReadConsoleInput(cin, &record, 1, &nevent_out))
31 return -1;
32 if (record.EventType != KEY_EVENT || !record.Event.KeyEvent.bKeyDown)
33 continue;
34 return record.Event.KeyEvent.uChar.AsciiChar;
35 }
36}