Subversion Repositories HelenOS

Rev

Rev 3933 | Rev 4061 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3933 Rev 3944
Line 45... Line 45...
45
static void parse_ds_e1(int scancode);
45
static void parse_ds_e1(int scancode);
46
static void parse_ds_e2(int scancode);
46
static void parse_ds_e2(int scancode);
47
static void parse_ds_e2a(int scancode);
47
static void parse_ds_e2a(int scancode);
48
static void parse_ds_e2b(int scancode);
48
static void parse_ds_e2b(int scancode);
49
 
49
 
50
static void parse_leaf(int scancode, int *map, size_t map_length);
50
static void parse_leaf(int scancode, int (*map)[2], size_t map_length);
51
 
51
 
52
enum dec_state {
52
enum dec_state {
53
    ds_start,
53
    ds_start,
54
    ds_e,
54
    ds_e,
55
    ds_e1,
55
    ds_e1,
56
    ds_e2,
56
    ds_e2,
57
    ds_e2a,
57
    ds_e2a,
58
    ds_e2b
58
    ds_e2b
59
};
59
};
60
 
60
 
61
static int map_start[] = {
61
static int map_start[][2] = {
62
 
62
 
63
    [0x60] = KC_BACKTICK,
63
    [0x60] = { 0, KC_BACKTICK },
64
 
64
 
65
    [0x31] = KC_1,
65
    [0x31] = { 0, KC_1 },
66
    [0x32] = KC_2,
66
    [0x32] = { 0, KC_2 },
67
    [0x33] = KC_3,
67
    [0x33] = { 0, KC_3 },
68
    [0x34] = KC_4,
68
    [0x34] = { 0, KC_4 },
69
    [0x35] = KC_5,
69
    [0x35] = { 0, KC_5 },
70
    [0x36] = KC_6,
70
    [0x36] = { 0, KC_6 },
71
    [0x37] = KC_7,
71
    [0x37] = { 0, KC_7 },
72
    [0x38] = KC_8,
72
    [0x38] = { 0, KC_8 },
73
    [0x39] = KC_9,
73
    [0x39] = { 0, KC_9 },
74
    [0x30] = KC_0,
74
    [0x30] = { 0, KC_0 },
75
 
75
 
76
    [0x2d] = KC_MINUS,
76
    [0x2d] = { 0, KC_MINUS },
77
    [0x3d] = KC_EQUALS,
77
    [0x3d] = { 0, KC_EQUALS },
78
    [0x08] = KC_BACKSPACE,
78
    [0x08] = { 0, KC_BACKSPACE },
79
 
79
 
80
    [0x0f] = KC_TAB,
80
    [0x0f] = { 0, KC_TAB },
81
 
81
 
82
    [0x71] = KC_Q,
82
    [0x71] = { 0, KC_Q },
83
    [0x77] = KC_W,
83
    [0x77] = { 0, KC_W },
84
    [0x65] = KC_E,
84
    [0x65] = { 0, KC_E },
85
    [0x72] = KC_R,
85
    [0x72] = { 0, KC_R },
86
    [0x74] = KC_T,
86
    [0x74] = { 0, KC_T },
87
    [0x79] = KC_Y,
87
    [0x79] = { 0, KC_Y },
88
    [0x75] = KC_U,
88
    [0x75] = { 0, KC_U },
89
    [0x69] = KC_I,
89
    [0x69] = { 0, KC_I },
90
    [0x6f] = KC_O,
90
    [0x6f] = { 0, KC_O },
91
    [0x70] = KC_P,
91
    [0x70] = { 0, KC_P },
92
 
92
 
93
    [0x5b] = KC_LBRACKET,
93
    [0x5b] = { 0, KC_LBRACKET },
94
    [0x5d] = KC_RBRACKET,
94
    [0x5d] = { 0, KC_RBRACKET },
95
 
-
 
96
//  [0x3a] = KC_CAPS_LOCK,
-
 
97
 
95
 
98
    [0x61] = KC_A,
96
    [0x61] = { 0, KC_A },
99
    [0x73] = KC_S,
97
    [0x73] = { 0, KC_S },
100
    [0x64] = KC_D,
98
    [0x64] = { 0, KC_D },
101
    [0x66] = KC_F,
99
    [0x66] = { 0, KC_F },
102
    [0x67] = KC_G,
100
    [0x67] = { 0, KC_G },
103
    [0x68] = KC_H,
101
    [0x68] = { 0, KC_H },
104
    [0x6a] = KC_J,
102
    [0x6a] = { 0, KC_J },
105
    [0x6b] = KC_K,
103
    [0x6b] = { 0, KC_K },
106
    [0x6c] = KC_L,
104
    [0x6c] = { 0, KC_L },
107
 
105
 
108
    [0x3b] = KC_SEMICOLON,
106
    [0x3b] = { 0, KC_SEMICOLON },
109
    [0x27] = KC_QUOTE,
107
    [0x27] = { 0, KC_QUOTE },
110
    [0x5c] = KC_BACKSLASH,
108
    [0x5c] = { 0, KC_BACKSLASH },
111
 
-
 
112
//  [0x2a] = KC_LSHIFT,
-
 
113
 
109
 
114
    [0x7a] = KC_Z,
110
    [0x7a] = { 0, KC_Z },
115
    [0x78] = KC_X,
111
    [0x78] = { 0, KC_X },
116
    [0x63] = KC_C,
112
    [0x63] = { 0, KC_C },
117
    [0x76] = KC_V,
113
    [0x76] = { 0, KC_V },
118
    [0x62] = KC_B,
114
    [0x62] = { 0, KC_B },
119
    [0x6e] = KC_N,
115
    [0x6e] = { 0, KC_N },
120
    [0x6d] = KC_M,
116
    [0x6d] = { 0, KC_M },
121
 
117
 
122
    [0x2c] = KC_COMMA,
118
    [0x2c] = { 0, KC_COMMA },
123
    [0x2e] = KC_PERIOD,
119
    [0x2e] = { 0, KC_PERIOD },
124
    [0x2f] = KC_SLASH,
120
    [0x2f] = { 0, KC_SLASH },
125
 
121
 
126
//  [0x36] = KC_RSHIFT,
122
    [0x20] = { 0, KC_SPACE },
127
 
123
 
128
//  [0x1d] = KC_LCTRL,
124
    [0x1b] = { 0, KC_ESCAPE },
-
 
125
 
129
//  [0x38] = KC_LALT,
126
    [0x0a] = { 0, KC_ENTER },
130
    [0x20] = KC_SPACE,
127
    [0x0d] = { 0, KC_ENTER },
-
 
128
 
-
 
129
    /* with Shift pressed */
-
 
130
 
-
 
131
    [0x7e] = { KM_LSHIFT, KC_BACKTICK },
131
 
132
 
-
 
133
    [0x21] = { KM_LSHIFT, KC_1 },
-
 
134
    [0x40] = { KM_LSHIFT, KC_2 },
-
 
135
    [0x23] = { KM_LSHIFT, KC_3 },
-
 
136
    [0x24] = { KM_LSHIFT, KC_4 },
-
 
137
    [0x25] = { KM_LSHIFT, KC_5 },
-
 
138
    [0x5e] = { KM_LSHIFT, KC_6 },
-
 
139
    [0x26] = { KM_LSHIFT, KC_7 },
-
 
140
    [0x2a] = { KM_LSHIFT, KC_8 },
-
 
141
    [0x28] = { KM_LSHIFT, KC_9 },
132
    [0x1b] = KC_ESCAPE,
142
    [0x29] = { KM_LSHIFT, KC_0 },
-
 
143
 
-
 
144
    [0x5f] = { KM_LSHIFT, KC_MINUS },
-
 
145
    [0x2b] = { KM_LSHIFT, KC_EQUALS },
133
 
146
 
-
 
147
    [0x51] = { KM_LSHIFT, KC_Q },
-
 
148
    [0x57] = { KM_LSHIFT, KC_W },
134
    [0x0a] = KC_ENTER,
149
    [0x45] = { KM_LSHIFT, KC_E },
135
    [0x0d] = KC_ENTER
150
    [0x52] = { KM_LSHIFT, KC_R },
-
 
151
    [0x54] = { KM_LSHIFT, KC_T },
-
 
152
    [0x59] = { KM_LSHIFT, KC_Y },
-
 
153
    [0x55] = { KM_LSHIFT, KC_U },
-
 
154
    [0x49] = { KM_LSHIFT, KC_I },
-
 
155
    [0x4f] = { KM_LSHIFT, KC_O },
-
 
156
    [0x50] = { KM_LSHIFT, KC_P },
136
 
157
 
-
 
158
    [0x7b] = { KM_LSHIFT, KC_LBRACKET },
-
 
159
    [0x7d] = { KM_LSHIFT, KC_RBRACKET },
137
/*
160
 
138
    [0x1] = KC_PRNSCR,
161
    [0x41] = { KM_LSHIFT, KC_A },
-
 
162
    [0x53] = { KM_LSHIFT, KC_S },
-
 
163
    [0x44] = { KM_LSHIFT, KC_D },
-
 
164
    [0x46] = { KM_LSHIFT, KC_F },
-
 
165
    [0x47] = { KM_LSHIFT, KC_G },
-
 
166
    [0x48] = { KM_LSHIFT, KC_H },
-
 
167
    [0x4a] = { KM_LSHIFT, KC_J },
-
 
168
    [0x4b] = { KM_LSHIFT, KC_K },
-
 
169
    [0x4c] = { KM_LSHIFT, KC_L },
-
 
170
 
-
 
171
    [0x3a] = { KM_LSHIFT, KC_SEMICOLON },
-
 
172
    [0x22] = { KM_LSHIFT, KC_QUOTE },
-
 
173
    [0x7c] = { KM_LSHIFT, KC_BACKSLASH },
-
 
174
 
-
 
175
    [0x5a] = { KM_LSHIFT, KC_Z },
-
 
176
    [0x58] = { KM_LSHIFT, KC_X },
139
    [0x1] = KC_SCROLL_LOCK,
177
    [0x43] = { KM_LSHIFT, KC_C },
-
 
178
    [0x56] = { KM_LSHIFT, KC_V },
-
 
179
    [0x42] = { KM_LSHIFT, KC_B },
-
 
180
    [0x4e] = { KM_LSHIFT, KC_N },
140
    [0x1] = KC_PAUSE,
181
    [0x4d] = { KM_LSHIFT, KC_M },
141
*/
182
 
-
 
183
    [0x3c] = { KM_LSHIFT, KC_COMMA },
-
 
184
    [0x3e] = { KM_LSHIFT, KC_PERIOD },
-
 
185
    [0x3f] = { KM_LSHIFT, KC_SLASH }
142
};
186
};
143
 
