فهرست منبع

Added love.system.vibrate(time), which causes the phone to vibrate on Android. love.system.getOS() now returns "Android" on Android. Implemented love.system.openURL.

Martin Felis 10 سال پیش
والد
کامیت
2ab69094e1
6فایلهای تغییر یافته به همراه37 افزوده شده و 1 حذف شده
  1. 2 1
      changes.txt
  2. 2 0
      src/modules/love/love.cpp
  3. 17 0
      src/modules/system/System.cpp
  4. 7 0
      src/modules/system/System.h
  5. 8 0
      src/modules/system/wrap_System.cpp
  6. 1 0
      src/modules/system/wrap_System.h

+ 2 - 1
changes.txt

@@ -3,7 +3,8 @@ LOVE 0.10.0 []
 
 
 Released: N/A
 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.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 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.
   * Added love.touch module. Note that it has important differences from the touch implementation in the LÖVE 0.9 Android and iOS ports.

+ 2 - 0
src/modules/love/love.cpp

@@ -306,6 +306,8 @@ int luaopen_love(lua_State *L)
 	lua_pushstring(L, "OS X");
 	lua_pushstring(L, "OS X");
 #elif defined(LOVE_IOS)
 #elif defined(LOVE_IOS)
 	lua_pushstring(L, "iOS");
 	lua_pushstring(L, "iOS");
+#elif defined(LOVE_ANDROID)
+	lua_pushstring(L, "Android");
 #elif defined(LOVE_LINUX)
 #elif defined(LOVE_LINUX)
 	lua_pushstring(L, "Linux");
 	lua_pushstring(L, "Linux");
 #else
 #else

+ 17 - 0
src/modules/system/System.cpp

@@ -26,6 +26,8 @@
 #include <CoreServices/CoreServices.h>
 #include <CoreServices/CoreServices.h>
 #elif defined(LOVE_IOS)
 #elif defined(LOVE_IOS)
 #include "common/iOS.h"
 #include "common/iOS.h"
+#elif defined(LOVE_ANDROID)
+#include "common/android.h"
 #elif defined(LOVE_LINUX)
 #elif defined(LOVE_LINUX)
 #include <spawn.h>
 #include <spawn.h>
 //#include <stdlib.h>
 //#include <stdlib.h>
@@ -66,6 +68,8 @@ std::string System::getOS() const
 	return "iOS";
 	return "iOS";
 #elif defined(LOVE_WINDOWS)
 #elif defined(LOVE_WINDOWS)
 	return "Windows";
 	return "Windows";
+#elif defined(LOVE_ANDROID)
+	return "Android";
 #elif defined(LOVE_LINUX)
 #elif defined(LOVE_LINUX)
 	return "Linux";
 	return "Linux";
 #else
 #else
@@ -98,6 +102,10 @@ bool System::openURL(const std::string &url) const
 
 
 	return love::ios::openURL(url);
 	return love::ios::openURL(url);
 
 
+#elif defined(LOVE_ANDROID)
+
+	return love::android::openURL(url);
+
 #elif defined(LOVE_LINUX)
 #elif defined(LOVE_LINUX)
 
 
 	pid_t pid;
 	pid_t pid;
@@ -134,6 +142,15 @@ bool System::openURL(const std::string &url) const
 #endif
 #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)
 bool System::getConstant(const char *in, System::PowerState &out)
 {
 {
 	return powerStates.find(in, out);
 	return powerStates.find(in, out);

+ 7 - 0
src/modules/system/System.h

@@ -99,6 +99,13 @@ public:
 	 **/
 	 **/
 	virtual bool openURL(const std::string &url) const;
 	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(const char *in, PowerState &out);
 	static bool getConstant(PowerState in, const char *&out);
 	static bool getConstant(PowerState in, const char *&out);
 
 

+ 8 - 0
src/modules/system/wrap_System.cpp

@@ -86,6 +86,13 @@ int w_openURL(lua_State *L)
 	return 1;
 	return 1;
 }
 }
 
 
+int w_vibrate(lua_State *L)
+{
+	double seconds = luaL_checknumber(L, 1);
+	instance()->vibrate(seconds);
+	return 0;
+}
+
 static const luaL_Reg functions[] =
 static const luaL_Reg functions[] =
 {
 {
 	{ "getOS", w_getOS },
 	{ "getOS", w_getOS },
@@ -94,6 +101,7 @@ static const luaL_Reg functions[] =
 	{ "getClipboardText", w_getClipboardText },
 	{ "getClipboardText", w_getClipboardText },
 	{ "getPowerInfo", w_getPowerInfo },
 	{ "getPowerInfo", w_getPowerInfo },
 	{ "openURL", w_openURL },
 	{ "openURL", w_openURL },
+	{ "vibrate", w_vibrate },
 	{ 0, 0 }
 	{ 0, 0 }
 };
 };
 
 

+ 1 - 0
src/modules/system/wrap_System.h

@@ -36,6 +36,7 @@ int w_setClipboardText(lua_State *L);
 int w_getClipboardText(lua_State *L);
 int w_getClipboardText(lua_State *L);
 int w_getPowerInfo(lua_State *L);
 int w_getPowerInfo(lua_State *L);
 int w_openURL(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);
 extern "C" LOVE_EXPORT int luaopen_love_system(lua_State *L);
 
 
 } // system
 } // system