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

(cherry picked from commit 6a2200823c to reduce conflicts merging between SDL2 and SDL3)
This commit is contained in:
Sylvain Becker
2022-11-27 17:38:43 +01:00
committed by Sam Lantinga
parent 0739d237ad
commit fb0ce375f0
386 changed files with 6103 additions and 4637 deletions

View File

@@ -37,7 +37,7 @@ main(int argc, char *argv[])
}
}
if(enable_haptic) {
if (enable_haptic) {
init_subsystems |= SDL_INIT_HAPTIC;
}
@@ -57,39 +57,31 @@ main(int argc, char *argv[])
*/
SDL_Log("There are %d joysticks at startup\n", SDL_NumJoysticks());
if (enable_haptic)
if (enable_haptic) {
SDL_Log("There are %d haptic devices at startup\n", SDL_NumHaptics());
}
while(keepGoing)
{
while (keepGoing) {
SDL_Event event;
while(SDL_PollEvent(&event))
{
while (SDL_PollEvent(&event)) {
switch(event.type)
{
case SDL_QUIT:
keepGoing = SDL_FALSE;
break;
case SDL_JOYDEVICEADDED:
if (joystick != NULL)
{
if (joystick != NULL) {
SDL_Log("Only one joystick supported by this test\n");
}
else
{
} else {
joystick = SDL_JoystickOpen(event.jdevice.which);
instance = SDL_JoystickInstanceID(joystick);
SDL_Log("Joy Added : %" SDL_PRIs32 " : %s\n", event.jdevice.which, SDL_JoystickName(joystick));
if (enable_haptic)
{
if (SDL_JoystickIsHaptic(joystick))
{
if (enable_haptic) {
if (SDL_JoystickIsHaptic(joystick)) {
haptic = SDL_HapticOpenFromJoystick(joystick);
if (haptic)
{
if (haptic) {
SDL_Log("Joy Haptic Opened\n");
if (SDL_HapticRumbleInit( haptic ) != 0)
{
if (SDL_HapticRumbleInit( haptic ) != 0) {
SDL_Log("Could not init Rumble!: %s\n", SDL_GetError());
SDL_HapticClose(haptic);
haptic = NULL;
@@ -97,21 +89,17 @@ main(int argc, char *argv[])
} else {
SDL_Log("Joy haptic open FAILED!: %s\n", SDL_GetError());
}
}
else
{
} else {
SDL_Log("No haptic found\n");
}
}
}
break;
case SDL_JOYDEVICEREMOVED:
if (instance == event.jdevice.which)
{
if (instance == event.jdevice.which) {
SDL_Log("Joy Removed: %" SDL_PRIs32 "\n", event.jdevice.which);
instance = -1;
if(enable_haptic && haptic)
{
if (enable_haptic && haptic) {
SDL_HapticClose(haptic);
haptic = NULL;
}
@@ -125,13 +113,13 @@ main(int argc, char *argv[])
/*
// SDL_Log("Axis Move: %d\n", event.jaxis.axis);
*/
if (enable_haptic)
if (enable_haptic) {
SDL_HapticRumblePlay(haptic, 0.25, 250);
}
break;
case SDL_JOYBUTTONDOWN:
SDL_Log("Button Press: %d\n", event.jbutton.button);
if(enable_haptic && haptic)
{
if (enable_haptic && haptic) {
SDL_HapticRumblePlay(haptic, 0.25, 250);
}
if (event.jbutton.button == 0) {