Added threading
This commit is contained in:
23
csoundbox.c
23
csoundbox.c
@@ -3,6 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <ncurses.h>
|
||||
#include <getopt.h>
|
||||
#include <ao/ao.h>
|
||||
|
||||
#include "csoundbox.h"
|
||||
#include "config.h"
|
||||
@@ -50,6 +51,7 @@ int main(int argc, char *argv[]) {
|
||||
inputLocal();
|
||||
}
|
||||
cfgdestroy();
|
||||
ao_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -57,13 +59,15 @@ void inputLocal(void) {
|
||||
initscr();
|
||||
nonl(); //no newline
|
||||
noecho();
|
||||
keypad(stdscr, FALSE); //Disable the F1-12 keypad
|
||||
keypad(stdscr, TRUE); //Disable the F1-12 keypad
|
||||
curs_set(0); //Disable the cursor
|
||||
|
||||
printCursesWelcome();
|
||||
|
||||
char input;
|
||||
while ((input = getch()) != 13) {
|
||||
int input;
|
||||
//Key 13 --> ENTER
|
||||
//Key 265 --> F1
|
||||
while ((input = getch()) != 13 && input != 265) {
|
||||
playSound(lookupSounds(input));
|
||||
}
|
||||
|
||||
@@ -74,17 +78,22 @@ void inputNetwork(char *server) {
|
||||
initscr();
|
||||
nonl(); //no newline
|
||||
noecho();
|
||||
keypad(stdscr, FALSE); //Disable the F1-12 keypad
|
||||
keypad(stdscr, TRUE); //Disable the F1-12 keypad
|
||||
curs_set(0); //Disable the cursor
|
||||
|
||||
printCursesWelcome();
|
||||
|
||||
char input[2];
|
||||
while ((input[0] = getch()) != 13) {
|
||||
int inp;
|
||||
//Key 13 --> ENTER
|
||||
//Key 265 --> F1
|
||||
while ((input[0] = inp = getch()) != 13 && inp != 265) {
|
||||
input[1] = '\0';
|
||||
sendKeyUDP(server, input);
|
||||
}
|
||||
|
||||
if (inp == 265) {
|
||||
sendKeyUDP(server, "exit");
|
||||
}
|
||||
endwin();
|
||||
}
|
||||
|
||||
@@ -95,7 +104,9 @@ void printCursesWelcome(void) {
|
||||
y /= 2;
|
||||
x /= 2;
|
||||
const char *msg = "Press enter to exit.";
|
||||
const char *msg2 = "Press F1 to kill the server + client";
|
||||
mvprintw(y, x - (strlen(msg) / 2), msg);
|
||||
mvprintw(y + 1, x - (strlen(msg2) / 2), msg2);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user