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

Commit 05a358fd authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 20330

* changes:
  EventHub: pass the name of each input device up to Java
parents 6ce548fa 34193b31
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -119,7 +119,7 @@ private:
        String8         keylayoutFilename;
        String8         keylayoutFilename;
        device_t*       next;
        device_t*       next;
        
        
        device_t(int32_t _id, const char* _path);
        device_t(int32_t _id, const char* _path, const char* name);
        ~device_t();
        ~device_t();
    };
    };


+8 −11
Original line number Original line Diff line number Diff line
@@ -82,8 +82,8 @@ static inline int max(int v1, int v2)
    return (v1 > v2) ? v1 : v2;
    return (v1 > v2) ? v1 : v2;
}
}


EventHub::device_t::device_t(int32_t _id, const char* _path)
EventHub::device_t::device_t(int32_t _id, const char* _path, const char* name)
    : id(_id), path(_path), classes(0)
    : id(_id), path(_path), name(name), classes(0)
    , keyBitmask(NULL), layoutMap(new KeyLayoutMap()), next(NULL) {
    , keyBitmask(NULL), layoutMap(new KeyLayoutMap()), next(NULL) {
}
}


@@ -593,7 +593,7 @@ int EventHub::open_device(const char *deviceName)
        version >> 16, (version >> 8) & 0xff, version & 0xff);
        version >> 16, (version >> 8) & 0xff, version & 0xff);
#endif
#endif


    device_t* device = new device_t(devid|mDevicesById[devid].seq, deviceName);
    device_t* device = new device_t(devid|mDevicesById[devid].seq, deviceName, name);
    if (device == NULL) {
    if (device == NULL) {
        LOGE("out of memory");
        LOGE("out of memory");
        return -1;
        return -1;
@@ -678,17 +678,14 @@ int EventHub::open_device(const char *deviceName)
#endif
#endif


    if ((device->classes&CLASS_KEYBOARD) != 0) {
    if ((device->classes&CLASS_KEYBOARD) != 0) {
        char devname[101];
        char tmpfn[sizeof(name)];
        char tmpfn[101];
        char keylayoutFilename[300];
        char keylayoutFilename[300];


        // a more descriptive name
        // a more descriptive name
        ioctl(mFDs[mFDCount].fd, EVIOCGNAME(sizeof(devname)-1), devname);
        device->name = name;
        devname[sizeof(devname)-1] = 0;
        device->name = devname;


        // replace all the spaces with underscores
        // replace all the spaces with underscores
        strcpy(tmpfn, devname);
        strcpy(tmpfn, name);
        for (char *p = strchr(tmpfn, ' '); p && *p; p = strchr(tmpfn, ' '))
        for (char *p = strchr(tmpfn, ' '); p && *p; p = strchr(tmpfn, ' '))
            *p = '_';
            *p = '_';


@@ -721,7 +718,7 @@ int EventHub::open_device(const char *deviceName)
        }
        }
        char propName[100];
        char propName[100];
        sprintf(propName, "hw.keyboards.%u.devname", publicID);
        sprintf(propName, "hw.keyboards.%u.devname", publicID);
        property_set(propName, devname);
        property_set(propName, name);


        // 'Q' key support = cheap test of whether this is an alpha-capable kbd
        // 'Q' key support = cheap test of whether this is an alpha-capable kbd
        if (hasKeycode(device, kKeyCodeQ)) {
        if (hasKeycode(device, kKeyCodeQ)) {
@@ -738,7 +735,7 @@ int EventHub::open_device(const char *deviceName)
        }
        }
        
        
        LOGI("New keyboard: publicID=%d device->id=0x%x devname='%s' propName='%s' keylayout='%s'\n",
        LOGI("New keyboard: publicID=%d device->id=0x%x devname='%s' propName='%s' keylayout='%s'\n",
                publicID, device->id, devname, propName, keylayoutFilename);
                publicID, device->id, name, propName, keylayoutFilename);
    }
    }


    LOGI("New device: path=%s name=%s id=0x%x (of 0x%x) index=%d fd=%d classes=0x%x\n",
    LOGI("New device: path=%s name=%s id=0x%x (of 0x%x) index=%d fd=%d classes=0x%x\n",