2 * piano.c - a piano emulator
4 * $FreeBSD: src/games/piano/piano.c,v 1.7 1999/12/12 03:22:37 billf Exp $
5 * $DragonFly: src/games/piano/piano.c,v 1.3 2005/05/31 00:22:38 swildner Exp $
17 static const char *initcmd = "t160 o1 l16 ml";
19 static const char usage_msg[] =
20 "simple keyboard player V0.8086\n"
21 "usage: %s [-v][-i str]\n"
22 "\t-i str defaults 't160 o1 l16 ml'\n"
23 "function: play by console keyboard\n"
24 "\tESC to exit. Note keys are ...\n"
25 "\t1 2 4 5 7 8 9 - = \\\n"
26 "\t Q W E R T Y U I O P [ ]\n"
34 static const char *kstr[256];
36 static struct kdef_t kdef[] = {
75 struct kdef_t *mv = kdef;
76 while (mv->str != NULL) {
77 kstr[mv->ch] = mv->str;
84 fdputs(const char *s, int fd, int p_echo)
87 size_t len = strlen(s);
89 err = write(fd, "\n", 1);
97 outspkr(const char *s)
99 int err = -1, fd = open("/dev/speaker", O_WRONLY);
101 fdputs(initcmd, fd, 0);
102 err = fdputs(s, fd, verbose);
117 while ((ch = getch()) != '\033') {
118 if (kstr[ch] != NULL) {
139 main(int argc, char *argv[])
141 int ch, ex, show_usage = 0;
143 while ((ch = getopt(argc, argv, "-vi:")) != -1) {
159 fprintf(stderr, usage_msg, myname);
162 printf("Type ESC to exit.\n");