annotate cos/kernel/keyboard.c @ 31:88590c42320f

Changed interrupt handler
author windel
date Tue, 10 Jan 2012 20:40:35 +0100
parents d8627924d40d
children 3a6a9b929db0
rev   line source
24
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
1 #include "kernel.h"
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
2
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
3 static int shiftstate = 0;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
4 static volatile uint8_t charAvail = 0;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
5 static volatile char kbdchar = ' ';
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
6
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
7 static char keymap[128] = {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
8 '?','?','1','2', '3', '4', '5','6', '7', '8','9', '0', '-','=', 0xe, '?',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
9 'q','w','e','r', 't', 'y', 'u','i', 'o', 'p','[', ']', '\n','?', 'a', 's',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
10 'd','f','g','h', 'j', 'k', 'l',';', '\'', '?','?', '?', 'z','x', 'c', 'v',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
11 'b','n','m',',', '.', '/', '?','?', '?', ' ','?', '?', '?','?', '?', '?',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
12
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
13 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
14 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
15 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
16 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?'
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
17 };
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
18
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
19 static char keymapUPPER[128] = {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
20 '?','?','!','@', '#', '$', '%','^', '&', '*','(', ')', '_','+', '?', '?',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
21 'Q','W','E','R', 'T', 'Y', 'U','I', 'O', 'P','{', '}', '|','?', 'A', 'S',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
22 'D','F','G','H', 'J', 'K', 'L',':', '"', '?','?', '?', 'Z','X', 'C', 'V',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
23 'B','N','M','<', '>', '?', '?','?', '?', ' ','?', '?', '?','?', '?', '?',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
24
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
25 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
26 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
27 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?',
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
28 '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?'
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
29 };
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
30
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
31 void keyboardDriverUpdate(unsigned char scancode)
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
32 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
33 switch(scancode) {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
34 case 0x2a:
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
35 shiftstate = 1;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
36 break;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
37 case 0xaa:
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
38 shiftstate = 0;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
39 break;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
40 default:
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
41 if (scancode < 128) {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
42 if (charAvail == 0) {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
43 if (shiftstate == 0) {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
44 kbdchar = keymap[scancode];
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
45 } else {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
46 kbdchar = keymapUPPER[scancode];
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
47 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
48
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
49 charAvail = 1;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
50 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
51 } else {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
52 // Key release
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
53 //printf("Unhandled scancode: 0x%x\n", scancode);
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
54 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
55 break;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
56 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
57 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
58
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
59 char getChar()
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
60 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
61 while (charAvail == 0);
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
62 char c = kbdchar;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
63 charAvail = 0;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
64 return c;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
65 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
66
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
67 void getline(char *buffer, int len)
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
68 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
69 char c;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
70 int i = 0;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
71 while (i < len-1) {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
72 c = getChar();
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
73 //printf("%x", c);
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
74 if (c == '\n') {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
75 // Enter
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
76 break;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
77 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
78 if (c == 0x0e)
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
79 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
80 // Backspace
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
81 if (i>0)
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
82 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
83 int r, c;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
84 get_cursor(&r, &c);
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
85 set_cursor(r, c - 1);
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
86 printf(" ");
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
87 set_cursor(r, c - 1);
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
88 i--;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
89 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
90 continue;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
91 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
92 buffer[i] = c;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
93 printf("%c", c);
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
94 i++;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
95 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
96 buffer[i] = 0;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
97 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
98