Browse Source

Expose Android Display Metrics to Löve

Jairo Luiz 12 years ago
parent
commit
2b99a488d3

+ 3 - 1
jni/love/Android.mk

@@ -16,6 +16,7 @@ LOCAL_C_INCLUDES  :=  \
 	${LOCAL_PATH}/src/libraries/ \
 	${LOCAL_PATH}/src/libraries/enet/libenet/include \
 	${LOCAL_PATH}/../SDL2-2.0.1/include \
+	${LOCAL_PATH}/../SDL2-2.0.1/src \
 	${LOCAL_PATH}/../devil-1.7.8/include \
 	${LOCAL_PATH}/../devil-1.7.8/src-IL/include \
 	${LOCAL_PATH}/../jasper-1.900.1/src/libjasper/include \
@@ -42,7 +43,8 @@ LOCAL_SRC_FILES := \
 	,$(subst $(LOCAL_PATH)/,,\
 	$(wildcard ${LOCAL_PATH}/src/love.cpp) \
  	$(wildcard ${LOCAL_PATH}/src/common/*.cpp) \
-	$(wildcard ${LOCAL_PATH}/src/modules/audio/*.cpp) \
+  $(wildcard ${LOCAL_PATH}/src/modules/android/*.cpp) \
+  $(wildcard ${LOCAL_PATH}/src/modules/audio/*.cpp) \
  	$(wildcard ${LOCAL_PATH}/src/modules/audio/null/*.cpp) \
  	$(wildcard ${LOCAL_PATH}/src/modules/audio/openal/*.cpp) \
 	$(wildcard ${LOCAL_PATH}/src/modules/event/*.cpp) \

+ 1 - 0
jni/love/src/common/config.h

@@ -90,6 +90,7 @@
 #		define LOVE_LITTLE_ENDIAN 1
 #	endif
 #else
+#	define LOVE_ENABLE_ANDROID
 #	define LOVE_ENABLE_AUDIO
 #	define LOVE_ENABLE_AUDIO_NULL
 #	define LOVE_ENABLE_AUDIO_OPENAL

+ 6 - 0
jni/love/src/common/types.h

@@ -35,6 +35,9 @@ enum Type
 	DATA_ID,
 	MODULE_ID,
 
+	// Android
+	ANDROID_DISPLAY_METRICS_ID,
+
 	// Filesystem.
 	FILESYSTEM_FILE_ID,
 	FILESYSTEM_FILE_DATA_ID,
@@ -121,6 +124,9 @@ const bits OBJECT_T = bits(1) << OBJECT_ID;
 const bits DATA_T = (bits(1) << DATA_ID) | OBJECT_T;
 const bits MODULE_T = (bits(1) << MODULE_ID) | OBJECT_T;
 
+// Android
+const bits ANDROID_DISPLAY_METRICS_T = (bits(1) << ANDROID_DISPLAY_METRICS_ID) | OBJECT_T;
+
 // Filesystem.
 const bits FILESYSTEM_FILE_T = (bits(1) << FILESYSTEM_FILE_ID) | OBJECT_T;
 const bits FILESYSTEM_FILE_DATA_T = (bits(1) << FILESYSTEM_FILE_DATA_ID) | DATA_T;

+ 43 - 0
jni/love/src/modules/android/Android.cpp

@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2006-2014 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#include "Android.h"
+
+namespace love
+{
+namespace android
+{
+
+DisplayMetrics* Android::getDisplayMetrics()
+{
+		if (metrics == NULL)
+		{
+				metrics = new DisplayMetrics();
+		}
+		return metrics;
+}
+
+const char *Android::getName() const
+{
+		return "love.android";
+}
+
+} // android
+} // love

+ 63 - 0
jni/love/src/modules/android/Android.h

@@ -0,0 +1,63 @@
+/**
+ * Copyright (c) 2006-2014 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#ifndef LOVE_ANDROID_ANDROID_H
+#define LOVE_ANDROID_ANDROID_H
+
+// LOVE
+#include "common/Module.h"
+#include "DisplayMetrics.h"
+
+namespace love
+{
+namespace android
+{
+
+/**
+ * The Android module provide access to some device features, like display metrics and camera.
+ **/
+class Android : public Module
+{
+public:
+
+	/**
+	 * Destructor.
+	 **/
+	virtual ~Android() {}
+
+	/**
+	 * Gets display metrics that describe the size and density of this display.
+	 * @return A DisplayMetrics object containing the metrics.
+	 **/
+	DisplayMetrics* getDisplayMetrics();
+
+	// Implements Module.
+	virtual const char *getName() const;
+
+private:
+
+	DisplayMetrics *metrics;
+
+}; // Android
+
+} // android
+} // love
+
+#endif // LOVE_ANDROID_ANDROID_H

