source: mainline/uspace/srv/hid/kbd/ctl/sun.c@ 9be360ee

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9be360ee was 9be360ee, checked in by Jiri Svoboda <jiri@…>, 14 years ago

Allow keyboard server to handle more than one driver at the same time.

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/*
2 * Copyright (c) 2006 Jakub Jermar
3 * Copyright (c) 2011 Jiri Svoboda
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup kbd_ctl
31 * @ingroup kbd
32 * @{
33 */
34/**
35 * @file
36 * @brief Sun keyboard controller driver.
37 */
38
39#include <kbd.h>
40#include <io/console.h>
41#include <io/keycode.h>
42#include <kbd_ctl.h>
43#include <kbd_port.h>
44
45static void sun_ctl_parse_scancode(int);
46static int sun_ctl_init(kbd_dev_t *);
47static void sun_ctl_set_ind(unsigned);
48
49kbd_ctl_ops_t sun_ctl = {
50 .parse_scancode = sun_ctl_parse_scancode,
51 .init = sun_ctl_init,
52 .set_ind = sun_ctl_set_ind
53};
54
55static kbd_dev_t *kbd_dev;
56
57#define KBD_KEY_RELEASE 0x80
58#define KBD_ALL_KEYS_UP 0x7f
59
60static int scanmap_simple[];
61
62static int sun_ctl_init(kbd_dev_t *kdev)
63{
64 kbd_dev = kdev;
65 return 0;
66}
67
68static void sun_ctl_parse_scancode(int scancode)
69{
70 kbd_event_type_t type;
71 unsigned int key;
72
73 if (scancode < 0 || scancode >= 0x100)
74 return;
75
76 if (scancode == KBD_ALL_KEYS_UP)
77 return;
78
79 if (scancode & KBD_KEY_RELEASE) {
80 scancode &= ~KBD_KEY_RELEASE;
81 type = KEY_RELEASE;
82 } else {
83 type = KEY_PRESS;
84 }
85
86 key = scanmap_simple[scancode];
87 if (key != 0)
88 kbd_push_ev(kbd_dev, type, key);
89}
90
91static void sun_ctl_set_ind(unsigned mods)
92{
93 (void) mods;
94}
95
96/** Primary meaning of scancodes. */
97static int scanmap_simple[] = {
98 [0x00] = 0,
99 [0x01] = 0,
100 [0x02] = 0,
101 [0x03] = 0,
102 [0x04] = 0,
103 [0x05] = KC_F1,
104 [0x06] = KC_F2,
105 [0x07] = KC_F10,
106 [0x08] = KC_F3,
107 [0x09] = KC_F11,
108 [0x0a] = KC_F4,
109 [0x0b] = KC_F12,
110 [0x0c] = KC_F5,
111 [0x0d] = KC_RALT,
112 [0x0e] = KC_F6,
113 [0x0f] = 0,
114 [0x10] = KC_F7,
115 [0x11] = KC_F8,
116 [0x12] = KC_F9,
117 [0x13] = KC_LALT,
118 [0x14] = KC_UP,
119 [0x15] = KC_PAUSE,
120 [0x16] = 0,
121 [0x17] = KC_SCROLL_LOCK,
122 [0x18] = KC_LEFT,
123 [0x19] = 0,
124 [0x1a] = 0,
125 [0x1b] = KC_DOWN,
126 [0x1c] = KC_RIGHT,
127 [0x1d] = KC_ESCAPE,
128 [0x1e] = KC_1,
129 [0x1f] = KC_2,
130 [0x20] = KC_3,
131 [0x21] = KC_4,
132 [0x22] = KC_5,
133 [0x23] = KC_6,
134 [0x24] = KC_7,
135 [0x25] = KC_8,
136 [0x26] = KC_9,
137 [0x27] = KC_0,
138 [0x28] = KC_MINUS,
139 [0x29] = KC_EQUALS,
140 [0x2a] = KC_BACKTICK,
141 [0x2b] = KC_BACKSPACE,
142 [0x2c] = KC_INSERT,
143 [0x2d] = 0,
144 [0x2e] = KC_NSLASH,
145 [0x2f] = KC_NTIMES,
146 [0x30] = 0,
147 [0x31] = 0,
148 [0x32] = KC_NPERIOD,
149 [0x33] = 0,
150 [0x34] = KC_HOME,
151 [0x35] = KC_TAB,
152 [0x36] = KC_Q,
153 [0x37] = KC_W,
154 [0x38] = KC_E,
155 [0x39] = KC_R,
156 [0x3a] = KC_T,
157 [0x3b] = KC_Y,
158 [0x3c] = KC_U,
159 [0x3d] = KC_I,
160 [0x3e] = KC_O,
161 [0x3f] = KC_P,
162 [0x40] = KC_LBRACKET,
163 [0x41] = KC_RBRACKET,
164 [0x42] = KC_DELETE,
165 [0x43] = 0,
166 [0x44] = KC_N7,
167 [0x45] = KC_N8,
168 [0x46] = KC_N9,
169 [0x47] = KC_NMINUS,
170 [0x48] = 0,
171 [0x49] = 0,
172 [0x4a] = KC_END,
173 [0x4b] = 0,
174 [0x4c] = KC_LCTRL,
175 [0x4d] = KC_A,
176 [0x4e] = KC_S,
177 [0x4f] = KC_D,
178 [0x50] = KC_F,
179 [0x51] = KC_G,
180 [0x52] = KC_H,
181 [0x53] = KC_J,
182 [0x54] = KC_K,
183 [0x55] = KC_L,
184 [0x56] = KC_SEMICOLON,
185 [0x57] = KC_QUOTE,
186 [0x58] = KC_BACKSLASH,
187 [0x59] = KC_ENTER,
188 [0x5a] = KC_NENTER,
189 [0x5b] = KC_N4,
190 [0x5c] = KC_N5,
191 [0x5d] = KC_N6,
192 [0x5e] = KC_N0,
193 [0x5f] = 0,
194 [0x60] = KC_PAGE_UP,
195 [0x61] = 0,
196 [0x62] = KC_NUM_LOCK,
197 [0x63] = KC_LSHIFT,
198 [0x64] = KC_Z,
199 [0x65] = KC_X,
200 [0x66] = KC_C,
201 [0x67] = KC_V,
202 [0x68] = KC_B,
203 [0x69] = KC_N,
204 [0x6a] = KC_M,
205 [0x6b] = KC_COMMA,
206 [0x6c] = KC_PERIOD,
207 [0x6d] = KC_SLASH,
208 [0x6e] = KC_RSHIFT,
209 [0x6f] = 0,
210 [0x70] = KC_N1,
211 [0x71] = KC_N2,
212 [0x72] = KC_N3,
213 [0x73] = 0,
214 [0x74] = 0,
215 [0x75] = 0,
216 [0x76] = 0,
217 [0x77] = KC_CAPS_LOCK,
218 [0x78] = 0,
219 [0x79] = KC_SPACE,
220 [0x7a] = 0,
221 [0x7b] = KC_PAGE_DOWN,
222 [0x7c] = 0,
223 [0x7d] = KC_NPLUS,
224 [0x7e] = 0,
225 [0x7f] = 0
226};
227
228/** @}
229 */
Note: See TracBrowser for help on using the repository browser.