mouseevent - Simulate mouse motion on linux wayland -
i receive xy data network , control mouse position using linux on wayland.
i've seen many source codes using x libs or x apps not work on wayland. have on libinput , evedev don't find code sample how create/simulate mouse.
uinput answer.
void initmouse(){ fd = open("/dev/uinput", o_wronly | o_nonblock); ioctl(fd, ui_set_evbit, ev_key); ioctl(fd, ui_set_keybit, btn_left); ioctl(fd, ui_set_evbit, ev_abs); ioctl(fd, ui_set_absbit, abs_x); ioctl(fd, ui_set_absbit, abs_y); struct uinput_user_dev uidev; memset(&uidev,0,sizeof(uidev)); snprintf(uidev.name,uinput_max_name_size,"holusionmouse"); uidev.id.bustype = bus_usb; uidev.id.version = 1; uidev.id.vendor = 0x1; uidev.id.product = 0x1; uidev.absmin[abs_x] = 0; uidev.absmax[abs_x] = 1080; uidev.absmin[abs_y] = 0; uidev.absmax[abs_y] = 1080; write(fd, &uidev, sizeof(uidev)); ioctl(fd, ui_dev_create); usleep(100000); }
and update:
struct input_event ev[2], evs; memset(ev, 0, sizeof(ev )); ev[0].type = ev_abs; ev[0].code = abs_x; ev[0].value = 100; ev[1].type = ev_abs; ev[1].code = abs_y; ev[1].value = 100; write(fd, ev, sizeof(ev)); memset(&evs,0,sizeof(struct input_event)); evs.type = ev_syn; write(fd, &evs, sizeof(struct input_event)); usleep(10000);
Comments
Post a Comment