1
0
forked from MeloNX/MeloNX

WIP: Fix SDL init

This commit is contained in:
Daniil Vinogradov 2025-03-05 23:44:34 +01:00
parent f18307af51
commit 1ada8c5e34
7 changed files with 28 additions and 8 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

@ -276,7 +276,7 @@ public class SDLActivity extends AppCompatActivity implements View.OnSystemUiVis
// "SDL2_mixer",
// "SDL2_net",
// "SDL2_ttf",
// "main"
"main"
};
}
@ -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();

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,12 +55,16 @@ open class MainActivity: SDLActivity {
enableEdgeToEdge()
setContent {
Box {
SDLComposeSurface()
val saveableStateHolder = rememberSaveableStateHolder()
saveableStateHolder.SaveableStateProvider(true) {
PresentationRootView(ComposeContext())
SideEffect { saveableStateHolder.removeState(true) }
}
}
}
// Example of requesting permissions on startup.
// These must match the permissions in the AndroidManifest.xml file.
@ -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)
}
}