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

Commit a9c0f0d6 authored by rmcc's avatar rmcc Committed by Ricardo Cerqueira
Browse files

Inotify support for TSLib

Change-Id: I26a289f00d98b5f010e1a6a9db2c111b349a29b6
parent 9b6318d3
Loading
Loading
Loading
Loading
+40 −7
Original line number Diff line number Diff line
@@ -76,6 +76,11 @@ namespace android {
static const char *WAKE_LOCK_ID = "KeyEvents";
static const char *device_path = "/dev/input";

#ifdef HAVE_TSLIB
static const char *ts_path = "/data/misc/tscal";
static const char *pointercal_path = "/data/misc/tscal/pointercal";
#endif

/* return the larger integer */
static inline int max(int v1, int v2)
{
@@ -387,8 +392,8 @@ bool EventHub::getEvent(int32_t* outDeviceId, int32_t* outType,
#ifdef HAVE_TSLIB
                            }
                            else{
                                LOGI("mTS->fd = %d", mTS->fd);
                                LOGI("tslib: calling ts_read from eventhub\n");
                                LOGV("mTS->fd = %d", mTS->fd);
                                LOGV("tslib: calling ts_read from eventhub\n");
                                res = ts_read(mTS, &samp, 1);

                                if (res < 0) {
@@ -514,6 +519,15 @@ bool EventHub::openPlatformInput(void)
    if(res < 0) {
        LOGE("could not add watch for %s, %s\n", device_path, strerror(errno));
    }
#ifdef HAVE_TSLIB
    res = inotify_add_watch(mFDs[0].fd, pointercal_path, IN_MODIFY);
    if (res < 0) {
        res = inotify_add_watch(mFDs[0].fd, ts_path, IN_MODIFY);
        if (res < 0) {
            LOGE("could not add watch for %s, %s\n", ts_path, strerror(errno));
        }
    }
#endif
#else
    /*
     * The code in EventHub::getEvent assumes that mFDs[0] is an inotify fd.
@@ -954,6 +968,19 @@ int EventHub::read_notify(int nfd)
        //printf("%d: %08x \"%s\"\n", event->wd, event->mask, event->len ? event->name : "");
        if(event->len) {
            strcpy(filename, event->name);
#ifdef HAVE_TSLIB
            if (!strcmp(filename, "pointercal")) {
                if (mTS->fd)
                    ts_reload(mTS);
                inotify_rm_watch(mFDs[0].fd, res);
                res = inotify_add_watch(mFDs[0].fd, pointercal_path, IN_MODIFY);
                if(res < 0) {
                    LOGE("could not add watch for %s, %s\n", pointercal_path, strerror(errno));
                }
            } else {
#else
            {
#endif
                if(event->mask & IN_CREATE) {
                    open_device(devname);
                }
@@ -961,6 +988,12 @@ int EventHub::read_notify(int nfd)
                    close_device(devname);
                }
            }
#ifdef HAVE_TSLIB
        } else {
              if (mTS->fd)
                  ts_reload(mTS);
#endif
        }
        event_size = sizeof(*event) + event->len;
        res -= event_size;
        event_pos += event_size;