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

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

View File

@@ -39,8 +39,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;
@@ -77,19 +76,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:
@@ -101,26 +97,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;
@@ -130,8 +122,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;
@@ -143,55 +134,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;
@@ -206,13 +191,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,