Subversion Repositories HelenOS

Rev

Rev 3923 | Rev 3933 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3923 Rev 3924
1
/*
1
/*
2
 * Copyright (c) 2009 Jiri Svoboda
2
 * Copyright (c) 2009 Jiri Svoboda
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
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
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.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
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
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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
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.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup kbd
29
/** @addtogroup kbd_ctl
30
 * @brief   PC keyboard controller driver.
30
 * @ingroup kbd
31
 * @{
31
 * @{
32
 */
32
 */
-
 
33
/**
-
 
34
 * @file
-
 
35
 * @brief   PC keyboard controller driver.
-
 
36
 */
33
 
37
 
34
#include <kbd.h>
38
#include <kbd.h>
35
#include <kbd/kbd.h>
39
#include <kbd/kbd.h>
36
#include <kbd/keycode.h>
40
#include <kbd/keycode.h>
37
#include <kbd_ctl.h>
41
#include <kbd_ctl.h>
38
 
42
 
39
int scanmap_simple[];
43
static int scanmap_simple[];
40
 
44
 
41
void kbd_ctl_parse_scancode(int scancode)
45
void kbd_ctl_parse_scancode(int scancode)
42
{
46
{
43
    kbd_ev_type_t type;
47
    kbd_ev_type_t type;
44
    unsigned int key;
48
    unsigned int key;
45
 
49
 
46
    if (scancode < 0 || scancode >= 0x100) return;
50
    if (scancode < 0 || scancode >= 0x100)
-
 
51
        return;
47
 
52
 
48
    if (scancode & 0x80) {
53
    if (scancode & 0x80) {
49
        scancode &= ~0x80;
54
        scancode &= ~0x80;
50
        type = KE_RELEASE;
55
        type = KE_RELEASE;
51
    } else {
56
    } else {
52
        type = KE_PRESS;
57
        type = KE_PRESS;
53
    }
58
    }
54
 
59
 
55
    key = scanmap_simple[scancode];
60
    key = scanmap_simple[scancode];
56
    if (key != 0)
61
    if (key != 0)
57
        kbd_push_ev(type, key, 0);
62
        kbd_push_ev(type, key, 0);
58
}
63
}
59
 
64
 
