mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-09-14 22:36:01 -05:00
Store netplay BootSessionData and use it to run the netplay game
This commit is contained in:
@@ -342,6 +342,12 @@ object NativeLibrary {
|
||||
@JvmStatic
|
||||
external fun RunSystemMenu()
|
||||
|
||||
/**
|
||||
* Begins emulation for a netplay session, using the BootSessionData provided by the host.
|
||||
*/
|
||||
@JvmStatic
|
||||
external fun RunNetPlay(paths: Array<String>, riivolution: Boolean)
|
||||
|
||||
@JvmStatic
|
||||
external fun ChangeDisc(path: String)
|
||||
|
||||
|
||||
@@ -4,12 +4,23 @@
|
||||
package org.dolphinemu.dolphinemu.features.netplay
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
import org.dolphinemu.dolphinemu.features.netplay.model.ConnectionType
|
||||
|
||||
object Netplay {
|
||||
@Keep
|
||||
private var netPlayClientPointer: Long = 0
|
||||
|
||||
@Keep
|
||||
private var bootSessionDataPointer: Long = 0
|
||||
|
||||
val isLaunching: Boolean
|
||||
get() = bootSessionDataPointer != 0L
|
||||
|
||||
private val _launchGame = Channel<String>(Channel.CONFLATED)
|
||||
val launchGame = _launchGame.receiveAsFlow()
|
||||
|
||||
@JvmStatic
|
||||
external fun getNickname(): String
|
||||
|
||||
@@ -103,4 +114,10 @@ object Netplay {
|
||||
|
||||
@JvmStatic
|
||||
private external fun Join(): Long
|
||||
|
||||
@JvmStatic
|
||||
fun onBootGame(gameFilePath: String, bootSessionDataPointer: Long) {
|
||||
this.bootSessionDataPointer = bootSessionDataPointer
|
||||
_launchGame.trySend(gameFilePath)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,12 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import org.dolphinemu.dolphinemu.R
|
||||
import org.dolphinemu.dolphinemu.activities.EmulationActivity
|
||||
import org.dolphinemu.dolphinemu.features.netplay.Netplay
|
||||
import org.dolphinemu.dolphinemu.features.netplay.model.ConnectionRole
|
||||
import org.dolphinemu.dolphinemu.features.netplay.model.ConnectionType
|
||||
import org.dolphinemu.dolphinemu.features.netplay.model.NetplaySetupViewModel
|
||||
@@ -64,6 +69,10 @@ class NetplaySetupActivity : AppCompatActivity(), ThemeProvider {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
Netplay.launchGame
|
||||
.onEach { EmulationActivity.launch(this, it, false) }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
viewModel = ViewModelProvider(this)[NetplaySetupViewModel::class.java]
|
||||
|
||||
setContent {
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.fragment.app.Fragment
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary
|
||||
import org.dolphinemu.dolphinemu.activities.EmulationActivity
|
||||
import org.dolphinemu.dolphinemu.databinding.FragmentEmulationBinding
|
||||
import org.dolphinemu.dolphinemu.features.netplay.Netplay
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings
|
||||
import org.dolphinemu.dolphinemu.overlay.InputOverlay
|
||||
@@ -214,6 +215,12 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
if (launchSystemMenu) {
|
||||
Log.debug("[EmulationFragment] Starting emulation thread for the Wii Menu.")
|
||||
NativeLibrary.RunSystemMenu()
|
||||
} else if (Netplay.isLaunching) {
|
||||
Log.debug("[EmulationFragment] Starting emulation thread for Netplay.")
|
||||
val paths = requireNotNull(gamePaths) {
|
||||
"Cannot start emulation without any game paths"
|
||||
}
|
||||
NativeLibrary.RunNetPlay(paths, riivolution)
|
||||
} else {
|
||||
Log.debug("[EmulationFragment] Starting emulation thread.")
|
||||
val paths = requireNotNull(gamePaths) {
|
||||
|
||||
Reference in New Issue
Block a user