1 #include <libchimara/glk.h>
9 if(!glk_gestalt(gestalt_Sound, 0)) {
10 fprintf(stderr, "Sound not supported.\n");
13 if(!glk_gestalt(gestalt_SoundVolume, 0)) {
14 fprintf(stderr, "Sound volume not supported.\n");
17 if(!glk_gestalt(gestalt_SoundNotify, 0)) {
18 fprintf(stderr, "Sound notification not supported.\n");
22 schanid_t sc = glk_schannel_create(0);
24 fprintf(stderr, "Could not create sound channel.\n");
28 /* Open the main window. */
29 winid_t mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
31 /* It's possible that the main window failed to open. There's
32 nothing we can do without it, so exit. */
35 glk_set_window(mainwin);
43 glk_put_string("\nprompt> ");
44 glk_request_line_event(mainwin, buffer, 1024, 0);
46 printf("Received event:\n");
47 printf("Type: %d\n", ev.type);
48 printf("Win: %d\n", glk_window_get_rock(ev.win) );
49 printf("Var1: %d\n", ev.val1);
50 printf("Var2: %d\n", ev.val2);
52 case evtype_LineInput:
53 // Null-terminate string
57 if(strcmp(buffer, "quit") == 0) {
58 glk_put_string("That's all, folks.\n");
60 } else if(strcmp(buffer, "play") == 0) {
61 glk_put_string("Playing sound.\n");
62 if(!glk_schannel_play(sc, 3)) {
63 fprintf(stderr, "Could not start sound channel.\n");
66 } else if(strcmp(buffer, "help") == 0) {
67 glk_put_string("Type PLAY or QUIT.\n");
70 case evtype_SoundNotify:
71 glk_put_string("\nGot sound notify event!\n");
78 glk_schannel_stop(sc);
79 glk_schannel_destroy(sc);