Update SDL2 to version 2.28.1.

This commit is contained in:
Sasha Szpakowski
2023-07-01 17:33:01 -03:00
parent ac30fb34cb
commit b38f57730a
1404 changed files with 361075 additions and 197139 deletions
+62 -50
View File
@@ -1,6 +1,6 @@
/*
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 2020 Collabora Ltd.
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 2020-2022 Collabora Ltd.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -31,34 +31,36 @@ static const struct
{
int code;
const char *name;
} device_classes[] =
{
#define CLS(x) \
{ SDL_UDEV_DEVICE_ ## x, #x }
} device_classes[] = {
#define CLS(x) \
{ \
SDL_UDEV_DEVICE_##x, #x \
}
CLS(MOUSE),
CLS(KEYBOARD),
CLS(JOYSTICK),
CLS(SOUND),
CLS(TOUCHSCREEN),
CLS(ACCELEROMETER),
CLS(TOUCHPAD),
#undef CLS
{ 0, NULL }
};
typedef struct
{
const char *name;
uint16_t bus_type;
uint16_t vendor_id;
uint16_t product_id;
uint16_t version;
uint8_t ev[(EV_MAX + 1) / 8];
uint8_t keys[(KEY_MAX + 1) / 8];
uint8_t abs[(ABS_MAX + 1) / 8];
uint8_t rel[(REL_MAX + 1) / 8];
uint8_t ff[(FF_MAX + 1) / 8];
uint8_t props[INPUT_PROP_MAX / 8];
int expected;
const char *name;
uint16_t bus_type;
uint16_t vendor_id;
uint16_t product_id;
uint16_t version;
uint8_t ev[(EV_MAX + 1) / 8];
uint8_t keys[(KEY_MAX + 1) / 8];
uint8_t abs[(ABS_MAX + 1) / 8];
uint8_t rel[(REL_MAX + 1) / 8];
uint8_t ff[(FF_MAX + 1) / 8];
uint8_t props[INPUT_PROP_MAX / 8];
int expected;
} GuessTest;
/*
@@ -72,10 +74,11 @@ typedef struct
*/
#define ZEROx4 0, 0, 0, 0
#define ZEROx8 ZEROx4, ZEROx4
#define FFx4 0xff, 0xff, 0xff, 0xff
#define FFx8 FFx4, FFx4
#define FFx4 0xff, 0xff, 0xff, 0xff
#define FFx8 FFx4, FFx4
/* Test-cases derived from real devices or from Linux kernel source */
/* *INDENT-OFF* */ /* clang-format off */
static const GuessTest guess_tests[] =
{
{
@@ -185,9 +188,7 @@ static const GuessTest guess_tests[] =
.bus_type = 0x0003,
.vendor_id = 0x054c,
.product_id = 0x09cc,
/* TODO: Should this be MOUSE? That's what it most closely
* resembles */
.expected = SDL_UDEV_DEVICE_UNKNOWN,
.expected = SDL_UDEV_DEVICE_TOUCHPAD,
/* SYN, KEY, ABS */
.ev = { 0x0b },
/* X, Y, multitouch */
@@ -596,7 +597,7 @@ static const GuessTest guess_tests[] =
* to the arrow, page up and page down keys, so it's a joystick
* with a subset of a keyboard attached. */
/* TODO: Should this be JOYSTICK, or even JOYSTICK|KEYBOARD? */
.expected = SDL_UDEV_DEVICE_UNKNOWN,
.expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY */
.ev = { 0x03 },
.keys = {
@@ -608,7 +609,7 @@ static const GuessTest guess_tests[] =
/* BTN_1, BTN_2, BTN_A, BTN_B, BTN_MODE */
/* 0x100 */ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x10,
/* 0x140 */ ZEROx8,
/* next, previous */
/* next (keyboard page down), previous (keyboard page up) */
/* 0x180 */ 0x00, 0x00, 0x80, 0x10, ZEROx4,
},
},
@@ -659,7 +660,7 @@ static const GuessTest guess_tests[] =
.name = "Wiimote - Classic Controller",
/* TODO: Should this be JOYSTICK, or maybe JOYSTICK|KEYBOARD?
* It's unusual in the same ways as the Wiimote */
.expected = SDL_UDEV_DEVICE_UNKNOWN,
.expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY, ABS */
.ev = { 0x0b },
/* Hat 1-3 */
@@ -673,7 +674,7 @@ static const GuessTest guess_tests[] =
/* A, B, X, Y, MODE, TL, TL2, TR, TR2 */
/* 0x100 */ ZEROx4, 0x00, 0x13, 0xdb, 0x10,
/* 0x140 */ ZEROx8,
/* next, previous */
/* next (keyboard page down), previous (keyboard page up) */
/* 0x180 */ 0x00, 0x00, 0x80, 0x10, ZEROx4,
},
},
@@ -718,9 +719,7 @@ static const GuessTest guess_tests[] =
.vendor_id = 0x06cb,
.product_id = 0x0000,
.version = 0x0000,
/* TODO: Should this be MOUSE? That's what it most closely
* resembles */
.expected = SDL_UDEV_DEVICE_UNKNOWN,
.expected = SDL_UDEV_DEVICE_TOUCHPAD,
/* SYN, KEY, ABS */
.ev = { 0x0b },
/* X, Y, pressure, multitouch */
@@ -756,7 +755,8 @@ static const GuessTest guess_tests[] =
},
{
.name = "Thinkpad ACPI buttons",
.expected = SDL_UDEV_DEVICE_UNKNOWN,
/* SDL treats this as a keyboard because it has a power button */
.expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY, MSC, SW */
.ev = { 0x33 },
.keys = {
@@ -815,7 +815,8 @@ static const GuessTest guess_tests[] =
.vendor_id = 0x0000,
.product_id = 0x0003,
.version = 0x0000,
.expected = SDL_UDEV_DEVICE_UNKNOWN,
/* SDL treats KEY_SLEEP as indicating a keyboard */
.expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY */
.ev = { 0x03 },
.keys = {
@@ -841,7 +842,8 @@ static const GuessTest guess_tests[] =
.vendor_id = 0x0000,
.product_id = 0x0001,
.version = 0x0000,
.expected = SDL_UDEV_DEVICE_UNKNOWN,
/* SDL treats KEY_POWER as indicating a keyboard */
.expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY */
.ev = { 0x03 },
.keys = {
@@ -856,7 +858,8 @@ static const GuessTest guess_tests[] =
.vendor_id = 0x0000,
.product_id = 0x0006,
.version = 0x0000,
.expected = SDL_UDEV_DEVICE_UNKNOWN,
/* SDL treats brightness control, etc. as keyboard keys */
.expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY */
.ev = { 0x03 },
.keys = {
@@ -873,7 +876,7 @@ static const GuessTest guess_tests[] =
.vendor_id = 0x17aa,
.product_id = 0x5054,
.version = 0x4101,
.expected = SDL_UDEV_DEVICE_UNKNOWN,
.expected = SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY */
.ev = { 0x03 },
.keys = {
@@ -911,9 +914,8 @@ static const GuessTest guess_tests[] =
.product_id = 0x6009,
/* For some reason the special keys like mute and wlan toggle
* show up here instead of, or in addition to, as part of
* the keyboard - so udev reports this as having keys too.
* SDL currently doesn't. */
.expected = SDL_UDEV_DEVICE_MOUSE,
* the keyboard - so both udev and SDL report this as having keys too. */
.expected = SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD,
/* SYN, KEY, REL, MSC, LED */
.ev = { 0x17, 0x00, 0x02 },
/* X, Y */
@@ -934,13 +936,24 @@ static const GuessTest guess_tests[] =
.expected = SDL_UDEV_DEVICE_UNKNOWN,
}
};
/* *INDENT-ON* */ /* clang-format on */
#if ULONG_MAX == 0xFFFFFFFFUL
# define SwapLongLE(X) SDL_SwapLE32(X)
#else
/* assume 64-bit */
# define SwapLongLE(X) SDL_SwapLE64(X)
#endif
/* The Linux kernel provides capability info in EVIOCGBIT and in /sys
* as an array of unsigned long in native byte order, rather than an array
* of bytes, an array of native-endian 32-bit words or an array of
* native-endian 64-bit words like you might have reasonably expected.
* The order of words in the array is always lowest-valued first: for
* instance, the first unsigned long in abs[] contains the bit representing
* absolute axis 0 (ABS_X).
*
* The constant arrays above provide test data in little-endian, because
* that's the easiest representation for hard-coding into a test like this.
* On a big-endian platform we need to byteswap it, one unsigned long at a
* time, to match what the kernel would produce. This requires us to choose
* an appropriate byteswapping function for the architecture's word size. */
SDL_COMPILE_TIME_ASSERT(sizeof_long, sizeof(unsigned long) == 4 || sizeof(unsigned long) == 8);
#define SwapLongLE(X) \
((sizeof(unsigned long) == 4) ? SDL_SwapLE32(X) : SDL_SwapLE64(X))
static int
run_test(void)
@@ -952,7 +965,8 @@ run_test(void)
const GuessTest *t = &guess_tests[i];
size_t j;
int actual;
struct {
struct
{
unsigned long ev[NBITS(EV_MAX)];
unsigned long abs[NBITS(ABS_MAX)];
unsigned long keys[NBITS(KEY_MAX)];
@@ -988,8 +1002,7 @@ run_test(void)
if (actual == t->expected) {
printf("\tOK\n");
}
else {
} else {
printf("\tExpected 0x%08x\n", t->expected);
for (j = 0; device_classes[j].code != 0; j++) {
@@ -1019,13 +1032,12 @@ static int
run_test(void)
{
printf("SDL compiled without evdev capability check.\n");
return 0;
return 1;
}
#endif
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
return run_test() ? 0 : 1;
}