60
int scanmap_simple[128] = {
65
static int scanmap_simple[128] = {
61
 
66
 
62
    [0x29] = KC_BACKTICK,
67
    [0x29] = KC_BACKTICK,
63
 
68
 
64
    [0x02] = KC_1,
69
    [0x02] = KC_1,
65
    [0x03] = KC_2,
70
    [0x03] = KC_2,
66
    [0x04] = KC_3,
71
    [0x04] = KC_3,
67
    [0x05] = KC_4,
72
    [0x05] = KC_4,
68
    [0x06] = KC_5,
73
    [0x06] = KC_5,
69
    [0x07] = KC_6,
74
    [0x07] = KC_6,
70
    [0x08] = KC_7,
75
    [0x08] = KC_7,
71
    [0x09] = KC_8,
76
    [0x09] = KC_8,
72
    [0x0a] = KC_9,
77
    [0x0a] = KC_9,
73
    [0x0b] = KC_0,
78
    [0x0b] = KC_0,
74
 
79
 
75
    [0x0c] = KC_MINUS,
80
    [0x0c] = KC_MINUS,
76
    [0x0d] = KC_EQUALS,
81
    [0x0d] = KC_EQUALS,
77
    [0x0e] = KC_BACKSPACE,
82
    [0x0e] = KC_BACKSPACE,
78
 
83
 
79
    [0x0f] = KC_TAB,
84
    [0x0f] = KC_TAB,
80
 
85
 
81
    [0x10] = KC_Q,
86
    [0x10] = KC_Q,
82
    [0x11] = KC_W,
87
    [0x11] = KC_W,
83
    [0x12] = KC_E,
88
    [0x12] = KC_E,
84
    [0x13] = KC_R,
89
    [0x13] = KC_R,
85
    [0x14] = KC_T,
90
    [0x14] = KC_T,
86
    [0x15] = KC_Y,
91
    [0x15] = KC_Y,
87
    [0x16] = KC_U,
92
    [0x16] = KC_U,
88
    [0x17] = KC_I,
93
    [0x17] = KC_I,
89
    [0x18] = KC_O,
94
    [0x18] = KC_O,
90
    [0x19] = KC_P,
95
    [0x19] = KC_P,
91
 
96
 
92
    [0x1a] = KC_LBRACKET,
97
    [0x1a] = KC_LBRACKET,
93
    [0x1b] = KC_RBRACKET,
98
    [0x1b] = KC_RBRACKET,
94
 
99
 
95
    [0x3a] = KC_CAPS_LOCK,
100
    [0x3a] = KC_CAPS_LOCK,
96
 
101
 
97
    [0x1e] = KC_A,
102
    [0x1e] = KC_A,
98
    [0x1f] = KC_S,
103
    [0x1f] = KC_S,
99
    [0x20] = KC_D,
104
    [0x20] = KC_D,
100
    [0x21] = KC_F,
105
    [0x21] = KC_F,
101
    [0x22] = KC_G,
106
    [0x22] = KC_G,
102
    [0x23] = KC_H,
107
    [0x23] = KC_H,
103
    [0x24] = KC_J,
108
    [0x24] = KC_J,
104
    [0x25] = KC_K,
109
    [0x25] = KC_K,
105
    [0x26] = KC_L,
110
    [0x26] = KC_L,
106
 
111
 
107
    [0x27] = KC_SEMICOLON,
112
    [0x27] = KC_SEMICOLON,
108
    [0x28] = KC_QUOTE,
113
    [0x28] = KC_QUOTE,
109
    [0x2b] = KC_BACKSLASH,
114
    [0x2b] = KC_BACKSLASH,
110
 
115
 
111
    [0x2a] = KC_LSHIFT,
116
    [0x2a] = KC_LSHIFT,
112
 
117
 
113
    [0x2c] = KC_Z,
118
    [0x2c] = KC_Z,
114
    [0x2d] = KC_X,
119
    [0x2d] = KC_X,
115
    [0x2e] = KC_C,
120
    [0x2e] = KC_C,
116
    [0x2f] = KC_V,
121
    [0x2f] = KC_V,
117
    [0x30] = KC_B,
122
    [0x30] = KC_B,
118
    [0x31] = KC_N,
123
    [0x31] = KC_N,
119
    [0x32] = KC_M,
124
    [0x32] = KC_M,
120
 
125
 
121
    [0x33] = KC_COMMA,
126
    [0x33] = KC_COMMA,
122
    [0x34] = KC_PERIOD,
127
    [0x34] = KC_PERIOD,
123
    [0x35] = KC_SLASH,
128
    [0x35] = KC_SLASH,
124
 
129
 
125
    [0x36] = KC_RSHIFT,
130
    [0x36] = KC_RSHIFT,
126
 
131
 
127
    [0x1d] = KC_LCTRL,
132
    [0x1d] = KC_LCTRL,
128
    [0x38] = KC_LALT,
133
    [0x38] = KC_LALT,
129
    [0x39] = KC_SPACE,
134
    [0x39] = KC_SPACE,
130
 
135
 
131
    [0x01] = KC_ESCAPE,
136
    [0x01] = KC_ESCAPE,
132
 
137
 
133
    [0x3b] = KC_F1,
138
    [0x3b] = KC_F1,
134
    [0x3c] = KC_F2,
139
    [0x3c] = KC_F2,
135
    [0x3d] = KC_F3,
140
    [0x3d] = KC_F3,
136
    [0x3e] = KC_F4,
141
    [0x3e] = KC_F4,
137
    [0x3f] = KC_F5,
142
    [0x3f] = KC_F5,
138
    [0x40] = KC_F6,
143
    [0x40] = KC_F6,
139
    [0x41] = KC_F7,
144
    [0x41] = KC_F7,
140
 
145
 
141
    [0x42] = KC_F8,
146
    [0x42] = KC_F8,
142
    [0x43] = KC_F9,
147
    [0x43] = KC_F9,
143
    [0x44] = KC_F10,
148
    [0x44] = KC_F10,
144
 
149
 
145
    [0x57] = KC_F11,
150
    [0x57] = KC_F11,
146
    [0x58] = KC_F12,
151
    [0x58] = KC_F12,
147
 
152
 
148
    [0x1c] = KC_ENTER
153
    [0x1c] = KC_ENTER
149
 
154
 
150
/*
155
/*
151
    [0x1] = KC_PRNSCR,
156
    [0x1] = KC_PRNSCR,
152
    [0x1] = KC_SCROLL_LOCK,
157
    [0x1] = KC_SCROLL_LOCK,
153
    [0x1] = KC_PAUSE,
158
    [0x1] = KC_PAUSE,
154
*/
159
*/
155
};
160
};
156
 
161
 
157
/**
162
/**
158
 * @}
163
 * @}
159
 */
164
 */
160
 
165