Add love.sensor.getName(sensorType)

This commit is contained in:
Miku AuahDark
2022-12-05 15:28:44 +08:00
parent 8cfb2d54d1
commit a4b94cd848
4 changed files with 27 additions and 0 deletions
+13
View File
@@ -124,6 +124,19 @@ std::vector<void*> Sensor::getHandles()
return nativeSensor;
}
const char *Sensor::getSensorName(SensorType type)
{
if (sensors[type] == nullptr)
{
const char *name = nullptr;
getConstant(type, name);
throw love::Exception("\"%s\" sensor is not enabled", name);
}
return SDL_SensorGetName(sensors[type]);
}
Sensor::SensorType Sensor::convert(SDL_SensorType type)
{
switch (type)
+1
View File
@@ -51,6 +51,7 @@ public:
void setEnabled(SensorType type, bool enable) override;
std::vector<float> getData(SensorType type) override;
std::vector<void*> getHandles() override;
const char *getSensorName(SensorType type) override;
static SensorType convert(SDL_SensorType type);