Skip to content

Commit

Permalink
Create new patch and set new include dir for sdl_image
Browse files Browse the repository at this point in the history
  • Loading branch information
misl6 committed Dec 3, 2023
1 parent e7ef1e4 commit 073fc17
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
--- a/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/src/main/java/org/libsdl/app/SDLActivity.java
@@ -222,6 +222,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
@@ -221,6 +221,8 @@

// This is what SDL runs in. It invokes SDL_main(), eventually
protected static Thread mSDLThread;

+ public static int keyboardInputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
+
+ public static int keyboardInputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;

protected static SDLGenericMotionListener_API12 getMotionListener() {
if (mMotionListener == null) {
if (Build.VERSION.SDK_INT >= 26) {
@@ -324,6 +326,15 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
@@ -323,6 +325,15 @@
Log.v(TAG, "Model: " + Build.MODEL);
Log.v(TAG, "onCreate()");
super.onCreate(savedInstanceState);
+
+ SDLActivity.initialize();
+ // So we can call stuff from static callbacks
+ mSingleton = this;
Expand All @@ -21,11 +22,10 @@
+ // We don't do this in onCreate because we unpack and load the app data on a thread
+ // and we can't run setup tasks until that thread completes.
+ protected void finishLoad() {
+
try {
Thread.currentThread().setName("SDLActivity");
} catch (Exception e) {
@@ -835,7 +846,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
@@ -837,7 +848,7 @@
Handler commandHandler = new SDLCommandHandler();

// Send a message from the SDLMain thread
Expand All @@ -34,36 +34,38 @@
Message msg = commandHandler.obtainMessage();
msg.arg1 = command;
msg.obj = data;
@@ -1384,6 +1395,20 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
@@ -1385,7 +1396,22 @@
return null;
}
return SDLActivity.mSurface.getNativeSurface();
+ }
+
+ /**
+ * Calls turnActive() on singleton to keep loading screen active
+ */
+ public static void triggerAppConfirmedActive() {
+ mSingleton.appConfirmedActive();
}

+ /**
+ * Calls turnActive() on singleton to keep loading screen active
+ */
+ public static void triggerAppConfirmedActive() {
+ mSingleton.appConfirmedActive();
+ }
+
+ /**
+ * Trick needed for loading screen, overridden by PythonActivity
+ * to keep loading screen active
+ */
+ public void appConfirmedActive() {
+ }
+
+ /**
+ * Trick needed for loading screen, overridden by PythonActivity
+ * to keep loading screen active
+ */
+ public void appConfirmedActive() {
+ }
+

// Input

/**
@@ -1878,6 +1903,7 @@ class SDLMain implements Runnable {
@@ -1881,6 +1907,7 @@

Log.v("SDL", "Running main function " + function + " from library " + library);

+ SDLActivity.mSingleton.appConfirmedActive();
SDLActivity.nativeRunMain(library, function, arguments);

Log.v("SDL", "Finished main function");
@@ -1935,8 +1961,7 @@ class DummyEdit extends View implements View.OnKeyListener {
@@ -1938,8 +1965,7 @@
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
ic = new SDLInputConnection(this, true);

Expand Down
3 changes: 2 additions & 1 deletion pythonforandroid/recipes/kivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ def get_recipe_env(self, arch):
env['USE_SDL2'] = '1'
env['KIVY_SPLIT_EXAMPLES'] = '1'
sdl2_mixer_recipe = self.get_recipe('sdl2_mixer', self.ctx)
sdl2_image_recipe = self.get_recipe('sdl2_image', self.ctx)
env['KIVY_SDL2_PATH'] = ':'.join([
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'),
*sdl2_image_recipe.get_include_dirs(arch),
*sdl2_mixer_recipe.get_include_dirs(arch),
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
])
Expand Down
7 changes: 6 additions & 1 deletion pythonforandroid/recipes/pygame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,18 @@ def prebuild_arch(self, arch):
for include_dir in sdl2_mixer_recipe.get_include_dirs(arch):
sdl_mixer_includes += f"-I{include_dir} "

sdl2_image_includes = ""
sdl2_image_recipe = self.get_recipe('sdl2_image', self.ctx)
for include_dir in sdl2_image_recipe.get_include_dirs(arch):
sdl2_image_includes += f"-I{include_dir} "

setup_file = setup_template.format(
sdl_includes=(
" -I" + join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include') +
" -L" + join(self.ctx.bootstrap.build_dir, "libs", str(arch)) +
" -L" + png_lib_dir + " -L" + jpeg_lib_dir + " -L" + arch.ndk_lib_dir_versioned),
sdl_ttf_includes="-I"+join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
sdl_image_includes="-I"+join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'),
sdl_image_includes=sdl2_image_includes,
sdl_mixer_includes=sdl_mixer_includes,
jpeg_includes="-I"+jpeg_inc_dir,
png_includes="-I"+png_inc_dir,
Expand Down
5 changes: 5 additions & 0 deletions pythonforandroid/recipes/sdl2_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class LibSDL2Image(BootstrapNDKRecipe):

patches = ['enable-webp.patch']

def get_include_dirs(self, arch):
return [
os.path.join(self.ctx.bootstrap.build_dir, "jni", "SDL2_image", "include")
]

def prebuild_arch(self, arch):
# We do not have a folder for each arch on BootstrapNDKRecipe, so we
# need to skip the external deps download if we already have done it.
Expand Down

0 comments on commit 073fc17

Please sign in to comment.