Skip to content

Commit

Permalink
Apply a patch from SDL upstream that fixes orientation settings (#2730)
Browse files Browse the repository at this point in the history
  • Loading branch information
misl6 authored Jan 2, 2023
1 parent a636b88 commit d3cb478
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pythonforandroid/recipes/sdl2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class LibSDL2Recipe(BootstrapNDKRecipe):

depends = ['sdl2_image', 'sdl2_mixer', 'sdl2_ttf']

patches = ['sdl-orientation-pr-6984.diff']

def get_recipe_env(self, arch=None, with_flags_in_cc=True, with_python=True):
env = super().get_recipe_env(
arch=arch, with_flags_in_cc=with_flags_in_cc, with_python=with_python)
Expand Down
27 changes: 27 additions & 0 deletions pythonforandroid/recipes/sdl2/sdl-orientation-pr-6984.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index 2d7d69b76a25..edb42fb55461 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -971,15 +971,18 @@ public void setOrientationBis(int w, int h, boolean resizable, String hint)
/* If set, hint "explicitly controls which UI orientations are allowed". */
if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
- } else if (hint.contains("LandscapeRight")) {
- orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
} else if (hint.contains("LandscapeLeft")) {
+ orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
+ } else if (hint.contains("LandscapeRight")) {
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
}

- if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) {
+ /* exact match to 'Portrait' to distinguish with PortraitUpsideDown */
+ boolean contains_Portrait = hint.contains("Portrait ") || hint.endsWith("Portrait");
+
+ if (contains_Portrait && hint.contains("PortraitUpsideDown")) {
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
- } else if (hint.contains("Portrait")) {
+ } else if (contains_Portrait) {
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
} else if (hint.contains("PortraitUpsideDown")) {
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;

0 comments on commit d3cb478

Please sign in to comment.