Rev 1634 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1634 | Rev 1649 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2006 Martin Decky |
2 | * Copyright (C) 2006 Martin Decky |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
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 | /** @addtogroup kbdppc32 ppc32 |
|
- | 30 | * @brief HelenOS ppc32 arch dependent parts of uspace keyboard handler. |
|
- | 31 | * @ingroup kbd |
|
- | 32 | * @{ |
|
- | 33 | */ |
|
- | 34 | /** @file |
|
- | 35 | */ |
|
- | 36 | ||
29 | #include <arch/kbd.h> |
37 | #include <arch/kbd.h> |
30 | #include <ipc/ipc.h> |
38 | #include <ipc/ipc.h> |
31 | #include <sysinfo.h> |
39 | #include <sysinfo.h> |
32 | 40 | ||
33 | irq_cmd_t cuda_cmds[1] = { |
41 | irq_cmd_t cuda_cmds[1] = { |
34 | { CMD_PPC32_GETCHAR, 0, 0 } |
42 | { CMD_PPC32_GETCHAR, 0, 0 } |
35 | }; |
43 | }; |
36 | 44 | ||
37 | irq_code_t cuda_kbd = { |
45 | irq_code_t cuda_kbd = { |
38 | 1, |
46 | 1, |
39 | cuda_cmds |
47 | cuda_cmds |
40 | }; |
48 | }; |
41 | 49 | ||
42 | 50 | ||
43 | #define SPECIAL 255 |
51 | #define SPECIAL 255 |
44 | #define FUNCTION_KEYS 0x100 |
52 | #define FUNCTION_KEYS 0x100 |
45 | 53 | ||
46 | 54 | ||
47 | static int lchars[0x80] = { |
55 | static int lchars[0x80] = { |
48 | 'a', |
56 | 'a', |
49 | 's', |
57 | 's', |
50 | 'd', |
58 | 'd', |
51 | 'f', |
59 | 'f', |
52 | 'h', |
60 | 'h', |
53 | 'g', |
61 | 'g', |
54 | 'z', |
62 | 'z', |
55 | 'x', |
63 | 'x', |
56 | 'c', |
64 | 'c', |
57 | 'v', |
65 | 'v', |
58 | SPECIAL, |
66 | SPECIAL, |
59 | 'b', |
67 | 'b', |
60 | 'q', |
68 | 'q', |
61 | 'w', |
69 | 'w', |
62 | 'e', |
70 | 'e', |
63 | 'r', |
71 | 'r', |
64 | 'y', |
72 | 'y', |
65 | 't', |
73 | 't', |
66 | '1', |
74 | '1', |
67 | '2', |
75 | '2', |
68 | '3', |
76 | '3', |
69 | '4', |
77 | '4', |
70 | '6', |
78 | '6', |
71 | '5', |
79 | '5', |
72 | '=', |
80 | '=', |
73 | '9', |
81 | '9', |
74 | '7', |
82 | '7', |
75 | '-', |
83 | '-', |
76 | '8', |
84 | '8', |
77 | '0', |
85 | '0', |
78 | ']', |
86 | ']', |
79 | 'o', |
87 | 'o', |
80 | 'u', |
88 | 'u', |
81 | '[', |
89 | '[', |
82 | 'i', |
90 | 'i', |
83 | 'p', |
91 | 'p', |
84 | '\n', /* Enter */ |
92 | '\n', /* Enter */ |
85 | 'l', |
93 | 'l', |
86 | 'j', |
94 | 'j', |
87 | '\'', |
95 | '\'', |
88 | 'k', |
96 | 'k', |
89 | ';', |
97 | ';', |
90 | '\\', |
98 | '\\', |
91 | ',', |
99 | ',', |
92 | '/', |
100 | '/', |
93 | 'n', |
101 | 'n', |
94 | 'm', |
102 | 'm', |
95 | '.', |
103 | '.', |
96 | '\t', /* Tab */ |
104 | '\t', /* Tab */ |
97 | ' ', |
105 | ' ', |
98 | '`', |
106 | '`', |
99 | '\b', /* Backspace */ |
107 | '\b', /* Backspace */ |
100 | SPECIAL, |
108 | SPECIAL, |
101 | SPECIAL, /* Escape */ |
109 | SPECIAL, /* Escape */ |
102 | SPECIAL, /* Ctrl */ |
110 | SPECIAL, /* Ctrl */ |
103 | SPECIAL, /* Alt */ |
111 | SPECIAL, /* Alt */ |
104 | SPECIAL, /* Shift */ |
112 | SPECIAL, /* Shift */ |
105 | SPECIAL, /* Caps-Lock */ |
113 | SPECIAL, /* Caps-Lock */ |
106 | SPECIAL, /* RAlt */ |
114 | SPECIAL, /* RAlt */ |
107 | SPECIAL, /* Left */ |
115 | SPECIAL, /* Left */ |
108 | SPECIAL, /* Right */ |
116 | SPECIAL, /* Right */ |
109 | SPECIAL, /* Down */ |
117 | SPECIAL, /* Down */ |
110 | SPECIAL, /* Up */ |
118 | SPECIAL, /* Up */ |
111 | SPECIAL, |
119 | SPECIAL, |
112 | SPECIAL, |
120 | SPECIAL, |
113 | '.', /* Keypad . */ |
121 | '.', /* Keypad . */ |
114 | SPECIAL, |
122 | SPECIAL, |
115 | '*', /* Keypad * */ |
123 | '*', /* Keypad * */ |
116 | SPECIAL, |
124 | SPECIAL, |
117 | '+', /* Keypad + */ |
125 | '+', /* Keypad + */ |
118 | SPECIAL, |
126 | SPECIAL, |
119 | SPECIAL, /* NumLock */ |
127 | SPECIAL, /* NumLock */ |
120 | SPECIAL, |
128 | SPECIAL, |
121 | SPECIAL, |
129 | SPECIAL, |
122 | SPECIAL, |
130 | SPECIAL, |
123 | '/', /* Keypad / */ |
131 | '/', /* Keypad / */ |
124 | '\n', /* Keypad Enter */ |
132 | '\n', /* Keypad Enter */ |
125 | SPECIAL, |
133 | SPECIAL, |
126 | '-', /* Keypad - */ |
134 | '-', /* Keypad - */ |
127 | SPECIAL, |
135 | SPECIAL, |
128 | SPECIAL, |
136 | SPECIAL, |
129 | SPECIAL, |
137 | SPECIAL, |
130 | '0', /* Keypad 0 */ |
138 | '0', /* Keypad 0 */ |
131 | '1', /* Keypad 1 */ |
139 | '1', /* Keypad 1 */ |
132 | '2', /* Keypad 2 */ |
140 | '2', /* Keypad 2 */ |
133 | '3', /* Keypad 3 */ |
141 | '3', /* Keypad 3 */ |
134 | '4', /* Keypad 4 */ |
142 | '4', /* Keypad 4 */ |
135 | '5', /* Keypad 5 */ |
143 | '5', /* Keypad 5 */ |
136 | '6', /* Keypad 6 */ |
144 | '6', /* Keypad 6 */ |
137 | '7', /* Keypad 7 */ |
145 | '7', /* Keypad 7 */ |
138 | SPECIAL, |
146 | SPECIAL, |
139 | '8', /* Keypad 8 */ |
147 | '8', /* Keypad 8 */ |
140 | '9', /* Keypad 9 */ |
148 | '9', /* Keypad 9 */ |
141 | SPECIAL, |
149 | SPECIAL, |
142 | SPECIAL, |
150 | SPECIAL, |
143 | SPECIAL, |
151 | SPECIAL, |
144 | (FUNCTION_KEYS | 5), /* F5 */ |
152 | (FUNCTION_KEYS | 5), /* F5 */ |
145 | (FUNCTION_KEYS | 6), /* F6 */ |
153 | (FUNCTION_KEYS | 6), /* F6 */ |
146 | (FUNCTION_KEYS | 7), /* F7 */ |
154 | (FUNCTION_KEYS | 7), /* F7 */ |
147 | (FUNCTION_KEYS | 3), /* F3 */ |
155 | (FUNCTION_KEYS | 3), /* F3 */ |
148 | (FUNCTION_KEYS | 8), /* F8 */ |
156 | (FUNCTION_KEYS | 8), /* F8 */ |
149 | (FUNCTION_KEYS | 9), /* F9 */ |
157 | (FUNCTION_KEYS | 9), /* F9 */ |
150 | SPECIAL, |
158 | SPECIAL, |
151 | (FUNCTION_KEYS | 11), /* F11 */ |
159 | (FUNCTION_KEYS | 11), /* F11 */ |
152 | SPECIAL, |
160 | SPECIAL, |
153 | (FUNCTION_KEYS | 13), /* F13 */ |
161 | (FUNCTION_KEYS | 13), /* F13 */ |
154 | SPECIAL, |
162 | SPECIAL, |
155 | SPECIAL, /* ScrollLock */ |
163 | SPECIAL, /* ScrollLock */ |
156 | SPECIAL, |
164 | SPECIAL, |
157 | (FUNCTION_KEYS | 10), /* F10 */ |
165 | (FUNCTION_KEYS | 10), /* F10 */ |
158 | SPECIAL, |
166 | SPECIAL, |
159 | (FUNCTION_KEYS | 12), /* F12 */ |
167 | (FUNCTION_KEYS | 12), /* F12 */ |
160 | SPECIAL, |
168 | SPECIAL, |
161 | SPECIAL, /* Pause */ |
169 | SPECIAL, /* Pause */ |
162 | SPECIAL, /* Insert */ |
170 | SPECIAL, /* Insert */ |
163 | SPECIAL, /* Home */ |
171 | SPECIAL, /* Home */ |
164 | SPECIAL, /* PageUp */ |
172 | SPECIAL, /* PageUp */ |
165 | SPECIAL, /* Delete */ |
173 | SPECIAL, /* Delete */ |
166 | (FUNCTION_KEYS | 4), /* F4 */ |
174 | (FUNCTION_KEYS | 4), /* F4 */ |
167 | SPECIAL, /* End */ |
175 | SPECIAL, /* End */ |
168 | (FUNCTION_KEYS | 2), /* F2 */ |
176 | (FUNCTION_KEYS | 2), /* F2 */ |
169 | SPECIAL, /* PageDown */ |
177 | SPECIAL, /* PageDown */ |
170 | (FUNCTION_KEYS | 1) /* F1 */ |
178 | (FUNCTION_KEYS | 1) /* F1 */ |
171 | }; |
179 | }; |
172 | 180 | ||
173 | 181 | ||
174 | int kbd_arch_init(void) |
182 | int kbd_arch_init(void) |
175 | { |
183 | { |
176 | return (!ipc_register_irq(sysinfo_value("cuda.irq"), &cuda_kbd)); |
184 | return (!ipc_register_irq(sysinfo_value("cuda.irq"), &cuda_kbd)); |
177 | } |
185 | } |
178 | 186 | ||
179 | 187 | ||
180 | int kbd_arch_process(keybuffer_t *keybuffer, int scan_code) |
188 | int kbd_arch_process(keybuffer_t *keybuffer, int scan_code) |
181 | { |
189 | { |
182 | if (scan_code != -1) { |
190 | if (scan_code != -1) { |
183 | uint8_t scancode = (uint8_t) scan_code; |
191 | uint8_t scancode = (uint8_t) scan_code; |
184 | 192 | ||
185 | if ((scancode & 0x80) != 0x80) { |
193 | if ((scancode & 0x80) != 0x80) { |
186 | int key = lchars[scancode & 0x7f]; |
194 | int key = lchars[scancode & 0x7f]; |
187 | 195 | ||
188 | if (key != SPECIAL) |
196 | if (key != SPECIAL) |
189 | keybuffer_push(keybuffer, key); |
197 | keybuffer_push(keybuffer, key); |
190 | } |
198 | } |
191 | } |
199 | } |
192 | 200 | ||
193 | return 1; |
201 | return 1; |
194 | } |
202 | } |
- | 203 | ||
- | 204 | /** @} |
|
- | 205 | */ |
|
- | 206 | ||
195 | 207 |