| 647 | } |
| 648 | |
| 649 | static void |
| 650 | HIDAPI_AddDevice(struct hid_device_info *info) |
| 651 | { |
| 652 | SDL_HIDAPI_Device *device; |
| 653 | SDL_HIDAPI_Device *curr, *last = NULL; |
| 654 | |
| 655 | for (curr = SDL_HIDAPI_devices, last = NULL; curr; last = curr, curr = curr->next) { |
| 656 | continue; |
| 657 | } |
| 658 | |
| 659 | device = (SDL_HIDAPI_Device *)SDL_calloc(1, sizeof(*device)); |
| 660 | if (!device) { |
| 661 | return; |
| 662 | } |
| 663 | device->path = SDL_strdup(info->path); |
| 664 | if (!device->path) { |
| 665 | SDL_free(device); |
| 666 | return; |
| 667 | } |
| 668 | device->seen = SDL_TRUE; |
| 669 | device->vendor_id = info->vendor_id; |
| 670 | device->product_id = info->product_id; |
| 671 | device->version = info->release_number; |
| 672 | device->interface_number = info->interface_number; |
| 673 | device->interface_class = info->interface_class; |
| 674 | device->interface_subclass = info->interface_subclass; |
| 675 | device->interface_protocol = info->interface_protocol; |
| 676 | device->usage_page = info->usage_page; |
| 677 | device->usage = info->usage; |
| 678 | { |
| 679 | /* FIXME: Is there any way to tell whether this is a Bluetooth device? */ |
| 680 | const Uint16 vendor = device->vendor_id; |
| 681 | const Uint16 product = device->product_id; |
| 682 | const Uint16 version = device->version; |
| 683 | Uint16 *guid16 = (Uint16 *)device->guid.data; |
| 684 | |
| 685 | *guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_USB); |
| 686 | *guid16++ = 0; |
| 687 | *guid16++ = SDL_SwapLE16(vendor); |
| 688 | *guid16++ = 0; |
| 689 | *guid16++ = SDL_SwapLE16(product); |
| 690 | *guid16++ = 0; |
| 691 | *guid16++ = SDL_SwapLE16(version); |
| 692 | *guid16++ = 0; |
| 693 | |
| 694 | /* Note that this is a HIDAPI device for special handling elsewhere */ |
| 695 | device->guid.data[14] = 'h'; |
| 696 | device->guid.data[15] = 0; |
| 697 | } |
| 698 | device->dev_lock = SDL_CreateMutex(); |
| 699 | |
| 700 | /* Need the device name before getting the driver to know whether to ignore this device */ |
| 701 | if (!device->name) { |
| 702 | const char *name = SDL_GetCustomJoystickName(device->vendor_id, device->product_id); |
| 703 | if (name) { |
| 704 | device->name = SDL_strdup(name); |
| 705 | } |
| 706 | } |
no test coverage detected