Subversion Repositories HelenOS

Rev

Rev 3923 | Rev 3933 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3923 svoboda 1
/*
2
 * Copyright (c) 2009 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
 
3924 svoboda 29
/** @addtogroup kbd_ctl
30
 * @ingroup kbd
31
 * @{
32
 */
33
/**
34
 * @file
3923 svoboda 35
 * @brief   PC keyboard controller driver.
3924 svoboda 36
 */
3923 svoboda 37
 
38
#include <kbd.h>
39
#include <kbd/kbd.h>
40
#include <kbd/keycode.h>
41
#include <kbd_ctl.h>
42
 
3924 svoboda 43
static int scanmap_simple[];
3923 svoboda 44
 
45
void kbd_ctl_parse_scancode(int scancode)
46
{
47
    kbd_ev_type_t type;
48
    unsigned int key;
49
 
3924 svoboda 50
    if (scancode < 0 || scancode >= 0x100)
51
        return;
3923 svoboda 52
 
53
    if (scancode & 0x80) {
54
        scancode &= ~0x80;
55
        type = KE_RELEASE;
56
    } else {
57
        type = KE_PRESS;
58
    }
59
 
60
    key = scanmap_simple[scancode];
61
    if (key != 0)
62
        kbd_push_ev(type, key, 0);
63
}
64
 
3924 svoboda 65
static int scanmap_simple[128] = {
3923 svoboda 66
 
67
    [0x29] = KC_BACKTICK,
68
 
69
    [0x02] = KC_1,
70
    [0x03] = KC_2,
71
    [0x04] = KC_3,
72
    [0x05] = KC_4,
73
    [0x06] = KC_5,
74
    [0x07] = KC_6,
75
    [0x08] = KC_7,
76
    [0x09] = KC_8,
77
    [0x0a] = KC_9,
78
    [0x0b] = KC_0,
79
 
80
    [0x0c] = KC_MINUS,
81
    [0x0d] = KC_EQUALS,
82
    [0x0e] = KC_BACKSPACE,
83
 
84
    [0x0f] = KC_TAB,
85
 
86
    [0x10] = KC_Q,
87
    [0x11] = KC_W,
88
    [0x12] = KC_E,
89
    [0x13] = KC_R,
90
    [0x14] = KC_T,
91
    [0x15] = KC_Y,
92
    [0x16] = KC_U,
93
    [0x17] = KC_I,
94
    [0x18] = KC_O,
95
    [0x19] = KC_P,
96
 
97
    [0x1a] = KC_LBRACKET,
98
    [0x1b] = KC_RBRACKET,
99
 
100
    [0x3a] = KC_CAPS_LOCK,
101
 
102
    [0x1e] = KC_A,
103
    [0x1f] = KC_S,
104
    [0x20] = KC_D,
105
    [0x21] = KC_F,
106
    [0x22] = KC_G,
107
    [0x23] = KC_H,
108
    [0x24] = KC_J,
109
    [0x25] = KC_K,
110
    [0x26] = KC_L,
111
 
112
    [0x27] = KC_SEMICOLON,
113
    [0x28] = KC_QUOTE,
114
    [0x2b] = KC_BACKSLASH,
115
 
116
    [0x2a] = KC_LSHIFT,
117
 
118
    [0x2c] = KC_Z,
119
    [0x2d] = KC_X,
120
    [0x2e] = KC_C,
121
    [0x2f] = KC_V,
122
    [0x30] = KC_B,
123
    [0x31] = KC_N,
124
    [0x32] = KC_M,
125
 
126
    [0x33] = KC_COMMA,
127
    [0x34] = KC_PERIOD,
128
    [0x35] = KC_SLASH,
129
 
130
    [0x36] = KC_RSHIFT,
131
 
132
    [0x1d] = KC_LCTRL,
133
    [0x38] = KC_LALT,
134
    [0x39] = KC_SPACE,
135
 
136
    [0x01] = KC_ESCAPE,
137
 
138
    [0x3b] = KC_F1,
139
    [0x3c] = KC_F2,
140
    [0x3d] = KC_F3,
141
    [0x3e] = KC_F4,
142
    [0x3f] = KC_F5,
143
    [0x40] = KC_F6,
144
    [0x41] = KC_F7,
145
 
146
    [0x42] = KC_F8,
147
    [0x43] = KC_F9,
148
    [0x44] = KC_F10,
149
 
150
    [0x57] = KC_F11,
151
    [0x58] = KC_F12,
152
 
153
    [0x1c] = KC_ENTER
154
 
155
/*
156
    [0x1] = KC_PRNSCR,
157
    [0x1] = KC_SCROLL_LOCK,
158
    [0x1] = KC_PAUSE,
159
*/
160
};
161
 
162
/**
163
 * @}
164
 */