Compare commits

..
Author SHA1 Message Date
The412Banner 11193646b2 fix(input): a mouse on the game's second screen drives the session pointer
With the game shown on another display (Dual screen sessions set to game on
second screen, or Swap screens), mouse and touchpad events on that display
were passed to the phone window's panel, which consumed them, so the
session pointer never moved. Route them to the session's mouse handler in
that screen's surface space and hide Android's arrow over the game, where
the compositor already draws the guest cursor.
2026-11-29 19:27:51 +00:00
15 changed files with 127 additions and 219 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()
}
@@ -3888,8 +3888,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
else -> return super.dispatchGenericMotionEvent(event)
}
if ((event.isFromSource(android.view.InputDevice.SOURCE_MOUSE) ||
event.isFromSource(android.view.InputDevice.SOURCE_TOUCHPAD)) && !drawerOpen) {
if (com.droiddeck.launcher.input.PointerCapture.isMouse(event) && !drawerOpen) {
if (appUiOwnsPointer()) {
if (super.dispatchGenericMotionEvent(event)) return true
if (touchEditorOpen) return false
@@ -5401,8 +5400,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private fun handleTouch(event: MotionEvent): Boolean {
val pen = PenStream.penIndex(event)
val penRouted = if (pen >= 0) routePen(event, pen).takeIf { it != PenRouter.Route.TOUCH } else null
if (penRouted == null && (event.isFromSource(android.view.InputDevice.SOURCE_MOUSE) ||
event.isFromSource(android.view.InputDevice.SOURCE_TOUCHPAD))) return onMouse(event)
if (penRouted == null && com.droiddeck.launcher.input.PointerCapture.isMouse(event)) return onMouse(event)
when (event.actionMasked) {
MotionEvent.ACTION_DOWN -> {
sessionTouchDown = true
@@ -6834,7 +6832,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private fun onBottomGameHover(event: MotionEvent): Boolean {
val pen = PenStream.penIndex(event)
if (pipUi || pen < 0) return false
if (pipUi) return false
if (pen < 0) return onBottomGameMouse(event)
return when (routePen(event, pen)) {
PenRouter.Route.TOUCH -> false
PenRouter.Route.PEN -> {
@@ -6846,8 +6845,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
}
private fun onBottomGameMouse(event: MotionEvent): Boolean {
if (PenStream.penIndex(event) >= 0 || !com.droiddeck.launcher.input.PointerCapture.isMouse(event)) return false
notePress(event)
onMouse(event)
return true
}
private fun onBottomGameTouch(event: MotionEvent): Boolean {
if (pipUi) return true
if (onBottomGameMouse(event)) return true
if (!event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN) && PenStream.penIndex(event) < 0) return false
notePress(event)
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
@@ -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;
}
@@ -10,6 +10,9 @@ object PointerCapture {
fun isTouchpad(event: MotionEvent): Boolean = event.isFromSource(InputDevice.SOURCE_TOUCHPAD)
fun isMouse(event: MotionEvent): Boolean =
event.isFromSource(InputDevice.SOURCE_MOUSE) || event.isFromSource(InputDevice.SOURCE_TOUCHPAD)
fun delta(event: MotionEvent): FloatArray {
var dx = event.x
var dy = event.y
@@ -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()
@@ -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.view.Display
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.PointerIcon
import android.view.SurfaceHolder
import android.view.SurfaceView
import android.view.View
@@ -44,6 +45,7 @@ class BottomGameScreen(
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
surfaceView.pointerIcon = PointerIcon.getSystemIcon(context, PointerIcon.TYPE_NULL)
surfaceView.setOnTouchListener { _, event -> onTouch(event) }
surfaceView.holder.addCallback(callback)
}
@@ -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])
@@ -54,6 +54,37 @@ class PointerCaptureTest {
}
}
@Test fun aHoveringMouseOrTouchpadDrivesThePointer() {
listOf(
event(MotionEvent.ACTION_HOVER_MOVE, InputDevice.SOURCE_MOUSE, x = 640f, y = 360f),
event(MotionEvent.ACTION_BUTTON_PRESS, InputDevice.SOURCE_MOUSE, x = 640f, y = 360f),
event(MotionEvent.ACTION_SCROLL, InputDevice.SOURCE_MOUSE, x = 640f, y = 360f),
event(MotionEvent.ACTION_HOVER_MOVE, InputDevice.SOURCE_TOUCHPAD, x = 640f, y = 360f),
).forEach { event ->
try {
assertTrue(PointerCapture.isMouse(event))
} finally {
event.recycle()
}
}
}
@Test fun touchesPensControllersAndCapturedMiceAreNotAHoveringMouse() {
listOf(
InputDevice.SOURCE_TOUCHSCREEN,
InputDevice.SOURCE_STYLUS,
InputDevice.SOURCE_JOYSTICK,
InputDevice.SOURCE_MOUSE_RELATIVE,
).forEach { source ->
val event = event(MotionEvent.ACTION_MOVE, source, x = 640f, y = 360f)
try {
assertFalse(PointerCapture.isMouse(event))
} finally {
event.recycle()
}
}
}
@Test fun touchpadTravelMatchesTheSameDistanceOnScreen() {
assertEquals(0.5f, PointerCapture.touchpadScale(unitsPerMm = 20f, padWidth = 2000f, pixelsPerMm = 10f, screenWidth = 1920), 0.001f)
}
@@ -157,10 +157,42 @@ class SessionPenRoutingTest {
SessionPrefs.setPenSetting(activity, "pen", SessionPrefs.PEN_TOUCH)
invoke("readPrefs")
assertFalse(hover(event(MotionEvent.ACTION_HOVER_MOVE, 30, pen to 500f)))
assertFalse(hover(event(MotionEvent.ACTION_HOVER_MOVE, 40, finger to 500f, source = InputDevice.SOURCE_MOUSE)))
assertTrue(hover(event(MotionEvent.ACTION_HOVER_MOVE, 40, finger to 500f, source = InputDevice.SOURCE_MOUSE)))
assertEquals(listOf(PEN_IN, PEN_IN or PEN_TIP, 0), CompositorShadow.pens.map { it.flags })
}
@Test fun aMouseOnTheOtherScreensGameMovesTheSessionPointer() {
fun hover(event: MotionEvent) = ReflectionHelpers.callInstanceMethod<Boolean>(activity, "onBottomGameHover",
ReflectionHelpers.ClassParameter.from(MotionEvent::class.java, event))
fun touch(event: MotionEvent) = ReflectionHelpers.callInstanceMethod<Boolean>(activity, "onBottomGameTouch",
ReflectionHelpers.ClassParameter.from(MotionEvent::class.java, event))
val mouse = MotionEvent.TOOL_TYPE_MOUSE
assertTrue(hover(event(MotionEvent.ACTION_HOVER_MOVE, 10, mouse to 250f, source = InputDevice.SOURCE_MOUSE)))
assertTrue(hover(event(MotionEvent.ACTION_BUTTON_PRESS, 20, mouse to 250f, source = InputDevice.SOURCE_MOUSE,
buttons = MotionEvent.BUTTON_PRIMARY)))
assertTrue(touch(event(MotionEvent.ACTION_DOWN, 20, mouse to 250f, source = InputDevice.SOURCE_MOUSE,
buttons = MotionEvent.BUTTON_PRIMARY)))
assertTrue(touch(event(MotionEvent.ACTION_MOVE, 30, mouse to 750f, source = InputDevice.SOURCE_MOUSE,
buttons = MotionEvent.BUTTON_PRIMARY)))
assertTrue(touch(event(MotionEvent.ACTION_UP, 40, mouse to 750f, source = InputDevice.SOURCE_MOUSE)))
assertTrue(hover(event(MotionEvent.ACTION_HOVER_MOVE, 50, finger to 600f, source = InputDevice.SOURCE_TOUCHPAD)))
assertEquals(
listOf(InputSpace.x(250f, 1000), InputSpace.x(250f, 1000), InputSpace.x(750f, 1000), InputSpace.x(600f, 1000)),
CompositorShadow.pointers.map { it.second },
)
assertTrue(CompositorShadow.pointers.all { it.first == 1 && it.third == InputSpace.y(300f, 600) })
assertTrue(CompositorShadow.pens.isEmpty())
assertTrue(CompositorShadow.touches.isEmpty())
}
@Test fun aControllerOnTheOtherScreensGameIsNotTakenAsAMouse() {
fun hover(event: MotionEvent) = ReflectionHelpers.callInstanceMethod<Boolean>(activity, "onBottomGameHover",
ReflectionHelpers.ClassParameter.from(MotionEvent::class.java, event))
assertFalse(hover(event(MotionEvent.ACTION_MOVE, 10, finger to 500f, source = InputDevice.SOURCE_JOYSTICK)))
assertTrue(CompositorShadow.pointers.isEmpty())
assertTrue(CompositorShadow.pens.isEmpty())
}
@Test fun glassesAProgramPointerLockAndAppUiDropPenHover() {
state<Boolean>("glassesOutputActive").value = true
activity.dispatchGenericMotionEvent(event(MotionEvent.ACTION_HOVER_MOVE, 10, pen to 500f))
@@ -224,23 +224,15 @@ if [ -n "${DD_VK_DRIVER:-}" ]; then
unset dd_icd_lib
fi
dd_webhelper_layout() {
local layout
if [ -n "${DD_VKBRIDGE_WEBHELPER_ARGS:-}" ]; then
printf '%s\n' "$DD_VKBRIDGE_WEBHELPER_ARGS"
return
fi
if [ -z "${DD_VKBRIDGE_CEF_ANGLE:-}" ]; then
elif [ -z "${DD_VKBRIDGE_CEF_ANGLE:-}" ]; then
echo stock
return
fi
# ANGLE switches must not replace the helper's stable single-process layout.
layout="--no-zygote --in-process-gpu -AudioServiceOutOfProcess"
if [ "$DD_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${DD_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then
layout="$layout --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan"
elif [ "$DD_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${DD_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then
echo "--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan"
else
layout="$layout --use-gl=angle --use-angle=$DD_VKBRIDGE_CEF_ANGLE"
echo "--use-gl=angle --use-angle=$DD_VKBRIDGE_CEF_ANGLE"
fi
printf '%s\n' "$layout"
}
dd_now_ms() {
if [ -n "${EPOCHREALTIME:-}" ]; then
+8 -9
View File
@@ -6,7 +6,6 @@ from pathlib import Path
SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session"
KEYS = ("DD_VKBRIDGE_WEBHELPER_ARGS", "DD_VKBRIDGE_CEF_ANGLE", "DD_VKBRIDGE_CEF_VULKAN")
BASE = "--no-zygote --in-process-gpu -AudioServiceOutOfProcess"
def layout_function():
@@ -28,14 +27,14 @@ class WebhelperLayoutTest(unittest.TestCase):
def test_angle_on_vulkan_brings_chromiums_vulkan_compositing(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan"),
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
def test_vulkan_compositing_can_be_left_off_without_zygotes(self):
def test_vulkan_compositing_can_be_left_off(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan", DD_VKBRIDGE_CEF_VULKAN="0"),
BASE + " --use-gl=angle --use-angle=vulkan")
"--use-gl=angle --use-angle=vulkan")
def test_other_angle_backends_get_only_the_angle_switches(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="gl"), BASE + " --use-gl=angle --use-angle=gl")
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="gl"), "--use-gl=angle --use-angle=gl")
def test_explicit_layout_wins(self):
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan", DD_VKBRIDGE_WEBHELPER_ARGS="--x +Y"),
@@ -58,10 +57,10 @@ class WebhelperLayoutTest(unittest.TestCase):
env = {k: v for k, v in os.environ.items() if k not in KEYS}
run = lambda **s: subprocess.run(["bash", "-c", "set -u\n" + script], env={**env, **s},
capture_output=True, text=True, check=True).stdout.strip()
self.assertEqual(run(), BASE + " --use-gl=angle --use-angle=vulkan")
self.assertEqual(run(), "--use-gl=angle --use-angle=vulkan")
self.assertEqual(run(DD_VKBRIDGE_CEF_VULKAN="1"),
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE="gl"), BASE + " --use-gl=angle --use-angle=gl")
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE="gl"), "--use-gl=angle --use-angle=gl")
def test_empty_settings_are_kept_as_set(self):
script = ': "${DD_VKBRIDGE_CEF_ANGLE=vulkan}" "${DD_VKBRIDGE_CEF_VULKAN=0}"\n' + layout_function() + "dd_webhelper_layout\n"
@@ -70,7 +69,7 @@ class WebhelperLayoutTest(unittest.TestCase):
capture_output=True, text=True, check=True).stdout.strip()
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE=""), "stock")
self.assertEqual(run(DD_VKBRIDGE_CEF_VULKAN=""),
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
if __name__ == "__main__":