#include #include #include #include #include #include void Akey(int fd){ //A hold D*3 L K J* 2 K L relese A // Create the virtual input device struct uinput_user_dev uidev; memset(&uidev, 0, sizeof(uidev)); strncpy(uidev.name, "Virtual Keyboard", UINPUT_MAX_NAME_SIZE); uidev.id.bustype = BUS_VIRTUAL; uidev.id.vendor = 0x1234; uidev.id.product = 0x5678; uidev.id.version = 1; write(fd, &uidev, sizeof(uidev)); ioctl(fd, UI_DEV_CREATE); // Simulate pressing and releasing the 'A' key struct input_event event; memset(&event, 0, sizeof(event)); event.type = EV_KEY; event.code = KEY_A; event.value = 1; // Pressing the key write(fd, &event, sizeof(event)); event.type = EV_SYN; event.code = SYN_REPORT; event.value = 0; write(fd, &event, sizeof(event)); usleep(200000); // Delay in microseconds event.type = EV_KEY; event.code = KEY_A; event.value = 0; // Releasing the key write(fd, &event, sizeof(event)); event.type = EV_SYN; event.code = SYN_REPORT; event.value = 0; write(fd, &event, sizeof(event)); } int main() { sleep(5); // gimme a sec to start this sht int fd = open("/dev/input/by-path/platform-i8042-serio-0-event-kbd", O_WRONLY | O_NONBLOCK); if (fd < 0) { perror("Failed to open /dev/input/by-path/platform-i8042-serio-0-event-kbd"); return 1; } //system("helm"); //A hold D*3 L K J* 2 K L relese A // Enable keyboard events ioctl(fd, UI_SET_EVBIT, EV_KEY); for (int keycode = KEY_ESC; keycode <= KEY_SLASH; keycode++) { ioctl(fd, UI_SET_KEYBIT, keycode); } Akey(fd); ioctl(fd, UI_DEV_DESTROY); close(fd); return 0; }