Rename love.sensor.isAvailable to love.sensor.hasSensor.

This commit is contained in:
Miku AuahDark
2022-12-06 00:01:47 +08:00
parent a2a7ecd1e7
commit 32bebfd1fc
4 changed files with 6 additions and 7 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ public:
/**
* Check the availability of the sensor.
**/
virtual bool isAvailable(SensorType type) = 0;
virtual bool hasSensor(SensorType type) = 0;
/**
* Check if the sensor is enabled.
+1 -1
View File
@@ -49,7 +49,7 @@ const char *Sensor::getName() const
return "love.sensor.sdl";
}
bool Sensor::isAvailable(SensorType type)
bool Sensor::hasSensor(SensorType type)
{
for (int i = 0; i < SDL_NumSensors(); i++)
{
+1 -1
View File
@@ -46,7 +46,7 @@ public:
// Implements Module.
const char *getName() const override;
bool isAvailable(SensorType type) override;
bool hasSensor(SensorType type) override;
bool isEnabled(SensorType type) override;
void setEnabled(SensorType type, bool enable) override;
std::vector<float> getData(SensorType type) override;
+3 -4
View File
@@ -40,11 +40,11 @@ inline Sensor::SensorType luax_checksensortype(lua_State *L, int i)
return type;
}
static int w_isAvailable(lua_State *L)
static int w_hasSensor(lua_State *L)
{
Sensor::SensorType type = luax_checksensortype(L, 1);
lua_pushboolean(L, instance()->isAvailable(type));
lua_pushboolean(L, instance()->hasSensor(type));
return 1;
}
@@ -90,8 +90,7 @@ static int w_getName(lua_State *L)
static const luaL_Reg functions[] =
{
{ "isAvailable", w_isAvailable },
{ "hasSensor", w_isAvailable },
{ "hasSensor", w_hasSensor },
{ "isEnabled", w_isEnabled },
{ "setEnabled", w_setEnabled },
{ "getData", w_getData },