死键问题(急性、分音符等)c++
我目前正在使用 X11 库为 Linux 编写自己的虚拟键盘,但我找不到模拟任何死键的 KeyPress 事件的方法。 例如,我尝试使用指定的宏(XK_aacute)编写“á”,但没有任何反应。 后来我尝试发送 XK_acute (急性重音宏),然后发送 XK_a,然后再次没有任何反应:(
在 KDE 虚拟键盘“Kvkbd”中可以做到这一点,所以我下载了源代码,但它只支持英语键盘布局
这是我的测试代码:
#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);
}
任何帮助或想法将不胜感激
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 :(
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
Here is my test code:
#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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚发现 ØØ
我使用了错误的宏
i just figured out ¬¬
i was using the wrong macro