add sdl for android

This commit is contained in:
Logan McNaughton
2026-05-25 19:07:56 +02:00
parent 411cb0efa7
commit 7599f71c17
8 changed files with 65 additions and 0 deletions
Generated
+1
View File
@@ -2233,6 +2233,7 @@ dependencies = [
"reqwest",
"rfd",
"sdl3-image-sys",
"sdl3-src",
"sdl3-sys",
"sdl3-ttf-sys",
"semver",
+1
View File
@@ -51,6 +51,7 @@ jni = "0.22"
[build-dependencies]
winresource = "0.1"
bindgen = "0.72"
sdl3-src = "3.4"
slint-build = { version = "1.12", optional = true }
cc = { version = "1.2", features = ["parallel"] }
+2
View File
@@ -34,3 +34,5 @@ google-services.json
# Android Profiling
*.hprof
app/src/main/java/org/libsdl/app/
@@ -18,6 +18,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".N64Activity"></activity>
</application>
</manifest>
@@ -0,0 +1,5 @@
package io.github.gopher64.gopher64
import org.libsdl.app.SDLActivity
class N64Activity : SDLActivity() {}
+25
View File
@@ -306,4 +306,29 @@ fn main() {
{
println!("cargo:rustc-cfg=ra_hardcore_enabled");
}
if os == "android" {
copy_dir_all(
std::path::Path::new(sdl3_src::SOURCE_DIR)
.join("android-project/app/src/main/java/org/libsdl/app"),
"android-project/app/src/main/java/org/libsdl/app",
)
.unwrap();
}
}
fn copy_dir_all(
src: impl AsRef<std::path::Path>,
dst: impl AsRef<std::path::Path>,
) -> std::io::Result<()> {
std::fs::create_dir_all(&dst)?;
for entry in std::fs::read_dir(src)? {
let entry = entry?;
let ty = entry.file_type()?;
if ty.is_dir() {
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
std::fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}
+22
View File
@@ -127,6 +127,28 @@ pub struct ControllerInfo {
pub descriptor: String,
}
pub fn configure_input_profile(
_profile_name: slint::SharedString,
_dinput: bool,
_deadzone: i32,
_weak: slint::Weak<ui::gui::AppWindow>,
) {
}
pub fn run_rom(
_file_path: std::path::PathBuf,
_game_settings: ui::GameSettings,
netplay: Option<ui::gui::NetplayDevice>,
_weak: slint::Weak<ui::gui::AppWindow>,
) {
if let Some(netplay) = netplay {
println!(
"Netplay peer addr: {} player number: {}",
netplay.peer_addr, netplay.player_number
);
}
}
fn get_vm() -> Option<JavaVM> {
if let Ok(app) = ANDROID_APP.lock()
&& let Some(app) = app.as_ref()
+8
View File
@@ -353,6 +353,10 @@ fn controller_window(app: &AppWindow, config: &ui::config::Config) {
let deadzone = handle.get_input_deadzone();
handle.set_show_input_profile(false);
#[cfg(target_os = "android")]
ui::android::configure_input_profile(profile_name, dinput, deadzone, weak_app2);
#[cfg(not(target_os = "android"))]
tokio::spawn(async move {
let cli_path = std::env::current_exe()
.unwrap()
@@ -538,6 +542,10 @@ pub fn run_rom(
netplay: Option<NetplayDevice>,
weak: slint::Weak<AppWindow>,
) {
#[cfg(target_os = "android")]
ui::android::run_rom(file_path, game_settings, netplay, weak);
#[cfg(not(target_os = "android"))]
tokio::spawn(async move {
weak.upgrade_in_event_loop(move |handle| handle.set_game_running(true))
.unwrap();