Added properties to various SDL objects

The following objects now have properties that can be user modified:
* SDL_AudioStream
* SDL_Gamepad
* SDL_Joystick
* SDL_RWops
* SDL_Renderer
* SDL_Sensor
* SDL_Surface
* SDL_Texture
* SDL_Window
This commit is contained in:
Sam Lantinga
2023-10-11 16:59:51 -07:00
parent 973c8b3273
commit 4368f70ff9
32 changed files with 434 additions and 292 deletions

View File

@@ -393,6 +393,27 @@ SDL_Sensor *SDL_GetSensorFromInstanceID(SDL_SensorID instance_id)
return sensor;
}
/*
* Get the properties associated with a sensor.
*/
SDL_PropertiesID SDL_GetSensorProperties(SDL_Sensor *sensor)
{
SDL_PropertiesID retval;
SDL_LockSensors();
{
CHECK_SENSOR_MAGIC(sensor, 0);
if (sensor->props == 0) {
sensor->props = SDL_CreateProperties();
}
retval = sensor->props;
}
SDL_UnlockSensors();
return retval;
}
/*
* Get the friendly name of this sensor
*/
@@ -500,6 +521,8 @@ void SDL_CloseSensor(SDL_Sensor *sensor)
return;
}
SDL_DestroyProperties(sensor->props);
sensor->driver->Close(sensor);
sensor->hwdata = NULL;

View File

@@ -45,6 +45,8 @@ struct SDL_Sensor
struct sensor_hwdata *hwdata _guarded; /* Driver dependent information */
SDL_PropertiesID props _guarded;
int ref_count _guarded; /* Reference count for multiple opens */
struct SDL_Sensor *next _guarded; /* pointer to next sensor we have allocated */