Updates the SDL library to the latest standard bugfix release

This commit is contained in:
JeffR 2023-07-13 15:20:29 -05:00
parent cb766f2878
commit 083d2175ea
1280 changed files with 343926 additions and 179615 deletions

View file

@ -39,7 +39,7 @@ Bugs (hidraw implementation only):
-----------------------------------
On Kernel versions < 2.6.34, if your device uses numbered reports, an extra
byte will be returned at the beginning of all reports returned from read()
for hidraw devices. This is worked around in the libary. No action should be
for hidraw devices. This is worked around in the library. No action should be
necessary in the client library.
On Kernel versions < 2.6.35, reports will only be sent using a Set_Report

View file

@ -22,6 +22,8 @@
********************************************************/
#include "../../SDL_internal.h"
#include "SDL_hints.h"
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* needed for wcsdup() before glibc 2.10 */
#endif
@ -198,7 +200,7 @@ static int uses_numbered_reports(__u8 *report_descriptor, __u32 size) {
/* Can't ever happen since size_code is & 0x3 */
data_len = 0;
break;
};
}
key_size = 1;
}
@ -219,7 +221,7 @@ parse_uevent_info(const char *uevent, unsigned *bus_type,
unsigned short *vendor_id, unsigned short *product_id,
char **serial_number_utf8, char **product_name_utf8)
{
char *tmp = strdup(uevent);
char *tmp;
char *saveptr = NULL;
char *line;
char *key;
@ -229,6 +231,15 @@ parse_uevent_info(const char *uevent, unsigned *bus_type,
int found_serial = 0;
int found_name = 0;
if (!uevent) {
return 0;
}
tmp = strdup(uevent);
if (!tmp) {
return 0;
}
line = strtok_r(tmp, "\n", &saveptr);
while (line != NULL) {
/* line: "KEY=value" */
@ -472,6 +483,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
struct hid_device_info *root = NULL; /* return object */
struct hid_device_info *cur_dev = NULL;
struct hid_device_info *prev_dev = NULL; /* previous device */
const char *hint = SDL_GetHint(SDL_HINT_HIDAPI_IGNORE_DEVICES);
hid_init();
@ -543,6 +555,16 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
goto next;
}
/* 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)) {
continue;
}
}
/* Check the VID/PID against the arguments */
if ((vendor_id == 0x0 || vendor_id == dev_vid) &&
(product_id == 0x0 || product_id == dev_pid)) {
@ -707,6 +729,8 @@ hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const
hid_device * HID_API_EXPORT hid_open_path(const char *path, int bExclusive)
{
const int MAX_ATTEMPTS = 10;
int attempt;
hid_device *dev = NULL;
hid_init();
@ -714,7 +738,15 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path, int bExclusive)
dev = new_hid_device();
/* OPEN HERE */
dev->device_handle = open(path, O_RDWR | O_CLOEXEC);
for (attempt = 1; attempt <= MAX_ATTEMPTS; ++attempt) {
dev->device_handle = open(path, O_RDWR | O_CLOEXEC);
if (dev->device_handle < 0 && errno == EACCES) {
/* udev might be setting up permissions, wait a bit and try again */
usleep(1 * 1000);
continue;
}
break;
}
/* If we have a good handle, return it. */
if (dev->device_handle >= 0) {