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

(cherry picked from commit 5750bcb174)
This commit is contained in:
Sam Lantinga 2022-11-30 12:51:59 -08:00
parent 5c4bc807f7
commit b8d85c6939
764 changed files with 50598 additions and 54407 deletions

View file

@ -48,8 +48,7 @@ IsDeviceIndexValid(int device_index)
return device_index >= 0 && device_index < N3DS_SENSOR_COUNT;
}
static int
N3DS_SensorInit(void)
static int N3DS_SensorInit(void)
{
if (InitN3DSServices() < 0) {
return SDL_SetError("Failed to initialise N3DS services");
@ -79,19 +78,16 @@ InitN3DSServices(void)
return 0;
}
static int
N3DS_SensorGetCount(void)
static int N3DS_SensorGetCount(void)
{
return N3DS_SENSOR_COUNT;
}
static void
N3DS_SensorDetect(void)
static void N3DS_SensorDetect(void)
{
}
static const char *
N3DS_SensorGetDeviceName(int device_index)
static const char *N3DS_SensorGetDeviceName(int device_index)
{
if (IsDeviceIndexValid(device_index)) {
switch (N3DS_sensors[device_index].type) {
@ -107,8 +103,7 @@ N3DS_SensorGetDeviceName(int device_index)
return NULL;
}
static SDL_SensorType
N3DS_SensorGetDeviceType(int device_index)
static SDL_SensorType N3DS_SensorGetDeviceType(int device_index)
{
if (IsDeviceIndexValid(device_index)) {
return N3DS_sensors[device_index].type;
@ -116,14 +111,12 @@ N3DS_SensorGetDeviceType(int device_index)
return SDL_SENSOR_INVALID;
}
static int
N3DS_SensorGetDeviceNonPortableType(int device_index)
static int N3DS_SensorGetDeviceNonPortableType(int device_index)
{
return (int) N3DS_SensorGetDeviceType(device_index);
return (int)N3DS_SensorGetDeviceType(device_index);
}
static SDL_SensorID
N3DS_SensorGetDeviceInstanceID(int device_index)
static SDL_SensorID N3DS_SensorGetDeviceInstanceID(int device_index)
{
if (IsDeviceIndexValid(device_index)) {
return N3DS_sensors[device_index].instance_id;
@ -131,14 +124,12 @@ N3DS_SensorGetDeviceInstanceID(int device_index)
return -1;
}
static int
N3DS_SensorOpen(SDL_Sensor *sensor, int device_index)
static int N3DS_SensorOpen(SDL_Sensor *sensor, int device_index)
{
return 0;
}
static void
N3DS_SensorUpdate(SDL_Sensor *sensor)
static void N3DS_SensorUpdate(SDL_Sensor *sensor)
{
switch (sensor->type) {
case SDL_SENSOR_ACCEL:
@ -162,9 +153,9 @@ UpdateN3DSAccelerometer(SDL_Sensor *sensor)
hidAccelRead(&current_state);
if (SDL_memcmp(&previous_state, &current_state, sizeof(accelVector)) != 0) {
SDL_memcpy(&previous_state, &current_state, sizeof(accelVector));
data[0] = (float) current_state.x * SDL_STANDARD_GRAVITY;
data[1] = (float) current_state.y * SDL_STANDARD_GRAVITY;
data[2] = (float) current_state.z * SDL_STANDARD_GRAVITY;
data[0] = (float)current_state.x * SDL_STANDARD_GRAVITY;
data[1] = (float)current_state.y * SDL_STANDARD_GRAVITY;
data[2] = (float)current_state.z * SDL_STANDARD_GRAVITY;
SDL_PrivateSensorUpdate(sensor, 0, data, sizeof data);
}
}
@ -179,20 +170,18 @@ UpdateN3DSGyroscope(SDL_Sensor *sensor)
hidGyroRead(&current_state);
if (SDL_memcmp(&previous_state, &current_state, sizeof(angularRate)) != 0) {
SDL_memcpy(&previous_state, &current_state, sizeof(angularRate));
data[0] = (float) current_state.x;
data[1] = (float) current_state.y;
data[2] = (float) current_state.z;
data[0] = (float)current_state.x;
data[1] = (float)current_state.y;
data[2] = (float)current_state.z;
SDL_PrivateSensorUpdate(sensor, 0, data, sizeof data);
}
}
static void
N3DS_SensorClose(SDL_Sensor *sensor)
static void N3DS_SensorClose(SDL_Sensor *sensor)
{
}
static void
N3DS_SensorQuit(void)
static void N3DS_SensorQuit(void)
{
HIDUSER_DisableGyroscope();
HIDUSER_DisableAccelerometer();