source: mainline/uspace/srv/hid/input/ctl/apple.c@ 8442d10

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

use local includes within the input server

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