diff options
author | hpa <hpa> | 2005-08-30 00:05:26 +0000 |
---|---|---|
committer | hpa <hpa> | 2005-08-30 00:05:26 +0000 |
commit | deec9eeabdb560545f94198686b2f93ec6d20839 (patch) | |
tree | 5ce2c5f0aeee40bdb5b5b2f620f24fb0dfa3f51e /com32/libutil | |
parent | 33dfda973ac3e937afa23c948e62dd90ec3abd94 (diff) | |
download | syslinux-deec9eeabdb560545f94198686b2f93ec6d20839.tar.gz |
Correct the enabling of the 16550A FIFOsyslinux-3.11-pre10
Diffstat (limited to 'com32/libutil')
-rw-r--r-- | com32/libutil/get_key.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/com32/libutil/get_key.c b/com32/libutil/get_key.c index 228253e2..bd06008e 100644 --- a/com32/libutil/get_key.c +++ b/com32/libutil/get_key.c @@ -1,7 +1,7 @@ #ident "$Id$" /* ----------------------------------------------------------------------- * * - * Copyright 2004 H. Peter Anvin - All Rights Reserved + * Copyright 2004-2005 H. Peter Anvin - All Rights Reserved * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -116,6 +116,8 @@ static const struct keycode keycodes[] = { }; #define NCODES ((int)(sizeof keycodes/sizeof(struct keycode))) +#define KEY_TIMEOUT ((CLK_TCK+9)/10) + int get_key(FILE *f, clock_t timeout) { unsigned char buffer[MAXLEN]; @@ -135,9 +137,12 @@ int get_key(FILE *f, clock_t timeout) rv = read(fileno(f), &ch, 1); if ( rv == 0 || (rv == -1 && errno == EAGAIN) ) { clock_t lateness = times(NULL)-start; - if ( nc && lateness > 1+CLK_TCK/20 ) - return buffer[0]; /* timeout in sequence */ - else if ( !nc && timeout && lateness > timeout ) + if ( nc && lateness > 1+KEY_TIMEOUT ) { + if ( nc == 1 ) + return buffer[0]; /* timeout in sequence */ + else if ( timeout && lateness > timeout ) + return KEY_NONE; + } else if ( !nc && timeout && lateness > timeout ) return KEY_NONE; /* timeout before sequence */ do_idle(); |