implemented love.system.vibrate(seconds)

This commit is contained in:
Martin Felis
2014-08-18 18:47:13 +02:00
parent 8f20cb7cc5
commit 6110de0fa8
8 changed files with 47 additions and 2 deletions
+6
View File
@@ -118,6 +118,12 @@ bool System::openURL(const std::string &url) const
#endif
}
void System::vibrate(double seconds) const {
#ifdef LOVE_ANDROID
love::android::vibrate (seconds);
#endif
}
bool System::getConstant(const char *in, System::PowerState &out)
{
return powerStates.find(in, out);
+8
View File
@@ -95,6 +95,14 @@ public:
**/
virtual bool openURL(const std::string &url) const;
/**
* Vibrates for the specified amount of seconds.
*
* @param number of seconds to vibrate.
*
*/
virtual void vibrate(double seconds) const;
static bool getConstant(const char *in, PowerState &out);
static bool getConstant(PowerState in, const char *&out);
@@ -86,6 +86,13 @@ int w_openURL(lua_State *L)
return 1;
}
int w_vibrate(lua_State *L)
{
double seconds = static_cast<double>(luaL_checknumber(L, 1));
instance->vibrate(seconds);
return 0;
}
static const luaL_Reg functions[] =
{
{ "getOS", w_getOS },
@@ -94,6 +101,7 @@ static const luaL_Reg functions[] =
{ "getClipboardText", w_getClipboardText },
{ "getPowerInfo", w_getPowerInfo },
{ "openURL", w_openURL },
{ "vibrate", w_vibrate },
{ 0, 0 }
};
@@ -36,6 +36,7 @@ int w_setClipboardText(lua_State *L);
int w_getClipboardText(lua_State *L);
int w_getPowerInfo(lua_State *L);
int w_openURL(lua_State *L);
int w_vibrate(lua_State *L);
extern "C" LOVE_EXPORT int luaopen_love_system(lua_State *L);
} // system