Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cdeb0cac authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Allow compatibility with 'old' Touchscreens (Linux < 3.1)" into ics

parents 0c222c2d 7347f6a8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_C_INCLUDES := \
    external/skia/include/core

ifeq ($(BOARD_USE_LEGACY_TOUCHSCREEN),true)
LOCAL_CFLAGS += -DLEGACY_TOUCHSCREEN
endif

LOCAL_MODULE:= libinput

LOCAL_MODULE_TAGS := optional
+59 −3
Original line number Diff line number Diff line
@@ -931,6 +931,9 @@ void InputDevice::process(const RawEvent* rawEvents, size_t count) {
    // have side-effects that must be interleaved.  For example, joystick movement events and
    // gamepad button presses are handled by different mappers but they should be dispatched
    // in the order received.
#ifdef LEGACY_TOUCHSCREEN
    static int32_t touched, z_data;
#endif
    size_t numMappers = mMappers.size();
    for (const RawEvent* rawEvent = rawEvents; count--; rawEvent++) {
#if DEBUG_RAW_EVENTS
@@ -956,13 +959,66 @@ void InputDevice::process(const RawEvent* rawEvents, size_t count) {
            mDropUntilNextSync = true;
            reset(rawEvent->when);
        } else {

            if (!numMappers) continue;
            InputMapper* mapper = NULL;

#ifdef LEGACY_TOUCHSCREEN

            // Old touchscreen sensors need to send a fake BTN_TOUCH (BTN_LEFT)

            if (rawEvent->scanCode == ABS_MT_TOUCH_MAJOR) {

                z_data = rawEvent->value;
                touched = (0 != z_data);
            }
            else if (rawEvent->scanCode == ABS_MT_POSITION_Y) {

                RawEvent event;
                memset(&event, 0, sizeof(event));
                event.when = rawEvent->when;
                event.deviceId = rawEvent->deviceId;
                event.scanCode = rawEvent->scanCode;

                event.type = rawEvent->type;
                event.value = rawEvent->value;
                for (size_t i = 0; i < numMappers; i++) {
                InputMapper* mapper = mMappers[i];
                    mapper = mMappers[i];
                    mapper->process(&event);
                }

                /* Pressure on contact area from ABS_MT_TOUCH_MAJOR */
                event.type = rawEvent->type;
                event.scanCode = ABS_MT_PRESSURE;
                event.value = z_data;
                for (size_t i = 0; i < numMappers; i++) {
                    mapper = mMappers[i];
                    mapper->process(&event);
                }

                event.type = EV_KEY;
                event.scanCode = BTN_TOUCH;
                event.keyCode = BTN_LEFT;
                event.value = touched;
                for (size_t i = 0; i < numMappers; i++) {
                    mapper = mMappers[i];
                    mapper->process(&event);
                }

                LOGD("Fake event sent, touch=%d !", touched);
            }
            else
#endif //LEGACY_TOUCHSCREEN
            {
                // just send the rawEvent
                for (size_t i = 0; i < numMappers; i++) {
                     mapper = mMappers[i];
                     mapper->process(rawEvent);
                }
            }
        }
    }
}

void InputDevice::timeoutExpired(nsecs_t when) {
    size_t numMappers = mMappers.size();