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

@@ -26,5 +26,4 @@ struct sensor_hwdata
float data[3];
};
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -42,8 +42,7 @@ static CMMotionManager *SDL_motion_manager;
static SDL_CoreMotionSensor *SDL_sensors;
static int SDL_sensors_count;
static int
SDL_COREMOTION_SensorInit(void)
static int SDL_COREMOTION_SensorInit(void)
{
int i, sensors_count = 0;
@@ -80,19 +79,16 @@ SDL_COREMOTION_SensorInit(void)
return 0;
}
static int
SDL_COREMOTION_SensorGetCount(void)
static int SDL_COREMOTION_SensorGetCount(void)
{
return SDL_sensors_count;
}
static void
SDL_COREMOTION_SensorDetect(void)
static void SDL_COREMOTION_SensorDetect(void)
{
}
static const char *
SDL_COREMOTION_SensorGetDeviceName(int device_index)
static const char *SDL_COREMOTION_SensorGetDeviceName(int device_index)
{
switch (SDL_sensors[device_index].type) {
case SDL_SENSOR_ACCEL:
@@ -104,26 +100,22 @@ SDL_COREMOTION_SensorGetDeviceName(int device_index)
}
}
static SDL_SensorType
SDL_COREMOTION_SensorGetDeviceType(int device_index)
static SDL_SensorType SDL_COREMOTION_SensorGetDeviceType(int device_index)
{
return SDL_sensors[device_index].type;
}
static int
SDL_COREMOTION_SensorGetDeviceNonPortableType(int device_index)
static int SDL_COREMOTION_SensorGetDeviceNonPortableType(int device_index)
{
return SDL_sensors[device_index].type;
}
static SDL_SensorID
SDL_COREMOTION_SensorGetDeviceInstanceID(int device_index)
static SDL_SensorID SDL_COREMOTION_SensorGetDeviceInstanceID(int device_index)
{
return SDL_sensors[device_index].instance_id;
}
static int
SDL_COREMOTION_SensorOpen(SDL_Sensor *sensor, int device_index)
static int SDL_COREMOTION_SensorOpen(SDL_Sensor *sensor, int device_index)
{
struct sensor_hwdata *hwdata;
@@ -133,8 +125,7 @@ SDL_COREMOTION_SensorOpen(SDL_Sensor *sensor, int device_index)
}
sensor->hwdata = hwdata;
switch (sensor->type)
{
switch (sensor->type) {
case SDL_SENSOR_ACCEL:
[SDL_motion_manager startAccelerometerUpdates];
break;
@@ -146,55 +137,49 @@ SDL_COREMOTION_SensorOpen(SDL_Sensor *sensor, int device_index)
}
return 0;
}
static void
SDL_COREMOTION_SensorUpdate(SDL_Sensor *sensor)
static void SDL_COREMOTION_SensorUpdate(SDL_Sensor *sensor)
{
switch (sensor->type)
{
switch (sensor->type) {
case SDL_SENSOR_ACCEL:
{
CMAccelerometerData *accelerometerData = SDL_motion_manager.accelerometerData;
if (accelerometerData) {
CMAcceleration acceleration = accelerometerData.acceleration;
float data[3];
data[0] = -acceleration.x * SDL_STANDARD_GRAVITY;
data[1] = -acceleration.y * SDL_STANDARD_GRAVITY;
data[2] = -acceleration.z * SDL_STANDARD_GRAVITY;
if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) {
SDL_PrivateSensorUpdate(sensor, 0, data, SDL_arraysize(data));
SDL_memcpy(sensor->hwdata->data, data, sizeof(data));
}
{
CMAccelerometerData *accelerometerData = SDL_motion_manager.accelerometerData;
if (accelerometerData) {
CMAcceleration acceleration = accelerometerData.acceleration;
float data[3];
data[0] = -acceleration.x * SDL_STANDARD_GRAVITY;
data[1] = -acceleration.y * SDL_STANDARD_GRAVITY;
data[2] = -acceleration.z * SDL_STANDARD_GRAVITY;
if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) {
SDL_PrivateSensorUpdate(sensor, 0, data, SDL_arraysize(data));
SDL_memcpy(sensor->hwdata->data, data, sizeof(data));
}
}
break;
} break;
case SDL_SENSOR_GYRO:
{
CMGyroData *gyroData = SDL_motion_manager.gyroData;
if (gyroData) {
CMRotationRate rotationRate = gyroData.rotationRate;
float data[3];
data[0] = rotationRate.x;
data[1] = rotationRate.y;
data[2] = rotationRate.z;
if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) {
SDL_PrivateSensorUpdate(sensor, 0, data, SDL_arraysize(data));
SDL_memcpy(sensor->hwdata->data, data, sizeof(data));
}
{
CMGyroData *gyroData = SDL_motion_manager.gyroData;
if (gyroData) {
CMRotationRate rotationRate = gyroData.rotationRate;
float data[3];
data[0] = rotationRate.x;
data[1] = rotationRate.y;
data[2] = rotationRate.z;
if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) {
SDL_PrivateSensorUpdate(sensor, 0, data, SDL_arraysize(data));
SDL_memcpy(sensor->hwdata->data, data, sizeof(data));
}
}
break;
} break;
default:
break;
}
}
static void
SDL_COREMOTION_SensorClose(SDL_Sensor *sensor)
static void SDL_COREMOTION_SensorClose(SDL_Sensor *sensor)
{
if (sensor->hwdata) {
switch (sensor->type)
{
switch (sensor->type) {
case SDL_SENSOR_ACCEL:
[SDL_motion_manager stopAccelerometerUpdates];
break;
@@ -209,13 +194,11 @@ SDL_COREMOTION_SensorClose(SDL_Sensor *sensor)
}
}
static void
SDL_COREMOTION_SensorQuit(void)
static void SDL_COREMOTION_SensorQuit(void)
{
}
SDL_SensorDriver SDL_COREMOTION_SensorDriver =
{
SDL_SensorDriver SDL_COREMOTION_SensorDriver = {
SDL_COREMOTION_SensorInit,
SDL_COREMOTION_SensorGetCount,
SDL_COREMOTION_SensorDetect,