Support relative mouse for Samsung DeX on Samsung Experience 9.5 or later (Android 8.1 or later)
authorSam Lantinga <slouken@libsdl.org>
Mon, 24 Sep 2018 11:53:04 -0700
changeset 12202453f55c56b16
parent 12201 8bdc4d340419
child 12203 b527a6a49bfd
Support relative mouse for Samsung DeX on Samsung Experience 9.5 or later (Android 8.1 or later)
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Mon Sep 24 11:49:25 2018 -0700
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Mon Sep 24 11:53:04 2018 -0700
     1.3 @@ -766,9 +766,14 @@
     1.4              return false;
     1.5          }
     1.6  
     1.7 -        // Samsung DeX mode doesn't support relative mice properly under Android 7 APIs,
     1.8 -        // and simply returns no data under Android 8 APIs.
     1.9 -        if (isDeXMode()) {
    1.10 +        // DeX mode in Samsung Experience 9.0 and earlier doesn't support relative mice properly under 
    1.11 +        // Android 7 APIs, and simply returns no data under Android 8 APIs.
    1.12 +        //
    1.13 +        // This is fixed in Samsung Experience 9.5, which corresponds to Android 8.1.0, and
    1.14 +        // thus SDK version 27.  If we are in DeX mode and not API 27 or higher, as a result,
    1.15 +        // we should stick to relative mode.
    1.16 +        //
    1.17 +        if ((Build.VERSION.SDK_INT < 27) && isDeXMode()) {
    1.18              return false;
    1.19          }
    1.20  
     2.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java	Mon Sep 24 11:49:25 2018 -0700
     2.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java	Mon Sep 24 11:53:04 2018 -0700
     2.3 @@ -764,7 +764,7 @@
     2.4  
     2.5      @Override
     2.6      public boolean supportsRelativeMouse() {
     2.7 -        return !SDLActivity.isDeXMode();
     2.8 +        return (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27));
     2.9      }
    2.10  
    2.11      @Override
    2.12 @@ -774,7 +774,7 @@
    2.13  
    2.14      @Override
    2.15      public boolean setRelativeMouseEnabled(boolean enabled) {
    2.16 -        if (!SDLActivity.isDeXMode()) {
    2.17 +        if (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27)) {
    2.18              if (enabled) {
    2.19                  SDLActivity.getContentView().requestPointerCapture();
    2.20              }