#include #include #include #include #include #include #include void send_mouse_event(int fd, int type, int code, int value) { struct input_event ev; memset(&ev, 0, sizeof(ev)); ev.type = type; ev.code = code; ev.value = value; write(fd, &ev, sizeof(ev)); } int create_virtual_mouse() { int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK); if (fd < 0) { perror("uinput"); exit(1); } ioctl(fd, UI_SET_EVBIT, EV_REL); ioctl(fd, UI_SET_RELBIT, REL_X); ioctl(fd, UI_SET_RELBIT, REL_Y); ioctl(fd, UI_SET_RELBIT, REL_WHEEL); ioctl(fd, UI_SET_RELBIT, REL_HWHEEL); ioctl(fd, UI_SET_EVBIT, EV_KEY); ioctl(fd, UI_SET_KEYBIT, BTN_LEFT); ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT); ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE); ioctl(fd, UI_SET_EVBIT, EV_REL); struct uinput_setup setup; memset(&setup, 0, sizeof(setup)); setup.id.bustype = BUS_USB; setup.id.vendor = 0x1234; setup.id.product = 0x5678; strcpy(setup.name, "Virtual Keyboard Mouse"); ioctl(fd, UI_DEV_SETUP, &setup); ioctl(fd, UI_DEV_CREATE); printf("Virtual mouse created\n"); return fd; }