--- a/recovery/minui/events.cpp
+++ b/recovery/minui/events.cpp
@@ -68,18 +68,25 @@ int ev_init(ev_callback input_cb, void* data) {
unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)];
// fprintf(stderr,"/dev/input/%s\n", de->d_name);
if (strncmp(de->d_name, "event", 5)) continue;
int fd = openat(dirfd(dir), de->d_name, O_RDONLY);
if (fd == -1) continue;
// Read the evbits of the input device.
- if (ioctl(fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits) == -1) {
+// if (ioctl(fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits) == -1) {
+// close(fd);
+// continue;
+// }
+
+ if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(ev_bits)), ev_bits) == -1) {
close(fd);
continue;
}
// We assume that only EV_KEY, EV_REL, and EV_SW event types are ever needed.
- if (!test_bit(EV_KEY, ev_bits) && !test_bit(EV_REL, ev_bits) && !test_bit(EV_SW, ev_bits)) {
+// if (!test_bit(EV_KEY, ev_bits) && !test_bit(EV_REL, ev_bits) && !test_bit(EV_SW, ev_bits)) {
+ if (!test_bit(ABS_MT_POSITION_X, ev_bits) && !test_bit(ABS_MT_POSITION_Y, ev_bits)) {
close(fd);
continue;
}
@@ -211,17 +218,18 @@ void ev_iterate_available_keys(std::function<void(int)> f) {
memset(key_bits, 0, sizeof(key_bits));
// Does this device even have keys?
- if (ioctl(ev_fdinfo[i].fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits) == -1) {
- continue;
- }
- if (!test_bit(EV_KEY, ev_bits)) {
+ if (ioctl(ev_fdinfo[i].fd, EVIOCGBIT(EV_ABS, sizeof(ev_bits)), ev_bits) == -1) {
continue;
}
- int rc = ioctl(ev_fdinfo[i].fd, EVIOCGBIT(EV_KEY, KEY_MAX), key_bits);
- if (rc == -1) {
- continue;
- }
+// if (!test_bit(EV_KEY, ev_bits)) {
+// continue;
+// }
+
+// int rc = ioctl(ev_fdinfo[i].fd, EVIOCGBIT(EV_KEY, KEY_MAX), key_bits);
+// if (rc == -1) {
+// continue;
+// }
for (int key_code = 0; key_code <= KEY_MAX; ++key_code) {
if (test_bit(key_code, key_bits)) {
void RecoveryUI::Init() {
ev_init(InputCallback, this);
ev_iterate_available_keys(std::bind(&RecoveryUI::OnKeyDetected, this, std::placeholders::_1));
@@ -95,31 +101,41 @@ int RecoveryUI::OnInputEvent(int fd, uint32_t epevents) {
}
if (ev.type == EV_SYN) {
- return 0;
- } else if (ev.type == EV_REL) {
- if (ev.code == REL_Y) {
- // accumulate the up or down motion reported by
- // the trackball. When it exceeds a threshold
- // (positive or negative), fake an up/down
- // key event.
- rel_sum += ev.value;
- if (rel_sum > 3) {
- ProcessKey(KEY_DOWN, 1); // press down key
- ProcessKey(KEY_DOWN, 0); // and release it
- rel_sum = 0;
- } else if (rel_sum < -3) {
- ProcessKey(KEY_UP, 1); // press up key
- ProcessKey(KEY_UP, 0); // and release it
- rel_sum = 0;
+ if (ev.code == SYN_REPORT) {
+ if (mFingerDown && !mSwiping) {
+// mStartX = mX;
+// mStartY = mY;
+ mSwiping = true;
+ } else if (!mFingerDown && mSwiping) {
+ mSwiping = false;
+ EnqueueKey(ABS_MT_SLOT);
+ }
+ }
+ } else if (ev.type == EV_ABS) {
+// if (ev.code == ABS_MT_SLOT) {
+
+ switch (ev.code) {
+ case ABS_MT_POSITION_X:
+ mFingerDown = true;
+// mX = event->value;
+ break;
+
+ case ABS_MT_POSITION_Y:
+ mFingerDown = true;
+// mY = event->value;
+ break;
+
+ case ABS_MT_TRACKING_ID:
+ if (ev.value < 0)
+ mFingerDown = false;
+ break;
}
}