187
 
144
static int map_e1[] =
188
static int map_e1[][2] =
145
{
189
{
146
    [0x50] = KC_F1,
190
    [0x50] = { 0, KC_F1 },
147
    [0x51] = KC_F2,
191
    [0x51] = { 0, KC_F2 },
148
    [0x52] = KC_F3,
192
    [0x52] = { 0, KC_F3 },
149
    [0x53] = KC_F4,
193
    [0x53] = { 0, KC_F4 },
150
};
194
};
151
 
195
 
152
static int map_e2[] =
196
static int map_e2[][2] =
153
{
197
{
154
    [0x41] = KC_UP,
198
    [0x41] = { 0, KC_UP },
155
    [0x42] = KC_DOWN,
199
    [0x42] = { 0, KC_DOWN },
156
    [0x44] = KC_LEFT,
200
    [0x44] = { 0, KC_LEFT },
157
    [0x43] = KC_RIGHT,
201
    [0x43] = { 0, KC_RIGHT },
158
};
202
};
159
 
203
 
160
static int map_e2a[] =
204
static int map_e2a[][2] =
161
{
205
{
162
    [0x35] = KC_F5,
206
    [0x35] = { 0, KC_F5 },
163
    [0x37] = KC_F6,
207
    [0x37] = { 0, KC_F6 },
164
    [0x38] = KC_F7,
208
    [0x38] = { 0, KC_F7 },
165
    [0x39] = KC_F8,
209
    [0x39] = { 0, KC_F8 },
166
};
210
};
167
 
