Skip to content

Commit

Permalink
Build with Android ndk r27c.
Browse files Browse the repository at this point in the history
This required fixing an issuew with SDL sensor events using a
removed API.
  • Loading branch information
renpytom committed Dec 22, 2024
1 parent 80fca78 commit 2e2c3f8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
44 changes: 44 additions & 0 deletions patches/SDL2-2.0.20/android-alooper-fix.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Backport ALooper_poolAll fix.

From: Tom Rothamel <[email protected]>

From https://github.com/libsdl-org/SDL/pull/9807
---
src/sensor/android/SDL_androidsensor.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c
index e6cfc23..d4179bf 100644
--- a/src/sensor/android/SDL_androidsensor.c
+++ b/src/sensor/android/SDL_androidsensor.c
@@ -163,7 +163,7 @@ SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index)
sensor->hwdata = hwdata;
return 0;
}
-
+
static void
SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor)
{
@@ -171,10 +171,17 @@ SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor)
ASensorEvent event;
struct android_poll_source* source;

- if (ALooper_pollAll(0, NULL, &events, (void**)&source) == LOOPER_ID_USER) {
- SDL_zero(event);
- while (ASensorEventQueue_getEvents(sensor->hwdata->eventqueue, &event, 1) > 0) {
- SDL_PrivateSensorUpdate(sensor, event.data, SDL_arraysize(event.data));
+ while (1) {
+ int result = ALooper_pollOnce(0, NULL, &events, (void**)&source);
+ if (result == LOOPER_ID_USER) {
+ SDL_zero(event);
+ while (ASensorEventQueue_getEvents(sensor->hwdata->eventqueue, &event, 1) > 0) {
+ SDL_PrivateSensorUpdate(sensor, event.data, SDL_arraysize(event.data));
+ }
+ }
+
+ if (result <0) {
+ break;
}
}
}
1 change: 1 addition & 0 deletions patches/SDL2-2.0.20/series
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ declaration-after-statement.diff
android-no-multi-window.diff
x11-numlock-capslock-scrolllock.diff
x11-ime.diff
android-alooper-fix.diff
4 changes: 3 additions & 1 deletion renpybuild/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def build_environment(c):
emsdk_environment(c)

if c.platform == "android":
c.var("ndk_version", "android-ndk-r25c")
c.var("ndk_version", "android-ndk-r27c")

cpuccount = os.cpu_count()

Expand Down Expand Up @@ -259,6 +259,7 @@ def build_environment(c):
android_llvm(c, "x86_64")

c.env("CFLAGS", "{{ CFLAGS }} -DSDL_MAIN_HANDLED")
c.env("LDFLAGS", "{{ LDFLAGS }} -Wl,-z,max-page-size=16384")

c.var("cmake_system_name", "Android")
c.var("cmake_system_processor", "x86_64")
Expand All @@ -270,6 +271,7 @@ def build_environment(c):
android_llvm(c, "aarch64")

c.env("CFLAGS", "{{ CFLAGS }} -DSDL_MAIN_HANDLED")
c.env("LDFLAGS", "{{ LDFLAGS }} -Wl,-z,max-page-size=16384")

c.var("cmake_system_name", "Android")
c.var("cmake_system_processor", "aarch64")
Expand Down
4 changes: 2 additions & 2 deletions tars/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
old/

android-ndk-r25c-linux.zip
android-ndk-r27c-linux.zip
CubismSdkForNative-4-r.6.2.zip
iPhoneOS14.0.sdk.tar.gz
iPhoneSimulator14.0.sdk.tar.gz
llvm-mingw-20220906-ucrt-ubuntu-18.04-x86_64.tar.xz
llvm-mingw-*
MacOSX10.10.sdk.tar.bz2
MacOSX12.3.sdk.tar.bz2
steamworks_sdk_160.zip
2 changes: 1 addition & 1 deletion tars/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Run ./ios_toolchains.sh /path/to/Xcode.app
Android NDK
-----------

* android-ndk-r25c-linux.zip
* android-ndk-r27c-linux.zip

Downloaded from https://developer.android.com/ndk/downloads .

Expand Down

0 comments on commit 2e2c3f8

Please sign in to comment.