Enlightenment CVS committal Author : raster Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_x Modified Files: Ecore_X.h ecore_x_test.c Log Message: add some more calls needed for better key faking =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/Ecore_X.h,v retrieving revision 1.200 retrieving revision 1.201 diff -u -3 -r1.200 -r1.201 --- Ecore_X.h 9 Jul 2008 15:18:55 -0000 1.200 +++ Ecore_X.h 16 Jul 2008 17:05:31 -0000 1.201 @@ -1701,7 +1701,9 @@ EAPI int ecore_x_test_fake_key_down(const char *key); EAPI int ecore_x_test_fake_key_up(const char *key); - +EAPI int ecore_x_test_fake_key_press(const char *key); +EAPI const char *ecore_x_keysym_string_get(int keysym); + #ifdef __cplusplus } #endif =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/ecore_x_test.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ecore_x_test.c 28 Mar 2008 14:38:35 -0000 1.1 +++ ecore_x_test.c 16 Jul 2008 17:05:31 -0000 1.2 @@ -5,6 +5,7 @@ #include "ecore_x_private.h" #include "Ecore_X.h" + EAPI int ecore_x_test_fake_key_down(const char *key) { @@ -18,7 +19,7 @@ { keysym = XStringToKeysym(key); if (keysym == NoSymbol) return 0; - keycode = XKeysymToKeycode(_ecore_x_disp, XStringToKeysym(key)); + keycode = XKeysymToKeycode(_ecore_x_disp, keysym); } if (keycode == 0) return 0; return XTestFakeKeyEvent(_ecore_x_disp, keycode, 1, 0); @@ -40,11 +41,76 @@ { keysym = XStringToKeysym(key); if (keysym == NoSymbol) return 0; - keycode = XKeysymToKeycode(_ecore_x_disp, XStringToKeysym(key)); + keycode = XKeysymToKeycode(_ecore_x_disp, keysym); } if (keycode == 0) return 0; return XTestFakeKeyEvent(_ecore_x_disp, keycode, 0, 0); #else return 0; #endif +} + +EAPI int +ecore_x_test_fake_key_press(const char *key) +{ +#ifdef ECORE_XTEST + KeyCode keycode = 0; + KeySym keysym = 0; + int shift = 0; + + if (!strncmp(key, "Keycode-", 8)) + keycode = atoi(key + 8); + else + { + keysym = XStringToKeysym(key); + if (keysym == NoSymbol) return 0; + keycode = XKeysymToKeycode(_ecore_x_disp, keysym); + if (XKeycodeToKeysym(_ecore_x_disp, keycode, 0) != keysym) + { + if (XKeycodeToKeysym(_ecore_x_disp, keycode, 1) == keysym) + shift = 1; + else + keycode = 0; + } + else + shift = 0; + } + if (keycode == 0) + { + static int mod; + static KeySym *keysyms; + static int keycode_min, keycode_max, keycode_num; + int i; + + XDisplayKeycodes(_ecore_x_disp, &keycode_min, &keycode_max); + keysyms = XGetKeyboardMapping(_ecore_x_disp, keycode_min, + keycode_max - keycode_min + 1, + &keycode_num); + mod = (mod + 1) & 0x7; + i = (keycode_max - keycode_min - mod - 1) * keycode_num; + + keysyms[i] = keysym; + XChangeKeyboardMapping(_ecore_x_disp, keycode_min, keycode_num, + keysyms, (keycode_max - keycode_min)); + XSync(_ecore_x_disp, False); + keycode = keycode_max - mod - 1; + } + if (shift) + XTestFakeKeyEvent(_ecore_x_disp, + XKeysymToKeycode(_ecore_x_disp, XK_Shift_L), 1, 0); + XTestFakeKeyEvent(_ecore_x_disp, keycode, 1, 0); + XTestFakeKeyEvent(_ecore_x_disp, keycode, 0, 0); + if (shift) + XTestFakeKeyEvent(_ecore_x_disp, + XKeysymToKeycode(_ecore_x_disp, XK_Shift_L), 0, 0); + return 1; +#else + return 0; +#endif +} + +EAPI const char * +ecore_x_keysym_string_get(int keysym) +{ + return XKeysymToString(keysym); } ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs