21,595
社区成员
发帖
与我相关
我的任务
分享
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <linux/input.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int fd, version, ret;
struct input_event event;
struct timeval time;
if ((fd = open("/dev/input/event0", O_RDWR)) < 0) {
perror("beep test");
return 1;
}
event.type = EV_SND;
event.code = SND_BELL;
event.value = 2000;
time.tv_sec = 1;
time.tv_usec = 0;
event.time = time;
ret = write(fd, &event, sizeof(struct input_event));
close(fd);
}
int fd, version, ret;
struct input_event event;
struct timeval time;
if ((fd = open("/dev/input/event0", O_RDWR)) < 0) {
perror("beep test");
return 1;
}
if (ioctl(fd, EVIOCGVERSION, &version)) {
perror("beep test, can't get version");
return 1;
}
printf("Input driver version is %d.%d.%d\n",
version >> 16, (version >> 8) & 0xff, version & 0xff);
event.type = EV_SND;
event.code = SND_BELL;
event.value = 2000;
time.tv_sec = 1;
time.tv_usec = 0;
event.time = time;
ret = write(fd, &event, sizeof(struct input_event));