From c7810d2101da70cb705e24cedfffb7ea8329df90 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Tue, 11 Mar 2025 22:33:21 +0100 Subject: [PATCH] Fix android compile --- base/project.js | 2 ++ base/sources/backends/android_file_dialog.c | 2 +- base/sources/backends/android_http_request.c | 2 +- base/sources/backends/android_system.c | 28 ++++++++++--------- base/sources/backends/android_system.h | 2 +- .../org/armory3d/IronActivity.kt} | 0 .../org/armory3d/IronMoviePlayer.kt} | 0 .../org/armory3d/IronMovieTexture.kt} | 0 base/sources/backends/vulkan_gpu.c | 4 --- base/sources/backends/vulkan_gpu.h | 4 --- base/sources/iron_file.c | 2 +- base/tools/make.js | 2 +- 12 files changed, 22 insertions(+), 26 deletions(-) rename base/sources/backends/{KincActivity.kt => data/android_java/org/armory3d/IronActivity.kt} (100%) rename base/sources/backends/{KincMoviePlayer.kt => data/android_java/org/armory3d/IronMoviePlayer.kt} (100%) rename base/sources/backends/{KincMovieTexture.kt => data/android_java/org/armory3d/IronMovieTexture.kt} (100%) diff --git a/base/project.js b/base/project.js index 2c22bd82..4fd59c40 100644 --- a/base/project.js +++ b/base/project.js @@ -213,6 +213,8 @@ if (!flags.lite) { add_thread_backend("posix"); add_gpu_backend("vulkan"); project.add_cfiles("sources/backends/android_file_dialog.c"); + project.add_cfiles("sources/backends/android_http_request.c"); + project.add_cfiles("sources/backends/android_native_app_glue.c"); project.add_define("IRON_ANDROID"); project.add_define("IRON_VULKAN"); project.add_define("IRON_ANDROID_API=24"); diff --git a/base/sources/backends/android_file_dialog.c b/base/sources/backends/android_file_dialog.c index 238a788b..7dcbeb01 100644 --- a/base/sources/backends/android_file_dialog.c +++ b/base/sources/backends/android_file_dialog.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include "android_native_app_glue.h" #include #include diff --git a/base/sources/backends/android_http_request.c b/base/sources/backends/android_http_request.c index 78e80610..aa7e1452 100644 --- a/base/sources/backends/android_http_request.c +++ b/base/sources/backends/android_http_request.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include "android_native_app_glue.h" ANativeActivity *iron_android_get_activity(void); jclass iron_android_find_class(JNIEnv *env, const char *name); diff --git a/base/sources/backends/android_system.c b/base/sources/backends/android_system.c index 14dcd2d7..bb19e618 100644 --- a/base/sources/backends/android_system.c +++ b/base/sources/backends/android_system.c @@ -1,10 +1,12 @@ -#include +#include "android_system.h" #include #define EGL_NO_PLATFORM_SPECIFIC_TYPES #include #include -#include +#include +#include +#include "android_native_app_glue.h" #include #include #include @@ -204,10 +206,10 @@ static void touchInput(AInputEvent *event) { case AMOTION_EVENT_ACTION_DOWN: case AMOTION_EVENT_ACTION_POINTER_DOWN: if (id == 0) { - iron_internal_mouse_trigger_press(0, 0, x, y); + iron_internal_mouse_trigger_press(0, x, y); } if (isPenEvent(event)) { - iron_internal_pen_trigger_press(0, x, y, AMotionEvent_getPressure(event, index)); + iron_internal_pen_trigger_press(x, y, AMotionEvent_getPressure(event, index)); } iron_internal_surface_trigger_touch_start(id, x, y); break; @@ -219,10 +221,10 @@ static void touchInput(AInputEvent *event) { x = AMotionEvent_getX(event, i); y = AMotionEvent_getY(event, i); if (id == 0) { - iron_internal_mouse_trigger_move(0, x, y); + iron_internal_mouse_trigger_move(x, y); } if (isPenEvent(event)) { - iron_internal_pen_trigger_move(0, x, y, AMotionEvent_getPressure(event, index)); + iron_internal_pen_trigger_move(x, y, AMotionEvent_getPressure(event, index)); } iron_internal_surface_trigger_move(id, x, y); } @@ -231,17 +233,17 @@ static void touchInput(AInputEvent *event) { case AMOTION_EVENT_ACTION_CANCEL: case AMOTION_EVENT_ACTION_POINTER_UP: if (id == 0) { - iron_internal_mouse_trigger_release(0, 0, x, y); + iron_internal_mouse_trigger_release(0, x, y); } if (isPenEvent(event)) { - iron_internal_pen_trigger_release(0, x, y, AMotionEvent_getPressure(event, index)); + iron_internal_pen_trigger_release(x, y, AMotionEvent_getPressure(event, index)); } iron_internal_surface_trigger_touch_end(id, x, y); break; case AMOTION_EVENT_ACTION_SCROLL: if (id == 0) { float scroll = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_VSCROLL, 0); - iron_internal_mouse_trigger_scroll(0, -(int)scroll); + iron_internal_mouse_trigger_scroll(-(int)scroll); } break; } @@ -879,12 +881,12 @@ static void cmd(struct android_app *app, int32_t cmd) { break; case APP_CMD_RESUME: iron_internal_resume_callback(); - resumeAudio(); + //resumeAudio(); paused = false; break; case APP_CMD_PAUSE: iron_internal_pause_callback(); - pauseAudio(); + //pauseAudio(); paused = true; break; case APP_CMD_STOP: @@ -1114,7 +1116,7 @@ bool iron_internal_handle_messages(void) { int32_t width = iron_android_width(); int32_t height = iron_android_height(); #ifdef IRON_VULKAN - iron_internal_resize(0, width, height); + iron_internal_resize(width, height); #endif iron_internal_call_resize_callback(width, height); } @@ -1172,7 +1174,7 @@ void android_main(struct android_app *application) { app = application; activity = application->activity; initAndroidFileReader(); - IronAndroidVideoInit(); + //IronAndroidVideoInit(); IronAndroidKeyboardInit(); application->onAppCmd = cmd; application->onInputEvent = input; diff --git a/base/sources/backends/android_system.h b/base/sources/backends/android_system.h index 2b280aa1..72a48bc3 100644 --- a/base/sources/backends/android_system.h +++ b/base/sources/backends/android_system.h @@ -1,6 +1,6 @@ #pragma once -#include +#include "android_native_app_glue.h" // name in usual Java syntax (points, no slashes) jclass iron_android_find_class(JNIEnv *env, const char *name); diff --git a/base/sources/backends/KincActivity.kt b/base/sources/backends/data/android_java/org/armory3d/IronActivity.kt similarity index 100% rename from base/sources/backends/KincActivity.kt rename to base/sources/backends/data/android_java/org/armory3d/IronActivity.kt diff --git a/base/sources/backends/KincMoviePlayer.kt b/base/sources/backends/data/android_java/org/armory3d/IronMoviePlayer.kt similarity index 100% rename from base/sources/backends/KincMoviePlayer.kt rename to base/sources/backends/data/android_java/org/armory3d/IronMoviePlayer.kt diff --git a/base/sources/backends/KincMovieTexture.kt b/base/sources/backends/data/android_java/org/armory3d/IronMovieTexture.kt similarity index 100% rename from base/sources/backends/KincMovieTexture.kt rename to base/sources/backends/data/android_java/org/armory3d/IronMovieTexture.kt diff --git a/base/sources/backends/vulkan_gpu.c b/base/sources/backends/vulkan_gpu.c index 7b2bae83..d26b487a 100644 --- a/base/sources/backends/vulkan_gpu.c +++ b/base/sources/backends/vulkan_gpu.c @@ -4313,8 +4313,6 @@ int iron_gpu_index_buffer_count(iron_gpu_index_buffer_t *buffer) { return buffer->impl.count; } -#ifndef IRON_ANDROID - static const int INDEX_RAYGEN = 0; static const int INDEX_MISS = 1; static const int INDEX_CLOSEST_HIT = 2; @@ -5580,5 +5578,3 @@ void iron_gpu_raytrace_dispatch_rays(iron_gpu_command_list_t *command_list) { vkCmdBeginRenderPass(command_list->impl._buffer, ¤t_render_pass_begin_info, VK_SUBPASS_CONTENTS_INLINE); } - -#endif diff --git a/base/sources/backends/vulkan_gpu.h b/base/sources/backends/vulkan_gpu.h index c597fa72..6003a6b7 100644 --- a/base/sources/backends/vulkan_gpu.h +++ b/base/sources/backends/vulkan_gpu.h @@ -218,8 +218,6 @@ typedef struct { VkMemoryAllocateInfo mem_alloc; } IndexBuffer5Impl; -#ifndef IRON_ANDROID - typedef struct { VkPipeline pipeline; VkPipelineLayout pipeline_layout; @@ -243,5 +241,3 @@ typedef struct { VkBuffer instances_buffer; VkDeviceMemory instances_mem; } iron_gpu_raytrace_acceleration_structure_impl_t; - -#endif diff --git a/base/sources/iron_file.c b/base/sources/iron_file.c index ddfc106e..73af9cd6 100644 --- a/base/sources/iron_file.c +++ b/base/sources/iron_file.c @@ -2,7 +2,7 @@ #include "iron_file.h" #include #ifdef IRON_ANDROID -#include +#include #endif #include #include diff --git a/base/tools/make.js b/base/tools/make.js index 0641cb03..7d4aef1f 100644 --- a/base/tools/make.js +++ b/base/tools/make.js @@ -2018,7 +2018,7 @@ class AndroidExporter extends Exporter { for (let dir of project.getJavaDirs()) { javasources += '"' + path_relative(path_join(outdir, 'app'), path_resolve(from, dir)).replace(/\\/g, '/') + '", '; } - javasources += '"' + path_join(irondir, 'sources', 'backends', 'android', 'java').replace(/\\/g, '/') + '"'; + javasources += '"' + path_join(irondir, 'sources', 'backends', 'data', 'android_java').replace(/\\/g, '/') + '"'; gradle = gradle.replace(/{javasources}/g, javasources); fs_writefile(path_join(outdir, 'app', 'build.gradle.kts'), gradle); }