211
 
168
static int map_e2b[] =
212
static int map_e2b[][2] =
169
{
213
{
170
    [0x30] = KC_F9,
214
    [0x30] = { 0, KC_F9 },
171
    [0x31] = KC_F10,
215
    [0x31] = { 0, KC_F10 },
172
    [0x32] = KC_F11,
216
    [0x32] = { 0, KC_F11 },
173
    [0x33] = KC_F12,
217
    [0x33] = { 0, KC_F12 },
174
};
218
};
175
 
219
 
-
 
220
static unsigned int mods_keys[][2] = {
-
 
221
    { KM_LSHIFT, KC_LSHIFT },
-
 
222
    { 0, 0 }
-
 
223
};
176
 
224
 
177
static enum dec_state ds;
225
static enum dec_state ds;
178
 
226
 
179
void kbd_ctl_parse_scancode(int scancode)
227
void kbd_ctl_parse_scancode(int scancode)
180
{
228
{
Line 188... Line 236...
188
    }
236
    }
189
}
237
}
190
 
238
 
191
static void parse_ds_start(int scancode)
239
static void parse_ds_start(int scancode)
192
{
240
{
193
    if (scancode < 0 || scancode >= sizeof(map_start) / sizeof(int))
-
 
194
        return;
-
 
195
 
-
 
196
    if (scancode == 0x1b) {
241
    if (scancode == 0x1b) {
197
        ds = ds_e;
242
        ds = ds_e;
198
        return;
243
        return;
199
    }
244
    }
200
 
245
 
201
    parse_leaf(scancode, map_start, sizeof(map_start) / sizeof(int));
246
    parse_leaf(scancode, map_start, sizeof(map_start) / (2 * sizeof(int)));
202
}
247
}
203
 
