#include #include #include #include #include #include #include int main(int argn, char *argv[]) { struct uinput_user_dev device; struct input_event event; int fd, cnt = 0; unsigned char aux; char buff[80]; /* open uinput device file */ fd = open("/dev/input/uinput", O_RDWR); if (fd < 0) { perror("open"); return fd; } /* sets the name of our device */ strcpy(device.name, "test keyboard"); /* inform that we'll generate key events */ ioctl(fd, UI_SET_EVBIT, EV_KEY); /* set key events we can generate (in this case, all) */ for (aux = 1; aux < 207; cnt ++) ioctl(fd, UI_SET_KEYBIT, cnt); exit(0); /* write down information for creating a new device */ if (write(fd, &device, sizeof(struct uinput_user_dev)) < 0) { perror("write"); close(fd); return 1; } /* actually creates the device */ ioctl(fd, UI_DEV_CREATE); close(fd); return 0; }