summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/io.c b/io.c
index 9848e8d..0c3a327 100644
--- a/io.c
+++ b/io.c
@@ -44,13 +44,14 @@ static inline char *get_keyseq(int keycode) {
}
}
-int get_key(WINDOW *scr) {
+int get_key(WINDOW *scr, int delay, uint64_t cycles) {
int x, y;
int c;
int keycode = 0;
int tmp_flag = dbg_print_per_inst;
- curs_set(1);
- if ((key == NULL) || (key && key[key_idx] == '\0') || !kbd_rdy) {
+ wtimeout(scr, delay);
+ curs_set((delay < 0));
+ if ((key == NULL) || (key && key[key_idx] == '\0') || !kbd_rdy || delay >= 0) {
c = wgetch(scr);
if (c == 19) {
if (kbd_rdy) {
@@ -60,13 +61,13 @@ int get_key(WINDOW *scr) {
} else if (c == 0x11) {
end = 1;
}
- if (kbd_rdy) {
+ if (kbd_rdy && delay < 0) {
key_idx = 0;
key = get_keyseq(c);
}
keycode = c;
}
- if (kbd_rdy) {
+ if (kbd_rdy && delay < 0) {
c = (key != NULL) ? key[key_idx++] : c;
}
@@ -106,7 +107,7 @@ int get_key(WINDOW *scr) {
}
}
- if (kbd_rdy) {
+ if (kbd_rdy && delay < 0) {
switch (c) {
case ERR:
addr[CTRL_ADDR] = 0;