2
* Copyright (c) 2009 Jiri Svoboda
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
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.
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.
30
* @brief US QWERTY layout.
35
#include <io/console.h>
36
#include <io/keycode.h>
39
static void layout_reset(void);
40
static wchar_t layout_parse_ev(console_event_t *ev);
42
layout_op_t us_qwerty_op = {
47
static wchar_t map_lcase[] = {
78
static wchar_t map_ucase[] = {
109
static wchar_t map_not_shifted[] = {
129
[KC_SEMICOLON] = ';',
131
[KC_BACKSLASH] = '\\',
138
static wchar_t map_shifted[] = {
158
[KC_SEMICOLON] = ':',
160
[KC_BACKSLASH] = '|',
167
static wchar_t map_neutral[] = {
168
[KC_BACKSPACE] = '\b',
180
static wchar_t map_numeric[] = {
195
static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)
197
if (key >= map_length)
202
static void layout_reset(void)
206
static wchar_t layout_parse_ev(console_event_t *ev)
210
/* Produce no characters when Ctrl or Alt is pressed. */
211
if ((ev->mods & (KM_CTRL | KM_ALT)) != 0)
214
c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(wchar_t));
218
if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0))
219
c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(wchar_t));
221
c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(wchar_t));
226
if ((ev->mods & KM_SHIFT) != 0)
227
c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(wchar_t));
229
c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(wchar_t));
234
if ((ev->mods & KM_NUM_LOCK) != 0)
235
c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(wchar_t));