+ 88 - 0
jni/love/src/modules/android/DisplayMetrics.cpp

@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) 2006-2014 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#include "DisplayMetrics.h"
+#include "core/android/SDL_android.h"
+
+namespace love
+{
+namespace android
+{
+
+DisplayMetrics::DisplayMetrics()
+{
+	JNIEnv *env = Android_JNI_GetEnv();
+
+	jclass activity = env->FindClass("org/love2d/android/GameActivity");
+	jmethodID getMetrics = env->GetStaticMethodID(activity, "getMetrics", "()Landroid/util/DisplayMetrics;");
+	jobject metrics = env->CallStaticObjectMethod(activity, getMetrics);
+	jclass metricsClass = env->GetObjectClass(metrics);
+
+	// Density
+	density = env->GetFloatField(metrics, env->GetFieldID(metricsClass, "density", "F"));
+	scaledDensity = env->GetFloatField(metrics, env->GetFieldID(metricsClass, "scaledDensity", "F"));
+	densityDpi = env->GetIntField(metrics, env->GetFieldID(metricsClass, "densityDpi", "I"));
+
+	// Size
+	widthPixels = env->GetIntField(metrics, env->GetFieldID(metricsClass, "widthPixels", "I"));
+	heightPixels = env->GetIntField(metrics, env->GetFieldID(metricsClass, "heightPixels", "I"));
+
+	// DPI
+	xdpi = env->GetFloatField(metrics, env->GetFieldID(metricsClass, "xdpi", "F"));
+	ydpi = env->GetFloatField(metrics, env->GetFieldID(metricsClass, "ydpi", "F"));
+}
+
+float DisplayMetrics::getDensity()
+{
+	return density;
+}
+
+float DisplayMetrics::getScaledDensity()
+{
+	return scaledDensity;
+}
+
+int DisplayMetrics::getDensityDpi()
+{
+	return densityDpi;
+}
+
+int DisplayMetrics::getWidthPixels()
+{
+	return widthPixels;
+}
+
+int DisplayMetrics::getHeightPixels()
+{
+	return heightPixels;
+}
+
+float DisplayMetrics::getXdpi()
+{
+	return xdpi;
+}
+
+float DisplayMetrics::getYdpi()
+{
+	return ydpi;
+}
+
+} // android
+} // love

+ 98 - 0
jni/love/src/modules/android/DisplayMetrics.h

@@ -0,0 +1,98 @@
+/**
+ * Copyright (c) 2006-2014 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#ifndef LOVE_ANDROID_DISPLAY_METRICS_H
+#define LOVE_ANDROID_DISPLAY_METRICS_H
+
+// LOVE
+#include "common/Object.h"
+
+namespace love
+{
+namespace android
+{
+
+/**
+ * A DisplayMetrics describe a general information about a display, such as its size, density, and font scaling.
+ **/
+class DisplayMetrics : public Object
+{
+public:
+
+	/**
+	 * Constructor.
+	 **/
+	DisplayMetrics();
+
+	/**
+	 * Destructor.
+	 **/
+	virtual ~DisplayMetrics() {}
+
+	/**
+	 * The logical density of the display.
+	 **/
+	float getDensity();
+
+	/**
+	 * A scaling factor for fonts displayed on the display.
+	 **/
+	float getScaledDensity();
+
+	/**
+	 * The screen density expressed as dots-per-inch.
+	 **/
+	int getDensityDpi();
+
+	/**
+	 * The absolute width of the display in pixels.
+	 **/
+	int getWidthPixels();
+
+	/**
+	 * The absolute height of the display in pixels.
+	 **/
+	int getHeightPixels();
+
+	/**
+	 * The exact physical pixels per inch of the screen in the X dimension.
+	 **/
+	float getXdpi();
+
+	/**
+	 * The exact physical pixels per inch of the screen in the X dimension.
+	 **/
+	float getYdpi();
+
+private:
+	float density;
+	float scaledDensity;
+	int densityDpi;
+	int widthPixels;
+	int heightPixels;
+	float xdpi;
+	float ydpi;
+
+}; // DisplayMetrics
+
+} // android
+} // love
+
+#endif // LOVE_ANDROID_DISPLAY_METRICS_H

+ 75 - 0
jni/love/src/modules/android/wrap_Android.cpp

