mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36ebd41cb3 | ||
|
|
678057d727 | ||
|
|
ae94009382 | ||
|
|
fd93a35b72 | ||
|
|
12fa3ac343 | ||
|
|
422b339af8 |
No files matched your search
@@ -133,10 +133,10 @@ static void handle_released(uint64_t id, int fd) {
|
||||
if (fd >= 0) {
|
||||
struct droiddeck_dma_buf_sync_file imp = {.flags = DROIDDECK_DMA_BUF_SYNC_READ, .fd = fd};
|
||||
int dmabuf_fd = droiddeck_dmabuf_fd(ab->b);
|
||||
if (!ab->display && dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &imp) == 0) {
|
||||
if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &imp) == 0) {
|
||||
close(fd);
|
||||
} else {
|
||||
if (!ab->display && !g_import_failed_logged) {
|
||||
if (!g_import_failed_logged) {
|
||||
g_import_failed_logged = 1;
|
||||
droiddeck_log("layer", "zero-copy: DMA_BUF_IOCTL_IMPORT_SYNC_FILE failed (%s): releases wait for the display's fence here instead",
|
||||
strerror(errno));
|
||||
|
||||
@@ -1993,11 +1993,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}
|
||||
}
|
||||
|
||||
val askAllFiles = Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.files.AllFilesAccess.missing() &&
|
||||
!SessionPrefs.allFilesAsked(this)
|
||||
if (savedInstanceState == null) {
|
||||
if (!askAllFiles) ui.post { startSteamAtStartupIfEnabled(cold = true) }
|
||||
}
|
||||
if (savedInstanceState == null) ui.post { startSteamAtStartupIfEnabled(cold = true) }
|
||||
saved?.let { state ->
|
||||
restoreCompatLaunch(state)
|
||||
pendingSwitch = savedIntent(state, KEY_PENDING_SWITCH)
|
||||
@@ -2005,13 +2001,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}
|
||||
|
||||
val wanted = ArrayList<String>()
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
// From targetSdk 30, shared storage outside the app's own folders is all-files access or nothing.
|
||||
if (askAllFiles) {
|
||||
SessionPrefs.setAllFilesAsked(this)
|
||||
com.droiddeck.launcher.files.AllFilesAccess.open(this)
|
||||
}
|
||||
} else if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
// From Android 11, shared storage outside the app's own folders is all-files access, which the file picker asks for when a shared drive is opened.
|
||||
if (Build.VERSION.SDK_INT < 30 && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
wanted.add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
}
|
||||
if (SessionPrefs.micEnabled(this) && !SessionPrefs.micAsked(this)
|
||||
@@ -2020,6 +2011,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
SessionPrefs.setMicAsked(this)
|
||||
}
|
||||
if (wanted.isNotEmpty()) requestPermissions(wanted.toTypedArray(), 1)
|
||||
com.droiddeck.launcher.session.Onboarding.onFirstRunReady = firstRunReady
|
||||
Thread({ com.droiddeck.launcher.stores.StoreAccounts.encryptAll(this) }, "store-credentials").start()
|
||||
if (!SessionState.running) Thread({
|
||||
com.droiddeck.launcher.session.LogMigration.run(this)
|
||||
@@ -2299,7 +2291,22 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
return super.dispatchGenericMotionEvent(event)
|
||||
}
|
||||
|
||||
@Volatile private var inFront = false
|
||||
private var autoSteamPending = false
|
||||
|
||||
/** Runs on the worker thread that finishes setup, so the foreground state is read as setup completes, not when the UI thread gets to it. */
|
||||
private val firstRunReady: () -> Unit = {
|
||||
val front = inFront
|
||||
runOnUiThread { if (front) autoStartSteam() }
|
||||
}
|
||||
|
||||
private fun autoStartSteam() {
|
||||
if (isFinishing || isDestroyed || SessionState.running || !inFront) return
|
||||
if (busy) autoSteamPending = true else playSteam()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
inFront = false
|
||||
stopRightStickScroll()
|
||||
compatLaunchVisible = false
|
||||
if (android.os.Build.VERSION.SDK_INT >= 29) com.droiddeck.launcher.ui.DualScreenPanel.ownerPaused(taskId, true)
|
||||
@@ -2308,6 +2315,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
inFront = true
|
||||
if (!homeChoiceOpen) {
|
||||
HomeApp.releaseUnusedHomeEntry(this)
|
||||
refreshHomeAppState()
|
||||
@@ -2443,6 +2451,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
|
||||
override fun onDestroy() {
|
||||
// The queued launch was saved before this; a restored activity keeps its copy, and this one must not start it too.
|
||||
if (com.droiddeck.launcher.session.Onboarding.onFirstRunReady === firstRunReady) com.droiddeck.launcher.session.Onboarding.onFirstRunReady = null
|
||||
queuedLaunchRunner.destroy()
|
||||
triggerKeys.cancel()
|
||||
launchCoordinator.cancelAll()
|
||||
@@ -3742,6 +3751,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
refresh()
|
||||
com.droiddeck.launcher.agent.AgentHost.refresh(this)
|
||||
if (ok == true && LinuxRuntime.isInstalled(this)) { protons.checkUpdates(); protons.ensureSteamClient() }
|
||||
if (autoSteamPending) { autoSteamPending = false; autoStartSteam() }
|
||||
}
|
||||
}, "runtime-operation").start()
|
||||
}
|
||||
|
||||
@@ -6349,10 +6349,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (!intent.hasExtra(EXTRA_LINK_TASK)) intent.putExtra(EXTRA_LINK_TASK, this.intent.getIntExtra(EXTRA_LINK_TASK, -1))
|
||||
setIntent(intent)
|
||||
if (::pip.isInitialized) pip.refresh(true)
|
||||
if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) {
|
||||
SessionState.steamVr = true
|
||||
steamVrAutoTried = false
|
||||
}
|
||||
if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) requestSteamVr()
|
||||
if (intent.action == SessionService.ACTION_HOME_GUIDE) {
|
||||
handleHomeGuideIntent(intent)
|
||||
} else if (intent.action == SessionService.ACTION_RESUME) {
|
||||
@@ -6441,7 +6438,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private val questSteamVrRequest = object : Runnable {
|
||||
override fun run() {
|
||||
if (com.droiddeck.launcher.session.QuestSteamVrLaunch.takeRequest(this@SessionActivity) &&
|
||||
SessionState.running && SessionState.mode == SessionService.MODE_STEAM) steamVrAction("start")
|
||||
SessionState.running && SessionState.mode == SessionService.MODE_STEAM) {
|
||||
if (com.droiddeck.launcher.session.QuestSteamVrLaunch.opensDirectly(steamVrStatus)) steamVrAction("start")
|
||||
else requestSteamVr()
|
||||
}
|
||||
uiHandler.postDelayed(this, 1000)
|
||||
}
|
||||
}
|
||||
@@ -6500,6 +6500,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
updateHeadTracker()
|
||||
}
|
||||
|
||||
private fun requestSteamVr() {
|
||||
SessionState.steamVr = true
|
||||
steamVrAutoTried = false
|
||||
steamVrInstallTried = false
|
||||
}
|
||||
|
||||
private fun steamVrAction(action: String) {
|
||||
if (action == "start" && com.droiddeck.launcher.session.QuestExperimental.isSupported()) {
|
||||
startActivity(android.content.Intent(this, QuestXrActivity::class.java))
|
||||
@@ -6977,6 +6983,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
SessionState.mode == SessionService.MODE_STEAM, steamVrAutoTried, steamVrInstallTried) ?: return
|
||||
if (action == "start") steamVrAutoTried = true else steamVrInstallTried = true
|
||||
Log.i(TAG, "requested SteamVR $action (glasses=${glasses.model}, output=$glassesOutputActive, control=${glasses.canControl})")
|
||||
if (action == "install") Toast.makeText(this, R.string.cardboard_steamvr_installing, Toast.LENGTH_LONG).show()
|
||||
steamVrAction(action)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,18 @@ import android.os.Environment
|
||||
import android.provider.Settings
|
||||
|
||||
object AllFilesAccess {
|
||||
private val VOLUME = Regex("^(/storage/emulated/\\d+|/storage/[^/]+|/sdcard)(/.*)?$")
|
||||
private val APP_FOLDERS = listOf("/Android/data", "/Android/obb")
|
||||
|
||||
fun missing(sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): Boolean =
|
||||
sdk >= Build.VERSION_CODES.R && !granted()
|
||||
|
||||
/** Whether reading [path] takes all-files access: shared storage, outside the per-app folders directly under a volume's root, which Android always lets the app use. */
|
||||
fun covers(path: String): Boolean {
|
||||
val inside = VOLUME.matchEntire(path)?.groupValues?.get(2) ?: return false
|
||||
return APP_FOLDERS.none { inside == it || inside.startsWith("$it/") }
|
||||
}
|
||||
|
||||
fun open(context: Context) {
|
||||
val app = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, Uri.parse("package:" + context.packageName))
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
||||
@@ -504,13 +504,15 @@ fun FileManagerScreen(
|
||||
}
|
||||
val drives = remember(storageTick) { StorageRoots.list(context) }
|
||||
var accessDrive by remember { mutableStateOf<String?>(null) }
|
||||
var accessWasMissing by remember { mutableStateOf(AllFilesAccess.missing()) }
|
||||
var accessDeclined by remember { mutableStateOf(false) }
|
||||
fun unreadable(drive: StorageRoot) {
|
||||
if (AllFilesAccess.missing()) accessDrive = drive.label
|
||||
else Toast.makeText(context, context.getString(R.string.fm_drive_not_readable, drive.label), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
accessDrive?.let { label ->
|
||||
OutlinedAlertDialog(
|
||||
onDismissRequest = { accessDrive = null },
|
||||
onDismissRequest = { accessDrive = null; accessDeclined = true },
|
||||
title = { Text(stringResource(R.string.fm_drive_access_title, label)) },
|
||||
text = { Text(stringResource(R.string.fm_drive_access_text)) },
|
||||
confirmButton = {
|
||||
@@ -519,9 +521,17 @@ fun FileManagerScreen(
|
||||
AllFilesAccess.open(context)
|
||||
}, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.upd_open_settings)) }
|
||||
},
|
||||
dismissButton = { TextButton(onClick = { accessDrive = null }, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) } },
|
||||
dismissButton = { TextButton(onClick = { accessDrive = null; accessDeclined = true }, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) } },
|
||||
)
|
||||
}
|
||||
LaunchedEffect(currentDir, storageTick) {
|
||||
if (!AllFilesAccess.missing()) {
|
||||
if (accessWasMissing) { accessWasMissing = false; loadDirectory(currentDir, resetScroll = false, record = false) }
|
||||
} else {
|
||||
accessWasMissing = true
|
||||
if (!accessDeclined && accessDrive == null && AllFilesAccess.covers(currentDir.path)) accessDrive = drives.firstOrNull { currentDir.path.startsWith(it.dir.path) }?.label ?: context.getString(R.string.fm_drive_internal)
|
||||
}
|
||||
}
|
||||
val linuxRoot = remember(storageTick) {
|
||||
com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context).takeIf { File(it, "usr").isDirectory }
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class PadBridge {
|
||||
private final PadState[] playerStates = new PadState[SLOTS];
|
||||
private final float[][] rawSticks = new float[SLOTS][4];
|
||||
private final Map<Integer, Boolean> rightStickLayouts = new HashMap<>();
|
||||
private final boolean[][] keyTriggers = new boolean[SLOTS][2];
|
||||
private final TriggerKey[][] keyTriggers = TriggerKey.slots(SLOTS);
|
||||
private final int[] retainedSticks = new int[SLOTS];
|
||||
private final PadState effectiveState = new PadState();
|
||||
private final PadState homeGuideReport = new PadState();
|
||||
@@ -484,7 +484,7 @@ public final class PadBridge {
|
||||
stateFor(slot).clear();
|
||||
retainedSticks[slot] = 0;
|
||||
Arrays.fill(rawSticks[slot], 0f);
|
||||
Arrays.fill(keyTriggers[slot], false);
|
||||
for (TriggerKey key : keyTriggers[slot]) key.reset();
|
||||
}
|
||||
|
||||
private void mutateState(java.util.function.Consumer<PadState> mutation) {
|
||||
@@ -570,26 +570,76 @@ public final class PadBridge {
|
||||
return true;
|
||||
}
|
||||
|
||||
static float keyTrigger(float current, boolean pressed, int repeatCount, boolean analog, boolean[] held, int side) {
|
||||
static final class TriggerKey {
|
||||
static final float RELEASE_FROM_PEAK = 0.05f;
|
||||
boolean held;
|
||||
boolean handoff;
|
||||
boolean axisLive;
|
||||
boolean axisMovedWhilePressed;
|
||||
float peak;
|
||||
float axis;
|
||||
|
||||
static TriggerKey[][] slots(int count) {
|
||||
TriggerKey[][] keys = new TriggerKey[count][2];
|
||||
for (TriggerKey[] pair : keys) {
|
||||
pair[0] = new TriggerKey();
|
||||
pair[1] = new TriggerKey();
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
held = false;
|
||||
handoff = false;
|
||||
axisLive = false;
|
||||
axisMovedWhilePressed = false;
|
||||
peak = 0f;
|
||||
axis = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
static float keyTrigger(float current, boolean pressed, int repeatCount, boolean analog, TriggerKey[] keys, int side) {
|
||||
TriggerKey key = keys[side];
|
||||
if (repeatCount > 0) return current;
|
||||
if (!analog) {
|
||||
held[side] = pressed;
|
||||
key.held = pressed;
|
||||
return pressed ? 1f : 0f;
|
||||
}
|
||||
if (pressed) {
|
||||
if (current != 0f) return current;
|
||||
held[side] = true;
|
||||
key.axisMovedWhilePressed = false;
|
||||
if (key.axisLive || current != 0f) return current;
|
||||
key.held = true;
|
||||
return 1f;
|
||||
}
|
||||
if (!held[side]) return current;
|
||||
held[side] = false;
|
||||
if (!key.axisMovedWhilePressed) key.axisLive = false;
|
||||
if (key.handoff) {
|
||||
key.handoff = false;
|
||||
return key.axis;
|
||||
}
|
||||
if (!key.held) return current;
|
||||
key.held = false;
|
||||
return 0f;
|
||||
}
|
||||
|
||||
static float axisTrigger(float value, boolean[] held, int side) {
|
||||
if (!held[side]) return value;
|
||||
if (value == 0f) return 1f;
|
||||
held[side] = false;
|
||||
static float axisTrigger(float value, TriggerKey[] keys, int side) {
|
||||
TriggerKey key = keys[side];
|
||||
key.axis = value;
|
||||
if (value != 0f) {
|
||||
key.axisLive = true;
|
||||
key.axisMovedWhilePressed = true;
|
||||
}
|
||||
if (key.held) {
|
||||
if (value == 0f) return 1f;
|
||||
key.held = false;
|
||||
key.handoff = true;
|
||||
key.peak = value;
|
||||
return 1f;
|
||||
}
|
||||
if (key.handoff) {
|
||||
key.peak = Math.max(key.peak, value);
|
||||
if (value > key.peak - TriggerKey.RELEASE_FROM_PEAK) return 1f;
|
||||
key.handoff = false;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@@ -951,6 +951,7 @@ internal object EnhancedSessionLogShare {
|
||||
"battlenet.log", "spawned.log", "flatpak-install.log", "cef_log.txt", "cef_log.previous.txt", "droiddeck-bionic.log",
|
||||
"console_log.txt", "webhelper_js.txt", "controller_support.txt", "systemperfmanager.txt",
|
||||
"rpcs3", "RPCS3.log",
|
||||
"droiddeck-steamvr-launch.log", "droiddeck-vrstartup.log",
|
||||
)
|
||||
private val KNOWN_COMPONENT_PATTERNS = listOf(
|
||||
Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"),
|
||||
|
||||
@@ -29,6 +29,10 @@ object Onboarding {
|
||||
/** The setup screens belong to the first run; later runtime, Proton and Steam client updates keep the usual Play button. */
|
||||
val firstRun = MutableStateFlow(true)
|
||||
|
||||
/** Called once, when this process finishes the first-run downloads itself; not when everything was already in place. */
|
||||
@Volatile var onFirstRunReady: (() -> Unit)? = null
|
||||
@Volatile private var worked = false
|
||||
|
||||
fun attach(context: Context) {
|
||||
appContext = context.applicationContext
|
||||
val prefs = context.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
||||
@@ -52,8 +56,10 @@ object Onboarding {
|
||||
|
||||
private fun markFirstRunDone() {
|
||||
val context = appContext ?: return
|
||||
val live = firstRun.value && worked
|
||||
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean(KEY_FIRST_RUN_DONE, true).apply()
|
||||
firstRun.value = false
|
||||
if (live) onFirstRunReady?.invoke()
|
||||
}
|
||||
|
||||
/** Keeps the process in the foreground, with one notification, while a step downloads and the runtime installer is not already doing so. */
|
||||
@@ -90,6 +96,7 @@ object Onboarding {
|
||||
}
|
||||
|
||||
fun report(step: Step, label: String, percent: Int) {
|
||||
worked = true
|
||||
failed.value = failed.value - step
|
||||
active.value = active.value + (step to Progress(label, percent))
|
||||
keepAlive()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.gpu.SteamVr
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
@@ -32,4 +33,7 @@ object QuestSteamVrLaunch {
|
||||
|
||||
fun takeRequest(context: Context): Boolean =
|
||||
QuestExperimental.isSupported() && File(context.filesDir, "$DIR/$REQUEST").delete()
|
||||
|
||||
fun opensDirectly(status: SteamVr.Status?): Boolean =
|
||||
status == SteamVr.Status.READY || status == SteamVr.Status.RUNNING
|
||||
}
|
||||
@@ -960,12 +960,6 @@ object SessionPrefs {
|
||||
|
||||
fun micAsked(context: Context): Boolean = prefs(context).getBoolean("micAsked", false)
|
||||
|
||||
fun allFilesAsked(context: Context): Boolean = prefs(context).getBoolean("allFilesAsked", false)
|
||||
|
||||
fun setAllFilesAsked(context: Context) {
|
||||
prefs(context).edit().putBoolean("allFilesAsked", true).apply()
|
||||
}
|
||||
|
||||
fun bluetoothAsked(context: Context): Boolean = prefs(context).getBoolean("bluetoothAsked", false)
|
||||
|
||||
fun setBluetoothAsked(context: Context) {
|
||||
|
||||
@@ -21,4 +21,20 @@ class AllFilesAccessTest {
|
||||
assertTrue(AllFilesAccess.missing(sdk = 35) { false })
|
||||
assertFalse(AllFilesAccess.missing(sdk = 35) { true })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlySharedStorageNeedsIt() {
|
||||
assertTrue(AllFilesAccess.covers("/storage/emulated/0"))
|
||||
assertTrue(AllFilesAccess.covers("/storage/1A2B-3C4D/Games"))
|
||||
assertTrue(AllFilesAccess.covers("/sdcard/Download"))
|
||||
assertFalse(AllFilesAccess.covers("/storage/emulated/0/Android/data"))
|
||||
assertFalse(AllFilesAccess.covers("/storage/1A2B-3C4D/Android/obb"))
|
||||
assertTrue(AllFilesAccess.covers("/storage/emulated/0/Android"))
|
||||
assertTrue(AllFilesAccess.covers("/storage/emulated/0/Android/database"))
|
||||
assertTrue(AllFilesAccess.covers("/storage/emulated/0/Download/Android/data"))
|
||||
assertTrue(AllFilesAccess.covers("/storage/1A2B-3C4D/Games/Android/obb/x"))
|
||||
assertFalse(AllFilesAccess.covers("/storage/emulated/0/Android/data/com.droiddeck.launcher/files"))
|
||||
assertFalse(AllFilesAccess.covers("/storage/1A2B-3C4D/Android/obb/com.droiddeck.launcher"))
|
||||
assertFalse(AllFilesAccess.covers("/data/user/0/com.droiddeck.launcher/files"))
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ class PadPartialAxesTest {
|
||||
}
|
||||
|
||||
@Test fun keyTriggerDecision() {
|
||||
val held = BooleanArray(2)
|
||||
val held = PadBridge.TriggerKey.slots(1)[0]
|
||||
assertEquals(1f, PadBridge.keyTrigger(0f, true, 0, false, held, 0))
|
||||
assertEquals(0f, PadBridge.keyTrigger(1f, false, 0, false, held, 0))
|
||||
assertEquals(0.25f, PadBridge.keyTrigger(0.25f, true, 1, false, held, 0))
|
||||
@@ -271,6 +271,64 @@ class PadPartialAxesTest {
|
||||
assertEquals(0f, PadBridge.axisTrigger(0f, held, 1))
|
||||
}
|
||||
|
||||
@Test fun keyBeforeAxisOnAFullPullIsOnePress() {
|
||||
val device = device(MotionEvent.AXIS_GAS)
|
||||
motion(device)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_R2)
|
||||
assertEquals(1f, pad().rightTrigger)
|
||||
for (value in listOf(0.1f, 0.3f, 0.6f, 1f, 0.98f)) {
|
||||
motion(device, MotionEvent.AXIS_GAS to value)
|
||||
assertEquals(1f, pad().rightTrigger)
|
||||
}
|
||||
motion(device, MotionEvent.AXIS_GAS to 0.7f)
|
||||
assertEquals(0.7f, pad().rightTrigger)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_R2, KeyEvent.ACTION_UP)
|
||||
assertEquals(0.7f, pad().rightTrigger)
|
||||
motion(device, MotionEvent.AXIS_GAS to 0f)
|
||||
assertEquals(0f, pad().rightTrigger)
|
||||
}
|
||||
|
||||
@Test fun releasingDuringTheHandoffFollowsTheAxis() {
|
||||
val device = device(MotionEvent.AXIS_GAS)
|
||||
motion(device)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_R2)
|
||||
motion(device, MotionEvent.AXIS_GAS to 0.4f)
|
||||
assertEquals(1f, pad().rightTrigger)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_R2, KeyEvent.ACTION_UP)
|
||||
assertEquals(0.4f, pad().rightTrigger)
|
||||
}
|
||||
|
||||
@Test fun movingTriggerAxisStaysAnalogWhenItsKeyFiresFirst() {
|
||||
val device = device(MotionEvent.AXIS_GAS)
|
||||
motion(device, MotionEvent.AXIS_GAS to 0.5f)
|
||||
motion(device, MotionEvent.AXIS_GAS to 0f)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_R2)
|
||||
assertEquals(0f, pad().rightTrigger)
|
||||
motion(device, MotionEvent.AXIS_GAS to 0.1f)
|
||||
assertEquals(0.1f, pad().rightTrigger)
|
||||
motion(device, MotionEvent.AXIS_GAS to 0.35f)
|
||||
assertEquals(0.35f, pad().rightTrigger)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_R2, KeyEvent.ACTION_UP)
|
||||
motion(device, MotionEvent.AXIS_GAS to 0f)
|
||||
assertEquals(0f, pad().rightTrigger)
|
||||
}
|
||||
|
||||
@Test fun triggerSwitchedToDigitalPressesAgainAfterOneSilentPress() {
|
||||
val device = device(MotionEvent.AXIS_GAS)
|
||||
motion(device, MotionEvent.AXIS_GAS to 0.5f)
|
||||
motion(device, MotionEvent.AXIS_GAS to 0f)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_R2)
|
||||
motion(device)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_R2, KeyEvent.ACTION_UP)
|
||||
assertEquals(0f, pad().rightTrigger)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_R2)
|
||||
assertEquals(1f, pad().rightTrigger)
|
||||
motion(device)
|
||||
assertEquals(1f, pad().rightTrigger)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_R2, KeyEvent.ACTION_UP)
|
||||
assertEquals(0f, pad().rightTrigger)
|
||||
}
|
||||
|
||||
@Test fun silentTriggerAxesLetTheirKeysPress() {
|
||||
val device = device(MotionEvent.AXIS_LTRIGGER, MotionEvent.AXIS_RTRIGGER)
|
||||
motion(device)
|
||||
@@ -294,11 +352,15 @@ class PadPartialAxesTest {
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_L2)
|
||||
assertEquals(1f, pad().leftTrigger)
|
||||
motion(device, MotionEvent.AXIS_LTRIGGER to 0.4f)
|
||||
assertEquals(0.4f, pad().leftTrigger)
|
||||
assertEquals(1f, pad().leftTrigger)
|
||||
motion(device, MotionEvent.AXIS_LTRIGGER to 0f)
|
||||
assertEquals(0f, pad().leftTrigger)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_L2, KeyEvent.ACTION_UP)
|
||||
assertEquals(0f, pad().leftTrigger)
|
||||
key(device, KeyEvent.KEYCODE_BUTTON_L2)
|
||||
assertEquals(0f, pad().leftTrigger)
|
||||
motion(device, MotionEvent.AXIS_LTRIGGER to 0.4f)
|
||||
assertEquals(0.4f, pad().leftTrigger)
|
||||
}
|
||||
|
||||
private fun pad(): PadState = requireNotNull(JoyConPadTest.RecordingWriter.pads[0])
|
||||
|
||||
@@ -114,6 +114,23 @@ class EnhancedSessionLogShareTest {
|
||||
SessionLogShare.clear(app)
|
||||
}
|
||||
|
||||
@Test fun steamVrLaunchLogsAreSharedUnderTheirNames() {
|
||||
val session = tmp.newFolder("2026-11-29-05-steam")
|
||||
session.resolve("session.log").writeText("startup ok\n")
|
||||
val steam = session.resolve("steam").apply { mkdirs() }
|
||||
steam.resolve("droiddeck-steamvr-launch.log").writeText("downloading SteamVR (571 MB)\n")
|
||||
steam.resolve("droiddeck-vrstartup.log").writeText("vrstartup ok\n")
|
||||
steam.resolve("unknown-tool.log").writeText("other\n")
|
||||
|
||||
val zips = EnhancedSessionLogShare.create(app, session)
|
||||
|
||||
val names = zips.flatMap { zip -> ZipFile(zip).use { archive -> archive.entries().toList().map { it.name } } }
|
||||
assertTrue(names.contains("${session.name}/steam/droiddeck-steamvr-launch.log"))
|
||||
assertTrue(names.contains("${session.name}/steam/droiddeck-vrstartup.log"))
|
||||
assertTrue(names.none { it.endsWith("/unknown-tool.log") })
|
||||
SessionLogShare.clear(app)
|
||||
}
|
||||
|
||||
@Test fun oversizedFilesKeepBoundedBeginningAndTailAndDeclareTruncation() {
|
||||
val session = tmp.newFolder("2026-11-04-02-game")
|
||||
session.resolve("steam-7.log").writeText("begin\n" + "middle\n".repeat(100) + "tail\n")
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import com.droiddeck.launcher.gpu.SteamVr
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class QuestSteamVrLaunchTest {
|
||||
@Test fun aLibraryRequestOpensTheImmersiveViewOnlyWhenSteamVrIsInstalled() {
|
||||
assertEquals(
|
||||
setOf(SteamVr.Status.READY, SteamVr.Status.RUNNING),
|
||||
SteamVr.Status.values().filter { QuestSteamVrLaunch.opensDirectly(it) }.toSet(),
|
||||
)
|
||||
assertEquals(false, QuestSteamVrLaunch.opensDirectly(null))
|
||||
}
|
||||
|
||||
@Test fun aRequestThatHasToInstallSteamVrGoesThroughTheAutomaticInstallThenStart() {
|
||||
assertEquals("install", SteamVr.autoAction(SteamVr.Status.NOT_INSTALLED, requested = true, loading = false,
|
||||
steamSession = true, startTried = false, installTried = false))
|
||||
assertEquals(null, SteamVr.autoAction(SteamVr.Status.INSTALLING, requested = true, loading = false,
|
||||
steamSession = true, startTried = false, installTried = true))
|
||||
assertEquals("start", SteamVr.autoAction(SteamVr.Status.READY, requested = true, loading = false,
|
||||
steamSession = true, startTried = false, installTried = true))
|
||||
}
|
||||
}
|
||||
@@ -145,8 +145,10 @@ verification against the actual phone's Steam version after installation.
|
||||
|
||||
The helper serializes installation/startup and avoids restarting an active
|
||||
DroidDeck SteamVR session. Library launch diagnostics are in
|
||||
`${XDG_RUNTIME_DIR:-/tmp}/droiddeck-steamvr/library-launch.log`; normal runtime
|
||||
logs remain in `vrstartup.log` and Steam's logs directory. It does not intercept
|
||||
`droiddeck-steamvr-launch.log` in Steam's logs directory, next to
|
||||
`droiddeck-vrstartup.log`, and Share logs includes both. On a Quest the helper
|
||||
only asks the app for SteamVR: the app installs it if needed, showing that it is
|
||||
downloading, then opens the immersive view. It does not intercept
|
||||
arbitrary external `steam://` URLs or change VR game launch arguments.
|
||||
|
||||
Only VR-only games (`vr_only`) wait for SteamVR and start it. Games where VR is
|
||||
|
||||
@@ -83,6 +83,10 @@ and display timing, and returns owned stereo images tagged with the latest eye p
|
||||
SteamVR haptics return through the tracking bridge. No root or separate XR APK
|
||||
is required. Other devices retain their existing SteamVR start behavior.
|
||||
|
||||
Play on SteamVR in Steam's library does the same: if SteamVR is not installed yet,
|
||||
DroidDeck shows that it is downloading SteamVR, installs it, then opens the
|
||||
immersive view.
|
||||
|
||||
The left Touch menu button is SteamVR's system button and toggles its dashboard.
|
||||
The right Meta button remains reserved by the headset OS.
|
||||
|
||||
|
||||
@@ -474,3 +474,13 @@ Short strokes never released it, and taps kept landing at the relative pointer i
|
||||
counts its touch-down warps, and a frame that contains one is left out of the hold decision. Touch drags, mouse motion
|
||||
and mouse warps still count, so a drag on a game that follows the pointer releases the hold and a recentring game is
|
||||
still held. `tools/tests/test_gamescope_pointer_hold_touch_down.py` compiles the rule with the 0133 rule.
|
||||
|
||||
## 0146 rendervulkan: composite only into output images the display has finished scanning out
|
||||
|
||||
The host compositor now releases a zero-copy display buffer as soon as the display latches the next one, and attaches
|
||||
the display's release fence to the buffer's dma-buf instead of waiting for it on the CPU. That wait had held every
|
||||
release back by about one refresh, so a chain of three buffers ran at two thirds of the refresh rate. KGSL Turnip does
|
||||
not wait on fences attached to a dma-buf, so the composite now checks each output image's dma-buf with `poll(POLLOUT)`.
|
||||
It picks the next image that is neither held by the host nor still being scanned out. Only when every free image is
|
||||
still on the display does it wait for one, up to 100 ms. On kernels that cannot attach the fence, the host keeps
|
||||
waiting itself and nothing changes. `tools/gamescope/tests/nested-swapchain.cpp` covers the choice and the busy check.
|
||||
@@ -0,0 +1,106 @@
|
||||
diff --git a/src/output_image_pick.hpp b/src/output_image_pick.hpp
|
||||
new file mode 100644
|
||||
index 0000000..193d9de
|
||||
--- /dev/null
|
||||
+++ b/src/output_image_pick.hpp
|
||||
@@ -0,0 +1,50 @@
|
||||
+#pragma once
|
||||
+#include <cstdint>
|
||||
+#include <poll.h>
|
||||
+
|
||||
+namespace gamescope
|
||||
+{
|
||||
+struct OutputImagePick
|
||||
+{
|
||||
+ uint32_t image;
|
||||
+ bool scanoutPending;
|
||||
+};
|
||||
+
|
||||
+template <typename Held, typename Busy>
|
||||
+inline OutputImagePick PickOutputImage( uint32_t count, uint32_t first, uint32_t last, uint32_t deferred,
|
||||
+ Held &&held, Busy &&busy )
|
||||
+{
|
||||
+ for ( int pass = 0; pass < 2; pass++ )
|
||||
+ {
|
||||
+ for ( uint32_t i = 0; i < count; i++ )
|
||||
+ {
|
||||
+ const uint32_t image = ( first + i ) % count;
|
||||
+ if ( count > 3 && ( image == last || image == deferred ) )
|
||||
+ continue;
|
||||
+ if ( held( image ) )
|
||||
+ continue;
|
||||
+ const bool pending = busy( image );
|
||||
+ if ( pass == 0 && pending )
|
||||
+ continue;
|
||||
+ return { image, pending };
|
||||
+ }
|
||||
+ }
|
||||
+ return { first, busy( first ) };
|
||||
+}
|
||||
+
|
||||
+inline bool DmabufScanoutPending( int fd )
|
||||
+{
|
||||
+ if ( fd < 0 )
|
||||
+ return false;
|
||||
+ pollfd p = { .fd = fd, .events = POLLOUT, .revents = 0 };
|
||||
+ return poll( &p, 1, 0 ) == 0;
|
||||
+}
|
||||
+
|
||||
+inline void WaitDmabufScanout( int fd, int timeoutMs )
|
||||
+{
|
||||
+ if ( fd < 0 )
|
||||
+ return;
|
||||
+ pollfd p = { .fd = fd, .events = POLLOUT, .revents = 0 };
|
||||
+ poll( &p, 1, timeoutMs );
|
||||
+}
|
||||
+}
|
||||
diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp
|
||||
index 1d3a80c..3668a10 100644
|
||||
--- a/src/rendervulkan.cpp
|
||||
+++ b/src/rendervulkan.cpp
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "steamcompmgr.hpp"
|
||||
#include "log.hpp"
|
||||
#include "Utils/Process.h"
|
||||
+#include "output_image_pick.hpp"
|
||||
|
||||
#include "cs_composite_blit.h"
|
||||
#include "cs_composite_blur.h"
|
||||
@@ -4297,18 +4298,29 @@ static bool vulkan_output_image_held( uint32_t nImage )
|
||||
return false;
|
||||
}
|
||||
|
||||
+static bool vulkan_output_image_scanout_pending( uint32_t nImage )
|
||||
+{
|
||||
+ for ( const auto &pImage : { g_output.outputImages[ nImage ], g_output.outputImagesPartialOverlay[ nImage ] } )
|
||||
+ {
|
||||
+ if ( pImage != nullptr && pImage->GetBackendFb() != nullptr && gamescope::DmabufScanoutPending( pImage->dmabuf().fd[0] ) )
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
static uint32_t vulkan_free_output_image( uint32_t nFirst )
|
||||
{
|
||||
- const uint32_t uCount = g_output.outputImages.size();
|
||||
- for ( uint32_t i = 0; i < uCount; i++ )
|
||||
+ const gamescope::OutputImagePick pick = gamescope::PickOutputImage( g_output.outputImages.size(), nFirst,
|
||||
+ g_output.nLastOutImage, g_output.nDeferredOutImage, vulkan_output_image_held, vulkan_output_image_scanout_pending );
|
||||
+ if ( pick.scanoutPending )
|
||||
{
|
||||
- const uint32_t nImage = ( nFirst + i ) % uCount;
|
||||
- if ( uCount > 3 && ( nImage == g_output.nLastOutImage || nImage == g_output.nDeferredOutImage ) )
|
||||
- continue;
|
||||
- if ( !vulkan_output_image_held( nImage ) )
|
||||
- return nImage;
|
||||
+ for ( const auto &pImage : { g_output.outputImages[ pick.image ], g_output.outputImagesPartialOverlay[ pick.image ] } )
|
||||
+ {
|
||||
+ if ( pImage != nullptr && pImage->GetBackendFb() != nullptr )
|
||||
+ gamescope::WaitDmabufScanout( pImage->dmabuf().fd[0], 100 );
|
||||
+ }
|
||||
}
|
||||
- return nFirst;
|
||||
+ return pick.image;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> vulkan_composite( struct FrameInfo_t *frameInfo, gamescope::Rc<CVulkanTexture> pPipewireTexture, bool partial, gamescope::Rc<CVulkanTexture> pOutputOverride, bool increment, std::unique_ptr<CVulkanCmdBuffer> pInCommandBuffer )
|
||||
@@ -1,3 +1,3 @@
|
||||
GAMESCOPE_REPO=Droid-Deck/DroidDeck-Components
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-1a29c65d
|
||||
GAMESCOPE_SHA256=18620dfedb65860da00003e965cc09784a650ef6ecc9a17056405fe0a1392a02
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-f3a45b31
|
||||
GAMESCOPE_SHA256=3908af87b2ee8a328e9780fc805c6a7bddd11d7405b9992d717b94e16c019313
|
||||
@@ -2,6 +2,9 @@
|
||||
#include "nested_surface_format.hpp"
|
||||
#include "dmabuf_import.hpp"
|
||||
#include "sdl_refresh.hpp"
|
||||
#include "output_image_pick.hpp"
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
|
||||
@@ -152,5 +155,43 @@ int main()
|
||||
assert(DmabufMemoryType(memory, 7, 0, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) == UINT32_MAX);
|
||||
assert(DmabufMemoryType(memory, 7, 4, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) == UINT32_MAX);
|
||||
|
||||
using gamescope::PickOutputImage;
|
||||
auto none = [](uint32_t) { return false; };
|
||||
auto pick = PickOutputImage(5, 2, 1, 0, none, none);
|
||||
assert(pick.image == 2 && !pick.scanoutPending);
|
||||
auto heldTwo = [](uint32_t i) { return i == 2; };
|
||||
pick = PickOutputImage(5, 2, 1, 0, heldTwo, none);
|
||||
assert(pick.image == 3 && !pick.scanoutPending);
|
||||
auto scanningTwo = [](uint32_t i) { return i == 2; };
|
||||
pick = PickOutputImage(5, 2, 1, 0, none, scanningTwo);
|
||||
assert(pick.image == 3 && !pick.scanoutPending);
|
||||
auto scanningAll = [](uint32_t) { return true; };
|
||||
pick = PickOutputImage(5, 2, 1, 0, heldTwo, scanningAll);
|
||||
assert(pick.image == 3 && pick.scanoutPending);
|
||||
auto heldAll = [](uint32_t) { return true; };
|
||||
auto scanningOne = [](uint32_t i) { return i == 1; };
|
||||
pick = PickOutputImage(5, 2, 1, 0, heldAll, none);
|
||||
assert(pick.image == 2 && !pick.scanoutPending);
|
||||
pick = PickOutputImage(5, 1, 0, 1, heldAll, scanningOne);
|
||||
assert(pick.image == 1 && pick.scanoutPending);
|
||||
pick = PickOutputImage(3, 1, 0, 2, none, none);
|
||||
assert(pick.image == 1 && !pick.scanoutPending);
|
||||
pick = PickOutputImage(3, 1, 0, 2, none, scanningOne);
|
||||
assert(pick.image == 2 && !pick.scanoutPending);
|
||||
|
||||
int fds[2];
|
||||
assert(pipe(fds) == 0);
|
||||
assert(!gamescope::DmabufScanoutPending(fds[1]));
|
||||
assert(!gamescope::DmabufScanoutPending(-1));
|
||||
fcntl(fds[1], F_SETFL, O_NONBLOCK);
|
||||
char block[4096] = {};
|
||||
while (write(fds[1], block, sizeof(block)) > 0) {}
|
||||
assert(gamescope::DmabufScanoutPending(fds[1]));
|
||||
gamescope::WaitDmabufScanout(fds[1], 1);
|
||||
while (read(fds[0], block, sizeof(block)) == sizeof(block) && gamescope::DmabufScanoutPending(fds[1])) {}
|
||||
assert(!gamescope::DmabufScanoutPending(fds[1]));
|
||||
close(fds[0]);
|
||||
close(fds[1]);
|
||||
std::puts("Gamescope presentation and DMA-BUF import tests passed");
|
||||
}
|
||||
@@ -546,10 +546,10 @@ VR_JS = r"""
|
||||
|
||||
def launch_steamvr():
|
||||
say("SteamVR library launch: using the DroidDeck ARM64 helper")
|
||||
state = os.path.join(os.environ.get("XDG_RUNTIME_DIR", "/tmp"), "droiddeck-steamvr")
|
||||
logs = os.path.join(os.path.expanduser("~"), ".local/share/Steam/logs")
|
||||
try:
|
||||
os.makedirs(state, exist_ok=True)
|
||||
with open(os.path.join(state, "library-launch.log"), "a") as log:
|
||||
os.makedirs(logs, exist_ok=True)
|
||||
with open(os.path.join(logs, "droiddeck-steamvr-launch.log"), "a") as log:
|
||||
return subprocess.Popen([VR_HELPER, "launch"], stdin=subprocess.DEVNULL,
|
||||
stdout=log, stderr=subprocess.STDOUT, start_new_session=True)
|
||||
except OSError as e:
|
||||
|
||||
@@ -103,15 +103,15 @@ case "${1:-status}" in
|
||||
launch)
|
||||
exec 8>"$state/launch.lock"
|
||||
flock -n 8 || exit 0
|
||||
if [ -f "$state/quest-immersive" ]; then
|
||||
: > "$state/xr-request"
|
||||
echo "asked DroidDeck to install SteamVR if needed and open the Quest's immersive view"
|
||||
exit 0
|
||||
fi
|
||||
if ! installed; then
|
||||
"$0" install || exit $?
|
||||
while [ -f "$state/installing" ]; do sleep 1; done
|
||||
fi
|
||||
if [ -f "$state/quest-immersive" ]; then
|
||||
: > "$state/xr-request"
|
||||
echo "asked DroidDeck to open the Quest's immersive view, which starts SteamVR"
|
||||
exit 0
|
||||
fi
|
||||
"$0" start
|
||||
;;
|
||||
status)
|
||||
|
||||
@@ -1003,13 +1003,15 @@ class SwitchToDesktopTest(unittest.TestCase):
|
||||
self.assertEqual(patched["launch_steamvr"].call_count, 2)
|
||||
|
||||
def test_vr_launch_runs_helper_without_shell_in_background(self):
|
||||
with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"XDG_RUNTIME_DIR": tmp}):
|
||||
with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"HOME": tmp}):
|
||||
with mock.patch.object(self.globals["subprocess"], "Popen") as popen:
|
||||
LIVE["launch_steamvr"]()
|
||||
self.assertEqual(popen.call_args.args, ([LIVE["VR_HELPER"], "launch"],))
|
||||
self.assertTrue(popen.call_args.kwargs["start_new_session"])
|
||||
self.assertNotIn("shell", popen.call_args.kwargs)
|
||||
self.assertTrue((Path(tmp) / "droiddeck-steamvr/library-launch.log").exists())
|
||||
self.assertEqual(popen.call_args.kwargs["stdout"].name,
|
||||
str(Path(tmp) / ".local/share/Steam/logs/droiddeck-steamvr-launch.log"))
|
||||
self.assertTrue((Path(tmp) / ".local/share/Steam/logs/droiddeck-steamvr-launch.log").exists())
|
||||
|
||||
def test_the_request_goes_to_steamos_session_select(self):
|
||||
helper = LIVE["Helper"]("/steam", 1)
|
||||
|
||||
@@ -274,6 +274,32 @@ class SteamVrHelperTest(unittest.TestCase):
|
||||
self.assertTrue(vrpath.is_file())
|
||||
self.assertTrue(xr.is_symlink())
|
||||
|
||||
def launch(self):
|
||||
self.executable(self.commands / 'curl', 'echo curl >> "$CURL_CALLS"; exit 22')
|
||||
self.environment['CURL_CALLS'] = str(self.root / 'curl-calls')
|
||||
self.helper.chmod(0o755)
|
||||
return subprocess.run(['sh', str(self.helper), 'launch'], env=self.environment,
|
||||
capture_output=True, text=True, timeout=5)
|
||||
|
||||
def test_quest_launch_hands_a_missing_steamvr_to_the_app_without_downloading_it(self):
|
||||
(self.steamvr / 'bin/linuxarm64/vrstartup').unlink()
|
||||
state = self.runtime / 'droiddeck-steamvr'
|
||||
state.mkdir(parents=True)
|
||||
(state / 'quest-immersive').touch()
|
||||
result = self.launch()
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertTrue((state / 'xr-request').is_file())
|
||||
self.assertFalse((self.root / 'curl-calls').exists())
|
||||
self.assertFalse((state / 'installing').exists())
|
||||
|
||||
def test_launch_elsewhere_still_installs_a_missing_steamvr_itself(self):
|
||||
(self.steamvr / 'bin/linuxarm64/vrstartup').unlink()
|
||||
result = self.launch()
|
||||
self.assertEqual(result.returncode, 1)
|
||||
self.assertIn('download failed', result.stdout)
|
||||
self.assertTrue((self.root / 'curl-calls').is_file())
|
||||
self.assertFalse((self.runtime / 'droiddeck-steamvr/xr-request').exists())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,141 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from test_vk_pending_completion import function
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SRC = ROOT / 'app/src/main/cpp/waylandcomp/src'
|
||||
|
||||
HARNESS = r'''
|
||||
#define _GNU_SOURCE
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <poll.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-util.h>
|
||||
struct wl_listener { struct wl_list link; void (*notify)(struct wl_listener *, void *); };
|
||||
struct wl_event_source { int unused; };
|
||||
struct wl_event_loop;
|
||||
enum { WL_EVENT_READABLE = 1 };
|
||||
struct wl_client;
|
||||
struct wl_resource { int unused; };
|
||||
struct surface;
|
||||
struct dmabuf_buffer { int fd; };
|
||||
typedef struct AHardwareBuffer { int unused; } AHardwareBuffer;
|
||||
DEFINES
|
||||
STRUCT
|
||||
static struct wl_list g_bufs;
|
||||
static struct wl_event_loop *g_loop;
|
||||
static int g_import_failed_logged;
|
||||
static int import_ok, imports, imported_flags, deferred_releases, frees, sources;
|
||||
static struct wl_event_source g_source;
|
||||
void wl_list_init(struct wl_list *l) { l->prev = l; l->next = l; }
|
||||
void wl_list_insert(struct wl_list *l, struct wl_list *e) {
|
||||
e->next = l->next; e->prev = l; l->next->prev = e; l->next = e;
|
||||
}
|
||||
static int fake_ioctl(int fd, unsigned long req, void *arg) {
|
||||
struct droiddeck_dma_buf_sync_file *f = arg;
|
||||
(void)fd;
|
||||
assert(req == DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE);
|
||||
++imports; imported_flags = (int)f->flags;
|
||||
if (import_ok) return 0;
|
||||
errno = ENOTTY; return -1;
|
||||
}
|
||||
#define ioctl fake_ioctl
|
||||
static int droiddeck_dmabuf_fd(struct dmabuf_buffer *b) { return b->fd; }
|
||||
static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; }
|
||||
static struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *l, int fd, uint32_t m,
|
||||
int (*cb)(int, uint32_t, void *), void *d) {
|
||||
(void)l; (void)fd; (void)m; (void)cb; (void)d; ++sources; return &g_source;
|
||||
}
|
||||
static int on_fence_readable(int fd, uint32_t mask, void *data) { (void)fd; (void)mask; (void)data; return 0; }
|
||||
static void send_deferred_release(struct ahb_buf *ab) { ++deferred_releases; ab->release_pending = 0; }
|
||||
static void maybe_free(struct ahb_buf *ab) { (void)ab; ++frees; }
|
||||
FUNCTIONS
|
||||
static void reset(void) { import_ok = imports = imported_flags = deferred_releases = frees = sources = 0; }
|
||||
static void run(int display, int can_import, int fence_signalled) {
|
||||
reset();
|
||||
wl_list_init(&g_bufs);
|
||||
struct dmabuf_buffer b = {.fd = 7};
|
||||
struct ahb_buf ab;
|
||||
memset(&ab, 0, sizeof(ab));
|
||||
ab.id = 42; ab.b = &b; ab.display = display; ab.on_layer = 1; ab.release_pending = 1; ab.fence_fd = -1;
|
||||
wl_list_insert(&g_bufs, &ab.link);
|
||||
int fds[2]; assert(pipe(fds) == 0);
|
||||
if (fence_signalled) assert(write(fds[1], "x", 1) == 1);
|
||||
import_ok = can_import;
|
||||
handle_released(42, fds[0]);
|
||||
assert(!ab.on_layer && imports == 1 && imported_flags == DROIDDECK_DMA_BUF_SYNC_READ);
|
||||
if (can_import || fence_signalled) {
|
||||
assert(deferred_releases == 1 && frees == 1 && !ab.fence_src && ab.fence_fd == -1);
|
||||
errno = 0; assert(fcntl(fds[0], F_GETFD) == -1 && errno == EBADF);
|
||||
} else {
|
||||
assert(deferred_releases == 0 && sources == 1 && ab.fence_src == &g_source && ab.fence_fd == fds[0]);
|
||||
close(fds[0]);
|
||||
}
|
||||
close(fds[1]);
|
||||
}
|
||||
int main(int argc, char **argv) {
|
||||
assert(argc == 4);
|
||||
run(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
class ZeroCopyReleaseAtLatchTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cc = shutil.which(os.environ.get('CC', 'cc'))
|
||||
if not cc:
|
||||
raise AssertionError('C compiler required')
|
||||
source_dir = Path(os.environ.get('DROIDDECK_DMABUF_TEST_SOURCE', SRC))
|
||||
ahb = (source_dir / 'ahb_swapchain.c').read_text()
|
||||
defines = '\n'.join(re.findall(r'^(?:struct droiddeck_dma_buf_sync_file \{.*?\};|#define DROIDDECK_DMA_BUF_\w+ .*)$',
|
||||
ahb, re.M))
|
||||
struct = re.search(r'struct ahb_buf \{.*?\n\};', ahb, re.S).group()
|
||||
functions = '\n'.join(function(ahb, n) for n in ('find_buf', 'handle_released'))
|
||||
source = HARNESS.replace('DEFINES', '#include <fcntl.h>\n#include <sys/ioctl.h>\n' + defines)
|
||||
source = source.replace('STRUCT', struct).replace('FUNCTIONS', functions)
|
||||
cls.tmp = tempfile.TemporaryDirectory(prefix='droiddeck-release-latch-')
|
||||
cls.addClassCleanup(cls.tmp.cleanup)
|
||||
probe = Path(cls.tmp.name) / 'probe.c'
|
||||
probe.write_text(source)
|
||||
cls.binary = probe.with_suffix('')
|
||||
built = subprocess.run([cc, '-std=c11', '-Wall', '-Wextra', '-Werror', '-Wno-unused-function', '-UNDEBUG',
|
||||
'-I', str(SRC.parent / 'prebuilt/include'), str(probe), '-o', str(cls.binary)],
|
||||
capture_output=True, text=True)
|
||||
if built.returncode:
|
||||
raise AssertionError(built.stdout + built.stderr)
|
||||
|
||||
def scenario(self, display, can_import, fence_signalled):
|
||||
result = subprocess.run([str(self.binary), str(display), str(can_import), str(fence_signalled)],
|
||||
capture_output=True, text=True, timeout=10)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
|
||||
def test_display_buffer_released_at_latch_when_fence_attaches(self):
|
||||
self.scenario(1, 1, 0)
|
||||
|
||||
def test_swapchain_buffer_released_at_latch_when_fence_attaches(self):
|
||||
self.scenario(0, 1, 0)
|
||||
|
||||
def test_display_buffer_waits_for_fence_when_kernel_cannot_attach(self):
|
||||
self.scenario(1, 0, 0)
|
||||
|
||||
def test_swapchain_buffer_waits_for_fence_when_kernel_cannot_attach(self):
|
||||
self.scenario(0, 0, 0)
|
||||
|
||||
def test_signalled_fence_releases_without_waiting(self):
|
||||
self.scenario(1, 0, 1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,25 +1,25 @@
|
||||
{
|
||||
"repository": "domsvoboda/nexus-runtime",
|
||||
"tag": "runtime-11.0-experimental-g86b2e622",
|
||||
"archive": "nexus-runtime-11.0-experimental-g86b2e622-x86_64.tar.xz",
|
||||
"sha512": "a93d566b68f56e6689d644cc3006bd91515e0ef849898cc9b0603ebceda01be5d5e8c5b21718d0ff073f5f1d6fbc31727f4a92450754465c6b8ef32a14c7e5fd",
|
||||
"tag": "runtime-11.0-20261102-g76c6dd13",
|
||||
"archive": "nexus-runtime-11.0-experimental-g76c6dd13-x86_64.tar.xz",
|
||||
"sha512": "ed6bf55af56128d831ec78ce223770978250d8a4692ea1f24f26258e9d5460c8106e9e6000f554665c91cfcf2abdd235e018d845d8f0cbbed0daaa3d50e61b62",
|
||||
"source": {
|
||||
"name": "nexus-runtime-11.0-experimental-g86b2e622-source.tar.xz",
|
||||
"sha256": "ec8c3d0c8b2a9fe37a53bcaec15a43c3ed9c0c001a4531578c73adc23505f050"
|
||||
"name": "nexus-runtime-11.0-experimental-g76c6dd13-source.tar.xz",
|
||||
"sha256": "9fd3ce24d0c9032fc2237df828c69f07e3de67f6c7008c89881ae7b805f953f5"
|
||||
},
|
||||
"xgameruntime": "b25c05f3d74c4574df93b6fa6c33f06847202ee3",
|
||||
"xgameruntime": "455b1ba9c59984f9478af062fa1aec496bc58ccc",
|
||||
"dlls": {
|
||||
"twinapi.appcore.dll": "aacc1e720dac6cf4192fc6e0f2064499dcda0b339c40601112ab7ceeeb0bdc9e",
|
||||
"windows.web.dll": "e5ae3dc522c5b2502a9d672641f8ffd6c29b93df397b44333c16949d699869de",
|
||||
"libnghttp2.dll": "1001dbbff8b9cb1efa558825b95cbe8efdf5570ad30f5177bdce61b2d102026e",
|
||||
"xgameruntime.dll": "0736131f2c2aeb33866f3f6d1193fc33acd30dd6b3d544dea9830e00e282b3c9",
|
||||
"winhttp.dll": "84c17a9757494af066dd3aea9ce52ed718bcfd3d58739ba6284f83e8eefce8ae",
|
||||
"wintypes.dll": "9542f783f066749ac5e1a5e6e90026eeba575f708e1f4d313caadcfbe51e181d"
|
||||
"twinapi.appcore.dll": "a9e640dee244a900a2d629ea62f2794e8ff973f916871b32b8f3b0f385e70006",
|
||||
"windows.web.dll": "c0b3c78c0d61f0df5387f8bbf6b6b1090d27db07ebdf6f941dce51b02dd28faa",
|
||||
"libnghttp2.dll": "a9c265b965d9af735886eb51e01afde905bc7ea53ed3dcc9ae18e2aebd45d8d0",
|
||||
"xgameruntime.dll": "90b4fd26bd52924a38b720840a3ad1cd9281a9aa64a91c0b52b650d096f1a883",
|
||||
"winhttp.dll": "e8e4e8a91834b481e305a0b6ae83894378ed6a1e83d5a1200605ca7526a46d45",
|
||||
"wintypes.dll": "0583b241fcbf2817a5088373875212f8f2c06bc84d854bc7fc4eb3b5cf75e126"
|
||||
},
|
||||
"compat": {
|
||||
"files/share/xodus-nexus/compat/PlayFabGameSave.dll": [
|
||||
"compat/PlayFabGameSave.dll",
|
||||
"d73ce4802ed5995375a1ce2b85b7c9b30105442a654679f14b99abea2906c69f"
|
||||
"83b4e9985244558b8449a92aafad64681182073d92d60e7bf3536bbac74d7e03"
|
||||
],
|
||||
"files/share/doc/nexus-runtime/runtime-compat-LICENSE": [
|
||||
"LICENSE.runtime-compat",
|
||||
|
||||
Reference in new issue
Block a user