mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-05 23:10:58 +00:00
Cleanup add brace (#6545)
* Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line
This commit is contained in:
parent
4958dafdc3
commit
6a2200823c
387 changed files with 6094 additions and 4633 deletions
|
@ -164,7 +164,7 @@ SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list)
|
|||
spot = (char *)hint;
|
||||
}
|
||||
|
||||
if (!spot) {
|
||||
if (spot == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list)
|
|||
entry = (Uint16)SDL_strtol(spot, &spot, 0);
|
||||
entry <<= 16;
|
||||
spot = SDL_strstr(spot, "0x");
|
||||
if (!spot) {
|
||||
if (spot == NULL) {
|
||||
break;
|
||||
}
|
||||
entry |= (Uint16)SDL_strtol(spot, &spot, 0);
|
||||
|
@ -218,9 +218,9 @@ static SDL_bool HasSameOutput(SDL_ExtendedGameControllerBind *a, SDL_ExtendedGam
|
|||
}
|
||||
|
||||
if (a->outputType == SDL_CONTROLLER_BINDTYPE_AXIS) {
|
||||
return (a->output.axis.axis == b->output.axis.axis);
|
||||
return a->output.axis.axis == b->output.axis.axis;
|
||||
} else {
|
||||
return (a->output.button == b->output.button);
|
||||
return a->output.button == b->output.button;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ static void HandleJoystickAxis(SDL_GameController *gamecontroller, int axis, int
|
|||
}
|
||||
}
|
||||
|
||||
if (last_match && (!match || !HasSameOutput(last_match, match))) {
|
||||
if (last_match && (match == NULL || !HasSameOutput(last_match, match))) {
|
||||
/* Clear the last input that this axis generated */
|
||||
ResetOutput(gamecontroller, last_match);
|
||||
}
|
||||
|
@ -545,8 +545,7 @@ static ControllerMapping_t *SDL_CreateMappingForAndroidController(SDL_JoystickGU
|
|||
SDL_strlcat(mapping_string, "righttrigger:a5,", sizeof(mapping_string));
|
||||
}
|
||||
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping_string,
|
||||
&existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping_string, &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
}
|
||||
#endif /* __ANDROID__ */
|
||||
|
||||
|
@ -677,8 +676,7 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI
|
|||
}
|
||||
}
|
||||
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping_string,
|
||||
&existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping_string, &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -692,8 +690,7 @@ static ControllerMapping_t *SDL_CreateMappingForRAWINPUTController(SDL_JoystickG
|
|||
SDL_strlcpy(mapping_string, "none,*,", sizeof(mapping_string));
|
||||
SDL_strlcat(mapping_string, "a:b0,b:b1,x:b2,y:b3,back:b6,guide:b10,start:b7,leftstick:b8,rightstick:b9,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,", sizeof(mapping_string));
|
||||
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping_string,
|
||||
&existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping_string, &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -711,8 +708,7 @@ static ControllerMapping_t *SDL_CreateMappingForWGIController(SDL_JoystickGUID g
|
|||
SDL_strlcpy(mapping_string, "none,*,", sizeof(mapping_string));
|
||||
SDL_strlcat(mapping_string, "a:b0,b:b1,x:b2,y:b3,back:b6,start:b7,leftstick:b8,rightstick:b9,leftshoulder:b4,rightshoulder:b5,dpup:b10,dpdown:b12,dpleft:b13,dpright:b11,leftx:a1,lefty:a0~,rightx:a3,righty:a2~,lefttrigger:a4,righttrigger:a5,", sizeof(mapping_string));
|
||||
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping_string,
|
||||
&existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping_string, &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -804,7 +800,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG
|
|||
return s_pXInputMapping;
|
||||
}
|
||||
#endif
|
||||
if (!mapping) {
|
||||
if (mapping == NULL) {
|
||||
if (SDL_IsJoystickHIDAPI(guid)) {
|
||||
mapping = SDL_CreateMappingForHIDAPIController(guid);
|
||||
} else if (SDL_IsJoystickRAWINPUT(guid)) {
|
||||
|
@ -843,13 +839,14 @@ SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(const char *pchString
|
|||
++pchString;
|
||||
}
|
||||
|
||||
if (!pchString || !pchString[0]) {
|
||||
if (pchString == NULL || !pchString[0]) {
|
||||
return SDL_CONTROLLER_AXIS_INVALID;
|
||||
}
|
||||
|
||||
for (entry = 0; map_StringForControllerAxis[entry]; ++entry) {
|
||||
if (!SDL_strcasecmp(pchString, map_StringForControllerAxis[entry]))
|
||||
return (SDL_GameControllerAxis) entry;
|
||||
if (!SDL_strcasecmp(pchString, map_StringForControllerAxis[entry])) {
|
||||
return (SDL_GameControllerAxis)entry;
|
||||
}
|
||||
}
|
||||
return SDL_CONTROLLER_AXIS_INVALID;
|
||||
}
|
||||
|
@ -896,12 +893,14 @@ static const char* map_StringForControllerButton[] = {
|
|||
SDL_GameControllerButton SDL_GameControllerGetButtonFromString(const char *pchString)
|
||||
{
|
||||
int entry;
|
||||
if (!pchString || !pchString[0])
|
||||
if (pchString == NULL || !pchString[0]) {
|
||||
return SDL_CONTROLLER_BUTTON_INVALID;
|
||||
}
|
||||
|
||||
for (entry = 0; map_StringForControllerButton[entry]; ++entry) {
|
||||
if (SDL_strcasecmp(pchString, map_StringForControllerButton[entry]) == 0)
|
||||
return (SDL_GameControllerButton) entry;
|
||||
if (SDL_strcasecmp(pchString, map_StringForControllerButton[entry]) == 0) {
|
||||
return (SDL_GameControllerButton)entry;
|
||||
}
|
||||
}
|
||||
return SDL_CONTROLLER_BUTTON_INVALID;
|
||||
}
|
||||
|
@ -1110,7 +1109,7 @@ static char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping)
|
|||
const char *pFirstComma = SDL_strchr(pMapping, ',');
|
||||
if (pFirstComma) {
|
||||
char *pchGUID = SDL_malloc(pFirstComma - pMapping + 1);
|
||||
if (!pchGUID) {
|
||||
if (pchGUID == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1150,15 +1149,17 @@ static char *SDL_PrivateGetControllerNameFromMappingString(const char *pMapping)
|
|||
char *pchName;
|
||||
|
||||
pFirstComma = SDL_strchr(pMapping, ',');
|
||||
if (!pFirstComma)
|
||||
if (pFirstComma == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pSecondComma = SDL_strchr(pFirstComma + 1, ',');
|
||||
if (!pSecondComma)
|
||||
if (pSecondComma == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pchName = SDL_malloc(pSecondComma - pFirstComma);
|
||||
if (!pchName) {
|
||||
if (pchName == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1176,12 +1177,14 @@ static char *SDL_PrivateGetControllerMappingFromMappingString(const char *pMappi
|
|||
const char *pFirstComma, *pSecondComma;
|
||||
|
||||
pFirstComma = SDL_strchr(pMapping, ',');
|
||||
if (!pFirstComma)
|
||||
if (pFirstComma == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pSecondComma = SDL_strchr(pFirstComma + 1, ',');
|
||||
if (!pSecondComma)
|
||||
if (pSecondComma == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return SDL_strdup(pSecondComma + 1); /* mapping is everything after the 3rd comma */
|
||||
}
|
||||
|
@ -1221,13 +1224,13 @@ SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString,
|
|||
Uint16 crc;
|
||||
|
||||
pchName = SDL_PrivateGetControllerNameFromMappingString(mappingString);
|
||||
if (!pchName) {
|
||||
if (pchName == NULL) {
|
||||
SDL_SetError("Couldn't parse name from %s", mappingString);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pchMapping = SDL_PrivateGetControllerMappingFromMappingString(mappingString);
|
||||
if (!pchMapping) {
|
||||
if (pchMapping == NULL) {
|
||||
SDL_free(pchName);
|
||||
SDL_SetError("Couldn't parse %s", mappingString);
|
||||
return NULL;
|
||||
|
@ -1284,7 +1287,7 @@ SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString,
|
|||
*existing = SDL_TRUE;
|
||||
} else {
|
||||
pControllerMapping = SDL_malloc(sizeof(*pControllerMapping));
|
||||
if (!pControllerMapping) {
|
||||
if (pControllerMapping == NULL) {
|
||||
SDL_free(pchName);
|
||||
SDL_free(pchMapping);
|
||||
SDL_OutOfMemory();
|
||||
|
@ -1327,7 +1330,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const
|
|||
|
||||
mapping = SDL_PrivateGetControllerMappingForGUID(guid);
|
||||
#ifdef __LINUX__
|
||||
if (!mapping && name) {
|
||||
if (mapping == NULL && name) {
|
||||
if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) {
|
||||
/* The Linux driver xpad.c maps the wireless dpad to buttons */
|
||||
SDL_bool existing;
|
||||
|
@ -1340,7 +1343,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const
|
|||
}
|
||||
#endif /* __LINUX__ */
|
||||
|
||||
if (!mapping) {
|
||||
if (mapping == NULL) {
|
||||
mapping = s_pDefaultMapping;
|
||||
}
|
||||
return mapping;
|
||||
|
@ -1422,8 +1425,7 @@ static ControllerMapping_t *SDL_PrivateGenerateAutomaticControllerMapping(const
|
|||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "lefttrigger", &raw_map->lefttrigger);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "righttrigger", &raw_map->righttrigger);
|
||||
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping,
|
||||
&existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping, &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
}
|
||||
|
||||
static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
|
||||
|
@ -1437,13 +1439,13 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
|
|||
if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
|
||||
SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
|
||||
SDL_UnlockJoysticks();
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
name = SDL_JoystickNameForIndex(device_index);
|
||||
guid = SDL_JoystickGetDeviceGUID(device_index);
|
||||
mapping = SDL_PrivateGetControllerMappingForNameAndGUID(name, guid);
|
||||
if (!mapping) {
|
||||
if (mapping == NULL) {
|
||||
SDL_GamepadMapping raw_map;
|
||||
|
||||
SDL_zero(raw_map);
|
||||
|
@ -1540,7 +1542,7 @@ SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMap
|
|||
SDL_bool existing = SDL_FALSE;
|
||||
ControllerMapping_t *pControllerMapping;
|
||||
|
||||
if (!mappingString) {
|
||||
if (mappingString == NULL) {
|
||||
return SDL_InvalidParamError("mappingString");
|
||||
}
|
||||
|
||||
|
@ -1607,7 +1609,7 @@ SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMap
|
|||
#endif
|
||||
|
||||
pchGUID = SDL_PrivateGetControllerGUIDFromMappingString(mappingString);
|
||||
if (!pchGUID) {
|
||||
if (pchGUID == NULL) {
|
||||
return SDL_SetError("Couldn't parse GUID from %s", mappingString);
|
||||
}
|
||||
if (!SDL_strcasecmp(pchGUID, "default")) {
|
||||
|
@ -1619,7 +1621,7 @@ SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMap
|
|||
SDL_free(pchGUID);
|
||||
|
||||
pControllerMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority);
|
||||
if (!pControllerMapping) {
|
||||
if (pControllerMapping == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1687,7 +1689,7 @@ CreateMappingString(ControllerMapping_t *mapping, SDL_JoystickGUID guid)
|
|||
}
|
||||
|
||||
pMappingString = SDL_malloc(needed);
|
||||
if (!pMappingString) {
|
||||
if (pMappingString == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1774,8 +1776,9 @@ SDL_GameControllerLoadHints()
|
|||
char *pchNewLine = NULL;
|
||||
|
||||
pchNewLine = SDL_strchr(pUserMappings, '\n');
|
||||
if (pchNewLine)
|
||||
if (pchNewLine) {
|
||||
*pchNewLine = '\0';
|
||||
}
|
||||
|
||||
SDL_PrivateGameControllerAddMapping(pUserMappings, SDL_CONTROLLER_MAPPING_PRIORITY_USER);
|
||||
|
||||
|
@ -1837,7 +1840,7 @@ SDL_GameControllerInitMappings(void)
|
|||
SDL_AddHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT,
|
||||
SDL_GameControllerIgnoreDevicesExceptChanged, NULL);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1858,7 +1861,7 @@ SDL_GameControllerInit(void)
|
|||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1926,7 +1929,7 @@ SDL_GameControllerMappingForDeviceIndex(int joystick_index)
|
|||
/* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */
|
||||
needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1;
|
||||
pMappingString = SDL_malloc(needed);
|
||||
if (!pMappingString) {
|
||||
if (pMappingString == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_UnlockJoysticks();
|
||||
return NULL;
|
||||
|
@ -2081,14 +2084,14 @@ SDL_GameControllerOpen(int device_index)
|
|||
gamecontroller = gamecontrollerlist;
|
||||
++gamecontroller->ref_count;
|
||||
SDL_UnlockJoysticks();
|
||||
return (gamecontroller);
|
||||
return gamecontroller;
|
||||
}
|
||||
gamecontrollerlist = gamecontrollerlist->next;
|
||||
}
|
||||
|
||||
/* Find a controller mapping */
|
||||
pSupportedController = SDL_PrivateGetControllerMapping(device_index);
|
||||
if (!pSupportedController) {
|
||||
if (pSupportedController == NULL) {
|
||||
SDL_SetError("Couldn't find mapping for device (%d)", device_index);
|
||||
SDL_UnlockJoysticks();
|
||||
return NULL;
|
||||
|
@ -2142,7 +2145,7 @@ SDL_GameControllerOpen(int device_index)
|
|||
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
return (gamecontroller);
|
||||
return gamecontroller;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2373,7 +2376,7 @@ int SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_S
|
|||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
int i;
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2435,7 +2438,7 @@ SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_Sens
|
|||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
int i;
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
@ -2467,7 +2470,7 @@ SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontroller,
|
|||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
int i;
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2503,7 +2506,7 @@ SDL_GameControllerPath(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return SDL_JoystickPath(joystick);
|
||||
|
@ -2514,7 +2517,7 @@ SDL_GameControllerGetType(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return SDL_CONTROLLER_TYPE_UNKNOWN;
|
||||
}
|
||||
return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetGUID(joystick), SDL_JoystickName(joystick));
|
||||
|
@ -2525,7 +2528,7 @@ SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return -1;
|
||||
}
|
||||
return SDL_JoystickGetPlayerIndex(joystick);
|
||||
|
@ -2539,7 +2542,7 @@ SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return;
|
||||
}
|
||||
SDL_JoystickSetPlayerIndex(joystick, player_index);
|
||||
|
@ -2550,7 +2553,7 @@ SDL_GameControllerGetVendor(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return SDL_JoystickGetVendor(joystick);
|
||||
|
@ -2561,7 +2564,7 @@ SDL_GameControllerGetProduct(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return SDL_JoystickGetProduct(joystick);
|
||||
|
@ -2572,7 +2575,7 @@ SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return SDL_JoystickGetProductVersion(joystick);
|
||||
|
@ -2583,7 +2586,7 @@ SDL_GameControllerGetFirmwareVersion(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return SDL_JoystickGetFirmwareVersion(joystick);
|
||||
|
@ -2594,7 +2597,7 @@ SDL_GameControllerGetSerial(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return SDL_JoystickGetSerial(joystick);
|
||||
|
@ -2670,8 +2673,9 @@ SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController
|
|||
|
||||
CHECK_GAMECONTROLLER_MAGIC(gamecontroller, bind);
|
||||
|
||||
if (axis == SDL_CONTROLLER_AXIS_INVALID)
|
||||
if (axis == SDL_CONTROLLER_AXIS_INVALID) {
|
||||
return bind;
|
||||
}
|
||||
|
||||
for (i = 0; i < gamecontroller->num_bindings; ++i) {
|
||||
SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i];
|
||||
|
@ -2704,8 +2708,9 @@ SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameControll
|
|||
|
||||
CHECK_GAMECONTROLLER_MAGIC(gamecontroller, bind);
|
||||
|
||||
if (button == SDL_CONTROLLER_BUTTON_INVALID)
|
||||
if (button == SDL_CONTROLLER_BUTTON_INVALID) {
|
||||
return bind;
|
||||
}
|
||||
|
||||
for (i = 0; i < gamecontroller->num_bindings; ++i) {
|
||||
SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i];
|
||||
|
@ -2731,7 +2736,7 @@ SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequenc
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return -1;
|
||||
}
|
||||
return SDL_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms);
|
||||
|
@ -2742,7 +2747,7 @@ SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return -1;
|
||||
}
|
||||
return SDL_JoystickRumbleTriggers(joystick, left_rumble, right_rumble, duration_ms);
|
||||
|
@ -2753,7 +2758,7 @@ SDL_GameControllerHasLED(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_JoystickHasLED(joystick);
|
||||
|
@ -2764,7 +2769,7 @@ SDL_GameControllerHasRumble(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_JoystickHasRumble(joystick);
|
||||
|
@ -2775,7 +2780,7 @@ SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_JoystickHasRumbleTriggers(joystick);
|
||||
|
@ -2786,7 +2791,7 @@ SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 gr
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return -1;
|
||||
}
|
||||
return SDL_JoystickSetLED(joystick, red, green, blue);
|
||||
|
@ -2797,7 +2802,7 @@ SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *dat
|
|||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
|
||||
if (!joystick) {
|
||||
if (joystick == NULL) {
|
||||
return -1;
|
||||
}
|
||||
return SDL_JoystickSendEffect(joystick, data, size);
|
||||
|
@ -2808,8 +2813,9 @@ SDL_GameControllerClose(SDL_GameController *gamecontroller)
|
|||
{
|
||||
SDL_GameController *gamecontrollerlist, *gamecontrollerlistprev;
|
||||
|
||||
if (!gamecontroller || gamecontroller->magic != &gamecontroller_magic)
|
||||
if (gamecontroller == NULL || gamecontroller->magic != &gamecontroller_magic) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_LockJoysticks();
|
||||
|
||||
|
@ -2913,7 +2919,7 @@ SDL_PrivateGameControllerAxis(SDL_GameController *gamecontroller, SDL_GameContro
|
|||
posted = SDL_PushEvent(&event) == 1;
|
||||
}
|
||||
#endif /* !SDL_EVENTS_DISABLED */
|
||||
return (posted);
|
||||
return posted;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2942,7 +2948,7 @@ SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, SDL_GameCont
|
|||
break;
|
||||
default:
|
||||
/* Invalid state -- bail */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif /* !SDL_EVENTS_DISABLED */
|
||||
|
||||
|
@ -2953,12 +2959,12 @@ SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, SDL_GameCont
|
|||
|
||||
if (gamecontroller->joystick->delayed_guide_button) {
|
||||
/* Skip duplicate press */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (!SDL_TICKS_PASSED(now, gamecontroller->guide_button_down+SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS)) {
|
||||
gamecontroller->joystick->delayed_guide_button = SDL_TRUE;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
gamecontroller->joystick->delayed_guide_button = SDL_FALSE;
|
||||
}
|
||||
|
@ -2974,7 +2980,7 @@ SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, SDL_GameCont
|
|||
posted = SDL_PushEvent(&event) == 1;
|
||||
}
|
||||
#endif /* !SDL_EVENTS_DISABLED */
|
||||
return (posted);
|
||||
return posted;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3009,7 +3015,7 @@ SDL_GameControllerEventState(int state)
|
|||
}
|
||||
break;
|
||||
}
|
||||
return (state);
|
||||
return state;
|
||||
#endif /* SDL_EVENTS_DISABLED */
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue