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

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

Merge "Inotify support for TSLib" into froyo

parents fa29c335 a9c0f0d6
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;