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 9bac886 commit c09bcf1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
11 changes: 6 additions & 5 deletions include/SDL_hints.h
Original file line number Diff line number Diff line change
Expand Up @@ -2460,27 +2460,28 @@ extern "C" {
/**
* \brief A variable that decides whether to send Luna calls to register the app automatically.
*/
#define SDL_HINT_WEBOS_REGISTER_APP "SDL_HINT_WEBOS_REGISTER_APP"
#define SDL_HINT_WEBOS_REGISTER_APP "SDL_WEBOS_REGISTER_APP"
/**
* \brief A variable that decides the window class.
*/
#define SDL_HINT_WEBOS_WINDOW_CLASS "SDL_HINT_WEBOS_WINDOW_CLASS"
#define SDL_HINT_WEBOS_WINDOW_CLASS "SDL_WEBOS_WINDOW_CLASS"
/**
* \brief A variable that decides update frequency of the cursor in second.
*/
#define SDL_HINT_WEBOS_CURSOR_FREQUENCY "SDL_HINT_WEBOS_CURSOR_FREQUENCY"
#define SDL_HINT_WEBOS_CURSOR_FREQUENCY "SDL_WEBOS_CURSOR_FREQUENCY"
/**
* \brief A variable that decides whether to disable cursor calibration.
*/
#define SDL_HINT_WEBOS_CURSOR_CALIBRATION_DISABLE "SDL_HINT_WEBOS_CURSOR_CALIBRATION_DISABLE"
#define SDL_HINT_WEBOS_CURSOR_CALIBRATION_DISABLE "SDL_WEBOS_CURSOR_CALIBRATION_DISABLE"
/**
* \brief A variable that decides whether to let SDL handle input from game controllers.
*
* Since webOS 8.3.0, input from game controllers is mapped to navigation / volume control keys by default.
* This change is useful, but can cause doubled input. SDL disables this behavior by default to let developers
* handle game controller input by themselves. But the behavior can be disabled by setting this hint to "false".
*/
#define SDL_HINT_WEBOS_CLOUDGAME_ACTIVE "SDL_HINT_WEBOS_CLOUDGAME_ACTIVE"
#define SDL_HINT_WEBOS_CLOUDGAME_ACTIVE "SDL_WEBOS_CLOUDGAME_ACTIVE"
#define SDL_HINT_WEBOS_HIDAPI_IGNORE_BLUETOOTH_DEVICES "SDL_EBOS_HIDAPI_IGNORE_BLUETOOTH_DEVICES"

/**
* \brief An enumeration of hint priorities
Expand Down
42 changes: 27 additions & 15 deletions src/hidapi/webos/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,23 +665,35 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
break;

case BUS_BLUETOOTH:
/* webOS doesn't handle bluetooth HID device as expected, so skip enumerating them */
/* 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;
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;
}
}
else {
cur_dev = root = NULL;
}

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 c09bcf1

Please sign in to comment.