Subversion Repositories HelenOS

Rev

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

Rev 2350 Rev 2360
1
/*
1
/*
2
 * Copyright (c) 2007 Michal Kebrt
2
 * Copyright (c) 2007 Michal Kebrt
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 kbdarm32gxemul GXemul
29
/** @addtogroup kbdarm32gxemul GXemul
30
 * @brief   HelenOS arm32 GXEmul uspace keyboard handler.
30
 * @brief   HelenOS arm32 GXEmul uspace keyboard handler.
31
 * @ingroup  kbdarm32
31
 * @ingroup  kbdarm32
32
 * @{
32
 * @{
33
 */
33
 */
34
/** @file
34
/** @file
35
 *  @brief GXemul uspace keyboard handler.
35
 *  @brief GXemul uspace keyboard handler.
36
 */
36
 */
37
 
37
 
38
#include <ipc/ipc.h>
38
#include <ipc/ipc.h>
39
#include <sysinfo.h>
39
#include <sysinfo.h>
40
#include <kbd.h>
40
#include <kbd.h>
41
#include <keys.h>
41
#include <keys.h>
-
 
42
#include <bool.h>
-
 
43
 
42
 
44
 
43
#define GXEMUL_KEY_F1  0x504f1bL
45
#define GXEMUL_KEY_F1  0x504f1bL
44
#define GXEMUL_KEY_F2  0x514f1bL
46
#define GXEMUL_KEY_F2  0x514f1bL
45
#define GXEMUL_KEY_F3  0x524f1bL
47
#define GXEMUL_KEY_F3  0x524f1bL
46
#define GXEMUL_KEY_F4  0x534f1bL
48
#define GXEMUL_KEY_F4  0x534f1bL
47
#define GXEMUL_KEY_F5  0x35315b1bL
49
#define GXEMUL_KEY_F5  0x35315b1bL
48
#define GXEMUL_KEY_F6  0x37315b1bL
50
#define GXEMUL_KEY_F6  0x37315b1bL
49
#define GXEMUL_KEY_F7  0x38315b1bL
51
#define GXEMUL_KEY_F7  0x38315b1bL
50
#define GXEMUL_KEY_F8  0x39315b1bL
52
#define GXEMUL_KEY_F8  0x39315b1bL
51
#define GXEMUL_KEY_F9  0x30325b1bL
53
#define GXEMUL_KEY_F9  0x30325b1bL
52
#define GXEMUL_KEY_F10 0x31325b1bL
54
#define GXEMUL_KEY_F10 0x31325b1bL
53
#define GXEMUL_KEY_F11 0x33325d1bL
55
#define GXEMUL_KEY_F11 0x33325d1bL
54
#define GXEMUL_KEY_F12 0x34325b1bL 
56
#define GXEMUL_KEY_F12 0x34325b1bL 
55
 
57
 
-
 
58
 
-
 
59
#define GXEMUL_FB_KEY_F1 0x504f5b1bL
-
 
60
#define GXEMUL_FB_KEY_F2 0x514f5b1bL
-
 
61
#define GXEMUL_FB_KEY_F3 0x524f5b1bL
-
 
62
#define GXEMUL_FB_KEY_F4 0x534f5b1bL
-
 
63
#define GXEMUL_FB_KEY_F5 0x35315b1bL
-
 
64
#define GXEMUL_FB_KEY_F6 0x37315b1bL
-
 
65
#define GXEMUL_FB_KEY_F7 0x38315b1bL
-
 
66
#define GXEMUL_FB_KEY_F8 0x39315b1bL
-
 
67
#define GXEMUL_FB_KEY_F9 0x38325b1bL
-
 
68
#define GXEMUL_FB_KEY_F10 0x39325b1bL
-
 
69
#define GXEMUL_FB_KEY_F11 0x33325b1bL
-
 
70
#define GXEMUL_FB_KEY_F12 0x34325b1bL
-
 
71
 
-
 
72
 
