Added SDL_IsChromebook() to determine if we're running on a Chromebook.
authorSam Lantinga <slouken@libsdl.org>
Tue, 05 Jun 2018 12:46:13 -0700
changeset 1200891f9b8f22b17
parent 12007 ecfb6a793c30
child 12009 5b41aa10b12f
Added SDL_IsChromebook() to determine if we're running on a Chromebook.
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
include/SDL_system.h
src/core/android/SDL_android.c
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Tue Jun 05 12:46:11 2018 -0700
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Tue Jun 05 12:46:13 2018 -0700
     1.3 @@ -698,6 +698,13 @@
     1.4      /**
     1.5       * This method is called by SDL using JNI.
     1.6       */
     1.7 +    public static boolean isChromebook() {
     1.8 +        return getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
     1.9 +    }    
    1.10 +
    1.11 +    /**
    1.12 +     * This method is called by SDL using JNI.
    1.13 +     */
    1.14      public static DisplayMetrics getDisplayDPI() {
    1.15          return getContext().getResources().getDisplayMetrics();
    1.16      }
     2.1 --- a/include/SDL_system.h	Tue Jun 05 12:46:11 2018 -0700
     2.2 +++ b/include/SDL_system.h	Tue Jun 05 12:46:13 2018 -0700
     2.3 @@ -126,6 +126,11 @@
     2.4  extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
     2.5  
     2.6  /**
     2.7 +   \brief Return true if the application is running on a Chromebook
     2.8 + */
     2.9 +extern DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
    2.10 +
    2.11 +/**
    2.12     See the official Android developer guide for more information:
    2.13     http://developer.android.com/guide/topics/data/data-storage.html
    2.14  */
     3.1 --- a/src/core/android/SDL_android.c	Tue Jun 05 12:46:11 2018 -0700
     3.2 +++ b/src/core/android/SDL_android.c	Tue Jun 05 12:46:13 2018 -0700
     3.3 @@ -213,6 +213,7 @@
     3.4  static jmethodID midSetOrientation;
     3.5  static jmethodID midGetContext;
     3.6  static jmethodID midIsAndroidTV;
     3.7 +static jmethodID midIsChromebook;
     3.8  static jmethodID midInputGetInputDeviceIds;
     3.9  static jmethodID midSendMessage;
    3.10  static jmethodID midShowTextInput;
    3.11 @@ -316,6 +317,8 @@
    3.12                                  "getContext","()Landroid/content/Context;");
    3.13      midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    3.14                                  "isAndroidTV","()Z");
    3.15 +    midIsChromebook = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    3.16 +                                "isChromebook", "()Z");
    3.17      midInputGetInputDeviceIds = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    3.18                                  "inputGetInputDeviceIds", "(I)[I");
    3.19      midSendMessage = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    3.20 @@ -349,7 +352,8 @@
    3.21         !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
    3.22         !midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
    3.23         !midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables || !midGetDisplayDPI ||
    3.24 -       !midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor || !midSupportsRelativeMouse || !midSetRelativeMouseEnabled) {
    3.25 +       !midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor || !midSupportsRelativeMouse || !midSetRelativeMouseEnabled ||
    3.26 +       !midIsChromebook) {
    3.27          __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
    3.28      }
    3.29  
    3.30 @@ -2024,6 +2028,12 @@
    3.31      return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsAndroidTV);
    3.32  }
    3.33  
    3.34 +SDL_bool SDL_IsChromebook(void)
    3.35 +{
    3.36 +    JNIEnv *env = Android_JNI_GetEnv();
    3.37 +    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsChromebook);
    3.38 +}
    3.39 +
    3.40  const char * SDL_AndroidGetInternalStoragePath(void)
    3.41  {
    3.42      static char *s_AndroidInternalFilesPath = NULL;
     4.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Tue Jun 05 12:46:11 2018 -0700
     4.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Tue Jun 05 12:46:13 2018 -0700
     4.3 @@ -672,3 +672,4 @@
     4.4  #define SDL_GameControllerMappingForDeviceIndex SDL_GameControllerMappingForDeviceIndex_REAL
     4.5  #define SDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority_REAL
     4.6  #define SDL_HasAVX512F SDL_HasAVX512F_REAL
     4.7 +#define SDL_IsChromebook SDL_IsChromebook_REAL
     5.1 --- a/src/dynapi/SDL_dynapi_procs.h	Tue Jun 05 12:46:11 2018 -0700
     5.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Tue Jun 05 12:46:13 2018 -0700
     5.3 @@ -712,3 +712,6 @@
     5.4  SDL_DYNAPI_PROC(int,SDL_LinuxSetThreadPriority,(Sint64 a, int b),(a,b),return)
     5.5  #endif
     5.6  SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX512F,(void),(),return)
     5.7 +#ifdef __ANDROID__
     5.8 +SDL_DYNAPI_PROC(SDL_bool,SDL_IsChromebook,(void),(),return)
     5.9 +#endif