summaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses/keyboard.c
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2008-04-08 23:21:33 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2008-04-08 23:21:33 +0000
commit672d0ae15655aa8c28e2ac0e698e501628347b7c (patch)
treed8777af35f8dc2300aa953b0e463aa667a0a8394 /payloads/libpayload/curses/keyboard.c
parent4eb5089821b014d84fac2ef432da0f7bbaba754e (diff)
downloadcoreboot-672d0ae15655aa8c28e2ac0e698e501628347b7c.tar.xz
libpayload: Add a timeout function for getchar and getch
Implement a timeout option for getchar() to return after so many milliseconds. Also implement the same thing for curses using the halfdelay() function. Signed-off-by: Jordan Crouse <jordan.crouse@amd.com> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3223 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/curses/keyboard.c')
-rw-r--r--payloads/libpayload/curses/keyboard.c34
1 files changed, 31 insertions, 3 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;
}