mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
Keep Android shortcut touch and system Back on separate displays
This commit is contained in:
1 parent
a051cd5fa6
commit
e72b41e2e4
10 files changed
+105
-7
No files matched your search
@@ -34,8 +34,26 @@ jobs:
|
||||
retention-days: 7
|
||||
compression-level: 0
|
||||
path: out/debs/
|
||||
scrcpy-server:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
- run: |
|
||||
sdkmanager 'platforms;android-36' 'build-tools;35.0.0'
|
||||
tools/ubuntu/build-scrcpy-server.sh out/scrcpy-server.jar
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: droiddeck-scrcpy-server
|
||||
path: out/scrcpy-server.jar
|
||||
rootfs:
|
||||
needs: debs
|
||||
needs: [debs, scrcpy-server]
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 120
|
||||
steps:
|
||||
@@ -46,6 +64,10 @@ jobs:
|
||||
with:
|
||||
name: ubuntu-runtime-debs
|
||||
path: out/debs
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: droiddeck-scrcpy-server
|
||||
path: out/server
|
||||
- uses: actions/create-github-app-token@v2
|
||||
id: components-token
|
||||
if: github.event_name == 'workflow_dispatch' && inputs.tag != ''
|
||||
@@ -68,7 +90,7 @@ jobs:
|
||||
set -euo pipefail
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq zstd gpgv ubuntu-keyring >/dev/null
|
||||
tag='${{ inputs.tag }}'
|
||||
tools/ubuntu/build.sh out/debs out "${tag:-ubuntu-dev}"
|
||||
tools/ubuntu/build.sh out/debs out "${tag:-ubuntu-dev}" out/server/scrcpy-server.jar
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ubuntu-runtime
|
||||
|
||||
@@ -877,6 +877,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var runtimeRemovalBlocked = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(R.style.SessionTheme)
|
||||
super.onCreate(savedInstanceState)
|
||||
com.droiddeck.launcher.session.xr.XrPanels.setMenuHost(this)
|
||||
AgentGuest.readyListener = agentReadyListener
|
||||
|
||||
@@ -32,6 +32,7 @@ internal object AndroidSteamApps {
|
||||
if (Build.VERSION.SDK_INT < MIN_ANDROID) return emptyList()
|
||||
val packages = prefs(context).all.keys.sorted()
|
||||
val apps = JSONArray()
|
||||
val appIds = mutableListOf<Long>()
|
||||
for (pkg in packages) {
|
||||
if (!supports(pkg)) continue
|
||||
val pm = context.packageManager
|
||||
@@ -41,12 +42,14 @@ internal object AndroidSteamApps {
|
||||
pm.getActivityInfo(component, 0).loadLabel(pm).toString()
|
||||
}.getOrDefault(pkg).ifBlank { pkg }
|
||||
val id = CRC32().apply { update("droiddeck-android-app:$pkg".toByteArray()) }.value or 0x80000000L
|
||||
appIds.add(id)
|
||||
apps.put(JSONObject().put("name", label).put("appid", id)
|
||||
.put("exe", LAUNCHER).put("dir", "/usr/local/bin").put("launch", pkg).put("native", true))
|
||||
}
|
||||
if (apps.length() == 0) return emptyList()
|
||||
val listing = File(sessionDir, "android-apps.json").apply { writeText(apps.toString()) }
|
||||
val env = mutableListOf("DD_ANDROID_APPS=${listing.absolutePath}")
|
||||
val env = mutableListOf("DD_ANDROID_APPS=${listing.absolutePath}",
|
||||
"DD_ANDROID_APP_IDS=${appIds.joinToString(" ")}")
|
||||
if (WirelessAdbFix.hasSavedPairing(context)) {
|
||||
val link = AgentAdb.prepare(context)
|
||||
if (link.paired) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Android apps in Steam
|
||||
|
||||
On Android 15 or newer, set DroidDeck as your Android Home app. In DroidDeck's **Apps** tab, open an app's menu and select **Add to Steam**. Pair Wireless debugging in DroidDeck's **Settings → Diagnostics** and keep Wireless debugging enabled. Restart Steam from DroidDeck. The app appears as a non-Steam shortcut in your library. To remove it, select **Remove from Steam** in the same app menu and restart Steam.
|
||||
On Android 15 or newer, open DroidDeck’s **Apps** tab. If it’s hidden, show it using **Arrange tabs**. Then open an app’s menu and select **Add to Steam**. Pair Wireless debugging in DroidDeck's **Settings → Diagnostics** and keep Wireless debugging enabled. Restart Steam from DroidDeck. The app appears as a non-Steam shortcut in your library. To remove it, select **Remove from Steam** in the same app menu and restart Steam.
|
||||
|
||||
The app runs on a separate Android display. Steam shows that display and forwards touch and gamepad input. Apps with controller support see an Xbox 360 pad. The app plays sound through Android, so use the handheld's media volume.
|
||||
The app runs on a separate Android display. Steam shows that display and forwards touch gestures and gamepad input. Android’s system Back stays with the handheld display, so it can open DroidDeck’s menu. Apps with controller support see an Xbox 360 pad. The app plays sound through Android, so use the handheld's media volume.
|
||||
|
||||
- Use the DroidDeck menu button for session controls and **Exit Game** in Steam to close the shortcut.
|
||||
- To go back inside the Android app with a keyboard, press **Alt+B**. DroidDeck's Back and the session menu are separate controls.
|
||||
|
||||
@@ -13,7 +13,8 @@ case "${1:-}" in
|
||||
''|*[!a-zA-Z0-9_.]*) fail "This shortcut has no valid Android app." ;;
|
||||
esac
|
||||
package=$1
|
||||
command -v scrcpy >/dev/null && command -v adb >/dev/null ||
|
||||
export SCRCPY_SERVER_PATH=/usr/share/droiddeck/scrcpy-server.jar
|
||||
command -v scrcpy >/dev/null && command -v adb >/dev/null && [ -r "$SCRCPY_SERVER_PATH" ] ||
|
||||
fail "Update the DroidDeck Linux runtime to launch Android apps."
|
||||
|
||||
serial=${DD_ANDROID_ADB_SERIAL:-}
|
||||
@@ -43,6 +44,6 @@ connected || connected ||
|
||||
export SDL_VIDEODRIVER=x11
|
||||
# Android plays audio on the handheld. Capturing it here would feed it back into Android again.
|
||||
scrcpy --serial "$serial" --new-display=1280x720/240 --start-app="$package" \
|
||||
--window-title="Android app" --no-vd-system-decorations --no-clipboard-autosync \
|
||||
--window-title="Android app" --no-vd-system-decorations --no-clipboard-autosync --no-mouse-hover \
|
||||
--mouse-bind=----:---- --gamepad=uhid --no-audio --max-fps=60 9>&- ||
|
||||
fail "The Android app window closed unexpectedly. Try launching it again."
|
||||
@@ -1359,6 +1359,12 @@ case $mode in
|
||||
&& echo "== scaling: applied the client's saved scaling filter $filter"
|
||||
return 0
|
||||
}
|
||||
android_touch_mode() {
|
||||
[ -n "$app" ] || return 0
|
||||
case " ${DD_ANDROID_APP_IDS:-} " in
|
||||
*" $app "*) xprop -root -f STEAM_TOUCH_CLICK_MODE 32c -set STEAM_TOUCH_CLICK_MODE 4 ;;
|
||||
esac
|
||||
}
|
||||
tmode= app= prev=
|
||||
while read -r line; do
|
||||
case $line in
|
||||
@@ -1367,12 +1373,14 @@ case $mode in
|
||||
[ "$pv" = "$tmode" ] && continue
|
||||
tmode=$pv
|
||||
echo "== touch mode: $tmode (focused app ${app:-?}) at $(date +%T)"
|
||||
[ "$tmode" = 4 ] || android_touch_mode
|
||||
;;
|
||||
GAMESCOPE_FOCUSED_APP*)
|
||||
prop_value "$line" none
|
||||
if [ "$pv" != "$app" ]; then
|
||||
app=$pv
|
||||
echo "== focused app: $app (touch mode ${tmode:-unset}) at $(date +%T)"
|
||||
[ "$tmode" = 4 ] || android_touch_mode
|
||||
if [ -n "${DD_LAUNCH_DIR:-}" ]; then
|
||||
printf '%s\n' "$app" > "$DD_LAUNCH_DIR/steam-focused-app.tmp" && mv -f "$DD_LAUNCH_DIR/steam-focused-app.tmp" "$DD_LAUNCH_DIR/steam-focused-app"
|
||||
fi
|
||||
|
||||
@@ -50,3 +50,5 @@ At run time:
|
||||
`.github/workflows/build-ubuntu-runtime.yml` builds it and, run with a new tag (`ubuntu-rN`),
|
||||
publishes the runtime and its desktop pack in Droid-Deck/DroidDeck-Components; `linuxfs-ubuntu.json` there names the release the
|
||||
app installs.
|
||||
|
||||
Build the scrcpy server with `tools/ubuntu/build-scrcpy-server.sh out/scrcpy-server.jar`. It requires JDK 17, Android platform 36 and build-tools 35.0.0. Pass the resulting jar as the fourth argument to `tools/ubuntu/build.sh` when building a runtime locally.
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
sdk=${ANDROID_HOME:?Android SDK required}
|
||||
out=$(realpath -m "${1:?output server jar}")
|
||||
tools=$sdk/build-tools/35.0.0
|
||||
platform=$sdk/platforms/android-36
|
||||
version=3.3.4
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
curl -fsSL --retry 3 --proto '=https' -o "$work/source.tar.gz" \
|
||||
"https://codeload.github.com/Genymobile/scrcpy/tar.gz/refs/tags/v$version"
|
||||
echo "03b72d1f71ca7783cff2995ca7cd8c67b9b75038a3cc35e443a1913e951b49dd $work/source.tar.gz" | sha256sum -c -
|
||||
tar xzf "$work/source.tar.gz" -C "$work" --strip-components=1
|
||||
git -C "$work" apply "$here/patches/scrcpy-display-focus.patch"
|
||||
src=$work/server/src/main
|
||||
mkdir -p "$work/generated/com/genymobile/scrcpy" "$work/classes" "$(dirname "$out")"
|
||||
for file in "$src"/aidl/android/*/*.aidl; do
|
||||
"${DROIDDECK_AIDL:-$tools/aidl}" -I"$src/aidl" -p"$platform/framework.aidl" -o"$work/generated" "$file"
|
||||
done
|
||||
cat > "$work/generated/com/genymobile/scrcpy/BuildConfig.java" <<JAVA
|
||||
package com.genymobile.scrcpy;
|
||||
public final class BuildConfig {
|
||||
public static final boolean DEBUG = false;
|
||||
public static final String VERSION_NAME = "$version";
|
||||
}
|
||||
JAVA
|
||||
find "$src/java" "$work/generated" -name '*.java' > "$work/sources"
|
||||
javac --release 8 -classpath "$platform/android.jar" -d "$work/classes" @"$work/sources"
|
||||
jar cf "$work/server.jar" -C "$work/classes" .
|
||||
java -cp "$tools/lib/d8.jar" com.android.tools.r8.D8 --release --min-api 21 \
|
||||
--lib "$platform/android.jar" --output "$out" "$work/server.jar"
|
||||
@@ -4,6 +4,7 @@ here=$(cd "$(dirname "$0")" && pwd)
|
||||
debs=$(realpath "${1:?directory with the DroidDeck-built .deb files}")
|
||||
out=$(realpath -m "${2:?out dir}")
|
||||
runtime_id=${3:?runtime id, e.g. ubuntu-r1}
|
||||
scrcpy_server=$(realpath "${4:?patched scrcpy server jar}")
|
||||
[ "$(uname -m)" = aarch64 ] || { echo 'the Ubuntu runtime needs a native arm64 runner' >&2; exit 1; }
|
||||
source "$here/base.env"
|
||||
fetch() { curl -fsSL --proto '=https' --proto-redir '=https' --retry 6 --retry-delay 5 --retry-all-errors -o "$1" "$2"; }
|
||||
@@ -47,6 +48,11 @@ unseal() {
|
||||
}
|
||||
|
||||
stage runtime
|
||||
case $(sudo chroot "$root" dpkg-query -W -f='${Version}' scrcpy) in
|
||||
3.3.4-*) ;;
|
||||
*) echo "The scrcpy client must match the patched 3.3.4 server" >&2; exit 1 ;;
|
||||
esac
|
||||
sudo install -D -m 644 "$scrcpy_server" "$root/usr/share/droiddeck/scrcpy-server.jar"
|
||||
seal
|
||||
sudo mv "$root/tmp/droiddeck" "$work/src-keep"
|
||||
sudo chroot "$root" dpkg-query -W -f '${Package} ${Version}\n' > "$out/$runtime_id.packages.txt"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java
|
||||
+++ b/server/src/main/java/com/genymobile/scrcpy/video/NewDisplayCapture.java
|
||||
@@ -38,6 +38,8 @@
|
||||
private static final int VIRTUAL_DISPLAY_FLAG_OWN_FOCUS = 1 << 14;
|
||||
private static final int VIRTUAL_DISPLAY_FLAG_DEVICE_DISPLAY_GROUP = 1 << 15;
|
||||
|
||||
+ private static final int VIRTUAL_DISPLAY_FLAG_STEAL_TOP_FOCUS_DISABLED = 1 << 16;
|
||||
+
|
||||
private final VirtualDisplayListener vdListener;
|
||||
private final NewDisplay newDisplay;
|
||||
|
||||
@@ -187,7 +189,8 @@
|
||||
| VIRTUAL_DISPLAY_FLAG_TOUCH_FEEDBACK_DISABLED;
|
||||
if (Build.VERSION.SDK_INT >= AndroidVersions.API_34_ANDROID_14) {
|
||||
flags |= VIRTUAL_DISPLAY_FLAG_OWN_FOCUS
|
||||
- | VIRTUAL_DISPLAY_FLAG_DEVICE_DISPLAY_GROUP;
|
||||
+ | VIRTUAL_DISPLAY_FLAG_DEVICE_DISPLAY_GROUP
|
||||
+ | VIRTUAL_DISPLAY_FLAG_STEAL_TOP_FOCUS_DISABLED;
|
||||
}
|
||||
}
|
||||
virtualDisplay = ServiceManager.getDisplayManager()
|
||||
Reference in new issue
Block a user