| 278 | } |
| 279 | |
| 280 | static int is_language_supported(libusb_device_handle *dev, uint16_t lang) |
| 281 | { |
| 282 | uint16_t buf[32]; |
| 283 | int len; |
| 284 | int i; |
| 285 | |
| 286 | /* Get the string from libusb. */ |
| 287 | len = libusb_get_string_descriptor(dev, |
| 288 | 0x0, /* String ID */ |
| 289 | 0x0, /* Language */ |
| 290 | (unsigned char*)buf, |
| 291 | sizeof(buf)); |
| 292 | if (len < 4) |
| 293 | return 0x0; |
| 294 | |
| 295 | |
| 296 | len /= 2; /* language IDs are two-bytes each. */ |
| 297 | /* Start at index 1 because there are two bytes of protocol data. */ |
| 298 | for (i = 1; i < len; i++) { |
| 299 | if (buf[i] == lang) |
| 300 | return 1; |
| 301 | } |
| 302 | |
| 303 | return 0; |
| 304 | } |
| 305 | |
| 306 | |
| 307 | /* This function returns a newly allocated wide string containing the USB |
no test coverage detected