Get the first language the device says it reports. This comes from USB string #0. */
| 256 | /* Get the first language the device says it reports. This comes from |
| 257 | USB string #0. */ |
| 258 | static uint16_t get_first_language(libusb_device_handle *dev) |
| 259 | { |
| 260 | uint16_t buf[32]; |
| 261 | int len; |
| 262 | |
| 263 | /* Get the string from libusb. */ |
| 264 | len = libusb_get_string_descriptor(dev, |
| 265 | 0x0, /* String ID */ |
| 266 | 0x0, /* Language */ |
| 267 | (unsigned char*)buf, |
| 268 | sizeof(buf)); |
| 269 | if (len < 4) |
| 270 | return 0x0; |
| 271 | |
| 272 | return buf[1]; // First two bytes are len and descriptor type. |
| 273 | } |
| 274 | |
| 275 | static int is_language_supported(libusb_device_handle *dev, uint16_t lang) |
| 276 | { |