From c7f4c7ee6076abcb296f01e6ce4f57434800a9fc Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 15 Jun 2009 19:06:38 +0000 Subject: CLI: - Fixes keyboard input on the MinGW port. (Thanks Kona) git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2537 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- test/test.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/test/test.c b/test/test.c index 56a3de45d..0e33a6020 100644 --- a/test/test.c +++ b/test/test.c @@ -11,14 +11,18 @@ #include #include -#ifdef PTW32_STATIC_LIB +#if defined( __MINGW32__ ) +#include +#endif + +#if defined( PTW32_STATIC_LIB ) #include #endif #include "hb.h" #include "parsecsv.h" -#ifdef __APPLE_CC__ +#if defined( __APPLE_CC__ ) #import #include #include @@ -171,7 +175,7 @@ int main( int argc, char ** argv ) return 1; } -#ifdef PTW32_STATIC_LIB +#if defined( PTW32_STATIC_LIB ) pthread_win32_process_attach_np(); pthread_win32_thread_attach_np(); #endif @@ -233,7 +237,29 @@ int main( int argc, char ** argv ) /* Wait... */ while( !die ) { -#if !defined(SYS_BEOS) && !defined(__MINGW32__) +#if defined( __MINGW32__ ) + if( _kbhit() ) { + switch( _getch() ) + { + case 0x03: /* ctrl-c */ + case 'q': + fprintf( stdout, "\nEncoding Quit by user command\n" ); + die = 1; + break; + case 'p': + fprintf( stdout, "\nEncoding Paused by user command, 'r' to resume\n" ); + hb_pause( h ); + break; + case 'r': + hb_resume( h ); + break; + case 'h': + ShowCommands(); + break; + } + } + hb_snooze( 200 ); +#elif !defined(SYS_BEOS) fd_set fds; struct timeval tv; int ret; @@ -322,7 +348,7 @@ int main( int argc, char ** argv ) fprintf( stderr, "HandBrake has exited.\n" ); -#ifdef PTW32_STATIC_LIB +#if defined( PTW32_STATIC_LIB ) pthread_win32_thread_detach_np(); pthread_win32_process_detach_np(); #endif -- cgit v1.2.3