diff --git a/examples/audio_standalone.c b/examples/audio_standalone.c index 7688b881..d090bb83 100644 --- a/examples/audio_standalone.c +++ b/examples/audio_standalone.c @@ -24,10 +24,52 @@ ********************************************************************************************/ #include +#if defined(_WIN32) #include // Windows only, no stardard library - +#endif #include "audio.h" +#if defined(__linux) + +#include +#include +#include +#include + +static int kbhit(void) +{ + struct termios oldt, newt; + int ch; + int oldf; + + tcgetattr(STDIN_FILENO, &oldt); + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &newt); + oldf = fcntl(STDIN_FILENO, F_GETFL, 0); + fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); + + ch = getchar(); + + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); + fcntl(STDIN_FILENO, F_SETFL, oldf); + + if(ch != EOF) + { + ungetc(ch, stdin); + return 1; + } + + return 0; +} + +static char getch() +{ + return getchar(); +} + +#endif + #define KEY_ESCAPE 27 int main() @@ -78,4 +120,4 @@ int main() //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +}