summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/audio_standalone.c46
1 files changed, 44 insertions, 2 deletions
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 <stdio.h>
+#if defined(_WIN32)
#include <conio.h> // Windows only, no stardard library
-
+#endif
#include "audio.h"
+#if defined(__linux)
+
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+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
+}