248
 
204
static void parse_ds_e(int scancode)
249
static void parse_ds_e(int scancode)
205
{
250
{
206
    if (scancode < 0 || scancode >= 0x80) return;
251
    if (scancode < 0 || scancode >= 0x80) return;
Line 215... Line 260...
215
    kbd_push_ev(KE_PRESS, KC_ESCAPE);
260
    kbd_push_ev(KE_PRESS, KC_ESCAPE);
216
}
261
}
217
 
262
 
218
static void parse_ds_e1(int scancode)
263
static void parse_ds_e1(int scancode)
219
{
264
{
220
    parse_leaf(scancode, map_e1, sizeof(map_e1) / sizeof(int));
265
    parse_leaf(scancode, map_e1, sizeof(map_e1) / (2 * sizeof(int)));
221
}
266
}
222
 
267
 
223
static void parse_ds_e2(int scancode)
268
static void parse_ds_e2(int scancode)
224
{
269
{
225
    switch (scancode) {
270
    switch (scancode) {
226
    case 0x31: ds = ds_e2a; break;
271
    case 0x31: ds = ds_e2a; break;
227
    case 0x32: ds = ds_e2b; break;
272
    case 0x32: ds = ds_e2b; break;
228
    default: ds = ds_start; break;
273
    default: ds = ds_start; break;
229
    }
274
    }
230
 
275
 
231
    parse_leaf(scancode, map_e2, sizeof(map_e2) / sizeof(int));
276
    parse_leaf(scancode, map_e2, sizeof(map_e2) / (2 * sizeof(int)));
232
}
277
}
233
 
278
 
234
static void parse_ds_e2a(int scancode)
279
static void parse_ds_e2a(int scancode)
235
{
280
{
236
    parse_leaf(scancode, map_e2a, sizeof(map_e2a) / sizeof(int));
281
    parse_leaf(scancode, map_e2a, sizeof(map_e2a) / (2 * sizeof(int)));
237
}
282
}
238
 
283
 
239
static void parse_ds_e2b(int scancode)
284
static void parse_ds_e2b(int scancode)
240
{
285
{
241
    parse_leaf(scancode, map_e2b, sizeof(map_e2b) / sizeof(int));
286
    parse_leaf(scancode, map_e2b, sizeof(map_e2b) / (2 * sizeof(int)));
242
}
287
}
243
 
288
 
244
static void parse_leaf(int scancode, int *map, size_t map_length)
289
static void parse_leaf(int scancode, int (*map)[2], size_t map_length)
245
{
290
{
246
    unsigned int key;
291
    unsigned int key, mod;
-
 
292
    int i;
247
 
293
 
248
    ds = ds_start;
294
    ds = ds_start;
249
 
295
 
250
    if (scancode < 0 || scancode >= map_length)
296
    if (scancode < 0 || scancode >= map_length)
251
        return;
297
        return;
252
 
298
 
-
 
299
    mod = map[scancode][0];
253
    key = map[scancode];
300
    key = map[scancode][1];
-
 
301
 
-
 
302
    /* Simulate modifier pressing. */
-
 
303
    i = 0;
-
 
304
    while (mods_keys[i][0] != 0) {
-
 
305
        if (mod & mods_keys[i][0]) {
-
 
306
            kbd_push_ev(KE_PRESS, mods_keys[i][1]);
-
 
307
        }
-
 
308
        ++i;
-
 
309
    }
-
 
310
 
254
    if (key != 0)
311
    if (key != 0) {
255
        kbd_push_ev(KE_PRESS, key);
312
        kbd_push_ev(KE_PRESS, key);
-
 
313
        kbd_push_ev(KE_RELEASE, key);
-
 
314
    }
-
 
315
 
-
 
316
    /* Simulate modifier releasing. */
-
 
317
    i = 0;
-
 
318
    while (mods_keys[i][0] != 0) {
-
 
319
        if (mod & mods_keys[i][0]) {
-
 
320
            kbd_push_ev(KE_RELEASE, mods_keys[i][1]);
-
 
321
        }
-
 
322
        ++i;
-
 
323
    }
256
}
324
}
257
 
325
 
258
 
326
 
259
/**
327
/**
260
 * @}
328
 * @}