diff -r b20673c09b07 modules/graphics/src/main/native-glass/lens/input/udev/udevInput.c --- a/modules/graphics/src/main/native-glass/lens/input/udev/udevInput.c Mon Oct 07 13:25:02 2013 +0200 +++ b/modules/graphics/src/main/native-glass/lens/input/udev/udevInput.c Tue Oct 08 16:36:44 2013 +0200 @@ -168,8 +168,6 @@ char *sysPath; //absolute path (under /sys), char *devNode; //virtual path (under /dev) char *productString; //string containing vendorID and productID - unsigned int vendorId; - unsigned int productId; /* device capabilities */ LensInputDeviceCapabilities caps; @@ -313,9 +311,6 @@ static void lens_input_udevMonitorHandleEvent(JNIEnv *env); static LensInputDeviceInfo *lens_input_deviceInfoAllocateAndInit(struct udev_device *udev_device, LensInputDevice *device); -static LensResult lens_input_udevParseProductID(struct udev_device *udev_device, - unsigned int *vendorId, - unsigned int *productId); // test input functions static void lens_input_testInputMonitorLoop(JNIEnv *env, void *handle); @@ -575,8 +570,6 @@ struct udev_device *parent; LensInputDeviceInfo *info; - unsigned int vendorId, productId; - device->info = NULL; //first get the name of the device, its important to initialize internal device data @@ -621,8 +614,6 @@ return NULL; } - lens_input_udevParseProductID(udev_device, &info->vendorId, &info->productId); - info->devNode = strdup(devNode); info->sysPath = strdup(sysPath); info->productString = strdup(product); @@ -2170,46 +2161,6 @@ //// utilities /** - * Parse the PRODUCT string from udev entry and convert into unsigned int - * - * @param udev_device [IN] the device to parse - * @param vendorId [OUT] usb vendor id number - * @param productId [OUT] usb product id number - * - * @return LensResult LES_OK on success - */ -static LensResult lens_input_udevParseProductID(struct udev_device *udev_device, - unsigned int *vendorId, - unsigned int *productId) { - - struct udev_device *parent = udev_device_get_parent(udev_device); - - LensResult result = LENS_FAILED; - - if (parent) { - const char *product = udev_device_get_property_value(parent, "PRODUCT"); - int matchedStrings; - unsigned int _productId, _vendorId; - - if (product) { - //first try to parse as hex - matchedStrings = sscanf(product, "%*x/%4x/%4x/%*x", &_vendorId, &_productId); - - if (matchedStrings == 2) { - *vendorId = _vendorId; - *productId = _productId; - result = LENS_OK; - } else { - GLASS_LOG_FINE("Failed to parse PRODUCT [%s]", product); - *vendorId = 0; - *productId = 0; - } - } - } - return result; -} - -/** * Remove LensInputDevice from the list of deevices and free its * resources * @@ -2245,35 +2196,23 @@ LensInputDevice **device) { LensInputDevice *_device = lensInputDevicesList_head; - const char *devNode = udev_device_get_devnode(udev_device); - - - unsigned int vendorId, productId; - - if (!_device) { - GLASS_LOG_FINER("Device doesn't exist - Device list empty\n"); + const char *sysPath = udev_device_get_syspath(udev_device); + + if (!sysPath) { + GLASS_LOG_CONFIG("Device has no sysPath"); } else { - if (lens_input_udevParseProductID(udev_device, &vendorId, &productId) == LENS_OK) { - while (_device) { - GLASS_LOG_FINER("Comparing udev[%s, %x, %x] with device[%s, %x, %x]", - devNode, vendorId, productId, - _device->info->devNode, - _device->info->vendorId, - _device->info->productId); - if ((_device->info->vendorId == vendorId && - _device->info->productId == productId) || - (devNode && !(strcmp(_device->info->devNode, devNode)))) { - GLASS_LOG_FINER("Device found"); - if (device) { - GLASS_LOG_FINER("referencing device"); - *device = _device; - } - return JNI_TRUE; - } - - _device = _device->nextDevice; + while (_device) { + // only devices with a valid sysPath should be in our list + assert(_device->info->sysPath); + if (strcmp(sysPath, _device->info->sysPath) == 0) { + GLASS_LOG_CONFIG("Device %s already added", sysPath); } + if (device) { + *device = _device; + } + return JNI_TRUE; } + _device = _device->nextDevice; } //no device found.... if (device) { @@ -2329,8 +2268,6 @@ GLASS_LOG_CONFIG("sysPath %s", device->info->sysPath); GLASS_LOG_CONFIG("fd: %i", device->fd); GLASS_LOG_CONFIG("Product: %s", device->info->productString); - GLASS_LOG_CONFIG("VendorId: %x", device->info->vendorId); - GLASS_LOG_CONFIG("ProductId: %x", device->info->productId); if (device->isKeyboard) { GLASS_LOG_CONFIG("device is keyboard\n"); @@ -2865,8 +2802,6 @@ lens_input_deviceRelease(env, device); return LENS_FAILED; } - device->info->vendorId = (unsigned int) id.vendor; - device->info->productId = (unsigned int) id.product; rc |= lens_input_testInputReadString(&device->info->name); rc |= lens_input_testInputReadString(&device->info->devNode); rc |= lens_input_testInputReadString(&device->info->productString);