}
name[sizeof(name) - 1] = '\0';
if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
- ALOGE("could not get device name for %s, %s\n", name, strerror(errno));
+ ALOGE("could not get device name for %s, %s", name, strerror(errno));
name[0] = '\0';
}
// TODO: parse /etc/excluded-input-devices.xml
if (!strcmp(name, "Power Button")) {
- ALOGI("open %s(%s) ok", de->d_name, name);
+ ALOGI("open %s(%s) ok fd=%d", de->d_name, name, fd);
pfds[cnt].events = POLLIN;
pfds[cnt++].fd = fd;
if (cnt < MAX_POWERBTNS)
struct pollfd pfds[MAX_POWERBTNS];
int cnt = openfds(pfds);
int timeout = -1;
+ int longpress = 1;
char prop[PROPERTY_VALUE_MAX];
int ufd = open("/dev/uinput", O_WRONLY | O_NDELAY);
ALOGE("poll error: %s", strerror(errno));
break;
}
- if (pollres == 0) { // timeout, send one power key
+ if (pollres == 0) {
+ ALOGI("timeout, send one power key");
simulate_powerkey(ufd, 0);
timeout = -1;
+ longpress = 1;
continue;
}
for (i = 0; i < cnt; ++i) {
ALOGW("insufficient input data(%d)? fd=%d", res, pfds[i].fd);
continue;
}
- ALOGV("type=%d scancode=%d value=%d from fd=%d", iev.type, iev.code, iev.value, pfds[i].fd);
+ ALOGD("type=%d scancode=%d value=%d from fd=%d", iev.type, iev.code, iev.value, pfds[i].fd);
if (iev.type == EV_KEY && iev.code == KEY_POWER && !iev.value) {
if (prop[0] != '1' || timeout > 0) {
- simulate_powerkey(ufd, 1);
+ simulate_powerkey(ufd, longpress);
timeout = -1;
} else {
timeout = 1000; // one second
}
+ } else if (iev.type == EV_SYN && iev.code == SYN_REPORT && iev.value) {
+ ALOGI("got a resuming event");
+ longpress = 0;
+ timeout = 1000; // one second
}
}
}