aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clak.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/clak.c b/clak.c
index d6ad034..5203032 100644
--- a/clak.c
+++ b/clak.c
@@ -1,9 +1,10 @@
#include <stdio.h>
#include <unistd.h>
+#include <string.h>
#include <windows.h>
-#define VOLUME 0.05
+#define VOLUME 0.15
#include "board/boards.h"
#define BOARD(str, buf) { .name = str, .wav = buf },
@@ -29,15 +30,30 @@ void sound_play(unsigned char* buffer)
PlaySound((const char *) buffer, NULL, SND_MEMORY | SND_SYNC | SND_NODEFAULT);
}
-int main(void)
+Board *get_board(char *board_name)
{
- sound_init();
-
for (int i = 0; i < boards_n; ++i) {
- printf("name: %s\n", boards[i].name);
- sound_play(boards[i].wav);
- sleep(0.5);
+ if (strcmp(boards[i].name, board_name) == 0)
+ return &boards[i];
+ }
+ return NULL;
+}
+
+int main(int argc, char **argv)
+{
+ Board *board;
+ if (argc < 2 || (board = get_board(argv[1])) == NULL) {
+ printf("Please provide a valid board name.\n");
+ printf("Valid boards: ");
+ for (int i = 0; i < boards_n; ++i) {
+ printf("%s%s", boards[i].name, (i == boards_n - 1) ? "\n" : ", ");
+ }
+ return 1;
}
+ sound_init();
+ printf("name: %s\n", board->name);
+ sound_play(board->wav);
+
return 0;
} \ No newline at end of file