56
/** Function keys start code (F1=0x101) */
73
/** Function keys start code (F1=0x101) */
57
#define FUNCTION_KEYS 0x100
74
#define FUNCTION_KEYS 0x100
58
 
75
 
59
irq_cmd_t gxemul_cmds[] = {
76
static irq_cmd_t gxemul_cmds[] = {
60
    {
77
    {
61
        CMD_MEM_READ_1,
78
        CMD_MEM_READ_1,
62
        (void *) 0,
79
        (void *) 0,
63
        0,
80
        0,
64
        2
81
        2
65
    }
82
    }
66
};
83
};
67
 
84
 
68
irq_code_t gxemul_kbd = {
85
static irq_code_t gxemul_kbd = {
69
    1,
86
    1,
70
    gxemul_cmds
87
    gxemul_cmds
71
};
88
};
72
 
89
 
73
 
90
 
-
 
91
/** Framebuffer switched on. */
-
 
92
static bool fb;
-
 
93
 
-
 
94
 
74
/*
95
/*
75
// Please preserve this code (it can be used to determine scancodes)
96
// Please preserve this code (it can be used to determine scancodes)
76
int to_hex(int v)
97
int to_hex(int v)
77
{
98
{
78
        return "0123456789ABCDEF"[v];
99
        return "0123456789ABCDEF"[v];
79
}
100
}
80
*/
101
*/
81
 
102
 
82
 
103
 
83
/** Process data sent when a key is pressed.
104
/** Process data sent when a key is pressed (in no-framebuffer mode).
84
 *  
105
 *  
85
 *  @param keybuffer Buffer of scan codes.
106
 *  @param keybuffer Buffer of scan codes.
86
 *  @param scan_code Scan code.
107
 *  @param scan_code Scan code.
87
 *
108
 *
88
 *  @return Code of the pressed key.
109
 *  @return Code of the pressed key.
89
 */
110
 */
