死键的问题(急性,分音符等)c ++ [英] problem with dead keys (acute, diaeresis, etc) c++

查看:25
本文介绍了死键的问题(急性,分音符等)c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 X11 库为 linux 编写自己的虚拟键盘,但我找不到模拟任何死键的 KeyPress 事件的方法.例如,我曾尝试使用指定的宏(即 XK_aacute)编写á",但没有任何反应.后来我尝试发送 XK_acute(重音宏),然后发送 XK_a,再次,没有任何反应:(

I'm currently writing my own virtual keyboard for linux using the X11 lib and i just can't find the way to simulate a KeyPress event of any dead keys. I'd tried , for example, to write "á" using the asigned macro, which is XK_aacute, and nothing happens. later i'd tried to send XK_acute (the acute accent macro) and then XK_a, and again, nothing happens :(

在 KDE 虚拟键盘Kvkbd"中可以做到这一点,所以我下载了源代码,但它只支持英文键盘布局

In the KDE virtual Keyboard "Kvkbd" it's possible to do this, so i downloaded the source code, but it only supports the english keyboard layout

这是我的测试代码:

#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/extensions/XTest.h>
#include <iostream>

int main(){
 Display *display;
 unsigned int keycode;
 unsigned int keycode1;
 display = XOpenDisplay(NULL);

 keycode = XKeysymToKeycode(display, XK_aacute); 
 XTestFakeKeyEvent(display, keycode, True, 0);
 XTestFakeKeyEvent(display, keycode, False, 0);

 keycode1 = XKeysymToKeycode(display, XK_acute);
 XTestFakeKeyEvent(display, keycode1, True, 0);


 keycode = XKeysymToKeycode(display, XK_a);
 XTestFakeKeyEvent(display, keycode, True, 0);
 XTestFakeKeyEvent(display, keycode, False, 0);

 XTestFakeKeyEvent(display, keycode1, False, 0);


 keycode = XKeysymToKeycode(display, XK_D);
 XTestFakeKeyEvent(display, keycode, True, 0);
 XTestFakeKeyEvent(display, keycode, False, 0);
 XFlush(display);
}

任何帮助或想法将不胜感激

Any help or idea will be much apreciated

推荐答案

我刚刚发现 ¬¬

#include <X11/extensions/XTest.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <iostream>

int main(){
 Display *display;
 unsigned int keycode;
 unsigned int keycode1;
 display = XOpenDisplay(NULL);

 keycode1 = XKeysymToKeycode(display, XK_dead_acute);
 XTestFakeKeyEvent(display, keycode1, true, 0);


 keycode = XKeysymToKeycode(display, XK_A);
 XTestFakeKeyEvent(display, keycode, true, 0);
 XTestFakeKeyEvent(display, keycode, false, 0);

 XTestFakeKeyEvent(display, keycode1, false, 0);

 XFlush(display);
}

我使用了错误的宏

这篇关于死键的问题(急性,分音符等)c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