source: mainline/uspace/srv/hid/kbd/ctl/apple.c@ b1bdc7a4

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

Control keyboard port modules through ops structures. Allows compiling in
all modules at the same time.

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*
2 * Copyright (c) 2010 Jiri Svoboda
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
29/** @addtogroup kbd_ctl
30 * @ingroup kbd
31 * @{
32 */
33/**
34 * @file
35 * @brief Apple ADB keyboard controller driver.
36 */
37
38#include <kbd.h>
39#include <io/console.h>
40#include <io/keycode.h>
41#include <kbd_ctl.h>
42#include <kbd_port.h>
43
44#define KBD_KEY_RELEASE 0x80
45
46static int scanmap[];
47
48int kbd_ctl_init(kbd_port_ops_t *kbd_port)
49{
50 (void) kbd_port;
51 return 0;
52}
53
54void kbd_ctl_parse_scancode(int scancode)
55{
56 kbd_event_type_t type;
57 unsigned int key;
58
59 if (scancode < 0 || scancode >= 0x100)
60 return;
61
62 if (scancode & KBD_KEY_RELEASE) {
63 scancode &= ~KBD_KEY_RELEASE;
64 type = KEY_RELEASE;
65 } else {
66 type = KEY_PRESS;
67 }
68
69 key = scanmap[scancode];
70 if (key != 0)
71 kbd_push_ev(type, key);
72}
73
74void kbd_ctl_set_ind(unsigned mods)
75{
76 (void) mods;
77}
78
79static int scanmap[] = {
80 [0x00] = KC_A,
81 [0x01] = KC_S,
82 [0x02] = KC_D,
83 [0x03] = KC_F,
84 [0x04] = KC_H,
85 [0x05] = KC_G,
86 [0x06] = KC_Z,
87 [0x07] = KC_X,
88 [0x08] = KC_C,
89 [0x09] = KC_V,
90 [0x0a] = KC_BACKSLASH,
91 [0x0b] = KC_B,
92 [0x0c] = KC_Q,
93 [0x0d] = KC_W,
94 [0x0e] = KC_E,
95 [0x0f] = KC_R,
96 [0x10] = KC_Y,
97 [0x11] = KC_T,
98 [0x12] = KC_1,
99 [0x13] = KC_2,
100 [0x14] = KC_3,
101 [0x15] = KC_4,
102 [0x16] = KC_6,
103 [0x17] = KC_5,
104 [0x18] = KC_EQUALS,
105 [0x19] = KC_9,
106 [0x1a] = KC_7,
107 [0x1b] = KC_MINUS,
108 [0x1c] = KC_8,
109 [0x1d] = KC_0,
110 [0x1e] = KC_RBRACKET,
111 [0x1f] = KC_O,
112 [0x20] = KC_U,
113 [0x21] = KC_LBRACKET,
114 [0x22] = KC_I,
115 [0x23] = KC_P,
116 [0x24] = KC_ENTER,
117 [0x25] = KC_L,
118 [0x26] = KC_J,
119 [0x27] = KC_QUOTE,
120 [0x28] = KC_K,
121 [0x29] = KC_SEMICOLON,
122 [0x2a] = KC_BACKSLASH,
123 [0x2b] = KC_COMMA,
124 [0x2c] = KC_SLASH,
125 [0x2d] = KC_N,
126 [0x2e] = KC_M,
127 [0x2f] = KC_PERIOD,
128 [0x30] = KC_TAB,
129 [0x31] = KC_SPACE,
130 [0x32] = KC_BACKTICK,
131 [0x33] = KC_BACKSPACE,
132 [0x34] = 0,
133 [0x35] = KC_ESCAPE,
134 [0x36] = KC_LCTRL,
135 [0x37] = 0,
136 [0x38] = KC_LSHIFT,
137 [0x39] = KC_CAPS_LOCK,
138 [0x3a] = KC_LALT,
139 [0x3b] = KC_LEFT,
140 [0x3c] = KC_RIGHT,
141 [0x3d] = KC_DOWN,
142 [0x3e] = KC_UP,
143 [0x3f] = 0,
144 [0x40] = 0,
145 [0x41] = KC_NPERIOD,
146 [0x42] = 0,
147 [0x43] = KC_NTIMES,
148 [0x44] = 0,
149 [0x45] = KC_NPLUS,
150 [0x46] = 0,
151 [0x47] = KC_NUM_LOCK,
152 [0x48] = 0,
153 [0x49] = 0,
154 [0x4a] = 0,
155 [0x4b] = KC_NSLASH,
156 [0x4c] = KC_NENTER,
157 [0x4d] = 0,
158 [0x4e] = KC_NMINUS,
159 [0x4f] = 0,
160 [0x50] = 0,
161 [0x51] = 0,
162 [0x52] = KC_N0,
163 [0x53] = KC_N1,
164 [0x54] = KC_N2,
165 [0x55] = KC_N3,
166 [0x56] = KC_N4,
167 [0x57] = KC_N5,
168 [0x58] = KC_N6,
169 [0x59] = KC_N7,
170 [0x5a] = 0,
171 [0x5b] = KC_N8,
172 [0x5c] = KC_N9,
173 [0x5d] = 0,
174 [0x5e] = 0,
175 [0x5f] = 0,
176 [0x60] = KC_F5,
177 [0x61] = KC_F6,
178 [0x62] = KC_F7,
179 [0x63] = KC_F3,
180 [0x64] = KC_F8,
181 [0x65] = KC_F9,
182 [0x66] = 0,
183 [0x67] = KC_F11,
184 [0x68] = 0,
185 [0x69] = 0,
186 [0x6a] = 0,
187 [0x6b] = KC_SCROLL_LOCK,
188 [0x6c] = 0,
189 [0x6d] = KC_F10,
190 [0x6e] = 0,
191 [0x6f] = KC_F12,
192 [0x70] = 0,
193 [0x71] = 0,
194 [0x72] = KC_INSERT,
195 [0x73] = KC_HOME,
196 [0x74] = KC_PAGE_UP,
197 [0x75] = KC_DELETE,
198 [0x76] = KC_F4,
199 [0x77] = KC_END,
200 [0x78] = KC_F2,
201 [0x79] = KC_PAGE_DOWN,
202 [0x7a] = KC_F1,
203 [0x7b] = KC_RSHIFT,
204 [0x7c] = KC_RALT,
205 [0x7d] = KC_RCTRL,
206 [0x7e] = 0,
207 [0x7f] = 0
208};
209
210/** @}
211 */
Note: See TracBrowser for help on using the repository browser.