[Commits] SDL: Added SDL_IsAndroidTV()

libsdl.org revision control commits-owner at libsdl.org
Tue Feb 6 15:03:28 PST 2018


details:   https://hg.libsdl.org/SDL/rev/8e2ca40e07f3
changeset: 11844:8e2ca40e07f3
user:      Sam Lantinga <slouken at libsdl.org>
date:      Tue Feb 06 15:03:35 2018 -0800
description:
Added SDL_IsAndroidTV()

diffstat:

 android-project/app/src/main/java/org/libsdl/app/SDLActivity.java |  13 +++++++++-
 include/SDL_system.h                                              |   5 +++
 src/core/android/SDL_android.c                                    |  12 ++++++++-
 src/dynapi/SDL_dynapi_overrides.h                                 |   2 +
 src/dynapi/SDL_dynapi_procs.h                                     |  10 ++++++-
 5 files changed, 38 insertions(+), 4 deletions(-)

diffs (134 lines):

diff -r bbe75e4fc57e -r 8e2ca40e07f3 android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Mon Feb 05 11:40:39 2018 -0800
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Tue Feb 06 15:03:35 2018 -0800
@@ -7,6 +7,7 @@
 
 import android.app.*;
 import android.content.*;
+import android.content.res.Configuration;
 import android.text.InputType;
 import android.view.*;
 import android.view.inputmethod.BaseInputConnection;
@@ -611,6 +612,17 @@
         return SDL.getContext();
     }
 
+    /**
+     * This method is called by SDL using JNI.
+     */
+    public static boolean isAndroidTV() {
+        UiModeManager uiModeManager = (UiModeManager) getContext().getSystemService(UI_MODE_SERVICE);
+        return (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION);
+    }
+
+    /**
+     * This method is called by SDL using JNI.
+     */
     public static DisplayMetrics getDisplayDPI() {
         return getContext().getResources().getDisplayMetrics();
     }
@@ -1027,7 +1039,6 @@
     public static void clipboardSetText(String string) {
         mClipboardHandler.clipboardSetText(string);
     }
-
 }
 
 /**
diff -r bbe75e4fc57e -r 8e2ca40e07f3 include/SDL_system.h
--- a/include/SDL_system.h	Mon Feb 05 11:40:39 2018 -0800
+++ b/include/SDL_system.h	Tue Feb 06 15:03:35 2018 -0800
@@ -109,6 +109,11 @@
 extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void);
 
 /**
+   \brief Return true if the application is running on Android TV
+ */
+extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
+
+/**
    See the official Android developer guide for more information:
    http://developer.android.com/guide/topics/data/data-storage.html
 */
diff -r bbe75e4fc57e -r 8e2ca40e07f3 src/core/android/SDL_android.c
--- a/src/core/android/SDL_android.c	Mon Feb 05 11:40:39 2018 -0800
+++ b/src/core/android/SDL_android.c	Tue Feb 06 15:03:35 2018 -0800
@@ -211,6 +211,7 @@
 static jmethodID midSetActivityTitle;
 static jmethodID midSetOrientation;
 static jmethodID midGetContext;
+static jmethodID midIsAndroidTV;
 static jmethodID midInputGetInputDeviceIds;
 static jmethodID midSendMessage;
 static jmethodID midShowTextInput;
@@ -305,6 +306,8 @@
                                 "setOrientation","(IIZLjava/lang/String;)V");
     midGetContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
                                 "getContext","()Landroid/content/Context;");
+    midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+                                "isAndroidTV","()Z");
     midInputGetInputDeviceIds = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
                                 "inputGetInputDeviceIds", "(I)[I");
     midSendMessage = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
@@ -326,9 +329,10 @@
                                 "getManifestEnvironmentVariables", "()Z");
 
     midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
+    midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
 
     if (!midGetNativeSurface ||
-       !midSetActivityTitle || !midSetOrientation || !midGetContext || !midInputGetInputDeviceIds ||
+       !midSetActivityTitle || !midSetOrientation || !midGetContext || !midIsAndroidTV || !midInputGetInputDeviceIds ||
        !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
        !midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
        !midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables|| !midGetDisplayDPI) {
@@ -1993,6 +1997,12 @@
     return (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
 }
 
+SDL_bool SDL_IsAndroidTV(void)
+{
+    JNIEnv *env = Android_JNI_GetEnv();
+    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsAndroidTV);
+}
+
 const char * SDL_AndroidGetInternalStoragePath(void)
 {
     static char *s_AndroidInternalFilesPath = NULL;
diff -r bbe75e4fc57e -r 8e2ca40e07f3 src/dynapi/SDL_dynapi_overrides.h
--- a/src/dynapi/SDL_dynapi_overrides.h	Mon Feb 05 11:40:39 2018 -0800
+++ b/src/dynapi/SDL_dynapi_overrides.h	Tue Feb 06 15:03:35 2018 -0800
@@ -665,3 +665,5 @@
 #define SDL_GetYUVConversionModeForResolution SDL_GetYUVConversionModeForResolution_REAL
 #define SDL_RenderGetMetalLayer SDL_RenderGetMetalLayer_REAL
 #define SDL_RenderGetMetalCommandEncoder SDL_RenderGetMetalCommandEncoder_REAL
+#define SDL_IsAndroidTV SDL_IsAndroidTV_REAL
+#define SDL_WinRTGetDeviceFamily SDL_WinRTGetDeviceFamily_REAL
diff -r bbe75e4fc57e -r 8e2ca40e07f3 src/dynapi/SDL_dynapi_procs.h
--- a/src/dynapi/SDL_dynapi_procs.h	Mon Feb 05 11:40:39 2018 -0800
+++ b/src/dynapi/SDL_dynapi_procs.h	Tue Feb 06 15:03:35 2018 -0800
@@ -69,12 +69,12 @@
 SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_RenderGetD3D9Device,(SDL_Renderer *a),(a),return)
 #endif
 
-#if defined(__IPHONEOS__) && __IPHONEOS__
+#ifdef __IPHONEOS__
 SDL_DYNAPI_PROC(int,SDL_iPhoneSetAnimationCallback,(SDL_Window *a, int b, void c, void *d),(a,b,c,d),return)
 SDL_DYNAPI_PROC(void,SDL_iPhoneSetEventPump,(SDL_bool a),(a),)
 #endif
 
-#if defined(__ANDROID__) && __ANDROID__
+#ifdef __ANDROID__
 SDL_DYNAPI_PROC(void*,SDL_AndroidGetJNIEnv,(void),(),return)
 SDL_DYNAPI_PROC(void*,SDL_AndroidGetActivity,(void),(),return)
 SDL_DYNAPI_PROC(const char*,SDL_AndroidGetInternalStoragePath,(void),(),return)
@@ -699,3 +699,9 @@
 SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionModeForResolution,(int a, int b),(a,b),return)
 SDL_DYNAPI_PROC(void*,SDL_RenderGetMetalLayer,(SDL_Renderer *a),(a),return)
 SDL_DYNAPI_PROC(void*,SDL_RenderGetMetalCommandEncoder,(SDL_Renderer *a),(a),return)
+#ifdef __WINRT__
+SDL_DYNAPI_PROC(SDL_WinRT_DeviceFamily,SDL_WinRTGetDeviceFamily,(void),(),return)
+#endif
+#ifdef __ANDROID__
+SDL_DYNAPI_PROC(SDL_bool,SDL_IsAndroidTV,(void),(),return)
+#endif


More information about the commits mailing list