Skip to content

Apply a patch from SDL upstream that fixes orientation settings #2730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;