友善三星2440的buttons_test程序,里面是这样的
for (;;) {
char current_buttons[3];
int count_of_changed_key;
int i;
if (read(buttons_fd, current_buttons, sizeof current_buttons) != sizeof current_buttons) {
perror("read buttons:");
exit(1);
}
for (i = 0, count_of_changed_key = 0; i < sizeof buttons / sizeof buttons[0]; i++) {
if (buttons != current_buttons) {
buttons = current_buttons;
printf("%skey %d is %s", count_of_changed_key? ", ": "", i+1, buttons == '0' ? "up" : "down");
count_of_changed_key++;
}
}
if (count_of_changed_key) {
printf("\n");
}
printf("ok\n"); //这是我添加的,为什么不是一直打印OK?????
}
只打印了一次,然后按键才打印一次???不是死循环来的吗?