diff --git a/changes.txt b/changes.txt index 54b0d108b..ba5b37679 100644 --- a/changes.txt +++ b/changes.txt @@ -3,7 +3,8 @@ LOVE 0.10.0 [] Released: N/A - * Added a (work-in-progress) iOS port. + * Added an iOS port. + * Added an Android port. * Added the flag t.accelerometerjoystick to love.conf. Disables accelerometer-as-joystick functionality on mobile devices when false. * Added the flag t.gammacorrect to love.conf (replaces t.window.srgb.) Enabling it globally enables gamma-correct rendering, when supported. * Added love.touch module. Note that it has important differences from the touch implementation in the LÖVE 0.9 Android and iOS ports. diff --git a/src/modules/love/love.cpp b/src/modules/love/love.cpp index a9ab99180..25f21d66a 100644 --- a/src/modules/love/love.cpp +++ b/src/modules/love/love.cpp @@ -306,6 +306,8 @@ int luaopen_love(lua_State *L) lua_pushstring(L, "OS X"); #elif defined(LOVE_IOS) lua_pushstring(L, "iOS"); +#elif defined(LOVE_ANDROID) + lua_pushstring(L, "Android"); #elif defined(LOVE_LINUX) lua_pushstring(L, "Linux"); #else diff --git a/src/modules/system/System.cpp b/src/modules/system/System.cpp index 27f643b35..881d5682f 100755 --- a/src/modules/system/System.cpp +++ b/src/modules/system/System.cpp @@ -26,6 +26,8 @@ #include #elif defined(LOVE_IOS) #include "common/iOS.h" +#elif defined(LOVE_ANDROID) +#include "common/android.h" #elif defined(LOVE_LINUX) #include //#include @@ -66,6 +68,8 @@ std::string System::getOS() const return "iOS"; #elif defined(LOVE_WINDOWS) return "Windows"; +#elif defined(LOVE_ANDROID) + return "Android"; #elif defined(LOVE_LINUX) return "Linux"; #else @@ -98,6 +102,10 @@ bool System::openURL(const std::string &url) const return love::ios::openURL(url); +#elif defined(LOVE_ANDROID) + + return love::android::openURL(url); + #elif defined(LOVE_LINUX) pid_t pid; @@ -134,6 +142,15 @@ bool System::openURL(const std::string &url) const #endif } +void System::vibrate(double seconds) const +{ +#ifdef LOVE_ANDROID + love::android::vibrate(seconds); +#else + LOVE_UNUSED(seconds); +#endif +} + bool System::getConstant(const char *in, System::PowerState &out) { return powerStates.find(in, out); diff --git a/src/modules/system/System.h b/src/modules/system/System.h index 6d7887b68..be850e279 100644 --- a/src/modules/system/System.h +++ b/src/modules/system/System.h @@ -99,6 +99,13 @@ 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); diff --git a/src/modules/system/wrap_System.cpp b/src/modules/system/wrap_System.cpp index 2d95f5b87..505865457 100644 --- a/src/modules/system/wrap_System.cpp +++ b/src/modules/system/wrap_System.cpp @@ -86,6 +86,13 @@ int w_openURL(lua_State *L) return 1; } +int w_vibrate(lua_State *L) +{ + double seconds = 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 } }; diff --git a/src/modules/system/wrap_System.h b/src/modules/system/wrap_System.h index 090879709..2fe6438f5 100644 --- a/src/modules/system/wrap_System.h +++ b/src/modules/system/wrap_System.h @@ -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