Skip to content

Commit 2a506c8

Browse files
committed
SDL_hidapi.c: fix -Wundef failures due to HAVE_DRIVER_BACKEND check
(cherry picked from commit 7a34e14)
1 parent a455f02 commit 2a506c8

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/hidapi/SDL_hidapi.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,9 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL;
630630

631631
#ifdef SDL_JOYSTICK_HIDAPI_STEAMXBOX
632632
#define HAVE_DRIVER_BACKEND 1
633-
#else
634-
#define HAVE_DRIVER_BACKEND 0
635633
#endif
636634

637-
#if HAVE_DRIVER_BACKEND
635+
#ifdef HAVE_DRIVER_BACKEND
638636

639637
/* DRIVER HIDAPI Implementation */
640638

@@ -905,7 +903,7 @@ IsInWhitelist(Uint16 vendor, Uint16 product)
905903
return SDL_FALSE;
906904
}
907905

908-
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND
906+
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND)
909907
#define use_libusb_whitelist_default SDL_TRUE
910908
#else
911909
#define use_libusb_whitelist_default SDL_FALSE
@@ -951,7 +949,7 @@ static const struct hidapi_backend PLATFORM_Backend = {
951949
};
952950
#endif /* HAVE_PLATFORM_BACKEND */
953951

954-
#if HAVE_DRIVER_BACKEND
952+
#ifdef HAVE_DRIVER_BACKEND
955953
static const struct hidapi_backend DRIVER_Backend = {
956954
(void *)DRIVER_hid_write,
957955
(void *)DRIVER_hid_read_timeout,
@@ -993,7 +991,7 @@ struct SDL_hid_device_
993991
};
994992
static char device_magic;
995993

996-
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
994+
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
997995

998996
static SDL_hid_device *CreateHIDDeviceWrapper(void *device, const struct hidapi_backend *backend)
999997
{
@@ -1019,7 +1017,7 @@ static void DeleteHIDDeviceWrapper(SDL_hid_device *device)
10191017
}
10201018

10211019
#ifndef SDL_HIDAPI_DISABLED
1022-
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
1020+
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
10231021

10241022
#define COPY_IF_EXISTS(var) \
10251023
if (pSrc->var != NULL) { \
@@ -1249,12 +1247,12 @@ Uint32 SDL_hid_device_change_count(void)
12491247

12501248
struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id)
12511249
{
1252-
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
1250+
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
12531251
#ifdef HAVE_LIBUSB
12541252
struct SDL_hid_device_info *usb_devs = NULL;
12551253
struct SDL_hid_device_info *usb_dev;
12561254
#endif
1257-
#if HAVE_DRIVER_BACKEND
1255+
#ifdef HAVE_DRIVER_BACKEND
12581256
struct SDL_hid_device_info *driver_devs = NULL;
12591257
struct SDL_hid_device_info *driver_dev;
12601258
#endif
@@ -1309,7 +1307,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
13091307
}
13101308
#endif /* HAVE_LIBUSB */
13111309

1312-
#if HAVE_DRIVER_BACKEND
1310+
#ifdef HAVE_DRIVER_BACKEND
13131311
driver_devs = DRIVER_hid_enumerate(vendor_id, product_id);
13141312
for (driver_dev = driver_devs; driver_dev; driver_dev = driver_dev->next) {
13151313
new_dev = (struct SDL_hid_device_info *)SDL_malloc(sizeof(struct SDL_hid_device_info));
@@ -1347,7 +1345,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
13471345
}
13481346
}
13491347
#endif
1350-
#if HAVE_DRIVER_BACKEND
1348+
#ifdef HAVE_DRIVER_BACKEND
13511349
for (driver_dev = driver_devs; driver_dev; driver_dev = driver_dev->next) {
13521350
if (raw_dev->vendor_id == driver_dev->vendor_id &&
13531351
raw_dev->product_id == driver_dev->product_id &&
@@ -1412,7 +1410,7 @@ void SDL_hid_free_enumeration(struct SDL_hid_device_info *devs)
14121410

14131411
SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
14141412
{
1415-
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
1413+
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
14161414
void *pDevice = NULL;
14171415

14181416
if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
@@ -1428,7 +1426,7 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id
14281426
}
14291427
#endif /* HAVE_PLATFORM_BACKEND */
14301428

1431-
#if HAVE_DRIVER_BACKEND
1429+
#ifdef HAVE_DRIVER_BACKEND
14321430
pDevice = DRIVER_hid_open(vendor_id, product_id, serial_number);
14331431
if (pDevice != NULL) {
14341432
return CreateHIDDeviceWrapper(pDevice, &DRIVER_Backend);
@@ -1451,7 +1449,7 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id
14511449

14521450
SDL_hid_device *SDL_hid_open_path(const char *path, int bExclusive /* = false */)
14531451
{
1454-
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
1452+
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
14551453
void *pDevice = NULL;
14561454

14571455
if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
@@ -1467,7 +1465,7 @@ SDL_hid_device *SDL_hid_open_path(const char *path, int bExclusive /* = false */
14671465
}
14681466
#endif /* HAVE_PLATFORM_BACKEND */
14691467

1470-
#if HAVE_DRIVER_BACKEND
1468+
#ifdef HAVE_DRIVER_BACKEND
14711469
pDevice = DRIVER_hid_open_path(path, bExclusive);
14721470
if (pDevice != NULL) {
14731471
return CreateHIDDeviceWrapper(pDevice, &DRIVER_Backend);

0 commit comments

Comments
 (0)