Skip to content

Commit

Permalink
Fixed 'lag' issue with arrow keys
Browse files Browse the repository at this point in the history
  • Loading branch information
lornix committed Jul 29, 2014
1 parent 696779f commit b7430a3
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions fauxcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,20 @@ static void connect_user(int escape_char)
/* build fd_set for select */
fd_set readfds;
FD_ZERO(&readfds);
/* listen for stdin */
FD_SET(0,&readfds);
struct timeval tval;

while (1) {
int sel=select(1,&readfds,NULL,NULL,NULL);
/* listen for stdin */
FD_SET(0,&readfds);
/* reset timeout to 1usec */
tval.tv_sec=0;
tval.tv_usec=1;
int sel=select(1,&readfds,NULL,NULL,&tval);
if (sel<0) {
/* something bad happened */
perror("Error during select");
break;
}
if (sel==0) {
/* nobody available, try again */
/* listen for stdin again, since it was reset */
FD_SET(0,&readfds);
continue;
}

/* supposed to be a character ready */
int chr=getchar();
Expand Down Expand Up @@ -350,7 +348,15 @@ static void connect_user(int escape_char)
sendchar(chr);

/* verbose output? (very verbose!) */
if (verbose_mode>1) {
if (verbose_mode>2) {
putchar("0123456789abcdef"[chr/16]);
putchar("0123456789abcdef"[chr%16]);
if (chr>' ') {
putchar(' ');
putchar(chr);
}
putchar('\n');
} else if (verbose_mode>1) {
putchar(chr);
}
}
Expand Down

0 comments on commit b7430a3

Please sign in to comment.