Archived
1
0
forked from MeloNX/MeloNX

WIP: Fix SDL init | Audio working

This commit is contained in:
Daniil Vinogradov 2025-03-05 23:44:34 +01:00
parent f18307af51
commit 2b290f5153
9 changed files with 37 additions and 16 deletions

View File

@ -32,6 +32,7 @@
<!-- Allow access to the vibrator -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<!-- if you want to capture audio, uncomment this. -->
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->

View File

@ -398,7 +398,7 @@ public class SDLActivity extends AppCompatActivity implements View.OnSystemUiVis
mSurface = createSDLSurface(this);
mLayout = new RelativeLayout(this);
mLayout.addView(mSurface);
// mLayout.addView(mSurface);
// Get our current screen orientation and pass it down.
mCurrentOrientation = SDLActivity.getCurrentOrientation();
@ -1883,15 +1883,15 @@ class SDLMain implements Runnable {
Log.v("SDL", "Running main function " + function + " from library " + library);
SDLActivity.nativeRunMain(library, function, arguments);
// SDLActivity.nativeRunMain(library, function, arguments);
Log.v("SDL", "Finished main function");
if (SDLActivity.mSingleton != null && !SDLActivity.mSingleton.isFinishing()) {
// Let's finish the Activity
SDLActivity.mSDLThread = null;
SDLActivity.mSingleton.finish();
} // else: Activity is already being destroyed
// Log.v("SDL", "Finished main function");
//
// if (SDLActivity.mSingleton != null && !SDLActivity.mSingleton.isFinishing()) {
// // Let's finish the Activity
// SDLActivity.mSDLThread = null;
// SDLActivity.mSingleton.finish();
// } // else: Activity is already being destroyed
}
}

View File

@ -10,14 +10,19 @@ import android.app.Application
import androidx.activity.enableEdgeToEdge
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.app.ActivityCompat
import org.libsdl.app.SDLActivity
@ -50,10 +55,14 @@ open class MainActivity: SDLActivity {
enableEdgeToEdge()
setContent {
val saveableStateHolder = rememberSaveableStateHolder()
saveableStateHolder.SaveableStateProvider(true) {
PresentationRootView(ComposeContext())
SideEffect { saveableStateHolder.removeState(true) }
Box {
SDLComposeSurface()
val saveableStateHolder = rememberSaveableStateHolder()
saveableStateHolder.SaveableStateProvider(true) {
PresentationRootView(ComposeContext())
SideEffect { saveableStateHolder.removeState(true) }
}
}
}
@ -119,6 +128,15 @@ open class MainActivity: SDLActivity {
companion object {
}
@Composable
fun SDLComposeSurface() {
AndroidView(
factory = { context ->
mSurface
}
)
}
}
@Composable

View File

@ -139,8 +139,8 @@ private extension Ryujinx {
args.append(config.gamepath)
// Starts with vulkan
// args.append("--graphics-backend")
// args.append("Vulkan")
args.append("--graphics-backend")
args.append("Vulkan")
args.append(contentsOf: ["--memory-manager-mode", config.memoryManagerMode])

View File

@ -22,6 +22,7 @@ public struct melonxRootView : View {
logger.info("Welcome to Skip on \(androidSDK != nil ? "Android" : "Darwin")!")
logger.info("Skip app logs are viewable in the Xcode console for iOS; Android logs can be viewed in Studio or using adb logcat")
}
.opacity(0.3)
}
}

View File

@ -18,6 +18,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using static SDL2.SDL;
using AntiAliasing = Ryujinx.Common.Configuration.AntiAliasing;
@ -36,7 +37,7 @@ namespace Ryujinx.Headless.SDL2
private static readonly ConcurrentQueue<Action> _mainThreadActions = new();
[LibraryImport("SDL2.framework/SDL2")]
[LibraryImport("SDL2", SetLastError = true)]
// TODO: Remove this as soon as SDL2-CS was updated to expose this method publicly
private static partial IntPtr SDL_LoadBMP_RW(IntPtr src, int freesrc);