mirror of https://github.com/encounter/SDL.git
Added SDL_IsAndroidTV()
This commit is contained in:
parent
2b441ec6c4
commit
6ed184ec69
|
@ -7,6 +7,7 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
import android.app.*;
|
import android.app.*;
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.view.inputmethod.BaseInputConnection;
|
import android.view.inputmethod.BaseInputConnection;
|
||||||
|
@ -611,6 +612,17 @@ public class SDLActivity extends Activity {
|
||||||
return SDL.getContext();
|
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() {
|
public static DisplayMetrics getDisplayDPI() {
|
||||||
return getContext().getResources().getDisplayMetrics();
|
return getContext().getResources().getDisplayMetrics();
|
||||||
}
|
}
|
||||||
|
@ -1027,7 +1039,6 @@ public class SDLActivity extends Activity {
|
||||||
public static void clipboardSetText(String string) {
|
public static void clipboardSetText(String string) {
|
||||||
mClipboardHandler.clipboardSetText(string);
|
mClipboardHandler.clipboardSetText(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -108,6 +108,11 @@ extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(void);
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void);
|
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:
|
See the official Android developer guide for more information:
|
||||||
http://developer.android.com/guide/topics/data/data-storage.html
|
http://developer.android.com/guide/topics/data/data-storage.html
|
||||||
|
|
|
@ -211,6 +211,7 @@ static jmethodID midGetNativeSurface;
|
||||||
static jmethodID midSetActivityTitle;
|
static jmethodID midSetActivityTitle;
|
||||||
static jmethodID midSetOrientation;
|
static jmethodID midSetOrientation;
|
||||||
static jmethodID midGetContext;
|
static jmethodID midGetContext;
|
||||||
|
static jmethodID midIsAndroidTV;
|
||||||
static jmethodID midInputGetInputDeviceIds;
|
static jmethodID midInputGetInputDeviceIds;
|
||||||
static jmethodID midSendMessage;
|
static jmethodID midSendMessage;
|
||||||
static jmethodID midShowTextInput;
|
static jmethodID midShowTextInput;
|
||||||
|
@ -305,6 +306,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass c
|
||||||
"setOrientation","(IIZLjava/lang/String;)V");
|
"setOrientation","(IIZLjava/lang/String;)V");
|
||||||
midGetContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
midGetContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
||||||
"getContext","()Landroid/content/Context;");
|
"getContext","()Landroid/content/Context;");
|
||||||
|
midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
||||||
|
"isAndroidTV","()Z");
|
||||||
midInputGetInputDeviceIds = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
midInputGetInputDeviceIds = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
||||||
"inputGetInputDeviceIds", "(I)[I");
|
"inputGetInputDeviceIds", "(I)[I");
|
||||||
midSendMessage = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
midSendMessage = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
||||||
|
@ -326,9 +329,10 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass c
|
||||||
"getManifestEnvironmentVariables", "()Z");
|
"getManifestEnvironmentVariables", "()Z");
|
||||||
|
|
||||||
midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
|
midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
|
||||||
|
midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
|
||||||
|
|
||||||
if (!midGetNativeSurface ||
|
if (!midGetNativeSurface ||
|
||||||
!midSetActivityTitle || !midSetOrientation || !midGetContext || !midInputGetInputDeviceIds ||
|
!midSetActivityTitle || !midSetOrientation || !midGetContext || !midIsAndroidTV || !midInputGetInputDeviceIds ||
|
||||||
!midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
|
!midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
|
||||||
!midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
|
!midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
|
||||||
!midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables|| !midGetDisplayDPI) {
|
!midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables|| !midGetDisplayDPI) {
|
||||||
|
@ -1993,6 +1997,12 @@ void *SDL_AndroidGetActivity(void)
|
||||||
return (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
|
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)
|
const char * SDL_AndroidGetInternalStoragePath(void)
|
||||||
{
|
{
|
||||||
static char *s_AndroidInternalFilesPath = NULL;
|
static char *s_AndroidInternalFilesPath = NULL;
|
||||||
|
|
|
@ -665,3 +665,5 @@
|
||||||
#define SDL_GetYUVConversionModeForResolution SDL_GetYUVConversionModeForResolution_REAL
|
#define SDL_GetYUVConversionModeForResolution SDL_GetYUVConversionModeForResolution_REAL
|
||||||
#define SDL_RenderGetMetalLayer SDL_RenderGetMetalLayer_REAL
|
#define SDL_RenderGetMetalLayer SDL_RenderGetMetalLayer_REAL
|
||||||
#define SDL_RenderGetMetalCommandEncoder SDL_RenderGetMetalCommandEncoder_REAL
|
#define SDL_RenderGetMetalCommandEncoder SDL_RenderGetMetalCommandEncoder_REAL
|
||||||
|
#define SDL_IsAndroidTV SDL_IsAndroidTV_REAL
|
||||||
|
#define SDL_WinRTGetDeviceFamily SDL_WinRTGetDeviceFamily_REAL
|
||||||
|
|
|
@ -69,12 +69,12 @@ SDL_DYNAPI_PROC(int,SDL_Direct3D9GetAdapterIndex,(int a),(a),return)
|
||||||
SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_RenderGetD3D9Device,(SDL_Renderer *a),(a),return)
|
SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_RenderGetD3D9Device,(SDL_Renderer *a),(a),return)
|
||||||
#endif
|
#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(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),)
|
SDL_DYNAPI_PROC(void,SDL_iPhoneSetEventPump,(SDL_bool a),(a),)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__ANDROID__) && __ANDROID__
|
#ifdef __ANDROID__
|
||||||
SDL_DYNAPI_PROC(void*,SDL_AndroidGetJNIEnv,(void),(),return)
|
SDL_DYNAPI_PROC(void*,SDL_AndroidGetJNIEnv,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(void*,SDL_AndroidGetActivity,(void),(),return)
|
SDL_DYNAPI_PROC(void*,SDL_AndroidGetActivity,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(const char*,SDL_AndroidGetInternalStoragePath,(void),(),return)
|
SDL_DYNAPI_PROC(const char*,SDL_AndroidGetInternalStoragePath,(void),(),return)
|
||||||
|
@ -699,3 +699,9 @@ SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionMode,(void),(),retur
|
||||||
SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionModeForResolution,(int a, int b),(a,b),return)
|
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_RenderGetMetalLayer,(SDL_Renderer *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(void*,SDL_RenderGetMetalCommandEncoder,(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
|
||||||
|
|
Loading…
Reference in New Issue