Android Port

This commit is contained in:
Anders Jenbo 2025-07-07 20:13:07 +02:00
parent cf3658a712
commit 97cafa43ae
32 changed files with 242 additions and 33 deletions

View File

@ -24,6 +24,7 @@ DetectTargetCPUArchitectures(ISLE_CPUS)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON)
if (NOT MINGW) if (NOT MINGW)
set(NOT_MINGW ON) set(NOT_MINGW ON)
@ -482,8 +483,13 @@ if (NOT ISLE_MINIWIN)
endif() endif()
if (ISLE_BUILD_APP) if (ISLE_BUILD_APP)
add_executable(isle WIN32 if(ANDROID)
ISLE/res/isle.rc add_library(isle SHARED)
else()
add_executable(isle WIN32)
target_sources(isle PRIVATE ISLE/res/isle.rc)
endif()
target_sources(isle PRIVATE
ISLE/isleapp.cpp ISLE/isleapp.cpp
ISLE/islefiles.cpp ISLE/islefiles.cpp
${CMAKE_SOURCE_DIR}/ISLE/res/arrow_bmp.h ${CMAKE_SOURCE_DIR}/ISLE/res/arrow_bmp.h
@ -545,6 +551,9 @@ if (ISLE_BUILD_APP)
ISLE/3ds/config.cpp ISLE/3ds/config.cpp
) )
endif() endif()
if(ANDROID)
target_sources(isle PRIVATE ISLE/android/config.cpp)
endif()
if(WINDOWS_STORE) if(WINDOWS_STORE)
target_sources(isle PRIVATE target_sources(isle PRIVATE
ISLE/xbox_one_series/config.cpp ISLE/xbox_one_series/config.cpp

12
ISLE/android/config.cpp Normal file
View File

@ -0,0 +1,12 @@
#include "config.h"
#include <SDL3/SDL_log.h>
#include <iniparser.h>
void Android_SetupDefaultConfigOverrides(dictionary* p_dictionary)
{
SDL_Log("Overriding default config for Android");
iniparser_set(p_dictionary, "isle:diskpath", "/data/data/org.legoisland.Isle.dev/files/DATA/disk/LEGO");
iniparser_set(p_dictionary, "isle:cdpath", "/data/data/org.legoisland.Isle.dev/files/");
}

8
ISLE/android/config.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef ANDROID_CONFIG_H
#define ANDROID_CONFIG_H
#include "dictionary.h"
void Android_SetupDefaultConfigOverrides(dictionary* p_dictionary);
#endif // ANDROID_CONFIG_H

View File

@ -58,6 +58,10 @@
#include "3ds/config.h" #include "3ds/config.h"
#endif #endif
#ifdef __ANDROID__
#include "android/config.h"
#endif
#ifdef WINDOWS_STORE #ifdef WINDOWS_STORE
#include "xbox_one_series/config.h" #include "xbox_one_series/config.h"
#endif #endif
@ -994,6 +998,9 @@ bool IsleApp::LoadConfig()
#ifdef __3DS__ #ifdef __3DS__
N3DS_SetupDefaultConfigOverrides(dict); N3DS_SetupDefaultConfigOverrides(dict);
#endif #endif
#ifdef __ANDROID__
Android_SetupDefaultConfigOverrides(dict);
#endif
#ifdef WINDOWS_STORE #ifdef WINDOWS_STORE
XBONE_SetupDefaultConfigOverrides(dict); XBONE_SetupDefaultConfigOverrides(dict);
#endif #endif

12
android-project/.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
# Intellij
.idea/
# Gradle files
/.gradle/
build/
# Android
/app/.cxx/
# Local configuration file (sdk path, etc)
/local.properties

View File

@ -2,30 +2,27 @@ plugins {
id 'com.android.application' id 'com.android.application'
} }
def buildWithCMake = project.hasProperty('BUILD_WITH_CMAKE');
android { android {
namespace = "org.libsdl.app" namespace = "org.libsdl.app"
ndkVersion '28.0.13004108'
compileSdkVersion 35 compileSdkVersion 35
defaultConfig { defaultConfig {
applicationId "org.legoisland.Isle"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 35 targetSdkVersion 35
versionCode 1 versionCode 1
versionName "1.0" versionName "0.1"
externalNativeBuild { externalNativeBuild {
ndkBuild {
arguments "APP_PLATFORM=android-21"
// abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
abiFilters 'arm64-v8a'
}
cmake { cmake {
arguments "-DANDROID_PLATFORM=android-21", "-DANDROID_STL=c++_static" arguments "-DANDROID_PLATFORM=android-21", "-DANDROID_STL=c++_static", "-DISLE_BUILD_CONFIG=OFF"
// abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
abiFilters 'arm64-v8a'
} }
} }
} }
buildTypes { buildTypes {
debug {
applicationIdSuffix ".dev"
}
release { release {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@ -40,14 +37,9 @@ android {
jniLibs.srcDir 'libs' jniLibs.srcDir 'libs'
} }
externalNativeBuild { externalNativeBuild {
if (buildWithCMake) {
cmake { cmake {
path 'jni/CMakeLists.txt' path '../../CMakeLists.txt'
} version "3.31.6+"
} else {
ndkBuild {
path 'jni/Android.mk'
}
} }
} }

View File

@ -10,23 +10,23 @@
<!-- Touchscreen support --> <!-- Touchscreen support -->
<uses-feature <uses-feature
android:name="android.hardware.touchscreen" android:name="android.hardware.touchscreen"
android:required="false" /> android:required="true" />
<!-- Game controller support --> <!-- Game controller support -->
<uses-feature <uses-feature
android:name="android.hardware.bluetooth" android:name="android.hardware.bluetooth"
android:required="false" /> android:required="true" />
<uses-feature <uses-feature
android:name="android.hardware.gamepad" android:name="android.hardware.gamepad"
android:required="false" /> android:required="true" />
<uses-feature <uses-feature
android:name="android.hardware.usb.host" android:name="android.hardware.usb.host"
android:required="false" /> android:required="true" />
<!-- External mouse input events --> <!-- External mouse input events -->
<uses-feature <uses-feature
android:name="android.hardware.type.pc" android:name="android.hardware.type.pc"
android:required="false" /> android:required="true" />
<!-- Audio recording support --> <!-- Audio recording support -->
<!-- if you want to record audio, uncomment this. --> <!-- if you want to record audio, uncomment this. -->
@ -77,11 +77,12 @@
<meta-data android:name="SDL_ENV.SDL_ANDROID_TRAP_BACK_BUTTON" android:value="0"/> <meta-data android:name="SDL_ENV.SDL_ANDROID_TRAP_BACK_BUTTON" android:value="0"/>
--> -->
<activity android:name="SDLActivity" <activity android:name="org.legoisland.Isle.IsleSDLActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:alwaysRetainTaskState="true" android:alwaysRetainTaskState="true"
android:launchMode="singleInstance" android:launchMode="singleInstance"
android:configChanges="layoutDirection|locale|grammaticalGender|fontScale|fontWeightAdjustment|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation" android:configChanges="layoutDirection|locale|grammaticalGender|fontScale|fontWeightAdjustment|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
android:screenOrientation="landscape"
android:preferMinimalPostProcessing="true" android:preferMinimalPostProcessing="true"
android:exported="true" android:exported="true"
> >

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,13 @@
package org.legoisland.Isle;
import org.libsdl.app.SDLActivity;
public class IsleSDLActivity extends SDLActivity {
protected String[] getLibraries() {
return new String[] {
"SDL3",
"lego1",
"isle"
};
}
}

View File

@ -0,0 +1,141 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="180"
android:viewportHeight="180">
<group android:scaleX="0.47"
android:scaleY="0.47"
android:translateX="47.7"
android:translateY="47.7">
<path
android:pathData="M16.09,16.09m-16.09,0a16.09,16.09 0,1 1,32.18 0a16.09,16.09 0,1 1,-32.18 0"
android:strokeWidth="6.09858"
android:fillColor="#ffff00"/>
<path
android:pathData="M9.23,38.09L9.23,65.53"
android:strokeLineJoin="round"
android:strokeWidth="9.15"
android:fillColor="#ffff00"
android:strokeColor="#ffff00"
android:strokeLineCap="round"/>
<path
android:pathData="m66.61,9.11l-27.44,0"
android:strokeLineJoin="round"
android:strokeWidth="9.15"
android:fillColor="#ffff00"
android:strokeColor="#ffff00"
android:strokeLineCap="round"/>
<path
android:pathData="M21.86,39.44 L29.29,61.95"
android:strokeLineJoin="round"
android:strokeWidth="9.15"
android:fillColor="#ffff00"
android:strokeColor="#ffff00"
android:strokeLineCap="round"/>
<path
android:pathData="m33.06,32.76 l19.56,13.39"
android:strokeLineJoin="round"
android:strokeWidth="9.15"
android:fillColor="#ffff00"
android:strokeColor="#ffff00"
android:strokeLineCap="round"/>
<path
android:pathData="m38.74,20.71 l22.48,7.51"
android:strokeLineJoin="round"
android:strokeWidth="9.15"
android:fillColor="#ffff00"
android:strokeColor="#ffff00"
android:strokeLineCap="round"/>
<path
android:pathData="M31.84,157.94l131.47,0l0,18.05l-131.47,0z"
android:strokeLineJoin="round"
android:strokeWidth="8.01"
android:fillColor="#ffff00"
android:strokeColor="#ffff00"
android:strokeLineCap="butt"/>
<path
android:pathData="M31.84,79.75l131.47,0l0,18.05l-131.47,0z"
android:strokeLineJoin="round"
android:strokeWidth="8.01"
android:fillColor="#ffff00"
android:strokeColor="#ffff00"
android:strokeLineCap="butt"/>
<path
android:pathData="M31.84,131.88l131.47,0l0,18.05l-131.47,0z"
android:strokeLineJoin="round"
android:strokeWidth="8.01"
android:fillColor="#ff0000"
android:strokeColor="#ff0000"
android:strokeLineCap="butt"/>
<path
android:pathData="M31.84,105.81l131.47,0l0,18.05l-131.47,0z"
android:strokeLineJoin="round"
android:strokeWidth="8.01"
android:fillColor="#0000ff"
android:strokeColor="#0000ff"
android:strokeLineCap="butt"/>
<path
android:pathData="M70.06,80.85l55.04,0l0,68.99l-55.04,0z"
android:strokeLineJoin="miter"
android:strokeWidth="8.91"
android:fillColor="#000000"
android:strokeColor="#000000"
android:strokeLineCap="butt"/>
<path
android:pathData="M72.74,85.31l20.36,0l0,24.52l-20.36,0z"
android:strokeLineJoin="round"
android:strokeWidth="3.04"
android:fillColor="#00ffff"
android:strokeColor="#00ffff"
android:strokeLineCap="butt"/>
<path
android:pathData="M101.96,85.31l20.36,0l0,24.52l-20.36,0z"
android:strokeLineJoin="round"
android:strokeWidth="3.04"
android:fillColor="#00ffff"
android:strokeColor="#00ffff"
android:strokeLineCap="butt"/>
<path
android:pathData="M72.89,116.22l20.06,0l0,30.02l-20.06,0z"
android:strokeLineJoin="round"
android:strokeWidth="3.34"
android:fillColor="#00ffff"
android:strokeColor="#00ffff"
android:strokeLineCap="butt"/>
<path
android:pathData="M102.11,116.22l20.06,0l0,30.02l-20.06,0z"
android:strokeLineJoin="round"
android:strokeWidth="3.34"
android:fillColor="#00ffff"
android:strokeColor="#00ffff"
android:strokeLineCap="butt"/>
<path
android:pathData="M131.19,7.33L131.19,55.6"
android:strokeLineJoin="round"
android:strokeWidth="4.57"
android:fillColor="#ff0000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
<path
android:pathData="m111.99,3.21 l38.38,29.26"
android:strokeLineJoin="round"
android:strokeWidth="4.57"
android:fillColor="#ff0000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
<path
android:pathData="m115.82,19.64 l30.2,23.02"
android:strokeLineJoin="round"
android:strokeWidth="4.57"
android:fillColor="#ff0000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
<path
android:pathData="M19.99,75.94H173.06L150.4,51.32h-7.63l-5.02,6.19h-7.47l-4.27,-8.06h-7.59l-4.57,8.06h-8l-4.69,-8.06h-7.44l-4.18,8.06h-8.45l-3.9,-8.06h-7.23l-4.36,8.06h-8.61l-5.45,-6.19h-6.08z"
android:strokeLineJoin="round"
android:strokeWidth="3.04929"
android:fillColor="#ff0000"
android:strokeColor="#ff0000"
android:strokeLineCap="butt"/>
</group>
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#39A0D9</color>
</resources>

View File

@ -1,3 +1,3 @@
<resources> <resources>
<string name="app_name">Game</string> <string name="app_name">LEGO Island</string>
</resources> </resources>

View File

@ -6,7 +6,7 @@ buildscript {
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:8.7.3' classpath 'com.android.tools.build:gradle:8.11.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

View File

@ -1,6 +1,6 @@
#Thu Nov 11 18:20:34 PST 2021 #Thu Nov 11 18:20:34 PST 2021
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@ -39,18 +39,18 @@ if(OpenGL_FOUND AND NOT WINDOWS_STORE)
src/d3drm/backends/opengl1/renderer.cpp src/d3drm/backends/opengl1/renderer.cpp
) )
target_compile_definitions(miniwin PRIVATE USE_OPENGL1) target_compile_definitions(miniwin PRIVATE USE_OPENGL1)
target_link_libraries(miniwin PRIVATE OpenGL::GL) target_link_libraries(miniwin PRIVATE ${OPENGL_LIBRARIES})
else() else()
message(STATUS "🧩 OpenGL 1.x support not enabled — needs OpenGL") message(STATUS "🧩 OpenGL 1.x support not enabled — needs OpenGL")
endif() endif()
find_library(OPENGL_ES2_LIBRARY NAMES GLESv2) find_library(OPENGL_ES2_LIBRARY NAMES GLESv2)
if(EMSCRIPTEN OR OPENGL_ES2_LIBRARY AND NOT WINDOWS_STORE) if(EMSCRIPTEN OR (OPENGL_ES2_LIBRARY AND NOT WINDOWS_STORE))
message(STATUS "Found OpenGL: enabling OpenGL ES 2.x renderer") message(STATUS "Found OpenGL ES 2.x: enabling OpenGL ES 2.x renderer")
target_sources(miniwin PRIVATE src/d3drm/backends/opengles2/renderer.cpp) target_sources(miniwin PRIVATE src/d3drm/backends/opengles2/renderer.cpp)
target_compile_definitions(miniwin PRIVATE USE_OPENGLES2) target_compile_definitions(miniwin PRIVATE USE_OPENGLES2)
if(OPENGL_ES2_LIBRARY) if(OPENGL_ES2_LIBRARY)
target_link_libraries(miniwin PRIVATE OpenGL::GL) target_link_libraries(miniwin PRIVATE ${OPENGL_ES2_LIBRARY})
endif() endif()
else() else()
message(STATUS "🧩 OpenGL ES 2.x support not enabled") message(STATUS "🧩 OpenGL ES 2.x support not enabled")