From d611ced6461305e30f0b151a847743f3bdb1fec7 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Thu, 4 Aug 2011 05:09:25 -0400 Subject: [PATCH] Live sending --- ntester.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/ntester.cpp b/ntester.cpp index e14551f..29e635c 100644 --- a/ntester.cpp +++ b/ntester.cpp @@ -1,3 +1,6 @@ +#include +#include + #include "network.hpp" #include "keystroke.hpp" @@ -29,13 +32,28 @@ int main( int argc, char *argv[] ) while ( true ) { KeyStroke s = n->recv(); - fprintf( stderr, "Got KeyStroke: %c\n", s.letter ); + printf( "%c", s.letter ); + fflush( NULL ); } } else { - while( true ) { - sleep( 1 ); + struct termios the_termios; - KeyStroke t( string( "x", 1 ) ); + if ( tcgetattr( STDIN_FILENO, &the_termios ) < 0 ) { + perror( "tcgetattr" ); + exit( 1 ); + } + + cfmakeraw( &the_termios ); + + if ( tcsetattr( STDIN_FILENO, TCSANOW, &the_termios ) < 0 ) { + perror( "tcsetattr" ); + exit( 1 ); + } + + while( true ) { + char x = getchar(); + + KeyStroke t( string( &x, 1 ) ); n->send( t ); }