source: mainline/uspace/srv/kbd/arch/ppc32/src/kbd.c@ fcd7053

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since fcd7053 was fcd7053, checked in by Martin Decky <martin@…>, 17 years ago

cleanup configuration
code cleanup

  • Property mode set to 100644
File size: 4.5 KB
RevLine 
[d7eafd8]1/*
[df4ed85]2 * Copyright (c) 2006 Martin Decky
[d7eafd8]3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
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
15 * derived from this software without specific prior written permission.
16 *
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
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
[ce5bcb4]29/** @addtogroup kbdppc32 ppc32
30 * @brief HelenOS ppc32 arch dependent parts of uspace keyboard handler.
31 * @ingroup kbd
32 * @{
33 */
34/** @file
35 */
36
[d7eafd8]37#include <arch/kbd.h>
38#include <ipc/ipc.h>
[9a71438]39#include <sysinfo.h>
[15039b67]40#include <kbd.h>
41#include <keys.h>
[9a71438]42
[d7eafd8]43
[9e951acb]44#define SPECIAL 255
45#define FUNCTION_KEYS 0x100
46
47
48static int lchars[0x80] = {
49 'a',
50 's',
51 'd',
52 'f',
53 'h',
54 'g',
55 'z',
56 'x',
57 'c',
58 'v',
59 SPECIAL,
60 'b',
61 'q',
62 'w',
63 'e',
64 'r',
65 'y',
66 't',
67 '1',
68 '2',
69 '3',
70 '4',
71 '6',
72 '5',
73 '=',
74 '9',
75 '7',
76 '-',
77 '8',
78 '0',
79 ']',
80 'o',
81 'u',
82 '[',
83 'i',
84 'p',
85 '\n', /* Enter */
86 'l',
87 'j',
88 '\'',
89 'k',
90 ';',
91 '\\',
92 ',',
93 '/',
94 'n',
95 'm',
96 '.',
97 '\t', /* Tab */
98 ' ',
99 '`',
100 '\b', /* Backspace */
101 SPECIAL,
102 SPECIAL, /* Escape */
103 SPECIAL, /* Ctrl */
104 SPECIAL, /* Alt */
105 SPECIAL, /* Shift */
106 SPECIAL, /* Caps-Lock */
107 SPECIAL, /* RAlt */
108 SPECIAL, /* Left */
109 SPECIAL, /* Right */
110 SPECIAL, /* Down */
111 SPECIAL, /* Up */
112 SPECIAL,
113 SPECIAL,
114 '.', /* Keypad . */
115 SPECIAL,
116 '*', /* Keypad * */
117 SPECIAL,
118 '+', /* Keypad + */
119 SPECIAL,
120 SPECIAL, /* NumLock */
121 SPECIAL,
122 SPECIAL,
123 SPECIAL,
124 '/', /* Keypad / */
125 '\n', /* Keypad Enter */
126 SPECIAL,
127 '-', /* Keypad - */
128 SPECIAL,
129 SPECIAL,
130 SPECIAL,
131 '0', /* Keypad 0 */
132 '1', /* Keypad 1 */
133 '2', /* Keypad 2 */
134 '3', /* Keypad 3 */
135 '4', /* Keypad 4 */
136 '5', /* Keypad 5 */
137 '6', /* Keypad 6 */
138 '7', /* Keypad 7 */
139 SPECIAL,
140 '8', /* Keypad 8 */
141 '9', /* Keypad 9 */
142 SPECIAL,
143 SPECIAL,
144 SPECIAL,
145 (FUNCTION_KEYS | 5), /* F5 */
146 (FUNCTION_KEYS | 6), /* F6 */
147 (FUNCTION_KEYS | 7), /* F7 */
148 (FUNCTION_KEYS | 3), /* F3 */
149 (FUNCTION_KEYS | 8), /* F8 */
150 (FUNCTION_KEYS | 9), /* F9 */
151 SPECIAL,
152 (FUNCTION_KEYS | 11), /* F11 */
153 SPECIAL,
154 (FUNCTION_KEYS | 13), /* F13 */
155 SPECIAL,
156 SPECIAL, /* ScrollLock */
157 SPECIAL,
158 (FUNCTION_KEYS | 10), /* F10 */
159 SPECIAL,
160 (FUNCTION_KEYS | 12), /* F12 */
161 SPECIAL,
162 SPECIAL, /* Pause */
163 SPECIAL, /* Insert */
164 SPECIAL, /* Home */
165 SPECIAL, /* PageUp */
166 SPECIAL, /* Delete */
167 (FUNCTION_KEYS | 4), /* F4 */
168 SPECIAL, /* End */
169 (FUNCTION_KEYS | 2), /* F2 */
170 SPECIAL, /* PageDown */
171 (FUNCTION_KEYS | 1) /* F1 */
[0f09bd45]172};
173
174
[d7eafd8]175int kbd_arch_init(void)
176{
[917c427]177 if (!sysinfo_value("kbd"))
[f817d3a]178 return 0;
179
[fcd7053]180 return ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, 0);
[d7eafd8]181}
182
[9a71438]183
[15039b67]184int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
[d7eafd8]185{
[15039b67]186 int param = IPC_GET_ARG2(*call);
187
188 if (param != -1) {
189 uint8_t scancode = (uint8_t) param;
[0f09bd45]190
[9e951acb]191 if ((scancode & 0x80) != 0x80) {
192 int key = lchars[scancode & 0x7f];
193
194 if (key != SPECIAL)
195 keybuffer_push(keybuffer, key);
196 }
197 }
[0f09bd45]198
[d7eafd8]199 return 1;
200}
[ce5bcb4]201
202/** @}
203 */
Note: See TracBrowser for help on using the repository browser.