source: mainline/uspace/drv/usbkbd/conv.c@ 1c13dac

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 1c13dac was 1c13dac, checked in by Vojtech Horky <vojtechhorky@…>, 15 years ago

Add Doxygen groups to usbkbd driver

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2 * Copyright (c) 2011 Lubos Slovak
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 drvusbhid
30 * @{
31 */
32/** @file
33 * USB scancode parser.
34 */
35
36#include <io/keycode.h>
37#include <stdint.h>
38#include "conv.h"
39
40static int scanmap_simple[255] = {
41
42// [0x29] = KC_BACKTICK,
43
44// [0x02] = KC_1,
45// [0x03] = KC_2,
46 [0x04] = KC_A,
47 [0x05] = KC_B,
48 [0x06] = KC_C,
49 [0x07] = KC_D,
50 [0x08] = KC_E,
51 [0x09] = KC_F,
52 [0x0a] = KC_G,
53 [0x0b] = KC_H,
54 [0x0c] = KC_I,
55 [0x0d] = KC_J,
56 [0x0e] = KC_K,
57 [0x0f] = KC_L,
58 [0x10] = KC_M,
59 [0x11] = KC_N,
60 [0x12] = KC_O,
61 [0x13] = KC_P,
62 [0x14] = KC_Q,
63 [0x15] = KC_R,
64 [0x16] = KC_S,
65 [0x17] = KC_T,
66 [0x18] = KC_U,
67 [0x19] = KC_V,
68 [0x1a] = KC_W,
69 [0x1b] = KC_X,
70 [0x1c] = KC_Y,
71 [0x1d] = KC_Z,
72
73 [0x1e] = KC_1,
74 [0x1f] = KC_2,
75 [0x20] = KC_3,
76 [0x21] = KC_4,
77 [0x22] = KC_5,
78 [0x23] = KC_6,
79 [0x24] = KC_7,
80 [0x25] = KC_8,
81 [0x26] = KC_9,
82 [0x27] = KC_0,
83
84 [0x28] = KC_ENTER,
85 [0x29] = KC_ESCAPE,
86 [0x2a] = KC_BACKSPACE,
87 [0x2b] = KC_TAB,
88 [0x2c] = KC_SPACE,
89
90 [0x2d] = KC_MINUS, // same as DASH? (- or _)
91 [0x2e] = KC_EQUALS,
92 [0x2f] = KC_LBRACKET,
93 [0x30] = KC_RBRACKET,
94 [0x31] = KC_BACKSLASH,
95 //[0x32] = KC_, // TODO: HASH??? maybe some as 0x31 - backslash
96 [0x33] = KC_SEMICOLON,
97 [0x34] = KC_QUOTE, // same as APOSTROPHE? (')
98 [0x35] = KC_BACKTICK, // same as GRAVE ACCENT?? (`)
99 [0x36] = KC_COMMA,
100 [0x37] = KC_PERIOD,
101 [0x38] = KC_SLASH,
102
103 [0x39] = KC_CAPS_LOCK,
104
105 [0x3a] = KC_F1,
106 [0x3b] = KC_F2,
107 [0x3c] = KC_F3,
108 [0x3d] = KC_F4,
109 [0x3e] = KC_F5,
110 [0x3f] = KC_F6,
111 [0x40] = KC_F7,
112 [0x41] = KC_F8,
113 [0x42] = KC_F9,
114 [0x43] = KC_F10,
115 [0x44] = KC_F11,
116 [0x45] = KC_F12,
117
118 [0x46] = KC_PRTSCR,
119 [0x47] = KC_SCROLL_LOCK,
120 [0x48] = KC_PAUSE,
121 [0x49] = KC_INSERT,
122 [0x4a] = KC_HOME,
123 [0x4b] = KC_PAGE_UP,
124 [0x4c] = KC_DELETE,
125 [0x4d] = KC_END,
126 [0x4e] = KC_PAGE_DOWN,
127 [0x4f] = KC_RIGHT,
128 [0x50] = KC_LEFT,
129 [0x51] = KC_DOWN,
130 [0x52] = KC_UP,
131
132 //[0x64] = // some funny key
133
134 [0xe0] = KC_LCTRL,
135 [0xe1] = KC_LSHIFT,
136 [0xe2] = KC_LALT,
137 //[0xe3] = KC_L // TODO: left GUI
138 [0xe4] = KC_RCTRL,
139 [0xe5] = KC_RSHIFT,
140 [0xe6] = KC_RALT,
141 //[0xe7] = KC_R // TODO: right GUI
142
143};
144
145unsigned int usbkbd_parse_scancode(int scancode)
146{
147// console_ev_type_t type;
148 unsigned int key;
149 int *map = scanmap_simple;
150 size_t map_length = sizeof(scanmap_simple) / sizeof(int);
151
152 /*
153 * ACK/NAK are returned as response to us sending a command.
154 * We are not interested in them.
155 */
156// if (scancode == SC_ACK || scancode == SC_NAK)
157// return;
158
159// if (scancode == 0xe0) {
160// ds = ds_e;
161// return;
162// }
163
164// switch (ds) {
165// case ds_s:
166// map = scanmap_simple;
167// map_length = sizeof(scanmap_simple) / sizeof(int);
168// break;
169// case ds_e:
170// map = scanmap_e0;
171// map_length = sizeof(scanmap_e0) / sizeof(int);
172// break;
173// default:
174// map = NULL;
175// map_length = 0;
176// }
177
178// ds = ds_s;
179
180// if (scancode & 0x80) {
181// scancode &= ~0x80;
182// type = KEY_RELEASE;
183// } else {
184// type = KEY_PRESS;
185// }
186
187 if ((scancode < 0) || ((size_t) scancode >= map_length))
188 return -1;
189
190 key = map[scancode];
191// if (key != 0)
192// kbd_push_ev(type, key);
193 return key;
194}
195
196/**
197 * @}
198 */
Note: See TracBrowser for help on using the repository browser.