egrep "^(N|H)" /proc/bus/input/devices
/ dev / input / event5
était le clavier.ls -lh /dev/input/event5
crw-rw---- 1 root input 13,69 24 août 18:33 /dev/input/event5
write.c
#include <stdio.h>
#include <stdlib.h>
#include <linux/input.h>
#include <sys/time.h>
void write_key_event(int code, int value, int fd)
{
struct input_event key_event;
gettimeofday(&key_event.time, NULL);
key_event.type = EV_KEY;
key_event.code = code;
key_event.value = value;
write(fd, &key_event, sizeof(key_event));
}
int main(void)
{
write_key_event(KEY_ESC, 1, 1);
write_key_event(KEY_ESC, 0, 1);
//int i = 0;
//int keys[] = { KEY_A ,KEY_B ,KEY_C };
//while (keys[i] != '\0' ) {
// write_key_event(keys[i], 1, 1);
// write_key_event(keys[i], 0, 1);
// i++;
//}
//i = 0;
//write_key_event(KEY_LEFTSHIFT, 1, 1);
//while (keys[i] != '\0' ) {
// write_key_event(keys[i], 1, 1);
// write_key_event(keys[i], 0, 1);
// i++;
//}
//write_key_event(KEY_LEFTSHIFT, 0, 1);
exit(EXIT_SUCCESS);
}
gcc -o write.o write.c
./write.o > /dev/input/event5
Recommended Posts