90
static int gxemul_process_no_fb(keybuffer_t *keybuffer, int scan_code)
111
static int gxemul_process_no_fb(keybuffer_t *keybuffer, int scan_code)
91
{
112
{
92
 
113
 
93
    static unsigned long buf = 0;
114
    static unsigned long buf = 0;
94
    static int count = 0;  
115
    static int count = 0;  
95
 
116
 
96
    /* Preserve for detecting scan codes.
117
    // Preserve for detecting scan codes. 
97
    keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
118
    // keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
98
    keybuffer_push(keybuffer, to_hex(scan_code&0xf));
119
    // keybuffer_push(keybuffer, to_hex(scan_code&0xf));
99
    keybuffer_push(keybuffer, 'X');
120
    // keybuffer_push(keybuffer, 'X');
100
    keybuffer_push(keybuffer, 'Y');
121
    // keybuffer_push(keybuffer, 'Y');
101
    return 1;
122
    // return 1;
102
    */
-
 
103
 
123
 
104
    if (scan_code == '\r')
124
    if (scan_code == '\r')
105
        scan_code = '\n';
125
        scan_code = '\n';
106
 
126
 
107
    if(scan_code == 0x7e) {
127
    if(scan_code == 0x7e) {
108
        switch (buf) {
128
        switch (buf) {
109
        case GXEMUL_KEY_F5:
129
        case GXEMUL_KEY_F5:
110
            keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
130
            keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
111
            buf = count = 0;
131
            buf = count = 0;
112
            return 1;
132
            return 1;
113
        case GXEMUL_KEY_F6:
133
        case GXEMUL_KEY_F6:
114
            keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
134
            keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
115
            buf = count = 0;
135
            buf = count = 0;
116
            return 1;
136
            return 1;
117
        case GXEMUL_KEY_F7:
137
        case GXEMUL_KEY_F7:
118
            keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
138
            keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
119
            buf = count = 0;
139
            buf = count = 0;
120
            return 1;
140
            return 1;
121
        case GXEMUL_KEY_F8:
141
        case GXEMUL_KEY_F8:
122
            keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
142
            keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
123
            buf = count = 0;
143
            buf = count = 0;
124
            return 1;
144
            return 1;
125
        case GXEMUL_KEY_F9:
145
        case GXEMUL_KEY_F9:
126
            keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
146
            keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
127
            buf = count = 0;
147
            buf = count = 0;
128
            return 1;
148
            return 1;
129
        case GXEMUL_KEY_F10:
149
        case GXEMUL_KEY_F10:
130
            keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
150
            keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
131
            buf = count = 0;
151
            buf = count = 0;
132
            return 1;
152
            return 1;
133
        case GXEMUL_KEY_F11:
153
        case GXEMUL_KEY_F11:
134
            keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
154
            keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
135
            buf = count = 0;
155
            buf = count = 0;
136
            return 1;
156
            return 1;
137
        case GXEMUL_KEY_F12:
157
        case GXEMUL_KEY_F12:
138
            keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
158
            keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
139
            buf = count = 0;
159
            buf = count = 0;
140
            return 1;
160
            return 1;
141
        default:
161
        default:
142
            keybuffer_push(keybuffer, buf & 0xff);
162
            keybuffer_push(keybuffer, buf & 0xff);
143
            keybuffer_push(keybuffer, (buf >> 8) &0xff);
163
            keybuffer_push(keybuffer, (buf >> 8) &0xff);
144
            keybuffer_push(keybuffer, (buf >> 16) &0xff);
164
            keybuffer_push(keybuffer, (buf >> 16) &0xff);
145
            keybuffer_push(keybuffer, (buf >> 24) &0xff);
165
            keybuffer_push(keybuffer, (buf >> 24) &0xff);
146
            keybuffer_push(keybuffer, scan_code);
166
            keybuffer_push(keybuffer, scan_code);
147
            buf = count = 0;
167
            buf = count = 0;
148
            return 1;
168
            return 1;
149
        }
169
        }
150
    }
170
    }
151
 
171
 
152
    buf |= ((unsigned long) scan_code)<<(8*(count++));
172
    buf |= ((unsigned long) scan_code)<<(8*(count++));
153
   
173
   
154
    if((buf & 0xff) != (GXEMUL_KEY_F1 & 0xff)) {
174
    if((buf & 0xff) != (GXEMUL_KEY_F1 & 0xff)) {
155
        keybuffer_push(keybuffer, buf);
175
        keybuffer_push(keybuffer, buf);
156
        buf = count = 0;
176
        buf = count = 0;
157
        return 1;
177
        return 1;
158
    }
178
    }
159
 
179
 
160
    if (count <= 1)
180
    if (count <= 1)
161
        return 1;
181
        return 1;
162
 
182
 
163
    if ((buf & 0xffff) != (GXEMUL_KEY_F1 & 0xffff)
183
    if ((buf & 0xffff) != (GXEMUL_KEY_F1 & 0xffff)
164
        && (buf & 0xffff) != (GXEMUL_KEY_F5 & 0xffff) ) {
184
        && (buf & 0xffff) != (GXEMUL_KEY_F5 & 0xffff) ) {
165
 
185
 
166
        keybuffer_push(keybuffer, buf & 0xff);
186
        keybuffer_push(keybuffer, buf & 0xff);
167
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
187
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
168
        buf = count = 0;
188
        buf = count = 0;
169
        return 1;
189
        return 1;
170
    }
190
    }
171
 
191
 
172
    if (count <= 2)
192
    if (count <= 2)
173
        return 1;
193
        return 1;
174
 
194
 
175
    switch (buf) {
195
    switch (buf) {
176
    case GXEMUL_KEY_F1:
196
    case GXEMUL_KEY_F1:
177
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
197
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
178
        buf = count = 0;
198
        buf = count = 0;
179
        return 1;
199
        return 1;
180
    case GXEMUL_KEY_F2:
200
    case GXEMUL_KEY_F2:
181
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
201
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
182
        buf = count = 0;
202
        buf = count = 0;
183
        return 1;
203
        return 1;
184
    case GXEMUL_KEY_F3:
204
    case GXEMUL_KEY_F3:
185
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
205
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
186
        buf = count = 0;
206
        buf = count = 0;
187
        return 1;
207
        return 1;
188
    case GXEMUL_KEY_F4:
208
    case GXEMUL_KEY_F4:
189
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
209
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
190
        buf = count = 0;
210
        buf = count = 0;
191
        return 1;
211
        return 1;
192
    }
212
    }
193
 
213
 
194
 
214
 
195
    if((buf & 0xffffff) != (GXEMUL_KEY_F5 & 0xffffff)
215
    if((buf & 0xffffff) != (GXEMUL_KEY_F5 & 0xffffff)
196
        && (buf & 0xffffff) != (GXEMUL_KEY_F9 & 0xffffff)) {
216
        && (buf & 0xffffff) != (GXEMUL_KEY_F9 & 0xffffff)) {
197
 
217
 
198
        keybuffer_push(keybuffer, buf & 0xff);
218
        keybuffer_push(keybuffer, buf & 0xff);
199
        keybuffer_push(keybuffer, (buf >> 8) & 0xff);
219
        keybuffer_push(keybuffer, (buf >> 8) & 0xff);
200
        keybuffer_push(keybuffer, (buf >> 16) & 0xff);
220
        keybuffer_push(keybuffer, (buf >> 16) & 0xff);
201
        buf=count=0;
221
        buf=count=0;
202
        return 1;
222
        return 1;
203
    }
223
    }
204
 
224
 
205
    if (count <= 3)
225
    if (count <= 3)
206
        return 1;
226
        return 1;
207
   
227
   
208
    switch (buf) {
228
    switch (buf) {
209
    case GXEMUL_KEY_F5:
229
    case GXEMUL_KEY_F5:
210
    case GXEMUL_KEY_F6:
230
    case GXEMUL_KEY_F6:
211
    case GXEMUL_KEY_F7:
231
    case GXEMUL_KEY_F7:
212
    case GXEMUL_KEY_F8:
232
    case GXEMUL_KEY_F8:
213
    case GXEMUL_KEY_F9:
233
    case GXEMUL_KEY_F9:
214
    case GXEMUL_KEY_F10:
234
    case GXEMUL_KEY_F10:
215
    case GXEMUL_KEY_F11:
235
    case GXEMUL_KEY_F11:
216
    case GXEMUL_KEY_F12:
236
    case GXEMUL_KEY_F12:
217
        return 1;
237
        return 1;
218
    default:
238
    default:
219
        keybuffer_push(keybuffer, buf & 0xff);
239
        keybuffer_push(keybuffer, buf & 0xff);
220
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
240
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
221
        keybuffer_push(keybuffer, (buf >> 16) &0xff);
241
        keybuffer_push(keybuffer, (buf >> 16) &0xff);
222
        keybuffer_push(keybuffer, (buf >> 24) &0xff);
242
        keybuffer_push(keybuffer, (buf >> 24) &0xff);
223
        buf = count = 0;
243
        buf = count = 0;
224
        return 1;
244
        return 1;
225
    }
245
    }
226
    return 1;
246
    return 1;
227
}
247
}
228
 
