mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
Merge branch 'main' into fix/steam-library-capsules
This commit is contained in:
commit
bf70ca8f25
7 files changed
+347
-21
No files matched your search
@@ -255,7 +255,20 @@ object Library {
|
||||
"armsx2" -> listOf("-batch", "-bigpicture", "-fullscreen", "--", guestPath)
|
||||
// DuckStation shares PCSX2's flags (src/duckstation-qt/qthost.cpp): the same launch and exit.
|
||||
"duckstation" -> listOf("-batch", "-bigpicture", "-fullscreen", "--", guestPath)
|
||||
"dolphin" -> listOf("-e", guestPath)
|
||||
// Dolphin: full screen, drawn inside its own main window, without its "stop the emulation?"
|
||||
// question; no warning boxes either, which wait for a click a controller cannot give
|
||||
// (they still go to Dolphin's log). The guide button is Dolphin's Toggle Fullscreen hotkey
|
||||
// (bannerlator-pad-defaults), which shows Dolphin's window and its settings - so no -b, which
|
||||
// hides that window; closing Dolphin ends the session. Under gamescope Dolphin does not
|
||||
// always see its window as focused, and by default both its hotkeys and the game's
|
||||
// controller then stop: HotkeysRequireFocus off, BackgroundInput on. -C sets a Dolphin.ini
|
||||
// value for this run only, so Dolphin started from the desktop keeps its own settings.
|
||||
"dolphin" -> listOf(
|
||||
"-C", "Dolphin.Display.Fullscreen=True", "-C", "Dolphin.Display.RenderToMain=True",
|
||||
"-C", "Dolphin.Interface.ConfirmStop=False", "-C", "Dolphin.Interface.UsePanicHandlers=False",
|
||||
"-C", "Dolphin.General.HotkeysRequireFocus=False", "-C", "Dolphin.Input.BackgroundInput=True",
|
||||
"-e", guestPath,
|
||||
)
|
||||
"cemu" -> listOf("-g", guestPath)
|
||||
else -> listOf(guestPath)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ import kotlin.math.abs
|
||||
* - two fingers up / down ............ scroll wheel
|
||||
* - hold still, then drag ............ left-button drag
|
||||
* - double-tap, hold, drag ........... left-button drag as well
|
||||
* - one finger held, another slides .. left-button drag, as on a laptop's pad: the held finger is
|
||||
* the button, the other moves the pointer (a window by its
|
||||
* title bar or edge, a desktop icon). The sliding finger may
|
||||
* lift and slide again; lifting the held one drops.
|
||||
*
|
||||
* Positions handed to the listener are the pointer's, in the view's pixels; the caller keeps them
|
||||
* inside the picture.
|
||||
@@ -45,6 +49,16 @@ class TouchpadGestures(
|
||||
private var twoFingers = false
|
||||
private var scrollAnchorY = 0f
|
||||
private var scrolled = false
|
||||
// Hold-and-slide: the first finger stays as the button, the second moves the pointer.
|
||||
private var anchorId = -1
|
||||
private var anchorStartX = 0f
|
||||
private var anchorStartY = 0f
|
||||
private var moverId = -1
|
||||
private var moverStartX = 0f
|
||||
private var moverStartY = 0f
|
||||
private var moverLastX = 0f
|
||||
private var moverLastY = 0f
|
||||
private var holdDrag = false
|
||||
private val longPress = Runnable {
|
||||
held = true
|
||||
dragging = true
|
||||
@@ -63,6 +77,7 @@ class TouchpadGestures(
|
||||
lastX = event.x; lastY = event.y
|
||||
downAt = event.eventTime
|
||||
travelled = 0f; held = false; twoFingers = false; scrolled = false; secondWasTap = false
|
||||
anchorId = event.getPointerId(0); moverId = -1; holdDrag = false
|
||||
// A tap shortly before this touch: holding now drags (double-tap-and-hold).
|
||||
if (event.eventTime - lastTapAt < DOUBLE_TAP_MS) {
|
||||
dragging = true
|
||||
@@ -75,6 +90,17 @@ class TouchpadGestures(
|
||||
}
|
||||
MotionEvent.ACTION_POINTER_DOWN -> {
|
||||
handler.removeCallbacks(longPress)
|
||||
val i = event.actionIndex
|
||||
if (moverId == -1 && event.getPointerId(i) != anchorId) {
|
||||
moverId = event.getPointerId(i)
|
||||
moverStartX = event.getX(i); moverStartY = event.getY(i)
|
||||
moverLastX = moverStartX; moverLastY = moverStartY
|
||||
event.findPointerIndex(anchorId).takeIf { it >= 0 }?.let {
|
||||
anchorStartX = event.getX(it); anchorStartY = event.getY(it)
|
||||
}
|
||||
}
|
||||
// Mid-drag, a finger coming back only picks the sliding up again.
|
||||
if (holdDrag) return true
|
||||
twoFingers = true
|
||||
secondDownAt = event.eventTime
|
||||
secondWasTap = true
|
||||
@@ -82,6 +108,38 @@ class TouchpadGestures(
|
||||
return true
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
val ai = event.findPointerIndex(anchorId)
|
||||
val mi = if (moverId == -1) -1 else event.findPointerIndex(moverId)
|
||||
if (ai >= 0 && mi >= 0) {
|
||||
val mx = event.getX(mi); val my = event.getY(mi)
|
||||
// One finger still, the other on the move: that is a drag, not a scroll (which
|
||||
// moves both). Decided once, before anything has scrolled.
|
||||
if (!holdDrag && !scrolled) {
|
||||
val anchorMoved = abs(event.getX(ai) - anchorStartX) + abs(event.getY(ai) - anchorStartY)
|
||||
val moverMoved = abs(mx - moverStartX) + abs(my - moverStartY)
|
||||
if (moverMoved > slopPx && anchorMoved < slopPx) {
|
||||
holdDrag = true
|
||||
secondWasTap = false
|
||||
if (!dragging) {
|
||||
dragging = true
|
||||
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (holdDrag) {
|
||||
val dx = mx - moverLastX
|
||||
val dy = my - moverLastY
|
||||
moverLastX = mx; moverLastY = my
|
||||
val speed = abs(dx) + abs(dy)
|
||||
val gain = sensitivity * (1f + minOf(speed / 40f, 1.5f))
|
||||
place(x + dx * gain, y + dy * gain)
|
||||
listener.onMove(x, y)
|
||||
return true
|
||||
}
|
||||
} else if (holdDrag) {
|
||||
// Only the held finger is down: the drag waits for the next slide.
|
||||
return true
|
||||
}
|
||||
if (twoFingers && event.pointerCount >= 2) {
|
||||
val mid = (event.getY(0) + event.getY(1)) / 2f
|
||||
val dy = mid - scrollAnchorY
|
||||
@@ -109,6 +167,30 @@ class TouchpadGestures(
|
||||
return true
|
||||
}
|
||||
MotionEvent.ACTION_POINTER_UP -> {
|
||||
val gone = event.getPointerId(event.actionIndex)
|
||||
if (holdDrag) {
|
||||
if (gone == anchorId) {
|
||||
// The held finger lifted: drop. The other finger carries on as the pointer.
|
||||
listener.onButton(PointerGestures.BTN_LEFT, false, x, y)
|
||||
dragging = false; holdDrag = false; twoFingers = false
|
||||
anchorId = moverId; moverId = -1
|
||||
event.findPointerIndex(anchorId).takeIf { it >= 0 }?.let {
|
||||
lastX = event.getX(it); lastY = event.getY(it)
|
||||
}
|
||||
travelled = slopPx + 1f
|
||||
} else if (gone == moverId) {
|
||||
moverId = -1
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (gone == moverId) moverId = -1
|
||||
if (gone == anchorId) {
|
||||
// The first finger left a two-finger gesture: the other one is the pointer now.
|
||||
anchorId = event.getPointerId(if (event.actionIndex == 0) 1 else 0)
|
||||
event.findPointerIndex(anchorId).takeIf { it >= 0 }?.let {
|
||||
lastX = event.getX(it); lastY = event.getY(it)
|
||||
}
|
||||
}
|
||||
// The second finger lifting quickly, with nothing scrolled: a right click.
|
||||
if (twoFingers && secondWasTap && event.eventTime - secondDownAt < TAP_MS && !scrolled) {
|
||||
listener.onButton(PointerGestures.BTN_RIGHT, true, x, y)
|
||||
@@ -136,6 +218,7 @@ class TouchpadGestures(
|
||||
}
|
||||
}
|
||||
dragging = false; held = false; twoFingers = false
|
||||
holdDrag = false; anchorId = -1; moverId = -1
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,8 @@ class SessionService : Service() {
|
||||
}
|
||||
// Another Steam client on the device signs ours out seconds after every login; the one that
|
||||
// does it here runs from boot without being opened. Only the Steam session signs in.
|
||||
if (SessionState.mode == MODE_STEAM) RivalClients.stopBeforeSession(this)
|
||||
// The desktop too: its Steam launchers run the client right there (bannerlator-steam-launch).
|
||||
if (SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP) RivalClients.stopBeforeSession(this)
|
||||
SessionState.firstFrameSeen = false
|
||||
SessionState.guestPid = -1
|
||||
SessionEvents.transition(SessionPhase.STARTING_GUEST, "service.started", mapOf("mode" to SessionState.mode))
|
||||
@@ -318,7 +319,10 @@ class SessionService : Service() {
|
||||
if (SessionPrefs.glThread(this)) guest.add("mesa_glthread=true")
|
||||
if (SessionPrefs.noGlError(this)) guest.add("MESA_NO_ERROR=1")
|
||||
if (SessionState.mode == MODE_STEAM) guest.add("BL_STEAMDECK=" + (if (SessionPrefs.steamDeckMode(this)) "1" else "0"))
|
||||
if (SessionState.mode == MODE_STEAM) guest.add("BL_STEAM_CHANNEL=" + SessionPrefs.steamChannel(this))
|
||||
// The desktop's Steam launchers start the client there (bannerlator-steam-launch), through the
|
||||
// same set-up as a Steam session: it gets what the client and its games are started with.
|
||||
val steamHere = SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP
|
||||
if (steamHere) guest.add("BL_STEAM_CHANNEL=" + SessionPrefs.steamChannel(this))
|
||||
if (SessionState.mode == MODE_STEAM) {
|
||||
guest.add("BL_GAMESCOPE_FORCE_FULLSCREEN=" + (if (SessionPrefs.forceFullscreen(this)) "1" else "0"))
|
||||
SessionPrefs.writeForceFullscreenFlag(this)
|
||||
@@ -330,7 +334,7 @@ class SessionService : Service() {
|
||||
// The FEXCore preset for the x86 games the client launches: its FEX_* variables go in
|
||||
// here, before the script, so every game process inherits them from the client. The
|
||||
// default preset sets nothing, which is what every session ran on before.
|
||||
if (SessionState.mode == MODE_STEAM) {
|
||||
if (steamHere) {
|
||||
val preset = SessionPrefs.fexPreset(this)
|
||||
val vars = com.droiddeck.launcher.core.FexPreset.env(preset)
|
||||
vars.forEach { guest.add(it) }
|
||||
@@ -345,7 +349,7 @@ class SessionService : Service() {
|
||||
// on, even naming every core: it exists to undo the pin Steam applies to its own interface
|
||||
// renderer, and the scheduler's default is exactly what that pin takes away. A game's is
|
||||
// sent only when it is a real restriction - a game has no pin of its own to undo.
|
||||
if (SessionState.mode == MODE_STEAM && SessionPrefs.clientCpusOverride(this)) {
|
||||
if (steamHere && SessionPrefs.clientCpusOverride(this)) {
|
||||
guest.add("BL_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
|
||||
}
|
||||
// The game cores also pin the desktop and a program from the rail; without a choice the
|
||||
@@ -447,7 +451,7 @@ class SessionService : Service() {
|
||||
}
|
||||
// The user's own games, for the runtime's shortcuts writer to put in the client's library
|
||||
// before the client starts (see frontend/AddedGames and bannerlator-steam-shortcuts).
|
||||
if (SessionState.mode == MODE_STEAM) {
|
||||
if (steamHere) {
|
||||
val added = com.droiddeck.launcher.frontend.AddedGames.scan(this)
|
||||
val listing = com.droiddeck.launcher.frontend.AddedGames.writeListing(this, added)
|
||||
guest.add("BL_ADDED_GAMES=" + listing.path)
|
||||
@@ -582,7 +586,7 @@ class SessionService : Service() {
|
||||
|
||||
// Whether the client signs in to Valve or starts offline: read once, while it starts, and
|
||||
// rewritten by the client when it exits, so it is set again here at every session start.
|
||||
if (SessionState.mode == MODE_STEAM) OfflineMode.apply(this, root)
|
||||
if (SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP) OfflineMode.apply(this, root)
|
||||
|
||||
val networkLink = LinuxNetworkLinkComponent(this, root)
|
||||
networkLink.attach(this)
|
||||
|
||||
Reference in new issue
Block a user