Rev 1389 | Go to most recent revision | Details | 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 | * Copyright (C) 2000 Paolo Gai |
||
19 | * |
||
20 | * This program is free software; you can redistribute it and/or modify |
||
21 | * it under the terms of the GNU General Public License as published by |
||
22 | * the Free Software Foundation; either version 2 of the License, or |
||
23 | * (at your option) any later version. |
||
24 | * |
||
25 | * This program is distributed in the hope that it will be useful, |
||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
28 | * GNU General Public License for more details. |
||
29 | * |
||
30 | * You should have received a copy of the GNU General Public License |
||
31 | * along with this program; if not, write to the Free Software |
||
32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
33 | * |
||
34 | */ |
||
35 | |||
36 | #include <kernel/kern.h> |
||
37 | #include <kernel/func.h> |
||
38 | #include <stdlib.h> |
||
39 | #include <string.h> |
||
40 | |||
41 | #include <drivers/shark_linuxc26.h> |
||
42 | #include <drivers/shark_input26.h> |
||
43 | #include <drivers/shark_keyb26.h> |
||
44 | #include <drivers/shark_spk26.h> |
||
45 | |||
46 | void my_sysclose(KEY_EVT *e) |
||
47 | { |
||
48 | speaker_sound(0, 0); |
||
49 | |||
50 | cprintf("Keyboard Close : %d\n", KEYB26_close()); |
||
51 | cprintf("Speaker Close : %d\n", SPEAK26_close()); |
||
52 | cprintf("Input Close : %d\n", INPUT26_close()); |
||
53 | |||
54 | kern_printf("S.Ha.R.K. closed.\n\n"); |
||
55 | sys_end(); |
||
56 | } |
||
57 | |||
58 | void no_note(KEY_EVT *e){ |
||
59 | speaker_sound(0, 0); |
||
60 | } |
||
61 | |||
62 | void my_note(KEY_EVT *e){ |
||
63 | |||
64 | switch (e->scan) { |
||
65 | case KEY_Q: |
||
66 | speaker_sound(262, 0); |
||
67 | break; |
||
68 | case KEY_W: |
||
69 | speaker_sound(277, 0); |
||
70 | break; |
||
71 | case KEY_E: |
||
72 | speaker_sound(294, 0); |
||
73 | break; |
||
74 | case KEY_R: |
||
75 | speaker_sound(311, 0); |
||
76 | break; |
||
77 | case KEY_T: |
||
78 | speaker_sound(330, 0); |
||
79 | break; |
||
80 | case KEY_Y: |
||
81 | speaker_sound(349, 0); |
||
82 | break; |
||
83 | case KEY_U: |
||
84 | speaker_sound(370, 0); |
||
85 | break; |
||
86 | case KEY_I: |
||
87 | speaker_sound(392, 0); |
||
88 | break; |
||
89 | case KEY_O: |
||
90 | speaker_sound(415, 0); |
||
91 | break; |
||
92 | case KEY_P: |
||
93 | speaker_sound(440, 0); |
||
94 | break; |
||
95 | case KEY_BRL: |
||
96 | speaker_sound(466, 0); |
||
97 | break; |
||
98 | case KEY_BRR: |
||
99 | speaker_sound(494, 0); |
||
100 | break; |
||
101 | } |
||
102 | } |
||
103 | |||
104 | int main(int argc, char **argv) |
||
105 | { |
||
106 | KEY_EVT ev; |
||
107 | |||
108 | ev.ascii = 'c'; |
||
109 | ev.scan = KEY_C; |
||
110 | ev.status = KEY_PRESSED; |
||
111 | ev.flag = CNTL_BIT; |
||
112 | keyb_hook(ev, my_sysclose, FALSE); |
||
113 | ev.flag = CNTR_BIT; |
||
114 | keyb_hook(ev, my_sysclose, FALSE); |
||
115 | |||
116 | speaker_sound(440, 400); |
||
117 | while ( (sys_gettime(NULL)/1000) < 1000); |
||
118 | |||
119 | ev.ascii = 'q'; |
||
120 | ev.scan = KEY_Q; |
||
121 | ev.flag = 0; |
||
122 | ev.status = KEY_PRESSED; |
||
123 | keyb_hook(ev, my_note, FALSE); |
||
124 | ev.status = KEY_RELEASED; |
||
125 | keyb_hook(ev, no_note, FALSE); |
||
126 | |||
127 | ev.ascii = 'w'; |
||
128 | ev.scan = KEY_W; |
||
129 | ev.flag = 0; |
||
130 | ev.status = KEY_PRESSED; |
||
131 | keyb_hook(ev, my_note, FALSE); |
||
132 | ev.status = KEY_RELEASED; |
||
133 | keyb_hook(ev, no_note, FALSE); |
||
134 | |||
135 | ev.ascii = 'e'; |
||
136 | ev.scan = KEY_E; |
||
137 | ev.flag = 0; |
||
138 | ev.status = KEY_PRESSED; |
||
139 | keyb_hook(ev, my_note, FALSE); |
||
140 | ev.status = KEY_RELEASED; |
||
141 | keyb_hook(ev, no_note, FALSE); |
||
142 | |||
143 | ev.ascii = 'r'; |
||
144 | ev.scan = KEY_R; |
||
145 | ev.flag = 0; |
||
146 | ev.status = KEY_PRESSED; |
||
147 | keyb_hook(ev, my_note, FALSE); |
||
148 | ev.status = KEY_RELEASED; |
||
149 | keyb_hook(ev, no_note, FALSE); |
||
150 | |||
151 | ev.ascii = 't'; |
||
152 | ev.scan = KEY_T; |
||
153 | ev.flag = 0; |
||
154 | ev.status = KEY_PRESSED; |
||
155 | keyb_hook(ev, my_note, FALSE); |
||
156 | ev.status = KEY_RELEASED; |
||
157 | keyb_hook(ev, no_note, FALSE); |
||
158 | |||
159 | ev.ascii = 'y'; |
||
160 | ev.scan = KEY_Y; |
||
161 | ev.flag = 0; |
||
162 | ev.status = KEY_PRESSED; |
||
163 | keyb_hook(ev, my_note, FALSE); |
||
164 | ev.status = KEY_RELEASED; |
||
165 | keyb_hook(ev, no_note, FALSE); |
||
166 | |||
167 | ev.ascii = 'u'; |
||
168 | ev.scan = KEY_U; |
||
169 | ev.flag = 0; |
||
170 | ev.status = KEY_PRESSED; |
||
171 | keyb_hook(ev, my_note, FALSE); |
||
172 | ev.status = KEY_RELEASED; |
||
173 | keyb_hook(ev, no_note, FALSE); |
||
174 | |||
175 | ev.ascii = 'i'; |
||
176 | ev.scan = KEY_I; |
||
177 | ev.flag = 0; |
||
178 | ev.status = KEY_PRESSED; |
||
179 | keyb_hook(ev, my_note, FALSE); |
||
180 | ev.status = KEY_RELEASED; |
||
181 | keyb_hook(ev, no_note, FALSE); |
||
182 | |||
183 | ev.ascii = 'o'; |
||
184 | ev.scan = KEY_O; |
||
185 | ev.flag = 0; |
||
186 | ev.status = KEY_PRESSED; |
||
187 | keyb_hook(ev, my_note, FALSE); |
||
188 | ev.status = KEY_RELEASED; |
||
189 | keyb_hook(ev, no_note, FALSE); |
||
190 | |||
191 | ev.ascii = 'p'; |
||
192 | ev.scan = KEY_P; |
||
193 | ev.flag = 0; |
||
194 | ev.status = KEY_PRESSED; |
||
195 | keyb_hook(ev, my_note, FALSE); |
||
196 | ev.status = KEY_RELEASED; |
||
197 | keyb_hook(ev, no_note, FALSE); |
||
198 | |||
199 | ev.ascii = '['; |
||
200 | ev.scan = KEY_BRL; |
||
201 | ev.flag = 0; |
||
202 | ev.status = KEY_PRESSED; |
||
203 | keyb_hook(ev, my_note, FALSE); |
||
204 | ev.status = KEY_RELEASED; |
||
205 | keyb_hook(ev, no_note, FALSE); |
||
206 | |||
207 | ev.ascii = ']'; |
||
208 | ev.scan = KEY_BRR; |
||
209 | ev.flag = 0; |
||
210 | ev.status = KEY_PRESSED; |
||
211 | keyb_hook(ev, my_note, FALSE); |
||
212 | ev.status = KEY_RELEASED; |
||
213 | keyb_hook(ev, no_note, FALSE); |
||
214 | |||
215 | /*while ( (sys_gettime(NULL)/1000) < 20000); |
||
216 | my_sysclose(NULL);*/ |
||
217 | |||
218 | while(1); |
||
219 | return 0; |
||
220 | } |