mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-29 14:38:29 +00:00
Use C++ style comments consistently in SDL source code
Implemented using this script: find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \; git checkout \ core/linux/SDL_evdev_kbd_default_keymap.h \ events/imKStoUCS.* \ hidapi \ joystick/controller_type.c \ joystick/controller_type.h \ joystick/hidapi/steam/controller_constants.h \ joystick/hidapi/steam/controller_structs.h \ joystick/SDL_gamepad_db.h \ libm \ render/*/*Shader*.h \ render/vitagxm/SDL_render_vita_gxm_shaders.h \ render/metal/SDL_shaders_metal_*.h \ stdlib/SDL_malloc.c \ stdlib/SDL_qsort.c \ stdlib/SDL_strtokr.c \ test/ \ video/directx/SDL_d3d12_xbox_cmacros.h \ video/directx/d3d12.h \ video/directx/d3d12sdklayers.h \ video/khronos \ video/x11/edid-parse.c \ video/x11/xsettings-client.* \ video/yuv2rgb sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This is the sensor API for Simple DirectMedia Layer */
|
||||
// This is the sensor API for Simple DirectMedia Layer
|
||||
|
||||
#include "SDL_syssensor.h"
|
||||
|
||||
@@ -51,7 +51,7 @@ static SDL_SensorDriver *SDL_sensor_drivers[] = {
|
||||
#ifndef SDL_THREAD_SAFETY_ANALYSIS
|
||||
static
|
||||
#endif
|
||||
SDL_Mutex *SDL_sensor_lock = NULL; /* This needs to support recursive locks */
|
||||
SDL_Mutex *SDL_sensor_lock = NULL; // This needs to support recursive locks
|
||||
static SDL_AtomicInt SDL_sensor_lock_pending;
|
||||
static int SDL_sensors_locked;
|
||||
static SDL_bool SDL_sensors_initialized;
|
||||
@@ -85,7 +85,7 @@ void SDL_UnlockSensors(void)
|
||||
--SDL_sensors_locked;
|
||||
|
||||
if (!SDL_sensors_initialized) {
|
||||
/* NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks */
|
||||
// NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks
|
||||
if (!SDL_sensors_locked && SDL_AtomicGet(&SDL_sensor_lock_pending) == 0) {
|
||||
last_unlock = SDL_TRUE;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ int SDL_InitSensors(void)
|
||||
{
|
||||
int i, status;
|
||||
|
||||
/* Create the sensor list lock */
|
||||
// Create the sensor list lock
|
||||
if (SDL_sensor_lock == NULL) {
|
||||
SDL_sensor_lock = SDL_CreateMutex();
|
||||
}
|
||||
@@ -319,7 +319,7 @@ SDL_Sensor *SDL_OpenSensor(SDL_SensorID instance_id)
|
||||
sensorlist = sensorlist->next;
|
||||
}
|
||||
|
||||
/* Create and initialize the sensor */
|
||||
// Create and initialize the sensor
|
||||
sensor = (SDL_Sensor *)SDL_calloc(sizeof(*sensor), 1);
|
||||
if (!sensor) {
|
||||
SDL_UnlockSensors();
|
||||
@@ -345,9 +345,9 @@ SDL_Sensor *SDL_OpenSensor(SDL_SensorID instance_id)
|
||||
sensor->name = NULL;
|
||||
}
|
||||
|
||||
/* Add sensor to list */
|
||||
// Add sensor to list
|
||||
++sensor->ref_count;
|
||||
/* Link the sensor in the list */
|
||||
// Link the sensor in the list
|
||||
sensor->next = SDL_sensors;
|
||||
SDL_sensors = sensor;
|
||||
|
||||
@@ -497,7 +497,7 @@ void SDL_CloseSensor(SDL_Sensor *sensor)
|
||||
{
|
||||
CHECK_SENSOR_MAGIC(sensor,);
|
||||
|
||||
/* First decrement ref count */
|
||||
// First decrement ref count
|
||||
if (--sensor->ref_count > 0) {
|
||||
SDL_UnlockSensors();
|
||||
return;
|
||||
@@ -514,7 +514,7 @@ void SDL_CloseSensor(SDL_Sensor *sensor)
|
||||
while (sensorlist) {
|
||||
if (sensor == sensorlist) {
|
||||
if (sensorlistprev) {
|
||||
/* unlink this entry */
|
||||
// unlink this entry
|
||||
sensorlistprev->next = sensorlist->next;
|
||||
} else {
|
||||
SDL_sensors = sensor->next;
|
||||
@@ -525,7 +525,7 @@ void SDL_CloseSensor(SDL_Sensor *sensor)
|
||||
sensorlist = sensorlist->next;
|
||||
}
|
||||
|
||||
/* Free the data associated with this sensor */
|
||||
// Free the data associated with this sensor
|
||||
SDL_free(sensor->name);
|
||||
SDL_free(sensor);
|
||||
}
|
||||
@@ -538,13 +538,13 @@ void SDL_QuitSensors(void)
|
||||
|
||||
SDL_LockSensors();
|
||||
|
||||
/* Stop the event polling */
|
||||
// Stop the event polling
|
||||
while (SDL_sensors) {
|
||||
SDL_sensors->ref_count = 1;
|
||||
SDL_CloseSensor(SDL_sensors);
|
||||
}
|
||||
|
||||
/* Quit the sensor setup */
|
||||
// Quit the sensor setup
|
||||
for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) {
|
||||
SDL_sensor_drivers[i]->Quit();
|
||||
}
|
||||
@@ -556,7 +556,7 @@ void SDL_QuitSensors(void)
|
||||
SDL_UnlockSensors();
|
||||
}
|
||||
|
||||
/* These are global for SDL_syssensor.c and SDL_events.c */
|
||||
// These are global for SDL_syssensor.c and SDL_events.c
|
||||
|
||||
int SDL_SendSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_timestamp, float *data, int num_values)
|
||||
{
|
||||
@@ -564,13 +564,13 @@ int SDL_SendSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_tim
|
||||
|
||||
SDL_AssertSensorsLocked();
|
||||
|
||||
/* Allow duplicate events, for things like steps and heartbeats */
|
||||
// Allow duplicate events, for things like steps and heartbeats
|
||||
|
||||
/* Update internal sensor state */
|
||||
// Update internal sensor state
|
||||
num_values = SDL_min(num_values, SDL_arraysize(sensor->data));
|
||||
SDL_memcpy(sensor->data, data, num_values * sizeof(*data));
|
||||
|
||||
/* Post the event, if desired */
|
||||
// Post the event, if desired
|
||||
posted = 0;
|
||||
if (SDL_EventEnabled(SDL_EVENT_SENSOR_UPDATE)) {
|
||||
SDL_Event event;
|
||||
|
@@ -29,31 +29,31 @@ extern SDL_Mutex *SDL_sensor_lock;
|
||||
|
||||
struct SDL_SensorDriver;
|
||||
|
||||
/* Useful functions and variables from SDL_sensor.c */
|
||||
// Useful functions and variables from SDL_sensor.c
|
||||
|
||||
/* Initialization and shutdown functions */
|
||||
// Initialization and shutdown functions
|
||||
extern int SDL_InitSensors(void);
|
||||
extern void SDL_QuitSensors(void);
|
||||
|
||||
/* Return whether the sensor system is currently initialized */
|
||||
// Return whether the sensor system is currently initialized
|
||||
extern SDL_bool SDL_SensorsInitialized(void);
|
||||
|
||||
/* Return whether the sensors are currently locked */
|
||||
// Return whether the sensors are currently locked
|
||||
extern SDL_bool SDL_SensorsLocked(void);
|
||||
|
||||
/* Make sure we currently have the sensors locked */
|
||||
// Make sure we currently have the sensors locked
|
||||
extern void SDL_AssertSensorsLocked(void) SDL_ASSERT_CAPABILITY(SDL_sensor_lock);
|
||||
|
||||
extern void SDL_LockSensors(void) SDL_ACQUIRE(SDL_sensor_lock);
|
||||
extern void SDL_UnlockSensors(void) SDL_RELEASE(SDL_sensor_lock);
|
||||
|
||||
/* Function to return whether there are any sensors opened by the application */
|
||||
// Function to return whether there are any sensors opened by the application
|
||||
extern SDL_bool SDL_SensorsOpened(void);
|
||||
|
||||
/* Update an individual sensor, used by gamepad sensor fusion */
|
||||
// Update an individual sensor, used by gamepad sensor fusion
|
||||
extern void SDL_UpdateSensor(SDL_Sensor *sensor);
|
||||
|
||||
/* Internal event queueing functions */
|
||||
// Internal event queueing functions
|
||||
extern int SDL_SendSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_timestamp, float *data, int num_values);
|
||||
|
||||
#endif /* SDL_sensor_c_h_ */
|
||||
#endif // SDL_sensor_c_h_
|
||||
|
@@ -23,31 +23,31 @@
|
||||
#ifndef SDL_syssensor_c_h_
|
||||
#define SDL_syssensor_c_h_
|
||||
|
||||
/* This is the system specific header for the SDL sensor API */
|
||||
// This is the system specific header for the SDL sensor API
|
||||
|
||||
#include "SDL_sensor_c.h"
|
||||
|
||||
#define _guarded SDL_GUARDED_BY(SDL_sensor_lock)
|
||||
|
||||
/* The SDL sensor structure */
|
||||
// The SDL sensor structure
|
||||
struct SDL_Sensor
|
||||
{
|
||||
SDL_SensorID instance_id _guarded; /* Device instance, monotonically increasing from 0 */
|
||||
char *name _guarded; /* Sensor name - system dependent */
|
||||
SDL_SensorType type _guarded; /* Type of the sensor */
|
||||
int non_portable_type _guarded; /* Platform dependent type of the sensor */
|
||||
SDL_SensorID instance_id _guarded; // Device instance, monotonically increasing from 0
|
||||
char *name _guarded; // Sensor name - system dependent
|
||||
SDL_SensorType type _guarded; // Type of the sensor
|
||||
int non_portable_type _guarded; // Platform dependent type of the sensor
|
||||
|
||||
float data[16] _guarded; /* The current state of the sensor */
|
||||
float data[16] _guarded; // The current state of the sensor
|
||||
|
||||
struct SDL_SensorDriver *driver _guarded;
|
||||
|
||||
struct sensor_hwdata *hwdata _guarded; /* Driver dependent information */
|
||||
struct sensor_hwdata *hwdata _guarded; // Driver dependent information
|
||||
|
||||
SDL_PropertiesID props _guarded;
|
||||
|
||||
int ref_count _guarded; /* Reference count for multiple opens */
|
||||
int ref_count _guarded; // Reference count for multiple opens
|
||||
|
||||
struct SDL_Sensor *next _guarded; /* pointer to next sensor we have allocated */
|
||||
struct SDL_Sensor *next _guarded; // pointer to next sensor we have allocated
|
||||
};
|
||||
|
||||
#undef _guarded
|
||||
@@ -60,22 +60,22 @@ typedef struct SDL_SensorDriver
|
||||
*/
|
||||
int (*Init)(void);
|
||||
|
||||
/* Function to return the number of sensors available right now */
|
||||
// Function to return the number of sensors available right now
|
||||
int (*GetCount)(void);
|
||||
|
||||
/* Function to check to see if the available sensors have changed */
|
||||
// Function to check to see if the available sensors have changed
|
||||
void (*Detect)(void);
|
||||
|
||||
/* Function to get the device-dependent name of a sensor */
|
||||
// Function to get the device-dependent name of a sensor
|
||||
const char *(*GetDeviceName)(int device_index);
|
||||
|
||||
/* Function to get the type of a sensor */
|
||||
// Function to get the type of a sensor
|
||||
SDL_SensorType (*GetDeviceType)(int device_index);
|
||||
|
||||
/* Function to get the platform dependent type of a sensor */
|
||||
// Function to get the platform dependent type of a sensor
|
||||
int (*GetDeviceNonPortableType)(int device_index);
|
||||
|
||||
/* Function to get the current instance id of the sensor located at device_index */
|
||||
// Function to get the current instance id of the sensor located at device_index
|
||||
SDL_SensorID (*GetDeviceInstanceID)(int device_index);
|
||||
|
||||
/* Function to open a sensor for use.
|
||||
@@ -91,15 +91,15 @@ typedef struct SDL_SensorDriver
|
||||
*/
|
||||
void (*Update)(SDL_Sensor *sensor);
|
||||
|
||||
/* Function to close a sensor after use */
|
||||
// Function to close a sensor after use
|
||||
void (*Close)(SDL_Sensor *sensor);
|
||||
|
||||
/* Function to perform any system-specific sensor related cleanup */
|
||||
// Function to perform any system-specific sensor related cleanup
|
||||
void (*Quit)(void);
|
||||
|
||||
} SDL_SensorDriver;
|
||||
|
||||
/* The available sensor drivers */
|
||||
// The available sensor drivers
|
||||
extern SDL_SensorDriver SDL_ANDROID_SensorDriver;
|
||||
extern SDL_SensorDriver SDL_COREMOTION_SensorDriver;
|
||||
extern SDL_SensorDriver SDL_WINDOWS_SensorDriver;
|
||||
@@ -107,4 +107,4 @@ extern SDL_SensorDriver SDL_DUMMY_SensorDriver;
|
||||
extern SDL_SensorDriver SDL_VITA_SensorDriver;
|
||||
extern SDL_SensorDriver SDL_N3DS_SensorDriver;
|
||||
|
||||
#endif /* SDL_syssensor_h_ */
|
||||
#endif // SDL_syssensor_h_
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#ifdef SDL_SENSOR_ANDROID
|
||||
|
||||
/* This is the system specific header for the SDL sensor API */
|
||||
// This is the system specific header for the SDL sensor API
|
||||
#include <android/sensor.h>
|
||||
|
||||
#include "SDL_androidsensor.h"
|
||||
@@ -126,7 +126,7 @@ static int SDL_ANDROID_StartSensorThread(SDL_AndroidSensorThreadContext *ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Wait for the sensor thread to start */
|
||||
// Wait for the sensor thread to start
|
||||
SDL_WaitSemaphore(ctx->sem);
|
||||
|
||||
return 0;
|
||||
@@ -142,7 +142,7 @@ static int SDL_ANDROID_SensorInit(void)
|
||||
return SDL_SetError("Couldn't create sensor manager");
|
||||
}
|
||||
|
||||
/* FIXME: Is the sensor list dynamic? */
|
||||
// FIXME: Is the sensor list dynamic?
|
||||
sensors_count = ASensorManager_getSensorList(SDL_sensor_manager, &sensors);
|
||||
if (sensors_count > 0) {
|
||||
SDL_sensors = (SDL_AndroidSensor *)SDL_calloc(sensors_count, sizeof(*SDL_sensors));
|
||||
@@ -219,8 +219,8 @@ static int SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index)
|
||||
return SDL_SetError("Couldn't enable sensor");
|
||||
}
|
||||
|
||||
/* Use 60 Hz update rate if possible */
|
||||
/* FIXME: Maybe add a hint for this? */
|
||||
// Use 60 Hz update rate if possible
|
||||
// FIXME: Maybe add a hint for this?
|
||||
delay_us = 1000000 / 60;
|
||||
min_delay_us = ASensor_getMinDelay(SDL_sensors[device_index].asensor);
|
||||
if (delay_us < min_delay_us) {
|
||||
@@ -258,7 +258,7 @@ static void SDL_ANDROID_SensorClose(SDL_Sensor *sensor)
|
||||
|
||||
static void SDL_ANDROID_SensorQuit(void)
|
||||
{
|
||||
/* All sensors are closed, but we need to unblock the sensor thread */
|
||||
// All sensors are closed, but we need to unblock the sensor thread
|
||||
SDL_AssertSensorsLocked();
|
||||
SDL_UnlockSensors();
|
||||
SDL_ANDROID_StopSensorThread(&SDL_sensor_thread_context);
|
||||
@@ -285,4 +285,4 @@ SDL_SensorDriver SDL_ANDROID_SensorDriver = {
|
||||
SDL_ANDROID_SensorQuit,
|
||||
};
|
||||
|
||||
#endif /* SDL_SENSOR_ANDROID */
|
||||
#endif // SDL_SENSOR_ANDROID
|
||||
|
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* The private structure used to keep track of a sensor */
|
||||
// The private structure used to keep track of a sensor
|
||||
struct sensor_hwdata
|
||||
{
|
||||
float data[3];
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#ifdef SDL_SENSOR_COREMOTION
|
||||
|
||||
/* This is the system specific header for the SDL sensor API */
|
||||
// This is the system specific header for the SDL sensor API
|
||||
#include <CoreMotion/CoreMotion.h>
|
||||
|
||||
#include "SDL_coremotionsensor.h"
|
||||
@@ -211,4 +211,4 @@ SDL_SensorDriver SDL_COREMOTION_SensorDriver = {
|
||||
SDL_COREMOTION_SensorQuit,
|
||||
};
|
||||
|
||||
#endif /* SDL_SENSOR_COREMOTION */
|
||||
#endif // SDL_SENSOR_COREMOTION
|
||||
|
@@ -90,4 +90,4 @@ SDL_SensorDriver SDL_DUMMY_SensorDriver = {
|
||||
SDL_DUMMY_SensorQuit,
|
||||
};
|
||||
|
||||
#endif /* SDL_SENSOR_DUMMY || SDL_SENSOR_DISABLED */
|
||||
#endif // SDL_SENSOR_DUMMY || SDL_SENSOR_DISABLED
|
||||
|
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "../SDL_syssensor.h"
|
||||
|
||||
/* 1 accelerometer and 1 gyroscope */
|
||||
// 1 accelerometer and 1 gyroscope
|
||||
#define N3DS_SENSOR_COUNT 2
|
||||
|
||||
typedef struct
|
||||
@@ -200,4 +200,4 @@ SDL_SensorDriver SDL_N3DS_SensorDriver = {
|
||||
.Quit = N3DS_SensorQuit,
|
||||
};
|
||||
|
||||
#endif /* SDL_SENSOR_N3DS */
|
||||
#endif // SDL_SENSOR_N3DS
|
||||
|
@@ -201,4 +201,4 @@ SDL_SensorDriver SDL_VITA_SensorDriver = {
|
||||
SDL_VITA_SensorQuit,
|
||||
};
|
||||
|
||||
#endif /* SDL_SENSOR_VITA */
|
||||
#endif // SDL_SENSOR_VITA
|
||||
|
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* The private structure used to keep track of a sensor */
|
||||
// The private structure used to keep track of a sensor
|
||||
struct sensor_hwdata
|
||||
{
|
||||
Uint32 counter;
|
||||
|
@@ -36,7 +36,7 @@ DEFINE_GUID(SDL_IID_SensorManager, 0xBD77DB67, 0x45A8, 0x42DC, 0x8D, 0x00, 0x6D,
|
||||
DEFINE_GUID(SDL_IID_SensorManagerEvents, 0x9B3B0B86, 0x266A, 0x4AAD, 0xB2, 0x1F, 0xFD, 0xE5, 0x50, 0x10, 0x01, 0xB7);
|
||||
DEFINE_GUID(SDL_IID_SensorEvents, 0x5D8DCC91, 0x4641, 0x47E7, 0xB7, 0xC3, 0xB7, 0x4F, 0x48, 0xA6, 0xC3, 0x91);
|
||||
|
||||
/* These constants aren't available in Visual Studio 2015 or earlier Windows SDK */
|
||||
// These constants aren't available in Visual Studio 2015 or earlier Windows SDK
|
||||
DEFINE_PROPERTYKEY(SDL_SENSOR_DATA_TYPE_ANGULAR_VELOCITY_X_DEGREES_PER_SECOND, 0X3F8A69A2, 0X7C5, 0X4E48, 0XA9, 0X65, 0XCD, 0X79, 0X7A, 0XAB, 0X56, 0XD5, 10); //[VT_R8]
|
||||
DEFINE_PROPERTYKEY(SDL_SENSOR_DATA_TYPE_ANGULAR_VELOCITY_Y_DEGREES_PER_SECOND, 0X3F8A69A2, 0X7C5, 0X4E48, 0XA9, 0X65, 0XCD, 0X79, 0X7A, 0XAB, 0X56, 0XD5, 11); //[VT_R8]
|
||||
DEFINE_PROPERTYKEY(SDL_SENSOR_DATA_TYPE_ANGULAR_VELOCITY_Z_DEGREES_PER_SECOND, 0X3F8A69A2, 0X7C5, 0X4E48, 0XA9, 0X65, 0XCD, 0X79, 0X7A, 0XAB, 0X56, 0XD5, 12); //[VT_R8]
|
||||
@@ -199,7 +199,7 @@ static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_OnDataUpdated(ISensorEvents *
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* FIXME: Need to know how to interpret the data for this sensor */
|
||||
// FIXME: Need to know how to interpret the data for this sensor
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -337,7 +337,7 @@ static int DisconnectSensor(ISensor *sensor)
|
||||
/* This call hangs for some reason:
|
||||
* https://github.com/libsdl-org/SDL/issues/5288
|
||||
*/
|
||||
/*ISensor_SetEventSink(sensor, NULL);*/
|
||||
// ISensor_SetEventSink(sensor, NULL);
|
||||
ISensor_Release(sensor);
|
||||
SDL_free(old_sensor->name);
|
||||
--SDL_num_sensors;
|
||||
@@ -363,8 +363,8 @@ static int SDL_WINDOWS_SensorInit(void)
|
||||
|
||||
hr = CoCreateInstance(&SDL_CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &SDL_IID_SensorManager, (LPVOID *)&SDL_sensor_manager);
|
||||
if (FAILED(hr)) {
|
||||
/* If we can't create a sensor manager (i.e. on Wine), we won't have any sensors, but don't fail the init */
|
||||
return 0; /* WIN_SetErrorFromHRESULT("Couldn't create the sensor manager", hr); */
|
||||
// If we can't create a sensor manager (i.e. on Wine), we won't have any sensors, but don't fail the init
|
||||
return 0; // WIN_SetErrorFromHRESULT("Couldn't create the sensor manager", hr);
|
||||
}
|
||||
|
||||
hr = ISensorManager_SetEventSink(SDL_sensor_manager, &sensor_manager_events);
|
||||
@@ -482,4 +482,4 @@ SDL_SensorDriver SDL_WINDOWS_SensorDriver = {
|
||||
SDL_WINDOWS_SensorQuit,
|
||||
};
|
||||
|
||||
#endif /* SDL_SENSOR_WINDOWS */
|
||||
#endif // SDL_SENSOR_WINDOWS
|
||||
|
Reference in New Issue
Block a user