我正在尝试使用功能XKeysymToKeycode将击键发送到活动的x11应用程序。 该功能有效,但使用的是英文键盘。 我的电脑本地化为意大利语。现在,我必须发送例如意大利语键盘中定义的字符“à”。 我该怎么做才能发送?
答案 0 :(得分:0)
我一直在努力解决同一问题。似乎是:
您可以手动as the clutter guys did完成工作。或结合使用gdk和X:
//char *oksym ="KP_Enter";
char *oksym ="at";
gboolean orv;
guint okeyval;
GdkKeymapKey *okeys;
gint on_keys;
GdkKeymap *okeymap;
GdkDisplay *odisplay;
XkbGetState(display, XkbUseCoreKbd, &xkbState);
printf("Active group would be %d\n",xkbState.group);
odisplay = gdk_display_get_default();
okeymap = gdk_keymap_get_for_display(odisplay);
okeyval = gdk_keyval_from_name(oksym);
if(okeyval == GDK_KEY_VoidSymbol){
printf("GDK keyval GDK_KEY_%s is unknown\n",oksym);
exit(-1);
}
orv = gdk_keymap_get_entries_for_keyval(okeymap, okeyval, &okeys, &on_keys);
printf("The following hardware keys will produce keyval GDK_KEY_%s(%d):\n",oksym,okeyval);
for(int i = 0; i < on_keys; i++){
/*Groups seems to be used to manage multiple keyboard layouts (at least using MATE)
* instead/on top of their orignal meaning. Getting the active layout seems to be
* acheivable using XkbGetState. Some keys seems to be shared/stay on group 0, example
* Return/Enter. So if there is more than one key bound to a keyval, we'll take the one
* that matches the active group. If there is only one (i.e Enter/Return) we'll just take
* it regardless of its group.
* */
if( okeys[i].group == xkbState.group || on_keys == 1)
printf("\tkeycode: %d, group: %d, level: %d\n",okeys[i].keycode,okeys[i].group,okeys[i].level);
}