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

@@ -39,8 +39,7 @@ typedef struct
static SDL_VitaSensor *SDL_sensors;
static int SDL_sensors_count;
static int
SDL_VITA_SensorInit(void)
static int SDL_VITA_SensorInit(void)
{
sceMotionReset();
sceMotionStartSampling();
@@ -64,36 +63,32 @@ SDL_VITA_SensorInit(void)
return 0;
}
static int
SDL_VITA_SensorGetCount(void)
static int SDL_VITA_SensorGetCount(void)
{
return SDL_sensors_count;
}
static void
SDL_VITA_SensorDetect(void)
static void SDL_VITA_SensorDetect(void)
{
}
static const char *
SDL_VITA_SensorGetDeviceName(int device_index)
static const char *SDL_VITA_SensorGetDeviceName(int device_index)
{
if (device_index < SDL_sensors_count) {
switch (SDL_sensors[device_index].type) {
case SDL_SENSOR_ACCEL:
return "Accelerometer";
case SDL_SENSOR_GYRO:
return "Gyro";
default:
return "Unknown";
case SDL_SENSOR_ACCEL:
return "Accelerometer";
case SDL_SENSOR_GYRO:
return "Gyro";
default:
return "Unknown";
}
}
return NULL;
}
static SDL_SensorType
SDL_VITA_SensorGetDeviceType(int device_index)
static SDL_SensorType SDL_VITA_SensorGetDeviceType(int device_index)
{
if (device_index < SDL_sensors_count) {
return SDL_sensors[device_index].type;
@@ -102,8 +97,7 @@ SDL_VITA_SensorGetDeviceType(int device_index)
return SDL_SENSOR_INVALID;
}
static int
SDL_VITA_SensorGetDeviceNonPortableType(int device_index)
static int SDL_VITA_SensorGetDeviceNonPortableType(int device_index)
{
if (device_index < SDL_sensors_count) {
return SDL_sensors[device_index].type;
@@ -111,8 +105,7 @@ SDL_VITA_SensorGetDeviceNonPortableType(int device_index)
return -1;
}
static SDL_SensorID
SDL_VITA_SensorGetDeviceInstanceID(int device_index)
static SDL_SensorID SDL_VITA_SensorGetDeviceInstanceID(int device_index)
{
if (device_index < SDL_sensors_count) {
return SDL_sensors[device_index].instance_id;
@@ -120,8 +113,7 @@ SDL_VITA_SensorGetDeviceInstanceID(int device_index)
return -1;
}
static int
SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index)
static int SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index)
{
struct sensor_hwdata *hwdata;
@@ -134,8 +126,7 @@ SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index)
return 0;
}
static void
SDL_VITA_SensorUpdate(SDL_Sensor *sensor)
static void SDL_VITA_SensorUpdate(SDL_Sensor *sensor)
{
int err = 0;
SceMotionSensorState motionState[SCE_MOTION_MAX_NUM_STATES];
@@ -166,46 +157,40 @@ SDL_VITA_SensorUpdate(SDL_Sensor *sensor)
}
sensor->hwdata->last_timestamp = timestamp;
switch (sensor->type)
switch (sensor->type) {
case SDL_SENSOR_ACCEL:
{
case SDL_SENSOR_ACCEL:
{
float data[3];
data[0] = motionState[i].accelerometer.x * SDL_STANDARD_GRAVITY;
data[1] = motionState[i].accelerometer.y * SDL_STANDARD_GRAVITY;
data[2] = motionState[i].accelerometer.z * SDL_STANDARD_GRAVITY;
SDL_PrivateSensorUpdate(sensor, sensor->hwdata->timestamp_us, data, SDL_arraysize(data));
}
break;
case SDL_SENSOR_GYRO:
{
float data[3];
data[0] = motionState[i].gyro.x;
data[1] = motionState[i].gyro.y;
data[2] = motionState[i].gyro.z;
SDL_PrivateSensorUpdate(sensor, sensor->hwdata->timestamp_us, data, SDL_arraysize(data));
}
break;
default:
float data[3];
data[0] = motionState[i].accelerometer.x * SDL_STANDARD_GRAVITY;
data[1] = motionState[i].accelerometer.y * SDL_STANDARD_GRAVITY;
data[2] = motionState[i].accelerometer.z * SDL_STANDARD_GRAVITY;
SDL_PrivateSensorUpdate(sensor, sensor->hwdata->timestamp_us, data, SDL_arraysize(data));
} break;
case SDL_SENSOR_GYRO:
{
float data[3];
data[0] = motionState[i].gyro.x;
data[1] = motionState[i].gyro.y;
data[2] = motionState[i].gyro.z;
SDL_PrivateSensorUpdate(sensor, sensor->hwdata->timestamp_us, data, SDL_arraysize(data));
} break;
default:
break;
}
}
}
}
static void
SDL_VITA_SensorClose(SDL_Sensor *sensor)
static void SDL_VITA_SensorClose(SDL_Sensor *sensor)
{
}
static void
SDL_VITA_SensorQuit(void)
static void SDL_VITA_SensorQuit(void)
{
sceMotionStopSampling();
}
SDL_SensorDriver SDL_VITA_SensorDriver =
{
SDL_SensorDriver SDL_VITA_SensorDriver = {
SDL_VITA_SensorInit,
SDL_VITA_SensorGetCount,
SDL_VITA_SensorDetect,