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 ); }