mirror of
https://github.com/love2d/love.git
synced 2026-08-12 16:40:57 +02:00
Implement love.window.getSafeArea for Android
--HG-- branch : android-safearea
This commit is contained in:
@@ -90,6 +90,28 @@ double getScreenScale()
|
||||
return result;
|
||||
}
|
||||
|
||||
bool getSafeArea(int &top, int &left, int &bottom, int &right)
|
||||
{
|
||||
JNIEnv *env = (JNIEnv*) SDL_AndroidGetJNIEnv();
|
||||
jobject activity = (jobject) SDL_AndroidGetActivity();
|
||||
jclass clazz(env->GetObjectClass(activity));
|
||||
jmethodID methodID = env->GetMethodID(clazz, "initializeSafeArea", "()Z");
|
||||
bool hasSafeArea = false;
|
||||
|
||||
if ((hasSafeArea = env->CallBooleanMethod(activity, methodID)))
|
||||
{
|
||||
top = env->GetIntField(activity, env->GetFieldID(clazz, "safeAreaTop", "I"));
|
||||
left = env->GetIntField(activity, env->GetFieldID(clazz, "safeAreaLeft", "I"));
|
||||
bottom = env->GetIntField(activity, env->GetFieldID(clazz, "safeAreaBottom", "I"));
|
||||
right = env->GetIntField(activity, env->GetFieldID(clazz, "safeAreaRight", "I"));
|
||||
}
|
||||
|
||||
env->DeleteLocalRef(clazz);
|
||||
env->DeleteLocalRef(activity);
|
||||
|
||||
return hasSafeArea;
|
||||
}
|
||||
|
||||
const char *getSelectedGameFile()
|
||||
{
|
||||
static const char *path = NULL;
|
||||
|
||||
Reference in New Issue
Block a user