Unix & Linux Asked by Az ayd on February 21, 2021
Using this short snipped of code I am able to capture events from the keyboard (/dev/input/event1) and print them properly. However, sending them to the Xvfb display using XTestFakeKeyEvent does not work even if XTestFakeKeyEvent returns successful.
char devname[] = "/dev/input/event1";
int device = open(devname, O_RDONLY);
struct input_event ev;
signal(SIGINT, INThandler);
Display *dpy = XOpenDisplay(NULL);
if (!dpy) {fprintf(stderr, "unable to connect to display");return 7;}
while(1)
{
read(device,&ev, sizeof(ev));
printf("Key: %i State: %in",ev.code,ev.value);
if(ev.code!=4)
if(!(XTestFakeKeyEvent(dpy, ev.code, ev.value, 0)))
{fprintf(stderr, "unable to send keystroken");return 7;};
}
I thought the problem was with the compatibility between Xvfb and XTestFakeKeyEvent but I am able to send keystrokes to the display using the xdotool program in the shell, which uses XTestFakeKeyEvent. It’s possible that I’m doing this wrong, I’m not familiar with X11 programming. Thank you in advance.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP