Pointer as bool (libsdl-org#7214)
This commit is contained in:
@@ -135,7 +135,7 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device)
|
||||
#endif
|
||||
|
||||
ctx = (SDL_DriverGameCube_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device
|
||||
}
|
||||
|
||||
joystick = SDL_GetJoystickFromInstanceID(ctx->joysticks[i]);
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
/* Hasn't been opened yet, skip */
|
||||
return;
|
||||
}
|
||||
@@ -322,7 +322,7 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device
|
||||
joystick = SDL_GetJoystickFromInstanceID(ctx->joysticks[i]);
|
||||
|
||||
/* Hasn't been opened yet, skip */
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -72,7 +72,7 @@ static SDL_bool HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_DriverLuna_Context *ctx;
|
||||
|
||||
ctx = (SDL_DriverLuna_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -393,7 +393,7 @@ static SDL_bool HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
#ifdef DEBUG_LUNA_PROTOCOL
|
||||
HIDAPI_DumpPacket("Amazon Luna packet: size = %d", data, size);
|
||||
#endif
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device)
|
||||
}
|
||||
|
||||
ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ static void HIDAPI_DriverPS3_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL
|
||||
{
|
||||
SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context;
|
||||
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -491,7 +491,7 @@ static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
#ifdef DEBUG_PS3_PROTOCOL
|
||||
HIDAPI_DumpPacket("PS3 packet: size = %d", data, size);
|
||||
#endif
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -604,7 +604,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_DriverPS3_Context *ctx;
|
||||
|
||||
ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -932,7 +932,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *devic
|
||||
#ifdef DEBUG_PS3_PROTOCOL
|
||||
HIDAPI_DumpPacket("PS3 packet: size = %d", data, size);
|
||||
#endif
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMEPAD;
|
||||
|
||||
ctx = (SDL_DriverPS4_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -1207,7 +1207,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
++packet_count;
|
||||
ctx->last_packet = now;
|
||||
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMEPAD;
|
||||
|
||||
ctx = (SDL_DriverPS5_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -1476,7 +1476,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
++packet_count;
|
||||
ctx->last_packet = now;
|
||||
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ int SDL_HIDAPI_SendRumbleWithCallbackAndUnlock(SDL_HIDAPI_Device *device, const
|
||||
}
|
||||
|
||||
request = (SDL_HIDAPI_RumbleRequest *)SDL_calloc(1, sizeof(*request));
|
||||
if (request == NULL) {
|
||||
if (!request) {
|
||||
SDL_HIDAPI_UnlockRumble();
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ static SDL_bool HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_DriverShield_Context *ctx;
|
||||
|
||||
ctx = (SDL_DriverShield_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -489,7 +489,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
/* Byte 0 is HID report ID */
|
||||
switch (data[0]) {
|
||||
case k_ShieldReportIdControllerState:
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
if (size == 16) {
|
||||
@@ -499,7 +499,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
}
|
||||
break;
|
||||
case k_ShieldReportIdControllerTouch:
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
HIDAPI_DriverShield_HandleTouchPacketV103(joystick, ctx, data, size);
|
||||
|
||||
@@ -69,7 +69,7 @@ static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_DriverStadia_Context *ctx;
|
||||
|
||||
ctx = (SDL_DriverStadia_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ static SDL_bool HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
#ifdef DEBUG_STADIA_PROTOCOL
|
||||
HIDAPI_DumpPacket("Google Stadia packet: size = %d", data, size);
|
||||
#endif
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -973,7 +973,7 @@ static SDL_bool HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_DriverSteam_Context *ctx;
|
||||
|
||||
ctx = (SDL_DriverSteam_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -1105,7 +1105,7 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
break;
|
||||
}
|
||||
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -438,7 +438,7 @@ static SDL_bool WriteSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommand
|
||||
SwitchSubcommandInputPacket_t *reply = NULL;
|
||||
int nTries;
|
||||
|
||||
for (nTries = 1; reply == NULL && nTries <= ctx->m_nMaxWriteAttempts; ++nTries) {
|
||||
for (nTries = 1; !reply && nTries <= ctx->m_nMaxWriteAttempts; ++nTries) {
|
||||
SwitchSubcommandOutputPacket_t commandPacket;
|
||||
ConstructSubcommand(ctx, ucCommandID, pBuf, ucLen, &commandPacket);
|
||||
|
||||
@@ -462,7 +462,7 @@ static SDL_bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprieta
|
||||
for (nTries = 1; nTries <= ctx->m_nMaxWriteAttempts; ++nTries) {
|
||||
SwitchProprietaryOutputPacket_t packet;
|
||||
|
||||
if ((pBuf == NULL && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData)) {
|
||||
if ((!pBuf && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -1272,7 +1272,7 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_DriverSwitch_Context *ctx;
|
||||
|
||||
ctx = (SDL_DriverSwitch_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -2203,7 +2203,7 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
++packet_count;
|
||||
ctx->m_ulLastInput = now;
|
||||
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ static SDL_bool ReadInputSync(SDL_DriverWii_Context *ctx, EWiiInputReportIDs exp
|
||||
int nRead = 0;
|
||||
while ((nRead = ReadInput(ctx)) != -1) {
|
||||
if (nRead > 0) {
|
||||
if (ctx->m_rgucReadBuffer[0] == expectedID && (isMine == NULL || isMine(ctx->m_rgucReadBuffer))) {
|
||||
if (ctx->m_rgucReadBuffer[0] == expectedID && (!isMine || isMine(ctx->m_rgucReadBuffer))) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
} else {
|
||||
@@ -725,7 +725,7 @@ static SDL_bool HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_DriverWii_Context *ctx;
|
||||
|
||||
ctx = (SDL_DriverWii_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ static SDL_bool HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_DriverXbox360_Context *ctx;
|
||||
|
||||
ctx = (SDL_DriverXbox360_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -329,7 +329,7 @@ static SDL_bool HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
#ifdef DEBUG_XBOX_PROTOCOL
|
||||
HIDAPI_DumpPacket("Xbox 360 packet: size = %d", data, size);
|
||||
#endif
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device)
|
||||
HIDAPI_SetDeviceName(device, "Xbox 360 Wireless Controller");
|
||||
|
||||
ctx = (SDL_DriverXbox360W_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ static void HIDAPI_DriverXbox360W_SetDevicePlayerIndex(SDL_HIDAPI_Device *device
|
||||
{
|
||||
SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context;
|
||||
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ static SDL_bool HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_DriverXboxOne_Context *ctx;
|
||||
|
||||
ctx = (SDL_DriverXboxOne_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -1401,7 +1401,7 @@ static SDL_bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXbox
|
||||
/* Ignore this packet */
|
||||
break;
|
||||
case GIP_CMD_VIRTUAL_KEY:
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
HIDAPI_DriverXboxOne_HandleModePacket(joystick, ctx, data, size);
|
||||
@@ -1436,13 +1436,13 @@ static SDL_bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXbox
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
HIDAPI_DriverXboxOne_HandleStatePacket(joystick, ctx, data, size);
|
||||
break;
|
||||
case GIP_CMD_UNMAPPED_STATE:
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(joystick, ctx, data, size);
|
||||
@@ -1568,7 +1568,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
if (device->is_bluetooth) {
|
||||
switch (data[0]) {
|
||||
case 0x01:
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
if (size >= 16) {
|
||||
@@ -1580,13 +1580,13 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
}
|
||||
break;
|
||||
case 0x02:
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(joystick, ctx, data, size);
|
||||
break;
|
||||
case 0x04:
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(joystick, ctx, data, size);
|
||||
|
||||
@@ -99,7 +99,7 @@ static char *HIDAPI_ConvertString(const wchar_t *wide_string)
|
||||
|
||||
if (wide_string) {
|
||||
string = SDL_iconv_string("UTF-8", "WCHAR_T", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t));
|
||||
if (string == NULL) {
|
||||
if (!string) {
|
||||
switch (sizeof(wchar_t)) {
|
||||
case 2:
|
||||
string = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t));
|
||||
@@ -608,7 +608,7 @@ static int HIDAPI_JoystickInit(void)
|
||||
static SDL_bool HIDAPI_AddJoystickInstanceToDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID)
|
||||
{
|
||||
SDL_JoystickID *joysticks = (SDL_JoystickID *)SDL_realloc(device->joysticks, (device->num_joysticks + 1) * sizeof(*device->joysticks));
|
||||
if (joysticks == NULL) {
|
||||
if (!joysticks) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -730,7 +730,7 @@ SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial)
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (serial == NULL) {
|
||||
if (!serial) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -756,7 +756,7 @@ void HIDAPI_DisconnectBluetoothDevice(const char *serial)
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (serial == NULL) {
|
||||
if (!serial) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -866,7 +866,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
|
||||
}
|
||||
|
||||
device = (SDL_HIDAPI_Device *)SDL_calloc(1, sizeof(*device));
|
||||
if (device == NULL) {
|
||||
if (!device) {
|
||||
return NULL;
|
||||
}
|
||||
device->magic = &SDL_HIDAPI_device_magic;
|
||||
@@ -950,7 +950,9 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
|
||||
}
|
||||
|
||||
#ifdef DEBUG_HIDAPI
|
||||
SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED");
|
||||
SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version,
|
||||
device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage,
|
||||
device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED");
|
||||
#endif
|
||||
|
||||
return device;
|
||||
@@ -964,7 +966,9 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
#ifdef DEBUG_HIDAPI
|
||||
SDL_Log("Removing HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED");
|
||||
SDL_Log("Removing HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version,
|
||||
device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage,
|
||||
device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED");
|
||||
#endif
|
||||
|
||||
for (curr = SDL_HIDAPI_devices, last = NULL; curr; last = curr, curr = curr->next) {
|
||||
@@ -1038,7 +1042,7 @@ static SDL_bool HIDAPI_CreateCombinedJoyCons(void)
|
||||
if (joycons[0] && joycons[1]) {
|
||||
SDL_hid_device_info info;
|
||||
SDL_HIDAPI_Device **children = (SDL_HIDAPI_Device **)SDL_malloc(2 * sizeof(SDL_HIDAPI_Device *));
|
||||
if (children == NULL) {
|
||||
if (!children) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
children[0] = joycons[0];
|
||||
@@ -1423,13 +1427,13 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (device == NULL || !device->driver) {
|
||||
if (!device || !device->driver) {
|
||||
/* This should never happen - validated before being called */
|
||||
return SDL_SetError("Couldn't find HIDAPI device at index %d\n", device_index);
|
||||
}
|
||||
|
||||
hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata));
|
||||
if (hwdata == NULL) {
|
||||
if (!hwdata) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
hwdata->device = device;
|
||||
|
||||
Reference in New Issue
Block a user