diff options
-rw-r--r-- | payloads/libpayload/curses/keyboard.c | 34 | ||||
-rw-r--r-- | payloads/libpayload/curses/tinycurses.c | 1 | ||||
-rw-r--r-- | payloads/libpayload/include/libpayload.h | 1 | ||||
-rw-r--r-- | payloads/libpayload/libc/console.c | 16 |
4 files changed, 48 insertions, 4 deletions
diff --git a/payloads/libpayload/curses/keyboard.c b/payloads/libpayload/curses/keyboard.c index 2062ac2ffe..8e9212ceda 100644 --- a/payloads/libpayload/curses/keyboard.c +++ b/payloads/libpayload/curses/keyboard.c @@ -39,6 +39,8 @@ #include "local.h" +static int _halfdelay = 0; + /* ============== Serial ==================== */ /* FIXME: Cook the serial correctly */ @@ -241,8 +243,13 @@ static int curses_getchar(int delay) return cook_serial(c); } - if (!delay) + if (delay == 0) break; + + if (delay > 0) { + mdelay(100); + delay--; + } } c = inb(0x60); @@ -262,12 +269,33 @@ static int curses_getchar(int delay) int wgetch(WINDOW *win) { - return curses_getchar(win->_delay); + int delay = -1; + + if (_halfdelay || win->_delay) + delay = win->_delay ? 0 : _halfdelay; + + return curses_getchar(delay); } int nodelay(WINDOW *win, NCURSES_BOOL flag) { - win->_delay = flag ? 0 : -1; + win->_delay = flag ? 1 : 0; + return 0; +} + +int halfdelay(int tenths) +{ + if (tenths > 255) + return ERR; + + _halfdelay = tenths; + return 0; +} + +int nocbreak(void) +{ + /* Remove half delay timeout. */ + _halfdelay = 0; return 0; } diff --git a/payloads/libpayload/curses/tinycurses.c b/payloads/libpayload/curses/tinycurses.c index 5e707c47db..6fcb43fcf8 100644 --- a/payloads/libpayload/curses/tinycurses.c +++ b/payloads/libpayload/curses/tinycurses.c @@ -318,7 +318,6 @@ WINDOW *newwin(int num_lines, int num_columns, int begy, int begx) return win; } /* D */ int nl(void) { SP->_nl = TRUE; return OK; } -int nocbreak(void) { /* TODO */ return(*(int *)0); } /* D */ int noecho(void) { SP->_echo = FALSE; return OK; } /* D */ int nonl(void) { SP->_nl = FALSE; return OK; } // void noqiflush (void) {} diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h index b74fbfeab2..388785dba1 100644 --- a/payloads/libpayload/include/libpayload.h +++ b/payloads/libpayload/include/libpayload.h @@ -94,6 +94,7 @@ int putchar(int c); int puts(const char *s); int havekey(void); int getchar(void); +int getchar_timeout(int *ms); extern int last_putchar; diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c index b2b115b835..73e2644cd4 100644 --- a/payloads/libpayload/libc/console.c +++ b/payloads/libpayload/libc/console.c @@ -101,3 +101,19 @@ int getchar(void) #endif } } + +int getchar_timeout(int *ms) +{ + while (*ms > 0) { + if (havekey()) + return getchar(); + + mdelay(100); + *ms -= 100; + } + + if (*ms < 0) + *ms = 0; + + return 0; +} |