mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-28 01:21:35 +00:00
[SDL2] pointer boolean (#8523)
This commit is contained in:
@@ -140,7 +140,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;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device
|
||||
}
|
||||
|
||||
joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]);
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
/* Hasn't been opened yet, skip */
|
||||
return;
|
||||
}
|
||||
@@ -323,7 +323,7 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device
|
||||
joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]);
|
||||
|
||||
/* Hasn't been opened yet, skip */
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -75,7 +75,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,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;
|
||||
}
|
||||
@@ -220,7 +220,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;
|
||||
}
|
||||
|
||||
@@ -494,7 +494,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;
|
||||
}
|
||||
|
||||
@@ -606,7 +606,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;
|
||||
}
|
||||
@@ -924,7 +924,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
|
||||
|
||||
ctx = (SDL_DriverPS4_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -1145,7 +1145,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
++packet_count;
|
||||
ctx->last_packet = now;
|
||||
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||
SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
|
||||
|
||||
ctx = (SDL_DriverPS5_Context *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -1415,7 +1415,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
++packet_count;
|
||||
ctx->last_packet = now;
|
||||
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -216,7 +216,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();
|
||||
}
|
||||
|
||||
@@ -118,7 +118,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);
|
||||
|
||||
@@ -72,7 +72,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;
|
||||
}
|
||||
@@ -288,7 +288,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -977,7 +977,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;
|
||||
}
|
||||
@@ -1109,7 +1109,7 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
break;
|
||||
}
|
||||
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -444,7 +444,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);
|
||||
|
||||
@@ -468,7 +468,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;
|
||||
}
|
||||
|
||||
@@ -1278,7 +1278,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;
|
||||
}
|
||||
@@ -2168,7 +2168,7 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
++packet_count;
|
||||
ctx->m_unLastInput = now;
|
||||
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -236,7 +236,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 {
|
||||
@@ -733,7 +733,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;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,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;
|
||||
}
|
||||
@@ -332,7 +332,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,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;
|
||||
}
|
||||
@@ -162,7 +162,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +368,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;
|
||||
}
|
||||
@@ -1159,7 +1159,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
if (ctx->bluetooth) {
|
||||
switch (data[0]) {
|
||||
case 0x01:
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
if (size >= 16) {
|
||||
@@ -1171,13 +1171,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);
|
||||
@@ -1225,7 +1225,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
break;
|
||||
case 0x03:
|
||||
/* Controller status update */
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
/* We actually want to handle this packet any time it arrives */
|
||||
/*break;*/
|
||||
}
|
||||
@@ -1238,13 +1238,13 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
/* Unknown chatty controller information, sent by both sides */
|
||||
break;
|
||||
case 0x07:
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
HIDAPI_DriverXboxOne_HandleModePacket(joystick, ctx, data, size);
|
||||
break;
|
||||
case 0x0C:
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(joystick, ctx, data, size);
|
||||
@@ -1259,7 +1259,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
The controller sends that in response to this request:
|
||||
0x1E 0x30 0x07 0x01 0x04
|
||||
*/
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
#ifdef SET_SERIAL_AFTER_OPEN
|
||||
@@ -1278,7 +1278,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
if (joystick == NULL) {
|
||||
if (!joystick) {
|
||||
break;
|
||||
}
|
||||
HIDAPI_DriverXboxOne_HandleStatePacket(joystick, ctx, data, size);
|
||||
|
||||
@@ -104,7 +104,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));
|
||||
@@ -612,7 +612,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;
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial)
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (serial == NULL) {
|
||||
if (!serial) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -758,7 +758,7 @@ void HIDAPI_DisconnectBluetoothDevice(const char *serial)
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (serial == NULL) {
|
||||
if (!serial) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -867,7 +867,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;
|
||||
@@ -946,7 +946,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;
|
||||
@@ -960,7 +962,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) {
|
||||
@@ -1034,7 +1038,7 @@ static SDL_bool HIDAPI_CreateCombinedJoyCons()
|
||||
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];
|
||||
@@ -1419,13 +1423,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