Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <linux/uinput.h>
- #include <string.h>
- void Akey(int fd, struct uinput_user_dev uidev){
- int dtime=200000; //in ms
- //A hold D*3 L K J* 2 K L relese A
- // 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));
- /////////////D1///////////////////////
- event.type = EV_KEY;
- event.code = KEY_D;
- 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(dtime/2);
- event.type = EV_KEY;
- event.code = KEY_D;
- 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));
- usleep(dtime/2);
- ///////////D1////////////////
- /////////////D2///////////////////////
- event.type = EV_KEY;
- event.code = KEY_D;
- 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(dtime/2);
- event.type = EV_KEY;
- event.code = KEY_D;
- 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));
- usleep(dtime/2);
- ///////////D2////////////////////
- /////////D3///////////////////////
- event.type = EV_KEY;
- event.code = KEY_D;
- 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(dtime/2);
- event.type = EV_KEY;
- event.code = KEY_D;
- 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));
- usleep(dtime/2);
- ///////////D3////////////////
- /////////////L///////////////////////
- event.type = EV_KEY;
- event.code = KEY_L;
- 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(dtime);
- event.type = EV_KEY;
- event.code = KEY_L;
- 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));
- usleep(dtime);
- ///////////L////////////////
- /////////////K///////////////////////
- event.type = EV_KEY;
- event.code = KEY_K;
- 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(dtime);
- event.type = EV_KEY;
- event.code = KEY_K;
- 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));
- usleep(dtime);
- ///////////K////////////////
- /////////////J///////////////////////
- event.type = EV_KEY;
- event.code = KEY_J;
- 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(dtime);
- event.type = EV_KEY;
- event.code = KEY_J;
- 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));
- usleep(dtime*2);
- ///////////J////////////////
- /////////////J///////////////////////
- event.type = EV_KEY;
- event.code = KEY_J;
- 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(dtime);
- event.type = EV_KEY;
- event.code = KEY_J;
- 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));
- usleep(dtime*2);
- ///////////J////////////////
- /////////////K///////////////////////
- event.type = EV_KEY;
- event.code = KEY_K;
- 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(dtime);
- event.type = EV_KEY;
- event.code = KEY_K;
- 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));
- usleep(dtime*2);
- ///////////K////////////////
- /////////////L///////////////////////
- event.type = EV_KEY;
- event.code = KEY_L;
- 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(dtime);
- event.type = EV_KEY;
- event.code = KEY_L;
- 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));
- usleep(dtime);
- ///////////L////////////////
- 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
- // 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);
- // 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);
- }
- // system("helm");
- Akey(fd, uidev);
- ioctl(fd, UI_DEV_DESTROY);
- close(fd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement