Update for SDL3 coding style (#6717)

I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
This commit is contained in:
Sam Lantinga
2022-11-30 12:51:59 -08:00
committed by GitHub
parent 14b902faca
commit 5750bcb174
781 changed files with 51659 additions and 55763 deletions

View File

@@ -40,9 +40,7 @@ extern "C" {
static SDL_bool s_bXInputEnabled = SDL_TRUE;
static char *s_arrXInputDevicePath[XUSER_MAX_COUNT];
static SDL_bool
SDL_XInputUseOldJoystickMapping()
static SDL_bool SDL_XInputUseOldJoystickMapping()
{
#ifdef __WINRT__
/* TODO: remove this __WINRT__ block, but only after integrating with UWP/WinRT's HID API */
@@ -64,8 +62,7 @@ SDL_bool SDL_XINPUT_Enabled(void)
return s_bXInputEnabled;
}
int
SDL_XINPUT_JoystickInit(void)
int SDL_XINPUT_JoystickInit(void)
{
s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE);
@@ -77,13 +74,12 @@ SDL_XINPUT_JoystickInit(void)
#endif
if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) {
s_bXInputEnabled = SDL_FALSE; /* oh well. */
s_bXInputEnabled = SDL_FALSE; /* oh well. */
}
return 0;
}
static const char *
GetXInputName(const Uint8 userid, BYTE SubType)
static const char *GetXInputName(const Uint8 userid, BYTE SubType)
{
static char name[32];
@@ -128,15 +124,14 @@ GetXInputName(const Uint8 userid, BYTE SubType)
/* We can't really tell what device is being used for XInput, but we can guess
and we'll be correct for the case where only one device is connected.
*/
static void
GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion)
static void GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion)
{
#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* TODO: remove this ifndef __WINRT__ block, but only after integrating with UWP/WinRT's HID API */
PRAWINPUTDEVICELIST devices = NULL;
UINT i, j, device_count = 0;
if ((GetRawInputDeviceList(NULL, &device_count, sizeof(RAWINPUTDEVICELIST)) == -1) || (!device_count)) {
return; /* oh well. */
return; /* oh well. */
}
devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * device_count);
@@ -146,7 +141,7 @@ GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion)
if (GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST)) == -1) {
SDL_free(devices);
return; /* oh well. */
return; /* oh well. */
}
/* First see if we have a cached entry for this index */
@@ -229,7 +224,7 @@ GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion)
}
}
SDL_free(devices);
#endif /* !__WINRT__ */
#endif /* !__WINRT__ */
/* The device wasn't in the raw HID device list, it's probably Bluetooth */
*pVID = 0x045e; /* Microsoft */
@@ -237,8 +232,7 @@ GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion)
*pVersion = 0;
}
static void
AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
{
Uint16 vendor = 0;
Uint16 product = 0;
@@ -265,7 +259,7 @@ AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
pNewJoystick->pNext = SYS_Joystick;
SYS_Joystick = pNewJoystick;
return; /* already in the list. */
return; /* already in the list. */
}
pPrevJoystick = pNewJoystick;
@@ -317,8 +311,7 @@ AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
WINDOWS_AddJoystickDevice(pNewJoystick);
}
static void
DelXInputDevice(Uint8 userid)
static void DelXInputDevice(Uint8 userid)
{
if (s_arrXInputDevicePath[userid]) {
SDL_free(s_arrXInputDevicePath[userid]);
@@ -326,8 +319,7 @@ DelXInputDevice(Uint8 userid)
}
}
void
SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
{
int iuserid;
@@ -359,8 +351,7 @@ SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
}
}
int
SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice)
int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice)
{
const Uint8 userId = joystickdevice->XInputUserId;
XINPUT_CAPABILITIES capabilities;
@@ -394,8 +385,7 @@ SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde
return 0;
}
static void
UpdateXInputJoystickBatteryInformation(SDL_Joystick * joystick, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
static void UpdateXInputJoystickBatteryInformation(SDL_Joystick *joystick, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
{
if (pBatteryInformation->BatteryType != BATTERY_TYPE_UNKNOWN) {
SDL_JoystickPowerLevel ePowerLevel = SDL_JOYSTICK_POWER_UNKNOWN;
@@ -423,8 +413,7 @@ UpdateXInputJoystickBatteryInformation(SDL_Joystick * joystick, XINPUT_BATTERY_I
}
}
static void
UpdateXInputJoystickState_OLD(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
static void UpdateXInputJoystickState_OLD(SDL_Joystick *joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
{
static WORD s_XInputButtons[] = {
XINPUT_GAMEPAD_DPAD_UP, XINPUT_GAMEPAD_DPAD_DOWN, XINPUT_GAMEPAD_DPAD_LEFT, XINPUT_GAMEPAD_DPAD_RIGHT,
@@ -450,8 +439,7 @@ UpdateXInputJoystickState_OLD(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputS
UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation);
}
static void
UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
{
static WORD s_XInputButtons[] = {
XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, XINPUT_GAMEPAD_X, XINPUT_GAMEPAD_Y,
@@ -491,8 +479,7 @@ UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState
UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation);
}
int
SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
int SDL_XINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
XINPUT_VIBRATION XVibration;
@@ -509,13 +496,12 @@ SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble,
}
Uint32
SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick * joystick)
SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return SDL_JOYCAP_RUMBLE;
}
void
SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick)
{
HRESULT result;
XINPUT_STATE_EX XInputState;
@@ -551,13 +537,11 @@ SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
#endif
}
void
SDL_XINPUT_JoystickClose(SDL_Joystick * joystick)
void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick)
{
}
void
SDL_XINPUT_JoystickQuit(void)
void SDL_XINPUT_JoystickQuit(void)
{
if (s_bXInputEnabled) {
WIN_UnloadXInputDLL();
@@ -578,47 +562,40 @@ SDL_bool SDL_XINPUT_Enabled(void)
return SDL_FALSE;
}
int
SDL_XINPUT_JoystickInit(void)
int SDL_XINPUT_JoystickInit(void)
{
return 0;
}
void
SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
{
}
int
SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice)
int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice)
{
return SDL_Unsupported();
}
int
SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
int SDL_XINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
return SDL_Unsupported();
}
Uint32
SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick * joystick)
SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return 0;
}
void
SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick)
{
}
void
SDL_XINPUT_JoystickClose(SDL_Joystick * joystick)
void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick)
{
}
void
SDL_XINPUT_JoystickQuit(void)
void SDL_XINPUT_JoystickQuit(void)
{
}