source: mainline/uspace/srv/hid/input/ctl/apple.c@ 7354b5e

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

use the PAUSE / BREAK key to activate the kernel console in compositor (F15 on some strange keyboards)
this avoids issues with stuck modifier keys and other surprises
it is also unlikely that any client applications would like to use these keys

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