Skip to content

Commit

Permalink
make bluetooth hid vid/pid can be ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Jan 17, 2024
1 parent b5a33bf commit 583d465
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions src/hidapi/webos/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,30 +665,35 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
break;

case BUS_BLUETOOTH:
if (SDL_GetHintBoolean(SDL_HINT_WEBOS_JOYSTICK_HIDAPI_BLUETOOTH, SDL_TRUE)) {
/* Manufacturer and Product strings */
cur_dev->manufacturer_string = wcsdup(L"");
cur_dev->product_string = utf8_to_wchar_t(product_name_utf8);

break;
}
else {
/* Free this device */
free(cur_dev->serial_number);
free(cur_dev->path);
free(cur_dev);

/* Take it off the device list. */
if (prev_dev) {
prev_dev->next = NULL;
cur_dev = prev_dev;
}
else {
cur_dev = root = NULL;
hint = SDL_GetHint(SDL_HINT_WEBOS_HIDAPI_IGNORE_BLUETOOTH_DEVICES);
/* See if there are any devices we should skip in enumeration */
if (hint) {
char vendor_match[16], product_match[16];
SDL_snprintf(vendor_match, sizeof(vendor_match), "0x%.4x/0x0000", dev_vid);
SDL_snprintf(product_match, sizeof(product_match), "0x%.4x/0x%.4x", dev_vid, dev_pid);
if (SDL_strcasestr(hint, vendor_match) || SDL_strcasestr(hint, product_match)) {
/* Free this device */
free(cur_dev->serial_number);
free(cur_dev->path);
free(cur_dev);

/* Take it off the device list. */
if (prev_dev) {
prev_dev->next = NULL;
cur_dev = prev_dev;
}
else {
cur_dev = root = NULL;
}

goto next;
}

goto next;
}
/* Manufacturer and Product strings */
cur_dev->manufacturer_string = wcsdup(L"");
cur_dev->product_string = utf8_to_wchar_t(product_name_utf8);

break;
default:
/* Unknown device type - this should never happen, as we
* check for USB and Bluetooth devices above */
Expand Down

0 comments on commit 583d465

Please sign in to comment.