Added SDL_GetDisplayOrientation() to get the display orientation, and added a new event SDL_DISPLAYEVENT to notify the application when the orientation changes.

Documented the values returned by the accelerometer and gyroscope sensors
This commit is contained in:
Sam Lantinga 2018-08-22 21:48:28 -07:00
parent f1bc1c1274
commit f225af0c1e
14 changed files with 290 additions and 25 deletions

View file

@ -32,8 +32,6 @@
#include "../SDL_syssensor.h"
#include "../SDL_sensor_c.h"
#define STANDARD_GRAVITY 9.80665f
typedef struct
{
SDL_SensorType type;
@ -160,9 +158,9 @@ SDL_COREMOTION_SensorUpdate(SDL_Sensor *sensor)
if (accelerometerData) {
CMAcceleration acceleration = accelerometerData.acceleration;
float data[3];
data[0] = acceleration.x * STANDARD_GRAVITY;
data[1] = acceleration.y * STANDARD_GRAVITY;
data[2] = acceleration.z * STANDARD_GRAVITY;
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, data, SDL_arraysize(data));
SDL_memcpy(sensor->hwdata->data, data, sizeof(data));