@@ -0,0 +1,75 @@
+/**
+ * Copyright (c) 2006-2014 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#include "wrap_Android.h"
+#include "wrap_DisplayMetrics.h"
+
+namespace love
+{
+namespace android
+{
+
+static Android *instance = nullptr;
+
+int w_getDisplayMetrics(lua_State *L)
+{
+	DisplayMetrics *metrics = 0;
+	EXCEPT_GUARD(metrics = instance->getDisplayMetrics();)
+	luax_pushtype(L, "DisplayMetrics", ANDROID_DISPLAY_METRICS_T, metrics);
+	return 1;
+}
+
+// List of functions to wrap.
+static const luaL_Reg functions[] =
+{
+	{ "getDisplayMetrics", w_getDisplayMetrics },
+	{ 0, 0 }
+};
+
+// Types for this module.
+static const lua_CFunction types[] =
+{
+	luaopen_displaymetrics,
+	0
+};
+
+extern "C" int luaopen_love_android(lua_State *L)
+{
+	if (instance == 0)
+	{
+		EXCEPT_GUARD(instance = new Android();)
+	}
+	else
+		instance->retain();
+
+	WrappedModule w;
+	w.module = instance;
+	w.name = "android";
+	w.flags = MODULE_T;
+	w.functions = functions;
+	w.types = types;
+
+	int n = luax_register_module(L, w);
+
+	return n;
+}
+
+} // android
+} // love

+ 40 - 0
jni/love/src/modules/android/wrap_Android.h

@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2006-2014 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#ifndef LOVE_ANDROID_WRAP_ANDROID_H
+#define LOVE_ANDROID_WRAP_ANDROID_H
+
+// LOVE
+#include "common/config.h"
+#include "common/runtime.h"
+#include "Android.h"
+
+namespace love
+{
+namespace android
+{
+
+int w_getDisplayMetrics(lua_State *L);
+extern "C" LOVE_EXPORT int luaopen_love_android(lua_State *L);
+
+} // android
+} // love
+
+#endif // LOVE_ANDROID_WRAP_ANDROID_H

+ 100 - 0
jni/love/src/modules/android/wrap_DisplayMetrics.cpp

@@ -0,0 +1,100 @@
+/**
+ * Copyright (c) 2006-2014 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#include "wrap_DisplayMetrics.h"
+
+namespace love
+{
+namespace android
+{
+
+DisplayMetrics *luax_checkdisplaymetrics(lua_State *L, int idx)
+{
+	return luax_checktype<DisplayMetrics>(L, idx, "DisplayMetrics", ANDROID_DISPLAY_METRICS_T);
+}
+
+int w_getDensity(lua_State *L)
+{
+	DisplayMetrics *metrics = luax_checkdisplaymetrics(L, 1);
+	lua_pushnumber(L, metrics->getDensity());
+	return 1;
+}
+
+int w_getScaledDensity(lua_State *L)
+{
+	DisplayMetrics *metrics = luax_checkdisplaymetrics(L, 1);
+	lua_pushnumber(L, metrics->getScaledDensity());
+	return 1;
+}
+
+int w_getDensityDpi(lua_State *L)
+{
+	DisplayMetrics *metrics = luax_checkdisplaymetrics(L, 1);
+	lua_pushnumber(L, metrics->getDensityDpi());
+	return 1;
+}
+
+int w_getWidthPixels(lua_State *L)
+{
+	DisplayMetrics *metrics = luax_checkdisplaymetrics(L, 1);
+	lua_pushnumber(L, metrics->getWidthPixels());
+	return 1;
+}
+
+int w_getHeightPixels(lua_State *L)
+{
+	DisplayMetrics *metrics = luax_checkdisplaymetrics(L, 1);
+	lua_pushnumber(L, metrics->getHeightPixels());
+	return 1;
+}
+
+int w_getXdpi(lua_State *L)
+{
+	DisplayMetrics *metrics = luax_checkdisplaymetrics(L, 1);
+	lua_pushnumber(L, metrics->getXdpi());
+	return 1;
+}
+
+int w_getYdpi(lua_State *L)
+{
+	DisplayMetrics *metrics = luax_checkdisplaymetrics(L, 1);
+	lua_pushnumber(L, metrics->getYdpi());
+	return 1;
+}
+
+static const luaL_Reg functions[] =
+{
+	{ "getDensity", w_getDensity },
+	{ "getScaledDensity", w_getScaledDensity },
+	{ "getDensityDpi", w_getDensityDpi },
+	{ "getWidthPixels", w_getWidthPixels },
+	{ "getHeightPixels", w_getHeightPixels },
+	{ "getXdpi", w_getXdpi },
+	{ "getYdpi", w_getYdpi },
+	{ 0, 0 },
+};
+
+extern "C" int luaopen_displaymetrics(lua_State *L)
+{
+	return luax_register_type(L, "DisplayMetrics", functions);
+}
+
+} // android
+} // love

+ 45 - 0
jni/love/src/modules/android/wrap_DisplayMetrics.h

@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2006-2014 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#ifndef LOVE_ANDROID_WRAP_DISPLAY_METRICS_H
+#define LOVE_ANDROID_WRAP_DISPLAY_METRICS_H
+
+#include "common/runtime.h"
+#include "DisplayMetrics.h"
+
+namespace love
+{
+namespace android
+{
+
+DisplayMetrics *luax_checkdisplaymetrics(lua_State *L, int idx);
+int w_getDensity(lua_State *L);
+int w_getScaledDensity(lua_State *L);
+int w_getDensityDpi(lua_State *L);
+int w_getWidthPixels(lua_State *L);
+int w_getHeightPixels(lua_State *L);
+int w_getXdpi(lua_State *L);
+int w_getYdpi(lua_State *L);
+extern "C" int luaopen_displaymetrics(lua_State *L);
+
+} // android
+} // love
+
+#endif // LOVE_ANDROID_WRAP_DISPLAY_METRICS_H

+ 6 - 0
jni/love/src/modules/love/love.cpp

@@ -52,6 +52,9 @@
 // of addressing implementations directly.
 extern "C"
 {
+#if defined(LOVE_ENABLE_ANDROID)
+	extern int luaopen_love_android(lua_State*);
+#endif
 #if defined(LOVE_ENABLE_AUDIO)
 	extern int luaopen_love_audio(lua_State*);
 #endif
@@ -107,6 +110,9 @@ extern "C"
 }
 
 static const luaL_Reg modules[] = {
+#if defined(LOVE_ENABLE_ANDROID)
+	{ "love.android", luaopen_love_android },
+#endif
 #if defined(LOVE_ENABLE_AUDIO)
 	{ "love.audio", luaopen_love_audio },
 #endif

+ 2 - 0
jni/love/src/scripts/boot.lua

@@ -312,6 +312,7 @@ function love.init()
 			highdpi = false,
 		},
 		modules = {
+			android = true,
 			event = true,
 			keyboard = true,
 			mouse = true,
@@ -355,6 +356,7 @@ function love.init()
 
 	-- Gets desired modules.
 	for k,v in ipairs{
+		"android",
 		"thread",
 		"timer",
 		"event",

+ 3 - 25
jni/love/src/scripts/boot.lua.h

@@ -319,27 +319,6 @@ const unsigned char boot_lua[] =
 	0x76, 0x65, 0x2e, 0x74, 0x6f, 0x75, 0x63, 0x68, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x28, 0x69, 0x64, 0x2c, 0x78, 
 	0x2c, 0x79, 0x2c, 0x70, 0x29, 0x20, 0x65, 0x6e, 0x64, 0x0a,
 	0x09, 0x09, 0x65, 0x6e, 0x64, 0x2c, 0x0a,
-	0x09, 0x09, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 
-	0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x78, 0x2c, 0x79, 0x2c, 0x62, 0x29, 0x0a,
-	0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 
-	0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 
-	0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 
-	0x64, 0x28, 0x78, 0x2c, 0x79, 0x2c, 0x62, 0x29, 0x20, 0x65, 0x6e, 0x64, 0x0a,
-	0x09, 0x09, 0x65, 0x6e, 0x64, 0x2c, 0x0a,
-	0x09, 0x09, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x20, 0x3d, 
-	0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x78, 0x2c, 0x79, 0x2c, 0x62, 0x29, 0x0a,
-	0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x72, 
-	0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 
-	0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x72, 0x65, 0x6c, 0x65, 0x61, 
-	0x73, 0x65, 0x64, 0x28, 0x78, 0x2c, 0x79, 0x2c, 0x62, 0x29, 0x20, 0x65, 0x6e, 0x64, 0x0a,
-	0x09, 0x09, 0x65, 0x6e, 0x64, 0x2c, 0x0a,
-	0x09, 0x09, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x6d, 0x6f, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x66, 
-	0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x78, 0x2c, 0x79, 0x2c, 0x62, 0x29, 0x0a,
-	0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x6d, 
-	0x6f, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 
-	0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x6d, 0x6f, 0x74, 0x69, 0x6f, 0x6e, 0x28, 
-	0x78, 0x2c, 0x79, 0x2c, 0x62, 0x29, 0x20, 0x65, 0x6e, 0x64, 0x0a,
-	0x09, 0x09, 0x65, 0x6e, 0x64, 0x2c, 0x0a,
 	0x09, 0x09, 0x6a, 0x6f, 0x79, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 
 	0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x6a, 0x2c, 0x62, 0x29, 0x0a,
 	0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x6a, 0x6f, 0x79, 0x73, 0x74, 0x69, 0x63, 
@@ -584,6 +563,7 @@ const unsigned char boot_lua[] =
 	0x2c, 0x0a,
 	0x09, 0x09, 0x7d, 0x2c, 0x0a,
 	0x09, 0x09, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x7b, 0x0a,
+	0x09, 0x09, 0x09, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x2c, 0x0a,
 	0x09, 0x09, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x2c, 0x0a,
 	0x09, 0x09, 0x09, 0x6b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 
 	0x2c, 0x0a,
@@ -649,6 +629,7 @@ const unsigned char boot_lua[] =
 	0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x2e, 0x0a,
 	0x09, 0x66, 0x6f, 0x72, 0x20, 0x6b, 0x2c, 0x76, 0x20, 0x69, 0x6e, 0x20, 0x69, 0x70, 0x61, 0x69, 0x72, 0x73, 
 	0x7b, 0x0a,
+	0x09, 0x09, 0x22, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x22, 0x2c, 0x0a,
 	0x09, 0x09, 0x22, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x22, 0x2c, 0x0a,
 	0x09, 0x09, 0x22, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x22, 0x2c, 0x0a,
 	0x09, 0x09, 0x22, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x2c, 0x0a,
@@ -4865,7 +4846,6 @@ const unsigned char boot_lua[] =
 	0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x74, 0x65, 0x78, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x0a,
 	0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x61, 0x69, 0x6e, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x0a,
 	0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x67, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x3d, 0x20, 0x30, 0x0a,
-	0x09, 0x0a,
 	0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x0a,
 	0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x6c, 0x6f, 0x61, 
 	0x64, 0x28, 0x29, 0x0a,
@@ -4960,7 +4940,6 @@ const unsigned char boot_lua[] =
 	0x09, 0x09, 0x72, 0x61, 0x69, 0x6e, 0x2e, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x0a,
 	0x09, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a,
 	0x09, 0x65, 0x6e, 0x64, 0x0a,
-	0x09, 0x0a,
 	0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x72, 
 	0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a,
 	0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x62, 0x61, 0x74, 0x63, 0x68, 0x20, 0x3d, 0x20, 0x72, 0x61, 
@@ -5013,7 +4992,7 @@ const unsigned char boot_lua[] =
 	0x09, 0x09, 0x62, 0x61, 0x74, 0x63, 0x68, 0x3a, 0x75, 0x6e, 0x62, 0x69, 0x6e, 0x64, 0x28, 0x29, 0x0a,
 	0x09, 0x65, 0x6e, 0x64, 0x0a,
 	0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x75, 0x70, 
-	0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x28, 0x74, 0x29, 0x09, 0x09, 0x0a,
+	0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x28, 0x74, 0x29, 0x0a,
 	0x09, 0x09, 0x72, 0x61, 0x69, 0x6e, 0x2e, 0x74, 0x20, 0x3d, 0x20, 0x74, 0x0a,
 	0x09, 0x65, 0x6e, 0x64, 0x0a,
 	0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x72, 0x65, 0x73, 
@@ -5193,7 +5172,6 @@ const unsigned char boot_lua[] =
 	0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x6f, 
 	0x70, 0x28, 0x29, 0x0a,
 	0x09, 0x65, 0x6e, 0x64, 0x0a,
-	0x09, 0x0a,
 	0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x6b, 0x65, 0x79, 
 	0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x28, 0x6b, 0x65, 0x79, 0x29, 0x0a,
 	0x09, 0x09, 0x69, 0x66, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x3d, 0x3d, 0x20, 0x22, 0x65, 0x73, 0x63, 0x61, 0x70, 

+ 15 - 0
src/org/love2d/android/GameActivity.java

@@ -1,7 +1,22 @@
 package org.love2d.android;
 
 import org.libsdl.app.SDLActivity;
+import android.util.DisplayMetrics;
+import android.os.Bundle;
 
 public class GameActivity extends SDLActivity {
 
+    private static DisplayMetrics metrics = new DisplayMetrics();
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        getWindowManager().getDefaultDisplay().getMetrics(metrics);
+    }
+
+    public static DisplayMetrics getMetrics() {
+        return metrics;
+    }
+
 }