db_bridge/console.cpp
changeset 23 7acfc5eda7ed
parent 21 403742321c65
child 65 76514757b0d6
equal deleted inserted replaced
22:0db9235d68d9 23:7acfc5eda7ed
       
     1 /**
       
     2  * test/demos/db_bridge/console.cpp
       
     3  * Copyright (C) Markus Broeker
       
     4  */
       
     5 
     1 #include <console.h>
     6 #include <console.h>
     2 #include <cstdio>
     7 #include <cstdio>
     3 
     8 
     4 #ifdef WIN32
     9 #ifdef WIN32
     5 #include <windows.h>
       
     6 #include <conio.h>
    10 #include <conio.h>
     7 
    11 
     8 int Console::getch ()
    12 int Console::getch ()
     9 {
    13 {
    10     int pressed = 0;
       
    11     int ch = -1;
    14     int ch = -1;
    12 
    15 
    13     while (!pressed) {
    16     while (!kbhit ()) {
    14         if (kbhit ()) {
    17         ch =::getch ();
    15             ch =::getch ();
       
    16             pressed = 1;
       
    17         }
       
    18         Sleep (10);
       
    19     }
    18     }
       
    19 
    20     return ch;
    20     return ch;
    21 }
    21 }
    22 #else
    22 #else
    23 #include <termios.h>
    23 #include <termios.h>
    24 
    24