248
 
229
 
249
 
-
 
250
/** Process data sent when a key is pressed (in framebuffer mode).
-
 
251
 *  
-
 
252
 *  @param keybuffer Buffer of scan codes.
-
 
253
 *  @param scan_code Scan code.
-
 
254
 *
-
 
255
 *  @return Code of the pressed key.
-
 
256
 */
-
 
257
static int gxemul_process_fb(keybuffer_t *keybuffer, int scan_code)
-
 
258
{
-
 
259
    static unsigned long buf = 0;
-
 
260
    static int count = 0;
-
 
261
 
-
 
262
    /* Please preserve this code (it can be used to determine scancodes)
-
 
263
   
-
 
264
    keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
-
 
265
    keybuffer_push(keybuffer, to_hex(scan_code&0xf));
-
 
266
    keybuffer_push(keybuffer, ' ');
-
 
267
    keybuffer_push(keybuffer, ' ');
-
 
268
   
-
 
269
    return 1;
-
 
270
    */
-
 
271
   
-
 
272
    if (scan_code == '\r')
-
 
273
        scan_code = '\n';
-
 
274
   
-
 
275
    buf |= ((unsigned long) scan_code)<<(8*(count++));
-
 
276
   
-
 
277
   
-
 
278
    if ((buf & 0xff) != (GXEMUL_FB_KEY_F1 & 0xff)) {
-
 
279
        keybuffer_push(keybuffer, buf);
-
 
280
        buf = count = 0;
-
 
281
        return 1;
-
 
282
    }
-
 
283
 
-
 
284
    if (count <= 1)
-
 
285
        return 1;
-
 
286
 
-
 
287
    if ((buf & 0xffff) != (GXEMUL_FB_KEY_F1 & 0xffff)) {
-
 
288
        keybuffer_push(keybuffer, buf & 0xff);
-
 
289
        keybuffer_push(keybuffer, (buf >> 8) &0xff);
-
 
290
        buf = count = 0;
-
 
291
        return 1;
-
 
292
    }
-
 
293
 
-
 
294
    if (count <= 2)
-
 
295
        return 1;
-
 
296
 
-
 
297
 
-
 
298
    if ((buf & 0xffffff) != (GXEMUL_FB_KEY_F1 & 0xffffff)
-
 
299
        && (buf & 0xffffff) != (GXEMUL_FB_KEY_F5 & 0xffffff)
-
 
300
        && (buf & 0xffffff) != (GXEMUL_FB_KEY_F9 & 0xffffff)) {
-
 
301
 
-
 
302
        keybuffer_push(keybuffer, buf & 0xff);
-
 
303
        keybuffer_push(keybuffer, (buf >> 8) & 0xff);
-
 
304
        keybuffer_push(keybuffer, (buf >> 16) & 0xff);
-
 
305
        buf = count = 0;
-
 
306
        return 1;
-
 
307
    }
-
 
308
 
-
 
309
    if ( count <= 3 )
-
 
310
        return 1;
-
 
311
   
-
 
312
 
-
 
313
    switch (buf) {
-
 
314
    case GXEMUL_FB_KEY_F1:
-
 
315
        keybuffer_push(keybuffer,FUNCTION_KEYS | 1 );
-
 
316
        buf=count=0;
-
 
317
        return 1;
-
 
318
    case GXEMUL_FB_KEY_F2:
-
 
319
        keybuffer_push(keybuffer,FUNCTION_KEYS | 2 );
-
 
320
        buf=count=0;
-
 
321
        return 1;
-
 
322
    case GXEMUL_FB_KEY_F3:
-
 
323
        keybuffer_push(keybuffer,FUNCTION_KEYS | 3 );
-
 
324
        buf=count=0;
-
 
325
        return 1;
-
 
326
    case GXEMUL_FB_KEY_F4:
-
 
327
        keybuffer_push(keybuffer,FUNCTION_KEYS | 4 );
-
 
328
        buf=count=0;
-
 
329
        return 1;
-
 
330
    case GXEMUL_FB_KEY_F5:
-
 
331
        keybuffer_push(keybuffer,FUNCTION_KEYS | 5 );
-
 
332
        buf=count=0;
-
 
333
        return 1;
-
 
334
    case GXEMUL_FB_KEY_F6:
-
 
335
        keybuffer_push(keybuffer,FUNCTION_KEYS | 6 );
-
 
336
        buf=count=0;
-
 
337
        return 1;
-
 
338
    case GXEMUL_FB_KEY_F7:
-
 
339
        keybuffer_push(keybuffer,FUNCTION_KEYS | 7 );
-
 
340
        buf=count=0;
-
 
341
        return 1;
-
 
342
    case GXEMUL_FB_KEY_F8:
-
 
343
        keybuffer_push(keybuffer,FUNCTION_KEYS | 8 );
-
 
344
        buf=count=0;
-
 
345
        return 1;
-
 
346
    case GXEMUL_FB_KEY_F9:
-
 
347
        keybuffer_push(keybuffer,FUNCTION_KEYS | 9 );
-
 
348
        buf=count=0;
-
 
349
        return 1;
-
 
350
    case GXEMUL_FB_KEY_F10:
-
 
351
        keybuffer_push(keybuffer,FUNCTION_KEYS | 10 );
-
 
352
        buf=count=0;
-
 
353
        return 1;
-
 
354
    case GXEMUL_FB_KEY_F11:
-
 
355
        keybuffer_push(keybuffer,FUNCTION_KEYS | 11 );
-
 
356
        buf=count=0;
-
 
357
        return 1;
-
 
358
    case GXEMUL_FB_KEY_F12:
-
 
359
        keybuffer_push(keybuffer,FUNCTION_KEYS | 12 );
-
 
360
        buf=count=0;
-
 
361
        return 1;
-
 
362
    default:
-
 
363
        keybuffer_push(keybuffer, buf & 0xff );
-
 
364
        keybuffer_push(keybuffer, (buf >> 8) &0xff );
-
 
365
        keybuffer_push(keybuffer, (buf >> 16) &0xff );
-
 
366
        keybuffer_push(keybuffer, (buf >> 24) &0xff );
-
 
367
        buf=count=0;
-
 
368
        return 1;
-
 
369
    }
-
 
370
    return 1;
-
 
371
}
-
 
