Rev 1389 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1347 | giacomo | 1 | |
2 | /* |
||
3 | * Project: S.Ha.R.K. |
||
4 | * |
||
5 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * |
||
7 | * Authors : Mauro Marinoni <mauro.marinoni@unipv.it> |
||
8 | * (see authors.txt for full list of hartik's authors) |
||
9 | * |
||
10 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
11 | * |
||
12 | * http://www.sssup.it |
||
13 | * http://retis.sssup.it |
||
14 | * http://shark.sssup.it |
||
15 | */ |
||
16 | |||
17 | /* |
||
18 | * This program is free software; you can redistribute it and/or modify |
||
19 | * it under the terms of the GNU General Public License as published by |
||
20 | * the Free Software Foundation; either version 2 of the License, or |
||
21 | * (at your option) any later version. |
||
22 | * |
||
23 | * This program is distributed in the hope that it will be useful, |
||
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
26 | * GNU General Public License for more details. |
||
27 | * |
||
28 | * You should have received a copy of the GNU General Public License |
||
29 | * along with this program; if not, write to the Free Software |
||
30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
31 | */ |
||
32 | |||
33 | #include <kernel/kern.h> |
||
34 | #include <kernel/func.h> |
||
35 | #include <stdlib.h> |
||
36 | #include <string.h> |
||
37 | |||
38 | #include <drivers/shark_keyb26.h> |
||
39 | #include <drivers/shark_spk26.h> |
||
40 | |||
41 | void my_sysclose(KEY_EVT *e) |
||
42 | { |
||
43 | speaker_sound(0, 0); |
||
44 | |||
45 | kern_printf("S.Ha.R.K. closed.\n\n"); |
||
1550 | pj | 46 | exit(0); |
1347 | giacomo | 47 | } |
48 | |||
49 | void no_note(KEY_EVT *e){ |
||
50 | speaker_sound(0, 0); |
||
51 | } |
||
52 | |||
53 | void my_note(KEY_EVT *e){ |
||
54 | |||
55 | switch (e->scan) { |
||
56 | case KEY_Q: |
||
57 | speaker_sound(262, 0); |
||
58 | break; |
||
59 | case KEY_W: |
||
60 | speaker_sound(277, 0); |
||
61 | break; |
||
62 | case KEY_E: |
||
63 | speaker_sound(294, 0); |
||
64 | break; |
||
65 | case KEY_R: |
||
66 | speaker_sound(311, 0); |
||
67 | break; |
||
68 | case KEY_T: |
||
69 | speaker_sound(330, 0); |
||
70 | break; |
||
71 | case KEY_Y: |
||
72 | speaker_sound(349, 0); |
||
73 | break; |
||
74 | case KEY_U: |
||
75 | speaker_sound(370, 0); |
||
76 | break; |
||
77 | case KEY_I: |
||
78 | speaker_sound(392, 0); |
||
79 | break; |
||
80 | case KEY_O: |
||
81 | speaker_sound(415, 0); |
||
82 | break; |
||
83 | case KEY_P: |
||
84 | speaker_sound(440, 0); |
||
85 | break; |
||
86 | case KEY_BRL: |
||
87 | speaker_sound(466, 0); |
||
88 | break; |
||
89 | case KEY_BRR: |
||
90 | speaker_sound(494, 0); |
||
91 | break; |
||
92 | } |
||
93 | } |
||
94 | |||
95 | int main(int argc, char **argv) |
||
96 | { |
||
97 | KEY_EVT ev; |
||
98 | |||
99 | ev.ascii = 'c'; |
||
100 | ev.scan = KEY_C; |
||
101 | ev.status = KEY_PRESSED; |
||
102 | ev.flag = CNTL_BIT; |
||
103 | keyb_hook(ev, my_sysclose, FALSE); |
||
104 | ev.flag = CNTR_BIT; |
||
105 | keyb_hook(ev, my_sysclose, FALSE); |
||
106 | |||
107 | speaker_sound(440, 400); |
||
108 | while ( (sys_gettime(NULL)/1000) < 1000); |
||
109 | |||
110 | ev.ascii = 'q'; |
||
111 | ev.scan = KEY_Q; |
||
112 | ev.flag = 0; |
||
113 | ev.status = KEY_PRESSED; |
||
114 | keyb_hook(ev, my_note, FALSE); |
||
115 | ev.status = KEY_RELEASED; |
||
116 | keyb_hook(ev, no_note, FALSE); |
||
117 | |||
118 | ev.ascii = 'w'; |
||
119 | ev.scan = KEY_W; |
||
120 | ev.flag = 0; |
||
121 | ev.status = KEY_PRESSED; |
||
122 | keyb_hook(ev, my_note, FALSE); |
||
123 | ev.status = KEY_RELEASED; |
||
124 | keyb_hook(ev, no_note, FALSE); |
||
125 | |||
126 | ev.ascii = 'e'; |
||
127 | ev.scan = KEY_E; |
||
128 | ev.flag = 0; |
||
129 | ev.status = KEY_PRESSED; |
||
130 | keyb_hook(ev, my_note, FALSE); |
||
131 | ev.status = KEY_RELEASED; |
||
132 | keyb_hook(ev, no_note, FALSE); |
||
133 | |||
134 | ev.ascii = 'r'; |
||
135 | ev.scan = KEY_R; |
||
136 | ev.flag = 0; |
||
137 | ev.status = KEY_PRESSED; |
||
138 | keyb_hook(ev, my_note, FALSE); |
||
139 | ev.status = KEY_RELEASED; |
||
140 | keyb_hook(ev, no_note, FALSE); |
||
141 | |||
142 | ev.ascii = 't'; |
||
143 | ev.scan = KEY_T; |
||
144 | ev.flag = 0; |
||
145 | ev.status = KEY_PRESSED; |
||
146 | keyb_hook(ev, my_note, FALSE); |
||
147 | ev.status = KEY_RELEASED; |
||
148 | keyb_hook(ev, no_note, FALSE); |
||
149 | |||
150 | ev.ascii = 'y'; |
||
151 | ev.scan = KEY_Y; |
||
152 | ev.flag = 0; |
||
153 | ev.status = KEY_PRESSED; |
||
154 | keyb_hook(ev, my_note, FALSE); |
||
155 | ev.status = KEY_RELEASED; |
||
156 | keyb_hook(ev, no_note, FALSE); |
||
157 | |||
158 | ev.ascii = 'u'; |
||
159 | ev.scan = KEY_U; |
||
160 | ev.flag = 0; |
||
161 | ev.status = KEY_PRESSED; |
||
162 | keyb_hook(ev, my_note, FALSE); |
||
163 | ev.status = KEY_RELEASED; |
||
164 | keyb_hook(ev, no_note, FALSE); |
||
165 | |||
166 | ev.ascii = 'i'; |
||
167 | ev.scan = KEY_I; |
||
168 | ev.flag = 0; |
||
169 | ev.status = KEY_PRESSED; |
||
170 | keyb_hook(ev, my_note, FALSE); |
||
171 | ev.status = KEY_RELEASED; |
||
172 | keyb_hook(ev, no_note, FALSE); |
||
173 | |||
174 | ev.ascii = 'o'; |
||
175 | ev.scan = KEY_O; |
||
176 | ev.flag = 0; |
||
177 | ev.status = KEY_PRESSED; |
||
178 | keyb_hook(ev, my_note, FALSE); |
||
179 | ev.status = KEY_RELEASED; |
||
180 | keyb_hook(ev, no_note, FALSE); |
||
181 | |||
182 | ev.ascii = 'p'; |
||
183 | ev.scan = KEY_P; |
||
184 | ev.flag = 0; |
||
185 | ev.status = KEY_PRESSED; |
||
186 | keyb_hook(ev, my_note, FALSE); |
||
187 | ev.status = KEY_RELEASED; |
||
188 | keyb_hook(ev, no_note, FALSE); |
||
189 | |||
190 | ev.ascii = '['; |
||
191 | ev.scan = KEY_BRL; |
||
192 | ev.flag = 0; |
||
193 | ev.status = KEY_PRESSED; |
||
194 | keyb_hook(ev, my_note, FALSE); |
||
195 | ev.status = KEY_RELEASED; |
||
196 | keyb_hook(ev, no_note, FALSE); |
||
197 | |||
198 | ev.ascii = ']'; |
||
199 | ev.scan = KEY_BRR; |
||
200 | ev.flag = 0; |
||
201 | ev.status = KEY_PRESSED; |
||
202 | keyb_hook(ev, my_note, FALSE); |
||
203 | ev.status = KEY_RELEASED; |
||
204 | keyb_hook(ev, no_note, FALSE); |
||
1389 | mauro | 205 | |
1347 | giacomo | 206 | while(1); |
207 | return 0; |
||
208 | } |