~ubuntu-branches/ubuntu/maverick/ldtp/maverick

« back to all changes in this revision

Viewing changes to src/device.c

  • Committer: Bazaar Package Importer
  • Author(s): Kartik Mistry
  • Date: 2010-02-04 10:36:08 UTC
  • mfrom: (1.4.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: james.westby@ubuntu.com-20100204103608-dhqdo7jk10ygwt40
Tags: 2.0.2-1
* New upstream release:
  + Packaging is based on Ubuntu packages, Thanks Ubuntu!
  + LDTPv2 is a complete rewrite of LDTPv1 in Python
  + LTFX is completely removed in LDTP v2 in favor of wnck
* debian/control:
  + Updated to Standards-Version 3.8.4 (no changes needed)
  + Fixed typo in description python->Python
  + ldtp is now arch: all package
* debian/rules:
  + Using dh to make it simple
* Removed unused manpages
* Updated package to use new source format 3.0 (quilt)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
 
/*
3
 
 * Linux Desktop Testing Project http://ldtp.freedesktop.org
4
 
 *
5
 
 * Author:
6
 
 *    Prashanth Mohan <prashmohan@gmail.com>
7
 
 *
8
 
 * Copyright 2004 - 2006 Novell, Inc.
9
 
 *
10
 
 * This program is free software; you can redistribute it and/or
11
 
 * modify it under the terms of the GNU Lesser General Public
12
 
 * License as published by the Free Software Foundation; either
13
 
 * version 2 of the License, or (at your option) any later version.
14
 
 *
15
 
 * This library is distributed in the hope that it will be useful,
16
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
 
 * Lesser General Public License for more details.
19
 
 *
20
 
 * You should have received a copy of the GNU Lesser General Public
21
 
 * License along with this program; if not, write to the
22
 
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23
 
 * Boston, MA 02110, USA.
24
 
 */
25
 
 
26
 
#include "ldtp.h"
27
 
#include "ldtp-gui.h"
28
 
#include "ldtp-error.h"
29
 
#include "ldtp-logger.h"
30
 
#include "ldtp-command.h"
31
 
#include "ldtp-gui-comp.h"
32
 
#include "device.h"
33
 
     
34
 
struct NonPrint_Key_Synth NonPrint_Key_Synth_Vals[300];
35
 
 
36
 
static LDTPErrorCode
37
 
mouse_left_click (Accessible *object, FILE *log_fp)
38
 
{
39
 
        LDTPErrorCode error;
40
 
        SPIBoolean flag;
41
 
        long int x = 0, y = 0;
42
 
        long int width = 0;
43
 
        long int height = 0;
44
 
 
45
 
        if (Accessible_isComponent (object)) {
46
 
                AccessibleComponent *component;
47
 
                component = Accessible_getComponent (object);
48
 
                if (!AccessibleComponent_grabFocus (component)) {
49
 
                        Accessible_unref (component);
50
 
                        error = LDTP_ERROR_UNABLE_TO_GRAB_FOCUS;
51
 
                        log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
52
 
                        return error;
53
 
                }
54
 
 
55
 
                AccessibleComponent_getExtents (component, &x, &y, &width,
56
 
                                                &height, SPI_COORD_TYPE_SCREEN);
57
 
                Accessible_unref (component);
58
 
        } else {
59
 
                error = LDTP_ERROR_UNABLE_TO_GET_COMPONENT_HANDLE;
60
 
                log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
61
 
                return error;
62
 
        }
63
 
        flag = SPI_generateMouseEvent (x + width / 2, y + height / 2, "b1c");
64
 
        if (flag == FALSE) {
65
 
                error = LDTP_ERROR_CLICK_FAILED;
66
 
                log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
67
 
                return error;
68
 
        }
69
 
        return LDTP_ERROR_SUCCESS;
70
 
}
71
 
 
72
 
static LDTPErrorCode
73
 
mouse_right_click (Accessible *object, FILE *log_fp)
74
 
{
75
 
        SPIBoolean flag;
76
 
        LDTPErrorCode error;
77
 
        long int x = 0, y = 0;
78
 
        long int width = 0;
79
 
        long int height = 0;
80
 
 
81
 
        if (Accessible_isComponent (object)) {
82
 
                AccessibleComponent *component;
83
 
                component = Accessible_getComponent (object);
84
 
                if (!AccessibleComponent_grabFocus (component)) {
85
 
                        Accessible_unref (component);
86
 
                        error = LDTP_ERROR_UNABLE_TO_GRAB_FOCUS;
87
 
                        log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
88
 
                        return error;
89
 
                }
90
 
 
91
 
                AccessibleComponent_getExtents (component, &x, &y, &width,
92
 
                                                &height, SPI_COORD_TYPE_SCREEN);
93
 
                Accessible_unref (component);
94
 
        } else {
95
 
                error = LDTP_ERROR_UNABLE_TO_GET_COMPONENT_HANDLE;
96
 
                log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
97
 
                return error;
98
 
        }            
99
 
        flag = SPI_generateMouseEvent (x + width / 2, y + height / 2, "b3c");
100
 
        if (flag == FALSE) {
101
 
                error = LDTP_ERROR_RIGHT_CLICK_FAILED;
102
 
                log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
103
 
                return error;
104
 
        }
105
 
        return LDTP_ERROR_SUCCESS;
106
 
}
107
 
 
108
 
static LDTPErrorCode
109
 
mouse_move (Accessible *object, FILE *log_fp)
110
 
{
111
 
        LDTPErrorCode error;
112
 
        AccessibleCoordType screen_cood = SPI_COORD_TYPE_SCREEN;
113
 
        SPIBoolean flag;
114
 
        long int xpos, ypos;
115
 
        //long int width, height;
116
 
 
117
 
        if (Accessible_isComponent (object)) {
118
 
                AccessibleComponent *accessible_component;
119
 
                accessible_component = Accessible_getComponent (object);
120
 
                if (!AccessibleComponent_grabFocus (accessible_component)) {
121
 
                        Accessible_unref (accessible_component);
122
 
                        error = LDTP_ERROR_UNABLE_TO_GRAB_FOCUS;
123
 
                        goto error;
124
 
                }
125
 
                AccessibleComponent_getPosition (accessible_component, &xpos, &ypos, screen_cood);
126
 
                Accessible_unref (accessible_component);
127
 
        }
128
 
        else {
129
 
                error = LDTP_ERROR_UNABLE_TO_GET_COMPONENT_HANDLE;
130
 
                goto error;
131
 
        }            
132
 
        flag = SPI_generateMouseEvent (xpos, ypos, "abs");
133
 
        if (flag == FALSE) {
134
 
                error = LDTP_ERROR_UNABLE_TO_MOVE_MOUSE;
135
 
                goto error;
136
 
        }
137
 
        error = LDTP_ERROR_SUCCESS;
138
 
 
139
 
 error:
140
 
        if (error != LDTP_ERROR_SUCCESS)
141
 
                log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
142
 
        return error;
143
 
}
144
 
 
145
 
static struct KeyValue
146
 
get_key_value (gchar *keyval)
147
 
{
148
 
        static int Char_Key_Synth_Vals[] = {38, 56, 54, 40, 26, 41, 42, 43, 31,
149
 
                                            44, 45, 46, 58, 57, 32, 33, 24, 27,
150
 
                                            39, 28, 30, 55, 25, 53, 29, 52}; /* A - Z */
151
 
        static int Digit_Key_Synth_Vals[] = {19, 10, 11, 12, 13, 14, 15, 16, 17, 18}; /* 0 - 9 */
152
 
        static struct Symbol_Key_Synth Symbol_Key_Synth_Vals[] = {{'-', 20}, {'=', 21}, {'[', 34},
153
 
                                                                  {']', 35}, {';', 47}, {'\'', 48},
154
 
                                                                  {'`', 49}, {'\\', 51}, {',', 59},
155
 
                                                                  {'.', 60}, {'/', 61}, {' ', 65},
156
 
                                                                  {'!', 10}, {'@', 11}, {'#', 12},
157
 
                                                                  {'$', 13}, {'%', 14}, {'^', 15},
158
 
                                                                  {'&', 16}, {'*', 17}, {'(', 18},
159
 
                                                                  {')', 19}, {'_', 20}, {'+', 21},
160
 
                                                                  {'{', 34}, {'}', 35}, {':', 47},
161
 
                                                                  {'\"',48}, {'~', 49}, {'|', 51},
162
 
                                                                  {'<', 59}, {'>', 60}, {'\?', 61}};
163
 
 
164
 
        struct KeyValue return_val; /* will contain the return values */
165
 
        gint index;
166
 
 
167
 
        if (strlen (keyval) == 1) {
168
 
                /* This will identify small characters */
169
 
                if (*keyval >= 'a' && *keyval <= 'z') {
170
 
                        return_val.shift = FALSE;
171
 
                        return_val.capslck = FALSE;
172
 
                        return_val.non_print_key = FALSE;
173
 
                        return_val.value = Char_Key_Synth_Vals[*keyval-'a'];
174
 
                        return return_val;
175
 
                }
176
 
 
177
 
                /* This will identify Capital Charaters i.e. Shift+Small
178
 
                   Character */
179
 
                else if (*keyval >= 'A' && *keyval <= 'Z') {
180
 
                        return_val.shift = FALSE;
181
 
                        return_val.capslck = TRUE;
182
 
                        return_val.non_print_key = FALSE;
183
 
                        return_val.value = Char_Key_Synth_Vals[*keyval-'A'];
184
 
                        return return_val;
185
 
                }
186
 
 
187
 
                /* This will identify Digits */
188
 
                else if (*keyval >= '0' && *keyval <='9') {
189
 
                        return_val.shift = FALSE;
190
 
                        return_val.capslck = FALSE;
191
 
                        return_val.non_print_key = FALSE;
192
 
                        return_val.value = Digit_Key_Synth_Vals[*keyval-'0'];
193
 
                        return return_val;
194
 
                }
195
 
 
196
 
                /* This will identify Symbols */
197
 
                else {
198
 
                        /* Symbols obtained without using Shift Key */
199
 
                        for (index = 0; index < DOWNCHAR; index++) 
200
 
                                if (*keyval == Symbol_Key_Synth_Vals[index].sym) {
201
 
                                        return_val.shift = FALSE;
202
 
                                        return_val.capslck = FALSE;
203
 
                                        return_val.non_print_key = FALSE;
204
 
                                        return_val.value = Symbol_Key_Synth_Vals[index].KeyVal;
205
 
                                        return return_val;
206
 
                                }
207
 
                        /* Symbols produced with a key combination
208
 
                           including Shift Key */
209
 
                        for ( ; index < DOWNCHAR + UPCHAR; index++)
210
 
                                if (*keyval == Symbol_Key_Synth_Vals[index].sym) {
211
 
                                        return_val.shift = TRUE;
212
 
                                        return_val.capslck = FALSE;
213
 
                                        return_val.non_print_key = FALSE;
214
 
                                        return_val.value = Symbol_Key_Synth_Vals[index].KeyVal;
215
 
                                        return return_val;
216
 
                                }
217
 
                }
218
 
        } else {
219
 
                /* This is for identifying non printing keys like numlock,
220
 
                   capslock, etc */
221
 
                for (index = 0; NonPrint_Key_Synth_Vals[index].sym; index++)
222
 
                        if (g_ascii_strcasecmp (NonPrint_Key_Synth_Vals[index].sym,
223
 
                                                keyval) == 0) {
224
 
                                return_val.shift = FALSE;
225
 
                                return_val.capslck = FALSE;
226
 
                                return_val.non_print_key = TRUE;
227
 
                                return_val.value = NonPrint_Key_Synth_Vals[index].KeyVal;
228
 
                                return return_val;
229
 
                        }
230
 
        }
231
 
     
232
 
        /* Key Undefined */
233
 
        return_val.shift = FALSE;
234
 
        return_val.capslck = FALSE;
235
 
        return_val.non_print_key = FALSE;
236
 
        return_val.value = UNDEFINED_KEY;
237
 
        return return_val;
238
 
}
239
 
 
240
 
static LDTPErrorCode
241
 
get_keyval_id (gchar *input_string, struct KeyValue *keyvals)
242
 
{
243
 
        struct KeyValue key_val;
244
 
        gint index = 0;
245
 
        gint keyval_index = 0;
246
 
        gchar token[MAX_TOK_SIZE + 1];
247
 
 
248
 
        while (*input_string && keyval_index < MAX_TOKENS) {
249
 
                index = 0;
250
 
                if (*input_string == '<') {
251
 
                        /* Identified a Non Printing Key */
252
 
                        input_string++;
253
 
                        while (*input_string != '>' && *input_string != '\0' && index < MAX_TOK_SIZE) {
254
 
                                token[index] = *input_string;
255
 
                                input_string++;
256
 
                                index++;
257
 
                        }
258
 
                        if (*input_string != '>') {
259
 
                                /* Premature end of string without an opening '<' */
260
 
                                g_print ("ERROR:: premature EOS\n");
261
 
                                return LDTP_ERROR_INVALID_FORMAT;
262
 
                        }
263
 
                } else {
264
 
                        token[index] = *input_string;
265
 
                        index++;
266
 
                }
267
 
                input_string++;
268
 
                token[index] = '\0';
269
 
 
270
 
                key_val = get_key_value (token);
271
 
                if (key_val.value == UNDEFINED_KEY) {
272
 
                        g_print ("Invalid Key\n");
273
 
                        return LDTP_ERROR_TOKEN_NOT_FOUND;
274
 
                }
275
 
                g_print ("KEY_ID :: %d\n",key_val.value);
276
 
                keyvals[keyval_index] = key_val;
277
 
                keyval_index++;
278
 
        }
279
 
        if (keyval_index == MAX_TOKENS) {
280
 
                g_print ("ERROR :: Too many tokens\n");
281
 
                return LDTP_ERROR_INVALID_FORMAT;
282
 
        }
283
 
        keyvals [keyval_index].value = UNDEFINED_KEY; /* End Delimiter */
284
 
        return LDTP_ERROR_SUCCESS;
285
 
}
286
 
 
287
 
static LDTPErrorCode
288
 
press_key (char *input_string, FILE *log_fp)
289
 
{
290
 
        LDTPErrorCode error;
291
 
        struct KeyValue keyval[MAX_TOKENS+1];
292
 
        gint index;
293
 
        SPIBoolean flag;
294
 
 
295
 
        error = get_keyval_id (input_string,  keyval);
296
 
        if (error != LDTP_ERROR_SUCCESS) {
297
 
                goto error;
298
 
        }
299
 
 
300
 
        for (index=0; keyval[index].value != UNDEFINED_KEY && index < MAX_TOKENS;index++) {
301
 
                g_print ("Generating Key Board Value: %d\n", keyval [index].value);
302
 
                flag = SPI_generateKeyboardEvent (keyval [index].value, NULL, SPI_KEY_PRESS);
303
 
                if (flag == FALSE) {
304
 
                        error = LDTP_ERROR_UNABLE_TO_ENTER_KEY;
305
 
                        goto error;
306
 
                }
307
 
        }
308
 
        return error;
309
 
 error:
310
 
        log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
311
 
        return error;
312
 
}
313
 
 
314
 
static LDTPErrorCode
315
 
release_key (char *input_string, FILE *log_fp)
316
 
{
317
 
        LDTPErrorCode error;
318
 
        struct KeyValue keyval[MAX_TOKENS+1];
319
 
        gint index;
320
 
        SPIBoolean flag;
321
 
 
322
 
        error = get_keyval_id (input_string,  keyval);
323
 
        if (error != LDTP_ERROR_SUCCESS) {
324
 
                goto error;
325
 
        }
326
 
 
327
 
        for (index=0; keyval[index].value != UNDEFINED_KEY && index < MAX_TOKENS;index++) {
328
 
                g_print ("Generating Key Board Value: %d\n", keyval [index].value);
329
 
                flag = SPI_generateKeyboardEvent (keyval [index].value, NULL, SPI_KEY_RELEASE);
330
 
                if (flag == FALSE) {
331
 
                        error = LDTP_ERROR_UNABLE_TO_ENTER_KEY;
332
 
                        goto error;
333
 
                }
334
 
        }
335
 
        return error;
336
 
 error:
337
 
        log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
338
 
        return error;
339
 
}
340
 
 
341
 
static LDTPErrorCode
342
 
generate_keyboard_sequence (char *input_string, FILE *log_fp)
343
 
{
344
 
        LDTPErrorCode error;
345
 
        AccessibleKeySynthType type = SPI_KEY_PRESS;
346
 
        struct KeyValue keyval[MAX_TOKENS+1];
347
 
        gint index, history_index;
348
 
        SPIBoolean flag;
349
 
 
350
 
        error = get_keyval_id (input_string,  keyval);
351
 
        if (error != LDTP_ERROR_SUCCESS) {
352
 
                goto error;
353
 
        }
354
 
 
355
 
        for (index=0; keyval[index].value != UNDEFINED_KEY && index < MAX_TOKENS;index++) {
356
 
                g_print ("Generating Key Board Value: %d\n",keyval[index].value);
357
 
                if (keyval[index].non_print_key == TRUE)
358
 
                        type = SPI_KEY_PRESS;
359
 
                else
360
 
                        type = SPI_KEY_PRESSRELEASE;
361
 
                if (keyval[index].shift == 1)
362
 
                        SPI_generateKeyboardEvent (50, NULL, SPI_KEY_PRESS); // press shift
363
 
                if (keyval[index].capslck == 1) {
364
 
                        SPI_generateKeyboardEvent (66, NULL, SPI_KEY_PRESS); // press capslck
365
 
                        SPI_generateKeyboardEvent (66, NULL, SPI_KEY_RELEASE); // release capslck
366
 
                }
367
 
                flag = SPI_generateKeyboardEvent (keyval[index].value, NULL, type);
368
 
                if (keyval[index].shift == 1)
369
 
                        SPI_generateKeyboardEvent (50, NULL, SPI_KEY_RELEASE); // release shift
370
 
                if (keyval[index].capslck == 1) {
371
 
                        SPI_generateKeyboardEvent (66, NULL, SPI_KEY_PRESS); // press capslck
372
 
                        SPI_generateKeyboardEvent (66, NULL, SPI_KEY_RELEASE); // release capslck
373
 
                }
374
 
                if (flag == FALSE) {
375
 
                        error = LDTP_ERROR_UNABLE_TO_ENTER_KEY;
376
 
                        goto error;
377
 
                }
378
 
                if (keyval[index].non_print_key == FALSE) {
379
 
                        history_index = index;
380
 
                        type = SPI_KEY_RELEASE;
381
 
                        while (index--) {
382
 
                                if (keyval[index].non_print_key == FALSE)
383
 
                                        break;
384
 
                                g_print ("Releasing: %d\n", keyval [index].value);
385
 
                                flag = SPI_generateKeyboardEvent (keyval [index].value, NULL, type);
386
 
                                if (flag == FALSE) {
387
 
                                        error = LDTP_ERROR_UNABLE_TO_ENTER_KEY;
388
 
                                        goto error;
389
 
                                }
390
 
                        }
391
 
                        index = history_index;
392
 
                }
393
 
        }
394
 
        type = SPI_KEY_RELEASE;
395
 
        while (index--) {
396
 
                if (keyval[index].non_print_key == FALSE)
397
 
                        break;
398
 
                g_print ("Releasing: %d\n", keyval [index].value);
399
 
                flag = SPI_generateKeyboardEvent (keyval [index].value, NULL, type);
400
 
                if (flag == FALSE) {
401
 
                        error = LDTP_ERROR_UNABLE_TO_ENTER_KEY;
402
 
                        goto error;
403
 
                }
404
 
        }
405
 
        return error;
406
 
 error:
407
 
        log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
408
 
        return error;
409
 
}
410
 
 
411
 
LDTPErrorCode
412
 
device_main (LDTPClientContext* cctxt, int command)
413
 
{
414
 
        LDTPErrorCode error;
415
 
        switch (command) {
416
 
        case LDTP_CMD_MOUSELEFTCLICK:
417
 
                error = mouse_left_click (cctxt->gui_handle->handle, cctxt->log_fp);
418
 
                break;
419
 
        case LDTP_CMD_MOUSERIGHTCLICK:
420
 
                error = mouse_right_click (cctxt->gui_handle->handle, cctxt->log_fp);
421
 
                break;
422
 
        case LDTP_CMD_MOUSEMOVE:
423
 
                error = mouse_move (cctxt->gui_handle->handle, cctxt->log_fp);
424
 
                break;
425
 
        case LDTP_CMD_KBDENTER:
426
 
                error = grab_focus (cctxt->gui_handle->handle, cctxt->log_fp);
427
 
                if (error != LDTP_ERROR_SUCCESS)
428
 
                        return error;
429
 
                error = generate_keyboard_sequence (cctxt->req->arg_list->data, cctxt->log_fp);
430
 
                break;
431
 
        case LDTP_CMD_GENERATEKEYEVENT:
432
 
                error = generate_keyboard_sequence (cctxt->req->context, cctxt->log_fp);
433
 
                break;
434
 
        case LDTP_CMD_KEYPRESS:
435
 
                error = press_key (cctxt->req->context, cctxt->log_fp);
436
 
                break;
437
 
        case LDTP_CMD_KEYRELEASE:
438
 
                error = release_key (cctxt->req->context, cctxt->log_fp);
439
 
                break;
440
 
        default:
441
 
                error = LDTP_ERROR_COMMAND_NOT_IMPLEMENTED;
442
 
        }
443
 
        return error;
444
 
}
445
 
 
446
 
void
447
 
get_keyboard_keycodes() {
448
 
        FILE *fd;
449
 
        size_t readed;
450
 
        char *src;
451
 
        //char *keycode_symbol_start;
452
 
        int keycode;
453
 
        gchar **lines;
454
 
        gchar *line;
455
 
        int i, status;
456
 
        int index = 0;
457
 
 
458
 
        struct NonPrint_Key_Synth old_NonPrint_Key_Synth_Vals[] = {{"escape", 9}, {"esc", 9}, {"backspace", 22},
459
 
                                                                   {"bksp", 22}, {"ctrl", 37}, {"windowskey", 115},
460
 
                                                                   {"tab", 23}, {"return", 36}, {"enter", 36},
461
 
                                                                   {"shift", 50}, {"shiftl", 50}, {"shiftr", 62},
462
 
                                                                   {"home", 97}, {"end", 103}, {"window", 115},
463
 
                                                                   {"alt", 64}, {"altl", 64}, {"altr", 113},
464
 
                                                                   {"up", 98}, {"down", 104}, {"right", 102},
465
 
                                                                   {"left", 100}, {"space", 65}, {"capslock", 66},
466
 
                                                                   {"caps", 66}, {"menu", 117}, {"ins", 106},
467
 
                                                                   {"del", 107}, {"insert", 106}, {"delete", 107},
468
 
                                                                   {"pageup", 99}, {"pagedown", 105}, {"pgup", 99},
469
 
                                                                   {"pgdown", 105}, {"numlock", 77}, {"scrolllock", 78},
470
 
                                                                   {"F1", 67}, {"F2", 68}, {"F3", 69}, {"F4", 70},
471
 
                                                                   {"F5", 71}, {"F6", 72}, {"F7", 73}, {"F8", 74},
472
 
                                                                   {"F9", 75}, {"F10", 76}, {"F11", 95}, {"F12", 96},
473
 
                                                                   {"prtscrn", 111}};
474
 
 
475
 
 
476
 
        src = (char *) malloc(sizeof(char) * 100);
477
 
        readed = 0;
478
 
 
479
 
        fd = popen("xmodmap -pke 2>/dev/null", "r");
480
 
 
481
 
        while ( ! feof(fd)) {
482
 
                readed += fread(src + readed, 1, 100, fd);
483
 
                src = (char *) realloc(src, sizeof(char)*(readed+100));
484
 
        }
485
 
 
486
 
        status = pclose(fd);
487
 
 
488
 
        if (status != -1) {
489
 
                lines = g_strsplit(src, "\n", 0);
490
 
 
491
 
                for (index=0; lines != NULL && strcmp(*lines, ""); lines++) {
492
 
                        gchar **split;
493
 
                        line = *lines;
494
 
 
495
 
                        split = g_strsplit(line, "=", 2);
496
 
                        keycode = atoi(split[0] + 7);
497
 
 
498
 
                        if (strlen(split[1]) > 0) {
499
 
                                gchar **space_split = g_strsplit(split[1], " ", 3);
500
 
                                NonPrint_Key_Synth_Vals[index].sym    = space_split[1];
501
 
                                NonPrint_Key_Synth_Vals[index].KeyVal = keycode;
502
 
                                index++;
503
 
                        }
504
 
                }
505
 
        } else if (src) {
506
 
                g_free (src);
507
 
                src = NULL;
508
 
        }
509
 
 
510
 
        int old_len = sizeof(old_NonPrint_Key_Synth_Vals) / sizeof(struct NonPrint_Key_Synth);
511
 
 
512
 
        for(i = 0 ; index < 300 && i < old_len; index++, i++)
513
 
                NonPrint_Key_Synth_Vals[index] = old_NonPrint_Key_Synth_Vals[i];
514
 
 
515
 
        NonPrint_Key_Synth_Vals[index].sym    = NULL;
516
 
        NonPrint_Key_Synth_Vals[index].KeyVal = 0;
517
 
 
518
 
        return;
519
 
}