mirror of
https://github.com/love2d/love.git
synced 2026-08-14 10:13:46 +02:00
Add error handling in love.sensor.getData and only pass 3 values on love.sensorupdate.
This commit is contained in:
@@ -104,10 +104,16 @@ std::vector<float> Sensor::getData(SensorType type)
|
||||
throw love::Exception("\"%s\" sensor is not enabled", name);
|
||||
}
|
||||
|
||||
std::vector<float> values;
|
||||
values.resize(3);
|
||||
std::vector<float> values(3);
|
||||
|
||||
if (SDL_SensorGetData(sensors[type], values.data(), values.size()) != 0)
|
||||
{
|
||||
const char *name = nullptr;
|
||||
getConstant(type, name);
|
||||
|
||||
throw love::Exception("Could not get \"%s\" SDL sensor data (%s)", name, SDL_GetError());
|
||||
}
|
||||
|
||||
SDL_SensorGetData(sensors[type], values.data(), 3);
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user