Local input function
This commit is contained in:
29
csoundbox.c
29
csoundbox.c
@@ -9,22 +9,39 @@
|
||||
#define BITS 8
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
cfginit();
|
||||
playSound(lookupSounds('a'));
|
||||
char input;
|
||||
|
||||
inputLocal();
|
||||
cfgdestroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void inputLocal(void) {
|
||||
initscr();
|
||||
nonl(); //no newline
|
||||
noecho();
|
||||
keypad(stdscr, FALSE); //Disable the F1-12 keypad
|
||||
curs_set(0); //Disable the cursor
|
||||
|
||||
printCursesWelcome();
|
||||
|
||||
char input;
|
||||
while ((input = getch()) != 13) {
|
||||
playSound(lookupSounds(input));
|
||||
}
|
||||
|
||||
endwin();
|
||||
cfgdestroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void printCursesWelcome(void) {
|
||||
int y, x;
|
||||
getmaxyx(stdscr, y, x);
|
||||
//center
|
||||
y /= 2;
|
||||
x /= 2;
|
||||
const char *msg = "Press enter to exit.";
|
||||
mvprintw(y, x - (strlen(msg) / 2), msg);
|
||||
}
|
||||
|
||||
void playSound(const char *path) {
|
||||
|
Reference in New Issue
Block a user