Skip to content

Commit

Permalink
Added SDL_IsChromebook() to determine if we're running on a Chromebook.
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jun 5, 2018
1 parent 2dedbc7 commit 113801b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
Expand Up @@ -695,6 +695,13 @@ public static boolean isAndroidTV() {
return (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION);
}

/**
* This method is called by SDL using JNI.
*/
public static boolean isChromebook() {
return getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
}

/**
* This method is called by SDL using JNI.
*/
Expand Down
5 changes: 5 additions & 0 deletions include/SDL_system.h
Expand Up @@ -125,6 +125,11 @@ extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void);
*/
extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);

/**
\brief Return true if the application is running on a Chromebook
*/
extern DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);

/**
See the official Android developer guide for more information:
http://developer.android.com/guide/topics/data/data-storage.html
Expand Down
12 changes: 11 additions & 1 deletion src/core/android/SDL_android.c
Expand Up @@ -213,6 +213,7 @@ static jmethodID midSetWindowStyle;
static jmethodID midSetOrientation;
static jmethodID midGetContext;
static jmethodID midIsAndroidTV;
static jmethodID midIsChromebook;
static jmethodID midInputGetInputDeviceIds;
static jmethodID midSendMessage;
static jmethodID midShowTextInput;
Expand Down Expand Up @@ -316,6 +317,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass c
"getContext","()Landroid/content/Context;");
midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
"isAndroidTV","()Z");
midIsChromebook = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
"isChromebook", "()Z");
midInputGetInputDeviceIds = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
"inputGetInputDeviceIds", "(I)[I");
midSendMessage = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
Expand Down Expand Up @@ -349,7 +352,8 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass c
!midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
!midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
!midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables || !midGetDisplayDPI ||
!midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor || !midSupportsRelativeMouse || !midSetRelativeMouseEnabled) {
!midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor || !midSupportsRelativeMouse || !midSetRelativeMouseEnabled ||
!midIsChromebook) {
__android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
}

Expand Down Expand Up @@ -2024,6 +2028,12 @@ SDL_bool SDL_IsAndroidTV(void)
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsAndroidTV);
}

SDL_bool SDL_IsChromebook(void)
{
JNIEnv *env = Android_JNI_GetEnv();
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsChromebook);
}

const char * SDL_AndroidGetInternalStoragePath(void)
{
static char *s_AndroidInternalFilesPath = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/dynapi/SDL_dynapi_overrides.h
Expand Up @@ -672,3 +672,4 @@
#define SDL_GameControllerMappingForDeviceIndex SDL_GameControllerMappingForDeviceIndex_REAL
#define SDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority_REAL
#define SDL_HasAVX512F SDL_HasAVX512F_REAL
#define SDL_IsChromebook SDL_IsChromebook_REAL
3 changes: 3 additions & 0 deletions src/dynapi/SDL_dynapi_procs.h
Expand Up @@ -712,3 +712,6 @@ SDL_DYNAPI_PROC(char*,SDL_GameControllerMappingForDeviceIndex,(int a),(a),return
SDL_DYNAPI_PROC(int,SDL_LinuxSetThreadPriority,(Sint64 a, int b),(a,b),return)
#endif
SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX512F,(void),(),return)
#ifdef __ANDROID__
SDL_DYNAPI_PROC(SDL_bool,SDL_IsChromebook,(void),(),return)
#endif

0 comments on commit 113801b

Please sign in to comment.