Rev 1622 | Rev 1644 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1622 | Rev 1632 | ||
---|---|---|---|
Line 26... | Line 26... | ||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <arch/kbd.h> |
29 | #include <arch/kbd.h> |
30 | #include <ipc/ipc.h> |
30 | #include <ipc/ipc.h> |
- | 31 | #include <sysinfo.h> |
|
31 | 32 | ||
32 | 33 | ||
33 | #define KEY_F1 0x504f1bL |
34 | #define MSIM_KEY_F1 0x504f1bL |
34 | #define KEY_F2 0x514f1bL |
35 | #define MSIM_KEY_F2 0x514f1bL |
35 | #define KEY_F3 0x524f1bL |
36 | #define MSIM_KEY_F3 0x524f1bL |
36 | #define KEY_F4 0x534f1bL |
37 | #define MSIM_KEY_F4 0x534f1bL |
37 | #define KEY_F5 0x35315b1bL |
38 | #define MSIM_KEY_F5 0x35315b1bL |
38 | #define KEY_F6 0x37315b1bL |
39 | #define MSIM_KEY_F6 0x37315b1bL |
39 | #define KEY_F7 0x38315b1bL |
40 | #define MSIM_KEY_F7 0x38315b1bL |
40 | #define KEY_F8 0x39315b1bL |
41 | #define MSIM_KEY_F8 0x39315b1bL |
41 | #define KEY_F9 0x30325b1bL |
42 | #define MSIM_KEY_F9 0x30325b1bL |
42 | #define KEY_F10 0x31325b1bL |
43 | #define MSIM_KEY_F10 0x31325b1bL |
43 | #define KEY_F11 0x33325b1bL |
44 | #define MSIM_KEY_F11 0x33325b1bL |
44 | #define KEY_F12 0x34325b1bL |
45 | #define MSIM_KEY_F12 0x34325b1bL |
- | 46 | ||
- | 47 | ||
- | 48 | #define GXEMUL_KEY_F1 0x504f5b1bL |
|
- | 49 | #define GXEMUL_KEY_F2 0x514f5b1bL |
|
- | 50 | #define GXEMUL_KEY_F3 0x524f5b1bL |
|
- | 51 | #define GXEMUL_KEY_F4 0x534f5b1bL |
|
- | 52 | #define GXEMUL_KEY_F5 0x35315b1bL |
|
- | 53 | #define GXEMUL_KEY_F6 0x37315b1bL |
|
- | 54 | #define GXEMUL_KEY_F7 0x38315b1bL |
|
- | 55 | #define GXEMUL_KEY_F8 0x39315b1bL |
|
- | 56 | #define GXEMUL_KEY_F9 0x38325b1bL |
|
- | 57 | #define GXEMUL_KEY_F10 0x39325b1bL |
|
- | 58 | #define GXEMUL_KEY_F11 0x33325b1bL |
|
- | 59 | #define GXEMUL_KEY_F12 0x34325b1bL |
|
45 | 60 | ||
46 | 61 | ||
47 | #define FUNCTION_KEYS 0x100 |
62 | #define FUNCTION_KEYS 0x100 |
48 | 63 | ||
49 | 64 | ||
Line 54... | Line 69... | ||
54 | irq_code_t msim_kbd = { |
69 | irq_code_t msim_kbd = { |
55 | 1, |
70 | 1, |
56 | msim_cmds |
71 | msim_cmds |
57 | }; |
72 | }; |
58 | 73 | ||
- | 74 | static int msim,gxemul; |
|
- | 75 | ||
59 | int kbd_arch_init(void) |
76 | int kbd_arch_init(void) |
60 | { |
77 | { |
61 | ipc_register_irq(2, &msim_kbd); |
78 | ipc_register_irq(2, &msim_kbd); |
- | 79 | msim=sysinfo_value("machine.msim"); |
|
- | 80 | gxemul=sysinfo_value("machine.lgxemul"); |
|
62 | return 1; |
81 | return 1; |
63 | } |
82 | } |
64 | 83 | ||
65 | 84 | ||
66 | /* |
85 | //* |
67 | * |
86 | //* |
68 | * Please preserve this code (it can be used to determine scancodes) |
87 | //* Please preserve this code (it can be used to determine scancodes) |
69 | * |
88 | //* |
70 | int to_hex(int v) |
89 | int to_hex(int v) |
71 | { |
90 | { |
72 | return "0123456789ABCDEF"[v]; |
91 | return "0123456789ABCDEF"[v]; |
73 | } |
92 | } |
74 | */ |
93 | //*/ |
75 | 94 | ||
76 | int kbd_arch_process(keybuffer_t *keybuffer, int scan_code) |
95 | static int kbd_arch_process_msim(keybuffer_t *keybuffer, int scan_code) |
77 | { |
96 | { |
78 | 97 | ||
79 | static unsigned long buf=0; |
98 | static unsigned long buf=0; |
80 | static int count=0; |
99 | static int count=0; |
81 | 100 | ||
Line 91... | Line 110... | ||
91 | 110 | ||
92 | 111 | ||
93 | if(scan_code==0x7e) |
112 | if(scan_code==0x7e) |
94 | { |
113 | { |
95 | switch (buf){ |
114 | switch (buf){ |
96 | case KEY_F5: |
115 | case MSIM_KEY_F5: |
97 | keybuffer_push(keybuffer,FUNCTION_KEYS | 5 ); |
116 | keybuffer_push(keybuffer,FUNCTION_KEYS | 5 ); |
98 | buf=count=0; |
117 | buf=count=0; |
99 | return 1; |
118 | return 1; |
100 | case KEY_F6: |
119 | case MSIM_KEY_F6: |
101 | keybuffer_push(keybuffer,FUNCTION_KEYS | 6 ); |
120 | keybuffer_push(keybuffer,FUNCTION_KEYS | 6 ); |
102 | buf=count=0; |
121 | buf=count=0; |
103 | return 1; |
122 | return 1; |
104 | case KEY_F7: |
123 | case MSIM_KEY_F7: |
105 | keybuffer_push(keybuffer,FUNCTION_KEYS | 7 ); |
124 | keybuffer_push(keybuffer,FUNCTION_KEYS | 7 ); |
106 | buf=count=0; |
125 | buf=count=0; |
107 | return 1; |
126 | return 1; |
108 | case KEY_F8: |
127 | case MSIM_KEY_F8: |
109 | keybuffer_push(keybuffer,FUNCTION_KEYS | 8 ); |
128 | keybuffer_push(keybuffer,FUNCTION_KEYS | 8 ); |
110 | buf=count=0; |
129 | buf=count=0; |
111 | return 1; |
130 | return 1; |
112 | 131 | ||
113 | case KEY_F9: |
132 | case MSIM_KEY_F9: |
114 | keybuffer_push(keybuffer,FUNCTION_KEYS | 9 ); |
133 | keybuffer_push(keybuffer,FUNCTION_KEYS | 9 ); |
115 | buf=count=0; |
134 | buf=count=0; |
116 | return 1; |
135 | return 1; |
117 | case KEY_F10: |
136 | case MSIM_KEY_F10: |
118 | keybuffer_push(keybuffer,FUNCTION_KEYS | 10 ); |
137 | keybuffer_push(keybuffer,FUNCTION_KEYS | 10 ); |
119 | buf=count=0; |
138 | buf=count=0; |
120 | return 1; |
139 | return 1; |
121 | 140 | ||
122 | case KEY_F11: |
141 | case MSIM_KEY_F11: |
123 | keybuffer_push(keybuffer,FUNCTION_KEYS | 11 ); |
142 | keybuffer_push(keybuffer,FUNCTION_KEYS | 11 ); |
124 | buf=count=0; |
143 | buf=count=0; |
125 | return 1; |
144 | return 1; |
126 | case KEY_F12: |
145 | case MSIM_KEY_F12: |
127 | keybuffer_push(keybuffer,FUNCTION_KEYS | 12 ); |
146 | keybuffer_push(keybuffer,FUNCTION_KEYS | 12 ); |
128 | buf=count=0; |
147 | buf=count=0; |
129 | return 1; |
148 | return 1; |
130 | default: |
149 | default: |
131 | keybuffer_push(keybuffer, buf & 0xff ); |
150 | keybuffer_push(keybuffer, buf & 0xff ); |
Line 140... | Line 159... | ||
140 | } |
159 | } |
141 | 160 | ||
142 | buf|=((unsigned long) scan_code)<<(8*(count++)); |
161 | buf|=((unsigned long) scan_code)<<(8*(count++)); |
143 | 162 | ||
144 | 163 | ||
145 | if((buf & 0xff)!= (KEY_F1 & 0xff)) { |
164 | if((buf & 0xff)!= (MSIM_KEY_F1 & 0xff)) { |
146 | 165 | ||
147 | keybuffer_push(keybuffer,buf ); |
166 | keybuffer_push(keybuffer,buf ); |
148 | buf=count=0; |
167 | buf=count=0; |
149 | return 1; |
168 | return 1; |
150 | } |
169 | } |
151 | 170 | ||
152 | if ( count <= 1 ) |
171 | if ( count <= 1 ) |
153 | return 1; |
172 | return 1; |
154 | 173 | ||
155 | if( (buf & 0xffff) != (KEY_F1 & 0xffff) |
174 | if( (buf & 0xffff) != (MSIM_KEY_F1 & 0xffff) |
156 | && (buf & 0xffff) != (KEY_F5 & 0xffff) ) { |
175 | && (buf & 0xffff) != (MSIM_KEY_F5 & 0xffff) ) { |
157 | 176 | ||
158 | keybuffer_push(keybuffer, buf & 0xff ); |
177 | keybuffer_push(keybuffer, buf & 0xff ); |
159 | keybuffer_push(keybuffer, (buf >> 8) &0xff ); |
178 | keybuffer_push(keybuffer, (buf >> 8) &0xff ); |
160 | buf=count=0; |
179 | buf=count=0; |
161 | return 1; |
180 | return 1; |
Line 163... | Line 182... | ||
163 | 182 | ||
164 | if ( count <= 2) |
183 | if ( count <= 2) |
165 | return 1; |
184 | return 1; |
166 | 185 | ||
167 | switch (buf){ |
186 | switch (buf){ |
168 | case KEY_F1: |
187 | case MSIM_KEY_F1: |
169 | keybuffer_push(keybuffer,FUNCTION_KEYS | 1 ); |
188 | keybuffer_push(keybuffer,FUNCTION_KEYS | 1 ); |
170 | buf=count=0; |
189 | buf=count=0; |
171 | return 1; |
190 | return 1; |
172 | case KEY_F2: |
191 | case MSIM_KEY_F2: |
173 | keybuffer_push(keybuffer,FUNCTION_KEYS | 2 ); |
192 | keybuffer_push(keybuffer,FUNCTION_KEYS | 2 ); |
174 | buf=count=0; |
193 | buf=count=0; |
175 | return 1; |
194 | return 1; |
176 | case KEY_F3: |
195 | case MSIM_KEY_F3: |
177 | keybuffer_push(keybuffer,FUNCTION_KEYS | 3 ); |
196 | keybuffer_push(keybuffer,FUNCTION_KEYS | 3 ); |
178 | buf=count=0; |
197 | buf=count=0; |
179 | return 1; |
198 | return 1; |
180 | case KEY_F4: |
199 | case MSIM_KEY_F4: |
181 | keybuffer_push(keybuffer,FUNCTION_KEYS | 4 ); |
200 | keybuffer_push(keybuffer,FUNCTION_KEYS | 4 ); |
182 | buf=count=0; |
201 | buf=count=0; |
183 | return 1; |
202 | return 1; |
184 | } |
203 | } |
185 | 204 | ||
186 | 205 | ||
187 | if( (buf & 0xffffff) != (KEY_F5 & 0xffffff) |
206 | if( (buf & 0xffffff) != (MSIM_KEY_F5 & 0xffffff) |
188 | && (buf & 0xffffff) != (KEY_F9 & 0xffffff) ) { |
207 | && (buf & 0xffffff) != (MSIM_KEY_F9 & 0xffffff) ) { |
189 | 208 | ||
190 | keybuffer_push(keybuffer, buf & 0xff ); |
209 | keybuffer_push(keybuffer, buf & 0xff ); |
191 | keybuffer_push(keybuffer, (buf >> 8) &0xff ); |
210 | keybuffer_push(keybuffer, (buf >> 8) &0xff ); |
192 | keybuffer_push(keybuffer, (buf >> 16) &0xff ); |
211 | keybuffer_push(keybuffer, (buf >> 16) &0xff ); |
193 | buf=count=0; |
212 | buf=count=0; |
Line 199... | Line 218... | ||
199 | 218 | ||
200 | 219 | ||
201 | 220 | ||
202 | 221 | ||
203 | switch (buf){ |
222 | switch (buf){ |
204 | case KEY_F5: |
223 | case MSIM_KEY_F5: |
205 | case KEY_F6: |
224 | case MSIM_KEY_F6: |
206 | case KEY_F7: |
225 | case MSIM_KEY_F7: |
207 | case KEY_F8: |
226 | case MSIM_KEY_F8: |
208 | case KEY_F9: |
227 | case MSIM_KEY_F9: |
209 | case KEY_F10: |
228 | case MSIM_KEY_F10: |
210 | case KEY_F11: |
229 | case MSIM_KEY_F11: |
211 | case KEY_F12: |
230 | case MSIM_KEY_F12: |
212 | return 1; |
231 | return 1; |
213 | default: |
232 | default: |
214 | keybuffer_push(keybuffer, buf & 0xff ); |
233 | keybuffer_push(keybuffer, buf & 0xff ); |
215 | keybuffer_push(keybuffer, (buf >> 8) &0xff ); |
234 | keybuffer_push(keybuffer, (buf >> 8) &0xff ); |
216 | keybuffer_push(keybuffer, (buf >> 16) &0xff ); |
235 | keybuffer_push(keybuffer, (buf >> 16) &0xff ); |
Line 219... | Line 238... | ||
219 | return 1; |
238 | return 1; |
220 | 239 | ||
221 | } |
240 | } |
222 | return 1; |
241 | return 1; |
223 | } |
242 | } |
- | 243 | ||
- | 244 | ||
- | 245 | ||
- | 246 | static int kbd_arch_process_gxemul(keybuffer_t *keybuffer, int scan_code) |
|
- | 247 | { |
|
- | 248 | ||
- | 249 | static unsigned long buf=0; |
|
- | 250 | static int count=0; |
|
- | 251 | ||
- | 252 | ||
- | 253 | //* Please preserve this code (it can be used to determine scancodes) |
|
- | 254 | //* |
|
- | 255 | //keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf)); |
|
- | 256 | //keybuffer_push(keybuffer, to_hex(scan_code&0xf)); |
|
- | 257 | //keybuffer_push(keybuffer, ' '); |
|
- | 258 | //keybuffer_push(keybuffer, ' '); |
|
- | 259 | //*/ |
|
- | 260 | //return 1; |
|
- | 261 | ||
- | 262 | buf|=((unsigned long) scan_code)<<(8*(count++)); |
|
- | 263 | ||
- | 264 | ||
- | 265 | if((buf & 0xff)!= (GXEMUL_KEY_F1 & 0xff)) { |
|
- | 266 | ||
- | 267 | keybuffer_push(keybuffer,buf ); |
|
- | 268 | buf=count=0; |
|
- | 269 | return 1; |
|
- | 270 | } |
|
- | 271 | ||
- | 272 | if ( count <= 1 ) |
|
- | 273 | return 1; |
|
- | 274 | ||
- | 275 | if( (buf & 0xffff) != (GXEMUL_KEY_F1 & 0xffff) ) { |
|
- | 276 | ||
- | 277 | keybuffer_push(keybuffer, buf & 0xff ); |
|
- | 278 | keybuffer_push(keybuffer, (buf >> 8) &0xff ); |
|
- | 279 | buf=count=0; |
|
- | 280 | return 1; |
|
- | 281 | } |
|
- | 282 | ||
- | 283 | if ( count <= 2) |
|
- | 284 | return 1; |
|
- | 285 | ||
- | 286 | ||
- | 287 | if( (buf & 0xffffff) != (GXEMUL_KEY_F1 & 0xffffff) |
|
- | 288 | && (buf & 0xffffff) != (GXEMUL_KEY_F5 & 0xffffff) |
|
- | 289 | && (buf & 0xffffff) != (GXEMUL_KEY_F9 & 0xffffff) ) { |
|
- | 290 | ||
- | 291 | keybuffer_push(keybuffer, buf & 0xff ); |
|
- | 292 | keybuffer_push(keybuffer, (buf >> 8) &0xff ); |
|
- | 293 | keybuffer_push(keybuffer, (buf >> 16) &0xff ); |
|
- | 294 | buf=count=0; |
|
- | 295 | return 1; |
|
- | 296 | } |
|
- | 297 | ||
- | 298 | if ( count <= 3 ) |
|
- | 299 | return 1; |
|
- | 300 | ||
- | 301 | ||
- | 302 | switch (buf){ |
|
- | 303 | ||
- | 304 | case GXEMUL_KEY_F1: |
|
- | 305 | keybuffer_push(keybuffer,FUNCTION_KEYS | 1 ); |
|
- | 306 | buf=count=0; |
|
- | 307 | return 1; |
|
- | 308 | case GXEMUL_KEY_F2: |
|
- | 309 | keybuffer_push(keybuffer,FUNCTION_KEYS | 2 ); |
|
- | 310 | buf=count=0; |
|
- | 311 | return 1; |
|
- | 312 | case GXEMUL_KEY_F3: |
|
- | 313 | keybuffer_push(keybuffer,FUNCTION_KEYS | 3 ); |
|
- | 314 | buf=count=0; |
|
- | 315 | return 1; |
|
- | 316 | case GXEMUL_KEY_F4: |
|
- | 317 | keybuffer_push(keybuffer,FUNCTION_KEYS | 4 ); |
|
- | 318 | buf=count=0; |
|
- | 319 | return 1; |
|
- | 320 | case GXEMUL_KEY_F5: |
|
- | 321 | keybuffer_push(keybuffer,FUNCTION_KEYS | 5 ); |
|
- | 322 | buf=count=0; |
|
- | 323 | return 1; |
|
- | 324 | case GXEMUL_KEY_F6: |
|
- | 325 | keybuffer_push(keybuffer,FUNCTION_KEYS | 6 ); |
|
- | 326 | buf=count=0; |
|
- | 327 | return 1; |
|
- | 328 | case GXEMUL_KEY_F7: |
|
- | 329 | keybuffer_push(keybuffer,FUNCTION_KEYS | 7 ); |
|
- | 330 | buf=count=0; |
|
- | 331 | return 1; |
|
- | 332 | case GXEMUL_KEY_F8: |
|
- | 333 | keybuffer_push(keybuffer,FUNCTION_KEYS | 8 ); |
|
- | 334 | buf=count=0; |
|
- | 335 | return 1; |
|
- | 336 | case GXEMUL_KEY_F9: |
|
- | 337 | keybuffer_push(keybuffer,FUNCTION_KEYS | 9 ); |
|
- | 338 | buf=count=0; |
|
- | 339 | return 1; |
|
- | 340 | case GXEMUL_KEY_F10: |
|
- | 341 | keybuffer_push(keybuffer,FUNCTION_KEYS | 10 ); |
|
- | 342 | buf=count=0; |
|
- | 343 | return 1; |
|
- | 344 | case GXEMUL_KEY_F11: |
|
- | 345 | keybuffer_push(keybuffer,FUNCTION_KEYS | 11 ); |
|
- | 346 | buf=count=0; |
|
- | 347 | return 1; |
|
- | 348 | case GXEMUL_KEY_F12: |
|
- | 349 | keybuffer_push(keybuffer,FUNCTION_KEYS | 12 ); |
|
- | 350 | buf=count=0; |
|
- | 351 | return 1; |
|
- | 352 | ||
- | 353 | default: |
|
- | 354 | keybuffer_push(keybuffer, buf & 0xff ); |
|
- | 355 | keybuffer_push(keybuffer, (buf >> 8) &0xff ); |
|
- | 356 | keybuffer_push(keybuffer, (buf >> 16) &0xff ); |
|
- | 357 | keybuffer_push(keybuffer, (buf >> 24) &0xff ); |
|
- | 358 | buf=count=0; |
|
- | 359 | return 1; |
|
- | 360 | ||
- | 361 | } |
|
- | 362 | return 1; |
|
- | 363 | } |
|
- | 364 | ||
- | 365 | int kbd_arch_process(keybuffer_t *keybuffer, int scan_code) |
|
- | 366 | { |
|
- | 367 | if(msim) return kbd_arch_process_msim(keybuffer, scan_code); |
|
- | 368 | if(gxemul) return kbd_arch_process_gxemul(keybuffer, scan_code); |
|
- | 369 | ||
- | 370 | return 0; |
|
- | 371 | } |
|
- | 372 |