Skip to content

Commit d3cb478

Browse files
authored
Apply a patch from SDL upstream that fixes orientation settings (kivy#2730)
1 parent a636b88 commit d3cb478

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

pythonforandroid/recipes/sdl2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class LibSDL2Recipe(BootstrapNDKRecipe):
1414

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

17+
patches = ['sdl-orientation-pr-6984.diff']
18+
1719
def get_recipe_env(self, arch=None, with_flags_in_cc=True, with_python=True):
1820
env = super().get_recipe_env(
1921
arch=arch, with_flags_in_cc=with_flags_in_cc, with_python=with_python)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
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
2+
index 2d7d69b76a25..edb42fb55461 100644
3+
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
4+
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
5+
@@ -971,15 +971,18 @@ public void setOrientationBis(int w, int h, boolean resizable, String hint)
6+
/* If set, hint "explicitly controls which UI orientations are allowed". */
7+
if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
8+
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
9+
- } else if (hint.contains("LandscapeRight")) {
10+
- orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
11+
} else if (hint.contains("LandscapeLeft")) {
12+
+ orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
13+
+ } else if (hint.contains("LandscapeRight")) {
14+
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
15+
}
16+
17+
- if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) {
18+
+ /* exact match to 'Portrait' to distinguish with PortraitUpsideDown */
19+
+ boolean contains_Portrait = hint.contains("Portrait ") || hint.endsWith("Portrait");
20+
+
21+
+ if (contains_Portrait && hint.contains("PortraitUpsideDown")) {
22+
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
23+
- } else if (hint.contains("Portrait")) {
24+
+ } else if (contains_Portrait) {
25+
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
26+
} else if (hint.contains("PortraitUpsideDown")) {
27+
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;

0 commit comments

Comments
 (0)