键值从键盘到Linux内核传输过程分析

#include <stdio.h>

#include <stdlib.h>

#include <fcntl.h>

#include <linux/input.h>

#include <sys/ioctl.h>

#ifndef EVIOCSREP

#define EVIOCSREP _IOW(‘E’, 0x03,int[2])

#endif

int main(int argc,char** argv) {

int fd = 0;

int rep[2] = {0};

if ((fd =open("/dev/input/event4",

O_RDWR))< 0) {

perror("unableto access /dev/input/event2, exiting");

exit(1);

}

// get current auto-repeat args.

if (ioctl(fd,EVIOCGREP, rep)) {

perror("unableto set delay and repeat rate for input devices");

exit(1);

}

rep[1] =0; // set auto-repeat rate as 0.

if (ioctl(fd,EVIOCSREP, rep)) {

perror("unableto set delay and repeat rate for input devices");

exit(1);

}

printf("rep[0]:%d;rep[1]:%d\n", rep[0], rep[1]);

close(fd);

}

同生天地间,为何我不能。

键值从键盘到Linux内核传输过程分析

相关文章:

你感兴趣的文章:

标签云: