Compare commits

..
Author SHA1 Message Date
maxjivi05 1525dcfb52 fix(input): the controls editor uses the same screen area as the game, so edited controls stay where they were placed
On screens with a cutout the editor window stopped at the cutout while the
session drew across it, so controls on the cutout side moved over by the
cutout's width in game and could overlap. Both windows now lay out into the
cutout through one shared helper and see the same safe insets.
2026-11-29 14:14:07 -05:00
21 changed files with 81 additions and 303 deletions

No files matched your search

@@ -1993,7 +1993,11 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
}
}
if (savedInstanceState == null) ui.post { startSteamAtStartupIfEnabled(cold = true) }
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) }
}
saved?.let { state ->
restoreCompatLaunch(state)
pendingSwitch = savedIntent(state, KEY_PENDING_SWITCH)
@@ -2001,8 +2005,13 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
}
val wanted = ArrayList<String>()
// 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) {
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) {
wanted.add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
}
if (SessionPrefs.micEnabled(this) && !SessionPrefs.micAsked(this)
@@ -2011,7 +2020,6 @@ 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)
@@ -2291,22 +2299,7 @@ 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)
@@ -2315,7 +2308,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
override fun onResume() {
super.onResume()
inFront = true
if (!homeChoiceOpen) {
HomeApp.releaseUnusedHomeEntry(this)
refreshHomeAppState()
@@ -2451,7 +2443,6 @@ 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()
@@ -3751,7 +3742,6 @@ 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()
}
@@ -54,6 +54,7 @@ import com.droiddeck.launcher.stores.StoreAchievements
import com.droiddeck.launcher.stores.StoreGameSidecar
import com.droiddeck.launcher.stores.StoreLaunchRequests
import com.droiddeck.launcher.stores.epic.EpicClient
import com.droiddeck.launcher.ui.extendIntoCutout
import com.droiddeck.launcher.ui.SessionAchievements
import com.droiddeck.launcher.ui.screenIsOff
import com.droiddeck.launcher.gpu.Cardboard
@@ -6349,7 +6350,10 @@ 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) requestSteamVr()
if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) {
SessionState.steamVr = true
steamVrAutoTried = false
}
if (intent.action == SessionService.ACTION_HOME_GUIDE) {
handleHomeGuideIntent(intent)
} else if (intent.action == SessionService.ACTION_RESUME) {
@@ -6438,10 +6442,7 @@ 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) {
if (com.droiddeck.launcher.session.QuestSteamVrLaunch.opensDirectly(steamVrStatus)) steamVrAction("start")
else requestSteamVr()
}
SessionState.running && SessionState.mode == SessionService.MODE_STEAM) steamVrAction("start")
uiHandler.postDelayed(this, 1000)
}
}
@@ -6500,12 +6501,6 @@ 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))
@@ -6983,7 +6978,6 @@ 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)
}
@@ -7104,13 +7098,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
if (Build.VERSION.SDK_INT >= 28) {
window.attributes = window.attributes.apply {
layoutInDisplayCutoutMode = if (Build.VERSION.SDK_INT >= 30)
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
else WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
}
}
window.extendIntoCutout()
}
private val endListener: (Int) -> Unit = { status -> onSessionEnded(status) }
@@ -8,18 +8,9 @@ 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,15 +504,13 @@ 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; accessDeclined = true },
onDismissRequest = { accessDrive = null },
title = { Text(stringResource(R.string.fm_drive_access_title, label)) },
text = { Text(stringResource(R.string.fm_drive_access_text)) },
confirmButton = {
@@ -521,17 +519,9 @@ fun FileManagerScreen(
AllFilesAccess.open(context)
}, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.upd_open_settings)) }
},
dismissButton = { TextButton(onClick = { accessDrive = null; accessDeclined = true }, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) } },
dismissButton = { TextButton(onClick = { accessDrive = null }, 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 TriggerKey[][] keyTriggers = TriggerKey.slots(SLOTS);
private final boolean[][] keyTriggers = new boolean[SLOTS][2];
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);
for (TriggerKey key : keyTriggers[slot]) key.reset();
Arrays.fill(keyTriggers[slot], false);
}
private void mutateState(java.util.function.Consumer<PadState> mutation) {
@@ -570,76 +570,26 @@ public final class PadBridge {
return true;
}
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];
static float keyTrigger(float current, boolean pressed, int repeatCount, boolean analog, boolean[] held, int side) {
if (repeatCount > 0) return current;
if (!analog) {
key.held = pressed;
held[side] = pressed;
return pressed ? 1f : 0f;
}
if (pressed) {
key.axisMovedWhilePressed = false;
if (key.axisLive || current != 0f) return current;
key.held = true;
if (current != 0f) return current;
held[side] = true;
return 1f;
}
if (!key.axisMovedWhilePressed) key.axisLive = false;
if (key.handoff) {
key.handoff = false;
return key.axis;
}
if (!key.held) return current;
key.held = false;
if (!held[side]) return current;
held[side] = false;
return 0f;
}
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;
}
static float axisTrigger(float value, boolean[] held, int side) {
if (!held[side]) return value;
if (value == 0f) return 1f;
held[side] = false;
return value;
}
@@ -951,7 +951,6 @@ 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,10 +29,6 @@ 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)
@@ -56,10 +52,8 @@ 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. */
@@ -96,7 +90,6 @@ 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,7 +1,6 @@
package com.droiddeck.launcher.session
import android.content.Context
import com.droiddeck.launcher.gpu.SteamVr
import java.io.File
/**
@@ -33,7 +32,4 @@ 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,6 +960,12 @@ 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) {
@@ -7,6 +7,7 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.Display
import android.os.Build
import android.view.View
import android.view.Window
import android.view.WindowManager
@@ -480,6 +481,15 @@ private class SurfaceEditorPresentation(private val host: ComponentActivity, dis
internal fun Window.prepareInputEditor() {
addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or WindowManager.LayoutParams.FLAG_FULLSCREEN)
setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT)
extendIntoCutout()
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
}
internal fun Window.extendIntoCutout() {
if (Build.VERSION.SDK_INT < 28) return
attributes = attributes.apply {
layoutInDisplayCutoutMode = if (Build.VERSION.SDK_INT >= 30) WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
else WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
}
}
@@ -21,20 +21,4 @@ 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 = PadBridge.TriggerKey.slots(1)[0]
val held = BooleanArray(2)
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,64 +271,6 @@ 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)
@@ -352,15 +294,11 @@ class PadPartialAxesTest {
key(device, KeyEvent.KEYCODE_BUTTON_L2)
assertEquals(1f, pad().leftTrigger)
motion(device, MotionEvent.AXIS_LTRIGGER to 0.4f)
assertEquals(1f, pad().leftTrigger)
assertEquals(0.4f, 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,23 +114,6 @@ 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")
@@ -1,24 +0,0 @@
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))
}
}
@@ -5,6 +5,7 @@ import android.view.InputDevice
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import com.droiddeck.launcher.input.InputControl
import com.droiddeck.launcher.input.InputLibraries
import com.droiddeck.launcher.input.InputSurfaceElement
@@ -22,6 +23,7 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.Robolectric
import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
@@ -90,6 +92,22 @@ class InputSurfaceEditorViewTest {
private fun InputSurfaceEditorView.centre(id: String) = rendered().first { it.id == id }.let { (it.x + it.width / 2) * width to (it.y + it.height / 2) * height }
private fun editorCutoutMode(): Int {
val activity = Robolectric.buildActivity(android.app.Activity::class.java).setup().get()
val dialog = android.app.Dialog(activity)
dialog.window!!.prepareInputEditor()
return dialog.window!!.attributes.layoutInDisplayCutoutMode
}
@Test fun theEditorLaysOutIntoTheCutoutLikeTheSession() {
assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS, editorCutoutMode())
}
@Config(sdk = [29])
@Test fun theEditorLaysOutIntoShortEdgeCutoutsOnOlderAndroid() {
assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, editorCutoutMode())
}
@Test fun editingStartsInTheDisplayedFrame() {
val view = view()
var started: Pair<List<InputSurfaceElement>, Float>? = null
+2 -4
View File
@@ -145,10 +145,8 @@ 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
`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
`${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
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
-4
View File
@@ -83,10 +83,6 @@ 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.
@@ -546,10 +546,10 @@ VR_JS = r"""
def launch_steamvr():
say("SteamVR library launch: using the DroidDeck ARM64 helper")
logs = os.path.join(os.path.expanduser("~"), ".local/share/Steam/logs")
state = os.path.join(os.environ.get("XDG_RUNTIME_DIR", "/tmp"), "droiddeck-steamvr")
try:
os.makedirs(logs, exist_ok=True)
with open(os.path.join(logs, "droiddeck-steamvr-launch.log"), "a") as log:
os.makedirs(state, exist_ok=True)
with open(os.path.join(state, "library-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)
+2 -4
View File
@@ -1003,15 +1003,13 @@ 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, {"HOME": tmp}):
with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"XDG_RUNTIME_DIR": 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.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())
self.assertTrue((Path(tmp) / "droiddeck-steamvr/library-launch.log").exists())
def test_the_request_goes_to_steamos_session_select(self):
helper = LIVE["Helper"]("/steam", 1)
-26
View File
@@ -274,32 +274,6 @@ 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()