static void setActiveConfigValue(char line[]) { // Parse the device index DWORD devIdx = 0; line = parseNumber(line, devIdx); if (!line) { printf("Please provide a decimal device number following the command\n"); return; } if (devIdx >= gDeviceListSize || devIdx < 0) { printf("Invalid device index '%d' provided\n", devIdx); return; } // Parse the configuration value DWORD cv = -1; line = parseNumber(line, cv); if (!line) { printf("Please provide a decimal value for the configuration value\n"); return; } if (cv < 0 || cv > 255) { printf("Configuration value '%d' out of range\n", cv); return; } UKW_DEVICE device = gDeviceList[devIdx]; BOOL result = UkwSetConfig(device, static_cast<UCHAR>(cv)); if (!result) { printf("Failed to set configuration value '%d' on device '%d': %d\n", cv, devIdx, GetLastError()); } else { printf("bConfigurationValue = %.02x\n", cv); } }
static int wince_set_configuration( struct libusb_device_handle *handle, int config) { struct wince_device_priv *priv = _device_priv(handle->dev); // Setting configuration 0 places the device in Address state. // This should correspond to the "unconfigured state" required by // libusb when the specified configuration is -1. UCHAR cv = (config < 0) ? 0 : config; if (!UkwSetConfig(priv->dev, cv)) { return translate_driver_error(GetLastError()); } return LIBUSB_SUCCESS; }