372
 
-
 
373
 
230
/** Initializes keyboard handler. */
374
/** Initializes keyboard handler. */
231
int kbd_arch_init(void)
375
int kbd_arch_init(void)
232
{
376
{
-
 
377
    fb = (sysinfo_value("fb.kind") == 1);
233
    gxemul_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual");
378
    gxemul_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual");
234
    ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &gxemul_kbd);
379
    ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &gxemul_kbd);
235
    return 0;
380
    return 0;
236
}
381
}
237
 
382
 
238
 
383
 
239
/** Process data sent when a key is pressed.
384
/** Process data sent when a key is pressed.
240
 *  
385
 *  
241
 *  @param keybuffer Buffer of scan codes.
386
 *  @param keybuffer Buffer of scan codes.
242
 *  @param call      IPC call.
387
 *  @param call      IPC call.
243
 *
388
 *
244
 *  @return Code of the pressed key.
389
 *  @return Code of the pressed key.
245
 */
390
 */
246
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
391
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
247
{
392
{
248
    int scan_code = IPC_GET_ARG2(*call);
393
    int scan_code = IPC_GET_ARG2(*call);
249
    static int esc_count = 0;
394
    static int esc_count = 0;
250
 
395
 
251
    if (scan_code == 0x1b) {
396
    if (scan_code == 0x1b) {
252
        esc_count++;
397
        esc_count++;
253
        if (esc_count == 3) {
398
        if (esc_count == 3) {
254
            __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
399
            __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
255
        }
400
        }
256
    } else {
401
    } else {
257
        esc_count = 0;
402
        esc_count = 0;
258
    }
403
    }
259
 
404
 
-
 
405
    if (fb) {
-
 
406
        return gxemul_process_fb(keybuffer, scan_code);
-
 
407
    } else {
260
    return gxemul_process_no_fb(keybuffer, scan_code);
408
        return gxemul_process_no_fb(keybuffer, scan_code);
-
 
409
    }
-
 
410
 
261
}
411
}
262
 
412
 
263
/** @}
413
/** @}
264
 */
414
 */
265
 
415