mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Sensor: Check if getConstant is successful.
This commit is contained in:
@@ -463,8 +463,10 @@ Message *Event::convert(const SDL_Event &e)
|
||||
if (e.sensor.which == id)
|
||||
{
|
||||
// Found sensor
|
||||
const char *sensorType = "unknown";
|
||||
sensor::Sensor::getConstant(sensor::sdl::Sensor::convert(SDL_SensorGetType(sensor)), sensorType);
|
||||
const char *sensorType;
|
||||
if (!sensor::Sensor::getConstant(sensor::sdl::Sensor::convert(SDL_SensorGetType(sensor)), sensorType))
|
||||
sensorType = "unknown";
|
||||
|
||||
vargs.emplace_back(sensorType, strlen(sensorType));
|
||||
// Both accelerometer and gyroscope only pass up to 3 values.
|
||||
// https://github.com/libsdl-org/SDL/blob/SDL2/include/SDL_sensor.h#L81-L127
|
||||
@@ -603,9 +605,10 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
{
|
||||
using Sensor = love::sensor::Sensor;
|
||||
|
||||
const char *sensorName = "unknown";
|
||||
const char *sensorName;
|
||||
Sensor::SensorType sensorType = love::sensor::sdl::Sensor::convert((SDL_SensorType) e.csensor.sensor);
|
||||
Sensor::getConstant(sensorType, sensorName);
|
||||
if (!Sensor::getConstant(sensorType, sensorName))
|
||||
sensorName = "unknown";
|
||||
|
||||
vargs.emplace_back(joysticktype, stick);
|
||||
vargs.emplace_back(sensorName, strlen(sensorName));
|
||||
|
||||
Reference in New Issue
Block a user