mirror of https://github.com/encounter/SDL.git
Moved SDL_IsTablet() to a cross-platform API function
This commit is contained in:
parent
e9f6805fc6
commit
6f758ad25f
|
@ -174,15 +174,6 @@ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(void);
|
||||||
|
|
||||||
#endif /* __ANDROID__ */
|
#endif /* __ANDROID__ */
|
||||||
|
|
||||||
#if defined(__ANDROID__) || defined(__IPHONEOS__)
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief Return true if the current device is a tablet.
|
|
||||||
*/
|
|
||||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Platform specific functions for WinRT */
|
/* Platform specific functions for WinRT */
|
||||||
#if defined(__WINRT__) && __WINRT__
|
#if defined(__WINRT__) && __WINRT__
|
||||||
|
|
||||||
|
@ -272,6 +263,11 @@ extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily();
|
||||||
|
|
||||||
#endif /* __WINRT__ */
|
#endif /* __WINRT__ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Return true if the current device is a tablet.
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void);
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
/* Ends C function definitions when using C++ */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
14
src/SDL.c
14
src/SDL.c
|
@ -475,6 +475,20 @@ SDL_GetPlatform()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_bool
|
||||||
|
SDL_IsTablet()
|
||||||
|
{
|
||||||
|
#if __ANDROID__
|
||||||
|
extern SDL_bool SDL_IsAndroidTablet(void);
|
||||||
|
return SDL_IsAndroidTablet();
|
||||||
|
#elif __IPHONEOS__
|
||||||
|
extern SDL_bool SDL_IsIPad(void);
|
||||||
|
return SDL_IsIPad();
|
||||||
|
#else
|
||||||
|
return SDL_FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__)
|
||||||
|
|
||||||
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
|
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
|
||||||
|
|
|
@ -213,6 +213,7 @@ static jmethodID midSetActivityTitle;
|
||||||
static jmethodID midSetWindowStyle;
|
static jmethodID midSetWindowStyle;
|
||||||
static jmethodID midSetOrientation;
|
static jmethodID midSetOrientation;
|
||||||
static jmethodID midGetContext;
|
static jmethodID midGetContext;
|
||||||
|
static jmethodID midIsTablet;
|
||||||
static jmethodID midIsAndroidTV;
|
static jmethodID midIsAndroidTV;
|
||||||
static jmethodID midIsChromebook;
|
static jmethodID midIsChromebook;
|
||||||
static jmethodID midIsDeXMode;
|
static jmethodID midIsDeXMode;
|
||||||
|
@ -232,7 +233,6 @@ static jmethodID midSetCustomCursor;
|
||||||
static jmethodID midSetSystemCursor;
|
static jmethodID midSetSystemCursor;
|
||||||
static jmethodID midSupportsRelativeMouse;
|
static jmethodID midSupportsRelativeMouse;
|
||||||
static jmethodID midSetRelativeMouseEnabled;
|
static jmethodID midSetRelativeMouseEnabled;
|
||||||
static jmethodID midIsTablet;
|
|
||||||
|
|
||||||
/* audio manager */
|
/* audio manager */
|
||||||
static jclass mAudioManagerClass;
|
static jclass mAudioManagerClass;
|
||||||
|
@ -319,6 +319,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;");
|
||||||
|
midIsTablet = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
||||||
|
"isTablet", "()Z");
|
||||||
midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
||||||
"isAndroidTV","()Z");
|
"isAndroidTV","()Z");
|
||||||
midIsChromebook = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
midIsChromebook = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
||||||
|
@ -355,15 +357,14 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass c
|
||||||
midSupportsRelativeMouse = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "supportsRelativeMouse", "()Z");
|
midSupportsRelativeMouse = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "supportsRelativeMouse", "()Z");
|
||||||
midSetRelativeMouseEnabled = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setRelativeMouseEnabled", "(Z)Z");
|
midSetRelativeMouseEnabled = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setRelativeMouseEnabled", "(Z)Z");
|
||||||
|
|
||||||
midIsTablet = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "isTablet", "()Z");
|
|
||||||
|
|
||||||
if (!midGetNativeSurface ||
|
if (!midGetNativeSurface ||
|
||||||
!midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midGetContext || !midIsAndroidTV || !midInputGetInputDeviceIds ||
|
!midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midGetContext || !midIsTablet || !midIsAndroidTV || !midInputGetInputDeviceIds ||
|
||||||
!midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
|
!midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
|
||||||
!midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
|
!midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
|
||||||
!midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables || !midGetDisplayDPI ||
|
!midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables || !midGetDisplayDPI ||
|
||||||
!midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor || !midSupportsRelativeMouse || !midSetRelativeMouseEnabled ||
|
!midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor || !midSupportsRelativeMouse || !midSetRelativeMouseEnabled ||
|
||||||
!midIsChromebook || !midIsDeXMode || !midManualBackButton || !midIsTablet) {
|
!midIsChromebook || !midIsDeXMode || !midManualBackButton) {
|
||||||
__android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
|
__android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2033,6 +2034,12 @@ void *SDL_AndroidGetActivity(void)
|
||||||
return (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
|
return (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_bool SDL_IsAndroidTablet(void)
|
||||||
|
{
|
||||||
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsTablet);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IsAndroidTV(void)
|
SDL_bool SDL_IsAndroidTV(void)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
|
@ -2051,12 +2058,6 @@ SDL_bool SDL_IsDeXMode(void)
|
||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsDeXMode);
|
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsDeXMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IsTablet(void)
|
|
||||||
{
|
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
|
||||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsTablet);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDL_AndroidBackButton(void)
|
void SDL_AndroidBackButton(void)
|
||||||
{
|
{
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
|
|
|
@ -680,8 +680,6 @@
|
||||||
#define SDL_wcsdup SDL_wcsdup_REAL
|
#define SDL_wcsdup SDL_wcsdup_REAL
|
||||||
#define SDL_GameControllerRumble SDL_GameControllerRumble_REAL
|
#define SDL_GameControllerRumble SDL_GameControllerRumble_REAL
|
||||||
#define SDL_JoystickRumble SDL_JoystickRumble_REAL
|
#define SDL_JoystickRumble SDL_JoystickRumble_REAL
|
||||||
#define SDL_IsTablet SDL_IsTablet_REAL
|
|
||||||
#define SDL_IsTablet SDL_IsTablet_REAL
|
|
||||||
#define SDL_NumSensors SDL_NumSensors_REAL
|
#define SDL_NumSensors SDL_NumSensors_REAL
|
||||||
#define SDL_SensorGetDeviceName SDL_SensorGetDeviceName_REAL
|
#define SDL_SensorGetDeviceName SDL_SensorGetDeviceName_REAL
|
||||||
#define SDL_SensorGetDeviceType SDL_SensorGetDeviceType_REAL
|
#define SDL_SensorGetDeviceType SDL_SensorGetDeviceType_REAL
|
||||||
|
@ -696,3 +694,4 @@
|
||||||
#define SDL_SensorGetData SDL_SensorGetData_REAL
|
#define SDL_SensorGetData SDL_SensorGetData_REAL
|
||||||
#define SDL_SensorClose SDL_SensorClose_REAL
|
#define SDL_SensorClose SDL_SensorClose_REAL
|
||||||
#define SDL_SensorUpdate SDL_SensorUpdate_REAL
|
#define SDL_SensorUpdate SDL_SensorUpdate_REAL
|
||||||
|
#define SDL_IsTablet SDL_IsTablet_REAL
|
||||||
|
|
|
@ -722,9 +722,6 @@ SDL_DYNAPI_PROC(float,SDL_expf,(float a),(a),return)
|
||||||
SDL_DYNAPI_PROC(wchar_t*,SDL_wcsdup,(const wchar_t *a),(a),return)
|
SDL_DYNAPI_PROC(wchar_t*,SDL_wcsdup,(const wchar_t *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_GameControllerRumble,(SDL_GameController *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
|
SDL_DYNAPI_PROC(int,SDL_GameControllerRumble,(SDL_GameController *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_JoystickRumble,(SDL_Joystick *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
|
SDL_DYNAPI_PROC(int,SDL_JoystickRumble,(SDL_Joystick *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return)
|
||||||
#if defined(__ANDROID__) || defined(__IPHONEOS__)
|
|
||||||
SDL_DYNAPI_PROC(SDL_bool,SDL_IsTablet,(void),(),return)
|
|
||||||
#endif
|
|
||||||
SDL_DYNAPI_PROC(int,SDL_NumSensors,(void),(),return)
|
SDL_DYNAPI_PROC(int,SDL_NumSensors,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(const char*,SDL_SensorGetDeviceName,(int a),(a),return)
|
SDL_DYNAPI_PROC(const char*,SDL_SensorGetDeviceName,(int a),(a),return)
|
||||||
SDL_DYNAPI_PROC(SDL_SensorType,SDL_SensorGetDeviceType,(int a),(a),return)
|
SDL_DYNAPI_PROC(SDL_SensorType,SDL_SensorGetDeviceType,(int a),(a),return)
|
||||||
|
@ -739,3 +736,4 @@ SDL_DYNAPI_PROC(SDL_SensorID,SDL_SensorGetInstanceID,(SDL_Sensor *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_SensorGetData,(SDL_Sensor *a, float *b, int c),(a,b,c),return)
|
SDL_DYNAPI_PROC(int,SDL_SensorGetData,(SDL_Sensor *a, float *b, int c),(a,b,c),return)
|
||||||
SDL_DYNAPI_PROC(void,SDL_SensorClose,(SDL_Sensor *a),(a),)
|
SDL_DYNAPI_PROC(void,SDL_SensorClose,(SDL_Sensor *a),(a),)
|
||||||
SDL_DYNAPI_PROC(void,SDL_SensorUpdate,(void),(),)
|
SDL_DYNAPI_PROC(void,SDL_SensorUpdate,(void),(),)
|
||||||
|
SDL_DYNAPI_PROC(SDL_bool,SDL_IsTablet,(void),(),return)
|
||||||
|
|
|
@ -237,9 +237,9 @@ void SDL_NSLog(const char *text)
|
||||||
* iOS Tablet detection
|
* iOS Tablet detection
|
||||||
*
|
*
|
||||||
* This doesn't really have aything to do with the interfaces of the SDL video
|
* This doesn't really have aything to do with the interfaces of the SDL video
|
||||||
* subsystem, but we need to stuff this into an Objective-C source code file.
|
* subsystem, but we need to stuff this into an Objective-C source code file.
|
||||||
*/
|
*/
|
||||||
SDL_bool SDL_IsTablet(void)
|
SDL_bool SDL_IsIPad(void)
|
||||||
{
|
{
|
||||||
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
|
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue