mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-03 19:45:39 +00:00
Compare commits
159
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25208ffc77 | ||
|
|
f29f72d5d9 | ||
|
|
367151be2c | ||
|
|
9925873764 | ||
|
|
33761c30ab | ||
|
|
089c18b49d | ||
|
|
cb8e70b940 | ||
|
|
3c0d25d83b | ||
|
|
6f45b5347d | ||
|
|
a3e8b44145 | ||
|
|
0f37154933 | ||
|
|
42133bec0b | ||
|
|
d7f43c26cd | ||
|
|
d5c83eae15 | ||
|
|
83dc5f37e9 | ||
|
|
d0022a35f9 | ||
|
|
acb2cba970 | ||
|
|
e58b463f54 | ||
|
|
f5d879f222 | ||
|
|
11fb8f59d4 | ||
|
|
97e0251e6a | ||
|
|
7c2955b058 | ||
|
|
ec1d5126c4 | ||
|
|
56986b5999 | ||
|
|
a29315f7e0 | ||
|
|
38efe4d6d5 | ||
|
|
3f5280412d | ||
|
|
37cf698af2 | ||
|
|
fccd13689c | ||
|
|
5051fc8b32 | ||
|
|
4e81030fb8 | ||
|
|
dc9d1b81cc | ||
|
|
45c31a480a | ||
|
|
00557703da | ||
|
|
fc9ad2447d | ||
|
|
d4af37937a | ||
|
|
df48a85a71 | ||
|
|
13a6e0606a | ||
|
|
cc93ab51c5 | ||
|
|
de73e429cc | ||
|
|
71989b4cdb | ||
|
|
8f34554516 | ||
|
|
1456c0529d | ||
|
|
786166ba1a | ||
|
|
674e0d6fa4 | ||
|
|
d852b1a4e5 | ||
|
|
2ea857a07c | ||
|
|
697f8e73fa | ||
|
|
c4f4e18f87 | ||
|
|
c2adf3b3dd | ||
|
|
f2d8e9e837 | ||
|
|
44ade5eeee | ||
|
|
dcebdac765 | ||
|
|
cd5e824c1b | ||
|
|
10b21321b7 | ||
|
|
885c4f0a44 | ||
|
|
968828afbd | ||
|
|
c664b6cfbf | ||
|
|
446480aa19 | ||
|
|
c35da09d1a | ||
|
|
afa696cef2 | ||
|
|
b87da99d21 | ||
|
|
f180d98da7 | ||
|
|
adf13d0bdd | ||
|
|
732c97831d | ||
|
|
bf75dfb9c0 | ||
|
|
952f363b45 | ||
|
|
fdcb7eb3c4 | ||
|
|
b29a5ef8aa | ||
|
|
0364792111 | ||
|
|
e67c185f13 | ||
|
|
318d64f3d6 | ||
|
|
6f564caba6 | ||
|
|
695ae21f93 | ||
|
|
ceb0360cd8 | ||
|
|
40665bbb1a | ||
|
|
123c431b8e | ||
|
|
0fba656ee2 | ||
|
|
6ed281f78d | ||
|
|
b43724e5f3 | ||
|
|
5b7409d1d5 | ||
|
|
f0f7f7a116 | ||
|
|
24f5fa20f8 | ||
|
|
e4404fbb92 | ||
|
|
a5d8abeab4 | ||
|
|
7680b4d771 | ||
|
|
5afa8695a8 | ||
|
|
8cfe19cd13 | ||
|
|
fc5dd7f3c5 | ||
|
|
cca84f7b6b | ||
|
|
d94906bd9c | ||
|
|
801da99c11 | ||
|
|
fd2f1eec8a | ||
|
|
19fa6fd8e2 | ||
|
|
a139d9eff4 | ||
|
|
2a274623da | ||
|
|
bb5218746f | ||
|
|
b74d005e7f | ||
|
|
75c19cae68 | ||
|
|
ca7b7e74ec | ||
|
|
0a8d6669bf | ||
|
|
9e05e4c00c | ||
|
|
0a167e41c2 | ||
|
|
1702f2d72d | ||
|
|
f1be935761 | ||
|
|
d89c2c1c2d | ||
|
|
ecd74fce79 | ||
|
|
bf0260de61 | ||
|
|
2f07e11ba0 | ||
|
|
bdc18bdd03 | ||
|
|
c336f994e1 | ||
|
|
c1cf0f3a9c | ||
|
|
384eb78215 | ||
|
|
5e704296ed | ||
|
|
52c76ead74 | ||
|
|
08eadf7af8 | ||
|
|
d40c962b37 | ||
|
|
8953eea9e0 | ||
|
|
8faaac3b89 | ||
|
|
c7cd2b55af | ||
|
|
c8b291b9db | ||
|
|
eabcfc7b74 | ||
|
|
ad9348879d | ||
|
|
0ce168b913 | ||
|
|
868207baf8 | ||
|
|
eb5aa7a536 | ||
|
|
cbde8b1f25 | ||
|
|
7ce8b37824 | ||
|
|
d7d0583c5a | ||
|
|
7909af74d6 | ||
|
|
28cf995d7b | ||
|
|
b2b2e38e67 | ||
|
|
fa95df37d0 | ||
|
|
b88b5f6b1d | ||
|
|
c31f19a9f0 | ||
|
|
812e492302 | ||
|
|
f84e9d5191 | ||
|
|
2ff890f0ec | ||
|
|
913cb85c92 | ||
|
|
7852098e63 | ||
|
|
0794f361ad | ||
|
|
8c8cae85cf | ||
|
|
8e49dfe190 | ||
|
|
1951bbc92a | ||
|
|
d7c03ba3ec | ||
|
|
cdb8fa6f53 | ||
|
|
663a7003bc | ||
|
|
2be0ba58c7 | ||
|
|
637f4b21ee | ||
|
|
51ec4a3029 | ||
|
|
b1a7d9b2d0 | ||
|
|
6fe7b4ec11 | ||
|
|
d13458937d | ||
|
|
fde3089900 | ||
|
|
8e514ada62 | ||
|
|
aba9811357 | ||
|
|
5fac78797f | ||
|
|
d116021ff3 | ||
|
|
25cbcf0c1f |
No files matched your search
@@ -1,5 +1,6 @@
|
||||
ASEbrahim
|
||||
FX192
|
||||
FryMcNugget
|
||||
K11MCH1
|
||||
KeegantheVeganat0r
|
||||
kingokksa
|
||||
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
validate:
|
||||
name: Validate source and build result
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
timeout-minutes: 70
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
||||
+24
-14
@@ -195,17 +195,17 @@ jobs:
|
||||
app/src/main/assets/linuxfs
|
||||
!app/src/main/assets/linuxfs/usr/local/lib/droiddeck-comet
|
||||
!app/src/main/assets/linuxfs/usr/local/lib/droiddeck-xbox
|
||||
!app/src/main/assets/linuxfs/i386/libblsession.so
|
||||
!app/src/main/assets/linuxfs/i386/libddsession.so
|
||||
!app/src/main/assets/linuxfs/i386/libfakeinput.so
|
||||
!app/src/main/assets/linuxfs/i386/libfaultreport.so
|
||||
!app/src/main/assets/linuxfs/libblaudit.so
|
||||
!app/src/main/assets/linuxfs/libblfastpath.so
|
||||
!app/src/main/assets/linuxfs/libddaudit.so
|
||||
!app/src/main/assets/linuxfs/libddfastpath.so
|
||||
!app/src/main/assets/linuxfs/libddnatv-hook.so
|
||||
!app/src/main/assets/linuxfs/libblsession.so
|
||||
!app/src/main/assets/linuxfs/libddsession.so
|
||||
!app/src/main/assets/linuxfs/libfakeinput.so
|
||||
!app/src/main/assets/linuxfs/libssbs.so
|
||||
!app/src/main/assets/linuxfs/usr/local/bin/droiddeck-clipboard
|
||||
!app/src/main/assets/linuxfs/x86_64/libblsession.so
|
||||
!app/src/main/assets/linuxfs/x86_64/libddsession.so
|
||||
!app/src/main/assets/linuxfs/x86_64/libfakeinput.so
|
||||
!app/src/main/assets/linuxfs/x86_64/libfaultreport.so
|
||||
!app/src/main/assets/linuxfs/x86_64/libvulkan-thunk.so
|
||||
@@ -291,7 +291,7 @@ jobs:
|
||||
- name: Build the non-Adreno test additions (Mali bridge client, Venus GL probe, Xclipse layer)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
bash tools/ci/install-ubuntu-packages.sh gcc-aarch64-linux-gnu libvulkan-dev
|
||||
bash tools/ci/install-ubuntu-packages.sh gcc-aarch64-linux-gnu libc6-dev-arm64-cross libvulkan-dev
|
||||
D=app/src/main/assets/linuxfs
|
||||
mkdir -p "$D/usr/local/bin" "$D/usr/local/lib/droiddeck-xclipse"
|
||||
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -Wextra -Wno-unused-parameter -fvisibility=hidden -pthread \
|
||||
@@ -577,6 +577,12 @@ jobs:
|
||||
command -v i686-w64-mingw32-gcc >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq gcc-mingw-w64-i686; }
|
||||
bash tools/rockstar-launcher/build.sh
|
||||
|
||||
- name: Epic Games Launcher parent stand-in (x86_64-pc-windows-gnu)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
command -v x86_64-w64-mingw32-gcc >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq gcc-mingw-w64-x86-64; }
|
||||
bash tools/epic-launcher/build.sh
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: xbox-arm64
|
||||
@@ -588,7 +594,7 @@ jobs:
|
||||
path: |
|
||||
~/.cache/droiddeck-pack-inputs
|
||||
~/.cache/droiddeck-build
|
||||
key: pack-inputs-v2-${{ hashFiles('tools/packs/build.sh', 'tools/packs/fetch-verified.sh', 'tools/packs/tracking/release.env', 'tools/powervr/release.json') }}
|
||||
key: pack-inputs-v2-${{ hashFiles('tools/packs/build.sh', 'tools/packs/fetch-verified.sh', 'tools/packs/tracking/release.env', 'tools/packs/zstd/release.env', 'tools/powervr/release.json') }}
|
||||
restore-keys: pack-inputs-v2-
|
||||
- name: Build the add-on packs
|
||||
run: |
|
||||
@@ -619,14 +625,18 @@ jobs:
|
||||
export NDK="$ANDROID_HOME/ndk/$NDK_VERSION"
|
||||
tools/syncthing/build.sh app/src/main/jniLibs/arm64-v8a
|
||||
|
||||
- name: Note when the proot pack pin is behind this build
|
||||
- name: Check the proot pack pin against this build
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# shellcheck disable=SC1091
|
||||
source tools/packs/proot/release.env
|
||||
sha=$(sha256sum app/build/packs/proot.tar.zst | cut -d' ' -f1)
|
||||
if [ "$sha" != "$PROOT_PACK_SHA256" ]; then
|
||||
echo "::warning::built proot pack $sha does not match tools/packs/proot/release.env ($PROOT_PACK_SHA256). This build publishes the pack it just built. Source builds keep downloading the pinned pack until release.env is updated."
|
||||
size=$(stat -c %s app/build/packs/proot.tar.zst)
|
||||
if [ "$sha" != "$PROOT_PACK_SHA256" ] || [ "$size" != "$PROOT_PACK_SIZE" ]; then
|
||||
level=warning
|
||||
if [ "$GITHUB_EVENT_NAME" = pull_request ]; then level=error; fi
|
||||
echo "::$level::built proot pack $sha ($size bytes) does not match tools/packs/proot/release.env ($PROOT_PACK_SHA256, $PROOT_PACK_SIZE bytes). Source builds download the pinned pack, so set PROOT_PACK_SHA256=$sha and PROOT_PACK_SIZE=$size in tools/packs/proot/release.env."
|
||||
if [ "$level" = error ]; then exit 1; fi
|
||||
fi
|
||||
|
||||
- name: Check out MaliBridge
|
||||
@@ -765,7 +775,6 @@ jobs:
|
||||
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 15
|
||||
continue-on-error: true
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
@@ -811,7 +820,6 @@ jobs:
|
||||
stores-host-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.rust.outputs.rustc }}-
|
||||
- name: Store engines host unit tests
|
||||
timeout-minutes: 10
|
||||
continue-on-error: true
|
||||
run: |
|
||||
set -o pipefail
|
||||
cd app/src/main/rust/stores
|
||||
@@ -821,6 +829,7 @@ jobs:
|
||||
run: |
|
||||
cargo test --locked --manifest-path tools/ubisoft-launcher/Cargo.toml
|
||||
cargo test --locked --manifest-path tools/rockstar-launcher/Cargo.toml
|
||||
cargo test --locked --manifest-path tools/epic-launcher/Cargo.toml
|
||||
|
||||
python-tests:
|
||||
name: Python and native regression tests
|
||||
@@ -900,7 +909,7 @@ jobs:
|
||||
|
||||
checks:
|
||||
name: Compile and test APK
|
||||
needs: [build, python-tests]
|
||||
needs: [build, python-tests, store-tests]
|
||||
if: ${{ !cancelled() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
@@ -909,7 +918,8 @@ jobs:
|
||||
env:
|
||||
BUILD_RESULT: ${{ needs.build.result }}
|
||||
PYTHON_RESULT: ${{ needs.python-tests.result }}
|
||||
run: test "$BUILD_RESULT" = success && test "$PYTHON_RESULT" = success
|
||||
STORE_RESULT: ${{ needs.store-tests.result }}
|
||||
run: test "$BUILD_RESULT" = success && test "$PYTHON_RESULT" = success && test "$STORE_RESULT" = success
|
||||
|
||||
sign:
|
||||
needs: [build, checks]
|
||||
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
jq -r --arg n "$2" '.assets // [] | .[] | select(.name == $n) | .digest // empty'
|
||||
}
|
||||
commit=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$BUILD_RUN" --jq .head_sha 2>/dev/null || echo "$GITHUB_SHA")
|
||||
for name in proot directaudio tracking xbox comet butler powervr ubisoft rockstar dirt; do
|
||||
for name in proot directaudio tracking xbox comet butler powervr ubisoft rockstar dirt epic; do
|
||||
file="packs/$name.tar.zst"
|
||||
[ -f "$file" ] || { echo "::error::$name.tar.zst is missing from Build APK run $BUILD_RUN"; exit 1; }
|
||||
sha=$(sha256sum "$file" | cut -d' ' -f1)
|
||||
|
||||
@@ -37,3 +37,4 @@ app/src/main/assets/directaudio/
|
||||
app/src/main/assets/hybris/
|
||||
/tools/vr/out/
|
||||
app/src/main/assets/linuxfs/usr/local/lib/droiddeck-rockstar/
|
||||
app/src/main/assets/linuxfs/usr/local/lib/droiddeck-epic/
|
||||
@@ -47,7 +47,7 @@ Help, Preview builds and device reports are on [Discord](https://discord.gg/JRGA
|
||||
|
||||
## Build
|
||||
|
||||
Needs Docker, Java 17, the Android SDK and NDK, Rust via rustup, GitHub CLI, Python 3 and `zstd`.
|
||||
Needs Docker, Java 17, the Android SDK and NDK, Rust via rustup, Go, a host C compiler, the x86_64 and i686 MinGW-w64 compilers (i686 with DWARF-2 exceptions, as Debian and Ubuntu ship it; SJLJ builds such as Homebrew's cannot link Rust's `i686-pc-windows-gnu`), GitHub CLI, Python 3 and `zstd`. On x86_64 Linux, Docker also needs an arm64 binfmt handler (`docker run --privileged --rm tonistiigi/binfmt --install arm64`).
|
||||
|
||||
```bash
|
||||
tools/build_local.sh
|
||||
@@ -70,13 +70,13 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
|
||||
|
||||
- Runtime, shim, input and controller work build on WinNative and Bannerlator by maxjivi05.
|
||||
- mmap ring buffer controller input by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)).
|
||||
- [FEX](https://github.com/FEX-Emu/FEX) (MIT) runs x86 code. DroidDeck's build puts the platform name under `AT_PLATFORM` so [sharun](https://github.com/VHSgunzo/sharun) AppImages by VHSgunzo (MIT) start through its [userland-execve](https://crates.io/crates/userland-execve) loader (MIT). FEX's code disk cache was checked in its source.
|
||||
- [FEX](https://github.com/FEX-Emu/FEX) (MIT) runs x86 code. DroidDeck's build puts the platform name under `AT_PLATFORM` so [sharun](https://github.com/VHSgunzo/sharun) AppImages by VHSgunzo (MIT) start through its [userland-execve](https://crates.io/crates/userland-execve) loader (MIT), and its GL thunk hands X errors to the program's own error handler. FEX's code disk cache was checked in its source.
|
||||
- x86 AppImages, and arm64 ones whose runtime can't unpack on Android, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence.
|
||||
- x86 programs linking OpenSSL 3 use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt). x86 Linux games get the `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes.
|
||||
- `WriteProcessMemory` hooks fall back to `/proc/<pid>/mem` the way [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` did before Wine 11.
|
||||
- Windows programs on noexec storage get executable copies of their image pages, following [@yujikaido](https://github.com/yujikaido)'s finding in [droiddeck-rp4pro](https://github.com/yujikaido/droiddeck-rp4pro) that Wine's own processes need the noexec shim.
|
||||
- Wine write watches use userfaultfd support in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/ntdll/unix/virtual.c` (LGPL-2.1-or-later). libblsession supplies the arm64 syscall number and answers `PAGEMAP_SCAN` from `/proc/self/pagemap`.
|
||||
- libblsession runs Wine's arm64 `SIGUSR2` context handler (`dlls/ntdll/unix/signal_arm64.c`, LGPL-2.1-or-later) in place on a frame laid out like [Linux](https://github.com/torvalds/linux)'s `arch/arm64/kernel/signal.c`, and serves `fill_vm_counters` in `dlls/ntdll/unix/process.c` the kernel's own `/proc/<pid>/status`.
|
||||
- Wine write watches use userfaultfd support in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/ntdll/unix/virtual.c` (LGPL-2.1-or-later). libddsession supplies the arm64 syscall number and answers `PAGEMAP_SCAN` from `/proc/self/pagemap`.
|
||||
- libddsession runs Wine's arm64 `SIGUSR2` context handler (`dlls/ntdll/unix/signal_arm64.c`, LGPL-2.1-or-later) in place on a frame laid out like [Linux](https://github.com/torvalds/linux)'s `arch/arm64/kernel/signal.c`, and serves `fill_vm_counters` in `dlls/ntdll/unix/process.c` the kernel's own `/proc/<pid>/status`.
|
||||
- droiddeck-ntsync follows the [Linux](https://github.com/torvalds/linux) ntsync semantics in `Documentation/userspace-api/ntsync.rst` (GPL-2.0).
|
||||
- The proot fast path orders bindings like [PRoot](https://github.com/proot-me/proot)'s `path/binding.c` (GPL-2.0-or-later).
|
||||
- DiRT 3 and DiRT Showdown keep their telemetry socket the way RoccoC's DiRTTelemetryErrorFix (MIT) does, based on the fix by Carsten Gottschling.
|
||||
@@ -97,6 +97,7 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
|
||||
- Battle.net is by [@kayakyakr](https://github.com/kayakyakr). It runs Blizzard's own client in Proton (downloaded from Blizzard, not included) and shows key art from the [Battle.net Shop](https://shop.battle.net). Without Steam, its games see the pad as an Xbox 360 controller via `PROTON_SPOOF_STEAMINPUT_VIDPID` in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/winebus.sys`.
|
||||
- The EA store follows the EA app's protocols as documented by [ArmchairDevelopers](https://github.com/ArmchairDevelopers)' [Maxima](https://github.com/ArmchairDevelopers/Maxima) (GPL-3.0): sign-in, the GraphQL queries (included verbatim, since EA matches them by hash), build archives, online activation licences and the LSX game endpoint. The code is DroidDeck's own.
|
||||
- Battle.net installs drive Blizzard's Agent the way [@barncastle](https://github.com/barncastle)'s [Battle.Net-Installer](https://github.com/barncastle/Battle.Net-Installer) does, with requests from [wowdev.wiki](https://wowdev.wiki/Agent). Read without taking code: [@mubaraknumann](https://github.com/mubaraknumann)'s [unifideck](https://github.com/mubaraknumann/unifideck), [@djmittens](https://github.com/djmittens)'s [neo-mittens](https://github.com/djmittens/neo-mittens) `bnetswitch`, [@BCD1210](https://github.com/BCD1210)'s [soju](https://github.com/BCD1210/soju) and [Lutris](https://github.com/lutris/lutris)'s `product.db` reader.
|
||||
- The Rockstar launcher service looks for launcher pipe names in the executables beside the game, since [CitizenFX](https://github.com/citizenfx/fivem)'s `ros-patches-five` shows GTA V opening `GTAVLauncher_Pipe` and [@pingod](https://github.com/pingod)'s [rdr2-linux-launcher](https://github.com/pingod/rdr2-linux-launcher) notes that Rockstar's protected executables resolve such strings only at run time. Read without taking code.
|
||||
- World of Warcraft addon imports replace an addon's folder from a temporary copy, as [WowUp](https://github.com/WowUp/WowUp) does, and read flavour folders the way [WoWDeck](https://github.com/sigboe/wowdeck) does. No code from either is used.
|
||||
- The World of Warcraft addon Download window searches [WoWInterface](https://www.wowinterface.com) through its MMOUI API. [CurseForge](https://www.curseforge.com/wow) opens in the user's browser, with no API and no key.
|
||||
- The Xbox store runs [@domsvoboda](https://github.com/domsvoboda)'s [nexus-backend](https://github.com/domsvoboda/nexus-backend) 0.2.15 (GPL-3.0, a fork of [Xodus](https://github.com/xodus-gaming/xodus)), and Xbox games load the Windows modules of his [nexus-runtime](https://github.com/domsvoboda/nexus-runtime) (LGPL-2.1-or-later), including the C++ [nexus-xgameruntime](https://github.com/domsvoboda/nexus-xgameruntime) and `wintypes.dll`. Content licensing sends delegation-compact device tickets in the licensing wire form, as nexus-backend's Store license path (commit `27c335e`) does. Minecraft's GameInput setup was checked against [@Wyze3306](https://github.com/Wyze3306)'s [BedrockOnLinux](https://github.com/Wyze3306/BedrockOnLinux) (MIT).
|
||||
|
||||
+4
-2
@@ -93,7 +93,7 @@ def trackingPack = rootProject.file('tools/packs/tracking/release.env').readLine
|
||||
def prootPackPin = rootProject.file('tools/packs/proot/release.env').readLines()
|
||||
.findAll { it.contains('=') && !it.startsWith('#') }
|
||||
.collectEntries { def kv = it.split('=', 2); [(kv[0].trim()): kv[1].trim()] }
|
||||
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt'].collectEntries { name ->
|
||||
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic'].collectEntries { name ->
|
||||
def pack = file("build/packs/${name}.tar.zst")
|
||||
if (!pack.isFile()) {
|
||||
if (ciBuild) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs")
|
||||
@@ -202,7 +202,7 @@ android {
|
||||
}
|
||||
|
||||
androidResources {
|
||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~:<dir>droiddeck-xbox:<dir>droiddeck-comet:<dir>droiddeck-ubisoft:<dir>droiddeck-rockstar:<dir>droiddeck-dirt:<dir>directaudio:<dir>hybris'
|
||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~:<dir>droiddeck-xbox:<dir>droiddeck-comet:<dir>droiddeck-ubisoft:<dir>droiddeck-rockstar:<dir>droiddeck-dirt:<dir>droiddeck-epic:<dir>directaudio:<dir>hybris'
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
@@ -388,6 +388,8 @@ dependencies {
|
||||
implementation 'androidx.compose.material3:material3'
|
||||
implementation 'androidx.compose.ui:ui-tooling-preview'
|
||||
debugImplementation 'androidx.compose.ui:ui-tooling'
|
||||
// Declares the ComponentActivity that createComposeRule launches, for PreviewRenderTest.
|
||||
debugImplementation 'androidx.compose.ui:ui-test-manifest'
|
||||
implementation 'androidx.activity:activity-compose:1.8.2'
|
||||
implementation 'androidx.compose.material:material-icons-extended'
|
||||
implementation 'io.coil-kt:coil-compose:2.6.0'
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.input.SecondScreenMode
|
||||
|
||||
/** The launcher as a whole: rail and page, opened on each tab through FrontEndState.navigate. */
|
||||
@Composable
|
||||
private fun Launcher(tab: String, games: List<com.droiddeck.launcher.frontend.Library.SteamGame> = sampleGames, ready: Boolean = true) =
|
||||
PreviewHost { FrontEndScreen(sampleState(games = games, navigate = tab, ready = ready), sampleActions) }
|
||||
|
||||
@DroidDeckPreviews @Composable private fun SteamTabPreview() = Launcher("steam")
|
||||
@DroidDeckPreviews @Composable private fun LibraryPreview() = Launcher("games")
|
||||
@DroidDeckPreviews @Composable private fun LibraryEmptyPreview() = Launcher("games", games = emptyList())
|
||||
@DroidDeckPreviews @Composable private fun StoresPreview() = Launcher("stores")
|
||||
@DroidDeckPreviews @Composable private fun DownloadsPreview() = Launcher("downloads")
|
||||
@DroidDeckPreviews @Composable private fun SettingsPreview() = Launcher("setup")
|
||||
@DroidDeckPreviews @Composable private fun RuntimeMissingPreview() = Launcher("setup", ready = false)
|
||||
|
||||
/** The in-game menu on one page, as a session shows it. */
|
||||
@Composable
|
||||
private fun SessionMenu(page: SessionDrawerPage, steam: Boolean = true, desktop: Boolean = false) = PreviewHost {
|
||||
SessionDrawer(true, page, controllerActive = true, onPageChange = {}, a = sampleDrawerActions(steam, desktop))
|
||||
}
|
||||
|
||||
@DroidDeckPreviews @Composable private fun SessionMenuControllerPreview() = SessionMenu(SessionDrawerPage.CONTROLLER)
|
||||
@DroidDeckPreviews @Composable private fun SessionMenuDisplayPreview() = SessionMenu(SessionDrawerPage.DISPLAY)
|
||||
@DroidDeckPreviews @Composable private fun SessionMenuHudPreview() = SessionMenu(SessionDrawerPage.HUD)
|
||||
@DroidDeckPreviews @Composable private fun SessionMenuSessionPreview() = SessionMenu(SessionDrawerPage.SESSION)
|
||||
@DroidDeckPreviews @Composable private fun SessionMenuDesktopPreview() = SessionMenu(SessionDrawerPage.CONTROLLER, steam = false, desktop = true)
|
||||
|
||||
/** The in-game menu docked on the bottom screen, with the screen picker in its header. */
|
||||
@Composable
|
||||
private fun DockedMenu(page: SessionDrawerPage) = PreviewHost {
|
||||
SessionDrawer(true, page, controllerActive = false, onPageChange = {},
|
||||
a = sampleDrawerActions(secondScreen = SecondScreenMode.KEYBOARD_TRACKPAD), docked = true)
|
||||
}
|
||||
|
||||
/** The bottom screen's bar on a panel: the panel's name is the screen picker. */
|
||||
@Composable
|
||||
private fun BottomPanelBar() = PreviewHost {
|
||||
val modes = secondScreenModes(false, deckPad = false, dashboard = true, desktop = false)
|
||||
Column(Modifier.fillMaxSize().background(Color.Black)) {
|
||||
BottomScreenBar(BottomBarModel("Keyboard + trackpad", {}, {}, {}, {},
|
||||
listOf(BarExtra("Keyboard", icon = R.drawable.ic_bottom_keyboard) {}),
|
||||
picker = ScreenPicker(modes, SecondScreenMode.KEYBOARD_TRACKPAD, {}, onMenu = {})))
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews @Composable private fun SessionMenuDockedPreview() = DockedMenu(SessionDrawerPage.CONTROLLER)
|
||||
@DroidDeckPreviews @Composable private fun SessionMenuDockedDisplayPreview() = DockedMenu(SessionDrawerPage.DISPLAY)
|
||||
@DroidDeckPreviews @Composable private fun BottomPanelBarPreview() = BottomPanelBar()
|
||||
|
||||
/** The Library and Stores tabs read store accounts, which load on a background thread. */
|
||||
private val storesLoaded = { com.droiddeck.launcher.stores.StoresState.accountsLoaded }
|
||||
|
||||
/** Every preview above, for the render test. Add a case when adding a preview. */
|
||||
internal val previewCases: List<PreviewCase> = listOf(
|
||||
PreviewCase("steam-tab") { Launcher("steam") },
|
||||
PreviewCase("library", storesLoaded) { Launcher("games") },
|
||||
PreviewCase("library-empty", storesLoaded) { Launcher("games", games = emptyList()) },
|
||||
PreviewCase("stores", storesLoaded) { Launcher("stores") },
|
||||
PreviewCase("downloads") { Launcher("downloads") },
|
||||
PreviewCase("settings") { Launcher("setup") },
|
||||
PreviewCase("runtime-missing") { Launcher("setup", ready = false) },
|
||||
PreviewCase("session-menu-controller") { SessionMenu(SessionDrawerPage.CONTROLLER) },
|
||||
PreviewCase("session-menu-display") { SessionMenu(SessionDrawerPage.DISPLAY) },
|
||||
PreviewCase("session-menu-hud") { SessionMenu(SessionDrawerPage.HUD) },
|
||||
PreviewCase("session-menu-session") { SessionMenu(SessionDrawerPage.SESSION) },
|
||||
PreviewCase("session-menu-desktop") { SessionMenu(SessionDrawerPage.CONTROLLER, steam = false, desktop = true) },
|
||||
PreviewCase("session-menu-docked") { DockedMenu(SessionDrawerPage.CONTROLLER) },
|
||||
PreviewCase("session-menu-docked-display") { DockedMenu(SessionDrawerPage.DISPLAY) },
|
||||
PreviewCase("bottom-panel-bar") { BottomPanelBar() },
|
||||
)
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.gpu.FrameGen
|
||||
import com.droiddeck.launcher.gpu.Lossless
|
||||
import com.droiddeck.launcher.input.SecondScreenDisplay
|
||||
import com.droiddeck.launcher.input.SecondScreenMode
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
/**
|
||||
* Debug-only support for Compose previews: the production theme around a screen, and sample state and no-op actions so
|
||||
* production composables render without a device, a runtime or a network. See docs/compose-previews.md.
|
||||
*/
|
||||
|
||||
/** The sizes the previews come in. The Duo's top screen is 1920x1080 at xhdpi, i.e. 960x540 dp. */
|
||||
@Preview(name = "Handheld", widthDp = 960, heightDp = 540, device = "spec:width=960dp,height=540dp,dpi=320,orientation=landscape")
|
||||
@Preview(name = "Portrait", widthDp = 540, heightDp = 960, device = "spec:width=540dp,height=960dp,dpi=320")
|
||||
internal annotation class DroidDeckPreviews
|
||||
|
||||
@Composable
|
||||
internal fun PreviewHost(content: @Composable () -> Unit) {
|
||||
DroidDeckTheme {
|
||||
Box(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background)) { content() }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A case the render test draws: a name for its PNG and the preview's content. [ready] is what the test waits for before
|
||||
* drawing, for a screen that loads something off the main thread first.
|
||||
*/
|
||||
internal class PreviewCase(val name: String, val ready: () -> Boolean = { true }, val content: @Composable () -> Unit) {
|
||||
override fun toString() = name
|
||||
}
|
||||
|
||||
internal val sampleGames: List<Library.SteamGame> = listOf(
|
||||
"Portal 2" to 620, "Hades" to 1145360, "Celeste" to 504230, "Stardew Valley" to 413150, "Hollow Knight" to 367520,
|
||||
"Balatro" to 2379780, "Dead Cells" to 588650, "Terraria" to 105600, "Vampire Survivors" to 1794680, "Slay the Spire" to 646570,
|
||||
).mapIndexed { i, (name, appId) ->
|
||||
Library.SteamGame(appId, name, art = null, library = "steam", lastPlayed = 1_700_000_000_000L - i * 86_400_000L)
|
||||
}
|
||||
|
||||
internal fun sampleState(
|
||||
games: List<Library.SteamGame> = sampleGames,
|
||||
navigate: String? = null,
|
||||
ready: Boolean = true,
|
||||
): FrontEndState = FrontEndState(
|
||||
installed = "ubuntu-r1", ready = ready, available = "ubuntu-r1", busy = false, stage = "", percent = 0,
|
||||
desktopInstalled = true, offlineAccount = null, offline = false, frameGenLabel = "Off", romsDir = null, logsEnabled = true,
|
||||
steamGames = games, emulators = emptyList(), running = null, navigate = navigate,
|
||||
)
|
||||
|
||||
internal val sampleActions: FrontEndActions = FrontEndActions(
|
||||
onPlay = {}, onPlayDesktopUi = {}, onSteamGame = {}, onDesktop = {}, onEmulator = {}, onRom = {}, onResume = {},
|
||||
onSteamSettings = {}, onDesktopSettings = {}, onInstallPackage = {}, onRemovePackage = {}, onRuntime = {},
|
||||
onFrameGenPick = {}, onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {}, onRoms = {},
|
||||
onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> }, onSetPhantomProcessLimit = { _, _ -> },
|
||||
)
|
||||
|
||||
/** The in-game menu's actions with settled sample values; its switches do nothing. */
|
||||
internal fun sampleDrawerActions(
|
||||
steam: Boolean = true, desktop: Boolean = false, secondScreen: SecondScreenMode? = null,
|
||||
): DrawerActions = DrawerActions(
|
||||
steam = steam, desktop = desktop, title = if (!steam && !desktop) "Hades" else null,
|
||||
isHomeApp = false, androidApps = emptyList(),
|
||||
hudOn = true, onHud = {},
|
||||
frameGen = FrameGen.Mode.OFF, onFrameGenPick = {},
|
||||
lossless = Lossless.State.NONE,
|
||||
oscMode = SessionPrefs.OSC_AUTO, onOsc = {},
|
||||
suspendPolicy = SessionPrefs.SUSPEND_MANUAL, onSuspendPolicy = {},
|
||||
backActionsInverted = false, onBackActionsInverted = {},
|
||||
touchMode = SessionPrefs.TOUCH_AUTO, onTouch = {}, touchAuto = "Auto (direct)",
|
||||
fexPreset = "", onFexPreset = {},
|
||||
secondScreenMode = secondScreen ?: SecondScreenMode.NONE, onSecondScreenMode = {}, secondScreenNone = secondScreen == null,
|
||||
secondScreenDisplays = listOfNotNull(secondScreen?.let { SecondScreenDisplay(2, "Built-in · 1240×1080") }),
|
||||
selectedSecondScreenDisplay = if (secondScreen != null) 2 else -1, onSecondScreenDisplay = {},
|
||||
gameSwapAvailable = secondScreen != null, dashboardAvailable = secondScreen != null,
|
||||
onImportLossless = {}, onKeyboard = {}, onHardwareKeyboard = {},
|
||||
onSteamMenu = if (steam) ({}) else null, onQam = if (steam) ({}) else null,
|
||||
onLaunchAndroidApp = { _, _ -> }, onBackground = {}, onShareLogs = {}, onStop = {}, onClose = {},
|
||||
)
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
<queries>
|
||||
<package android:name="cn.nubia.gamelauncher" />
|
||||
<intent>
|
||||
<action android:name="android.speech.RecognitionService" />
|
||||
</intent>
|
||||
<intent>
|
||||
<action android:name="android.content.pm.action.CONFIRM_INSTALL" />
|
||||
</intent>
|
||||
@@ -150,6 +153,7 @@
|
||||
<category android:name="android.intent.category.CAR_LAUNCHER" />
|
||||
<data android:scheme="droiddeck" android:host="game" />
|
||||
<data android:scheme="droiddeck" android:host="soundtrack" />
|
||||
<data android:scheme="droiddeck" android:host="settings" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
||||
|
||||
@@ -2312,7 +2312,7 @@ __attribute__((visibility("hidden"))) static int inject_uevent(const char *actio
|
||||
const char *subsystem, const char *devname,
|
||||
unsigned major, unsigned minor) {
|
||||
using inject_fn = int (*)(const char *, const char *, const char *, const char *, unsigned, unsigned);
|
||||
static auto inject = reinterpret_cast<inject_fn>(dlsym(RTLD_DEFAULT, "bl_udevmon_inject"));
|
||||
static auto inject = reinterpret_cast<inject_fn>(dlsym(RTLD_DEFAULT, "dd_udevmon_inject"));
|
||||
return inject ? inject(action, devpath, subsystem, devname, major, minor) : -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec2 fragTexCoord;
|
||||
layout(location = 0) out vec4 outColor;
|
||||
layout(set = 0, binding = 0) uniform sampler2D InputTexture;
|
||||
layout(push_constant) uniform Constants {
|
||||
vec4 ndc;
|
||||
vec2 resolution;
|
||||
float extra;
|
||||
float pad;
|
||||
} pc;
|
||||
|
||||
float luma(vec3 c) {
|
||||
return dot(c, vec3(0.2126, 0.7152, 0.0722));
|
||||
}
|
||||
|
||||
float edgeVertical(vec2 uv, vec2 px) {
|
||||
float a = luma(texture(InputTexture, uv - vec2(px.x, 0.0)).rgb);
|
||||
float b = luma(texture(InputTexture, uv + vec2(px.x, 0.0)).rgb);
|
||||
return abs(a - b);
|
||||
}
|
||||
|
||||
float edgeHorizontal(vec2 uv, vec2 px) {
|
||||
float a = luma(texture(InputTexture, uv - vec2(0.0, px.y)).rgb);
|
||||
float b = luma(texture(InputTexture, uv + vec2(0.0, px.y)).rgb);
|
||||
return abs(a - b);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 px = 1.0 / max(pc.resolution, vec2(1.0));
|
||||
vec2 uv = clamp(fragTexCoord, px * 0.5, vec2(1.0) - px * 0.5);
|
||||
vec4 center = texture(InputTexture, uv);
|
||||
|
||||
float lc = luma(center.rgb);
|
||||
float ll = luma(texture(InputTexture, uv - vec2(px.x, 0.0)).rgb);
|
||||
float lr = luma(texture(InputTexture, uv + vec2(px.x, 0.0)).rgb);
|
||||
float lu = luma(texture(InputTexture, uv - vec2(0.0, px.y)).rgb);
|
||||
float ld = luma(texture(InputTexture, uv + vec2(0.0, px.y)).rgb);
|
||||
|
||||
float dL = abs(lc - ll);
|
||||
float dR = abs(lc - lr);
|
||||
float dU = abs(lc - lu);
|
||||
float dD = abs(lc - ld);
|
||||
float localMin = min(lc, min(min(ll, lr), min(lu, ld)));
|
||||
float localMax = max(lc, max(max(ll, lr), max(lu, ld)));
|
||||
float localContrast = localMax - localMin;
|
||||
float threshold = max(0.045, localContrast * 0.08);
|
||||
|
||||
float vertical = max(dL, dR);
|
||||
float horizontal = max(dU, dD);
|
||||
float strongest = max(vertical, horizontal);
|
||||
if (strongest <= threshold) {
|
||||
outColor = center;
|
||||
return;
|
||||
}
|
||||
|
||||
bool verticalEdge = vertical >= horizontal;
|
||||
vec2 tangent = verticalEdge ? vec2(0.0, px.y) : vec2(px.x, 0.0);
|
||||
vec2 normal = verticalEdge
|
||||
? vec2(dL >= dR ? -1.0 : 1.0, 0.0)
|
||||
: vec2(0.0, dU >= dD ? -1.0 : 1.0);
|
||||
|
||||
float negativeRun = 0.0;
|
||||
float positiveRun = 0.0;
|
||||
for (int i = 1; i <= 6; ++i) {
|
||||
vec2 offset = tangent * float(i);
|
||||
float edgeN = verticalEdge ? edgeVertical(uv - offset, px) : edgeHorizontal(uv - offset, px);
|
||||
float edgeP = verticalEdge ? edgeVertical(uv + offset, px) : edgeHorizontal(uv + offset, px);
|
||||
if (negativeRun == float(i - 1) && edgeN > threshold * 0.65) negativeRun = float(i);
|
||||
if (positiveRun == float(i - 1) && edgeP > threshold * 0.65) positiveRun = float(i);
|
||||
}
|
||||
|
||||
float span = negativeRun + positiveRun;
|
||||
float edgeConfidence = smoothstep(threshold, threshold * 2.5, strongest);
|
||||
|
||||
float nw = luma(texture(InputTexture, uv + vec2(-px.x, -px.y)).rgb);
|
||||
float ne = luma(texture(InputTexture, uv + vec2(px.x, -px.y)).rgb);
|
||||
float sw = luma(texture(InputTexture, uv + vec2(-px.x, px.y)).rgb);
|
||||
float se = luma(texture(InputTexture, uv + vec2(px.x, px.y)).rgb);
|
||||
float endpointPattern = clamp(abs(negativeRun - positiveRun) / max(span, 1.0), 0.0, 1.0);
|
||||
float endpointArea = endpointPattern / (1.0 + span * 0.055);
|
||||
float crossingA = verticalEdge ? abs(nw - ne) : abs(nw - sw);
|
||||
float crossingB = verticalEdge ? abs(sw - se) : abs(ne - se);
|
||||
float crossingContrast = abs(crossingA - crossingB);
|
||||
float crossingPattern = smoothstep(threshold, threshold * 2.5, crossingContrast);
|
||||
float areaWeight = 0.38 * crossingPattern * clamp(span / 4.0, 0.0, 1.0);
|
||||
float diagonalContrast = max(abs(nw - se), abs(ne - sw));
|
||||
float cornerFactor = 1.0 - 0.35 * smoothstep(threshold, threshold * 3.0, diagonalContrast);
|
||||
float baseWeight = areaWeight * endpointArea * edgeConfidence * cornerFactor;
|
||||
|
||||
float diagonalStrength = min(vertical, horizontal);
|
||||
float diagonalPattern = smoothstep(threshold, threshold * 2.5, diagonalStrength);
|
||||
float diagonalContinuity = smoothstep(1.0, 3.0, span);
|
||||
float diagonalFallback = 0.16 * diagonalPattern * edgeConfidence
|
||||
* cornerFactor * diagonalContinuity * crossingPattern;
|
||||
|
||||
float weight = clamp(max(baseWeight, diagonalFallback), 0.0, 0.42);
|
||||
vec3 across = texture(InputTexture, uv + normal * px).rgb;
|
||||
outColor = vec4(mix(center.rgb, across, weight), center.a);
|
||||
}
|
||||
@@ -0,0 +1,443 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
static const uint32_t smaa_code[] = {
|
||||
0x07230203u, 0x00010000u, 0x0008000bu, 0x00000251u, 0x00000000u, 0x00020011u, 0x00000001u, 0x0006000bu,
|
||||
0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x00000000u, 0x00000001u,
|
||||
0x0007000fu, 0x00000004u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x00000072u, 0x000000f6u, 0x00030010u,
|
||||
0x00000004u, 0x00000007u, 0x00030003u, 0x00000002u, 0x000001c2u, 0x00040005u, 0x00000004u, 0x6e69616du,
|
||||
0x00000000u, 0x00050005u, 0x0000000bu, 0x616d756cu, 0x33667628u, 0x0000003bu, 0x00030005u, 0x0000000au,
|
||||
0x00000063u, 0x00080005u, 0x00000012u, 0x65676465u, 0x74726556u, 0x6c616369u, 0x32667628u, 0x3266763bu,
|
||||
0x0000003bu, 0x00030005u, 0x00000010u, 0x00007675u, 0x00030005u, 0x00000011u, 0x00007870u, 0x00080005u,
|
||||
0x00000016u, 0x65676465u, 0x69726f48u, 0x746e6f7au, 0x76286c61u, 0x763b3266u, 0x003b3266u, 0x00030005u,
|
||||
0x00000014u, 0x00007675u, 0x00030005u, 0x00000015u, 0x00007870u, 0x00030005u, 0x00000021u, 0x00000061u,
|
||||
0x00060005u, 0x00000025u, 0x75706e49u, 0x78655474u, 0x65727574u, 0x00000000u, 0x00040005u, 0x00000031u,
|
||||
0x61726170u, 0x0000006du, 0x00030005u, 0x00000034u, 0x00000062u, 0x00040005u, 0x0000003cu, 0x61726170u,
|
||||
0x0000006du, 0x00030005u, 0x00000045u, 0x00000061u, 0x00040005u, 0x0000004eu, 0x61726170u, 0x0000006du,
|
||||
0x00030005u, 0x00000051u, 0x00000062u, 0x00040005u, 0x00000059u, 0x61726170u, 0x0000006du, 0x00030005u,
|
||||
0x00000062u, 0x00007870u, 0x00050005u, 0x00000064u, 0x736e6f43u, 0x746e6174u, 0x00000073u, 0x00040006u,
|
||||
0x00000064u, 0x00000000u, 0x0063646eu, 0x00060006u, 0x00000064u, 0x00000001u, 0x6f736572u, 0x6974756cu,
|
||||
0x00006e6fu, 0x00050006u, 0x00000064u, 0x00000002u, 0x72747865u, 0x00000061u, 0x00040006u, 0x00000064u,
|
||||
0x00000003u, 0x00646170u, 0x00030005u, 0x00000066u, 0x00006370u, 0x00030005u, 0x00000070u, 0x00007675u,
|
||||
0x00060005u, 0x00000072u, 0x67617266u, 0x43786554u, 0x64726f6fu, 0x00000000u, 0x00040005u, 0x0000007cu,
|
||||
0x746e6563u, 0x00007265u, 0x00030005u, 0x00000080u, 0x0000636cu, 0x00040005u, 0x00000081u, 0x61726170u,
|
||||
0x0000006du, 0x00030005u, 0x00000085u, 0x00006c6cu, 0x00040005u, 0x0000008du, 0x61726170u, 0x0000006du,
|
||||
0x00030005u, 0x00000090u, 0x0000726cu, 0x00040005u, 0x00000098u, 0x61726170u, 0x0000006du, 0x00030005u,
|
||||
0x0000009bu, 0x0000756cu, 0x00040005u, 0x000000a3u, 0x61726170u, 0x0000006du, 0x00030005u, 0x000000a6u,
|
||||
0x0000646cu, 0x00040005u, 0x000000aeu, 0x61726170u, 0x0000006du, 0x00030005u, 0x000000b1u, 0x00004c64u,
|
||||
0x00030005u, 0x000000b6u, 0x00005264u, 0x00030005u, 0x000000bbu, 0x00005564u, 0x00030005u, 0x000000c0u,
|
||||
0x00004464u, 0x00050005u, 0x000000c5u, 0x61636f6cu, 0x6e694d6cu, 0x00000000u, 0x00050005u, 0x000000cfu,
|
||||
0x61636f6cu, 0x78614d6cu, 0x00000000u, 0x00060005u, 0x000000d9u, 0x61636f6cu, 0x6e6f436cu, 0x73617274u,
|
||||
0x00000074u, 0x00050005u, 0x000000ddu, 0x65726874u, 0x6c6f6873u, 0x00000064u, 0x00050005u, 0x000000e3u,
|
||||
0x74726576u, 0x6c616369u, 0x00000000u, 0x00050005u, 0x000000e7u, 0x69726f68u, 0x746e6f7au, 0x00006c61u,
|
||||
0x00050005u, 0x000000ebu, 0x6f727473u, 0x7365676eu, 0x00000074u, 0x00050005u, 0x000000f6u, 0x4374756fu,
|
||||
0x726f6c6fu, 0x00000000u, 0x00060005u, 0x000000fau, 0x74726576u, 0x6c616369u, 0x65676445u, 0x00000000u,
|
||||
0x00040005u, 0x000000feu, 0x676e6174u, 0x00746e65u, 0x00040005u, 0x0000010bu, 0x6d726f6eu, 0x00006c61u,
|
||||
0x00050005u, 0x0000011du, 0x6167656eu, 0x65766974u, 0x006e7552u, 0x00050005u, 0x0000011eu, 0x69736f70u,
|
||||
0x65766974u, 0x006e7552u, 0x00030005u, 0x00000120u, 0x00000069u, 0x00040005u, 0x00000129u, 0x7366666fu,
|
||||
0x00007465u, 0x00040005u, 0x0000012eu, 0x65676465u, 0x0000004eu, 0x00040005u, 0x00000136u, 0x61726170u,
|
||||
0x0000006du, 0x00040005u, 0x00000137u, 0x61726170u, 0x0000006du, 0x00040005u, 0x0000013eu, 0x61726170u,
|
||||
0x0000006du, 0x00040005u, 0x0000013fu, 0x61726170u, 0x0000006du, 0x00040005u, 0x00000143u, 0x65676465u,
|
||||
0x00000050u, 0x00040005u, 0x0000014bu, 0x61726170u, 0x0000006du, 0x00040005u, 0x0000014cu, 0x61726170u,
|
||||
0x0000006du, 0x00040005u, 0x00000153u, 0x61726170u, 0x0000006du, 0x00040005u, 0x00000154u, 0x61726170u,
|
||||
0x0000006du, 0x00040005u, 0x0000017bu, 0x6e617073u, 0x00000000u, 0x00060005u, 0x0000017fu, 0x65676465u,
|
||||
0x666e6f43u, 0x6e656469u, 0x00006563u, 0x00030005u, 0x00000186u, 0x0000776eu, 0x00040005u, 0x00000192u,
|
||||
0x61726170u, 0x0000006du, 0x00030005u, 0x00000195u, 0x0000656eu, 0x00040005u, 0x000001a0u, 0x61726170u,
|
||||
0x0000006du, 0x00030005u, 0x000001a3u, 0x00007773u, 0x00040005u, 0x000001aeu, 0x61726170u, 0x0000006du,
|
||||
0x00030005u, 0x000001b1u, 0x00006573u, 0x00040005u, 0x000001bbu, 0x61726170u, 0x0000006du, 0x00060005u,
|
||||
0x000001beu, 0x70646e65u, 0x746e696fu, 0x74746150u, 0x006e7265u, 0x00060005u, 0x000001c7u, 0x70646e65u,
|
||||
0x746e696fu, 0x61657241u, 0x00000000u, 0x00050005u, 0x000001ceu, 0x736f7263u, 0x676e6973u, 0x00000041u,
|
||||
0x00050005u, 0x000001ddu, 0x736f7263u, 0x676e6973u, 0x00000042u, 0x00070005u, 0x000001ecu, 0x736f7263u,
|
||||
0x676e6973u, 0x746e6f43u, 0x74736172u, 0x00000000u, 0x00060005u, 0x000001f1u, 0x736f7263u, 0x676e6973u,
|
||||
0x74746150u, 0x006e7265u, 0x00050005u, 0x000001f7u, 0x61657261u, 0x67696557u, 0x00007468u, 0x00070005u,
|
||||
0x00000200u, 0x67616964u, 0x6c616e6fu, 0x746e6f43u, 0x74736172u, 0x00000000u, 0x00060005u, 0x0000020au,
|
||||
0x6e726f63u, 0x61467265u, 0x726f7463u, 0x00000000u, 0x00050005u, 0x00000214u, 0x65736162u, 0x67696557u,
|
||||
0x00007468u, 0x00070005u, 0x0000021cu, 0x67616964u, 0x6c616e6fu, 0x65727453u, 0x6874676eu, 0x00000000u,
|
||||
0x00060005u, 0x00000220u, 0x67616964u, 0x6c616e6fu, 0x74746150u, 0x006e7265u, 0x00070005u, 0x00000226u,
|
||||
0x67616964u, 0x6c616e6fu, 0x746e6f43u, 0x69756e69u, 0x00007974u, 0x00070005u, 0x00000229u, 0x67616964u,
|
||||
0x6c616e6fu, 0x6c6c6146u, 0x6b636162u, 0x00000000u, 0x00040005u, 0x00000235u, 0x67696577u, 0x00007468u,
|
||||
0x00040005u, 0x0000023bu, 0x6f726361u, 0x00007373u, 0x00040047u, 0x00000025u, 0x00000021u, 0x00000000u,
|
||||
0x00040047u, 0x00000025u, 0x00000022u, 0x00000000u, 0x00030047u, 0x00000064u, 0x00000002u, 0x00050048u,
|
||||
0x00000064u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u, 0x00000064u, 0x00000001u, 0x00000023u,
|
||||
0x00000010u, 0x00050048u, 0x00000064u, 0x00000002u, 0x00000023u, 0x00000018u, 0x00050048u, 0x00000064u,
|
||||
0x00000003u, 0x00000023u, 0x0000001cu, 0x00040047u, 0x00000072u, 0x0000001eu, 0x00000000u, 0x00040047u,
|
||||
0x000000f6u, 0x0000001eu, 0x00000000u, 0x00020013u, 0x00000002u, 0x00030021u, 0x00000003u, 0x00000002u,
|
||||
0x00030016u, 0x00000006u, 0x00000020u, 0x00040017u, 0x00000007u, 0x00000006u, 0x00000003u, 0x00040020u,
|
||||
0x00000008u, 0x00000007u, 0x00000007u, 0x00040021u, 0x00000009u, 0x00000006u, 0x00000008u, 0x00040017u,
|
||||
0x0000000du, 0x00000006u, 0x00000002u, 0x00040020u, 0x0000000eu, 0x00000007u, 0x0000000du, 0x00050021u,
|
||||
0x0000000fu, 0x00000006u, 0x0000000eu, 0x0000000eu, 0x0004002bu, 0x00000006u, 0x00000019u, 0x3e59b3d0u,
|
||||
0x0004002bu, 0x00000006u, 0x0000001au, 0x3f371759u, 0x0004002bu, 0x00000006u, 0x0000001bu, 0x3d93dd98u,
|
||||
0x0006002cu, 0x00000007u, 0x0000001cu, 0x00000019u, 0x0000001au, 0x0000001bu, 0x00040020u, 0x00000020u,
|
||||
0x00000007u, 0x00000006u, 0x00090019u, 0x00000022u, 0x00000006u, 0x00000001u, 0x00000000u, 0x00000000u,
|
||||
0x00000000u, 0x00000001u, 0x00000000u, 0x0003001bu, 0x00000023u, 0x00000022u, 0x00040020u, 0x00000024u,
|
||||
0x00000000u, 0x00000023u, 0x0004003bu, 0x00000024u, 0x00000025u, 0x00000000u, 0x00040015u, 0x00000028u,
|
||||
0x00000020u, 0x00000000u, 0x0004002bu, 0x00000028u, 0x00000029u, 0x00000000u, 0x0004002bu, 0x00000006u,
|
||||
0x0000002cu, 0x00000000u, 0x00040017u, 0x0000002fu, 0x00000006u, 0x00000004u, 0x0004002bu, 0x00000028u,
|
||||
0x00000048u, 0x00000001u, 0x0004002bu, 0x00000006u, 0x00000063u, 0x3f800000u, 0x0006001eu, 0x00000064u,
|
||||
0x0000002fu, 0x0000000du, 0x00000006u, 0x00000006u, 0x00040020u, 0x00000065u, 0x00000009u, 0x00000064u,
|
||||
0x0004003bu, 0x00000065u, 0x00000066u, 0x00000009u, 0x00040015u, 0x00000067u, 0x00000020u, 0x00000001u,
|
||||
0x0004002bu, 0x00000067u, 0x00000068u, 0x00000001u, 0x00040020u, 0x00000069u, 0x00000009u, 0x0000000du,
|
||||
0x0005002cu, 0x0000000du, 0x0000006cu, 0x00000063u, 0x00000063u, 0x00040020u, 0x00000071u, 0x00000001u,
|
||||
0x0000000du, 0x0004003bu, 0x00000071u, 0x00000072u, 0x00000001u, 0x0004002bu, 0x00000006u, 0x00000075u,
|
||||
0x3f000000u, 0x00040020u, 0x0000007bu, 0x00000007u, 0x0000002fu, 0x0004002bu, 0x00000006u, 0x000000deu,
|
||||
0x3d3851ecu, 0x0004002bu, 0x00000006u, 0x000000e0u, 0x3da3d70au, 0x00020014u, 0x000000f1u, 0x00040020u,
|
||||
0x000000f5u, 0x00000003u, 0x0000002fu, 0x0004003bu, 0x000000f5u, 0x000000f6u, 0x00000003u, 0x00040020u,
|
||||
0x000000f9u, 0x00000007u, 0x000000f1u, 0x0004002bu, 0x00000006u, 0x00000113u, 0xbf800000u, 0x00040020u,
|
||||
0x0000011fu, 0x00000007u, 0x00000067u, 0x0004002bu, 0x00000067u, 0x00000127u, 0x00000006u, 0x0004002bu,
|
||||
0x00000006u, 0x00000161u, 0x3f266666u, 0x0004002bu, 0x00000006u, 0x00000182u, 0x40200000u, 0x0004002bu,
|
||||
0x00000006u, 0x000001cau, 0x3d6147aeu, 0x0004002bu, 0x00000006u, 0x000001f8u, 0x3ec28f5cu, 0x0004002bu,
|
||||
0x00000006u, 0x000001fcu, 0x40800000u, 0x0004002bu, 0x00000006u, 0x0000020bu, 0x3eb33333u, 0x0004002bu,
|
||||
0x00000006u, 0x0000020eu, 0x40400000u, 0x0004002bu, 0x00000006u, 0x0000022au, 0x3e23d70au, 0x0004002bu,
|
||||
0x00000006u, 0x00000239u, 0x3ed70a3du, 0x0004002bu, 0x00000028u, 0x0000024au, 0x00000003u, 0x00050036u,
|
||||
0x00000002u, 0x00000004u, 0x00000000u, 0x00000003u, 0x000200f8u, 0x00000005u, 0x0004003bu, 0x0000000eu,
|
||||
0x00000062u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000070u, 0x00000007u, 0x0004003bu, 0x0000007bu,
|
||||
0x0000007cu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000080u, 0x00000007u, 0x0004003bu, 0x00000008u,
|
||||
0x00000081u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000085u, 0x00000007u, 0x0004003bu, 0x00000008u,
|
||||
0x0000008du, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000090u, 0x00000007u, 0x0004003bu, 0x00000008u,
|
||||
0x00000098u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000009bu, 0x00000007u, 0x0004003bu, 0x00000008u,
|
||||
0x000000a3u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000a6u, 0x00000007u, 0x0004003bu, 0x00000008u,
|
||||
0x000000aeu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000b1u, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x000000b6u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000bbu, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x000000c0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000c5u, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x000000cfu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000d9u, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x000000ddu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000e3u, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x000000e7u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000ebu, 0x00000007u, 0x0004003bu, 0x000000f9u,
|
||||
0x000000fau, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x000000feu, 0x00000007u, 0x0004003bu, 0x0000000eu,
|
||||
0x00000100u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000010bu, 0x00000007u, 0x0004003bu, 0x0000000eu,
|
||||
0x0000010du, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000011du, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x0000011eu, 0x00000007u, 0x0004003bu, 0x0000011fu, 0x00000120u, 0x00000007u, 0x0004003bu, 0x0000000eu,
|
||||
0x00000129u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000012eu, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x00000130u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000136u, 0x00000007u, 0x0004003bu, 0x0000000eu,
|
||||
0x00000137u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000013eu, 0x00000007u, 0x0004003bu, 0x0000000eu,
|
||||
0x0000013fu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000143u, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x00000145u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000014bu, 0x00000007u, 0x0004003bu, 0x0000000eu,
|
||||
0x0000014cu, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000153u, 0x00000007u, 0x0004003bu, 0x0000000eu,
|
||||
0x00000154u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000017bu, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x0000017fu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000186u, 0x00000007u, 0x0004003bu, 0x00000008u,
|
||||
0x00000192u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000195u, 0x00000007u, 0x0004003bu, 0x00000008u,
|
||||
0x000001a0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001a3u, 0x00000007u, 0x0004003bu, 0x00000008u,
|
||||
0x000001aeu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001b1u, 0x00000007u, 0x0004003bu, 0x00000008u,
|
||||
0x000001bbu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001beu, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x000001c7u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ceu, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x000001d0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ddu, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x000001dfu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ecu, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x000001f1u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001f7u, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x00000200u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000020au, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x00000214u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000021cu, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x00000220u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000226u, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x00000229u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000235u, 0x00000007u, 0x0004003bu, 0x00000008u,
|
||||
0x0000023bu, 0x00000007u, 0x00050041u, 0x00000069u, 0x0000006au, 0x00000066u, 0x00000068u, 0x0004003du,
|
||||
0x0000000du, 0x0000006bu, 0x0000006au, 0x0007000cu, 0x0000000du, 0x0000006du, 0x00000001u, 0x00000028u,
|
||||
0x0000006bu, 0x0000006cu, 0x00050050u, 0x0000000du, 0x0000006eu, 0x00000063u, 0x00000063u, 0x00050088u,
|
||||
0x0000000du, 0x0000006fu, 0x0000006eu, 0x0000006du, 0x0003003eu, 0x00000062u, 0x0000006fu, 0x0004003du,
|
||||
0x0000000du, 0x00000073u, 0x00000072u, 0x0004003du, 0x0000000du, 0x00000074u, 0x00000062u, 0x0005008eu,
|
||||
0x0000000du, 0x00000076u, 0x00000074u, 0x00000075u, 0x0004003du, 0x0000000du, 0x00000077u, 0x00000062u,
|
||||
0x0005008eu, 0x0000000du, 0x00000078u, 0x00000077u, 0x00000075u, 0x00050083u, 0x0000000du, 0x00000079u,
|
||||
0x0000006cu, 0x00000078u, 0x0008000cu, 0x0000000du, 0x0000007au, 0x00000001u, 0x0000002bu, 0x00000073u,
|
||||
0x00000076u, 0x00000079u, 0x0003003eu, 0x00000070u, 0x0000007au, 0x0004003du, 0x00000023u, 0x0000007du,
|
||||
0x00000025u, 0x0004003du, 0x0000000du, 0x0000007eu, 0x00000070u, 0x00050057u, 0x0000002fu, 0x0000007fu,
|
||||
0x0000007du, 0x0000007eu, 0x0003003eu, 0x0000007cu, 0x0000007fu, 0x0004003du, 0x0000002fu, 0x00000082u,
|
||||
0x0000007cu, 0x0008004fu, 0x00000007u, 0x00000083u, 0x00000082u, 0x00000082u, 0x00000000u, 0x00000001u,
|
||||
0x00000002u, 0x0003003eu, 0x00000081u, 0x00000083u, 0x00050039u, 0x00000006u, 0x00000084u, 0x0000000bu,
|
||||
0x00000081u, 0x0003003eu, 0x00000080u, 0x00000084u, 0x0004003du, 0x00000023u, 0x00000086u, 0x00000025u,
|
||||
0x0004003du, 0x0000000du, 0x00000087u, 0x00000070u, 0x00050041u, 0x00000020u, 0x00000088u, 0x00000062u,
|
||||
0x00000029u, 0x0004003du, 0x00000006u, 0x00000089u, 0x00000088u, 0x00050050u, 0x0000000du, 0x0000008au,
|
||||
0x00000089u, 0x0000002cu, 0x00050083u, 0x0000000du, 0x0000008bu, 0x00000087u, 0x0000008au, 0x00050057u,
|
||||
0x0000002fu, 0x0000008cu, 0x00000086u, 0x0000008bu, 0x0008004fu, 0x00000007u, 0x0000008eu, 0x0000008cu,
|
||||
0x0000008cu, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x0000008du, 0x0000008eu, 0x00050039u,
|
||||
0x00000006u, 0x0000008fu, 0x0000000bu, 0x0000008du, 0x0003003eu, 0x00000085u, 0x0000008fu, 0x0004003du,
|
||||
0x00000023u, 0x00000091u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000092u, 0x00000070u, 0x00050041u,
|
||||
0x00000020u, 0x00000093u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u, 0x00000094u, 0x00000093u,
|
||||
0x00050050u, 0x0000000du, 0x00000095u, 0x00000094u, 0x0000002cu, 0x00050081u, 0x0000000du, 0x00000096u,
|
||||
0x00000092u, 0x00000095u, 0x00050057u, 0x0000002fu, 0x00000097u, 0x00000091u, 0x00000096u, 0x0008004fu,
|
||||
0x00000007u, 0x00000099u, 0x00000097u, 0x00000097u, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu,
|
||||
0x00000098u, 0x00000099u, 0x00050039u, 0x00000006u, 0x0000009au, 0x0000000bu, 0x00000098u, 0x0003003eu,
|
||||
0x00000090u, 0x0000009au, 0x0004003du, 0x00000023u, 0x0000009cu, 0x00000025u, 0x0004003du, 0x0000000du,
|
||||
0x0000009du, 0x00000070u, 0x00050041u, 0x00000020u, 0x0000009eu, 0x00000062u, 0x00000048u, 0x0004003du,
|
||||
0x00000006u, 0x0000009fu, 0x0000009eu, 0x00050050u, 0x0000000du, 0x000000a0u, 0x0000002cu, 0x0000009fu,
|
||||
0x00050083u, 0x0000000du, 0x000000a1u, 0x0000009du, 0x000000a0u, 0x00050057u, 0x0000002fu, 0x000000a2u,
|
||||
0x0000009cu, 0x000000a1u, 0x0008004fu, 0x00000007u, 0x000000a4u, 0x000000a2u, 0x000000a2u, 0x00000000u,
|
||||
0x00000001u, 0x00000002u, 0x0003003eu, 0x000000a3u, 0x000000a4u, 0x00050039u, 0x00000006u, 0x000000a5u,
|
||||
0x0000000bu, 0x000000a3u, 0x0003003eu, 0x0000009bu, 0x000000a5u, 0x0004003du, 0x00000023u, 0x000000a7u,
|
||||
0x00000025u, 0x0004003du, 0x0000000du, 0x000000a8u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000000a9u,
|
||||
0x00000062u, 0x00000048u, 0x0004003du, 0x00000006u, 0x000000aau, 0x000000a9u, 0x00050050u, 0x0000000du,
|
||||
0x000000abu, 0x0000002cu, 0x000000aau, 0x00050081u, 0x0000000du, 0x000000acu, 0x000000a8u, 0x000000abu,
|
||||
0x00050057u, 0x0000002fu, 0x000000adu, 0x000000a7u, 0x000000acu, 0x0008004fu, 0x00000007u, 0x000000afu,
|
||||
0x000000adu, 0x000000adu, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x000000aeu, 0x000000afu,
|
||||
0x00050039u, 0x00000006u, 0x000000b0u, 0x0000000bu, 0x000000aeu, 0x0003003eu, 0x000000a6u, 0x000000b0u,
|
||||
0x0004003du, 0x00000006u, 0x000000b2u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000b3u, 0x00000085u,
|
||||
0x00050083u, 0x00000006u, 0x000000b4u, 0x000000b2u, 0x000000b3u, 0x0006000cu, 0x00000006u, 0x000000b5u,
|
||||
0x00000001u, 0x00000004u, 0x000000b4u, 0x0003003eu, 0x000000b1u, 0x000000b5u, 0x0004003du, 0x00000006u,
|
||||
0x000000b7u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000b8u, 0x00000090u, 0x00050083u, 0x00000006u,
|
||||
0x000000b9u, 0x000000b7u, 0x000000b8u, 0x0006000cu, 0x00000006u, 0x000000bau, 0x00000001u, 0x00000004u,
|
||||
0x000000b9u, 0x0003003eu, 0x000000b6u, 0x000000bau, 0x0004003du, 0x00000006u, 0x000000bcu, 0x00000080u,
|
||||
0x0004003du, 0x00000006u, 0x000000bdu, 0x0000009bu, 0x00050083u, 0x00000006u, 0x000000beu, 0x000000bcu,
|
||||
0x000000bdu, 0x0006000cu, 0x00000006u, 0x000000bfu, 0x00000001u, 0x00000004u, 0x000000beu, 0x0003003eu,
|
||||
0x000000bbu, 0x000000bfu, 0x0004003du, 0x00000006u, 0x000000c1u, 0x00000080u, 0x0004003du, 0x00000006u,
|
||||
0x000000c2u, 0x000000a6u, 0x00050083u, 0x00000006u, 0x000000c3u, 0x000000c1u, 0x000000c2u, 0x0006000cu,
|
||||
0x00000006u, 0x000000c4u, 0x00000001u, 0x00000004u, 0x000000c3u, 0x0003003eu, 0x000000c0u, 0x000000c4u,
|
||||
0x0004003du, 0x00000006u, 0x000000c6u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000c7u, 0x00000085u,
|
||||
0x0004003du, 0x00000006u, 0x000000c8u, 0x00000090u, 0x0007000cu, 0x00000006u, 0x000000c9u, 0x00000001u,
|
||||
0x00000025u, 0x000000c7u, 0x000000c8u, 0x0004003du, 0x00000006u, 0x000000cau, 0x0000009bu, 0x0004003du,
|
||||
0x00000006u, 0x000000cbu, 0x000000a6u, 0x0007000cu, 0x00000006u, 0x000000ccu, 0x00000001u, 0x00000025u,
|
||||
0x000000cau, 0x000000cbu, 0x0007000cu, 0x00000006u, 0x000000cdu, 0x00000001u, 0x00000025u, 0x000000c9u,
|
||||
0x000000ccu, 0x0007000cu, 0x00000006u, 0x000000ceu, 0x00000001u, 0x00000025u, 0x000000c6u, 0x000000cdu,
|
||||
0x0003003eu, 0x000000c5u, 0x000000ceu, 0x0004003du, 0x00000006u, 0x000000d0u, 0x00000080u, 0x0004003du,
|
||||
0x00000006u, 0x000000d1u, 0x00000085u, 0x0004003du, 0x00000006u, 0x000000d2u, 0x00000090u, 0x0007000cu,
|
||||
0x00000006u, 0x000000d3u, 0x00000001u, 0x00000028u, 0x000000d1u, 0x000000d2u, 0x0004003du, 0x00000006u,
|
||||
0x000000d4u, 0x0000009bu, 0x0004003du, 0x00000006u, 0x000000d5u, 0x000000a6u, 0x0007000cu, 0x00000006u,
|
||||
0x000000d6u, 0x00000001u, 0x00000028u, 0x000000d4u, 0x000000d5u, 0x0007000cu, 0x00000006u, 0x000000d7u,
|
||||
0x00000001u, 0x00000028u, 0x000000d3u, 0x000000d6u, 0x0007000cu, 0x00000006u, 0x000000d8u, 0x00000001u,
|
||||
0x00000028u, 0x000000d0u, 0x000000d7u, 0x0003003eu, 0x000000cfu, 0x000000d8u, 0x0004003du, 0x00000006u,
|
||||
0x000000dau, 0x000000cfu, 0x0004003du, 0x00000006u, 0x000000dbu, 0x000000c5u, 0x00050083u, 0x00000006u,
|
||||
0x000000dcu, 0x000000dau, 0x000000dbu, 0x0003003eu, 0x000000d9u, 0x000000dcu, 0x0004003du, 0x00000006u,
|
||||
0x000000dfu, 0x000000d9u, 0x00050085u, 0x00000006u, 0x000000e1u, 0x000000dfu, 0x000000e0u, 0x0007000cu,
|
||||
0x00000006u, 0x000000e2u, 0x00000001u, 0x00000028u, 0x000000deu, 0x000000e1u, 0x0003003eu, 0x000000ddu,
|
||||
0x000000e2u, 0x0004003du, 0x00000006u, 0x000000e4u, 0x000000b1u, 0x0004003du, 0x00000006u, 0x000000e5u,
|
||||
0x000000b6u, 0x0007000cu, 0x00000006u, 0x000000e6u, 0x00000001u, 0x00000028u, 0x000000e4u, 0x000000e5u,
|
||||
0x0003003eu, 0x000000e3u, 0x000000e6u, 0x0004003du, 0x00000006u, 0x000000e8u, 0x000000bbu, 0x0004003du,
|
||||
0x00000006u, 0x000000e9u, 0x000000c0u, 0x0007000cu, 0x00000006u, 0x000000eau, 0x00000001u, 0x00000028u,
|
||||
0x000000e8u, 0x000000e9u, 0x0003003eu, 0x000000e7u, 0x000000eau, 0x0004003du, 0x00000006u, 0x000000ecu,
|
||||
0x000000e3u, 0x0004003du, 0x00000006u, 0x000000edu, 0x000000e7u, 0x0007000cu, 0x00000006u, 0x000000eeu,
|
||||
0x00000001u, 0x00000028u, 0x000000ecu, 0x000000edu, 0x0003003eu, 0x000000ebu, 0x000000eeu, 0x0004003du,
|
||||
0x00000006u, 0x000000efu, 0x000000ebu, 0x0004003du, 0x00000006u, 0x000000f0u, 0x000000ddu, 0x000500bcu,
|
||||
0x000000f1u, 0x000000f2u, 0x000000efu, 0x000000f0u, 0x000300f7u, 0x000000f4u, 0x00000000u, 0x000400fau,
|
||||
0x000000f2u, 0x000000f3u, 0x000000f4u, 0x000200f8u, 0x000000f3u, 0x0004003du, 0x0000002fu, 0x000000f7u,
|
||||
0x0000007cu, 0x0003003eu, 0x000000f6u, 0x000000f7u, 0x000100fdu, 0x000200f8u, 0x000000f4u, 0x0004003du,
|
||||
0x00000006u, 0x000000fbu, 0x000000e3u, 0x0004003du, 0x00000006u, 0x000000fcu, 0x000000e7u, 0x000500beu,
|
||||
0x000000f1u, 0x000000fdu, 0x000000fbu, 0x000000fcu, 0x0003003eu, 0x000000fau, 0x000000fdu, 0x0004003du,
|
||||
0x000000f1u, 0x000000ffu, 0x000000fau, 0x000300f7u, 0x00000102u, 0x00000000u, 0x000400fau, 0x000000ffu,
|
||||
0x00000101u, 0x00000106u, 0x000200f8u, 0x00000101u, 0x00050041u, 0x00000020u, 0x00000103u, 0x00000062u,
|
||||
0x00000048u, 0x0004003du, 0x00000006u, 0x00000104u, 0x00000103u, 0x00050050u, 0x0000000du, 0x00000105u,
|
||||
0x0000002cu, 0x00000104u, 0x0003003eu, 0x00000100u, 0x00000105u, 0x000200f9u, 0x00000102u, 0x000200f8u,
|
||||
0x00000106u, 0x00050041u, 0x00000020u, 0x00000107u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u,
|
||||
0x00000108u, 0x00000107u, 0x00050050u, 0x0000000du, 0x00000109u, 0x00000108u, 0x0000002cu, 0x0003003eu,
|
||||
0x00000100u, 0x00000109u, 0x000200f9u, 0x00000102u, 0x000200f8u, 0x00000102u, 0x0004003du, 0x0000000du,
|
||||
0x0000010au, 0x00000100u, 0x0003003eu, 0x000000feu, 0x0000010au, 0x0004003du, 0x000000f1u, 0x0000010cu,
|
||||
0x000000fau, 0x000300f7u, 0x0000010fu, 0x00000000u, 0x000400fau, 0x0000010cu, 0x0000010eu, 0x00000116u,
|
||||
0x000200f8u, 0x0000010eu, 0x0004003du, 0x00000006u, 0x00000110u, 0x000000b1u, 0x0004003du, 0x00000006u,
|
||||
0x00000111u, 0x000000b6u, 0x000500beu, 0x000000f1u, 0x00000112u, 0x00000110u, 0x00000111u, 0x000600a9u,
|
||||
0x00000006u, 0x00000114u, 0x00000112u, 0x00000113u, 0x00000063u, 0x00050050u, 0x0000000du, 0x00000115u,
|
||||
0x00000114u, 0x0000002cu, 0x0003003eu, 0x0000010du, 0x00000115u, 0x000200f9u, 0x0000010fu, 0x000200f8u,
|
||||
0x00000116u, 0x0004003du, 0x00000006u, 0x00000117u, 0x000000bbu, 0x0004003du, 0x00000006u, 0x00000118u,
|
||||
0x000000c0u, 0x000500beu, 0x000000f1u, 0x00000119u, 0x00000117u, 0x00000118u, 0x000600a9u, 0x00000006u,
|
||||
0x0000011au, 0x00000119u, 0x00000113u, 0x00000063u, 0x00050050u, 0x0000000du, 0x0000011bu, 0x0000002cu,
|
||||
0x0000011au, 0x0003003eu, 0x0000010du, 0x0000011bu, 0x000200f9u, 0x0000010fu, 0x000200f8u, 0x0000010fu,
|
||||
0x0004003du, 0x0000000du, 0x0000011cu, 0x0000010du, 0x0003003eu, 0x0000010bu, 0x0000011cu, 0x0003003eu,
|
||||
0x0000011du, 0x0000002cu, 0x0003003eu, 0x0000011eu, 0x0000002cu, 0x0003003eu, 0x00000120u, 0x00000068u,
|
||||
0x000200f9u, 0x00000121u, 0x000200f8u, 0x00000121u, 0x000400f6u, 0x00000123u, 0x00000124u, 0x00000000u,
|
||||
0x000200f9u, 0x00000125u, 0x000200f8u, 0x00000125u, 0x0004003du, 0x00000067u, 0x00000126u, 0x00000120u,
|
||||
0x000500b3u, 0x000000f1u, 0x00000128u, 0x00000126u, 0x00000127u, 0x000400fau, 0x00000128u, 0x00000122u,
|
||||
0x00000123u, 0x000200f8u, 0x00000122u, 0x0004003du, 0x0000000du, 0x0000012au, 0x000000feu, 0x0004003du,
|
||||
0x00000067u, 0x0000012bu, 0x00000120u, 0x0004006fu, 0x00000006u, 0x0000012cu, 0x0000012bu, 0x0005008eu,
|
||||
0x0000000du, 0x0000012du, 0x0000012au, 0x0000012cu, 0x0003003eu, 0x00000129u, 0x0000012du, 0x0004003du,
|
||||
0x000000f1u, 0x0000012fu, 0x000000fau, 0x000300f7u, 0x00000132u, 0x00000000u, 0x000400fau, 0x0000012fu,
|
||||
0x00000131u, 0x0000013au, 0x000200f8u, 0x00000131u, 0x0004003du, 0x0000000du, 0x00000133u, 0x00000070u,
|
||||
0x0004003du, 0x0000000du, 0x00000134u, 0x00000129u, 0x00050083u, 0x0000000du, 0x00000135u, 0x00000133u,
|
||||
0x00000134u, 0x0003003eu, 0x00000136u, 0x00000135u, 0x0004003du, 0x0000000du, 0x00000138u, 0x00000062u,
|
||||
0x0003003eu, 0x00000137u, 0x00000138u, 0x00060039u, 0x00000006u, 0x00000139u, 0x00000012u, 0x00000136u,
|
||||
0x00000137u, 0x0003003eu, 0x00000130u, 0x00000139u, 0x000200f9u, 0x00000132u, 0x000200f8u, 0x0000013au,
|
||||
0x0004003du, 0x0000000du, 0x0000013bu, 0x00000070u, 0x0004003du, 0x0000000du, 0x0000013cu, 0x00000129u,
|
||||
0x00050083u, 0x0000000du, 0x0000013du, 0x0000013bu, 0x0000013cu, 0x0003003eu, 0x0000013eu, 0x0000013du,
|
||||
0x0004003du, 0x0000000du, 0x00000140u, 0x00000062u, 0x0003003eu, 0x0000013fu, 0x00000140u, 0x00060039u,
|
||||
0x00000006u, 0x00000141u, 0x00000016u, 0x0000013eu, 0x0000013fu, 0x0003003eu, 0x00000130u, 0x00000141u,
|
||||
0x000200f9u, 0x00000132u, 0x000200f8u, 0x00000132u, 0x0004003du, 0x00000006u, 0x00000142u, 0x00000130u,
|
||||
0x0003003eu, 0x0000012eu, 0x00000142u, 0x0004003du, 0x000000f1u, 0x00000144u, 0x000000fau, 0x000300f7u,
|
||||
0x00000147u, 0x00000000u, 0x000400fau, 0x00000144u, 0x00000146u, 0x0000014fu, 0x000200f8u, 0x00000146u,
|
||||
0x0004003du, 0x0000000du, 0x00000148u, 0x00000070u, 0x0004003du, 0x0000000du, 0x00000149u, 0x00000129u,
|
||||
0x00050081u, 0x0000000du, 0x0000014au, 0x00000148u, 0x00000149u, 0x0003003eu, 0x0000014bu, 0x0000014au,
|
||||
0x0004003du, 0x0000000du, 0x0000014du, 0x00000062u, 0x0003003eu, 0x0000014cu, 0x0000014du, 0x00060039u,
|
||||
0x00000006u, 0x0000014eu, 0x00000012u, 0x0000014bu, 0x0000014cu, 0x0003003eu, 0x00000145u, 0x0000014eu,
|
||||
0x000200f9u, 0x00000147u, 0x000200f8u, 0x0000014fu, 0x0004003du, 0x0000000du, 0x00000150u, 0x00000070u,
|
||||
0x0004003du, 0x0000000du, 0x00000151u, 0x00000129u, 0x00050081u, 0x0000000du, 0x00000152u, 0x00000150u,
|
||||
0x00000151u, 0x0003003eu, 0x00000153u, 0x00000152u, 0x0004003du, 0x0000000du, 0x00000155u, 0x00000062u,
|
||||
0x0003003eu, 0x00000154u, 0x00000155u, 0x00060039u, 0x00000006u, 0x00000156u, 0x00000016u, 0x00000153u,
|
||||
0x00000154u, 0x0003003eu, 0x00000145u, 0x00000156u, 0x000200f9u, 0x00000147u, 0x000200f8u, 0x00000147u,
|
||||
0x0004003du, 0x00000006u, 0x00000157u, 0x00000145u, 0x0003003eu, 0x00000143u, 0x00000157u, 0x0004003du,
|
||||
0x00000006u, 0x00000158u, 0x0000011du, 0x0004003du, 0x00000067u, 0x00000159u, 0x00000120u, 0x00050082u,
|
||||
0x00000067u, 0x0000015au, 0x00000159u, 0x00000068u, 0x0004006fu, 0x00000006u, 0x0000015bu, 0x0000015au,
|
||||
0x000500b4u, 0x000000f1u, 0x0000015cu, 0x00000158u, 0x0000015bu, 0x000300f7u, 0x0000015eu, 0x00000000u,
|
||||
0x000400fau, 0x0000015cu, 0x0000015du, 0x0000015eu, 0x000200f8u, 0x0000015du, 0x0004003du, 0x00000006u,
|
||||
0x0000015fu, 0x0000012eu, 0x0004003du, 0x00000006u, 0x00000160u, 0x000000ddu, 0x00050085u, 0x00000006u,
|
||||
0x00000162u, 0x00000160u, 0x00000161u, 0x000500bau, 0x000000f1u, 0x00000163u, 0x0000015fu, 0x00000162u,
|
||||
0x000200f9u, 0x0000015eu, 0x000200f8u, 0x0000015eu, 0x000700f5u, 0x000000f1u, 0x00000164u, 0x0000015cu,
|
||||
0x00000147u, 0x00000163u, 0x0000015du, 0x000300f7u, 0x00000166u, 0x00000000u, 0x000400fau, 0x00000164u,
|
||||
0x00000165u, 0x00000166u, 0x000200f8u, 0x00000165u, 0x0004003du, 0x00000067u, 0x00000167u, 0x00000120u,
|
||||
0x0004006fu, 0x00000006u, 0x00000168u, 0x00000167u, 0x0003003eu, 0x0000011du, 0x00000168u, 0x000200f9u,
|
||||
0x00000166u, 0x000200f8u, 0x00000166u, 0x0004003du, 0x00000006u, 0x00000169u, 0x0000011eu, 0x0004003du,
|
||||
0x00000067u, 0x0000016au, 0x00000120u, 0x00050082u, 0x00000067u, 0x0000016bu, 0x0000016au, 0x00000068u,
|
||||
0x0004006fu, 0x00000006u, 0x0000016cu, 0x0000016bu, 0x000500b4u, 0x000000f1u, 0x0000016du, 0x00000169u,
|
||||
0x0000016cu, 0x000300f7u, 0x0000016fu, 0x00000000u, 0x000400fau, 0x0000016du, 0x0000016eu, 0x0000016fu,
|
||||
0x000200f8u, 0x0000016eu, 0x0004003du, 0x00000006u, 0x00000170u, 0x00000143u, 0x0004003du, 0x00000006u,
|
||||
0x00000171u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000172u, 0x00000171u, 0x00000161u, 0x000500bau,
|
||||
0x000000f1u, 0x00000173u, 0x00000170u, 0x00000172u, 0x000200f9u, 0x0000016fu, 0x000200f8u, 0x0000016fu,
|
||||
0x000700f5u, 0x000000f1u, 0x00000174u, 0x0000016du, 0x00000166u, 0x00000173u, 0x0000016eu, 0x000300f7u,
|
||||
0x00000176u, 0x00000000u, 0x000400fau, 0x00000174u, 0x00000175u, 0x00000176u, 0x000200f8u, 0x00000175u,
|
||||
0x0004003du, 0x00000067u, 0x00000177u, 0x00000120u, 0x0004006fu, 0x00000006u, 0x00000178u, 0x00000177u,
|
||||
0x0003003eu, 0x0000011eu, 0x00000178u, 0x000200f9u, 0x00000176u, 0x000200f8u, 0x00000176u, 0x000200f9u,
|
||||
0x00000124u, 0x000200f8u, 0x00000124u, 0x0004003du, 0x00000067u, 0x00000179u, 0x00000120u, 0x00050080u,
|
||||
0x00000067u, 0x0000017au, 0x00000179u, 0x00000068u, 0x0003003eu, 0x00000120u, 0x0000017au, 0x000200f9u,
|
||||
0x00000121u, 0x000200f8u, 0x00000123u, 0x0004003du, 0x00000006u, 0x0000017cu, 0x0000011du, 0x0004003du,
|
||||
0x00000006u, 0x0000017du, 0x0000011eu, 0x00050081u, 0x00000006u, 0x0000017eu, 0x0000017cu, 0x0000017du,
|
||||
0x0003003eu, 0x0000017bu, 0x0000017eu, 0x0004003du, 0x00000006u, 0x00000180u, 0x000000ddu, 0x0004003du,
|
||||
0x00000006u, 0x00000181u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000183u, 0x00000181u, 0x00000182u,
|
||||
0x0004003du, 0x00000006u, 0x00000184u, 0x000000ebu, 0x0008000cu, 0x00000006u, 0x00000185u, 0x00000001u,
|
||||
0x00000031u, 0x00000180u, 0x00000183u, 0x00000184u, 0x0003003eu, 0x0000017fu, 0x00000185u, 0x0004003du,
|
||||
0x00000023u, 0x00000187u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000188u, 0x00000070u, 0x00050041u,
|
||||
0x00000020u, 0x00000189u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u, 0x0000018au, 0x00000189u,
|
||||
0x0004007fu, 0x00000006u, 0x0000018bu, 0x0000018au, 0x00050041u, 0x00000020u, 0x0000018cu, 0x00000062u,
|
||||
0x00000048u, 0x0004003du, 0x00000006u, 0x0000018du, 0x0000018cu, 0x0004007fu, 0x00000006u, 0x0000018eu,
|
||||
0x0000018du, 0x00050050u, 0x0000000du, 0x0000018fu, 0x0000018bu, 0x0000018eu, 0x00050081u, 0x0000000du,
|
||||
0x00000190u, 0x00000188u, 0x0000018fu, 0x00050057u, 0x0000002fu, 0x00000191u, 0x00000187u, 0x00000190u,
|
||||
0x0008004fu, 0x00000007u, 0x00000193u, 0x00000191u, 0x00000191u, 0x00000000u, 0x00000001u, 0x00000002u,
|
||||
0x0003003eu, 0x00000192u, 0x00000193u, 0x00050039u, 0x00000006u, 0x00000194u, 0x0000000bu, 0x00000192u,
|
||||
0x0003003eu, 0x00000186u, 0x00000194u, 0x0004003du, 0x00000023u, 0x00000196u, 0x00000025u, 0x0004003du,
|
||||
0x0000000du, 0x00000197u, 0x00000070u, 0x00050041u, 0x00000020u, 0x00000198u, 0x00000062u, 0x00000029u,
|
||||
0x0004003du, 0x00000006u, 0x00000199u, 0x00000198u, 0x00050041u, 0x00000020u, 0x0000019au, 0x00000062u,
|
||||
0x00000048u, 0x0004003du, 0x00000006u, 0x0000019bu, 0x0000019au, 0x0004007fu, 0x00000006u, 0x0000019cu,
|
||||
0x0000019bu, 0x00050050u, 0x0000000du, 0x0000019du, 0x00000199u, 0x0000019cu, 0x00050081u, 0x0000000du,
|
||||
0x0000019eu, 0x00000197u, 0x0000019du, 0x00050057u, 0x0000002fu, 0x0000019fu, 0x00000196u, 0x0000019eu,
|
||||
0x0008004fu, 0x00000007u, 0x000001a1u, 0x0000019fu, 0x0000019fu, 0x00000000u, 0x00000001u, 0x00000002u,
|
||||
0x0003003eu, 0x000001a0u, 0x000001a1u, 0x00050039u, 0x00000006u, 0x000001a2u, 0x0000000bu, 0x000001a0u,
|
||||
0x0003003eu, 0x00000195u, 0x000001a2u, 0x0004003du, 0x00000023u, 0x000001a4u, 0x00000025u, 0x0004003du,
|
||||
0x0000000du, 0x000001a5u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000001a6u, 0x00000062u, 0x00000029u,
|
||||
0x0004003du, 0x00000006u, 0x000001a7u, 0x000001a6u, 0x0004007fu, 0x00000006u, 0x000001a8u, 0x000001a7u,
|
||||
0x00050041u, 0x00000020u, 0x000001a9u, 0x00000062u, 0x00000048u, 0x0004003du, 0x00000006u, 0x000001aau,
|
||||
0x000001a9u, 0x00050050u, 0x0000000du, 0x000001abu, 0x000001a8u, 0x000001aau, 0x00050081u, 0x0000000du,
|
||||
0x000001acu, 0x000001a5u, 0x000001abu, 0x00050057u, 0x0000002fu, 0x000001adu, 0x000001a4u, 0x000001acu,
|
||||
0x0008004fu, 0x00000007u, 0x000001afu, 0x000001adu, 0x000001adu, 0x00000000u, 0x00000001u, 0x00000002u,
|
||||
0x0003003eu, 0x000001aeu, 0x000001afu, 0x00050039u, 0x00000006u, 0x000001b0u, 0x0000000bu, 0x000001aeu,
|
||||
0x0003003eu, 0x000001a3u, 0x000001b0u, 0x0004003du, 0x00000023u, 0x000001b2u, 0x00000025u, 0x0004003du,
|
||||
0x0000000du, 0x000001b3u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000001b4u, 0x00000062u, 0x00000029u,
|
||||
0x0004003du, 0x00000006u, 0x000001b5u, 0x000001b4u, 0x00050041u, 0x00000020u, 0x000001b6u, 0x00000062u,
|
||||
0x00000048u, 0x0004003du, 0x00000006u, 0x000001b7u, 0x000001b6u, 0x00050050u, 0x0000000du, 0x000001b8u,
|
||||
0x000001b5u, 0x000001b7u, 0x00050081u, 0x0000000du, 0x000001b9u, 0x000001b3u, 0x000001b8u, 0x00050057u,
|
||||
0x0000002fu, 0x000001bau, 0x000001b2u, 0x000001b9u, 0x0008004fu, 0x00000007u, 0x000001bcu, 0x000001bau,
|
||||
0x000001bau, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x000001bbu, 0x000001bcu, 0x00050039u,
|
||||
0x00000006u, 0x000001bdu, 0x0000000bu, 0x000001bbu, 0x0003003eu, 0x000001b1u, 0x000001bdu, 0x0004003du,
|
||||
0x00000006u, 0x000001bfu, 0x0000011du, 0x0004003du, 0x00000006u, 0x000001c0u, 0x0000011eu, 0x00050083u,
|
||||
0x00000006u, 0x000001c1u, 0x000001bfu, 0x000001c0u, 0x0006000cu, 0x00000006u, 0x000001c2u, 0x00000001u,
|
||||
0x00000004u, 0x000001c1u, 0x0004003du, 0x00000006u, 0x000001c3u, 0x0000017bu, 0x0007000cu, 0x00000006u,
|
||||
0x000001c4u, 0x00000001u, 0x00000028u, 0x000001c3u, 0x00000063u, 0x00050088u, 0x00000006u, 0x000001c5u,
|
||||
0x000001c2u, 0x000001c4u, 0x0008000cu, 0x00000006u, 0x000001c6u, 0x00000001u, 0x0000002bu, 0x000001c5u,
|
||||
0x0000002cu, 0x00000063u, 0x0003003eu, 0x000001beu, 0x000001c6u, 0x0004003du, 0x00000006u, 0x000001c8u,
|
||||
0x000001beu, 0x0004003du, 0x00000006u, 0x000001c9u, 0x0000017bu, 0x00050085u, 0x00000006u, 0x000001cbu,
|
||||
0x000001c9u, 0x000001cau, 0x00050081u, 0x00000006u, 0x000001ccu, 0x00000063u, 0x000001cbu, 0x00050088u,
|
||||
0x00000006u, 0x000001cdu, 0x000001c8u, 0x000001ccu, 0x0003003eu, 0x000001c7u, 0x000001cdu, 0x0004003du,
|
||||
0x000000f1u, 0x000001cfu, 0x000000fau, 0x000300f7u, 0x000001d2u, 0x00000000u, 0x000400fau, 0x000001cfu,
|
||||
0x000001d1u, 0x000001d7u, 0x000200f8u, 0x000001d1u, 0x0004003du, 0x00000006u, 0x000001d3u, 0x00000186u,
|
||||
0x0004003du, 0x00000006u, 0x000001d4u, 0x00000195u, 0x00050083u, 0x00000006u, 0x000001d5u, 0x000001d3u,
|
||||
0x000001d4u, 0x0006000cu, 0x00000006u, 0x000001d6u, 0x00000001u, 0x00000004u, 0x000001d5u, 0x0003003eu,
|
||||
0x000001d0u, 0x000001d6u, 0x000200f9u, 0x000001d2u, 0x000200f8u, 0x000001d7u, 0x0004003du, 0x00000006u,
|
||||
0x000001d8u, 0x00000186u, 0x0004003du, 0x00000006u, 0x000001d9u, 0x000001a3u, 0x00050083u, 0x00000006u,
|
||||
0x000001dau, 0x000001d8u, 0x000001d9u, 0x0006000cu, 0x00000006u, 0x000001dbu, 0x00000001u, 0x00000004u,
|
||||
0x000001dau, 0x0003003eu, 0x000001d0u, 0x000001dbu, 0x000200f9u, 0x000001d2u, 0x000200f8u, 0x000001d2u,
|
||||
0x0004003du, 0x00000006u, 0x000001dcu, 0x000001d0u, 0x0003003eu, 0x000001ceu, 0x000001dcu, 0x0004003du,
|
||||
0x000000f1u, 0x000001deu, 0x000000fau, 0x000300f7u, 0x000001e1u, 0x00000000u, 0x000400fau, 0x000001deu,
|
||||
0x000001e0u, 0x000001e6u, 0x000200f8u, 0x000001e0u, 0x0004003du, 0x00000006u, 0x000001e2u, 0x000001a3u,
|
||||
0x0004003du, 0x00000006u, 0x000001e3u, 0x000001b1u, 0x00050083u, 0x00000006u, 0x000001e4u, 0x000001e2u,
|
||||
0x000001e3u, 0x0006000cu, 0x00000006u, 0x000001e5u, 0x00000001u, 0x00000004u, 0x000001e4u, 0x0003003eu,
|
||||
0x000001dfu, 0x000001e5u, 0x000200f9u, 0x000001e1u, 0x000200f8u, 0x000001e6u, 0x0004003du, 0x00000006u,
|
||||
0x000001e7u, 0x00000195u, 0x0004003du, 0x00000006u, 0x000001e8u, 0x000001b1u, 0x00050083u, 0x00000006u,
|
||||
0x000001e9u, 0x000001e7u, 0x000001e8u, 0x0006000cu, 0x00000006u, 0x000001eau, 0x00000001u, 0x00000004u,
|
||||
0x000001e9u, 0x0003003eu, 0x000001dfu, 0x000001eau, 0x000200f9u, 0x000001e1u, 0x000200f8u, 0x000001e1u,
|
||||
0x0004003du, 0x00000006u, 0x000001ebu, 0x000001dfu, 0x0003003eu, 0x000001ddu, 0x000001ebu, 0x0004003du,
|
||||
0x00000006u, 0x000001edu, 0x000001ceu, 0x0004003du, 0x00000006u, 0x000001eeu, 0x000001ddu, 0x00050083u,
|
||||
0x00000006u, 0x000001efu, 0x000001edu, 0x000001eeu, 0x0006000cu, 0x00000006u, 0x000001f0u, 0x00000001u,
|
||||
0x00000004u, 0x000001efu, 0x0003003eu, 0x000001ecu, 0x000001f0u, 0x0004003du, 0x00000006u, 0x000001f2u,
|
||||
0x000000ddu, 0x0004003du, 0x00000006u, 0x000001f3u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x000001f4u,
|
||||
0x000001f3u, 0x00000182u, 0x0004003du, 0x00000006u, 0x000001f5u, 0x000001ecu, 0x0008000cu, 0x00000006u,
|
||||
0x000001f6u, 0x00000001u, 0x00000031u, 0x000001f2u, 0x000001f4u, 0x000001f5u, 0x0003003eu, 0x000001f1u,
|
||||
0x000001f6u, 0x0004003du, 0x00000006u, 0x000001f9u, 0x000001f1u, 0x00050085u, 0x00000006u, 0x000001fau,
|
||||
0x000001f8u, 0x000001f9u, 0x0004003du, 0x00000006u, 0x000001fbu, 0x0000017bu, 0x00050088u, 0x00000006u,
|
||||
0x000001fdu, 0x000001fbu, 0x000001fcu, 0x0008000cu, 0x00000006u, 0x000001feu, 0x00000001u, 0x0000002bu,
|
||||
0x000001fdu, 0x0000002cu, 0x00000063u, 0x00050085u, 0x00000006u, 0x000001ffu, 0x000001fau, 0x000001feu,
|
||||
0x0003003eu, 0x000001f7u, 0x000001ffu, 0x0004003du, 0x00000006u, 0x00000201u, 0x00000186u, 0x0004003du,
|
||||
0x00000006u, 0x00000202u, 0x000001b1u, 0x00050083u, 0x00000006u, 0x00000203u, 0x00000201u, 0x00000202u,
|
||||
0x0006000cu, 0x00000006u, 0x00000204u, 0x00000001u, 0x00000004u, 0x00000203u, 0x0004003du, 0x00000006u,
|
||||
0x00000205u, 0x00000195u, 0x0004003du, 0x00000006u, 0x00000206u, 0x000001a3u, 0x00050083u, 0x00000006u,
|
||||
0x00000207u, 0x00000205u, 0x00000206u, 0x0006000cu, 0x00000006u, 0x00000208u, 0x00000001u, 0x00000004u,
|
||||
0x00000207u, 0x0007000cu, 0x00000006u, 0x00000209u, 0x00000001u, 0x00000028u, 0x00000204u, 0x00000208u,
|
||||
0x0003003eu, 0x00000200u, 0x00000209u, 0x0004003du, 0x00000006u, 0x0000020cu, 0x000000ddu, 0x0004003du,
|
||||
0x00000006u, 0x0000020du, 0x000000ddu, 0x00050085u, 0x00000006u, 0x0000020fu, 0x0000020du, 0x0000020eu,
|
||||
0x0004003du, 0x00000006u, 0x00000210u, 0x00000200u, 0x0008000cu, 0x00000006u, 0x00000211u, 0x00000001u,
|
||||
0x00000031u, 0x0000020cu, 0x0000020fu, 0x00000210u, 0x00050085u, 0x00000006u, 0x00000212u, 0x0000020bu,
|
||||
0x00000211u, 0x00050083u, 0x00000006u, 0x00000213u, 0x00000063u, 0x00000212u, 0x0003003eu, 0x0000020au,
|
||||
0x00000213u, 0x0004003du, 0x00000006u, 0x00000215u, 0x000001f7u, 0x0004003du, 0x00000006u, 0x00000216u,
|
||||
0x000001c7u, 0x00050085u, 0x00000006u, 0x00000217u, 0x00000215u, 0x00000216u, 0x0004003du, 0x00000006u,
|
||||
0x00000218u, 0x0000017fu, 0x00050085u, 0x00000006u, 0x00000219u, 0x00000217u, 0x00000218u, 0x0004003du,
|
||||
0x00000006u, 0x0000021au, 0x0000020au, 0x00050085u, 0x00000006u, 0x0000021bu, 0x00000219u, 0x0000021au,
|
||||
0x0003003eu, 0x00000214u, 0x0000021bu, 0x0004003du, 0x00000006u, 0x0000021du, 0x000000e3u, 0x0004003du,
|
||||
0x00000006u, 0x0000021eu, 0x000000e7u, 0x0007000cu, 0x00000006u, 0x0000021fu, 0x00000001u, 0x00000025u,
|
||||
0x0000021du, 0x0000021eu, 0x0003003eu, 0x0000021cu, 0x0000021fu, 0x0004003du, 0x00000006u, 0x00000221u,
|
||||
0x000000ddu, 0x0004003du, 0x00000006u, 0x00000222u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000223u,
|
||||
0x00000222u, 0x00000182u, 0x0004003du, 0x00000006u, 0x00000224u, 0x0000021cu, 0x0008000cu, 0x00000006u,
|
||||
0x00000225u, 0x00000001u, 0x00000031u, 0x00000221u, 0x00000223u, 0x00000224u, 0x0003003eu, 0x00000220u,
|
||||
0x00000225u, 0x0004003du, 0x00000006u, 0x00000227u, 0x0000017bu, 0x0008000cu, 0x00000006u, 0x00000228u,
|
||||
0x00000001u, 0x00000031u, 0x00000063u, 0x0000020eu, 0x00000227u, 0x0003003eu, 0x00000226u, 0x00000228u,
|
||||
0x0004003du, 0x00000006u, 0x0000022bu, 0x00000220u, 0x00050085u, 0x00000006u, 0x0000022cu, 0x0000022au,
|
||||
0x0000022bu, 0x0004003du, 0x00000006u, 0x0000022du, 0x0000017fu, 0x00050085u, 0x00000006u, 0x0000022eu,
|
||||
0x0000022cu, 0x0000022du, 0x0004003du, 0x00000006u, 0x0000022fu, 0x0000020au, 0x00050085u, 0x00000006u,
|
||||
0x00000230u, 0x0000022eu, 0x0000022fu, 0x0004003du, 0x00000006u, 0x00000231u, 0x00000226u, 0x00050085u,
|
||||
0x00000006u, 0x00000232u, 0x00000230u, 0x00000231u, 0x0004003du, 0x00000006u, 0x00000233u, 0x000001f1u,
|
||||
0x00050085u, 0x00000006u, 0x00000234u, 0x00000232u, 0x00000233u, 0x0003003eu, 0x00000229u, 0x00000234u,
|
||||
0x0004003du, 0x00000006u, 0x00000236u, 0x00000214u, 0x0004003du, 0x00000006u, 0x00000237u, 0x00000229u,
|
||||
0x0007000cu, 0x00000006u, 0x00000238u, 0x00000001u, 0x00000028u, 0x00000236u, 0x00000237u, 0x0008000cu,
|
||||
0x00000006u, 0x0000023au, 0x00000001u, 0x0000002bu, 0x00000238u, 0x0000002cu, 0x00000239u, 0x0003003eu,
|
||||
0x00000235u, 0x0000023au, 0x0004003du, 0x00000023u, 0x0000023cu, 0x00000025u, 0x0004003du, 0x0000000du,
|
||||
0x0000023du, 0x00000070u, 0x0004003du, 0x0000000du, 0x0000023eu, 0x0000010bu, 0x0004003du, 0x0000000du,
|
||||
0x0000023fu, 0x00000062u, 0x00050085u, 0x0000000du, 0x00000240u, 0x0000023eu, 0x0000023fu, 0x00050081u,
|
||||
0x0000000du, 0x00000241u, 0x0000023du, 0x00000240u, 0x00050057u, 0x0000002fu, 0x00000242u, 0x0000023cu,
|
||||
0x00000241u, 0x0008004fu, 0x00000007u, 0x00000243u, 0x00000242u, 0x00000242u, 0x00000000u, 0x00000001u,
|
||||
0x00000002u, 0x0003003eu, 0x0000023bu, 0x00000243u, 0x0004003du, 0x0000002fu, 0x00000244u, 0x0000007cu,
|
||||
0x0008004fu, 0x00000007u, 0x00000245u, 0x00000244u, 0x00000244u, 0x00000000u, 0x00000001u, 0x00000002u,
|
||||
0x0004003du, 0x00000007u, 0x00000246u, 0x0000023bu, 0x0004003du, 0x00000006u, 0x00000247u, 0x00000235u,
|
||||
0x00060050u, 0x00000007u, 0x00000248u, 0x00000247u, 0x00000247u, 0x00000247u, 0x0008000cu, 0x00000007u,
|
||||
0x00000249u, 0x00000001u, 0x0000002eu, 0x00000245u, 0x00000246u, 0x00000248u, 0x00050041u, 0x00000020u,
|
||||
0x0000024bu, 0x0000007cu, 0x0000024au, 0x0004003du, 0x00000006u, 0x0000024cu, 0x0000024bu, 0x00050051u,
|
||||
0x00000006u, 0x0000024du, 0x00000249u, 0x00000000u, 0x00050051u, 0x00000006u, 0x0000024eu, 0x00000249u,
|
||||
0x00000001u, 0x00050051u, 0x00000006u, 0x0000024fu, 0x00000249u, 0x00000002u, 0x00070050u, 0x0000002fu,
|
||||
0x00000250u, 0x0000024du, 0x0000024eu, 0x0000024fu, 0x0000024cu, 0x0003003eu, 0x000000f6u, 0x00000250u,
|
||||
0x000100fdu, 0x00010038u, 0x00050036u, 0x00000006u, 0x0000000bu, 0x00000000u, 0x00000009u, 0x00030037u,
|
||||
0x00000008u, 0x0000000au, 0x000200f8u, 0x0000000cu, 0x0004003du, 0x00000007u, 0x00000018u, 0x0000000au,
|
||||
0x00050094u, 0x00000006u, 0x0000001du, 0x00000018u, 0x0000001cu, 0x000200feu, 0x0000001du, 0x00010038u,
|
||||
0x00050036u, 0x00000006u, 0x00000012u, 0x00000000u, 0x0000000fu, 0x00030037u, 0x0000000eu, 0x00000010u,
|
||||
0x00030037u, 0x0000000eu, 0x00000011u, 0x000200f8u, 0x00000013u, 0x0004003bu, 0x00000020u, 0x00000021u,
|
||||
0x00000007u, 0x0004003bu, 0x00000008u, 0x00000031u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000034u,
|
||||
0x00000007u, 0x0004003bu, 0x00000008u, 0x0000003cu, 0x00000007u, 0x0004003du, 0x00000023u, 0x00000026u,
|
||||
0x00000025u, 0x0004003du, 0x0000000du, 0x00000027u, 0x00000010u, 0x00050041u, 0x00000020u, 0x0000002au,
|
||||
0x00000011u, 0x00000029u, 0x0004003du, 0x00000006u, 0x0000002bu, 0x0000002au, 0x00050050u, 0x0000000du,
|
||||
0x0000002du, 0x0000002bu, 0x0000002cu, 0x00050083u, 0x0000000du, 0x0000002eu, 0x00000027u, 0x0000002du,
|
||||
0x00050057u, 0x0000002fu, 0x00000030u, 0x00000026u, 0x0000002eu, 0x0008004fu, 0x00000007u, 0x00000032u,
|
||||
0x00000030u, 0x00000030u, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x00000031u, 0x00000032u,
|
||||
0x00050039u, 0x00000006u, 0x00000033u, 0x0000000bu, 0x00000031u, 0x0003003eu, 0x00000021u, 0x00000033u,
|
||||
0x0004003du, 0x00000023u, 0x00000035u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000036u, 0x00000010u,
|
||||
0x00050041u, 0x00000020u, 0x00000037u, 0x00000011u, 0x00000029u, 0x0004003du, 0x00000006u, 0x00000038u,
|
||||
0x00000037u, 0x00050050u, 0x0000000du, 0x00000039u, 0x00000038u, 0x0000002cu, 0x00050081u, 0x0000000du,
|
||||
0x0000003au, 0x00000036u, 0x00000039u, 0x00050057u, 0x0000002fu, 0x0000003bu, 0x00000035u, 0x0000003au,
|
||||
0x0008004fu, 0x00000007u, 0x0000003du, 0x0000003bu, 0x0000003bu, 0x00000000u, 0x00000001u, 0x00000002u,
|
||||
0x0003003eu, 0x0000003cu, 0x0000003du, 0x00050039u, 0x00000006u, 0x0000003eu, 0x0000000bu, 0x0000003cu,
|
||||
0x0003003eu, 0x00000034u, 0x0000003eu, 0x0004003du, 0x00000006u, 0x0000003fu, 0x00000021u, 0x0004003du,
|
||||
0x00000006u, 0x00000040u, 0x00000034u, 0x00050083u, 0x00000006u, 0x00000041u, 0x0000003fu, 0x00000040u,
|
||||
0x0006000cu, 0x00000006u, 0x00000042u, 0x00000001u, 0x00000004u, 0x00000041u, 0x000200feu, 0x00000042u,
|
||||
0x00010038u, 0x00050036u, 0x00000006u, 0x00000016u, 0x00000000u, 0x0000000fu, 0x00030037u, 0x0000000eu,
|
||||
0x00000014u, 0x00030037u, 0x0000000eu, 0x00000015u, 0x000200f8u, 0x00000017u, 0x0004003bu, 0x00000020u,
|
||||
0x00000045u, 0x00000007u, 0x0004003bu, 0x00000008u, 0x0000004eu, 0x00000007u, 0x0004003bu, 0x00000020u,
|
||||
0x00000051u, 0x00000007u, 0x0004003bu, 0x00000008u, 0x00000059u, 0x00000007u, 0x0004003du, 0x00000023u,
|
||||
0x00000046u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000047u, 0x00000014u, 0x00050041u, 0x00000020u,
|
||||
0x00000049u, 0x00000015u, 0x00000048u, 0x0004003du, 0x00000006u, 0x0000004au, 0x00000049u, 0x00050050u,
|
||||
0x0000000du, 0x0000004bu, 0x0000002cu, 0x0000004au, 0x00050083u, 0x0000000du, 0x0000004cu, 0x00000047u,
|
||||
0x0000004bu, 0x00050057u, 0x0000002fu, 0x0000004du, 0x00000046u, 0x0000004cu, 0x0008004fu, 0x00000007u,
|
||||
0x0000004fu, 0x0000004du, 0x0000004du, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x0000004eu,
|
||||
0x0000004fu, 0x00050039u, 0x00000006u, 0x00000050u, 0x0000000bu, 0x0000004eu, 0x0003003eu, 0x00000045u,
|
||||
0x00000050u, 0x0004003du, 0x00000023u, 0x00000052u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000053u,
|
||||
0x00000014u, 0x00050041u, 0x00000020u, 0x00000054u, 0x00000015u, 0x00000048u, 0x0004003du, 0x00000006u,
|
||||
0x00000055u, 0x00000054u, 0x00050050u, 0x0000000du, 0x00000056u, 0x0000002cu, 0x00000055u, 0x00050081u,
|
||||
0x0000000du, 0x00000057u, 0x00000053u, 0x00000056u, 0x00050057u, 0x0000002fu, 0x00000058u, 0x00000052u,
|
||||
0x00000057u, 0x0008004fu, 0x00000007u, 0x0000005au, 0x00000058u, 0x00000058u, 0x00000000u, 0x00000001u,
|
||||
0x00000002u, 0x0003003eu, 0x00000059u, 0x0000005au, 0x00050039u, 0x00000006u, 0x0000005bu, 0x0000000bu,
|
||||
0x00000059u, 0x0003003eu, 0x00000051u, 0x0000005bu, 0x0004003du, 0x00000006u, 0x0000005cu, 0x00000045u,
|
||||
0x0004003du, 0x00000006u, 0x0000005du, 0x00000051u, 0x00050083u, 0x00000006u, 0x0000005eu, 0x0000005cu,
|
||||
0x0000005du, 0x0006000cu, 0x00000006u, 0x0000005fu, 0x00000001u, 0x00000004u, 0x0000005eu, 0x000200feu,
|
||||
0x0000005fu, 0x00010038u,
|
||||
};
|
||||
@@ -26,7 +26,7 @@ add_library(droiddeckwayland SHARED
|
||||
generated/linux-dmabuf-v1-protocol.c
|
||||
generated/wayland-android-protocol.c
|
||||
generated/viewporter-protocol.c
|
||||
generated/banner-desktop-v1-protocol.c
|
||||
generated/droiddeck-desktop-v1-protocol.c
|
||||
generated/presentation-time-protocol.c
|
||||
generated/pointer-constraints-unstable-v1-protocol.c
|
||||
generated/relative-pointer-unstable-v1-protocol.c
|
||||
|
||||
+9
-9
@@ -38,7 +38,7 @@
|
||||
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
|
||||
static const struct wl_interface *banner_desktop_v1_types[] = {
|
||||
static const struct wl_interface *droiddeck_desktop_v1_types[] = {
|
||||
NULL,
|
||||
&wl_surface_interface,
|
||||
&wl_surface_interface,
|
||||
@@ -47,16 +47,16 @@ static const struct wl_interface *banner_desktop_v1_types[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message banner_desktop_v1_requests[] = {
|
||||
{ "destroy", "", banner_desktop_v1_types + 0 },
|
||||
{ "set_desktop", "o", banner_desktop_v1_types + 1 },
|
||||
{ "set_window", "ouii", banner_desktop_v1_types + 2 },
|
||||
{ "set_zorder", "a", banner_desktop_v1_types + 0 },
|
||||
static const struct wl_message droiddeck_desktop_v1_requests[] = {
|
||||
{ "destroy", "", droiddeck_desktop_v1_types + 0 },
|
||||
{ "set_desktop", "o", droiddeck_desktop_v1_types + 1 },
|
||||
{ "set_window", "ouii", droiddeck_desktop_v1_types + 2 },
|
||||
{ "set_zorder", "a", droiddeck_desktop_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface banner_desktop_v1_interface = {
|
||||
"banner_desktop_v1", 1,
|
||||
4, banner_desktop_v1_requests,
|
||||
WL_PRIVATE const struct wl_interface droiddeck_desktop_v1_interface = {
|
||||
"droiddeck_desktop_v1", 1,
|
||||
4, droiddeck_desktop_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
+12
-12
@@ -1,6 +1,6 @@
|
||||
|
||||
#ifndef BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
|
||||
#define BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
|
||||
#ifndef DROIDDECK_DESKTOP_V1_SERVER_PROTOCOL_H
|
||||
#define DROIDDECK_DESKTOP_V1_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
@@ -14,7 +14,7 @@ struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/*
|
||||
* @section page_copyright_banner_desktop_v1 Copyright
|
||||
* @section page_copyright_droiddeck_desktop_v1 Copyright
|
||||
*
|
||||
* Copyright 2026 The412Banner
|
||||
*
|
||||
@@ -42,15 +42,15 @@ struct wl_resource;
|
||||
|
||||
|
||||
|
||||
struct banner_desktop_v1;
|
||||
struct droiddeck_desktop_v1;
|
||||
struct wl_surface;
|
||||
|
||||
#ifndef BANNER_DESKTOP_V1_INTERFACE
|
||||
#define BANNER_DESKTOP_V1_INTERFACE
|
||||
extern const struct wl_interface banner_desktop_v1_interface;
|
||||
#ifndef DROIDDECK_DESKTOP_V1_INTERFACE
|
||||
#define DROIDDECK_DESKTOP_V1_INTERFACE
|
||||
extern const struct wl_interface droiddeck_desktop_v1_interface;
|
||||
#endif
|
||||
|
||||
struct banner_desktop_v1_interface {
|
||||
struct droiddeck_desktop_v1_interface {
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
void (*set_desktop)(struct wl_client *client,
|
||||
@@ -68,10 +68,10 @@ struct banner_desktop_v1_interface {
|
||||
};
|
||||
|
||||
|
||||
#define BANNER_DESKTOP_V1_DESTROY_SINCE_VERSION 1
|
||||
#define BANNER_DESKTOP_V1_SET_DESKTOP_SINCE_VERSION 1
|
||||
#define BANNER_DESKTOP_V1_SET_WINDOW_SINCE_VERSION 1
|
||||
#define BANNER_DESKTOP_V1_SET_ZORDER_SINCE_VERSION 1
|
||||
#define DROIDDECK_DESKTOP_V1_DESTROY_SINCE_VERSION 1
|
||||
#define DROIDDECK_DESKTOP_V1_SET_DESKTOP_SINCE_VERSION 1
|
||||
#define DROIDDECK_DESKTOP_V1_SET_WINDOW_SINCE_VERSION 1
|
||||
#define DROIDDECK_DESKTOP_V1_SET_ZORDER_SINCE_VERSION 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="banner_desktop_v1">
|
||||
<protocol name="droiddeck_desktop_v1">
|
||||
<copyright>
|
||||
Copyright 2026 The412Banner
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="banner_desktop_v1" version="1">
|
||||
<interface name="droiddeck_desktop_v1" version="1">
|
||||
<description summary="Windows virtual desktop layout">
|
||||
Each Wine process is a separate Wayland client, so a Windows virtual
|
||||
desktop can't be built from subsurfaces. Instead the process that owns
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "sc_layer.h"
|
||||
#include "ahb_swapchain.h"
|
||||
#include "viewporter-server-protocol.h"
|
||||
#include "banner-desktop-v1-server-protocol.h"
|
||||
#include "droiddeck-desktop-v1-server-protocol.h"
|
||||
#include "presentation-time-server-protocol.h"
|
||||
#include "pointer-constraints-unstable-v1-server-protocol.h"
|
||||
#include "relative-pointer-unstable-v1-server-protocol.h"
|
||||
@@ -79,7 +79,7 @@ static void open_session_log(void) {
|
||||
|
||||
localtime_r(&now, &tm);
|
||||
strftime(stamp, sizeof(stamp), "%Y-%m-%d_%H-%M-%S", &tm);
|
||||
const char *given = getenv("BL_WAYLAND_LOG");
|
||||
const char *given = getenv("DD_WAYLAND_LOG");
|
||||
if (given && *given) {
|
||||
snprintf(path, sizeof(path), "%s", given);
|
||||
} else {
|
||||
@@ -256,6 +256,7 @@ struct surface {
|
||||
struct wl_list child_link;
|
||||
int sub_x, sub_y, sub_pending_x, sub_pending_y, sub_pending;
|
||||
int below_parent;
|
||||
int sub_desync;
|
||||
int fullscreen;
|
||||
int toplevel_committed;
|
||||
|
||||
@@ -332,6 +333,7 @@ struct pending_release {
|
||||
struct wl_resource *buffer;
|
||||
struct wl_listener destroy;
|
||||
struct surface *surface;
|
||||
struct surface *held_by;
|
||||
int64_t at_ns;
|
||||
int64_t since_ns;
|
||||
struct wl_list link;
|
||||
@@ -434,10 +436,54 @@ static void pending_release_free(struct pending_release *pr) {
|
||||
free(pr);
|
||||
}
|
||||
|
||||
static void release_due_buffers(void);
|
||||
static void arm_release_timer(void);
|
||||
|
||||
static void pending_releases_forget_surface(struct surface *s) {
|
||||
struct pending_release *pr;
|
||||
wl_list_for_each(pr, &g_pending_releases, link)
|
||||
int unheld = 0;
|
||||
wl_list_for_each(pr, &g_pending_releases, link) {
|
||||
if (pr->surface == s) pr->surface = NULL;
|
||||
if (pr->held_by == s) { pr->held_by = NULL; unheld = 1; }
|
||||
}
|
||||
if (unheld) { release_due_buffers(); arm_release_timer(); }
|
||||
}
|
||||
|
||||
static void pending_releases_cancel(struct wl_resource *buffer) {
|
||||
struct pending_release *pr, *tmp;
|
||||
wl_list_for_each_safe(pr, tmp, &g_pending_releases, link)
|
||||
if (pr->buffer == buffer) pending_release_free(pr);
|
||||
}
|
||||
|
||||
static void pending_releases_apply(struct surface *holder) {
|
||||
struct pending_release *pr;
|
||||
int unheld = 0;
|
||||
wl_list_for_each(pr, &g_pending_releases, link)
|
||||
if (pr->held_by == holder) { pr->held_by = NULL; unheld = 1; }
|
||||
if (unheld) { release_due_buffers(); arm_release_timer(); }
|
||||
}
|
||||
|
||||
static struct surface *sync_holder(struct surface *s) {
|
||||
struct surface *holder = NULL;
|
||||
for (int depth = 0; s && s->role == ROLE_SUBSURFACE && s->parent && depth < 8; depth++) {
|
||||
if (!s->sub_desync) holder = s->parent;
|
||||
s = s->parent;
|
||||
}
|
||||
return holder;
|
||||
}
|
||||
|
||||
static void pending_releases_rehold(struct surface *changed) {
|
||||
struct pending_release *pr;
|
||||
int unheld = 0;
|
||||
wl_list_for_each(pr, &g_pending_releases, link) {
|
||||
if (!pr->held_by || !pr->surface) continue;
|
||||
struct surface *s = pr->surface;
|
||||
for (int depth = 0; s && s != changed && depth < 8; depth++) s = s->parent;
|
||||
if (s != changed) continue;
|
||||
pr->held_by = sync_holder(pr->surface);
|
||||
if (!pr->held_by) unheld = 1;
|
||||
}
|
||||
if (unheld) { release_due_buffers(); arm_release_timer(); }
|
||||
}
|
||||
|
||||
static void on_pending_release_buffer_destroyed(struct wl_listener *l, void *data) {
|
||||
@@ -450,20 +496,18 @@ static void arm_release_timer(void) {
|
||||
int64_t earliest = 0;
|
||||
if (g_release_timer_fd < 0) return;
|
||||
wl_list_for_each(pr, &g_pending_releases, link)
|
||||
if (!buffer_release_blocked(pr->buffer) && (!earliest || pr->at_ns < earliest))
|
||||
if (!pr->held_by && !buffer_release_blocked(pr->buffer) && (!earliest || pr->at_ns < earliest))
|
||||
earliest = pr->at_ns;
|
||||
struct itimerspec its = {0};
|
||||
if (earliest) { its.it_value.tv_sec = earliest / 1000000000LL; its.it_value.tv_nsec = earliest % 1000000000LL; }
|
||||
timerfd_settime(g_release_timer_fd, TFD_TIMER_ABSTIME, &its, NULL);
|
||||
}
|
||||
|
||||
static int on_release_timer(int fd, uint32_t mask, void *data) {
|
||||
static void release_due_buffers(void) {
|
||||
struct pending_release *pr, *tmp;
|
||||
uint64_t expirations;
|
||||
int64_t now = now_ns() + 300000;
|
||||
if (read(fd, &expirations, sizeof(expirations)) < 0 && errno != EAGAIN) return 0;
|
||||
wl_list_for_each_safe(pr, tmp, &g_pending_releases, link) {
|
||||
if (pr->at_ns <= now && !buffer_release_blocked(pr->buffer)) {
|
||||
if (!pr->held_by && pr->at_ns <= now && !buffer_release_blocked(pr->buffer)) {
|
||||
/* Attached again since (to its surface or another): that surface releases it later. */
|
||||
if (buffer_shown_elsewhere(pr->buffer, NULL)) {
|
||||
pending_release_free(pr);
|
||||
@@ -474,28 +518,39 @@ static int on_release_timer(int fd, uint32_t mask, void *data) {
|
||||
pending_release_free(pr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int on_release_timer(int fd, uint32_t mask, void *data) {
|
||||
uint64_t expirations;
|
||||
if (read(fd, &expirations, sizeof(expirations)) < 0 && errno != EAGAIN) return 0;
|
||||
release_due_buffers();
|
||||
wl_display_flush_clients(g_display);
|
||||
arm_release_timer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void release_buffer(struct surface *s, struct wl_resource *buffer, int64_t since_ns) {
|
||||
static void release_buffer(struct surface *s, struct wl_resource *buffer, int64_t since_ns, struct surface *holder) {
|
||||
/* No allocation or immediate-release fallback is allowed for a quarantined
|
||||
* DMA-BUF. Existing queued releases stay held; their timer is disarmed. */
|
||||
if (buffer_release_blocked(buffer)) return;
|
||||
const int limit = g_fps_limit;
|
||||
const int64_t interval = limit > 0 ? 1000000000LL / limit : g_refresh_ns;
|
||||
if (g_release_unpaced || interval <= 0 || g_release_timer_fd < 0) { send_buffer_release(buffer); perf_note_release(since_ns); return; }
|
||||
const int paced = !g_release_unpaced && interval > 0 && g_release_timer_fd >= 0;
|
||||
if (!paced && !holder) { send_buffer_release(buffer); perf_note_release(since_ns); return; }
|
||||
int64_t now = now_ns();
|
||||
int64_t at = s->next_release_ns + interval;
|
||||
int64_t latest = now + interval * (int64_t)(s->releases_pending + 1);
|
||||
if (at < now) at = now;
|
||||
if (at > latest) at = latest;
|
||||
s->next_release_ns = at;
|
||||
int64_t at = now;
|
||||
if (paced) {
|
||||
int64_t latest = now + interval * (int64_t)(s->releases_pending + 1);
|
||||
at = s->next_release_ns + interval;
|
||||
if (at < now) at = now;
|
||||
if (at > latest) at = latest;
|
||||
s->next_release_ns = at;
|
||||
}
|
||||
struct pending_release *pr = calloc(1, sizeof(*pr));
|
||||
if (!pr) { send_buffer_release(buffer); perf_note_release(since_ns); return; }
|
||||
pr->buffer = buffer;
|
||||
pr->surface = s;
|
||||
pr->held_by = holder;
|
||||
pr->at_ns = at;
|
||||
pr->since_ns = since_ns;
|
||||
pr->destroy.notify = on_pending_release_buffer_destroyed;
|
||||
@@ -721,7 +776,7 @@ static void drop_dmabuf(struct surface *s, int paced) {
|
||||
wl_list_remove(&s->dmabuf_destroy.link);
|
||||
if (buffer_shown_elsewhere(s->dmabuf, s)) {
|
||||
} else if (!ahb_swapchain_defer_release(s->dmabuf_buf, s->dmabuf, s, paced)) {
|
||||
if (paced) release_buffer(s, s->dmabuf, now_ns());
|
||||
if (paced) release_buffer(s, s->dmabuf, now_ns(), sync_holder(s));
|
||||
else send_buffer_release(s->dmabuf);
|
||||
}
|
||||
s->dmabuf = NULL;
|
||||
@@ -887,6 +942,7 @@ static void take_dmabuf(struct surface *s, struct dmabuf_buffer *b, struct wl_re
|
||||
s->last_dmabuf = buffer;
|
||||
pace_note_buffer(buffer);
|
||||
drop_dmabuf(s, 1);
|
||||
pending_releases_cancel(buffer);
|
||||
s->dmabuf = buffer;
|
||||
s->dmabuf_buf = b;
|
||||
b->refs++;
|
||||
@@ -977,7 +1033,7 @@ void droiddeck_dmabuf_ref(struct dmabuf_buffer *b) { b->refs++; }
|
||||
void droiddeck_dmabuf_unref(struct dmabuf_buffer *b) { dmabuf_buffer_unref(b); }
|
||||
void droiddeck_release_buffer(struct surface *s, struct wl_resource *buffer, int paced, int64_t since_ns) {
|
||||
if (buffer_release_blocked(buffer)) return;
|
||||
if (paced && s) release_buffer(s, buffer, since_ns);
|
||||
if (paced && s) release_buffer(s, buffer, since_ns, NULL);
|
||||
else { send_buffer_release(buffer); perf_note_release(since_ns); }
|
||||
}
|
||||
void droiddeck_surface_describe(const struct surface *s, char *out, size_t size) { describe(s, out, size); }
|
||||
@@ -1265,6 +1321,7 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) {
|
||||
s->pending_attach = 0;
|
||||
|
||||
surface_drop_idle(s);
|
||||
buf_trace_attach(buffer);
|
||||
if (s->role == ROLE_CURSOR) {
|
||||
if (!buffer) {
|
||||
cursor_publish_hidden();
|
||||
@@ -1275,7 +1332,6 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) {
|
||||
} else if (s->role == ROLE_NONE) {
|
||||
if (buffer) surface_hold_idle(s, buffer);
|
||||
} else if (db) {
|
||||
buf_trace_attach(buffer);
|
||||
take_dmabuf(s, db, buffer);
|
||||
} else if (shm) {
|
||||
drop_dmabuf(s, 1);
|
||||
@@ -1289,6 +1345,7 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) {
|
||||
if (buffer) send_buffer_release(buffer);
|
||||
}
|
||||
}
|
||||
pending_releases_apply(s);
|
||||
|
||||
wl_list_for_each(child, &s->children, child_link) {
|
||||
if (child->sub_pending) {
|
||||
@@ -1486,8 +1543,14 @@ static void subsurface_place_below(struct wl_client *c, struct wl_resource *r,
|
||||
struct wl_resource *sibling) {
|
||||
restack_child(wl_resource_get_user_data(r), wl_resource_get_user_data(sibling), 0);
|
||||
}
|
||||
static void subsurface_set_sync(struct wl_client *c, struct wl_resource *r) {}
|
||||
static void subsurface_set_desync(struct wl_client *c, struct wl_resource *r) {}
|
||||
static void subsurface_set_sync(struct wl_client *c, struct wl_resource *r) {
|
||||
struct surface *s = wl_resource_get_user_data(r);
|
||||
if (s) s->sub_desync = 0;
|
||||
}
|
||||
static void subsurface_set_desync(struct wl_client *c, struct wl_resource *r) {
|
||||
struct surface *s = wl_resource_get_user_data(r);
|
||||
if (s) { s->sub_desync = 1; pending_releases_rehold(s); }
|
||||
}
|
||||
static const struct wl_subsurface_interface subsurface_impl = {
|
||||
.destroy = subsurface_destroy,
|
||||
.set_position = subsurface_set_position,
|
||||
@@ -1521,6 +1584,7 @@ static void subcompositor_get_subsurface(struct wl_client *c, struct wl_resource
|
||||
s->subsurface = sub;
|
||||
s->parent = p;
|
||||
s->below_parent = 0;
|
||||
s->sub_desync = 0;
|
||||
s->sub_x = s->sub_y = 0;
|
||||
wl_list_insert(p->children.prev, &s->child_link);
|
||||
}
|
||||
@@ -1796,14 +1860,14 @@ static void desktop_set_zorder(struct wl_client *c, struct wl_resource *r, struc
|
||||
apply_zorder();
|
||||
schedule_render();
|
||||
}
|
||||
static const struct banner_desktop_v1_interface desktop_impl = {
|
||||
static const struct droiddeck_desktop_v1_interface desktop_impl = {
|
||||
.destroy = desktop_destroy_req,
|
||||
.set_desktop = desktop_set_desktop,
|
||||
.set_window = desktop_set_window,
|
||||
.set_zorder = desktop_set_zorder,
|
||||
};
|
||||
static void bind_desktop(struct wl_client *c, void *data, uint32_t ver, uint32_t id) {
|
||||
struct wl_resource *r = wl_resource_create(c, &banner_desktop_v1_interface, ver, id);
|
||||
struct wl_resource *r = wl_resource_create(c, &droiddeck_desktop_v1_interface, ver, id);
|
||||
wl_resource_set_implementation(r, &desktop_impl, NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -4083,7 +4147,7 @@ int droiddeck_wayland_run(void) {
|
||||
wl_global_create(display, &zwp_linux_dmabuf_v1_interface, 4, NULL, bind_dmabuf);
|
||||
droiddeck_android_wlegl_init(display);
|
||||
wl_global_create(display, &wl_seat_interface, 9, NULL, bind_seat);
|
||||
wl_global_create(display, &banner_desktop_v1_interface, 1, NULL, bind_desktop);
|
||||
wl_global_create(display, &droiddeck_desktop_v1_interface, 1, NULL, bind_desktop);
|
||||
wl_global_create(display, &wp_presentation_interface, 2, NULL, bind_presentation);
|
||||
wl_global_create(display, &zwp_pointer_constraints_v1_interface, 1, NULL, bind_pointer_constraints);
|
||||
wl_global_create(display, &zwp_relative_pointer_manager_v1_interface, 1, NULL, bind_relative_pointer_manager);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "cas_frag.h"
|
||||
#include "color_frag.h"
|
||||
#include "fxaa_frag.h"
|
||||
#include "smaa_frag.h"
|
||||
#include "toon_frag.h"
|
||||
#include "hdr_frag.h"
|
||||
#include "ntsc_frag.h"
|
||||
@@ -41,7 +42,7 @@ struct fx_settings {
|
||||
int color_on;
|
||||
float brightness, contrast, gamma, saturation;
|
||||
float b_raw, c_raw, s_raw;
|
||||
int fxaa, toon, crt, ntsc;
|
||||
int aa_mode, toon, crt, ntsc;
|
||||
char look[48];
|
||||
};
|
||||
|
||||
@@ -78,7 +79,7 @@ void vkp_effects_set_deband(int enabled, int pct) {
|
||||
}
|
||||
static float clampf(float v, float lo, float hi) { return v < lo ? lo : v > hi ? hi : v; }
|
||||
void vkp_effects_set_screen(float brightness, float contrast, float gamma, float saturation,
|
||||
int fxaa, int toon, int crt, int ntsc) {
|
||||
int aa_mode, int toon, int crt, int ntsc) {
|
||||
int on = !(brightness == 0.0f && contrast == 0.0f && gamma == 1.0f && saturation == 100.0f);
|
||||
set_begin();
|
||||
g_set.color_on = on;
|
||||
@@ -87,7 +88,8 @@ void vkp_effects_set_screen(float brightness, float contrast, float gamma, float
|
||||
g_set.contrast = clampf(contrast / 100.0f, 0.0f, 2.0f);
|
||||
g_set.saturation = clampf(saturation / 100.0f, 0.0f, 2.0f);
|
||||
g_set.gamma = clampf(gamma, 0.1f, 5.0f);
|
||||
g_set.fxaa = fxaa ? 1 : 0; g_set.toon = toon ? 1 : 0; g_set.crt = crt ? 1 : 0; g_set.ntsc = ntsc ? 1 : 0;
|
||||
g_set.aa_mode = (aa_mode >= 0 && aa_mode <= 2) ? aa_mode : 0;
|
||||
g_set.toon = toon ? 1 : 0; g_set.crt = crt ? 1 : 0; g_set.ntsc = ntsc ? 1 : 0;
|
||||
set_end();
|
||||
}
|
||||
void vkp_effects_set_look(const char *name) {
|
||||
@@ -103,7 +105,7 @@ static const char *scaling_name(int m) {
|
||||
static int spatial_mode(int m) { return m >= 3 && m <= 8; }
|
||||
static int cas_active(const struct fx_settings *s) { return s->cas_on && s->cas_pct > 0; }
|
||||
static int effect_count(const struct fx_settings *s) {
|
||||
return s->fxaa + s->toon + s->color_on + cas_active(s) + s->hdr_on + s->ntsc + s->crt + s->deband_on;
|
||||
return (s->aa_mode != 0) + s->toon + s->color_on + cas_active(s) + s->hdr_on + s->ntsc + s->crt + s->deband_on;
|
||||
}
|
||||
|
||||
static void log_settings(const struct fx_settings *s) {
|
||||
@@ -121,7 +123,8 @@ static void log_settings(const struct fx_settings *s) {
|
||||
if (s->color_on)
|
||||
n += snprintf(line + n, sizeof(line) - n, ", colour b=%+.0f c=%+.0f g=%.2f s=%.0f%%",
|
||||
s->b_raw, s->c_raw, s->gamma, s->s_raw);
|
||||
if (s->fxaa) n += snprintf(line + n, sizeof(line) - n, ", FXAA on");
|
||||
if (s->aa_mode == 1) n += snprintf(line + n, sizeof(line) - n, ", FXAA on");
|
||||
else if (s->aa_mode == 2) n += snprintf(line + n, sizeof(line) - n, ", SMAA on");
|
||||
if (s->toon) n += snprintf(line + n, sizeof(line) - n, ", Toon on");
|
||||
if (s->hdr_on) n += snprintf(line + n, sizeof(line) - n, ", HDR on");
|
||||
if (s->ntsc) n += snprintf(line + n, sizeof(line) - n, ", NTSC on");
|
||||
@@ -152,6 +155,10 @@ int vkp_effects_upscaling(void) {
|
||||
return spatial_mode(g_cur.scaling) && g_cur.scaling != 6;
|
||||
}
|
||||
|
||||
int vkp_effects_sharpening(void) {
|
||||
return vkp_effects_upscaling() || cas_active(&g_cur);
|
||||
}
|
||||
|
||||
int vkp_effects_postprocessing(void) {
|
||||
vkp_effects_sync();
|
||||
return effect_count(&g_cur) > 0;
|
||||
@@ -202,7 +209,7 @@ static VkDescriptorSetLayout g_dsl;
|
||||
static VkPipelineLayout g_pl;
|
||||
static VkDescriptorPool g_dpool;
|
||||
static VkSampler g_sampler;
|
||||
enum { P_SGSR, P_SGSR_HQ, P_NIS, P_EASU, P_RCAS, P_CAS, P_COLOR, P_FXAA, P_TOON, P_HDR, P_NTSC, P_CRT, P_DEBAND, P_COUNT };
|
||||
enum { P_SGSR, P_SGSR_HQ, P_NIS, P_EASU, P_RCAS, P_CAS, P_COLOR, P_FXAA, P_SMAA, P_TOON, P_HDR, P_NTSC, P_CRT, P_DEBAND, P_COUNT };
|
||||
static VkPipeline g_pipe[P_COUNT];
|
||||
static struct fx_target g_t[2], g_mid;
|
||||
|
||||
@@ -438,6 +445,7 @@ static int objects_ensure(void) {
|
||||
MK(P_CAS, cas_code, "cas");
|
||||
MK(P_COLOR, color_code, "color");
|
||||
MK(P_FXAA, fxaa_code, "fxaa");
|
||||
MK(P_SMAA, smaa_code, "smaa");
|
||||
MK(P_TOON, toon_code, "toon");
|
||||
MK(P_HDR, hdr_code, "hdr");
|
||||
MK(P_NTSC, ntsc_code, "ntsc");
|
||||
@@ -446,7 +454,7 @@ static int objects_ensure(void) {
|
||||
#undef MK
|
||||
g_vk.DestroyShaderModule(g_dev, vert, NULL);
|
||||
g_ready = 1;
|
||||
droiddeck_log("effects", "chain ready: 13 passes (SGSR, SGSR HQ, NIS, FSR EASU+RCAS, CAS, colour, FXAA, Toon, HDR, NTSC, CRT, deband) on %s", vkp_gpu_name());
|
||||
droiddeck_log("effects", "chain ready: 14 pipelines (SGSR, SGSR HQ, NIS, FSR EASU+RCAS, CAS, colour, FXAA, SMAA, Toon, HDR, NTSC, CRT, deband) on %s", vkp_gpu_name());
|
||||
return 0;
|
||||
fail:
|
||||
objects_destroy();
|
||||
@@ -567,9 +575,10 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
|
||||
cur = NULL; cur_ds = g_scene.ds;
|
||||
}
|
||||
|
||||
enum { FX_FXAA, FX_TOON, FX_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND };
|
||||
enum { FX_FXAA, FX_SMAA, FX_TOON, FX_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND };
|
||||
int order[8], n = 0;
|
||||
if (s->fxaa) order[n++] = FX_FXAA;
|
||||
if (s->aa_mode == 1) order[n++] = FX_FXAA;
|
||||
else if (s->aa_mode == 2) order[n++] = FX_SMAA;
|
||||
if (s->toon) order[n++] = FX_TOON;
|
||||
if (s->color_on) order[n++] = FX_COLOR;
|
||||
if (cas_active(s)) order[n++] = FX_CAS;
|
||||
@@ -584,6 +593,7 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
|
||||
pr.res[0] = (float)cw; pr.res[1] = (float)ch;
|
||||
switch (order[i]) {
|
||||
case FX_FXAA: pass(cmd, g_pipe[P_FXAA], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||
case FX_SMAA: pass(cmd, g_pipe[P_SMAA], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||
case FX_TOON: pass(cmd, g_pipe[P_TOON], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||
case FX_COLOR: {
|
||||
struct pc_color pc = {0};
|
||||
|
||||
@@ -11,6 +11,7 @@ int vkp_effects_sync(void);
|
||||
int vkp_effects_active(void);
|
||||
|
||||
int vkp_effects_upscaling(void);
|
||||
int vkp_effects_sharpening(void);
|
||||
int vkp_effects_postprocessing(void);
|
||||
|
||||
VkFilter vkp_effects_blit_filter(void);
|
||||
@@ -30,7 +31,7 @@ void vkp_effects_set_cas(int enabled, int pct);
|
||||
void vkp_effects_set_hdr(int enabled);
|
||||
void vkp_effects_set_deband(int enabled, int pct);
|
||||
void vkp_effects_set_screen(float brightness, float contrast, float gamma, float saturation,
|
||||
int fxaa, int toon, int crt, int ntsc);
|
||||
int aa_mode, int toon, int crt, int ntsc);
|
||||
void vkp_effects_set_look(const char *name);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef VK_LINEAR_DMABUF_H
|
||||
#define VK_LINEAR_DMABUF_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
static inline int vkp_linear_dmabuf_through_buffer(int drm_modifiers, uint64_t modifier, int blit_dst) {
|
||||
return !drm_modifiers && modifier == 0 && !blit_dst;
|
||||
}
|
||||
|
||||
static inline int vkp_linear_dmabuf_foreign_image(int dmabuf, int staged) {
|
||||
return dmabuf && !staged;
|
||||
}
|
||||
|
||||
static inline VkPipelineStageFlags vkp_linear_dmabuf_readback_stage(int in_general) {
|
||||
return in_general ? VK_PIPELINE_STAGE_TRANSFER_BIT : VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||
}
|
||||
|
||||
static inline VkAccessFlags vkp_linear_dmabuf_readback_access(int in_general) {
|
||||
return in_general ? VK_ACCESS_TRANSFER_WRITE_BIT : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t vkp_linear_dmabuf_texel_bytes(VkFormat fmt) {
|
||||
return fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? 8u : 4u;
|
||||
}
|
||||
|
||||
static inline VkDeviceSize vkp_linear_dmabuf_copy(VkFormat fmt, int w, int h, uint32_t stride, uint32_t offset,
|
||||
VkBufferImageCopy *copy) {
|
||||
const uint32_t texel = vkp_linear_dmabuf_texel_bytes(fmt);
|
||||
if (!copy || w <= 0 || h <= 0 || stride % texel || offset % texel || stride / texel < (uint32_t)w) return 0;
|
||||
*copy = (VkBufferImageCopy){
|
||||
.bufferOffset = offset,
|
||||
.bufferRowLength = stride / texel,
|
||||
.bufferImageHeight = (uint32_t)h,
|
||||
.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||
.imageExtent = {(uint32_t)w, (uint32_t)h, 1},
|
||||
};
|
||||
return (VkDeviceSize)offset + (VkDeviceSize)stride * (VkDeviceSize)(h - 1) + (VkDeviceSize)w * texel;
|
||||
}
|
||||
|
||||
static inline VkBufferMemoryBarrier vkp_linear_dmabuf_ownership(VkBuffer buffer, uint32_t queue_family,
|
||||
int acquire) {
|
||||
return (VkBufferMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
|
||||
.srcAccessMask = acquire ? 0 : VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.dstAccessMask = acquire ? VK_ACCESS_TRANSFER_READ_BIT : 0,
|
||||
.srcQueueFamilyIndex = acquire ? VK_QUEUE_FAMILY_FOREIGN_EXT : queue_family,
|
||||
.dstQueueFamilyIndex = acquire ? queue_family : VK_QUEUE_FAMILY_FOREIGN_EXT,
|
||||
.buffer = buffer,
|
||||
.offset = 0,
|
||||
.size = VK_WHOLE_SIZE,
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -23,6 +23,8 @@
|
||||
X(EndCommandBuffer) X(ResetFences) X(QueueSubmit) X(QueuePresentKHR) X(WaitForFences) \
|
||||
X(QueueWaitIdle) X(GetMemoryFdPropertiesKHR) X(GetAndroidHardwareBufferPropertiesANDROID) \
|
||||
X(GetImageSubresourceLayout) X(MapMemory) X(UnmapMemory) X(CmdClearColorImage) \
|
||||
X(CreateBuffer) X(DestroyBuffer) X(GetBufferMemoryRequirements) X(BindBufferMemory) \
|
||||
X(CmdCopyBufferToImage) \
|
||||
\
|
||||
X(CreateShaderModule) X(DestroyShaderModule) X(CreatePipelineLayout) X(DestroyPipelineLayout) \
|
||||
X(CreateGraphicsPipelines) X(DestroyPipeline) X(CreateRenderPass) X(DestroyRenderPass) \
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "vk_present.h"
|
||||
#include "vk_loader.h"
|
||||
#include "vk_external_image_sync.h"
|
||||
#include "vk_linear_dmabuf.h"
|
||||
#include "sc_layer.h"
|
||||
#include "effects_chain.h"
|
||||
#include "cardboard.h"
|
||||
@@ -42,10 +43,15 @@ struct vkp_image {
|
||||
VkFormat fmt;
|
||||
int sampled;
|
||||
AHardwareBuffer *android_buffer;
|
||||
int staged;
|
||||
VkBuffer linear_buf;
|
||||
VkDeviceMemory linear_mem;
|
||||
VkBufferImageCopy linear_copy;
|
||||
};
|
||||
|
||||
static ANativeWindow *g_window;
|
||||
static int g_ahb_import;
|
||||
static int g_drm_modifiers;
|
||||
static char *g_driver_path, *g_library_name, *g_native_lib_dir;
|
||||
static int g_allow_driver_fallback;
|
||||
static int g_dev_state;
|
||||
@@ -628,6 +634,7 @@ static int dev_init(void) {
|
||||
if (has_ext(exts, ne, import_exts[i])) dev_exts[n_dev_exts++] = import_exts[i];
|
||||
else LOGE("present: driver MISSING %s (dmabuf import will fail)", import_exts[i]);
|
||||
}
|
||||
g_drm_modifiers = has_ext(exts, ne, "VK_EXT_image_drm_format_modifier");
|
||||
int want_hdr_md = 0;
|
||||
if (droiddeck_color_requested()) {
|
||||
want_hdr_md = has_ext(exts, ne, VK_EXT_HDR_METADATA_EXTENSION_NAME);
|
||||
@@ -1088,6 +1095,10 @@ struct vkp_image *vkp_image_from_dmabuf(int fd, uint32_t drm_format, uint64_t mo
|
||||
return vkp_image_import_dmabuf(fd, drm_format, modifier, w, h, stride, offset, 0);
|
||||
}
|
||||
|
||||
static int foreign_image(const struct vkp_image *img) {
|
||||
return vkp_linear_dmabuf_foreign_image(img->dmabuf, img->staged);
|
||||
}
|
||||
|
||||
/* Return client sources to FOREIGN after their final read. The consuming paths
|
||||
* wait for our fence before Wayland can release an ordinary dma-buf or an
|
||||
* android_wlegl AHardwareBuffer. Producer-fence synchronization is separate from
|
||||
@@ -1095,7 +1106,7 @@ struct vkp_image *vkp_image_from_dmabuf(int fd, uint32_t drm_format, uint64_t mo
|
||||
static void release_external_client_image(VkCommandBuffer cmd, struct vkp_image *img) {
|
||||
struct vkp_external_client_barrier_pair pair;
|
||||
if (!img || !vkp_external_client_barrier_pair(
|
||||
img->image, g_qfam, img->dmabuf, img->blit_dst, &pair))
|
||||
img->image, g_qfam, foreign_image(img), img->blit_dst, &pair))
|
||||
return;
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0, NULL, 1, &pair.release);
|
||||
@@ -1109,6 +1120,37 @@ static void release_external_client_draws(VkCommandBuffer cmd, const struct vkp_
|
||||
}
|
||||
}
|
||||
|
||||
static void stage_linear_dmabuf(VkCommandBuffer cmd, const struct vkp_image *img) {
|
||||
if (!img || !img->linear_buf) return;
|
||||
const VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
VkBufferMemoryBarrier acquire = vkp_linear_dmabuf_ownership(img->linear_buf, g_qfam, 1);
|
||||
VkImageMemoryBarrier write = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = img->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
|
||||
0, NULL, 1, &acquire, 1, &write);
|
||||
g_vk.CmdCopyBufferToImage(cmd, img->linear_buf, img->image, VK_IMAGE_LAYOUT_GENERAL, 1, &img->linear_copy);
|
||||
VkBufferMemoryBarrier release = vkp_linear_dmabuf_ownership(img->linear_buf, g_qfam, 0);
|
||||
VkImageMemoryBarrier read = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = img->image, .subresourceRange = range, .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_SHADER_READ_BIT};
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0,
|
||||
0, NULL, 1, &release, 1, &read);
|
||||
}
|
||||
|
||||
static void stage_linear_dmabufs(VkCommandBuffer cmd, const struct vkp_draw *draws, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
int seen = 0;
|
||||
for (int j = 0; j < i; j++) if (draws[j].img == draws[i].img) { seen = 1; break; }
|
||||
if (!seen) stage_linear_dmabuf(cmd, draws[i].img);
|
||||
}
|
||||
}
|
||||
|
||||
int vkp_image_is_dmabuf(const struct vkp_image *img) {
|
||||
return img && vkp_is_external_client_image(img->dmabuf, img->blit_dst);
|
||||
}
|
||||
@@ -1181,6 +1223,102 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int optimal_sampled(VkFormat fmt) {
|
||||
if (!g_vk.GetPhysicalDeviceFormatProperties2) return 0;
|
||||
VkFormatProperties2 fp = {.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2};
|
||||
g_vk.GetPhysicalDeviceFormatProperties2(g_pd, fmt, &fp);
|
||||
const VkFormatFeatureFlags need = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
|
||||
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
||||
return (fp.formatProperties.optimalTilingFeatures & need) == need;
|
||||
}
|
||||
|
||||
static void destroy_image_objects(struct vkp_image *img) {
|
||||
if (img->image) g_vk.DestroyImage(g_dev, img->image, NULL);
|
||||
if (img->mem) g_vk.FreeMemory(g_dev, img->mem, NULL);
|
||||
if (img->linear_buf) g_vk.DestroyBuffer(g_dev, img->linear_buf, NULL);
|
||||
if (img->linear_mem) g_vk.FreeMemory(g_dev, img->linear_mem, NULL);
|
||||
img->image = VK_NULL_HANDLE; img->mem = VK_NULL_HANDLE;
|
||||
img->linear_buf = VK_NULL_HANDLE; img->linear_mem = VK_NULL_HANDLE;
|
||||
img->staged = 0; img->in_general = 0;
|
||||
}
|
||||
|
||||
static int import_linear_dmabuf(struct vkp_image *img, int fd, const VkBufferImageCopy *copy, VkDeviceSize need) {
|
||||
int dupfd = dup(fd);
|
||||
if (dupfd < 0) return -1;
|
||||
VkDeviceSize size = need;
|
||||
off_t end = lseek(dupfd, 0, SEEK_END);
|
||||
if (end > 0 && (VkDeviceSize)end >= need) size = (VkDeviceSize)end;
|
||||
lseek(dupfd, 0, SEEK_SET);
|
||||
if (end > 0 && (VkDeviceSize)end < need) {
|
||||
LOGE("dmabuf: the linear %dx%d buffer holds %lld bytes, its row pitch needs %llu", img->w, img->h,
|
||||
(long long)end, (unsigned long long)need);
|
||||
close(dupfd);
|
||||
return -1;
|
||||
}
|
||||
VkExternalMemoryBufferCreateInfo ext = {
|
||||
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO,
|
||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT};
|
||||
VkBufferCreateInfo bci = {.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = &ext, .size = size,
|
||||
.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT, .sharingMode = VK_SHARING_MODE_EXCLUSIVE};
|
||||
VkResult r = g_vk.CreateBuffer(g_dev, &bci, NULL, &img->linear_buf);
|
||||
if (r != VK_SUCCESS) goto fail;
|
||||
uint32_t allowed = 0xffffffff;
|
||||
if (g_vk.GetMemoryFdPropertiesKHR) {
|
||||
VkMemoryFdPropertiesKHR fp = {.sType = VK_STRUCTURE_TYPE_MEMORY_FD_PROPERTIES_KHR};
|
||||
if (g_vk.GetMemoryFdPropertiesKHR(g_dev, VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||
dupfd, &fp) == VK_SUCCESS)
|
||||
allowed = fp.memoryTypeBits;
|
||||
}
|
||||
VkMemoryRequirements breq;
|
||||
g_vk.GetBufferMemoryRequirements(g_dev, img->linear_buf, &breq);
|
||||
int bidx = memory_type(breq.memoryTypeBits & allowed, 0);
|
||||
r = VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||
if (bidx < 0) goto fail;
|
||||
VkImportMemoryFdInfoKHR imp = {.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
|
||||
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, .fd = dupfd};
|
||||
VkMemoryDedicatedAllocateInfo ded = {.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
|
||||
.pNext = &imp, .buffer = img->linear_buf};
|
||||
VkMemoryAllocateInfo mai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = &ded,
|
||||
.allocationSize = breq.size, .memoryTypeIndex = (uint32_t)bidx};
|
||||
r = g_vk.AllocateMemory(g_dev, &mai, NULL, &img->linear_mem);
|
||||
if (r != VK_SUCCESS) goto fail;
|
||||
dupfd = -1;
|
||||
r = g_vk.BindBufferMemory(g_dev, img->linear_buf, img->linear_mem, 0);
|
||||
if (r != VK_SUCCESS) goto fail;
|
||||
|
||||
VkImageCreateInfo ici = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D, .format = img->fmt,
|
||||
.extent = {(uint32_t)img->w, (uint32_t)img->h, 1}, .mipLevels = 1, .arrayLayers = 1,
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||
.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
|
||||
(img->sampled ? VK_IMAGE_USAGE_SAMPLED_BIT : 0),
|
||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
|
||||
r = g_vk.CreateImage(g_dev, &ici, NULL, &img->image);
|
||||
if (r != VK_SUCCESS) goto fail;
|
||||
VkMemoryRequirements ireq;
|
||||
g_vk.GetImageMemoryRequirements(g_dev, img->image, &ireq);
|
||||
int iidx = memory_type(ireq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
if (iidx < 0) iidx = memory_type(ireq.memoryTypeBits, 0);
|
||||
r = VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||
if (iidx < 0) goto fail;
|
||||
VkMemoryAllocateInfo iai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||
.allocationSize = ireq.size, .memoryTypeIndex = (uint32_t)iidx};
|
||||
r = g_vk.AllocateMemory(g_dev, &iai, NULL, &img->mem);
|
||||
if (r != VK_SUCCESS) goto fail;
|
||||
r = g_vk.BindImageMemory(g_dev, img->image, img->mem, 0);
|
||||
if (r != VK_SUCCESS) goto fail;
|
||||
img->linear_copy = *copy;
|
||||
img->staged = 1;
|
||||
img->in_general = 1;
|
||||
return 0;
|
||||
fail:
|
||||
LOGE("dmabuf: reading the linear %dx%d buffer at its row pitch failed (%s); importing it as an image",
|
||||
img->w, img->h, vk_result_name(r));
|
||||
if (dupfd >= 0) close(dupfd);
|
||||
destroy_image_objects(img);
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t modifier, int w, int h,
|
||||
uint32_t stride, uint32_t offset, int as_blit_dst) {
|
||||
if (modifier == MOD_INVALID || w <= 0 || h <= 0) return NULL;
|
||||
@@ -1190,9 +1328,11 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
|
||||
if (!img) return NULL;
|
||||
img->w = w; img->h = h; img->dmabuf = 1; img->blit_dst = as_blit_dst ? 1 : 0;
|
||||
img->fmt = drm_to_vk(drm_format);
|
||||
const int through_buffer = vkp_linear_dmabuf_through_buffer(g_drm_modifiers, modifier, as_blit_dst);
|
||||
const VkImageUsageFlags sampled_usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
img->sampled = !as_blit_dst && g_vk.GetPhysicalDeviceImageFormatProperties2 &&
|
||||
modifier_importable(img->fmt, modifier, sampled_usage);
|
||||
const int modifier_sampled = !as_blit_dst && g_drm_modifiers && g_vk.GetPhysicalDeviceImageFormatProperties2 &&
|
||||
modifier_importable(img->fmt, modifier, sampled_usage);
|
||||
img->sampled = through_buffer ? optimal_sampled(img->fmt) : modifier_sampled;
|
||||
/* Each new format/modifier/size a client hands over, once, for the graphics report: a colour
|
||||
* or swizzle mismatch on a non-Adreno driver shows up as the pair it arrived as. */
|
||||
{
|
||||
@@ -1203,10 +1343,11 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
|
||||
if (seen[i].fmt == drm_format && seen[i].mod == modifier && seen[i].w == w && seen[i].h == h) known = 1;
|
||||
if (!known && nseen < 32) {
|
||||
seen[nseen].fmt = drm_format; seen[nseen].mod = modifier; seen[nseen].w = w; seen[nseen].h = h; nseen++;
|
||||
droiddeck_log("gpu", "dmabuf import: %c%c%c%c %s %dx%d stride %u offset %u -> vk format %d, %s%s",
|
||||
droiddeck_log("gpu", "dmabuf import: %c%c%c%c %s %dx%d stride %u offset %u -> vk format %d, %s%s%s",
|
||||
drm_format & 0xff, (drm_format >> 8) & 0xff, (drm_format >> 16) & 0xff, (drm_format >> 24) & 0xff,
|
||||
vkp_modifier_name(modifier), w, h, stride, offset, (int)img->fmt,
|
||||
img->sampled ? "sampled" : "copied", as_blit_dst ? ", blit target" : "");
|
||||
img->sampled ? "sampled" : "copied", as_blit_dst ? ", blit target" : "",
|
||||
through_buffer ? ", trying a copy at its row pitch (no VK_EXT_image_drm_format_modifier)" : "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1214,6 +1355,12 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
|
||||
* vkCreateImage, which left the whole window unshown (David Cimo). One packed, 64-byte aligned
|
||||
* row is what a linear buffer that small holds. */
|
||||
if (stride == 0 && modifier == 0) stride = ((uint32_t)w * 4 + 63) & ~63u;
|
||||
if (through_buffer) {
|
||||
VkBufferImageCopy linear_copy;
|
||||
const VkDeviceSize linear_size = vkp_linear_dmabuf_copy(img->fmt, w, h, stride, offset, &linear_copy);
|
||||
if (linear_size && import_linear_dmabuf(img, fd, &linear_copy, linear_size) == 0) return img;
|
||||
img->sampled = modifier_sampled;
|
||||
}
|
||||
VkSubresourceLayout plane = {.offset = offset, .rowPitch = stride};
|
||||
VkImageDrmFormatModifierExplicitCreateInfoEXT modInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT,
|
||||
@@ -1501,8 +1648,7 @@ void vkp_image_destroy(struct vkp_image *img) {
|
||||
if (g_dev) {
|
||||
blendp_forget_image(img->image);
|
||||
if (img->map) g_vk.UnmapMemory(g_dev, img->mem);
|
||||
if (img->image) g_vk.DestroyImage(g_dev, img->image, NULL);
|
||||
if (img->mem) g_vk.FreeMemory(g_dev, img->mem, NULL);
|
||||
destroy_image_objects(img);
|
||||
}
|
||||
if (img->android_buffer) AHardwareBuffer_release(img->android_buffer);
|
||||
free(img);
|
||||
@@ -1600,7 +1746,7 @@ static void effects_source_note(int scene_w, int scene_h, const struct vkp_draw
|
||||
static void record_draw(VkCommandBuffer cmd, const struct vkp_draw *d, const VkImageBlit *blit, VkImage target,
|
||||
VkFormat target_fmt, int target_w, int target_h, VkFilter filter) {
|
||||
const struct vkp_image *im = d->img;
|
||||
const int external_client = vkp_image_is_dmabuf(im);
|
||||
const int external_client = vkp_is_external_client_image(foreign_image(im), im->blit_dst);
|
||||
if (d->blend && im->sampled &&
|
||||
blendp_draw(cmd, im->image, im->fmt, im->w, im->h, !external_client,
|
||||
target, target_fmt, target_w, target_h,
|
||||
@@ -2084,6 +2230,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
|
||||
g_vk.BeginCommandBuffer(cmd, &bi);
|
||||
blendp_begin_frame();
|
||||
stage_linear_dmabufs(cmd, draws, n);
|
||||
VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
|
||||
VkImageMemoryBarrier *bars = calloc((size_t)n + 1, sizeof(*bars));
|
||||
@@ -2101,7 +2248,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
if (seen || !im) continue;
|
||||
struct vkp_external_client_barrier_pair pair;
|
||||
if (vkp_external_client_barrier_pair(
|
||||
im->image, g_qfam, im->dmabuf, im->blit_dst, &pair)) {
|
||||
im->image, g_qfam, foreign_image(im), im->blit_dst, &pair)) {
|
||||
bars[nb++] = pair.acquire;
|
||||
} else if (!im->blit_dst && !im->in_general) {
|
||||
bars[nb++] = (VkImageMemoryBarrier){
|
||||
@@ -2179,7 +2326,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
VkImageLayout result_layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
if (fx) {
|
||||
int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f);
|
||||
if (fg) { mapped_w = scene_w; mapped_h = scene_h; }
|
||||
if (fg && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; }
|
||||
vkp_effects_set_formats(scene_fmt, scene_fmt);
|
||||
result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, &rw, &rh);
|
||||
effects_overlay_draws(cmd, result, rw, rh, scene_w, scene_h,
|
||||
@@ -2383,9 +2530,10 @@ int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
|
||||
VkCommandBufferBeginInfo bi = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
|
||||
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
|
||||
g_vk.BeginCommandBuffer(g_cmd, &bi);
|
||||
stage_linear_dmabuf(g_cmd, src);
|
||||
struct vkp_external_client_barrier_pair src_pair;
|
||||
const int src_external = vkp_external_client_barrier_pair(
|
||||
src->image, g_qfam, src->dmabuf, src->blit_dst, &src_pair);
|
||||
src->image, g_qfam, foreign_image(src), src->blit_dst, &src_pair);
|
||||
VkImageMemoryBarrier acq[2] = {
|
||||
src_external ? src_pair.acquire : (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
@@ -2489,22 +2637,26 @@ int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px) {
|
||||
VkCommandBufferBeginInfo bi = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
|
||||
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
|
||||
g_vk.BeginCommandBuffer(cmd, &bi);
|
||||
stage_linear_dmabuf(cmd, src);
|
||||
struct vkp_external_client_barrier_pair src_pair;
|
||||
const int src_external = vkp_external_client_barrier_pair(
|
||||
src->image, g_qfam, src->dmabuf, src->blit_dst, &src_pair);
|
||||
src->image, g_qfam, foreign_image(src), src->blit_dst, &src_pair);
|
||||
VkImageMemoryBarrier acq[2] = {
|
||||
src_external ? src_pair.acquire : (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT},
|
||||
.image = src->image, .subresourceRange = range,
|
||||
.srcAccessMask = vkp_linear_dmabuf_readback_access(src->in_general),
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT},
|
||||
{.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .image = g_rb->image, .subresourceRange = range,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT}};
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, NULL, 0, NULL, 2, acq);
|
||||
g_vk.CmdPipelineBarrier(cmd, vkp_linear_dmabuf_readback_stage(src->in_general),
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 2, acq);
|
||||
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||
.srcOffsets = {{0, 0, 0}, {src->w, src->h, 1}},
|
||||
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||
@@ -2602,6 +2754,7 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
|
||||
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
|
||||
g_vk.BeginCommandBuffer(cmd, &bi);
|
||||
blendp_begin_frame();
|
||||
stage_linear_dmabufs(cmd, draws, n);
|
||||
VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
|
||||
VkImageMemoryBarrier *bars = calloc((size_t)n + 1, sizeof(*bars));
|
||||
@@ -2620,7 +2773,7 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
|
||||
if (seen || !im) continue;
|
||||
struct vkp_external_client_barrier_pair pair;
|
||||
if (vkp_external_client_barrier_pair(
|
||||
im->image, g_qfam, im->dmabuf, im->blit_dst, &pair)) {
|
||||
im->image, g_qfam, foreign_image(im), im->blit_dst, &pair)) {
|
||||
bars[nb++] = pair.acquire;
|
||||
} else if (!im->blit_dst && !im->in_general) {
|
||||
bars[nb++] = (VkImageMemoryBarrier){
|
||||
|
||||
@@ -497,8 +497,8 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetDeband(JNIEnv *en
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetScreenEffects(JNIEnv *env, jclass clazz, jfloat brightness,
|
||||
jfloat contrast, jfloat gamma, jfloat saturation, jboolean fxaa, jboolean toon, jboolean crt, jboolean ntsc) {
|
||||
vkp_effects_set_screen(brightness, contrast, gamma, saturation, fxaa ? 1 : 0, toon ? 1 : 0, crt ? 1 : 0, ntsc ? 1 : 0);
|
||||
jfloat contrast, jfloat gamma, jfloat saturation, jint aa_mode, jboolean toon, jboolean crt, jboolean ntsc) {
|
||||
vkp_effects_set_screen(brightness, contrast, gamma, saturation, aa_mode, toon ? 1 : 0, crt ? 1 : 0, ntsc ? 1 : 0);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
||||
@@ -43,15 +43,17 @@ class App : Application() {
|
||||
if (process == "$packageName:vr_recovery" || process == "$packageName:rgb_diagnostic" ||
|
||||
process == "$packageName:shortcuts_sync" || process == "$packageName:bottom_desktop") return
|
||||
CrashHandler.install(this)
|
||||
com.droiddeck.launcher.input.ShortcutsRelay.Holder.install(this)
|
||||
com.droiddeck.launcher.agent.AgentHost.refresh(this)
|
||||
com.droiddeck.launcher.agent.AgentTab.load(this)
|
||||
com.droiddeck.launcher.ui.NavTabs.load(this)
|
||||
com.droiddeck.launcher.ui.DeveloperTools.load(this)
|
||||
com.droiddeck.launcher.ui.AgentPet.install(this)
|
||||
if (com.droiddeck.launcher.agent.AgentTab.visible) com.droiddeck.launcher.lab.LabNotice.openOnInstall = "agent"
|
||||
com.droiddeck.launcher.lab.LabNotice.started(this)
|
||||
com.droiddeck.launcher.session.QuestExperimental.initialize(this)
|
||||
com.droiddeck.launcher.session.SessionPrefs.applyNtsyncDefault(this)
|
||||
com.droiddeck.launcher.session.SessionPrefs.settleGpuDriverMode(this)
|
||||
com.droiddeck.launcher.session.SessionPrefs.settleStoresTabOrder(this, com.droiddeck.launcher.stores.Store.entries.map { it.id })
|
||||
com.droiddeck.launcher.update.AppUpdates.init(this)
|
||||
com.droiddeck.launcher.update.UpdateWatch.sync(this, com.droiddeck.launcher.update.AppUpdates.follow(this, null))
|
||||
com.droiddeck.launcher.core.DownloadSource.init(this)
|
||||
@@ -94,6 +96,8 @@ class App : Application() {
|
||||
com.droiddeck.launcher.session.SessionFiles.ensureUbisoftService(app)
|
||||
if (com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, com.droiddeck.launcher.stores.Store.ROCKSTAR) != null)
|
||||
com.droiddeck.launcher.session.SessionFiles.ensureRockstarService(app)
|
||||
if (com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, com.droiddeck.launcher.stores.Store.EPIC) != null)
|
||||
com.droiddeck.launcher.session.SessionFiles.ensureEpicParent(app)
|
||||
com.droiddeck.launcher.handtracking.HandTracking.load(app)
|
||||
}.onFailure { android.util.Log.w("App", "add-on pack prefetch failed", it) }
|
||||
}, "addon-packs").start()
|
||||
|
||||
@@ -319,7 +319,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
refreshDrivers()
|
||||
return
|
||||
}
|
||||
if (gpu.family.mali && DriverPairs.recommendedKey(gpu, emptyList()) == null &&
|
||||
if (gpu.family.mali && !DriverPairs.autoEligible(gpu) &&
|
||||
com.droiddeck.launcher.gpu.VulkanInfo.cachedOrNull() == null) {
|
||||
releaseChecking = true
|
||||
autoStatus = activity.getString(R.string.drivers_checking_latest)
|
||||
@@ -335,14 +335,14 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
}, "gpu-name").start()
|
||||
return
|
||||
}
|
||||
Log.i(TAG, "auto: ${gpu.name} (${gpu.family}) -> " + (DriverPairs.recommendedKey(gpu, emptyList()) ?: "no pair"))
|
||||
if (gpu.family.mali && DriverPairs.recommendedKey(gpu, emptyList()) == null) {
|
||||
Log.i(TAG, "auto: ${gpu.name} (${gpu.family}) eligible=${DriverPairs.autoEligible(gpu)}")
|
||||
if (gpu.family.mali && !DriverPairs.autoEligible(gpu)) {
|
||||
// No PanVK build covers this Mali (e.g. the G1 series, arch v14): the phone's own driver.
|
||||
autoStatus = useMaliFallback(null)
|
||||
refreshDrivers()
|
||||
return
|
||||
}
|
||||
if (DriverPairs.recommendedKey(gpu, emptyList()) == null) {
|
||||
if (!DriverPairs.autoEligible(gpu)) {
|
||||
autoStatus = activity.getString(R.string.drivers_none_to_set, gpu.supportText(activity, com.droiddeck.launcher.core.DeviceSupport.vkBridge(activity)).lowercase())
|
||||
return
|
||||
}
|
||||
@@ -372,7 +372,11 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
}
|
||||
gpu.family == GpuInfo.Family.POWERVR && (pair == null || !pair.complete) -> {
|
||||
// RADV is not published right now: the Xclipse falls back to the system route.
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(activity)
|
||||
if (gpu.name.contains("Xclipse", ignoreCase = true) && DriverPairs.xclipseNeedsUpstream(gpu.name)) {
|
||||
if (!SessionState.running) SessionPrefs.ensurePowerVrAutoDrivers(activity, powerVr = true, autoOwnedOnly = true)
|
||||
} else {
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(activity)
|
||||
}
|
||||
autoStatus = activity.getString(R.string.drivers_powervr_builtin)
|
||||
refreshDrivers()
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
this, ui,
|
||||
idle = { !busy && flood == null && compatLaunch == null && pkgStage == null && components.compBusy == null },
|
||||
onInstalled = { if (!OfflineMode.enabled(this)) components.checkComponentUpdates(force = false) },
|
||||
onRemoved = { components.refreshComponents() },
|
||||
)
|
||||
|
||||
private var installed by mutableStateOf<String?>(null)
|
||||
@@ -180,10 +181,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
private var fsyncFirst by mutableStateOf(false)
|
||||
private var gamescopeRealtime by mutableStateOf(false)
|
||||
private var paceCores by mutableStateOf(true)
|
||||
private var ramCapMb by mutableStateOf(0)
|
||||
private var zramClient by mutableStateOf(true)
|
||||
private var zramIdle by mutableStateOf(true)
|
||||
private var vramCapMb by mutableStateOf(0)
|
||||
private var gpuClockPin by mutableStateOf(false)
|
||||
private var prootNoSeccomp by mutableStateOf(false)
|
||||
private var prootFastPath by mutableStateOf(true)
|
||||
@@ -208,8 +205,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
private var animationsEnabled by mutableStateOf(true)
|
||||
private var lowStorageWarning by mutableStateOf(true)
|
||||
private var launcherIcon by mutableStateOf(LauncherIcon.DARK)
|
||||
private var gameStoresEnabled by mutableStateOf(true)
|
||||
private var soundtracksEnabled by mutableStateOf(true)
|
||||
private var soundtracksIngame by mutableStateOf(false)
|
||||
private var soundtracks by mutableStateOf<List<Library.SteamGame>>(emptyList())
|
||||
private var soundtracksLoaded by mutableStateOf(false)
|
||||
@@ -281,6 +276,11 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
private val pickAnyDriver = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
|
||||
if (r.resultCode == RESULT_OK) InAppFilePicker.pickedUri(r.data)?.let { drivers.importDriver(it, linux = null) }
|
||||
}
|
||||
private val pickExperimentalProton = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
|
||||
if (r.resultCode == RESULT_OK) InAppFilePicker.pickedFile(r.data)?.let { zip ->
|
||||
protons.installExperimental { progress -> com.droiddeck.launcher.session.ExperimentalProtons.installFromFile(this, zip, progress) }
|
||||
}
|
||||
}
|
||||
private val pickLossless = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
|
||||
if (r.resultCode == RESULT_OK) InAppFilePicker.pickedFile(r.data)?.let { importLossless(it) }
|
||||
}
|
||||
@@ -875,7 +875,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
runCatching { com.droiddeck.launcher.frontend.AutoComponents.restoreMissing(this) }.onFailure { Log.w(TAG, "components: restore failed", it) }
|
||||
}, "components-restore").start()
|
||||
}
|
||||
private var pendingGameLink: String? = null
|
||||
private var pendingGameLink: com.droiddeck.launcher.frontend.GameRequest? = null
|
||||
private var gameLinkReading = false
|
||||
private var gameLinkTried = false
|
||||
private var gameSyncFolder by mutableStateOf<String?>(null)
|
||||
@@ -911,6 +911,16 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
|
||||
private fun readGameIntent(request: Intent) {
|
||||
request.getStringExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV)?.let { navRequest = it; request.removeExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV) }
|
||||
request.data?.takeIf { it.scheme == "droiddeck" && it.host == "settings" }?.let { uri ->
|
||||
val section = uri.pathSegments.firstOrNull()
|
||||
navRequest = if (section in setOf("storage", "sync", "downloads")) section
|
||||
else "settings:" + (com.droiddeck.launcher.ui.SettingsSection.of(section) ?: com.droiddeck.launcher.ui.SettingsSection.OVERVIEW).key
|
||||
request.data = null
|
||||
gameLinkReading = false
|
||||
pendingGameLink = null
|
||||
syncDualPanel()
|
||||
return
|
||||
}
|
||||
if (navRequest == com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_APPS) {
|
||||
homeAppSelected = HomeApp.isHomeScreenEnabled(this) && HomeApp.isDefault(this)
|
||||
if (!homeAppSelected) navRequest = null
|
||||
@@ -927,7 +937,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
val soundtrackId = com.droiddeck.launcher.frontend.SoundtrackShortcuts.read(request)
|
||||
if (soundtrackId != null) {
|
||||
soundtrackLaunch = true
|
||||
navRequest = if (SessionPrefs.soundtracksEnabled(this)) "sound:$soundtrackId" else "app:$soundtrackId"
|
||||
navRequest = if ("soundtracks" !in com.droiddeck.launcher.ui.NavTabs.hidden) "sound:$soundtrackId" else "app:$soundtrackId"
|
||||
request.data = null
|
||||
request.action = Intent.ACTION_MAIN
|
||||
return
|
||||
@@ -937,12 +947,12 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
com.droiddeck.launcher.ui.DualScreenPanel.hide(taskId)
|
||||
val copy = Intent(request)
|
||||
Thread({
|
||||
val id = GameLaunchIntent.read(this, copy)
|
||||
val game = GameLaunchIntent.read(this, copy)
|
||||
ui.post {
|
||||
if (intent === request && !isDestroyed) {
|
||||
gameLinkReading = false
|
||||
pendingGameLink = id
|
||||
if (id == null) {
|
||||
pendingGameLink = game
|
||||
if (game == null) {
|
||||
syncDualPanel()
|
||||
android.widget.Toast.makeText(this, R.string.game_link_invalid, android.widget.Toast.LENGTH_LONG).show()
|
||||
} else {
|
||||
@@ -955,13 +965,36 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchGame(game: Library.SteamGame, returnHome: Boolean = false, onHandled: () -> Unit = {}): Boolean {
|
||||
private fun launchGame(game: Library.SteamGame, returnHome: Boolean = false, onHandled: () -> Unit = {}, onSettled: () -> Unit = {}) {
|
||||
val request = gameLaunchRequest.incrementAndGet()
|
||||
if (!SessionPrefs.soundtracksIngame(this)) com.droiddeck.launcher.playback.SoundtrackController.pause(this)
|
||||
if (pkgStage != null) {
|
||||
onHandled()
|
||||
android.widget.Toast.makeText(this, R.string.main_wait_install_game, android.widget.Toast.LENGTH_SHORT).show()
|
||||
return false
|
||||
return
|
||||
}
|
||||
val files = game.gameFiles
|
||||
if (game.source != com.droiddeck.launcher.stores.Store.XBOX.id || files == null) {
|
||||
if (startGame(game, returnHome, onHandled)) onSettled()
|
||||
return
|
||||
}
|
||||
Thread({
|
||||
val refused = com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
|
||||
ui.post {
|
||||
when {
|
||||
request != gameLaunchRequest.get() || isFinishing || isDestroyed -> onHandled()
|
||||
refused -> {
|
||||
onHandled()
|
||||
android.widget.Toast.makeText(this, getString(R.string.game_needs_app_model, game.name), android.widget.Toast.LENGTH_LONG).show()
|
||||
onSettled()
|
||||
}
|
||||
startGame(game, returnHome, onHandled) -> onSettled()
|
||||
}
|
||||
}
|
||||
}, "xbox-app-model").start()
|
||||
}
|
||||
|
||||
private fun startGame(game: Library.SteamGame, returnHome: Boolean, onHandled: () -> Unit): Boolean {
|
||||
if (com.droiddeck.launcher.session.NoSteamLaunch.enabled(this, game)) return launchWithoutSteam(game, returnHome, onHandled)
|
||||
onHandled()
|
||||
if (SessionState.running) {
|
||||
@@ -1169,26 +1202,28 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
|
||||
private fun handleGameLink(games: List<Library.SteamGame>, scanned: Boolean = true) {
|
||||
if (!lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.RESUMED)) return
|
||||
val id = pendingGameLink ?: return
|
||||
if (!scanned && games.none { it.gameIdString == id }) return
|
||||
val request = pendingGameLink ?: return
|
||||
val game = request.find(games, byTitle = scanned)
|
||||
if (!scanned && game == null) return
|
||||
gameLinkTried = true
|
||||
ui.postDelayed({
|
||||
if (!isDestroyed && lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.RESUMED)) syncDualPanel()
|
||||
}, LINK_PANEL_MS)
|
||||
val game = games.firstOrNull { it.gameIdString == id }
|
||||
if (game == null) {
|
||||
val link = intent
|
||||
fun consume() {
|
||||
if (intent !== link || pendingGameLink !== request) return
|
||||
pendingGameLink = null
|
||||
intent.data = null
|
||||
intent.action = Intent.ACTION_MAIN
|
||||
intent.removeExtra(GameLaunchIntent.EXTRA_APP_ID)
|
||||
syncDualPanel()
|
||||
android.widget.Toast.makeText(this, R.string.game_link_missing, android.widget.Toast.LENGTH_LONG).show()
|
||||
} else if (launchGame(game, returnHome = true)) {
|
||||
pendingGameLink = null
|
||||
intent.data = null
|
||||
intent.action = Intent.ACTION_MAIN
|
||||
intent.removeExtra(GameLaunchIntent.EXTRA_APP_ID)
|
||||
link.data = null
|
||||
link.action = Intent.ACTION_MAIN
|
||||
link.removeExtra(GameLaunchIntent.EXTRA_APP_ID)
|
||||
}
|
||||
if (game == null) {
|
||||
consume()
|
||||
syncDualPanel()
|
||||
android.widget.Toast.makeText(this,
|
||||
if (request.program != null) R.string.game_link_program_unknown else R.string.game_link_missing,
|
||||
android.widget.Toast.LENGTH_LONG).show()
|
||||
} else launchGame(game, returnHome = true, onSettled = ::consume)
|
||||
}
|
||||
|
||||
private fun chooseGameShortcut(game: Library.SteamGame) {
|
||||
@@ -1235,8 +1270,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
lowStorageWarning = SessionPrefs.lowStorageWarning(this)
|
||||
LauncherIcon.repair(this, intent?.component)
|
||||
launcherIcon = LauncherIcon.current(this)
|
||||
gameStoresEnabled = SessionPrefs.gameStoresEnabled(this)
|
||||
soundtracksEnabled = SessionPrefs.soundtracksEnabled(this)
|
||||
soundtracksIngame = SessionPrefs.soundtracksIngame(this)
|
||||
gameStoresSpeedTier = SessionPrefs.gameStoresSpeedTier(this)
|
||||
storesShowMature = SessionPrefs.storesShowMature(this)
|
||||
@@ -1249,6 +1282,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
androidx.compose.runtime.LaunchedEffect(prootPack) {
|
||||
if (prootPack == com.droiddeck.launcher.core.AddonPack.State.Ready && installed == null) refresh()
|
||||
}
|
||||
val appsTabShown = "android-apps" !in com.droiddeck.launcher.ui.NavTabs.hidden
|
||||
androidx.compose.runtime.LaunchedEffect(appsTabShown) { if (appsTabShown && androidApps.isEmpty()) refreshAndroidApps() }
|
||||
DroidDeckTheme(theme, appScale = appScale) {
|
||||
com.droiddeck.launcher.ui.FocusGlideHost(androidx.compose.ui.Modifier.fillMaxSize().exposeTestTags()) {
|
||||
if (decky.deckyPendingZip != null) com.droiddeck.launcher.ui.DeckyZipWarningDialog(
|
||||
@@ -1332,8 +1367,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
animationsEnabled = animationsEnabled,
|
||||
lowStorageWarning = lowStorageWarning,
|
||||
launcherIcon = launcherIcon,
|
||||
gameStoresEnabled = gameStoresEnabled,
|
||||
soundtracksEnabled = soundtracksEnabled,
|
||||
soundtracksEnabled = "soundtracks" !in com.droiddeck.launcher.ui.NavTabs.hidden,
|
||||
soundtracksIngame = soundtracksIngame,
|
||||
soundtracks = soundtracks,
|
||||
soundtracksLoaded = soundtracksLoaded,
|
||||
@@ -1483,7 +1517,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
onComponents = { focusContent -> openComponents(focusContent) },
|
||||
onGameComponents = { game -> openComponents(gameKey = game.profileKey) },
|
||||
onComponentsTab = { tab -> openComponents(focusContent = true, tab = tab) },
|
||||
onSaveImport = { sg -> importSaves(sg.name) { GameSaves.game(sg) } },
|
||||
onSaveImport = { sg -> importSaves(sg.name) { GameSaves.game(this@FrontEndActivity, sg) } },
|
||||
onAddonImport = { sg, target -> importAddons(sg.name, target) },
|
||||
onAddonDelete = { target, name ->
|
||||
saveAction(getString(R.string.main_addons_deleting, name)) {
|
||||
@@ -1491,8 +1525,9 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
getString(R.string.main_addons_deleted, name)
|
||||
}
|
||||
},
|
||||
onSaveExport = { sg, layout -> exportSaves(sg.name, layout) { GameSaves.game(sg) } },
|
||||
onSaveExport = { sg, layout -> exportSaves(sg.name, layout) { GameSaves.game(this@FrontEndActivity, sg) } },
|
||||
onPerformance = { refreshCores(); showComponents = false; showMapping = false; showPerformance = true },
|
||||
performancePanel = { PerformanceHost(embedded = true) },
|
||||
onRoms = { showRoms = true },
|
||||
onFiles = { startActivity(Intent(this, com.droiddeck.launcher.files.FileManagerActivity::class.java)) },
|
||||
onBrowseFiles = { dir ->
|
||||
@@ -1608,8 +1643,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
offline = OfflineMode.enabled(this)
|
||||
},
|
||||
onPageBack = { showPerformance = false; showComponents = false; showMapping = false },
|
||||
onGameStoresEnabled = { on -> SessionPrefs.setGameStoresEnabled(this, on); gameStoresEnabled = on },
|
||||
onSoundtracksEnabled = { on -> SessionPrefs.setSoundtracksEnabled(this, on); soundtracksEnabled = on },
|
||||
onSoundtracksIngame = { on ->
|
||||
SessionPrefs.setSoundtracksIngame(this, on)
|
||||
soundtracksIngame = on
|
||||
@@ -1908,6 +1941,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
setIntent(intent)
|
||||
gameLaunchRequest.incrementAndGet()
|
||||
if (intent.action == SteamIntegration.ACTION_SETUP) {
|
||||
gameLinkReading = false
|
||||
pendingGameLink = null
|
||||
@@ -2200,13 +2234,13 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}
|
||||
|
||||
private fun refreshAndroidApps() {
|
||||
if (!homeAppSelected) {
|
||||
if (!homeAppSelected && "android-apps" in com.droiddeck.launcher.ui.NavTabs.hidden) {
|
||||
++androidAppsListing
|
||||
androidApps = emptyList()
|
||||
return
|
||||
}
|
||||
val seq = ++androidAppsListing
|
||||
HomePins.refresh(this)
|
||||
if (homeAppSelected) HomePins.refresh(this)
|
||||
Thread({
|
||||
val apps = runCatching { HomeApp.launchableApps(this) }.getOrDefault(emptyList())
|
||||
ui.post { if (seq == androidAppsListing) androidApps = apps }
|
||||
@@ -2401,13 +2435,20 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
),
|
||||
protons = com.droiddeck.launcher.ui.ProtonsState(
|
||||
rows = protons.protonRows, busyId = protons.protonBusyId, stage = protons.protonStage, percent = protons.protonPercent,
|
||||
runtimeReady = ready && !busy, sessionRunning = SessionState.running,
|
||||
runtimeReady = ready && !busy, sessionRunning = SessionState.running, experimental = protons.experimentalDirs,
|
||||
experimentalReleases = protons.experimentalReleases,
|
||||
),
|
||||
protonActions = com.droiddeck.launcher.ui.ProtonsActions(
|
||||
onInstall = { id -> protons.installProton(id) },
|
||||
onCancel = { id -> ProtonExtras.tools.firstOrNull { it.id == id }?.let { ProtonExtras.unqueue(this, it) }; protons.refreshProtons() },
|
||||
onRemove = { id, dir -> protons.removeProton(id, dir) },
|
||||
onRemoveOlder = { id -> protons.removeProton(id, older = true) },
|
||||
onExperimentalFile = {
|
||||
pickExperimentalProton.launch(InAppFilePicker.buildIntent(this, EXPERIMENTAL_PROTON_EXT, getString(R.string.xproton_install_file),
|
||||
android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS).path))
|
||||
},
|
||||
onExperimentalRelease = { release -> protons.installExperimentalRelease(release) },
|
||||
onRemoveExperimental = { dir -> protons.removeExperimental(dir) },
|
||||
),
|
||||
protonOptions = {
|
||||
com.droiddeck.launcher.ui.ProtonOptions(
|
||||
@@ -2704,7 +2745,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PerformanceHost() {
|
||||
private fun PerformanceHost(embedded: Boolean = false) {
|
||||
if (embedded) androidx.compose.runtime.LaunchedEffect(Unit) { refreshCores() }
|
||||
PerformancePage(
|
||||
cores = CpuCores.all.map { c -> CoreRow(c, "cpu$c" + (CpuCores.maxGhz(c)?.let { String.format(java.util.Locale.US, " · %.1f GHz", it) } ?: "")) },
|
||||
clientOverride = clientOverride, clientCores = clientCores, gameCores = gameCores, paceCores = paceCores,
|
||||
@@ -2714,10 +2756,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
fsyncFirst = fsyncFirst,
|
||||
gamescopeRealtime = gamescopeRealtime,
|
||||
gpuClockPin = gpuClockPin,
|
||||
ramCapMb = ramCapMb, vramCapMb = vramCapMb, zramClient = zramClient, zramIdle = zramIdle,
|
||||
deviceRamMb = (android.app.ActivityManager.MemoryInfo()
|
||||
.also((getSystemService(ACTIVITY_SERVICE) as android.app.ActivityManager)::getMemoryInfo).totalMem / (1024 * 1024)).toInt(),
|
||||
ramCapAvailable = com.droiddeck.launcher.core.ZramSupport.supported(),
|
||||
prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, nativeUserland = nativeUserland, cursorComposite = cursorComposite,
|
||||
guestHostname = guestHostname, phantomWarning = phantomWarning,
|
||||
onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on },
|
||||
@@ -2732,10 +2770,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
onFsyncFirst = { on -> SessionPrefs.setFsyncFirst(this, on); fsyncFirst = on },
|
||||
onGamescopeRealtime = { on -> SessionPrefs.setGamescopeRealtime(this, on); gamescopeRealtime = on },
|
||||
onGpuClockPin = { on -> SessionPrefs.setGpuClockPin(this, on); gpuClockPin = on },
|
||||
onRamCapMb = { mb -> SessionPrefs.setRamCapMb(this, mb); ramCapMb = mb },
|
||||
onZramClient = { on -> SessionPrefs.setZramClient(this, on); zramClient = on },
|
||||
onZramIdle = { on -> SessionPrefs.setZramIdle(this, on); zramIdle = on },
|
||||
onVramCapMb = { mb -> SessionPrefs.setVramCapMb(this, mb); vramCapMb = mb },
|
||||
onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on },
|
||||
onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on },
|
||||
onNativeUserland = { on -> SessionPrefs.setNativeUserland(this, on); nativeUserland = on },
|
||||
@@ -2750,6 +2784,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
SessionPrefs.setGameCpus(this, CpuCores.format(gameCores))
|
||||
},
|
||||
onDismiss = { showPerformance = false },
|
||||
embedded = embedded,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3033,10 +3068,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
fsyncFirst = SessionPrefs.fsyncFirst(this)
|
||||
gamescopeRealtime = SessionPrefs.gamescopeRealtime(this)
|
||||
paceCores = SessionPrefs.paceCores(this)
|
||||
ramCapMb = SessionPrefs.ramCapMb(this)
|
||||
zramClient = SessionPrefs.zramClient(this)
|
||||
zramIdle = SessionPrefs.zramIdle(this)
|
||||
vramCapMb = SessionPrefs.vramCapMb(this)
|
||||
gpuClockPin = SessionPrefs.gpuClockPin(this)
|
||||
prootNoSeccomp = SessionPrefs.prootNoSeccomp(this)
|
||||
prootFastPath = SessionPrefs.prootFastPath(this)
|
||||
@@ -3093,6 +3124,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
installed = LinuxRuntimeInstaller.installedVersion(this)
|
||||
ready = LinuxRuntime.isInstalled(this)
|
||||
vkBridge = SessionPrefs.vkBridge(this)
|
||||
venus = SessionPrefs.venus(this)
|
||||
venusHostVulkan = com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(this)
|
||||
vkBridgeSafe = SessionPrefs.vkBridgeSafe(this)
|
||||
bridgeProtonDxvk = SessionPrefs.bridgeProtonDxvk(this)
|
||||
removalPending = LinuxRuntimeInstaller.hasRemovalPending(this)
|
||||
@@ -3299,7 +3332,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
com.droiddeck.launcher.core.AppLanguage.setChosen(this, com.droiddeck.launcher.core.AppLanguage.SYSTEM)
|
||||
if (!ok) android.widget.Toast.makeText(this, R.string.setup_reset_settings_partial, android.widget.Toast.LENGTH_LONG).show()
|
||||
com.droiddeck.launcher.ui.Motion.refresh(this)
|
||||
com.droiddeck.launcher.agent.AgentTab.load(this)
|
||||
com.droiddeck.launcher.ui.DeveloperTools.load(this)
|
||||
com.droiddeck.launcher.ui.NavTabs.load(this)
|
||||
if (!switchLauncherIcon(LauncherIcon.DARK)) recreate()
|
||||
}
|
||||
@@ -3384,6 +3417,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
private const val KEY_SWITCH_DEADLINE = "switch_deadline"
|
||||
private val SESSION_ENDED = setOf(SessionPhase.IDLE, SessionPhase.FAILED)
|
||||
private val ZIP_EXT = listOf("zip")
|
||||
private val EXPERIMENTAL_PROTON_EXT = listOf("zip", "7z", "tar", "gz", "xz", "zst", "bz2", "tgz", "txz", "tbz2", "tzst")
|
||||
private val WCP_EXT = listOf("wcp")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.session.ExperimentalProtons
|
||||
import com.droiddeck.launcher.session.ProtonExtras
|
||||
import com.droiddeck.launcher.ui.ProtonRow
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
@@ -19,6 +20,7 @@ internal class ProtonMenu(
|
||||
private val activity: android.app.Activity,
|
||||
private val ui: Handler,
|
||||
private val onInstalled: () -> Unit = {},
|
||||
private val onRemoved: () -> Unit = {},
|
||||
private val idle: () -> Boolean = { true },
|
||||
) {
|
||||
private object Operation {
|
||||
@@ -27,13 +29,23 @@ internal class ProtonMenu(
|
||||
val stage = mutableStateOf<String?>(null)
|
||||
val percent = mutableIntStateOf(-1)
|
||||
val problem = mutableStateOf<String?>(null)
|
||||
val experimental = mutableStateOf<List<String>>(emptyList())
|
||||
val experimentalReleases = mutableStateOf<List<ExperimentalProtons.Release>>(emptyList())
|
||||
var fetchedReleases = emptyList<ExperimentalProtons.Release>()
|
||||
val checking = java.util.concurrent.atomic.AtomicBoolean(false)
|
||||
}
|
||||
var protonRows by Operation.rows
|
||||
var protonBusyId by Operation.busyId
|
||||
var protonStage by Operation.stage
|
||||
var protonPercent by Operation.percent
|
||||
var protonProblem by Operation.problem
|
||||
private val checking = java.util.concurrent.atomic.AtomicBoolean(false)
|
||||
var experimentalDirs by Operation.experimental
|
||||
var experimentalReleases by Operation.experimentalReleases
|
||||
companion object {
|
||||
const val EXPERIMENTAL = "experimental"
|
||||
}
|
||||
@VisibleForTesting internal var latestCheck: (Boolean) -> Boolean = { force -> ProtonExtras.checkLatest(activity, force) }
|
||||
@VisibleForTesting internal var experimentalRefresh: () -> List<ExperimentalProtons.Release>? = { ExperimentalProtons.refresh(activity) }
|
||||
@VisibleForTesting internal var installer: (ProtonExtras.Tool, (String, Int) -> Unit) -> String? =
|
||||
{ tool, progress -> ProtonExtras.install(activity, tool, progress) }
|
||||
|
||||
@@ -86,7 +98,57 @@ internal class ProtonMenu(
|
||||
}, "remove-proton-$id").start()
|
||||
}
|
||||
|
||||
fun installExperimental(work: ((String, Int) -> Unit) -> String?) {
|
||||
if (protonBusyId != null || ProtonExtras.installInProgress || SessionState.running) return
|
||||
protonBusyId = EXPERIMENTAL
|
||||
protonProblem = null
|
||||
protonStage = activity.getString(R.string.store_starting)
|
||||
protonPercent = -1
|
||||
Thread({
|
||||
val problem = runCatching {
|
||||
work { label, value -> ui.post { protonStage = label; protonPercent = value } }
|
||||
}.getOrElse { it.message ?: it.javaClass.simpleName }
|
||||
ui.post {
|
||||
protonProblem = problem
|
||||
protonBusyId = null
|
||||
protonStage = null
|
||||
protonPercent = -1
|
||||
refreshProtons()
|
||||
android.widget.Toast.makeText(activity, problem ?: activity.getString(R.string.xproton_installed), android.widget.Toast.LENGTH_LONG).show()
|
||||
if (problem == null) onInstalled()
|
||||
}
|
||||
}, "install-proton-experimental").start()
|
||||
}
|
||||
|
||||
fun installExperimentalRelease(release: ExperimentalProtons.Release) {
|
||||
installExperimental { progress -> ExperimentalProtons.installRelease(activity, release, progress) }
|
||||
}
|
||||
|
||||
fun removeExperimental(dir: String) {
|
||||
if (protonBusyId != null || SessionState.running) return
|
||||
protonBusyId = EXPERIMENTAL
|
||||
protonProblem = null
|
||||
protonStage = activity.getString(R.string.main_removing_named, dir)
|
||||
protonPercent = -1
|
||||
Thread({
|
||||
val removed = runCatching { ExperimentalProtons.remove(activity, dir) }.getOrDefault(false)
|
||||
ui.post {
|
||||
protonBusyId = null
|
||||
protonStage = null
|
||||
refreshProtons()
|
||||
if (!removed) android.widget.Toast.makeText(activity, activity.getString(R.string.xproton_remove_failed, dir), android.widget.Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}, "remove-proton-experimental").start()
|
||||
}
|
||||
|
||||
private fun refreshExperimental() {
|
||||
val installed = ExperimentalProtons.installed(activity)
|
||||
experimentalDirs = installed.map { it.dir }
|
||||
experimentalReleases = ExperimentalProtons.available(Operation.fetchedReleases, installed)
|
||||
}
|
||||
|
||||
fun refreshProtons() {
|
||||
refreshExperimental()
|
||||
protonRows = ProtonExtras.tools.map {
|
||||
val all = ProtonExtras.installedAll(activity, it)
|
||||
ProtonRow(it.id, it.name, all.lastOrNull(), ProtonExtras.queued(activity, it), all, ProtonExtras.update(activity, it))
|
||||
@@ -94,13 +156,22 @@ internal class ProtonMenu(
|
||||
}
|
||||
|
||||
fun checkUpdates(force: Boolean = false) {
|
||||
if (!checking.compareAndSet(false, true)) return
|
||||
if (!Operation.checking.compareAndSet(false, true)) return
|
||||
Thread({
|
||||
val asked = try { ProtonExtras.checkLatest(activity, force) } catch (_: Throwable) { false } finally { checking.set(false) }
|
||||
ui.post {
|
||||
if (asked) refreshProtons()
|
||||
val asked = runCatching { latestCheck(force) }.getOrDefault(false)
|
||||
val experimental = runCatching { experimentalRefresh() }.getOrNull()
|
||||
val published = ui.post {
|
||||
try {
|
||||
val before = experimentalDirs
|
||||
Operation.fetchedReleases = experimental ?: emptyList()
|
||||
if (asked) refreshProtons() else refreshExperimental()
|
||||
if (!experimentalDirs.containsAll(before)) onRemoved()
|
||||
} finally {
|
||||
Operation.checking.set(false)
|
||||
}
|
||||
ensureAutoUpdates()
|
||||
}
|
||||
if (!published) Operation.checking.set(false)
|
||||
}, "proton-updates").start()
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@ import com.droiddeck.launcher.hud.DroidDeckHudHost
|
||||
import com.droiddeck.launcher.session.PerfMode
|
||||
import com.droiddeck.launcher.session.SteamRepair
|
||||
import com.droiddeck.launcher.session.GameEnvironmentStore
|
||||
import com.droiddeck.launcher.session.GpuClockPin
|
||||
import com.droiddeck.launcher.session.GameProfileFollowState
|
||||
import com.droiddeck.launcher.session.GameProfileInventoryCache
|
||||
import com.droiddeck.launcher.session.GameProfileRefreshState
|
||||
@@ -191,6 +192,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var unfoldedPanel by mutableStateOf<OnScreenControls?>(null)
|
||||
private var unfoldedColumn: android.widget.LinearLayout? = null
|
||||
private var unfoldedDeckSurface: com.droiddeck.launcher.ui.InputSurfaceView? = null
|
||||
private var swappedInputSurface: com.droiddeck.launcher.ui.InputSurfaceView? = null
|
||||
private var unfoldedDeckPanel by mutableStateOf<com.droiddeck.launcher.input.DeckPanel?>(null)
|
||||
private var deckPanelLayouts: Map<com.droiddeck.launcher.input.DeckPanel, com.droiddeck.launcher.input.SavedInputLayout?> = emptyMap()
|
||||
private lateinit var sessionRoot: FrameLayout
|
||||
@@ -200,6 +202,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
@Volatile private var inputUsesLocalActions = false
|
||||
private var inputUsesPointer = false
|
||||
private var inputProfile = InputProfile.defaults(InputProfile.GAME)
|
||||
private var stockInputProfile = InputProfile.defaults(InputProfile.GAME)
|
||||
private val inputMotion = InputMotion { inputRouter }
|
||||
private val heldKeys = HeldInput { code, down -> WaylandCompositor.nativeSendKey(code, if (down) 1 else 0) }
|
||||
private val heldButtons = HeldInput(::sendSceneButton)
|
||||
@@ -486,7 +489,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
drawerLayerOpen = false
|
||||
drawerPinned = false
|
||||
if (value) drawerDocked = dockDrawer() && openDockedMenu()
|
||||
if (value) {
|
||||
releaseHeldKeys()
|
||||
drawerDocked = dockDrawer() && openDockedMenu()
|
||||
}
|
||||
drawerOpenState = value
|
||||
if (!value && drawerDocked) closeDockedMenu()
|
||||
}
|
||||
@@ -500,6 +506,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var drawerGameProfileId by mutableStateOf<Long?>(null)
|
||||
private var drawerGameProfileSelectionMade = false
|
||||
private var fpsLimit by mutableStateOf(SessionState.fpsLimit)
|
||||
private var cornerTap by mutableStateOf(false)
|
||||
private fun fpsLimitKey(): String? = if (SessionState.running) SessionPrefs.fpsLimitKey(SessionState.mode, SessionState.gameId)
|
||||
else SessionPrefs.fpsLimitKey(intent.getStringExtra(SessionService.EXTRA_MODE), intent.getStringExtra(SessionService.EXTRA_GAME_ID))
|
||||
private var blackFrameInsertion by mutableStateOf(false)
|
||||
|
||||
private fun noSteamSession(): Boolean = (SessionState.mode == SessionService.MODE_RUN &&
|
||||
@@ -539,9 +548,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var lastMouseY = Float.NaN
|
||||
private var padType by mutableStateOf(SessionPrefs.CONTROLLER_DECK)
|
||||
private var pcKeyboardOpen by mutableStateOf(false)
|
||||
private var fieldKeyboardOnPrimary = false
|
||||
private var pendingFieldKeyboard = false
|
||||
private var fieldKeyboardImeShown = false
|
||||
private var achievementsInFront by mutableStateOf<AchievementsInFront?>(null)
|
||||
private var achievementsOpen by mutableStateOf(false)
|
||||
private var hudOn by mutableStateOf(true)
|
||||
private var gpuClockPin by mutableStateOf(false)
|
||||
private var hudConfig by mutableStateOf<Map<String, String>>(emptyMap())
|
||||
private var hudColor by mutableStateOf(SessionPrefs.HUD_COLOR_MINT)
|
||||
private var hudOpacity by mutableStateOf(SessionPrefs.HUD_OPACITY_DEFAULT)
|
||||
@@ -656,11 +669,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
override fun onDisplayAdded(displayId: Int) {
|
||||
notifyActivityDisplayStateChanged(displayId)
|
||||
refreshSecondScreenDisplays()
|
||||
updateBottomGame()
|
||||
}
|
||||
override fun onDisplayRemoved(displayId: Int) {
|
||||
if (refreshActivityDisplayId() && started) {
|
||||
SessionService.setActivityDisplay(this@SessionActivity, sessionActivityDisplayId)
|
||||
}
|
||||
updateBottomGame()
|
||||
refreshSecondScreenDisplays()
|
||||
}
|
||||
override fun onDisplayChanged(displayId: Int) {
|
||||
@@ -788,9 +803,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
com.droiddeck.launcher.gpu.SteamVrHealth.begin(this, SessionState.sessionId)
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
if (!SessionState.running) {
|
||||
SessionState.fpsLimit = 0
|
||||
fpsLimit = 0
|
||||
SessionState.fpsLimit = SessionPrefs.savedFpsLimit(this, fpsLimitKey())
|
||||
}
|
||||
fpsLimit = SessionState.fpsLimit
|
||||
cornerTap = SessionPrefs.drawerCornerTap(this)
|
||||
applyOutputPacing()
|
||||
if (!SessionState.running) {
|
||||
SessionState.followScreen = followChoice()
|
||||
@@ -814,7 +830,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
pointerCaptureRefused = false
|
||||
if (usbMouse.active) updatePointerCapture()
|
||||
} else {
|
||||
releaseHeldGuestInput()
|
||||
releaseHeldInputOnCaptureLoss()
|
||||
uiHandler.postDelayed(::updatePointerCapture, 250)
|
||||
}
|
||||
}
|
||||
@@ -872,10 +888,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
root.addView(controls)
|
||||
}
|
||||
keyboard = KeyboardHost(this).also { host ->
|
||||
host.onImeChanged = { updateDesktopKeyboardButton() }
|
||||
host.onImeChanged = ::onPrimaryImeChanged
|
||||
root.addView(host)
|
||||
}
|
||||
desktopKeyboardButton = com.droiddeck.launcher.input.DesktopKeyboardButton(this) { keyboard?.show() }
|
||||
desktopKeyboardButton = com.droiddeck.launcher.input.DesktopKeyboardButton(this) { showPrimaryKeyboard() }
|
||||
.also { root.addView(it) }
|
||||
touchpad = TouchpadGestures(PointerGestures.slop(this), pointerListener)
|
||||
directTouchHold = DirectTouchHold(PointerGestures.slop(this), pointerListener, directTouchSink)
|
||||
@@ -893,6 +909,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
drawnRect()?.let { forwardTouch(event, it) }
|
||||
}
|
||||
override fun rightClick(x: Float, y: Float) {
|
||||
if (!screenTapsClick) return
|
||||
pointerListener.onLongPress()
|
||||
pointerListener.onButton(PointerGestures.BTN_RIGHT, true, x, y)
|
||||
surfaceView.postDelayed({ pointerListener.onButton(PointerGestures.BTN_RIGHT, false, x, y) }, 50L)
|
||||
@@ -1011,7 +1028,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
kotlinx.coroutines.delay(2000)
|
||||
}
|
||||
}
|
||||
pip = com.droiddeck.launcher.session.SessionPipController(this, ::pipBounds, ::showPipUi)
|
||||
pip = com.droiddeck.launcher.session.SessionPipController(this, ::pipBounds, ::showPipUi) {
|
||||
intent.getBooleanExtra(EXTRA_RETURN_HOME, false)
|
||||
}
|
||||
surfaceView.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> pip.refresh() }
|
||||
pip.refresh()
|
||||
handleHomeGuideIntent(intent)
|
||||
@@ -1090,6 +1109,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (AgentGuest.keyboardDismissals != keyboardDismissalsSeen[0]) {
|
||||
keyboardDismissalsSeen[0] = AgentGuest.keyboardDismissals
|
||||
secondScreenPresentation?.closeFieldKeyboard()
|
||||
dismissFieldKeyboard()
|
||||
}
|
||||
}
|
||||
androidx.compose.runtime.LaunchedEffect(picturePosition, integerScaling, SessionState.running, pipUi, cardboard.enabled) { applyGameAlignment() }
|
||||
@@ -1130,6 +1150,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
drawerPage = com.droiddeck.launcher.ui.SessionDrawerPage.GLASSES
|
||||
drawerOpen = true
|
||||
}
|
||||
if (!drawerOpen && !pcKeyboardOpen && !loading.visible) {
|
||||
com.droiddeck.launcher.ui.DrawerEntryHint(SessionState.mode == SessionService.MODE_STEAM, backActionsInverted) { drawerOpen = true }
|
||||
if (cornerTap) com.droiddeck.launcher.ui.DrawerCornerTap { drawerOpen = true }
|
||||
}
|
||||
if (loading.visible) LoadingOverlay(
|
||||
loading.step, loading.percent, loading.elapsed, loading.hint, loading.ended,
|
||||
topic = loading.topic, readable = loading.readable,
|
||||
@@ -1231,7 +1255,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onBack = { inputSettingsOpen = false; secondScreenPresentation?.refreshControls() },
|
||||
onChanged = {
|
||||
controllerSettings = ControllerPrefs.read(this@SessionActivity)
|
||||
oscMode = SessionPrefs.oscMode(this@SessionActivity)
|
||||
oscMode = SessionPrefs.oscMode(this@SessionActivity, SessionState.mode == SessionService.MODE_STEAM)
|
||||
padBridge?.setStickDeadZone(ControllerPrefs.deadZone(this@SessionActivity))
|
||||
joyConVr?.refresh()
|
||||
onScreenControls?.reload()
|
||||
@@ -1312,7 +1336,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
if (pcKeyboardOpen) com.droiddeck.launcher.ui.PcKeyboard(
|
||||
sendKey = { code, down -> if (CompositorHost.isStarted) sendGuestKey(code, down, 32) },
|
||||
onAndroidKeyboard = { pcKeyboardOpen = false; keyboard?.toggle() },
|
||||
onAndroidKeyboard = { pcKeyboardOpen = false; togglePrimaryKeyboard() },
|
||||
onClose = { pcKeyboardOpen = false },
|
||||
)
|
||||
if (!drawerDocked) SessionMenu(
|
||||
@@ -1387,6 +1411,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
androidApps = androidApps,
|
||||
hudOn = hudOn,
|
||||
hudConfig = hudConfig,
|
||||
gpuClockPin = gpuClockPin,
|
||||
upscaler = upscaler, upscaleSharpness = upscaleSharpness,
|
||||
effects = effects,
|
||||
screenEffectsTarget = screenEffectsTarget,
|
||||
@@ -1436,12 +1461,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
secondScreenNone = !bottomOutputActive && !dockDrawer(),
|
||||
gameOnBottom = bottomOutputActive,
|
||||
gameSwapAvailable = bottomSwapAvailable,
|
||||
gameSwapBuiltIn = !::displayManager.isInitialized || displayManager.getDisplay(selectedSecondScreenDisplay)
|
||||
?.let(com.droiddeck.launcher.input.DualScreen::builtIn) ?: true,
|
||||
onGameOnBottom = { on -> drawerOpen = false; putGameOnBottom(on) },
|
||||
dashboardAvailable = bottomPages().isNotEmpty(),
|
||||
desktopAvailable = com.droiddeck.launcher.session.BottomDesktop.available(),
|
||||
secondScreenDisplays = secondScreenDisplays,
|
||||
selectedSecondScreenDisplay = selectedSecondScreenDisplay,
|
||||
onHud = { on -> SessionPrefs.setHudEnabled(this@SessionActivity, on); hudOn = on; hud.refresh() },
|
||||
onGpuClockPin = { on ->
|
||||
SessionPrefs.setGpuClockPin(this@SessionActivity, on)
|
||||
gpuClockPin = on
|
||||
Thread {
|
||||
synchronized(GpuClockPin) { GpuClockPin.sync(applicationContext)?.let { Log.i(TAG, it) } }
|
||||
runOnUiThread { gpuClockPin = gpuClockHeld() }
|
||||
}.start()
|
||||
},
|
||||
onHudSetting = { key, value -> hudConfig = DroidDeckHudConfig.set(this@SessionActivity, key, value); hud.applyConfig() },
|
||||
onHudOrder = { switches, order -> hudConfig = DroidDeckHudConfig.choose(this@SessionActivity, switches, order); hud.applyConfig() },
|
||||
onHudReset = { hudConfig = DroidDeckHudConfig.reset(this@SessionActivity); hud.applyConfig() },
|
||||
@@ -1598,8 +1633,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onFpsLimit = { fps ->
|
||||
SessionState.fpsLimit = fps
|
||||
fpsLimit = fps
|
||||
SessionPrefs.saveFpsLimit(this@SessionActivity, fpsLimitKey(), fps)
|
||||
applyOutputPacing()
|
||||
},
|
||||
cornerTap = cornerTap,
|
||||
onCornerTap = { on -> SessionPrefs.setDrawerCornerTap(this@SessionActivity, on); cornerTap = on },
|
||||
blackFrameInsertion = blackFrameInsertion,
|
||||
blackFrameInsertionAvailable = blackFrameInsertion || blackFrameInsertionAvailable(),
|
||||
onBlackFrameInsertion = { on ->
|
||||
@@ -1629,7 +1667,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
pickLossless.launch(InAppFilePicker.buildIntent(
|
||||
this@SessionActivity, listOf("dll"), getString(R.string.lsfg_pick_title)))
|
||||
},
|
||||
onKeyboard = { drawerOpen = false; pcKeyboardOpen = false; keyboard?.toggle() },
|
||||
onKeyboard = { drawerOpen = false; pcKeyboardOpen = false; togglePrimaryKeyboard() },
|
||||
onHardwareKeyboard = ::togglePcKeyboard,
|
||||
wowChatShown = com.droiddeck.launcher.ui.WowChat.isWow(AgentGuest.gameProgram),
|
||||
wowChat = wowChat.remembered,
|
||||
@@ -1723,10 +1761,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onFexPreset = { v -> SessionPrefs.setFexPreset(this@SessionActivity, v); readPrefs() },
|
||||
onSecondScreenMode = { mode ->
|
||||
if (docked) drawerOpen = false
|
||||
typingReturnMode = null
|
||||
automaticPanel = false
|
||||
if (mode != SecondScreenMode.NONE) SessionPrefs.setSecondScreenPanel(this@SessionActivity, desktopSession, mode.id)
|
||||
selectSecondScreenMode(mode)
|
||||
pickSecondScreenMode(mode)
|
||||
},
|
||||
onSecondScreenDisplay = ::selectSecondScreenDisplay,
|
||||
onLaunchAndroidApp = { app, displayId ->
|
||||
@@ -1860,7 +1895,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val all = com.droiddeck.launcher.input.VrControllers.Emulate.entries
|
||||
com.droiddeck.launcher.input.VrControllers.setEmulate(this, all[(pads.emulate.ordinal + 1) % all.size])
|
||||
}) else null,
|
||||
onKeyboard = { keyboard?.toggle() },
|
||||
onKeyboard = { togglePrimaryKeyboard() },
|
||||
onSessionMenu = { drawerOpen = true },
|
||||
onStopSteamVr = if (vr) ({ steamVrAction("stop") }) else null,
|
||||
brightness = glasses.brightness,
|
||||
@@ -1901,12 +1936,44 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun togglePcKeyboard() {
|
||||
drawerOpen = false
|
||||
keyboard?.hide()
|
||||
hidePrimaryKeyboard()
|
||||
onScreenControls?.releaseAll()
|
||||
bottomInputControls?.releaseAll()
|
||||
pcKeyboardOpen = !pcKeyboardOpen
|
||||
}
|
||||
|
||||
private fun showPrimaryKeyboard() {
|
||||
pendingFieldKeyboard = false
|
||||
fieldKeyboardOnPrimary = false
|
||||
keyboard?.show()
|
||||
}
|
||||
|
||||
private fun togglePrimaryKeyboard() {
|
||||
pendingFieldKeyboard = false
|
||||
fieldKeyboardOnPrimary = false
|
||||
keyboard?.toggle()
|
||||
}
|
||||
|
||||
private fun hidePrimaryKeyboard() {
|
||||
pendingFieldKeyboard = false
|
||||
fieldKeyboardOnPrimary = false
|
||||
keyboard?.hide()
|
||||
}
|
||||
|
||||
private fun onPrimaryImeChanged(visible: Boolean) {
|
||||
if (visible) fieldKeyboardImeShown = true
|
||||
else if (fieldKeyboardImeShown) {
|
||||
fieldKeyboardImeShown = false
|
||||
fieldKeyboardOnPrimary = false
|
||||
}
|
||||
updateDesktopKeyboardButton()
|
||||
}
|
||||
|
||||
private fun dismissFieldKeyboard() {
|
||||
pendingFieldKeyboard = false
|
||||
if (fieldKeyboardOnPrimary) hidePrimaryKeyboard()
|
||||
}
|
||||
|
||||
private fun updateControllerPrefs(change: () -> Unit) {
|
||||
change()
|
||||
controllerSettings = ControllerPrefs.read(this)
|
||||
@@ -2414,6 +2481,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun gpuClockHeld() = SessionPrefs.gpuClockPin(this) && !GpuClockPin.failed
|
||||
|
||||
private fun readPrefs() {
|
||||
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
||||
unfoldedControls = SessionPrefs.unfoldedControls(this)
|
||||
@@ -2421,6 +2490,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
picturePosition = SessionPrefs.picturePosition(this)
|
||||
integerScaling = SessionPrefs.integerScaling(this)
|
||||
hudOn = SessionPrefs.hudEnabled(this)
|
||||
gpuClockPin = gpuClockHeld()
|
||||
blackFrameInsertion = SessionPrefs.blackFrameInsertion(this)
|
||||
hudConfig = DroidDeckHudConfig.load(this)
|
||||
hudColor = SessionPrefs.hudColor(this)
|
||||
@@ -2464,7 +2534,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
fexPreset = SessionPrefs.fexPreset(this)
|
||||
suspendPolicy = SessionPrefs.suspendPolicy(this, SessionState.mode)
|
||||
steamDownloadsInBackground = SessionPrefs.steamDownloadsInBackground(this)
|
||||
oscMode = SessionPrefs.oscMode(this)
|
||||
oscMode = SessionPrefs.oscMode(this, SessionState.mode == SessionService.MODE_STEAM)
|
||||
backHold = SessionPrefs.backHold(this)
|
||||
backActionsInverted = SessionPrefs.backActionsInverted(this)
|
||||
physicalShortcuts.bindings = PhysicalShortcuts.read(this)
|
||||
@@ -2691,7 +2761,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val waylandLog = File(SessionPaths.beginOrCurrent(this), "wayland.log")
|
||||
WaylandCompositor.setSessionLogFile(waylandLog)
|
||||
try {
|
||||
android.system.Os.setenv("BL_WAYLAND_LOG", waylandLog.path, true)
|
||||
android.system.Os.setenv("DD_WAYLAND_LOG", waylandLog.path, true)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "could not point the compositor's log at $waylandLog", e)
|
||||
}
|
||||
@@ -2884,7 +2954,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val display = if (Build.VERSION.SDK_INT >= 30) display else windowManager.defaultDisplay
|
||||
val wanted = window.attributes.preferredDisplayModeId
|
||||
val requested = display?.supportedModes?.firstOrNull { wanted != 0 && it.modeId == wanted }?.refreshRate
|
||||
val running = display?.refreshRate?.takeIf { it > 1f }
|
||||
// Display.refreshRate reports a per-app frame rate override (Game Mode FPS) instead of the panel's mode.
|
||||
val running = display?.mode?.refreshRate?.takeIf { it > 1f }
|
||||
val hz = listOfNotNull(requested, running).minOrNull() ?: 60f
|
||||
val mirrorCap = mirrorRefreshLimit().takeIf { it > 0 }?.toFloat() ?: Float.POSITIVE_INFINITY
|
||||
val capped = minOf(hz, PerfMode.peakRefreshCap(this), mirrorCap)
|
||||
@@ -3244,8 +3315,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
}
|
||||
|
||||
private fun prootFailureHint(): EndHint? {
|
||||
if (SessionState.failureCode != "PROOT_MISSING") return null
|
||||
private fun startFailureHint(): EndHint? {
|
||||
val code = SessionState.failureCode ?: return null
|
||||
if (code == "GUEST_EXIT") return null
|
||||
val message = SessionState.failureMessage ?: return null
|
||||
return EndHint(message)
|
||||
}
|
||||
@@ -3255,7 +3327,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun sessionExitHint(status: Int): EndHint? = if (status == 0) presentationFaultHint()
|
||||
else runtimeDamageHint() ?: sessionEndHint(SessionState.logFile) ?: prootFailureHint()
|
||||
else runtimeDamageHint() ?: sessionEndHint(SessionState.logFile) ?: startFailureHint()
|
||||
|
||||
private fun sessionEndHint(log: File?): EndHint? {
|
||||
presentationFaultHint()?.let { return it }
|
||||
@@ -3422,7 +3494,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (drawerOpen) {
|
||||
if (fromController && (event.keyCode == KeyEvent.KEYCODE_BUTTON_L1 || event.keyCode == KeyEvent.KEYCODE_BUTTON_R1)) {
|
||||
if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
|
||||
drawerPage = sessionDrawerPages(secondScreenDisplays.isNotEmpty(), glasses.present)
|
||||
drawerPage = sessionDrawerPages(glasses.present)
|
||||
.step(drawerPage, if (event.keyCode == KeyEvent.KEYCODE_BUTTON_R1) 1 else -1)
|
||||
releaseDrawerDirection()
|
||||
}
|
||||
@@ -3656,7 +3728,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val target = com.droiddeck.launcher.input.DualScreen.sessionDisplay(this, displayManager, shownOnDisplayId) ?: return false
|
||||
return try {
|
||||
val presentation = secondScreenPresentation ?: secondScreenPresentation(target).also {
|
||||
selectedSecondScreenDisplay = target.displayId
|
||||
secondScreenPresentation = it
|
||||
}
|
||||
if (!presentation.isShowing) presentation.show()
|
||||
@@ -4015,16 +4086,23 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val candidates = SecondScreenDisplays.available(displayManager, primaryId)
|
||||
.filter { glassesScreen == null || it.id != glasses.displayId }
|
||||
val oldIds = secondScreenDisplays.map { it.id }.toSet()
|
||||
val oldSelectedDisplay = selectedSecondScreenDisplay
|
||||
secondScreenDisplays = candidates
|
||||
reconcileDock(primaryId)
|
||||
bottomSwapAvailable = bottomGame != null || bottomGameDisplay() != null
|
||||
val newIds = candidates.map { it.id }.toSet()
|
||||
if (secondScreenMode != SecondScreenMode.NONE && oldIds.isNotEmpty() && selectedSecondScreenDisplay !in newIds) {
|
||||
bottomSwapAvailable = bottomGame != null
|
||||
closeSecondScreen(reset = true)
|
||||
SessionState.secondScreenAutoOpened = false
|
||||
return
|
||||
}
|
||||
if (selectedSecondScreenDisplay !in newIds) selectedSecondScreenDisplay = candidates.firstOrNull()?.id ?: -1
|
||||
selectedSecondScreenDisplay = SecondScreenDisplays.selection(selectedSecondScreenDisplay, candidates.map { it.id }, gameOnBottom) {
|
||||
SessionState.secondScreenDisplay = it
|
||||
}
|
||||
if (selectedSecondScreenDisplay != oldSelectedDisplay) {
|
||||
updateBottomGame()
|
||||
}
|
||||
bottomSwapAvailable = bottomGame != null || bottomGameDisplay() != null
|
||||
if (secondScreenMode != SecondScreenMode.NONE && candidates.isEmpty()) {
|
||||
closeSecondScreen(reset = true)
|
||||
SessionState.secondScreenAutoOpened = false
|
||||
@@ -4046,12 +4124,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun openDualScreenControls() {
|
||||
if (SessionState.secondScreenAutoOpened || secondScreenMode != SecondScreenMode.NONE || pipUi) return
|
||||
if (gameOnBottom && selectedSecondScreenDisplay >= 0 && secondScreenDisplays.none { it.id == selectedSecondScreenDisplay }) return
|
||||
if (!SessionPrefs.dualScreenSessionControls(this)) return
|
||||
val target = com.droiddeck.launcher.input.DualScreen.sessionDisplay(this, displayManager, shownOnDisplayId) ?: return
|
||||
if (secondScreenDisplays.none { it.id == target.displayId }) return
|
||||
val gameDisplay = bottomGame?.display?.displayId
|
||||
?: if (SessionState.gameOnBottom) bottomGameDisplay()?.displayId else null
|
||||
SessionState.secondScreenAutoOpened = true
|
||||
selectedSecondScreenDisplay = target.displayId
|
||||
selectSecondScreenMode(openingPanel())
|
||||
if (gameDisplay != null && gameDisplay != target.displayId && secondScreenDisplays.any { it.id == gameDisplay }) {
|
||||
panelMode(openingPanel())
|
||||
} else {
|
||||
val selectionChanged = selectedSecondScreenDisplay != target.displayId
|
||||
selectedSecondScreenDisplay = target.displayId
|
||||
SessionState.secondScreenDisplay = target.displayId
|
||||
if (selectionChanged) updateBottomGame()
|
||||
selectSecondScreenMode(openingPanel())
|
||||
}
|
||||
automaticPanel = secondScreenMode != SecondScreenMode.NONE
|
||||
dualControlsProvisional = ::loading.isInitialized && loading.visible
|
||||
}
|
||||
@@ -4077,6 +4165,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (secondScreenDisplays.none { it.id == displayId }) return
|
||||
selectedSecondScreenDisplay = displayId
|
||||
SessionState.secondScreenDisplay = displayId
|
||||
updateBottomGame()
|
||||
if (secondScreenMode != SecondScreenMode.NONE) showSecondScreen(secondScreenMode)
|
||||
}
|
||||
|
||||
@@ -4095,6 +4184,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
return
|
||||
}
|
||||
if (selectedSecondScreenDisplay !in secondScreenDisplays.map { it.id }) {
|
||||
if (gameOnBottom && selectedSecondScreenDisplay >= 0) {
|
||||
panelMode(mode)
|
||||
return
|
||||
}
|
||||
selectedSecondScreenDisplay = secondScreenDisplays.first().id
|
||||
}
|
||||
showSecondScreen(mode)
|
||||
@@ -4136,6 +4229,19 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
}
|
||||
|
||||
private fun pickSecondScreenMode(mode: SecondScreenMode) {
|
||||
typingReturnMode = null
|
||||
automaticPanel = false
|
||||
if (mode != SecondScreenMode.NONE) SessionPrefs.setSecondScreenPanel(this, desktopSession, mode.id)
|
||||
selectSecondScreenMode(mode)
|
||||
}
|
||||
|
||||
private fun bottomScreenPicker(mode: SecondScreenMode) = com.droiddeck.launcher.ui.ScreenPicker(
|
||||
com.droiddeck.launcher.ui.secondScreenModes(false, SessionState.deckPad, bottomPages().isNotEmpty(),
|
||||
com.droiddeck.launcher.session.BottomDesktop.available()),
|
||||
mode, ::pickSecondScreenMode, onMenu = { drawerOpen = true },
|
||||
)
|
||||
|
||||
private fun secondScreenPresentation(target: Display) = SecondScreenPresentation(
|
||||
this, target,
|
||||
onSteamMenu = ::tapSteamButton,
|
||||
@@ -4144,6 +4250,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
pad = padBridge,
|
||||
onKeyboardClosed = ::bottomKeyboardClosed,
|
||||
onMenu = { drawerOpen = true },
|
||||
picker = ::bottomScreenPicker,
|
||||
onMenuTouched = {
|
||||
if (drawerPinned) {
|
||||
drawerPinned = false
|
||||
@@ -4173,7 +4280,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
)
|
||||
}
|
||||
},
|
||||
onSwap = if (bottomSwapAvailable && com.droiddeck.launcher.input.DualScreen.builtIn(target)) ({ putGameOnBottom(true) }) else null,
|
||||
onSwap = if (bottomSwapAvailable) ({ putGameOnBottom(true) }) else null,
|
||||
onDeckPanel = ::selectDeckPanel,
|
||||
dashboard = if (bottomPages().isEmpty()) null else ({
|
||||
DroidDeckTheme {
|
||||
@@ -4277,6 +4384,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val library = com.droiddeck.launcher.input.InputLibraries.read(this)
|
||||
val desktop = loadingMode() == SessionService.MODE_DESKTOP
|
||||
inputProfile = library.compileActive(desktop, secondScreenMode.panel(this))
|
||||
stockInputProfile = library.compileStock(desktop, secondScreenMode.panel(this))
|
||||
primaryInputLayout = library.activeLayout(desktop, InputRole.PRIMARY)
|
||||
adaptiveSticks = primaryInputLayout?.adaptiveSticks
|
||||
quickButtons = primaryInputLayout?.takeIf { it.editable }?.let { l -> l.quickButtons.associateWith { it !in l.style.hidden } }.orEmpty()
|
||||
@@ -4416,6 +4524,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (!started) return null
|
||||
if (secondScreenPresentation?.showsKeyboard != true && dockDrawer()) {
|
||||
val target = com.droiddeck.launcher.input.DualScreen.sessionDisplay(this, displayManager, shownOnDisplayId) ?: return null
|
||||
if (gameOnBottom && selectedSecondScreenDisplay != target.displayId) return null
|
||||
if (drawerOpen || drawerPinned) drawerOpen = false
|
||||
typingReturnMode = secondScreenMode
|
||||
selectedSecondScreenDisplay = target.displayId
|
||||
@@ -4425,16 +4534,37 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun openBottomKeyboard() {
|
||||
val presentation = bottomKeyboardPresentation() ?: return
|
||||
val presentation = bottomKeyboardPresentation()
|
||||
if (presentation == null) {
|
||||
if (keyboardBelongsOnPrimary()) {
|
||||
pendingFieldKeyboard = true
|
||||
retryFieldKeyboard(hasWindowFocus())
|
||||
}
|
||||
return
|
||||
}
|
||||
pendingFieldKeyboard = false
|
||||
if (fieldKeyboardOnPrimary) hidePrimaryKeyboard()
|
||||
presentation.requestKeyboard(forField = true)
|
||||
com.droiddeck.launcher.ui.SessionTyping.focusDisplay(this, presentation.display.displayId)
|
||||
}
|
||||
|
||||
private fun keyboardBelongsOnPrimary() = SecondScreenDisplays.keyboardOnPrimary(gameOnBottom, selectedSecondScreenDisplay,
|
||||
secondScreenDisplays.map { it.id }, taken = com.droiddeck.launcher.input.DualScreen::taken)
|
||||
|
||||
private fun retryFieldKeyboard(hasFocus: Boolean) {
|
||||
if (!pendingFieldKeyboard || !hasFocus || !resumed || pipUi) return
|
||||
pendingFieldKeyboard = false
|
||||
if (!keyboardBelongsOnPrimary()) return
|
||||
fieldKeyboardOnPrimary = true
|
||||
fieldKeyboardImeShown = keyboard?.hideMeansDismissal == true
|
||||
keyboard?.show()
|
||||
}
|
||||
|
||||
private fun onGameTextField(focused: Boolean) {
|
||||
if (!focused || !com.droiddeck.launcher.ui.WowChat.isWow(AgentGuest.gameProgram)) wowChat.chatClosed()
|
||||
else if (resumed && !pipUi && !pcKeyboardOpen &&
|
||||
resources.configuration.hardKeyboardHidden != android.content.res.Configuration.HARDKEYBOARDHIDDEN_NO) {
|
||||
keyboard?.takeIf { it.shown }?.hide()
|
||||
hidePrimaryKeyboard()
|
||||
wowChat.chatOpened()
|
||||
}
|
||||
}
|
||||
@@ -4521,9 +4651,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun updateKeyboardRoute() {
|
||||
AgentGuest.routeKeyboard(this, SessionState.mode == SessionService.MODE_STEAM &&
|
||||
(secondScreenPresentation?.showsKeyboard == true || dockDrawer()) &&
|
||||
SessionPrefs.androidTextFieldKeyboard(this))
|
||||
AgentGuest.routeKeyboard(this, SecondScreenDisplays.routeKeyboard(
|
||||
SessionState.mode == SessionService.MODE_STEAM,
|
||||
SessionPrefs.androidTextFieldKeyboard(this),
|
||||
secondScreenPresentation?.showsKeyboard == true,
|
||||
dockDrawer(),
|
||||
SecondScreenDisplays.keyboardOnPrimary(gameOnBottom, selectedSecondScreenDisplay,
|
||||
secondScreenDisplays.map { it.id }, resumed && !pipUi, com.droiddeck.launcher.input.DualScreen::taken)))
|
||||
}
|
||||
|
||||
private fun dropDockedDrawer() {
|
||||
@@ -4734,6 +4868,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var lockedSwipeY = 0f
|
||||
private var dismissTouch = false
|
||||
private var sessionTouchDown = false
|
||||
private var screenTapsClick = true
|
||||
|
||||
private fun onScreenMouseButtonShown(): Boolean = listOfNotNull(
|
||||
onScreenControls?.inputSurface, bottomInputControls?.inputSurface, unfoldedPanel?.inputSurface, unfoldedDeckSurface,
|
||||
secondScreenPresentation?.controlsView, swappedInputSurface,
|
||||
).any { it.isShown && inputProfile.showsMouseButton(it.inputRole, it.shownElements, stockInputProfile) }
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
val pen = PenStream.penIndex(event)
|
||||
@@ -4766,6 +4906,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
val snapshot = fingerTouchSnapshot(uiBlocking)
|
||||
val route = com.droiddeck.launcher.input.TouchRouter.decide(snapshot)
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
|
||||
screenTapsClick = !onScreenMouseButtonShown()
|
||||
if (::touchpad.isInitialized) touchpad.clicks = screenTapsClick
|
||||
if (::scrollTouch.isInitialized) scrollTouch.clicks = screenTapsClick
|
||||
}
|
||||
if (route != touchRoute) {
|
||||
Log.i(TAG, "touch route $touchRoute -> $route (mode=$routedTouchMode steamUi=${SessionState.steamUi} scrollLayer=$scrollTouchGesture)")
|
||||
touchRoute = route
|
||||
@@ -4915,6 +5060,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) ignoreGameTouch = false
|
||||
return true
|
||||
}
|
||||
// With an on-screen mouse button the press comes from the button, so the pointer has to be there before
|
||||
// the two-finger gesture buffer holds the touch-down.
|
||||
if (SessionState.mode == SessionService.MODE_DESKTOP && !screenTapsClick && !pointerLocked &&
|
||||
event.actionMasked == MotionEvent.ACTION_DOWN) movePointer(event.x, event.y)
|
||||
if (SessionState.mode == SessionService.MODE_DESKTOP && twoFingerGestures.onTouch(event)) return true
|
||||
return forwardTouch(event, rect)
|
||||
}
|
||||
@@ -4949,7 +5098,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
}
|
||||
}
|
||||
directTouchHold.onTouch(event)
|
||||
if (screenTapsClick) directTouchHold.onTouch(event)
|
||||
else if (!pointerLocked && (event.actionMasked == MotionEvent.ACTION_DOWN || event.actionMasked == MotionEvent.ACTION_MOVE))
|
||||
movePointer(event.x, event.y)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -4996,10 +5147,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun relativeMouseAttached(): Boolean = !isInMultiWindowMode && !glassesOutputActive && mouseAttached()
|
||||
|
||||
private fun sessionOwnsInput() =
|
||||
resumed && !drawerOpen && !pcKeyboardOpen && !achievementsOpen && !inputSettingsOpen &&
|
||||
!pipUi && !bottomOutputActive && !touchEditorOpen && !wowChatOnTop
|
||||
|
||||
private fun updatePointerCapture() {
|
||||
if (!::surfaceView.isInitialized) return
|
||||
val view = window.decorView
|
||||
val want = (pointerLocked || relativeMouseAttached()) && resumed && hasWindowFocus() && !drawerOpen && !pcKeyboardOpen && !achievementsOpen && !inputSettingsOpen && !pipUi && !bottomOutputActive && !touchEditorOpen && !wowChatOnTop && mouseAttached()
|
||||
val want = (pointerLocked || relativeMouseAttached()) && sessionOwnsInput() && hasWindowFocus() && mouseAttached()
|
||||
releaseDesktopMouseGrab()
|
||||
updateUsbMouse(want)
|
||||
if (want == view.hasPointerCapture()) return
|
||||
@@ -5183,7 +5338,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val forced = File(Environment.getExternalStorageDirectory(), "Download/droiddeck-osc")
|
||||
.takeIf { it.isFile }
|
||||
?.let { FileUtils.readString(it)?.trim()?.lowercase() }
|
||||
?: SessionPrefs.oscMode(this)
|
||||
?: SessionPrefs.oscMode(this, SessionState.mode == SessionService.MODE_STEAM)
|
||||
val controls = onScreenControls ?: return
|
||||
fun showPinned() {
|
||||
controls.setPinnedOnly(true)
|
||||
@@ -5322,14 +5477,26 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private fun keyboardCoversPad() =
|
||||
SessionState.mode == SessionService.MODE_STEAM && AgentGuest.steamKeyboard
|
||||
|
||||
private fun releaseHeldGuestInput() {
|
||||
private fun releaseHeldInputOnCaptureLoss() {
|
||||
if (sessionOwnsInput()) releaseHeldPointerInput() else releaseHeldGuestInput()
|
||||
}
|
||||
|
||||
private fun releaseHeldPointerInput() {
|
||||
mouseBackInput.cancel()
|
||||
cancelPen(releaseKey = true)
|
||||
heldButtons.release(1 or 2 or 8 or 16)
|
||||
}
|
||||
|
||||
private fun releaseHeldKeys() {
|
||||
guestKeysDown.toList().forEach { sendGuestKey(it, false) }
|
||||
heldKeys.release(8 or 16 or 32)
|
||||
}
|
||||
|
||||
private fun releaseHeldGuestInput() {
|
||||
releaseHeldPointerInput()
|
||||
releaseHeldKeys()
|
||||
}
|
||||
|
||||
private fun sendGuestKey(key: Int, down: Boolean, owner: Int = 1) {
|
||||
if (down && pipUi) return
|
||||
val code = if (key == KEY_RIGHTCTRL && SessionState.mode == SessionService.MODE_DESKTOP) KEY_LEFTCTRL else key
|
||||
@@ -5405,6 +5572,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun showPipUi(show: Boolean) {
|
||||
pipUi = show
|
||||
updateKeyboardRoute()
|
||||
if (!show) retryFieldKeyboard(hasWindowFocus())
|
||||
if (show) {
|
||||
if (::hud.isInitialized) hud.setHidden(true)
|
||||
drawerOpen = false
|
||||
@@ -5424,7 +5593,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
guestKeysDown.toList().forEach { sendGuestKey(it, false) }
|
||||
heldKeys.clear()
|
||||
heldButtons.clear()
|
||||
keyboard?.hide()
|
||||
hidePrimaryKeyboard()
|
||||
sessionClipboard.stop()
|
||||
padMotion?.stop()
|
||||
cursorVisible = false
|
||||
@@ -5526,6 +5695,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (this.intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) intent.putExtra(EXTRA_RETURN_HOME, true)
|
||||
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
|
||||
@@ -5567,6 +5737,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onScreenControls?.reload()
|
||||
controllerSettings = ControllerPrefs.read(this)
|
||||
resumed = true
|
||||
updateKeyboardRoute()
|
||||
retryFieldKeyboard(hasWindowFocus())
|
||||
updateDesktopKeyboardButton()
|
||||
com.droiddeck.launcher.input.HomeButtonShortcuts.attach(this,
|
||||
enabled = {
|
||||
@@ -5604,9 +5776,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
departureCleanup()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
private fun departureCleanup() {
|
||||
com.droiddeck.launcher.input.SystemKeyCapture.detach(this)
|
||||
com.droiddeck.launcher.input.HomeButtonShortcuts.detach(this)
|
||||
if (runtimeRemovalBlocked) { super.onPause(); return }
|
||||
if (runtimeRemovalBlocked) return
|
||||
physicalShortcuts.clear()
|
||||
backQamInput.cancel()
|
||||
mouseBackInput.cancel()
|
||||
@@ -5640,14 +5817,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (::scrollTouch.isInitialized) scrollTouch.cancel()
|
||||
if (::padMouse.isInitialized) padMouse.reset()
|
||||
resumed = false
|
||||
updateKeyboardRoute()
|
||||
updatePointerCapture()
|
||||
updatePadMotion()
|
||||
keyboard?.takeIf { it.shown }?.hide()
|
||||
val pendingKeyboard = pendingFieldKeyboard
|
||||
hidePrimaryKeyboard()
|
||||
pendingFieldKeyboard = pendingKeyboard
|
||||
SessionPrefs.sessionPrefs(this).unregisterOnSharedPreferenceChangeListener(cardboardPrefListener)
|
||||
SessionPrefs.sessionPrefs(this).unregisterOnSharedPreferenceChangeListener(screenEffectsProfilePrefListener)
|
||||
ControllerPrefs.prefs(this).unregisterOnSharedPreferenceChangeListener(shortcutPrefListener)
|
||||
updateHeadTracker()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
private fun steamVrAction(action: String) {
|
||||
@@ -5888,9 +6067,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun bottomGameDisplay(): Display? {
|
||||
if (!::displayManager.isInitialized) return null
|
||||
return com.droiddeck.launcher.input.DualScreen.sessionDisplay(this, displayManager, shownOnDisplayId)
|
||||
?.takeIf { it.isValid && com.droiddeck.launcher.input.DualScreen.builtIn(it) }
|
||||
if (!::displayManager.isInitialized || SessionPrefs.dualScreenSessionMode(this) == com.droiddeck.launcher.input.DualScreen.MODE_OFF) return null
|
||||
return com.droiddeck.launcher.input.DualScreen.selectedSessionDisplay(
|
||||
this, displayManager, shownOnDisplayId, selectedSecondScreenDisplay,
|
||||
)
|
||||
}
|
||||
|
||||
private fun putGameOnBottom(on: Boolean) {
|
||||
@@ -6016,7 +6196,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
tabs = tabs,
|
||||
)
|
||||
val keyboardExtra = com.droiddeck.launcher.ui.BarExtra(getString(R.string.second_show_keyboard), icon = R.drawable.ic_bottom_keyboard) {
|
||||
keyboard?.toggle()
|
||||
togglePrimaryKeyboard()
|
||||
}
|
||||
val profileLayout = secondaryInputLayout
|
||||
androidx.compose.foundation.layout.Box(
|
||||
@@ -6044,8 +6224,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
androidx.compose.runtime.key(profileLayout) {
|
||||
androidx.compose.ui.viewinterop.AndroidView(
|
||||
factory = { context -> com.droiddeck.launcher.ui.InputSurfaceView(context, padBridge, profileLayout?.elements.orEmpty(),
|
||||
surfaceStyle = profileLayout?.style ?: com.droiddeck.launcher.input.InputSurfaceStyle()) },
|
||||
surfaceStyle = profileLayout?.style ?: com.droiddeck.launcher.input.InputSurfaceStyle()).also { swappedInputSurface = it } },
|
||||
modifier = Modifier.fillMaxWidth().weight(1f),
|
||||
onRelease = { if (swappedInputSurface === it) swappedInputSurface = null },
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -6212,6 +6393,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
releaseHeldGuestInput()
|
||||
}
|
||||
if (hasFocus && !pipUi) {
|
||||
retryFieldKeyboard(true)
|
||||
goFullscreen()
|
||||
refreshClipboard()
|
||||
}
|
||||
|
||||
@@ -76,6 +76,9 @@ class AgentBridgeProvider : ContentProvider() {
|
||||
"stop" -> stop(context)
|
||||
"resume" -> resume(context)
|
||||
"launch" -> launch(context, request)
|
||||
"library" -> AgentStores.library(context, request)
|
||||
"xodus" -> AgentStores.xodus(context, request)
|
||||
"cloud" -> AgentStores.cloud(context, request)
|
||||
"focus" -> guest(context, JSONObject().put("kind", "focus"), 15_000)
|
||||
"quit" -> guest(context, JSONObject().put("kind", "quit").put("appId", request.opt("appId"))
|
||||
.put("timeout", request.optDouble("timeout", 15.0)), timeoutMs(request, 15.0, 30_000))
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.droiddeck.launcher.agent
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
|
||||
/** The text typed in the Agent tab and not yet sent, kept across leaving the tab and restarts. */
|
||||
object AgentDraft {
|
||||
private const val KEY = "draft"
|
||||
private var state: MutableState<String>? = null
|
||||
|
||||
fun state(context: Context): MutableState<String> = state ?: run {
|
||||
val prefs = AgentHost.prefs(context.applicationContext)
|
||||
val backing = mutableStateOf(prefs.getString(KEY, "") ?: "")
|
||||
object : MutableState<String> {
|
||||
override var value: String
|
||||
get() = backing.value
|
||||
set(text) {
|
||||
if (text == backing.value) return
|
||||
backing.value = text
|
||||
prefs.edit().apply { if (text.isEmpty()) remove(KEY) else putString(KEY, text) }.apply()
|
||||
}
|
||||
override fun component1() = value
|
||||
override fun component2(): (String) -> Unit = { value = it }
|
||||
}.also { state = it }
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,8 @@ object AgentEnv {
|
||||
fun override(context: Context, name: String): JSONObject = synchronized(lock) {
|
||||
AgentAccess.requireCommands(context)
|
||||
if (NAME.matchEntire(name) == null || name in setOf(".", "..")) throw AgentException("INVALID_NAME", "Override names are letters, digits, '.', '_' and '-'")
|
||||
if (name == "libblfastpath.so" && (SessionState.running || SessionState.guestPid > 0 || SessionState.phase == SessionPhase.STOPPING)) {
|
||||
if (name == LEGACY_FAST_PATH) throw AgentException("INVALID_NAME", "The fast-path library is now $FAST_PATH")
|
||||
if (name == "libddfastpath.so" && (SessionState.running || SessionState.guestPid > 0 || SessionState.phase == SessionPhase.STOPPING)) {
|
||||
throw AgentException("SESSION_ACTIVE", "Stop the session before installing a fast-path library")
|
||||
}
|
||||
val source = File(inbox(context), name)
|
||||
@@ -73,7 +74,7 @@ object AgentEnv {
|
||||
staged.delete()
|
||||
throw AgentException("OVERRIDE_FAILED", "Could not stage the override")
|
||||
}
|
||||
if (name == "libblfastpath.so" && !arm64SharedLibrary(staged)) {
|
||||
if (name == "libddfastpath.so" && !arm64SharedLibrary(staged)) {
|
||||
staged.delete()
|
||||
throw AgentException("INVALID_LIBRARY", "The fast path must be a 64-bit little-endian ARM64 ELF shared library")
|
||||
}
|
||||
@@ -86,7 +87,7 @@ object AgentEnv {
|
||||
state.put("pendingOverrides", JSONArray(merge(strings(state.optJSONArray("pendingOverrides")), listOf(name))))
|
||||
save(context, state)
|
||||
state.put("installed", "$GUEST_BIN/$name")
|
||||
if (name == "libblfastpath.so") {
|
||||
if (name == "libddfastpath.so") {
|
||||
val digest = MessageDigest.getInstance("SHA-256")
|
||||
target.inputStream().use { input ->
|
||||
val buffer = ByteArray(65536)
|
||||
@@ -103,10 +104,10 @@ object AgentEnv {
|
||||
|
||||
fun fastPathLibrary(context: Context): String = synchronized(lock) {
|
||||
if (!AgentAccess.commandsAllowed(context)) return@synchronized ProotFastPath.LIBRARY
|
||||
if ("libblfastpath.so" !in strings(load(context).optJSONArray("activeOverrides"))) return@synchronized ProotFastPath.LIBRARY
|
||||
val file = File(bin(context), "libblfastpath.so")
|
||||
if ("libddfastpath.so" !in strings(load(context).optJSONArray("activeOverrides"))) return@synchronized ProotFastPath.LIBRARY
|
||||
val file = File(bin(context), "libddfastpath.so")
|
||||
if (!file.isFile || Files.isSymbolicLink(file.toPath())) return@synchronized ProotFastPath.LIBRARY
|
||||
"$GUEST_BIN/libblfastpath.so"
|
||||
"$GUEST_BIN/libddfastpath.so"
|
||||
}
|
||||
|
||||
private fun arm64SharedLibrary(file: File): Boolean = file.inputStream().use { input ->
|
||||
@@ -129,13 +130,18 @@ object AgentEnv {
|
||||
}
|
||||
val state = load(context)
|
||||
val active = strings(state.optJSONArray("pending"))
|
||||
val overrides = strings(state.optJSONArray("pendingOverrides"))
|
||||
val queued = strings(state.optJSONArray("pendingOverrides"))
|
||||
val legacy = File(bin(context), LEGACY_FAST_PATH)
|
||||
val stranded = FAST_PATH in queued && legacy.isFile && !File(bin(context), FAST_PATH).exists() &&
|
||||
!legacy.renameTo(File(bin(context), FAST_PATH))
|
||||
if (stranded) Log.w(TAG, "could not rename the queued $LEGACY_FAST_PATH; it stays queued for the next session")
|
||||
val overrides = if (stranded) queued - FAST_PATH else queued
|
||||
bin(context).listFiles()
|
||||
?.filter { it.name !in overrides }?.forEach { it.delete() }
|
||||
?.filter { it.name !in overrides && !(stranded && it.name == LEGACY_FAST_PATH) }?.forEach { it.delete() }
|
||||
val lines = strings(state.optJSONArray("persistent")) + active
|
||||
val withPath = if (overrides.none { it != "libblfastpath.so" }) lines else lines + "PATH=$GUEST_BIN:${pathOf(lines)}"
|
||||
val withPath = if (overrides.none { it != "libddfastpath.so" }) lines else lines + "PATH=$GUEST_BIN:${pathOf(lines)}"
|
||||
state.put("active", JSONArray(active)).put("pending", JSONArray())
|
||||
state.put("activeOverrides", JSONArray(overrides)).put("pendingOverrides", JSONArray())
|
||||
state.put("activeOverrides", JSONArray(overrides)).put("pendingOverrides", JSONArray(if (stranded) listOf(FAST_PATH) else emptyList()))
|
||||
save(context, state)
|
||||
if (withPath.isNotEmpty()) Log.i(TAG, "agent environment keys for this session: ${withPath.map { it.substringBefore('=') }}")
|
||||
withPath
|
||||
@@ -158,6 +164,9 @@ object AgentEnv {
|
||||
save(context, state)
|
||||
}
|
||||
|
||||
private const val FAST_PATH = "libddfastpath.so"
|
||||
private const val LEGACY_FAST_PATH = "libblfastpath.so"
|
||||
|
||||
private fun pathOf(lines: List<String>) =
|
||||
lines.lastOrNull { it.startsWith("PATH=") }?.substringAfter('=')?.takeIf { it.isNotBlank() } ?: LinuxRuntime.GUEST_PATH
|
||||
|
||||
@@ -186,6 +195,9 @@ object AgentEnv {
|
||||
for (key in listOf("pending", "active", "persistent", "pendingOverrides", "activeOverrides")) {
|
||||
if (!state.has(key)) state.put(key, JSONArray())
|
||||
}
|
||||
for (key in listOf("pendingOverrides", "activeOverrides")) {
|
||||
state.put(key, JSONArray(strings(state.optJSONArray(key)).map { if (it == LEGACY_FAST_PATH) FAST_PATH else it }.distinct()))
|
||||
}
|
||||
return state
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.droiddeck.launcher.agent
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import com.droiddeck.launcher.R
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
/** One coding agent CLI in the Linux userland, run one process per turn (or kept open, see [input]). */
|
||||
/** One coding agent CLI in the Linux userland, run as a process that takes its turns over stdin (see [AgentProtocol]). */
|
||||
interface AgentHarness {
|
||||
val id: String
|
||||
val name: String
|
||||
@@ -19,22 +21,36 @@ interface AgentHarness {
|
||||
val signedIn: List<String>
|
||||
/** A guest command that signs in through $BROWSER. */
|
||||
val signIn: List<String>
|
||||
/**
|
||||
* APIs the CLI reaches with a key pasted into DroidDeck, for a CLI whose own sign-in is a terminal
|
||||
* prompt; empty when it signs in through [signIn].
|
||||
*/
|
||||
val providers: List<Provider> get() = emptyList()
|
||||
/** Ids of the [providers] with a key saved under [rootfs]. */
|
||||
fun keys(rootfs: File): Set<String> = emptySet()
|
||||
/**
|
||||
* Saves [key] for [provider]. A [Provider.custom] one also takes the [endpoint] it is served from, and
|
||||
* [get] fetches a URL from the userland, with the key as a bearer token when it is not null.
|
||||
*/
|
||||
fun saveKey(rootfs: File, provider: Provider, key: String, endpoint: String? = null, get: (String, String?) -> String = { url, _ -> error("Cannot reach $url") }) {}
|
||||
fun removeKey(rootfs: File, provider: Provider) {}
|
||||
/** Whether the CLI has models that need no account; [useFree] then counts as signed in. */
|
||||
val free: Boolean get() = false
|
||||
fun useFree(rootfs: File) {}
|
||||
/** Usage reports the conversation's whole cost rather than the turn's. */
|
||||
val sessionCost: Boolean get() = false
|
||||
/** Whether [Options.plan] means anything to this CLI. */
|
||||
val plans: Boolean
|
||||
/** Reasoning effort levels the CLI accepts, lowest first; empty when it has none. */
|
||||
val efforts: List<String>
|
||||
/** Models to offer besides the CLI's default; [rootfs] is where the CLI's own files can be read. */
|
||||
fun models(rootfs: File): List<Model>
|
||||
/** The guest command for one turn; [conversation] is null for the first one. */
|
||||
/** How the CLI may run its tools, the one that asks before each action first and the default. */
|
||||
val permissions: List<Permission>
|
||||
/** The guest command of the process that runs the conversation's turns; [conversation] is null for a new one. */
|
||||
fun turn(message: String, conversation: String?, options: Options): List<String>
|
||||
/**
|
||||
* The line that hands [message] to a [turn] process over stdin, or null when the message is already in the
|
||||
* command. A process that takes its messages this way stays open between turns, so work it started in the
|
||||
* background can wake it, as it does in the CLI's own terminal.
|
||||
*/
|
||||
fun input(message: String): String? = null
|
||||
/** One line of the CLI's output, or null when it carries nothing to show. */
|
||||
fun parse(line: String): AgentEvent?
|
||||
/** A new reader for one [turn] process; it keeps what that process has said so far. */
|
||||
fun protocol(): AgentProtocol
|
||||
/** The folder, under the userland's root, where the CLI loads user skills (`<name>/SKILL.md`). */
|
||||
val skills: String
|
||||
/** The CLI's global instructions file under the userland's root, where DroidDeck keeps its rules in a marked block. */
|
||||
@@ -46,14 +62,45 @@ interface AgentHarness {
|
||||
|
||||
data class Model(val id: String, val label: String)
|
||||
|
||||
data class Options(val model: String? = null, val plan: Boolean = false, val brief: String? = null, val effort: String? = null)
|
||||
/** An API reached with a key; [keyPage] is where the key is made, and a [custom] one is any OpenAI-compatible server. */
|
||||
data class Provider(val id: String, val name: String, val keyPage: String? = null, val custom: Boolean = false)
|
||||
|
||||
/** A permission mode; [id] is DroidDeck's own name for it, which each CLI maps to its flags. */
|
||||
data class Permission(val id: String, @StringRes val label: Int, @StringRes val hint: Int)
|
||||
|
||||
data class Options(
|
||||
val model: String? = null, val plan: Boolean = false, val brief: String? = null, val effort: String? = null,
|
||||
val permission: String = ASK, val workdir: String = "/root",
|
||||
)
|
||||
|
||||
companion object {
|
||||
val all: List<AgentHarness> = listOf(ClaudeCode, Codex)
|
||||
const val ASK = "ask"
|
||||
const val EDITS = "edits"
|
||||
const val AUTO = "auto"
|
||||
const val DONT_ASK = "dontask"
|
||||
const val FULL = "full"
|
||||
|
||||
val all: List<AgentHarness> = listOf(ClaudeCode, Codex, OpenCode)
|
||||
fun byId(id: String?): AgentHarness = all.firstOrNull { it.id == id } ?: ClaudeCode
|
||||
}
|
||||
}
|
||||
|
||||
/** What goes to one CLI process's stdin, and what its output lines mean. */
|
||||
interface AgentProtocol {
|
||||
/**
|
||||
* The lines that start a turn of [message]; [started] is true for a process that has just been started. The
|
||||
* process stays open between turns, so work it started in the background can wake it.
|
||||
*/
|
||||
fun input(message: String, conversation: String?, options: AgentHarness.Options, started: Boolean): List<String>
|
||||
/** One line of the process's output, or null when it carries nothing to show. */
|
||||
fun parse(line: String): AgentEvent?
|
||||
/** The line that answers [approval]. */
|
||||
fun answer(approval: AgentHost.Approval, allow: Boolean): String
|
||||
}
|
||||
|
||||
/** The message a CLI tells its model when the user denies a tool call. */
|
||||
internal const val DENIED = "The user denied this tool call."
|
||||
|
||||
/** What one line of output carries: whole entries, or text still being written. */
|
||||
data class AgentEvent(
|
||||
val conversation: String? = null,
|
||||
@@ -70,6 +117,12 @@ data class AgentEvent(
|
||||
val background: Boolean = false,
|
||||
/** The error a background turn ended with, if it failed. */
|
||||
val backgroundError: String? = null,
|
||||
/** Lines to write to the process's stdin right away, the next step of a request it has answered. */
|
||||
val reply: List<String> = emptyList(),
|
||||
/** A tool call that waits for the user to allow it. */
|
||||
val approval: AgentHost.Approval? = null,
|
||||
/** The id of an approval the CLI no longer waits for. */
|
||||
val resolved: String? = null,
|
||||
)
|
||||
|
||||
/** Claude Code: `claude -p` with stream-json input and output, resumed by session id. */
|
||||
@@ -111,22 +164,54 @@ object ClaudeCode : AgentHarness {
|
||||
AgentHarness.Model("opus", "Opus"), AgentHarness.Model("sonnet", "Sonnet"), AgentHarness.Model("haiku", "Haiku"),
|
||||
)
|
||||
|
||||
// DroidDeck runs the agent unattended on the user's own device; permission prompts have no one to answer them.
|
||||
override val permissions = listOf(
|
||||
AgentHarness.Permission(AgentHarness.ASK, R.string.agent_permission_ask, R.string.agent_permission_ask_hint),
|
||||
AgentHarness.Permission(AgentHarness.EDITS, R.string.agent_permission_edits, R.string.agent_permission_edits_hint),
|
||||
AgentHarness.Permission(AgentHarness.AUTO, R.string.agent_permission_auto, R.string.agent_permission_auto_hint),
|
||||
AgentHarness.Permission(AgentHarness.DONT_ASK, R.string.agent_permission_dont_ask, R.string.agent_permission_dont_ask_hint),
|
||||
AgentHarness.Permission(AgentHarness.FULL, R.string.agent_permission_full, R.string.agent_permission_full_hint),
|
||||
)
|
||||
|
||||
private val MODES = mapOf(
|
||||
AgentHarness.ASK to "manual", AgentHarness.EDITS to "acceptEdits", AgentHarness.AUTO to "auto",
|
||||
AgentHarness.DONT_ASK to "dontAsk", AgentHarness.FULL to "bypassPermissions",
|
||||
)
|
||||
|
||||
/**
|
||||
* Prompts reach DroidDeck as can_use_tool requests on stdout (the SDK's stdio prompt tool). Plan mode keeps
|
||||
* answering none, so a turn that would leave plan mode ends on its plan.
|
||||
*/
|
||||
override fun turn(message: String, conversation: String?, options: AgentHarness.Options) = buildList {
|
||||
addAll(listOf(binary, "-p", "--input-format", "stream-json", "--output-format", "stream-json", "--verbose", "--include-partial-messages"))
|
||||
addAll(listOf("--permission-mode", if (options.plan) "plan" else "bypassPermissions"))
|
||||
val mode = if (options.plan) "plan" else MODES[options.permission] ?: "manual"
|
||||
addAll(listOf("--permission-mode", mode))
|
||||
if (mode != "plan" && mode != "bypassPermissions") add("--permission-prompt-tool=stdio")
|
||||
options.model?.let { addAll(listOf("--model", it)) }
|
||||
options.effort?.let { addAll(listOf("--effort", it)) }
|
||||
options.brief?.let { addAll(listOf("--append-system-prompt", it)) }
|
||||
if (conversation != null) addAll(listOf("--resume", conversation))
|
||||
}
|
||||
|
||||
override fun input(message: String): String? = JSONObject()
|
||||
fun input(message: String): String = JSONObject()
|
||||
.put("type", "user")
|
||||
.put("message", JSONObject().put("role", "user").put("content", JSONArray().put(JSONObject().put("type", "text").put("text", message))))
|
||||
.toString()
|
||||
|
||||
override fun parse(line: String): AgentEvent? {
|
||||
override fun protocol(): AgentProtocol = object : AgentProtocol {
|
||||
override fun input(message: String, conversation: String?, options: AgentHarness.Options, started: Boolean) = listOf(this@ClaudeCode.input(message))
|
||||
override fun parse(line: String) = this@ClaudeCode.parse(line)
|
||||
override fun answer(approval: AgentHost.Approval, allow: Boolean) = this@ClaudeCode.answer(approval, allow)
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
internal fun answer(approval: AgentHost.Approval, allow: Boolean): String {
|
||||
val decision = if (allow) JSONObject().put("behavior", "allow").put("updatedInput", runCatching { JSONObject(approval.payload) }.getOrDefault(JSONObject()))
|
||||
else JSONObject().put("behavior", "deny").put("message", DENIED)
|
||||
return JSONObject().put("type", "control_response")
|
||||
.put("response", JSONObject().put("subtype", "success").put("request_id", approval.id).put("response", decision)).toString()
|
||||
}
|
||||
|
||||
fun parse(line: String): AgentEvent? {
|
||||
val o = runCatching { JSONObject(line) }.getOrNull() ?: return null
|
||||
val conversation = o.optString("session_id").takeIf { it.isNotEmpty() }
|
||||
// A subagent's messages carry the call that started it; only its tool calls are shown, under that call.
|
||||
@@ -173,6 +258,13 @@ object ClaudeCode : AgentHarness {
|
||||
AgentEvent(conversation, results)
|
||||
}
|
||||
"rate_limit_event" -> AgentEvent(conversation, limits = limits(o.optJSONObject("rate_limit_info")))
|
||||
"control_request" -> {
|
||||
val request = o.optJSONObject("request")?.takeIf { it.optString("subtype") == "can_use_tool" } ?: return null
|
||||
val tool = request.optString("tool_name")
|
||||
val input = request.optJSONObject("input") ?: JSONObject()
|
||||
AgentEvent(approval = AgentHost.Approval(o.optString("request_id"), tool, detail(input), fullInput(tool, input), input.toString()))
|
||||
}
|
||||
"control_cancel_request" -> AgentEvent(resolved = o.optString("request_id"))
|
||||
// The CLI starts turns of its own for background tasks (a resumed session first answers the ones the last
|
||||
// run left behind). Such a result is not the end of the user's turn; the host decides what it ends.
|
||||
"result" -> {
|
||||
@@ -255,7 +347,7 @@ object ClaudeCode : AgentHarness {
|
||||
}.joinToString("\n")
|
||||
}
|
||||
|
||||
/** OpenAI Codex: `codex exec --json`, resumed by thread id. */
|
||||
/** OpenAI Codex: `codex app-server`, its JSON-RPC protocol over stdio, resumed by thread id. */
|
||||
object Codex : AgentHarness {
|
||||
override val id = "codex"
|
||||
override val name = "Codex"
|
||||
@@ -281,6 +373,13 @@ object Codex : AgentHarness {
|
||||
override val plans = false
|
||||
override val efforts = listOf("low", "medium", "high")
|
||||
|
||||
// Codex's sandbox needs Landlock and seccomp, which proot does not provide, so commands run unsandboxed
|
||||
// and "untrusted" is what makes Codex ask before each one that is not known to be safe.
|
||||
override val permissions = listOf(
|
||||
AgentHarness.Permission(AgentHarness.ASK, R.string.agent_permission_ask, R.string.agent_permission_ask_hint),
|
||||
AgentHarness.Permission(AgentHarness.FULL, R.string.agent_permission_full, R.string.agent_permission_full_hint),
|
||||
)
|
||||
|
||||
/** Codex keeps the models its account can use in `~/.codex/models_cache.json` once it has run. */
|
||||
override fun models(rootfs: File): List<AgentHarness.Model> = runCatching {
|
||||
val o = JSONObject(File(rootfs, "root/.codex/models_cache.json").readText())
|
||||
@@ -293,108 +392,652 @@ object Codex : AgentHarness {
|
||||
}
|
||||
}.getOrDefault(emptyList())
|
||||
|
||||
// Codex's own sandbox needs Landlock and seccomp, which proot does not provide.
|
||||
override fun turn(message: String, conversation: String?, options: AgentHarness.Options) = buildList {
|
||||
addAll(listOf(binary, "exec"))
|
||||
if (conversation != null) addAll(listOf("resume", conversation))
|
||||
addAll(listOf("--json", "--dangerously-bypass-approvals-and-sandbox", "--skip-git-repo-check"))
|
||||
options.model?.let { addAll(listOf("-m", it)) }
|
||||
options.effort?.let { addAll(listOf("-c", "model_reasoning_effort=\"$it\"")) }
|
||||
// codex exec has no system prompt option, so a new conversation starts with the brief.
|
||||
add(if (conversation == null && options.brief != null) "${options.brief}\n\n$message" else message)
|
||||
}
|
||||
override fun turn(message: String, conversation: String?, options: AgentHarness.Options) = withoutStderr("codex", listOf(binary, "app-server"))
|
||||
|
||||
override fun parse(line: String): AgentEvent? {
|
||||
val o = runCatching { JSONObject(line) }.getOrNull() ?: return null
|
||||
val item = o.optJSONObject("item")
|
||||
val id = item?.optString("id").orEmpty()
|
||||
val entries = when (o.optString("type")) {
|
||||
"thread.started" -> return AgentEvent(o.optString("thread_id").takeIf { it.isNotEmpty() })
|
||||
"item.started" -> when (item?.optString("type")) {
|
||||
"command_execution" -> shellCommand(item.optString("command")).let { listOf(AgentHost.Entry.Used(id, "Shell", firstLine(it), it)) }
|
||||
"mcp_tool_call" -> listOf(AgentHost.Entry.Used(id, item.optString("tool").ifEmpty { "Tool" }, item.optString("server"), item.optJSONObject("arguments")?.toString(2).orEmpty()))
|
||||
"web_search" -> listOf(AgentHost.Entry.Used(id, "Search", item.optString("query"), item.optString("query")))
|
||||
else -> emptyList()
|
||||
}
|
||||
"item.updated" -> when (item?.optString("type")) {
|
||||
"todo_list" -> listOf(todoEntry(id, item))
|
||||
else -> emptyList()
|
||||
}
|
||||
"item.completed" -> when (item?.optString("type")) {
|
||||
"agent_message" -> item.optString("text").trim().takeIf { it.isNotEmpty() }?.let { listOf(AgentHost.Entry.Said(it)) }.orEmpty()
|
||||
"reasoning" -> item.optString("text").trim().takeIf { it.isNotEmpty() }?.let { listOf(AgentHost.Entry.Thought(it)) }.orEmpty()
|
||||
"command_execution" -> listOf(AgentHost.Entry.Result(id, item.optString("aggregated_output"),
|
||||
item.has("exit_code") && !item.isNull("exit_code") && item.optInt("exit_code") != 0))
|
||||
"mcp_tool_call" -> listOf(AgentHost.Entry.Result(id, item.optJSONObject("result")?.toString(2) ?: item.optJSONObject("error")?.optString("message").orEmpty(),
|
||||
item.optString("status") == "failed"))
|
||||
"web_search" -> listOf(AgentHost.Entry.Result(id, "", false))
|
||||
"file_change" -> listOf(
|
||||
AgentHost.Entry.Used(id, "Edit", changedFiles(item), changedFiles(item).replace(", ", "\n")),
|
||||
AgentHost.Entry.Result(id, item.optString("status"), item.optString("status") == "failed"),
|
||||
)
|
||||
"todo_list" -> listOf(todoEntry(id, item))
|
||||
"error" -> listOf(AgentHost.Entry.Said("⚠ " + item.optString("message")))
|
||||
else -> emptyList()
|
||||
}
|
||||
"turn.completed" -> return AgentEvent(
|
||||
entries = listOf(AgentHost.Entry.Finished(null)),
|
||||
usage = o.optJSONObject("usage")?.let { AgentHost.Usage(0, 0.0, it.optLong("input_tokens") + it.optLong("cached_input_tokens"), it.optLong("output_tokens")) },
|
||||
override fun protocol(): AgentProtocol = Protocol()
|
||||
|
||||
@VisibleForTesting
|
||||
internal class Protocol : AgentProtocol {
|
||||
private var next = 1
|
||||
private var thread: String? = null
|
||||
/** The initialize request, the thread/start or thread/resume sent once it succeeds, and the turn that waits for its thread. */
|
||||
private var initializing = -1
|
||||
private var initialized = false
|
||||
private var open: String? = null
|
||||
private var opening = -1
|
||||
private var waiting: JSONObject? = null
|
||||
private var starting = -1
|
||||
private var turnId = ""
|
||||
/** Each file change's paths and diffs, from its start; an approval for it names only the item. */
|
||||
private val changes = mutableMapOf<String, JSONArray>()
|
||||
private var input = 0L
|
||||
private var output = 0L
|
||||
|
||||
override fun input(message: String, conversation: String?, options: AgentHarness.Options, started: Boolean): List<String> {
|
||||
val turn = JSONObject()
|
||||
.put("input", JSONArray().put(JSONObject().put("type", "text").put("text", message).put("text_elements", JSONArray())))
|
||||
options.model?.let { turn.put("model", it) }
|
||||
options.effort?.let { turn.put("effort", it) }
|
||||
val known = thread
|
||||
if (!started && known != null) return listOf(startTurn(turn.put("threadId", known)))
|
||||
val params = JSONObject()
|
||||
.put("approvalPolicy", if (options.permission == AgentHarness.FULL) "never" else "untrusted")
|
||||
.put("sandbox", "danger-full-access")
|
||||
options.model?.let { params.put("model", it) }
|
||||
options.brief?.let { params.put("developerInstructions", it) }
|
||||
if (conversation != null) params.put("threadId", conversation)
|
||||
waiting = turn
|
||||
opening = next++
|
||||
val request = JSONObject().put("id", opening).put("method", if (conversation != null) "thread/resume" else "thread/start").put("params", params).toString()
|
||||
// Codex refuses a second initialize on one connection, so a thread that failed to open is asked for again alone.
|
||||
if (initialized) return listOf(request)
|
||||
open = request
|
||||
initializing = next++
|
||||
return listOf(
|
||||
JSONObject().put("id", initializing).put("method", "initialize")
|
||||
.put("params", JSONObject().put("clientInfo", JSONObject().put("name", "droiddeck").put("title", "DroidDeck").put("version", "1"))
|
||||
.put("capabilities", JSONObject.NULL)).toString(),
|
||||
)
|
||||
"turn.failed" -> listOf(AgentHost.Entry.Finished(o.optJSONObject("error")?.optString("message") ?: "turn failed"))
|
||||
// codex reports a dropped stream it is retrying as an error event, and the turn goes on.
|
||||
"error" -> o.optString("message").let { message ->
|
||||
if (message.startsWith("Reconnecting...")) emptyList() else listOf(AgentHost.Entry.Finished(message.ifEmpty { "error" }))
|
||||
}
|
||||
else -> emptyList()
|
||||
}
|
||||
return if (entries.isEmpty()) null else AgentEvent(entries = entries)
|
||||
|
||||
private fun startTurn(params: JSONObject): String {
|
||||
starting = next++
|
||||
return JSONObject().put("id", starting).put("method", "turn/start").put("params", params).toString()
|
||||
}
|
||||
|
||||
override fun answer(approval: AgentHost.Approval, allow: Boolean): String =
|
||||
JSONObject(approval.payload).put("result", JSONObject().put("decision", if (allow) "accept" else "decline")).toString()
|
||||
|
||||
override fun parse(line: String): AgentEvent? {
|
||||
val o = runCatching { JSONObject(line) }.getOrNull() ?: return null
|
||||
val method = o.optString("method")
|
||||
if (method.isEmpty()) return response(o)
|
||||
val params = o.optJSONObject("params") ?: JSONObject()
|
||||
if (o.has("id")) return request(o.get("id"), method, params)
|
||||
return notification(method, params)
|
||||
}
|
||||
|
||||
private fun response(o: JSONObject): AgentEvent? {
|
||||
val id = o.optInt("id", -1)
|
||||
val error = o.optJSONObject("error")?.optString("message")?.ifEmpty { "error" }
|
||||
return when (id) {
|
||||
initializing -> {
|
||||
if (error != null) return AgentEvent(entries = listOf(AgentHost.Entry.Finished(error)))
|
||||
initialized = true
|
||||
val request = open ?: return null
|
||||
open = null
|
||||
AgentEvent(reply = listOf(JSONObject().put("method", "initialized").toString(), request))
|
||||
}
|
||||
opening -> {
|
||||
if (error != null) return AgentEvent(entries = listOf(AgentHost.Entry.Finished(error)))
|
||||
val started = o.optJSONObject("result")?.optJSONObject("thread")?.optString("id")?.takeIf { it.isNotEmpty() } ?: return null
|
||||
thread = started
|
||||
val turn = waiting ?: return AgentEvent(started)
|
||||
waiting = null
|
||||
AgentEvent(started, reply = listOf(startTurn(turn.put("threadId", started))))
|
||||
}
|
||||
starting -> error?.let { AgentEvent(entries = listOf(AgentHost.Entry.Finished(it))) }
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun request(id: Any, method: String, params: JSONObject): AgentEvent {
|
||||
val payload = JSONObject().put("id", id).toString()
|
||||
return when (method) {
|
||||
"item/commandExecution/requestApproval" -> {
|
||||
val command = shellCommand(params.optString("command"))
|
||||
val reason = params.optString("reason").takeIf { it.isNotEmpty() && it != "null" }
|
||||
AgentEvent(approval = AgentHost.Approval(id.toString(), "Shell", firstLine(command), listOfNotNull(command, reason).joinToString("\n\n"), payload))
|
||||
}
|
||||
"item/fileChange/requestApproval" -> {
|
||||
val list = changes[params.optString("itemId")] ?: JSONArray()
|
||||
val files = (0 until list.length()).mapNotNull { list.optJSONObject(it) }
|
||||
AgentEvent(approval = AgentHost.Approval(
|
||||
id.toString(), "Edit", files.joinToString(", ") { it.optString("path") }.take(400),
|
||||
files.joinToString("\n\n") { it.optString("path") + "\n" + patchLines(it.optString("diff"), it.optJSONObject("kind")?.optString("type").orEmpty()) }, payload,
|
||||
))
|
||||
}
|
||||
// Everything else asks for something DroidDeck has no screen for; refusing keeps the turn going.
|
||||
else -> AgentEvent(reply = listOf(JSONObject(payload)
|
||||
.put("error", JSONObject().put("code", -32601).put("message", "DroidDeck cannot answer $method")).toString()))
|
||||
}
|
||||
}
|
||||
|
||||
private fun notification(method: String, params: JSONObject): AgentEvent? {
|
||||
val item = params.optJSONObject("item")
|
||||
val id = item?.optString("id").orEmpty()
|
||||
val entries: List<AgentHost.Entry> = when (method) {
|
||||
"thread/started" -> return params.optJSONObject("thread")?.optString("id")?.takeIf { it.isNotEmpty() }?.let { AgentEvent(it) }
|
||||
"turn/started" -> {
|
||||
turnId = params.optJSONObject("turn")?.optString("id").orEmpty()
|
||||
input = 0
|
||||
output = 0
|
||||
return null
|
||||
}
|
||||
"item/agentMessage/delta" -> return AgentEvent(text = params.optString("delta"))
|
||||
"item/reasoning/summaryTextDelta", "item/reasoning/textDelta" -> return AgentEvent(thinking = params.optString("delta"))
|
||||
"item/started" -> when (item?.optString("type")) {
|
||||
"commandExecution" -> shellCommand(item.optString("command")).let { listOf(AgentHost.Entry.Used(id, "Shell", firstLine(it), it)) }
|
||||
"mcpToolCall" -> listOf(AgentHost.Entry.Used(id, item.optString("tool").ifEmpty { "Tool" }, item.optString("server"), item.opt("arguments")?.let(::pretty).orEmpty()))
|
||||
"webSearch" -> listOf(AgentHost.Entry.Used(id, "Search", item.optString("query"), item.optString("query")))
|
||||
"fileChange" -> {
|
||||
val list = item.optJSONArray("changes") ?: JSONArray()
|
||||
changes[id] = list
|
||||
fileEntries(id, list)
|
||||
}
|
||||
else -> emptyList()
|
||||
}
|
||||
"item/completed" -> when (item?.optString("type")) {
|
||||
"agentMessage" -> item.optString("text").trim().takeIf { it.isNotEmpty() }?.let { listOf(AgentHost.Entry.Said(it)) }.orEmpty()
|
||||
"reasoning" -> {
|
||||
val parts = (strings(item.optJSONArray("summary")) + strings(item.optJSONArray("content"))).joinToString("\n\n").trim()
|
||||
if (parts.isEmpty()) emptyList() else listOf(AgentHost.Entry.Thought(parts))
|
||||
}
|
||||
"commandExecution" -> {
|
||||
val status = item.optString("status")
|
||||
val exit = if (item.isNull("exitCode")) 0 else item.optInt("exitCode")
|
||||
val out = item.optString("aggregatedOutput").takeUnless { item.isNull("aggregatedOutput") }.orEmpty()
|
||||
listOf(AgentHost.Entry.Result(id, if (status == "declined") out.ifEmpty { DENIED } else out, status != "completed" || exit != 0))
|
||||
}
|
||||
"mcpToolCall" -> listOf(AgentHost.Entry.Result(id,
|
||||
item.optJSONObject("result")?.let(::pretty) ?: item.optJSONObject("error")?.optString("message").orEmpty(), item.optString("status") == "failed"))
|
||||
"webSearch" -> listOf(AgentHost.Entry.Result(id, "", false))
|
||||
"fileChange" -> {
|
||||
val list = item.optJSONArray("changes") ?: changes[id] ?: JSONArray()
|
||||
changes.remove(id)
|
||||
val failed = item.optString("status") != "completed"
|
||||
(0 until list.length()).map { AgentHost.Entry.Result("$id#$it", if (failed) item.optString("status") else "", failed) }
|
||||
}
|
||||
else -> emptyList()
|
||||
}
|
||||
"turn/plan/updated" -> listOf(plan(params.optJSONArray("plan")))
|
||||
"thread/tokenUsage/updated" -> {
|
||||
val usage = params.optJSONObject("tokenUsage") ?: return null
|
||||
val last = usage.optJSONObject("last")
|
||||
input += last?.optLong("inputTokens") ?: 0
|
||||
output += last?.optLong("outputTokens") ?: 0
|
||||
return AgentEvent(
|
||||
context = last?.optLong("totalTokens")?.takeIf { it > 0 },
|
||||
window = usage.optLong("modelContextWindow").takeIf { it > 0 },
|
||||
)
|
||||
}
|
||||
"account/rateLimits/updated" -> return rateLimits(params.optJSONObject("rateLimits"))?.let { AgentEvent(limits = it) }
|
||||
"serverRequest/resolved" -> return AgentEvent(resolved = params.opt("requestId")?.toString())
|
||||
"turn/completed" -> {
|
||||
val turn = params.optJSONObject("turn") ?: JSONObject()
|
||||
val error = when (turn.optString("status")) {
|
||||
"failed" -> turn.optJSONObject("error")?.optString("message")?.ifEmpty { null } ?: "turn failed"
|
||||
else -> null
|
||||
}
|
||||
return AgentEvent(
|
||||
entries = listOf(AgentHost.Entry.Finished(error)),
|
||||
usage = AgentHost.Usage(if (turn.isNull("durationMs")) 0 else turn.optLong("durationMs"), 0.0, input, output),
|
||||
)
|
||||
}
|
||||
else -> emptyList()
|
||||
}
|
||||
return if (entries.isEmpty()) null else AgentEvent(entries = entries)
|
||||
}
|
||||
|
||||
private fun plan(steps: JSONArray?): AgentHost.Entry.Used {
|
||||
val text = (0 until (steps?.length() ?: 0)).mapNotNull { i ->
|
||||
val step = steps?.optJSONObject(i) ?: return@mapNotNull null
|
||||
val mark = when (step.optString("status")) { "completed" -> "[x]"; "inProgress" -> "[~]"; else -> "[ ]" }
|
||||
"$mark ${step.optString("step")}"
|
||||
}.joinToString("\n")
|
||||
return AgentHost.Entry.Used("$turnId-todo", "TodoWrite", "", text, output = "")
|
||||
}
|
||||
}
|
||||
|
||||
private const val TOKEN_COUNT = "\"payload\":{\"type\":\"token_count\""
|
||||
|
||||
/** Codex prints no limits with --json; its session log, named after the thread, has a token_count event each step. */
|
||||
override fun usage(rootfs: File, conversation: String?): AgentEvent? {
|
||||
conversation ?: return null
|
||||
val log = File(rootfs, "root/.codex/sessions").walkBottomUp().filter { it.isFile && it.name.endsWith("-$conversation.jsonl") }
|
||||
.maxByOrNull { it.lastModified() } ?: return null
|
||||
val last = runCatching { log.readLines().lastOrNull { it.contains(TOKEN_COUNT) } }.getOrNull() ?: return null
|
||||
return tokenCount(last)
|
||||
/** One Edit per changed file: its path, then the diff as lines led by ' ', '-' or '+'. */
|
||||
private fun fileEntries(id: String, changes: JSONArray) = (0 until changes.length()).mapNotNull { i ->
|
||||
val change = changes.optJSONObject(i) ?: return@mapNotNull null
|
||||
val path = change.optString("path")
|
||||
AgentHost.Entry.Used("$id#$i", "Edit", path, path + "\n" + patchLines(change.optString("diff"), change.optJSONObject("kind")?.optString("type").orEmpty()))
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
internal fun tokenCount(line: String): AgentEvent? {
|
||||
val payload = runCatching { JSONObject(line).optJSONObject("payload") }.getOrNull()?.takeIf { it.optString("type") == "token_count" } ?: return null
|
||||
val info = payload.optJSONObject("info")
|
||||
val rates = payload.optJSONObject("rate_limits")
|
||||
val limits = listOf("primary", "secondary").mapNotNull { key ->
|
||||
val w = rates?.optJSONObject(key) ?: return@mapNotNull null
|
||||
AgentHost.Limit(w.optInt("window_minutes"), w.optDouble("used_percent", 0.0).toInt(), w.optLong("resets_at"))
|
||||
internal fun rateLimits(snapshot: JSONObject?): List<AgentHost.Limit>? {
|
||||
snapshot ?: return null
|
||||
return listOf("primary", "secondary").mapNotNull { key ->
|
||||
val w = snapshot.optJSONObject(key) ?: return@mapNotNull null
|
||||
AgentHost.Limit(w.optInt("windowDurationMins"), w.optDouble("usedPercent", 0.0).toInt(), w.optLong("resetsAt"))
|
||||
}.takeIf { it.isNotEmpty() }
|
||||
}
|
||||
|
||||
private fun strings(list: JSONArray?) = (0 until (list?.length() ?: 0)).mapNotNull { list?.optString(it)?.takeIf { s -> s.isNotBlank() } }
|
||||
|
||||
private fun pretty(value: Any): String = when (value) {
|
||||
is JSONObject -> value.toString(2)
|
||||
is JSONArray -> value.toString(2)
|
||||
JSONObject.NULL -> ""
|
||||
else -> value.toString()
|
||||
}
|
||||
}
|
||||
|
||||
/** OpenCode: `opencode acp`, the Agent Client Protocol over stdio, resumed by session id. */
|
||||
object OpenCode : AgentHarness {
|
||||
override val id = "opencode"
|
||||
override val name = "OpenCode"
|
||||
override val binary = "/root/.opencode/bin/opencode"
|
||||
override val skills = "root/.config/opencode/skills"
|
||||
override val instructions = "root/.config/opencode/AGENTS.md"
|
||||
override val install = "curl -fsSL https://opencode.ai/install | bash -s -- --no-modify-path"
|
||||
private const val AUTH = "root/.local/share/opencode/auth.json"
|
||||
private const val CONFIG = "root/.config/opencode/opencode.json"
|
||||
private const val FREE = "root/.config/opencode/.droiddeck-free"
|
||||
private const val MODELS = "root/.cache/droiddeck/opencode-models"
|
||||
/** The provider id DroidDeck gives a server the user names, in opencode's config and auth. */
|
||||
private const val CUSTOM = "droiddeck"
|
||||
|
||||
// `opencode models` lists only what the saved keys reach, so the check that runs it keeps the model list current.
|
||||
override val signedIn = listOf("sh", "-c",
|
||||
"mkdir -p /${MODELS.substringBeforeLast('/')}; $binary models --verbose > /$MODELS.$$ 2>/dev/null && mv -f /$MODELS.$$ /$MODELS; rm -f /$MODELS.$$; " +
|
||||
"grep -q '\"type\"' /$AUTH 2>/dev/null || [ -e /$FREE ] || grep -q '\"$CUSTOM\"' /$CONFIG 2>/dev/null")
|
||||
// Ids are opencode's own (models.dev), so a saved key is what `opencode auth login` would save for that provider.
|
||||
override val providers = listOf(
|
||||
AgentHarness.Provider("opencode", "OpenCode Zen", "https://opencode.ai/auth"),
|
||||
AgentHarness.Provider("ollama-cloud", "Ollama Cloud", "https://ollama.com/settings/keys"),
|
||||
AgentHarness.Provider("openrouter", "OpenRouter", "https://openrouter.ai/settings/keys"),
|
||||
AgentHarness.Provider("openai", "OpenAI", "https://platform.openai.com/api-keys"),
|
||||
AgentHarness.Provider("anthropic", "Anthropic", "https://console.anthropic.com/settings/keys"),
|
||||
AgentHarness.Provider("google", "Gemini", "https://aistudio.google.com/apikey"),
|
||||
AgentHarness.Provider(CUSTOM, "Other server", custom = true),
|
||||
)
|
||||
override val signIn = listOf("/root/.local/bin/android-open", providers.first().keyPage!!)
|
||||
override val free = true
|
||||
override val plans = true
|
||||
override val efforts = listOf("low", "medium", "high")
|
||||
|
||||
override fun keys(rootfs: File): Set<String> {
|
||||
val auth = runCatching { JSONObject(File(rootfs, AUTH).readText()) }.getOrNull()
|
||||
val custom = runCatching { JSONObject(File(rootfs, CONFIG).readText()).optJSONObject("provider")?.has(CUSTOM) }.getOrNull() == true
|
||||
return providers.filter { auth?.has(it.id) == true || (it.custom && custom) }.map { it.id }.toSet()
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the key as opencode's own `auth login` would. A custom server also gets a provider in
|
||||
* opencode's config with the models its `/models` lists, since opencode does not list them itself.
|
||||
*/
|
||||
override fun saveKey(rootfs: File, provider: AgentHarness.Provider, key: String, endpoint: String?, get: (String, String?) -> String) {
|
||||
val token = key.trim().takeIf { it.isNotEmpty() }
|
||||
// Both files are read before either is written, so one that cannot be read changes nothing.
|
||||
val authFile = File(rootfs, AUTH)
|
||||
val auth = readJson(authFile)
|
||||
if (token != null) auth.put(provider.id, JSONObject().put("type", "api").put("key", token)) else auth.remove(provider.id)
|
||||
if (!provider.custom) return writeJson(authFile, auth, private = true)
|
||||
val base = endpoint(endpoint ?: "")
|
||||
val configFile = File(rootfs, CONFIG)
|
||||
val before = configFile.takeIf { it.exists() }?.readText()
|
||||
val config = readJson(configFile)
|
||||
val models = modelIds(get("$base/models", token))
|
||||
check(models.isNotEmpty()) { "No models at $base" }
|
||||
if (!config.has("\$schema")) config.put("\$schema", "https://opencode.ai/config.json")
|
||||
val all = config.optJSONObject("provider") ?: JSONObject().also { config.put("provider", it) }
|
||||
all.put(CUSTOM, JSONObject()
|
||||
.put("npm", "@ai-sdk/openai-compatible")
|
||||
.put("name", runCatching { java.net.URI(base).host }.getOrNull() ?: provider.name)
|
||||
.put("options", JSONObject().put("baseURL", base))
|
||||
.put("models", JSONObject().apply { models.forEach { put(it, JSONObject().put("name", it)) } }))
|
||||
writeJson(configFile, config)
|
||||
try {
|
||||
writeJson(authFile, auth, private = true)
|
||||
} catch (e: Exception) {
|
||||
val undone = runCatching {
|
||||
if (before != null) writeFile(configFile, before) else java.nio.file.Files.deleteIfExists(configFile.toPath())
|
||||
}
|
||||
// First, since the setup row shows two lines of the message.
|
||||
undone.exceptionOrNull()?.let { throw IllegalStateException("The server config could not be put back (${it.message}): ${e.message}", e) }
|
||||
throw e
|
||||
}
|
||||
return AgentEvent(
|
||||
context = info?.optJSONObject("last_token_usage")?.optLong("total_tokens")?.takeIf { it > 0 },
|
||||
window = info?.optLong("model_context_window")?.takeIf { it > 0 },
|
||||
limits = limits.takeIf { it.isNotEmpty() },
|
||||
)
|
||||
}
|
||||
|
||||
private fun todoEntry(id: String, item: JSONObject): AgentHost.Entry.Used {
|
||||
val items = item.optJSONArray("items") ?: JSONArray()
|
||||
val text = (0 until items.length()).mapNotNull { i ->
|
||||
val todo = items.optJSONObject(i) ?: return@mapNotNull null
|
||||
"${if (todo.optBoolean("completed")) "[x]" else "[ ]"} ${todo.optString("text")}"
|
||||
}.joinToString("\n")
|
||||
return AgentHost.Entry.Used("$id-todo", "TodoWrite", "", text, output = "")
|
||||
override fun removeKey(rootfs: File, provider: AgentHarness.Provider) {
|
||||
if (File(rootfs, AUTH).exists()) editJson(File(rootfs, AUTH), private = true) { it.remove(provider.id) }
|
||||
if (provider.custom && File(rootfs, CONFIG).exists()) editJson(File(rootfs, CONFIG)) { it.optJSONObject("provider")?.remove(CUSTOM) }
|
||||
}
|
||||
|
||||
private fun changedFiles(item: JSONObject): String {
|
||||
val changes = item.optJSONArray("changes") ?: return ""
|
||||
return (0 until changes.length()).mapNotNull { changes.optJSONObject(it)?.optString("path") }.joinToString(", ").take(400)
|
||||
/** A server address as typed, made into the OpenAI-compatible base URL opencode calls. */
|
||||
@VisibleForTesting
|
||||
internal fun endpoint(typed: String): String {
|
||||
val url = typed.trim().trimEnd('/').let { if ("://" in it) it else "http://$it" }
|
||||
require(url.substringAfter("://").isNotEmpty()) { "No server address" }
|
||||
return if (url.substringAfter("://").contains('/')) url else "$url/v1"
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
internal fun modelIds(body: String): List<String> {
|
||||
// The userland can print its own warnings ahead of the response.
|
||||
val json = body.substring(body.indexOf('{').coerceAtLeast(0), body.lastIndexOf('}') + 1)
|
||||
val data = runCatching { JSONObject(json).optJSONArray("data") }.getOrNull() ?: return emptyList()
|
||||
return (0 until data.length()).mapNotNull { data.optJSONObject(it)?.optString("id")?.takeIf { id -> id.isNotEmpty() } }.distinct()
|
||||
}
|
||||
|
||||
// A file that cannot be read holds the user's other providers too, so it is never replaced.
|
||||
private fun readJson(file: File) = if (file.exists()) JSONObject(file.readText()) else JSONObject()
|
||||
|
||||
private fun editJson(file: File, private: Boolean = false, edit: (JSONObject) -> Unit) =
|
||||
writeJson(file, readJson(file).also(edit), private)
|
||||
|
||||
/** Writes beside [file] and moves it into place, so a write that stops partway leaves the old file. */
|
||||
private fun writeJson(file: File, json: JSONObject, private: Boolean = false) = writeFile(file, json.toString(2) + "\n", private)
|
||||
|
||||
private fun writeFile(file: File, text: String, private: Boolean = false) {
|
||||
file.parentFile?.mkdirs()
|
||||
val temp = File(file.parentFile, ".${file.name}.tmp")
|
||||
try {
|
||||
temp.writeText(text)
|
||||
if (private) {
|
||||
temp.setReadable(false, false)
|
||||
temp.setReadable(true, true)
|
||||
}
|
||||
java.nio.file.Files.move(temp.toPath(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING, java.nio.file.StandardCopyOption.ATOMIC_MOVE)
|
||||
} finally {
|
||||
temp.delete()
|
||||
}
|
||||
}
|
||||
|
||||
override fun useFree(rootfs: File) {
|
||||
File(rootfs, FREE).apply { parentFile?.mkdirs() }.writeText("Free OpenCode Zen models, chosen in DroidDeck's agent setup.\n")
|
||||
}
|
||||
|
||||
private class Listed(val modified: Long, val models: List<AgentHarness.Model>, val windows: Map<String, Long>)
|
||||
@Volatile private var listed: Listed? = null
|
||||
|
||||
private fun listed(rootfs: File): Listed? {
|
||||
val file = File(rootfs, MODELS)
|
||||
val modified = file.lastModified().takeIf { it > 0 } ?: return null
|
||||
listed?.takeIf { it.modified == modified }?.let { return it }
|
||||
return runCatching { listModels(file.readText()) }.getOrNull()?.let { (models, windows) -> Listed(modified, models, windows) }?.also { listed = it }
|
||||
}
|
||||
|
||||
override fun models(rootfs: File) = listed(rootfs)?.models.orEmpty()
|
||||
|
||||
/** `opencode models --verbose` prints each model's id on a line of its own, then its details as JSON. */
|
||||
@VisibleForTesting
|
||||
internal fun listModels(output: String): Pair<List<AgentHarness.Model>, Map<String, Long>> {
|
||||
val models = mutableListOf<AgentHarness.Model>()
|
||||
val windows = mutableMapOf<String, Long>()
|
||||
var id: String? = null
|
||||
val json = StringBuilder()
|
||||
for (line in output.lineSequence()) {
|
||||
val current = id
|
||||
if (current == null) {
|
||||
if (MODEL_ID.matches(line)) id = line.trim()
|
||||
continue
|
||||
}
|
||||
json.appendLine(line)
|
||||
if (line != "}") continue
|
||||
runCatching { JSONObject(json.toString()) }.getOrNull()?.takeIf { it.optString("status") != "deprecated" }?.let { o ->
|
||||
val provider = o.optString("providerID")
|
||||
val label = o.optString("name").ifEmpty { current }
|
||||
val source = if (provider == "opencode" || provider == CUSTOM) "" else providers.firstOrNull { it.id == provider }?.name ?: provider
|
||||
models += AgentHarness.Model(current, if (source.isEmpty()) label else "$label · $source")
|
||||
o.optJSONObject("limit")?.optLong("context")?.takeIf { it > 0 }?.let { windows[current] = it }
|
||||
}
|
||||
id = null
|
||||
json.clear()
|
||||
}
|
||||
return models to windows
|
||||
}
|
||||
|
||||
private val MODEL_ID = Regex("""^[\w.-]+/\S+$""")
|
||||
|
||||
override val permissions = listOf(
|
||||
AgentHarness.Permission(AgentHarness.ASK, R.string.agent_permission_ask, R.string.agent_permission_ask_hint),
|
||||
AgentHarness.Permission(AgentHarness.EDITS, R.string.agent_permission_edits, R.string.agent_permission_edits_hint),
|
||||
AgentHarness.Permission(AgentHarness.FULL, R.string.agent_permission_full, R.string.agent_permission_full_hint),
|
||||
)
|
||||
|
||||
/**
|
||||
* Rules merged over the user's opencode config. OpenCode applies the last rule that matches in key order, so the
|
||||
* asking modes name each permission rather than "*", which could land after a rule of the user's and override it.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
internal fun rules(permission: String): JSONObject {
|
||||
val asks = listOf("bash", "webfetch", "websearch", "codesearch")
|
||||
return when (permission) {
|
||||
AgentHarness.FULL -> JSONObject().put("*", "allow")
|
||||
AgentHarness.EDITS -> JSONObject().put("edit", "allow").apply { asks.forEach { put(it, "ask") } }
|
||||
else -> JSONObject().put("edit", "ask").apply { asks.forEach { put(it, "ask") } }
|
||||
}
|
||||
}
|
||||
|
||||
override fun turn(message: String, conversation: String?, options: AgentHarness.Options) =
|
||||
withoutStderr("opencode", listOf("/usr/bin/env", "OPENCODE_PERMISSION=${rules(options.permission)}", binary, "acp"))
|
||||
|
||||
/** The conversation's cost so far; DroidDeck takes the turn's share from what its chat has recorded. */
|
||||
override val sessionCost = true
|
||||
|
||||
override fun protocol(): AgentProtocol = Protocol()
|
||||
|
||||
/** `opencode acp`: the Agent Client Protocol, JSON-RPC over stdio. */
|
||||
@VisibleForTesting
|
||||
internal class Protocol : AgentProtocol {
|
||||
private enum class Stage { INIT, SESSION, CONFIG, PROMPT, IDLE }
|
||||
|
||||
private var next = 1
|
||||
private var stage = Stage.IDLE
|
||||
private var pending = -1
|
||||
private var session: String? = null
|
||||
private var resume: String? = null
|
||||
private var cwd = "/root"
|
||||
/** Requests for the session still to send, each once the one before it has been answered. */
|
||||
private val queue = ArrayDeque<(String) -> JSONObject>()
|
||||
private val said = StringBuilder()
|
||||
private val thought = StringBuilder()
|
||||
/** Each tool call's name, which only its first update carries, and its latest entry. */
|
||||
private val names = mutableMapOf<String, String>()
|
||||
private val used = mutableMapOf<String, AgentHost.Entry.Used>()
|
||||
private var cost = 0.0
|
||||
private var started = 0L
|
||||
|
||||
override fun input(message: String, conversation: String?, options: AgentHarness.Options, started: Boolean): List<String> {
|
||||
val text = if (conversation == null && options.brief != null) "${options.brief}\n\n$message" else message
|
||||
val prompt = { id: String ->
|
||||
JSONObject().put("sessionId", id).put("prompt", JSONArray().put(JSONObject().put("type", "text").put("text", text)))
|
||||
}
|
||||
queue.clear()
|
||||
val known = session
|
||||
if (!started && known != null && configured) return listOf(send(Stage.PROMPT, "session/prompt", prompt(known)))
|
||||
fun option(config: String, value: String) = { id: String -> JSONObject().put("sessionId", id).put("configId", config).put("value", value) }
|
||||
options.model?.let { queue += option("model", it) }
|
||||
options.effort?.let { queue += option("effort", it) }
|
||||
queue += option("mode", if (options.plan) "plan" else "build")
|
||||
queue += prompt
|
||||
// A session whose options were refused sets them all again before its next prompt.
|
||||
if (!started && known != null) return listOf(advance(known))
|
||||
resume = conversation
|
||||
cwd = options.workdir
|
||||
return listOf(send(Stage.INIT, "initialize", JSONObject().put("protocolVersion", 1).put("clientCapabilities", JSONObject())))
|
||||
}
|
||||
|
||||
private fun send(stage: Stage, method: String, params: JSONObject): String {
|
||||
this.stage = stage
|
||||
pending = next++
|
||||
if (stage == Stage.PROMPT) started = System.currentTimeMillis()
|
||||
return JSONObject().put("jsonrpc", "2.0").put("id", pending).put("method", method).put("params", params).toString()
|
||||
}
|
||||
|
||||
/** The next queued request: the prompt once nothing else is left. */
|
||||
private fun advance(id: String): String {
|
||||
val make = queue.removeFirst()
|
||||
val params = make(id)
|
||||
configuring = params.optString("configId")
|
||||
configured = queue.isEmpty()
|
||||
return if (queue.isEmpty()) send(Stage.PROMPT, "session/prompt", params) else send(Stage.CONFIG, "session/set_config_option", params)
|
||||
}
|
||||
|
||||
/** The config option the pending set_config_option sets. */
|
||||
private var configuring = ""
|
||||
/** The session's model, effort and mode were all set, so a later prompt can go straight to it. */
|
||||
private var configured = false
|
||||
|
||||
override fun answer(approval: AgentHost.Approval, allow: Boolean): String = JSONObject(approval.payload).put("jsonrpc", "2.0")
|
||||
.put("result", JSONObject().put("outcome", JSONObject().put("outcome", "selected").put("optionId", if (allow) "once" else "reject"))).toString()
|
||||
|
||||
override fun parse(line: String): AgentEvent? {
|
||||
val o = runCatching { JSONObject(line) }.getOrNull() ?: return null
|
||||
val method = o.optString("method")
|
||||
val params = o.optJSONObject("params") ?: JSONObject()
|
||||
return when {
|
||||
method.isEmpty() -> response(o)
|
||||
o.has("id") -> request(o.get("id"), method, params)
|
||||
method == "session/update" -> update(params.optJSONObject("update") ?: return null)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun response(o: JSONObject): AgentEvent? {
|
||||
if (o.optInt("id", -1) != pending) return null
|
||||
val error = o.optJSONObject("error")?.let { it.optJSONObject("data")?.optString("message")?.ifEmpty { null } ?: it.optString("message").ifEmpty { "error" } }
|
||||
val result = o.optJSONObject("result") ?: JSONObject()
|
||||
return when (stage) {
|
||||
Stage.INIT -> error?.let(::failed) ?: AgentEvent(reply = listOf(
|
||||
resume?.let { send(Stage.SESSION, "session/resume", JSONObject().put("sessionId", it).put("cwd", cwd).put("mcpServers", JSONArray())) }
|
||||
?: send(Stage.SESSION, "session/new", JSONObject().put("cwd", cwd).put("mcpServers", JSONArray())),
|
||||
))
|
||||
Stage.SESSION -> {
|
||||
if (error != null) return failed(error)
|
||||
val id = result.optString("sessionId").ifEmpty { resume.orEmpty() }.takeIf { it.isNotEmpty() } ?: return failed("no session")
|
||||
session = id
|
||||
AgentEvent(id, reply = listOf(advance(id)))
|
||||
}
|
||||
// A model without effort levels refuses one and the turn goes on with its default; a refused
|
||||
// mode would run a plan turn as a build one, so it ends the turn instead.
|
||||
Stage.CONFIG -> if (error != null && configuring == "mode") failed(error) else AgentEvent(reply = listOf(advance(session ?: return null)))
|
||||
Stage.PROMPT -> {
|
||||
stage = Stage.IDLE
|
||||
val usage = result.optJSONObject("usage")
|
||||
val reason = result.optString("stopReason")
|
||||
AgentEvent(
|
||||
session,
|
||||
flush() + AgentHost.Entry.Finished(error ?: if (reason == "refusal") "refused" else null),
|
||||
usage = AgentHost.Usage(
|
||||
System.currentTimeMillis() - started, cost,
|
||||
(usage?.optLong("inputTokens") ?: 0) + (usage?.optLong("cachedReadTokens") ?: 0),
|
||||
(usage?.optLong("outputTokens") ?: 0) + (usage?.optLong("thoughtTokens") ?: 0),
|
||||
),
|
||||
)
|
||||
}
|
||||
Stage.IDLE -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun failed(error: String): AgentEvent {
|
||||
stage = Stage.IDLE
|
||||
configured = false
|
||||
return AgentEvent(session, flush() + AgentHost.Entry.Finished(error))
|
||||
}
|
||||
|
||||
private fun request(id: Any, method: String, params: JSONObject): AgentEvent {
|
||||
val payload = JSONObject().put("id", id).toString()
|
||||
if (method != "session/request_permission") {
|
||||
// File writes and terminals stay with OpenCode, which does them itself when the client declines.
|
||||
return AgentEvent(reply = listOf(JSONObject(payload).put("jsonrpc", "2.0")
|
||||
.put("error", JSONObject().put("code", -32601).put("message", "DroidDeck cannot answer $method")).toString()))
|
||||
}
|
||||
val call = params.optJSONObject("toolCall") ?: JSONObject()
|
||||
val raw = call.optJSONObject("rawInput") ?: JSONObject()
|
||||
val name = names[call.optString("toolCallId")] ?: call.optString("kind")
|
||||
val kind = call.optString("kind")
|
||||
val approval = when {
|
||||
kind == "execute" -> AgentHost.Approval(id.toString(), "Bash", firstLine(raw.optString("command")), raw.optString("command"), payload)
|
||||
// OpenCode asks for a folder outside the workspace on its own, before the tool's own ask.
|
||||
raw.has("parentDir") -> AgentHost.Approval(
|
||||
id.toString(), "External directory", raw.optString("parentDir"),
|
||||
listOf(raw.optString("parentDir"), raw.optString("command")).filter { it.isNotEmpty() }.joinToString("\n\n"), payload,
|
||||
)
|
||||
raw.has("diff") -> {
|
||||
val path = raw.optString("filepath")
|
||||
AgentHost.Approval(id.toString(), "Edit", path, path + "\n" + patchLines(raw.optString("diff"), ""), payload)
|
||||
}
|
||||
else -> AgentHost.Approval(id.toString(), toolName(name), call.optString("title"), raw.toString(2), payload)
|
||||
}
|
||||
return AgentEvent(session, flush(), approval = approval)
|
||||
}
|
||||
|
||||
private fun update(u: JSONObject): AgentEvent? = when (u.optString("sessionUpdate")) {
|
||||
"agent_message_chunk" -> chunk(u)?.let { said.append(it); AgentEvent(session, text = it) }
|
||||
"agent_thought_chunk" -> chunk(u)?.let { thought.append(it); AgentEvent(session, thinking = it) }
|
||||
"tool_call", "tool_call_update" -> AgentEvent(session, flush() + tool(u))
|
||||
"usage_update" -> {
|
||||
u.optJSONObject("cost")?.optDouble("amount")?.takeIf { !it.isNaN() }?.let { cost = it }
|
||||
AgentEvent(session, context = u.optLong("used").takeIf { it > 0 }, window = u.optLong("size").takeIf { it > 0 })
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
||||
private fun chunk(u: JSONObject) = u.optJSONObject("content")?.takeIf { it.optString("type") == "text" }?.optString("text")?.takeIf { it.isNotEmpty() }
|
||||
|
||||
/** What was written since the last entry, as whole entries. */
|
||||
private fun flush(): List<AgentHost.Entry> = buildList {
|
||||
thought.toString().trim().takeIf { it.isNotEmpty() }?.let { add(AgentHost.Entry.Thought(it)) }
|
||||
said.toString().trim().takeIf { it.isNotEmpty() }?.let { add(AgentHost.Entry.Said(it)) }
|
||||
thought.clear()
|
||||
said.clear()
|
||||
}
|
||||
|
||||
private fun tool(u: JSONObject): List<AgentHost.Entry> {
|
||||
val id = u.optString("toolCallId")
|
||||
if (u.optString("sessionUpdate") == "tool_call") names[id] = u.optString("title")
|
||||
val input = u.optJSONObject("rawInput")?.takeIf { it.length() > 0 }
|
||||
val entry = if (input != null || used[id] == null) tool(id, names[id].orEmpty(), input ?: JSONObject()) else used.getValue(id)
|
||||
used[id] = entry
|
||||
val raw = u.optJSONObject("rawOutput")
|
||||
return when (u.optString("status")) {
|
||||
"completed" -> {
|
||||
val exit = raw?.optJSONObject("metadata")?.opt("exit")
|
||||
listOf(entry, AgentHost.Entry.Result(id, raw?.optString("output")?.ifEmpty { null } ?: content(u), exit is Number && exit.toInt() != 0))
|
||||
}
|
||||
"failed" -> listOf(entry, AgentHost.Entry.Result(id, raw?.optString("error")?.ifEmpty { null } ?: content(u), true))
|
||||
else -> listOf(entry)
|
||||
}
|
||||
}
|
||||
|
||||
private fun content(u: JSONObject): String {
|
||||
val list = u.optJSONArray("content") ?: return ""
|
||||
return (0 until list.length()).mapNotNull { list.optJSONObject(it)?.optJSONObject("content")?.optString("text") }.joinToString("\n")
|
||||
}
|
||||
}
|
||||
|
||||
private fun toolName(name: String) = name.replaceFirstChar { it.uppercase() }.ifEmpty { "Tool" }
|
||||
|
||||
private fun tool(id: String, name: String, input: JSONObject): AgentHost.Entry.Used {
|
||||
val path = input.optString("filePath")
|
||||
return when (name) {
|
||||
"bash" -> AgentHost.Entry.Used(id, "Bash", firstLine(input.optString("command")), input.optString("command"))
|
||||
"edit" -> AgentHost.Entry.Used(id, "Edit", path, path + "\n" + lineDiff(input.optString("oldString"), input.optString("newString")))
|
||||
"write" -> AgentHost.Entry.Used(id, "Write", path, path + "\n" + lineDiff("", input.optString("content")))
|
||||
"todowrite" -> AgentHost.Entry.Used(id, "TodoWrite", "", todos(input.optJSONArray("todos")))
|
||||
else -> AgentHost.Entry.Used(id, toolName(name), detail(input), if (input.length() == 0) "" else input.toString(2))
|
||||
}
|
||||
}
|
||||
|
||||
private fun detail(input: JSONObject): String {
|
||||
for (key in listOf("filePath", "path", "pattern", "url", "query", "description", "prompt", "command")) {
|
||||
input.optString(key).takeIf { it.isNotEmpty() }?.let { return firstLine(it) }
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
private fun todos(list: JSONArray?) = (0 until (list?.length() ?: 0)).mapNotNull { i ->
|
||||
val todo = list?.optJSONObject(i) ?: return@mapNotNull null
|
||||
val mark = when (todo.optString("status")) { "completed" -> "[x]"; "in_progress" -> "[~]"; else -> "[ ]" }
|
||||
"$mark ${todo.optString("content")}"
|
||||
}.joinToString("\n")
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
internal fun firstLine(text: String) = text.lineSequence().first().take(160)
|
||||
|
||||
/**
|
||||
* [command] with its stderr in a log of its own under /root/.cache/droiddeck. The agent's stdout and stderr share one
|
||||
* pipe, and a log line written in the middle of a long JSON line would make that line unreadable.
|
||||
*/
|
||||
internal fun withoutStderr(log: String, command: List<String>) =
|
||||
listOf("/bin/sh", "-c", "mkdir -p /root/.cache/droiddeck; exec \"\$@\" 2>/root/.cache/droiddeck/$log.log", "sh") + command
|
||||
|
||||
private const val DIFF_CONTEXT = 2
|
||||
|
||||
/**
|
||||
@@ -417,6 +1060,18 @@ internal fun lineDiff(old: String, new: String): String {
|
||||
}.joinToString("\n")
|
||||
}
|
||||
|
||||
/** A unified diff's hunks without their headers; an added or deleted file's diff is its whole content. */
|
||||
@VisibleForTesting
|
||||
internal fun patchLines(diff: String, kind: String): String {
|
||||
val lines = diff.removeSuffix("\n").lines()
|
||||
when (kind) {
|
||||
"add" -> return lines.joinToString("\n") { "+$it" }
|
||||
"delete" -> return lines.joinToString("\n") { "-$it" }
|
||||
}
|
||||
val start = lines.indexOfFirst { it.startsWith("@@") }
|
||||
return (if (start < 0) lines else lines.drop(start)).filter { it.isNotEmpty() && !it.startsWith("@@") && !it.startsWith("\\") }.joinToString("\n")
|
||||
}
|
||||
|
||||
private val SHELL_WRAPPER = Regex("^/bin/(?:ba)?sh -l?c '(.*)'$", RegexOption.DOT_MATCHES_ALL)
|
||||
|
||||
/** Codex runs each command as `/bin/bash -lc '<command>'`; the command is what the user wants to read. */
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.nio.file.Files
|
||||
|
||||
/**
|
||||
* The launcher's agent: a coding agent CLI ([AgentHarness]) from the Linux userland, run headless
|
||||
* outside any game or desktop session: one process per turn, or for a CLI that takes its messages over
|
||||
* stdin one process kept open between turns, so background work can start a turn of its own. Conversations are kept on disk
|
||||
* outside any game or desktop session as one process that takes its messages over stdin and stays open
|
||||
* between turns, so background work can start a turn of its own. Conversations are kept on disk
|
||||
* ([AgentChats]), so a restart (a Lab build, a crash) continues the same one.
|
||||
*/
|
||||
object AgentHost {
|
||||
@@ -56,6 +56,9 @@ object AgentHost {
|
||||
/** A message typed while the agent was working, sent when the turn ends. */
|
||||
data class Queued(val text: String, val files: List<String>)
|
||||
|
||||
/** A tool call the CLI waits on the user to allow; [payload] is what its protocol needs to answer. */
|
||||
data class Approval(val id: String, val tool: String, val detail: String, val input: String, val payload: String = "")
|
||||
|
||||
enum class State { MISSING, IDLE, WORKING }
|
||||
|
||||
private const val TAG = "AgentHost"
|
||||
@@ -94,6 +97,12 @@ object AgentHost {
|
||||
private set
|
||||
var plan by mutableStateOf(false)
|
||||
private set
|
||||
/** The chosen [AgentHarness.Permission] of [harness]; asking first until the user picks another. */
|
||||
var permission by mutableStateOf(AgentHarness.ASK)
|
||||
private set
|
||||
/** Tool calls of the running turn that wait for the user, oldest first. */
|
||||
val approvals = mutableStateListOf<Approval>()
|
||||
private var approvalNoticed = false
|
||||
var chat by mutableStateOf<String?>(null)
|
||||
private set
|
||||
/** A reply finished since the conversation was last on screen. */
|
||||
@@ -123,7 +132,9 @@ object AgentHost {
|
||||
var lab by mutableStateOf<LabProgress?>(null)
|
||||
private set
|
||||
|
||||
private class Turn(val process: Process, val pid: Int, val stdin: java.io.OutputStream? = null) {
|
||||
private class Turn(val process: Process, val pid: Int, val protocol: AgentProtocol, val stdin: java.io.OutputStream) {
|
||||
fun write(lines: List<String>) = synchronized(this) { stdin.apply { lines.forEach { write((it + "\n").toByteArray()) }; flush() } }
|
||||
|
||||
var writingGeneration: Int? = null
|
||||
var exitStatus: Int? = null
|
||||
var costs: AgentCostTracker? = null
|
||||
@@ -171,6 +182,8 @@ object AgentHost {
|
||||
model = prefs(app).getString(modelKey(harness), null)
|
||||
effort = prefs(app).getString(effortKey(harness), null)?.takeIf { it in harness.efforts }
|
||||
plan = prefs(app).getBoolean(PLAN_KEY, false)
|
||||
permission = prefs(app).getString(permissionKey(harness), null)?.takeIf { id -> harness.permissions.any { it.id == id } }
|
||||
?: harness.permissions.first().id
|
||||
limits = decodeLimits(prefs(app).getString(limitsKey(harness), null))
|
||||
available = LinuxRuntime.hasRootfs(app)
|
||||
installed = harness.files.all { guestFileExists(app, it) }
|
||||
@@ -273,6 +286,42 @@ object AgentHost {
|
||||
prefs(context).edit().putBoolean(PLAN_KEY, on).apply()
|
||||
}
|
||||
|
||||
/** Kept per CLI, for every conversation; the CLI process restarts with it on the next message. */
|
||||
fun choosePermission(context: Context, id: String) {
|
||||
if (harness.permissions.none { it.id == id }) return
|
||||
permission = id
|
||||
prefs(context).edit().putString(permissionKey(harness), id).apply()
|
||||
}
|
||||
|
||||
/** Lets the CLI run [approval]'s tool call, or tells it the user said no. */
|
||||
fun answer(context: Context, approval: Approval, allow: Boolean) {
|
||||
if (!approvals.remove(approval)) return
|
||||
val running = turn ?: session ?: return
|
||||
val line = running.protocol.answer(approval, allow)
|
||||
val app = context.applicationContext
|
||||
val current = harness
|
||||
Thread({ runCatching { running.write(listOf(line)) }.onFailure { lost(app, running, current, it) } }, "agent-approval").start()
|
||||
approvalsChanged(app)
|
||||
}
|
||||
|
||||
/** The approval notice goes once nothing waits on the user any more. */
|
||||
private fun approvalsChanged(app: Context) {
|
||||
if (approvals.isNotEmpty() || !approvalNoticed) return
|
||||
approvalNoticed = false
|
||||
AgentNotice.clear(app)
|
||||
}
|
||||
|
||||
/**
|
||||
* A line the CLI waits for could not be written, so it would wait forever: its process ends, which ends
|
||||
* the turn, and the chat says why. A request that may have reached it is not sent again.
|
||||
*/
|
||||
private fun lost(app: Context, from: Turn, current: AgentHarness, error: Throwable) {
|
||||
Log.w(TAG, "could not write to ${current.name}", error)
|
||||
main.post { if (turn === from || session === from) record(app, Entry.Notice("Could not write to ${current.name}: ${error.message ?: error.javaClass.simpleName}")) }
|
||||
AgentProcesses.killTree(from.pid)
|
||||
from.process.destroy()
|
||||
}
|
||||
|
||||
fun models(context: Context) = harness.models(LinuxRuntime.rootDir(context.applicationContext))
|
||||
|
||||
/** Sends [text] now, or after the current turn when the agent is working. */
|
||||
@@ -303,19 +352,20 @@ object AgentHost {
|
||||
val current = harness
|
||||
val prompt = AgentAttachments.prompt(message, attached)
|
||||
turnPlanned = plan && current.plans
|
||||
val options = AgentHarness.Options(model, turnPlanned, BRIEF, effort)
|
||||
val command = current.turn(prompt, conversation, options)
|
||||
val line = current.input(prompt)
|
||||
val key = "${current.id}|$id|$model|$turnPlanned|$effort"
|
||||
val options = AgentHarness.Options(model, turnPlanned, BRIEF, effort, permission, workspace(app))
|
||||
val key = "${current.id}|$id|$model|$turnPlanned|$effort|$permission"
|
||||
val resumed = conversation
|
||||
background = false
|
||||
approvals.clear()
|
||||
approvalsChanged(app)
|
||||
val kept = session
|
||||
if (kept != null && line != null && sessionKey == key && kept.process.isAlive) {
|
||||
if (kept != null && sessionKey == key && kept.process.isAlive) {
|
||||
main.removeCallbacks(reap)
|
||||
turn = kept
|
||||
kept.writingGeneration = gen
|
||||
kept.clearingCosts = prompt == "/clear"
|
||||
Thread({
|
||||
val written = runCatching { synchronized(kept) { kept.stdin?.apply { write((line + "\n").toByteArray()); flush() } != null } }.getOrDefault(false)
|
||||
val written = runCatching { kept.write(kept.protocol.input(prompt, resumed, options, started = false)) }.isSuccess
|
||||
// The process died between turns: the same message goes to a new one, which resumes the conversation.
|
||||
main.post {
|
||||
if (kept.writingGeneration == gen) kept.writingGeneration = null
|
||||
@@ -323,7 +373,7 @@ object AgentHost {
|
||||
if (!written) {
|
||||
dropSession()
|
||||
turn = null
|
||||
spawn(app, gen, current, current.turn(prompt, conversation, options), line, key)
|
||||
spawn(app, gen, current, prompt, resumed, options, key)
|
||||
} else kept.exitStatus?.let { processExited(app, kept, current, it) }
|
||||
}
|
||||
}
|
||||
@@ -331,12 +381,14 @@ object AgentHost {
|
||||
return
|
||||
}
|
||||
dropSession()
|
||||
spawn(app, gen, current, command, line, key)
|
||||
spawn(app, gen, current, prompt, resumed, options, key)
|
||||
}
|
||||
|
||||
private fun spawn(app: Context, gen: Int, current: AgentHarness, command: List<String>, line: String?, key: String) {
|
||||
val workdir = workspace(app)
|
||||
var threadConversation = conversation
|
||||
private fun spawn(app: Context, gen: Int, current: AgentHarness, prompt: String, resumed: String?, options: AgentHarness.Options, key: String) {
|
||||
val workdir = options.workdir
|
||||
val command = current.turn(prompt, resumed, options)
|
||||
val protocol = current.protocol()
|
||||
var threadConversation = resumed
|
||||
Thread({
|
||||
runCatching { current.prepare(LinuxRuntime.rootDir(app)) }
|
||||
runCatching { AgentSetup.installHelpers(app) }
|
||||
@@ -349,17 +401,18 @@ object AgentHost {
|
||||
main.post { if (generation == gen) finish(app, e.message ?: "could not start") }
|
||||
return@Thread
|
||||
}
|
||||
val started = Turn(child, AgentProcesses.pidOf(child), if (line != null) child.outputStream else null).apply {
|
||||
if (current === ClaudeCode && line != null) costs = AgentCostTracker()
|
||||
val started = Turn(child, AgentProcesses.pidOf(child), protocol, child.outputStream).apply {
|
||||
if (current === ClaudeCode) costs = AgentCostTracker()
|
||||
}
|
||||
OrphanReaper.keep(started.pid)
|
||||
main.post {
|
||||
if (generation == gen && state == State.WORKING && turn == null) {
|
||||
turn = started
|
||||
if (line != null) { session = started; sessionKey = key }
|
||||
session = started
|
||||
sessionKey = key
|
||||
} else AgentProcesses.killTree(started.pid)
|
||||
}
|
||||
if (line != null) runCatching { child.outputStream.apply { write((line + "\n").toByteArray()); flush() } } else child.outputStream.close()
|
||||
runCatching { started.write(protocol.input(prompt, resumed, options, started = true)) }.onFailure { lost(app, started, current, it) }
|
||||
val raw = runCatching {
|
||||
val log = File(app.filesDir, TURN_LOG).apply { parentFile?.mkdirs() }
|
||||
log.renameTo(File(app.filesDir, "$TURN_LOG.1"))
|
||||
@@ -368,7 +421,8 @@ object AgentHost {
|
||||
runCatching {
|
||||
child.inputStream.bufferedReader().forEachLine { output ->
|
||||
runCatching { raw?.apply { write(output); newLine(); flush() } }
|
||||
val parsed = current.parse(output) ?: return@forEachLine
|
||||
val parsed = protocol.parse(output) ?: return@forEachLine
|
||||
if (parsed.reply.isNotEmpty()) runCatching { started.write(parsed.reply) }.onFailure { lost(app, started, current, it) }
|
||||
parsed.conversation?.let { threadConversation = it }
|
||||
val done = parsed.entries.any { it is Entry.Finished }
|
||||
val event = if (!done) parsed else runCatching { current.usage(LinuxRuntime.rootDir(app), threadConversation) }.getOrNull()
|
||||
@@ -410,7 +464,7 @@ object AgentHost {
|
||||
if (background && state == State.WORKING) finish(app, event.backgroundError, usage = event.usage?.let { from.costs?.perTurn(it) ?: it })
|
||||
return
|
||||
}
|
||||
val content = event.text != null || event.thinking != null || event.entries.any { it !is Entry.Finished }
|
||||
val content = event.text != null || event.thinking != null || event.approval != null || event.entries.any { it !is Entry.Finished }
|
||||
if (content && state == State.IDLE && session === from) {
|
||||
main.removeCallbacks(reap)
|
||||
background = true
|
||||
@@ -428,10 +482,17 @@ object AgentHost {
|
||||
from.clearingCosts = false
|
||||
}
|
||||
val applied = if (finished != null && state == State.WORKING && event.usage != null)
|
||||
event.copy(usage = from.costs?.perTurn(event.usage) ?: event.usage) else event
|
||||
event.copy(usage = turnCost(from.costs?.perTurn(event.usage) ?: event.usage)) else event
|
||||
apply(app, applied)
|
||||
}
|
||||
|
||||
/** A CLI that reports the conversation's whole cost spent what this chat has not recorded yet. */
|
||||
private fun turnCost(usage: Usage): Usage {
|
||||
if (!harness.sessionCost) return usage
|
||||
val recorded = entries.sumOf { (it as? Entry.Finished)?.usage?.costUsd ?: 0.0 }
|
||||
return usage.copy(costUsd = (usage.costUsd - recorded).coerceAtLeast(0.0))
|
||||
}
|
||||
|
||||
/** Ends the CLI process kept between turns, and with it whatever it still runs in the background. */
|
||||
private fun dropSession() {
|
||||
main.removeCallbacks(reap)
|
||||
@@ -529,6 +590,15 @@ object AgentHost {
|
||||
}
|
||||
event.text?.let { live += it }
|
||||
event.thinking?.let { liveThinking += it }
|
||||
event.resolved?.let { id ->
|
||||
approvals.removeAll { it.id == id }
|
||||
approvalsChanged(app)
|
||||
}
|
||||
event.approval?.takeIf { a -> state == State.WORKING && approvals.none { it.id == a.id } }?.let {
|
||||
approvals += it
|
||||
approvalNoticed = true
|
||||
AgentNotice.post(app, AgentNotice.Kind.APPROVAL, listOf(it.tool, it.detail).filter { s -> s.isNotEmpty() }.joinToString(": "))
|
||||
}
|
||||
event.context?.let { context = it }
|
||||
event.window?.let { window = it }
|
||||
event.limits?.let { reported ->
|
||||
@@ -549,6 +619,8 @@ object AgentHost {
|
||||
private fun finish(app: Context, error: String?, stopped: Boolean = false, usage: Usage? = null) {
|
||||
if (state != State.WORKING) return
|
||||
turn = null
|
||||
approvals.clear()
|
||||
approvalsChanged(app)
|
||||
val answeredTask = background
|
||||
background = false
|
||||
main.removeCallbacks(reap)
|
||||
@@ -762,6 +834,7 @@ object AgentHost {
|
||||
private const val LINGER_MS = 20 * 60_000L
|
||||
|
||||
private fun modelKey(harness: AgentHarness) = "model_${harness.id}"
|
||||
private fun permissionKey(harness: AgentHarness) = "permission_${harness.id}"
|
||||
private fun limitsKey(harness: AgentHarness) = "limits_${harness.id}"
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -16,10 +16,10 @@ internal object AgentNotice {
|
||||
private const val CHANNEL_ID = "agent_done"
|
||||
private const val NOTIFICATION_ID = 4108
|
||||
|
||||
enum class Kind { DONE, FAILED, QUESTION }
|
||||
enum class Kind { DONE, FAILED, QUESTION, APPROVAL }
|
||||
|
||||
fun post(context: Context, kind: Kind, text: String) {
|
||||
if (onScreen(context)) return
|
||||
if (onScreen(context, kind)) return
|
||||
val manager = context.getSystemService(NotificationManager::class.java) ?: return
|
||||
manager.createNotificationChannel(NotificationChannel(CHANNEL_ID, context.getString(R.string.agent_done_channel), NotificationManager.IMPORTANCE_DEFAULT))
|
||||
val open = PendingIntent.getActivity(context, 2,
|
||||
@@ -31,6 +31,7 @@ internal object AgentNotice {
|
||||
Kind.DONE -> R.string.agent_done
|
||||
Kind.FAILED -> R.string.agent_done_failed
|
||||
Kind.QUESTION -> R.string.agent_done_question
|
||||
Kind.APPROVAL -> R.string.agent_done_approval
|
||||
})
|
||||
runCatching {
|
||||
manager.notify(NOTIFICATION_ID, Notification.Builder(context, CHANNEL_ID)
|
||||
@@ -49,9 +50,9 @@ internal object AgentNotice {
|
||||
context.getSystemService(NotificationManager::class.java)?.cancel(NOTIFICATION_ID)
|
||||
}
|
||||
|
||||
/** The chat in a DroidDeck window in front, or the pet, which shows the reply in its own bubble. */
|
||||
private fun onScreen(context: Context): Boolean {
|
||||
if (AgentPet.floating) return true
|
||||
/** The chat in a DroidDeck window in front, or the pet, which shows the reply in its own bubble but has no way to answer an approval. */
|
||||
private fun onScreen(context: Context, kind: Kind): Boolean {
|
||||
if (AgentPet.floating && kind != Kind.APPROVAL) return true
|
||||
val state = ActivityManager.RunningAppProcessInfo().also { ActivityManager.getMyMemoryState(it) }
|
||||
return AgentPet.agentOnScreen > 0 && state.importance <= ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
|
||||
}
|
||||
|
||||
@@ -27,6 +27,55 @@ object AgentSetup {
|
||||
val detail = mutableStateMapOf<Step, String>()
|
||||
var runtimeInstalled by mutableStateOf(true)
|
||||
private set
|
||||
/** Ids of the harness's [AgentHarness.providers] with a key saved; signed in without one means its free models. */
|
||||
var keys by mutableStateOf(emptySet<String>())
|
||||
private set
|
||||
/** The provider and custom server picked in the key field, kept while a save is checked. */
|
||||
var provider by mutableStateOf<String?>(null)
|
||||
var server by mutableStateOf("")
|
||||
|
||||
/** Saves a pasted key for a harness that signs in with one, then checks the sign-in again. */
|
||||
fun saveKey(context: Context, provider: AgentHarness.Provider, key: String, endpoint: String? = null) = signInLocally(context) { harness, root ->
|
||||
harness.saveKey(root, provider, key, endpoint) { url, token -> fetch(context.applicationContext, url, token) }
|
||||
}
|
||||
|
||||
fun removeKey(context: Context, provider: AgentHarness.Provider) = signInLocally(context) { harness, root -> harness.removeKey(root, provider) }
|
||||
|
||||
/** A GET from the userland, which reaches the LAN servers the app's own cleartext policy does not. */
|
||||
private fun fetch(app: Context, url: String, token: String?): String {
|
||||
// The key goes in on stdin, so it is never in a command line.
|
||||
val process = AgentHost.guest(app, listOf("curl", "-fsSL", "--max-time", "20", "-H", "@-", url), connectAdb = false).start()
|
||||
process.outputStream.bufferedWriter().use { if (token != null) it.write("Authorization: Bearer $token\n") }
|
||||
val output = process.inputStream.bufferedReader().readText()
|
||||
check(process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() == 0) { output.trim().lines().lastOrNull()?.takeIf { it.isNotEmpty() } ?: "Cannot reach $url" }
|
||||
return output
|
||||
}
|
||||
|
||||
fun useFree(context: Context) = signInLocally(context) { harness, root -> harness.useFree(root) }
|
||||
|
||||
private val signInLock = Any()
|
||||
|
||||
private fun signInLocally(context: Context, write: (AgentHarness, File) -> Unit) {
|
||||
val app = context.applicationContext
|
||||
val harness = AgentHost.harness
|
||||
set(Step.SIGN_IN, Status.WORKING)
|
||||
Thread({
|
||||
// Each write reads the files the one before it left, including across a save's model request.
|
||||
val result = synchronized(signInLock) { runCatching { write(harness, LinuxRuntime.rootDir(app)) } }
|
||||
main.post {
|
||||
// A failure stays on the row with the key field open, since the next check would clear it.
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
status[Step.SIGN_IN] = Status.FAILED
|
||||
detail[Step.SIGN_IN] = error.message ?: "failed"
|
||||
} else {
|
||||
status[Step.SIGN_IN] = Status.UNKNOWN
|
||||
detail.remove(Step.SIGN_IN)
|
||||
check(app)
|
||||
}
|
||||
}
|
||||
}, "agent-sign-in").start()
|
||||
}
|
||||
|
||||
val ready: Boolean get() = Step.entries.filter { it.required }.all { status[it] == Status.DONE }
|
||||
|
||||
@@ -53,6 +102,7 @@ object AgentSetup {
|
||||
if (!runtimeInstalled) return
|
||||
AgentHost.refresh(app)
|
||||
val harness = AgentHost.harness
|
||||
keys = harness.keys(LinuxRuntime.rootDir(app))
|
||||
val probes = mutableListOf<Pair<Step, List<String>>>()
|
||||
for (step in Step.entries) if (status[step] != Status.WORKING) {
|
||||
when (step) {
|
||||
@@ -79,15 +129,23 @@ object AgentSetup {
|
||||
fun runsAsRoot(step: Step) = step == Step.INSTALL
|
||||
|
||||
/** Runs [step]'s action. [CONNECTION] is the app's own pairing flow, so the caller opens it. */
|
||||
fun run(context: Context, step: Step) {
|
||||
fun run(context: Context, step: Step) = run(context, step, null)
|
||||
|
||||
/** Opens the page where a provider's key is made, as the sign-in of a harness that takes pasted keys. */
|
||||
fun openKeyPage(context: Context, page: String) = run(context, Step.SIGN_IN, listOf("/root/.local/bin/android-open", page))
|
||||
|
||||
private fun run(context: Context, step: Step, override: List<String>?) {
|
||||
val app = context.applicationContext
|
||||
val harness = AgentHost.harness
|
||||
val command = when (step) {
|
||||
val command = override ?: when (step) {
|
||||
Step.CONNECTION -> return
|
||||
Step.INSTALL -> {
|
||||
listOf("sh", "-c", "set -e; export DEBIAN_FRONTEND=noninteractive; " +
|
||||
"dpkg --configure -a; apt-get update || echo 'Some package sources could not be refreshed; continuing'; apt-get -f install -y; " +
|
||||
"apt-get install -y --no-install-recommends git gh adb curl ca-certificates python3; ${harness.install}")
|
||||
"apt() { apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 \"\$@\"; }; " +
|
||||
"dpkg --configure -a || echo 'Some packages are not configured yet; repairing dependencies'; " +
|
||||
"for i in 1 2 3; do apt update -q && break; echo 'Some package sources could not be refreshed; retrying'; sleep 3; done; " +
|
||||
"apt -f install -y --fix-missing; " +
|
||||
"apt install -y --fix-missing --no-install-recommends git gh adb curl ca-certificates python3; ${harness.install}")
|
||||
}
|
||||
Step.SIGN_IN -> harness.signIn
|
||||
Step.GITHUB -> listOf("dd-gh-login")
|
||||
|
||||
@@ -16,13 +16,14 @@ import java.nio.file.attribute.BasicFileAttributes
|
||||
|
||||
/**
|
||||
* What the agent adds to the Linux userland, measured and removable piece by piece. Sign-ins
|
||||
* (~/.claude, ~/.codex, gh's config) are left alone, so removing a CLI and installing it again
|
||||
* does not sign out.
|
||||
* (~/.claude, ~/.codex, ~/.local/share/opencode, gh's config) are left alone, so removing a CLI
|
||||
* and installing it again does not sign out.
|
||||
*/
|
||||
object AgentStorage {
|
||||
enum class Item(val paths: List<String>) {
|
||||
CLAUDE_CODE(listOf("/root/.local/share/claude", "/root/.local/bin/claude", "/root/cc")),
|
||||
CODEX(listOf("/root/.local/bin/codex", "/root/.local/bin/codex-code-mode-host")),
|
||||
OPENCODE(listOf("/root/.opencode")),
|
||||
BUILD_TOOLS(listOf("/root/android-sdk", "/root/aapt2", "/root/x86root", "/root/.gradle")),
|
||||
SOURCE(listOf("/root/DroidDeck")),
|
||||
CACHES(listOf("/root/.cache", "/root/.npm")),
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.droiddeck.launcher.agent
|
||||
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.frontend.LibraryCache
|
||||
import com.droiddeck.launcher.stores.CloudSaves
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.xbox.Xodus
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.InputStream
|
||||
import java.util.concurrent.TimeUnit
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
internal object AgentStores {
|
||||
private const val OUTPUT_CAP = 160 * 1024
|
||||
|
||||
fun library(context: Context, request: JSONObject): JSONObject {
|
||||
val query = request.optString("query").trim()
|
||||
val source = request.optString("source").trim()
|
||||
val games = JSONArray()
|
||||
LibraryCache.load(context)
|
||||
.filter { (query.isEmpty() || it.name.contains(query, ignoreCase = true)) && (source.isEmpty() || it.source.equals(source, ignoreCase = true)) }
|
||||
.forEach {
|
||||
games.put(JSONObject().put("id", it.gameIdString).put("name", it.name).put("source", it.source)
|
||||
.put("storeId", it.storeId ?: JSONObject.NULL).put("folder", it.gameFiles?.path ?: JSONObject.NULL))
|
||||
}
|
||||
return JSONObject().put("ok", true).put("command", "library").put("games", games)
|
||||
}
|
||||
|
||||
fun xodus(context: Context, request: JSONObject): JSONObject {
|
||||
AgentAccess.requireCommands(context)
|
||||
val list = request.optJSONArray("args")
|
||||
val args = if (list == null) emptyList() else List(list.length()) { list.optString(it) }
|
||||
if (args.isEmpty() || args.any { it.isEmpty() }) throw AgentException("INVALID_REQUEST", "xodus needs its arguments")
|
||||
val timeoutMs = (request.optDouble("timeout", 120.0) * 1000).toLong().coerceIn(1_000L, 900_000L)
|
||||
return Xodus.start(context.applicationContext, args).use { child ->
|
||||
val out = Tail(child.process.inputStream)
|
||||
val err = Tail(child.process.errorStream)
|
||||
val finished = child.process.waitFor(timeoutMs, TimeUnit.MILLISECONDS)
|
||||
if (!finished) child.close()
|
||||
JSONObject().put("ok", true).put("command", "xodus").put("timedOut", !finished)
|
||||
.put("exit", if (finished) child.process.exitValue() else JSONObject.NULL)
|
||||
.put("stdout", out.text()).put("stderr", err.text())
|
||||
}
|
||||
}
|
||||
|
||||
fun cloud(context: Context, request: JSONObject): JSONObject {
|
||||
AgentAccess.requireCommands(context)
|
||||
val store = Store.byId(request.optString("store"))?.takeIf(CloudSaves::supports)
|
||||
?: throw AgentException("INVALID_REQUEST", "store must be one with cloud saves")
|
||||
val id = request.optString("id").ifEmpty { throw AgentException("INVALID_REQUEST", "cloud needs a game id") }
|
||||
val force = request.optBoolean("force")
|
||||
val result = when (val direction = request.optString("direction")) {
|
||||
"down" -> CloudSaves.download(context.applicationContext, store, id, force)
|
||||
"up" -> CloudSaves.upload(context.applicationContext, store, id, force)
|
||||
else -> throw AgentException("INVALID_REQUEST", "direction '$direction' is not down or up")
|
||||
}
|
||||
return JSONObject().put("ok", true).put("command", "cloud").put("result", result.result).put("files", result.files)
|
||||
.put("bytes", result.bytes).put("reason", result.reason).put("conflicts", result.conflicts).put("detail", result.detail)
|
||||
}
|
||||
|
||||
private class Tail(stream: InputStream) {
|
||||
private val kept = ByteArrayOutputStream()
|
||||
private var dropped = false
|
||||
private val reader = Thread({
|
||||
val buffer = ByteArray(8192)
|
||||
stream.use { input ->
|
||||
while (true) {
|
||||
val n = runCatching { input.read(buffer) }.getOrDefault(-1)
|
||||
if (n < 0) break
|
||||
synchronized(kept) {
|
||||
kept.write(buffer, 0, n)
|
||||
if (kept.size() > OUTPUT_CAP * 2) {
|
||||
val bytes = kept.toByteArray()
|
||||
kept.reset()
|
||||
kept.write(bytes, bytes.size - OUTPUT_CAP, OUTPUT_CAP)
|
||||
dropped = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, "agent-xodus-output").apply { isDaemon = true; start() }
|
||||
|
||||
fun text(): String {
|
||||
reader.join(2_000)
|
||||
val bytes = synchronized(kept) { kept.toByteArray() }
|
||||
val tail = if (bytes.size > OUTPUT_CAP) bytes.copyOfRange(bytes.size - OUTPUT_CAP, bytes.size) else bytes
|
||||
return (if (dropped || bytes.size > OUTPUT_CAP) "...\n" else "") + String(tail, Charsets.UTF_8)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,9 @@
|
||||
package com.droiddeck.launcher.agent
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import com.droiddeck.launcher.ui.NavTabs
|
||||
|
||||
object AgentTab {
|
||||
var shown by mutableStateOf(true)
|
||||
private set
|
||||
val shown: Boolean get() = "agent" !in NavTabs.hidden
|
||||
|
||||
val visible: Boolean get() = shown && AgentHost.available
|
||||
|
||||
fun load(context: Context) {
|
||||
shown = SessionPrefs.agentTab(context)
|
||||
}
|
||||
|
||||
fun set(context: Context, show: Boolean) {
|
||||
shown = show
|
||||
SessionPrefs.setAgentTab(context, show)
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,10 @@ import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PulseAudioComponent extends SessionPart {
|
||||
private static final String TAG = "PulseAudio";
|
||||
@@ -38,6 +40,7 @@ public class PulseAudioComponent extends SessionPart {
|
||||
private long generation;
|
||||
private long launches;
|
||||
private final IntConsumer terminate;
|
||||
final ReentrantReadWriteLock commands = new ReentrantReadWriteLock();
|
||||
|
||||
HostLifecycle(IntConsumer terminate) {
|
||||
this.terminate = terminate;
|
||||
@@ -54,11 +57,27 @@ public class PulseAudioComponent extends SessionPart {
|
||||
pid = -1;
|
||||
}
|
||||
|
||||
synchronized boolean launch(long expected, IntSupplier launch) {
|
||||
if (expected != generation) return false;
|
||||
launches++;
|
||||
pid = launch.getAsInt();
|
||||
return true;
|
||||
boolean launch(long expected, IntSupplier launch) {
|
||||
commands.writeLock().lock();
|
||||
try {
|
||||
synchronized (this) {
|
||||
if (expected != generation) return false;
|
||||
launches++;
|
||||
pid = launch.getAsInt();
|
||||
return true;
|
||||
}
|
||||
} finally {
|
||||
commands.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
<T> T command(long token, Supplier<T> command) {
|
||||
commands.readLock().lock();
|
||||
try {
|
||||
return live(token) ? command.get() : null;
|
||||
} finally {
|
||||
commands.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
synchronized boolean current(long expected) {
|
||||
@@ -218,13 +237,13 @@ public class PulseAudioComponent extends SessionPart {
|
||||
String loadedAs = null;
|
||||
for (int attempt = 1; attempt <= 5 && loadedAs == null && host.live(token); attempt++) {
|
||||
try { Thread.sleep(2000L); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; }
|
||||
if (pactlFor(token, "load-module", "module-directaudio-native-sink", "sink_name=DirectAudio", "performance_mode=1",
|
||||
"adaptive=1", "decay=0", "limiter=1", "watchdog=1", "volume=1.0", "control_dir=" + deviceControls) != null
|
||||
&& pactlFor(token, "set-default-sink", "DirectAudio") != null) {
|
||||
if (pactlOk(token, "load-module", "module-directaudio-native-sink", "sink_name=DirectAudio", "performance_mode=1",
|
||||
"adaptive=1", "decay=0", "limiter=1", "watchdog=1", "volume=1.0", "control_dir=" + deviceControls)
|
||||
&& pactlOk(token, "set-default-sink", "DirectAudio")) {
|
||||
loadedAs = "DirectAudio on attempt " + attempt;
|
||||
} else if (pactlFor(token, "load-module", "module-aaudio-sink", "sink_name=AAudioSink",
|
||||
"performance_mode=" + (attempt == 1 ? "1" : "0"), "adaptive=1", "volume=1.0", "control_dir=" + deviceControls) != null
|
||||
&& pactlFor(token, "set-default-sink", "AAudioSink") != null) {
|
||||
} else if (pactlOk(token, "load-module", "module-aaudio-sink", "sink_name=AAudioSink",
|
||||
"performance_mode=" + (attempt == 1 ? "1" : "0"), "adaptive=1", "volume=1.0", "control_dir=" + deviceControls)
|
||||
&& pactlOk(token, "set-default-sink", "AAudioSink")) {
|
||||
loadedAs = "the plain AAudio sink (AAudioSink) on attempt " + attempt;
|
||||
}
|
||||
}
|
||||
@@ -248,14 +267,24 @@ public class PulseAudioComponent extends SessionPart {
|
||||
}
|
||||
|
||||
private String pactlFor(long token, String... args) {
|
||||
return host.live(token) ? pactl(args) : null;
|
||||
return host.command(token, () -> pactl(true, args));
|
||||
}
|
||||
|
||||
/** Runs pactl against this daemon; its stdout, or null when it failed or timed out. */
|
||||
private String pactl(String... args) {
|
||||
private boolean pactlOk(long token, String... args) {
|
||||
return host.command(token, () -> pactl(false, args)) != null;
|
||||
}
|
||||
|
||||
private static void reap(java.lang.Process process) throws InterruptedException {
|
||||
process.destroyForcibly();
|
||||
process.waitFor(2, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/** Runs pactl against this daemon; its stdout when captured (empty otherwise), or null when it failed or timed out. */
|
||||
private String pactl(boolean capture, String... args) {
|
||||
File pactl = new File(workingDir, "pactl");
|
||||
if (!pactl.isFile() || host.pid <= 1) return null;
|
||||
java.lang.Process process = null;
|
||||
File output = null;
|
||||
try {
|
||||
File modules = new File(workingDir, "modules/arm64");
|
||||
ArrayList<String> cmd = new ArrayList<>();
|
||||
@@ -268,29 +297,33 @@ public class PulseAudioComponent extends SessionPart {
|
||||
builder.environment().put("HOME", workingDir.getAbsolutePath());
|
||||
builder.environment().put("TMPDIR", workingDir.getAbsolutePath());
|
||||
builder.environment().put("PULSE_SERVER", "unix:" + socket().getAbsolutePath());
|
||||
process = builder.start();
|
||||
String output;
|
||||
try (InputStream in = process.getInputStream();
|
||||
java.io.ByteArrayOutputStream outStream = new java.io.ByteArrayOutputStream()) {
|
||||
byte[] buf = new byte[4096];
|
||||
int n;
|
||||
while ((n = in.read(buf)) != -1) {
|
||||
outStream.write(buf, 0, n);
|
||||
}
|
||||
output = outStream.toString(java.nio.charset.StandardCharsets.UTF_8.name());
|
||||
if (capture) {
|
||||
output = File.createTempFile("pactl", ".out", workingDir);
|
||||
builder.redirectOutput(output);
|
||||
} else {
|
||||
builder.redirectOutput(new File("/dev/null"));
|
||||
}
|
||||
process = builder.start();
|
||||
if (!process.waitFor(5, TimeUnit.SECONDS)) {
|
||||
process.destroyForcibly();
|
||||
reap(process);
|
||||
return null;
|
||||
}
|
||||
return process.exitValue() == 0 ? output : null;
|
||||
if (process.exitValue() != 0) return null;
|
||||
return capture ? new String(Files.readAllBytes(output.toPath()), java.nio.charset.StandardCharsets.UTF_8) : "";
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
return null;
|
||||
} catch (Throwable t) {
|
||||
return null;
|
||||
} finally {
|
||||
if (process != null && process.isAlive()) process.destroyForcibly();
|
||||
if (process != null && process.isAlive()) {
|
||||
try {
|
||||
reap(process);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
if (output != null) output.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -175,5 +175,6 @@ internal class AddonPack(
|
||||
val ROCKSTAR = AddonPack("rockstar", BuildConfig.PACK_ROCKSTAR_SHA256, BuildConfig.PACK_ROCKSTAR_SIZE,
|
||||
listOf("Launcher32.exe", "Launcher64.exe"))
|
||||
val DIRT = AddonPack("dirt", BuildConfig.PACK_DIRT_SHA256, BuildConfig.PACK_DIRT_SIZE, listOf("ws2_32.dll"))
|
||||
val EPIC = AddonPack("epic", BuildConfig.PACK_EPIC_SHA256, BuildConfig.PACK_EPIC_SIZE, listOf("EpicGamesLauncher.exe"))
|
||||
}
|
||||
}
|
||||
@@ -281,9 +281,6 @@ object DeviceReport {
|
||||
k("Linux x86 (FEX)", if (com.droiddeck.launcher.runtime.LinuxFex.ready(context)) "ready" else "not set up")
|
||||
k("gamescope realtime", SessionPrefs.gamescopeRealtime(context))
|
||||
k("pace cores", SessionPrefs.paceCores(context))
|
||||
k("zRAM: compress Steam during games", SessionPrefs.zramClient(context))
|
||||
k("RAM cap", SessionPrefs.ramCapMb(context).let { if (it > 0) "$it MB" else "off" })
|
||||
k("VRAM cap", SessionPrefs.vramCapMb(context).let { if (it > 0) "$it MB" else "driver default" })
|
||||
k("proot without seccomp", SessionPrefs.prootNoSeccomp(context))
|
||||
k("native userland (no proot)", SessionPrefs.nativeUserland(context))
|
||||
k("proot fast path", SessionPrefs.prootFastPath(context))
|
||||
|
||||
@@ -122,6 +122,12 @@ public final class Downloader {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Boolean gone(String url) {
|
||||
Fetch fetch = fetch(url);
|
||||
if (fetch.body != null) return Boolean.FALSE;
|
||||
return fetch.fatal ? Boolean.TRUE : null;
|
||||
}
|
||||
|
||||
public static String downloadDirect(String url) {
|
||||
LAST_FAILURE.remove();
|
||||
return fetch(url).body;
|
||||
|
||||
@@ -23,6 +23,7 @@ object GameEnvironment {
|
||||
)
|
||||
|
||||
fun validName(name: String) = namePattern.matches(name)
|
||||
fun currentName(name: String) = if (name.startsWith("BL_")) "DD_" + name.removePrefix("BL_") else name
|
||||
fun supported(name: String) = name !in unused && !name.startsWith("BOX64_") && !name.startsWith("BOX86_")
|
||||
fun validValue(value: String) = '\u0000' !in value && value.length <= 8192
|
||||
fun validScope(scope: String) = scope.isEmpty() || (Regex("[1-9][0-9]*").matches(scope) && scope.toLongOrNull()?.let { it in 1..4294967295L } == true)
|
||||
@@ -97,14 +98,14 @@ object GameEnvironment {
|
||||
|
||||
val syncBackends = listOf(SessionPrefs.SYNC_NTSYNC, SessionPrefs.SYNC_FSYNC, SessionPrefs.SYNC_ESYNC, SessionPrefs.SYNC_WINESERVER)
|
||||
|
||||
val syncKeys = listOf("BL_SYNC", "BL_FSYNC_FIRST", "BL_SYNC_FALLBACK", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC", "PROTON_NO_NTSYNC", "WINEESYNC")
|
||||
val syncKeys = listOf("DD_SYNC", "DD_FSYNC_FIRST", "DD_SYNC_FALLBACK", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC", "PROTON_NO_NTSYNC", "WINEESYNC")
|
||||
|
||||
fun syncEnvironment(backend: String): Map<String, String> {
|
||||
require(backend in syncBackends) { "unknown sync $backend" }
|
||||
return buildMap {
|
||||
put("BL_SYNC", if (backend == SessionPrefs.SYNC_NTSYNC) "1" else "0")
|
||||
put("BL_FSYNC_FIRST", if (backend == SessionPrefs.SYNC_FSYNC) "1" else "0")
|
||||
put("BL_SYNC_FALLBACK", if (backend == SessionPrefs.SYNC_WINESERVER) "0" else "1")
|
||||
put("DD_SYNC", if (backend == SessionPrefs.SYNC_NTSYNC) "1" else "0")
|
||||
put("DD_FSYNC_FIRST", if (backend == SessionPrefs.SYNC_FSYNC) "1" else "0")
|
||||
put("DD_SYNC_FALLBACK", if (backend == SessionPrefs.SYNC_WINESERVER) "0" else "1")
|
||||
if (backend == SessionPrefs.SYNC_FSYNC) put("PROTON_NO_ESYNC", "1")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ object GameEnvironmentOptions {
|
||||
Option("PROTON_NO_NTSYNC", "1", R.string.game_env_no_ntsync, Type.TOGGLE, listOf("0", "1")),
|
||||
Option("PROTON_NO_ESYNC", "1", R.string.game_env_no_esync, Type.TOGGLE, listOf("0", "1")),
|
||||
Option("PROTON_NO_FSYNC", "1", R.string.game_env_no_fsync, Type.TOGGLE, listOf("0", "1")),
|
||||
Option("BL_FSYNC_FIRST", "1", R.string.game_env_fsync_first, Type.TOGGLE, listOf("0", "1")),
|
||||
Option("DD_FSYNC_FIRST", "1", R.string.game_env_fsync_first, Type.TOGGLE, listOf("0", "1")),
|
||||
Option("DXVK_HUD", "fps", R.string.game_env_hud, Type.MULTIPLE, listOf("scale=0.5", "scale=0.7", "opacity=0.5", "opacity=0.7", "devinfo", "fps", "frametimes", "submissions", "drawcalls", "pipelines", "descriptors", "memory", "gpuload", "version", "api", "cs", "compiler", "samplers")),
|
||||
Option("DXVK_CONFIG", "dxvk.maxFrameRate = 60", R.string.game_env_dxvk_config, Type.TEXT),
|
||||
Option("VKD3D_FRAME_RATE", "60", R.string.game_env_vkd3d_limit, Type.NUMBER),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Process
|
||||
import android.util.Log
|
||||
import java.io.BufferedWriter
|
||||
@@ -113,7 +114,17 @@ object SessionLogCapture {
|
||||
}
|
||||
}
|
||||
|
||||
fun dumpMemoryPressure(target: File) {
|
||||
internal const val LMKD_COMMAND = "logcat -d -b main,events -v threadtime -s lowmemorykiller:D killinfo:I" +
|
||||
" | grep -v -E 'pgskip|zoneinfo_parse|polling check|thrashing:' | tail -n 120"
|
||||
|
||||
private fun lowMemoryKiller(context: Context?): String = when {
|
||||
context == null -> "(not captured)\n"
|
||||
!WirelessAdbFix.hasSavedPairing(context) -> "(not captured: pair DroidDeck with Wireless debugging in Settings > Diagnostics)\n"
|
||||
else -> runCatching { WirelessAdbFix.shell(context, LMKD_COMMAND) }
|
||||
.fold({ it.ifBlank { "(no lmkd lines in the log)\n" } }, { "(not captured: ${it.message})\n" })
|
||||
}
|
||||
|
||||
fun dumpMemoryPressure(target: File, context: Context? = null) {
|
||||
var temporary: File? = null
|
||||
try {
|
||||
val staged = File.createTempFile(target.name, ".part", target.parentFile).also { temporary = it }
|
||||
@@ -150,7 +161,8 @@ object SessionLogCapture {
|
||||
body.isNotEmpty() -> body
|
||||
else -> "(no readable events were returned)\n"
|
||||
} +
|
||||
"\n/proc/pressure/memory:\n$pressure\n/proc/meminfo:\n$meminfo\n/sys/class/kgsl/kgsl/page_alloc:\n$gpu"
|
||||
"\n/proc/pressure/memory:\n$pressure\n/proc/meminfo:\n$meminfo\n/sys/class/kgsl/kgsl/page_alloc:\n$gpu" +
|
||||
"\nAndroid's low memory killer (lmkd), read over Wireless debugging:\n${lowMemoryKiller(context)}"
|
||||
)
|
||||
Files.move(
|
||||
staged.toPath(), target.toPath(),
|
||||
|
||||
@@ -37,7 +37,7 @@ object SteamIntegration {
|
||||
locationOn = WifiDiscovery.locationEnabled(context),
|
||||
brightness = Settings.System.canWrite(context),
|
||||
home = HomeApp.isDefault(context),
|
||||
shortcuts = shortcutsEnabled(context),
|
||||
shortcuts = shortcutsEnabled(context) && shortcutsCurrent(context),
|
||||
shortcutsRestricted = restrictedSettings(context),
|
||||
suggested = !SessionPrefs.sessionPrefs(context).getBoolean("steam_integration_seen", false),
|
||||
)
|
||||
@@ -61,6 +61,10 @@ object SteamIntegration {
|
||||
return enabled.split(':').any { ComponentName.unflattenFromString(it.trim()) == shortcutsComponent }
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun shortcutsCurrent(context: Context): Boolean =
|
||||
runCatching { context.packageManager.getPackageInfo(Relay.PACKAGE, 0).versionCode }.getOrDefault(0) >= Relay.VERSION
|
||||
|
||||
fun shortcutsListed(context: Context): Boolean =
|
||||
context.getSystemService(android.view.accessibility.AccessibilityManager::class.java)
|
||||
?.installedAccessibilityServiceList.orEmpty()
|
||||
|
||||
@@ -235,6 +235,17 @@ object WirelessAdbFix {
|
||||
|
||||
fun hasSavedPairing(context: Context): Boolean = savedConnection(context.applicationContext) != null
|
||||
|
||||
fun savedPairingIsLocal(context: Context): Boolean = savedConnection(context.applicationContext)?.host
|
||||
?.let { host ->
|
||||
// Unlike isLocalAddress, an address that cannot be matched to this device's own counts as remote.
|
||||
runCatching {
|
||||
val address = InetAddress.getByName(host)
|
||||
address.isLoopbackAddress || NetworkInterface.getNetworkInterfaces().toList().any { network ->
|
||||
network.inetAddresses.toList().any { it.address.contentEquals(address.address) }
|
||||
}
|
||||
}.getOrDefault(false)
|
||||
} == true
|
||||
|
||||
fun clearCachedApps(context: Context) {
|
||||
shell(context, "am kill-all")
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.provider.DocumentsContract.Root
|
||||
import android.provider.DocumentsProvider
|
||||
import android.webkit.MimeTypeMap
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.IOException
|
||||
@@ -26,11 +27,21 @@ import java.nio.file.attribute.BasicFileAttributes
|
||||
class AppFilesProvider : DocumentsProvider() {
|
||||
private lateinit var base: File
|
||||
private lateinit var baseCanonical: String
|
||||
private lateinit var privatePaths: List<String>
|
||||
|
||||
override fun attachInfo(context: Context, info: ProviderInfo) {
|
||||
super.attachInfo(context, info)
|
||||
base = context.dataDir
|
||||
baseCanonical = base.canonicalPath
|
||||
// The wireless ADB pairing identity, preferences, store logins and Steam's saved login stay app-only.
|
||||
privatePaths = listOf(
|
||||
context.noBackupFilesDir,
|
||||
File(base, "shared_prefs"),
|
||||
context.getDatabasePath("x").parentFile!!,
|
||||
File(context.filesDir, "stores"),
|
||||
File(SessionPrefs.steamRoot(context, "arm64"), "config"),
|
||||
File(SessionPrefs.steamRoot(context, "x86_64"), "config"),
|
||||
).flatMap { listOf(it.absoluteFile.normalize().path, runCatching { it.canonicalPath }.getOrDefault(it.path)) }.distinct()
|
||||
}
|
||||
|
||||
override fun onCreate() = true
|
||||
@@ -74,6 +85,7 @@ class AppFilesProvider : DocumentsProvider() {
|
||||
var file = File(parent, name)
|
||||
var n = 2
|
||||
while (file.exists()) file = File(parent, "$name (${n++})")
|
||||
if (isPrivate(file)) throw FileNotFoundException("could not create ${file.path}")
|
||||
val made = try {
|
||||
if (mimeType == Document.MIME_TYPE_DIR) file.mkdir() else file.createNewFile()
|
||||
} catch (e: IOException) {
|
||||
@@ -85,7 +97,7 @@ class AppFilesProvider : DocumentsProvider() {
|
||||
|
||||
override fun deleteDocument(documentId: String) {
|
||||
val file = fileFor(documentId)
|
||||
if (file.canonicalPath == baseCanonical) throw FileNotFoundException("the app folder itself is not deleted")
|
||||
if (file.canonicalPath == baseCanonical || holdsPrivate(file)) throw FileNotFoundException("$documentId holds the app's private files")
|
||||
try {
|
||||
deleteTree(file.toPath())
|
||||
} catch (e: IOException) {
|
||||
@@ -116,17 +128,19 @@ class AppFilesProvider : DocumentsProvider() {
|
||||
|
||||
override fun renameDocument(documentId: String, displayName: String): String {
|
||||
val file = fileFor(documentId)
|
||||
if (holdsPrivate(file)) throw FileNotFoundException("$documentId holds the app's private files")
|
||||
val target = File(file.parentFile, displayName.substringAfterLast('/'))
|
||||
if (target.exists() || !file.renameTo(target)) throw FileNotFoundException("could not rename $documentId")
|
||||
if (target.exists() || isPrivate(target) || !file.renameTo(target)) throw FileNotFoundException("could not rename $documentId")
|
||||
return target.absolutePath
|
||||
}
|
||||
|
||||
override fun moveDocument(sourceDocumentId: String, sourceParentDocumentId: String, targetParentDocumentId: String): String {
|
||||
val source = fileFor(sourceDocumentId)
|
||||
if (holdsPrivate(source)) throw FileNotFoundException("$sourceDocumentId holds the app's private files")
|
||||
val targetParent = fileFor(targetParentDocumentId)
|
||||
if (!targetParent.isDirectory) throw FileNotFoundException("$targetParentDocumentId is not a folder")
|
||||
val target = File(targetParent, source.name)
|
||||
if (target.exists() || !source.renameTo(target)) throw FileNotFoundException("could not move $sourceDocumentId")
|
||||
if (target.exists() || isPrivate(target) || !source.renameTo(target)) throw FileNotFoundException("could not move $sourceDocumentId")
|
||||
return target.absolutePath
|
||||
}
|
||||
|
||||
@@ -163,7 +177,19 @@ class AppFilesProvider : DocumentsProvider() {
|
||||
val abs = f.absoluteFile.normalize().path
|
||||
if (abs != base.absolutePath && !abs.startsWith(base.absolutePath + "/")) return false
|
||||
val real = runCatching { f.canonicalPath }.getOrNull() ?: return false
|
||||
return real == baseCanonical || real.startsWith("$baseCanonical/")
|
||||
if (real != baseCanonical && !real.startsWith("$baseCanonical/")) return false
|
||||
return !isPrivate(f)
|
||||
}
|
||||
|
||||
private fun isPrivate(f: File): Boolean {
|
||||
val real = runCatching { f.canonicalPath }.getOrNull() ?: return true
|
||||
val paths = listOf(f.absoluteFile.normalize().path, real)
|
||||
return privatePaths.any { p -> paths.any { it == p || it.startsWith("$p/") } }
|
||||
}
|
||||
|
||||
private fun holdsPrivate(f: File): Boolean {
|
||||
val paths = listOfNotNull(f.absoluteFile.normalize().path, runCatching { f.canonicalPath }.getOrNull())
|
||||
return privatePaths.any { p -> paths.any { p.startsWith("$it/") } }
|
||||
}
|
||||
|
||||
private fun addRow(result: MatrixCursor, file: File) {
|
||||
@@ -173,7 +199,7 @@ class AppFilesProvider : DocumentsProvider() {
|
||||
} else if (file.canWrite()) {
|
||||
flags = flags or Document.FLAG_SUPPORTS_WRITE
|
||||
}
|
||||
if (file.absolutePath != base.absolutePath && file.parentFile?.canWrite() == true) {
|
||||
if (file.absolutePath != base.absolutePath && file.parentFile?.canWrite() == true && !holdsPrivate(file)) {
|
||||
flags = flags or Document.FLAG_SUPPORTS_DELETE or Document.FLAG_SUPPORTS_RENAME or
|
||||
Document.FLAG_SUPPORTS_MOVE or Document.FLAG_SUPPORTS_REMOVE
|
||||
}
|
||||
|
||||
@@ -40,12 +40,10 @@ import androidx.compose.material.icons.filled.ContentPaste
|
||||
import androidx.compose.material.icons.filled.CreateNewFolder
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.Folder
|
||||
import androidx.compose.material.icons.filled.GridView
|
||||
import androidx.compose.material.icons.filled.SdStorage
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material.icons.filled.Sort
|
||||
import androidx.compose.material.icons.filled.Star
|
||||
import androidx.compose.material.icons.filled.ViewList
|
||||
import androidx.compose.material.icons.filled.StarBorder
|
||||
import androidx.compose.material.icons.filled.Storage
|
||||
import androidx.compose.material.icons.filled.Smartphone
|
||||
@@ -727,11 +725,15 @@ fun FileManagerScreen(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(MaterialTheme.colorScheme.surfaceContainer)
|
||||
.then(if (compactToolbar) Modifier.horizontalScroll(rememberScrollState()) else Modifier)
|
||||
.padding(horizontal = 8.dp, vertical = 6.dp),
|
||||
) {
|
||||
IconButton(onClick = { requestNavigation(FileManagerNavigation.UP) }, enabled = canGoUp && !cancellingNavigation, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(Icons.Filled.ArrowBack, stringResource(R.string.fm_back), tint = MaterialTheme.colorScheme.primary)
|
||||
val upEnabled = canGoUp && !cancellingNavigation
|
||||
IconButton(onClick = { requestNavigation(FileManagerNavigation.UP) }, enabled = upEnabled, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(
|
||||
Icons.Filled.ArrowBack,
|
||||
stringResource(R.string.fm_back),
|
||||
tint = if (upEnabled) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f),
|
||||
)
|
||||
}
|
||||
|
||||
val currentDriveLabel = stringResource(describeLocation(currentDir).driveLabel)
|
||||
@@ -794,113 +796,119 @@ fun FileManagerScreen(
|
||||
|
||||
Spacer(Modifier.width(4.dp))
|
||||
|
||||
if (showFavorites) {
|
||||
Text(
|
||||
text = stringResource(R.string.fm_favorites),
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontSize = 13.sp,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = if (compactToolbar) Modifier.widthIn(max = 140.dp) else Modifier.weight(1f),
|
||||
)
|
||||
} else if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
if (!compactToolbar) Spacer(Modifier.weight(1f))
|
||||
} else {
|
||||
Text(
|
||||
text = currentDir.name.ifBlank { currentDir.absolutePath },
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = if (compactToolbar) Modifier.widthIn(max = 140.dp) else Modifier.weight(1f),
|
||||
)
|
||||
}
|
||||
|
||||
if (launchDir != null) {
|
||||
IconButton(onClick = { requestNavigation(FileManagerNavigation.RETURN_TO_START) }, enabled = !cancellingNavigation, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(Icons.AutoMirrored.Filled.KeyboardReturn, stringResource(R.string.fm_return_to_start), tint = MaterialTheme.colorScheme.primary)
|
||||
}
|
||||
if (LocalConfiguration.current.screenWidthDp >= 700) Spacer(Modifier.width(56.dp))
|
||||
}
|
||||
|
||||
if (!showFavorites) {
|
||||
if (!pickMode) {
|
||||
OutlinedButton(
|
||||
onClick = { showNewFolderDialog = true },
|
||||
border = BorderStroke(1.dp, MaterialTheme.colorScheme.primary.copy(alpha = 0.6f)),
|
||||
contentPadding = PaddingValues(horizontal = 10.dp, vertical = 2.dp),
|
||||
modifier = Modifier.height(32.dp).focusGlide(CircleShape),
|
||||
) {
|
||||
Icon(Icons.Filled.CreateNewFolder, null, tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(16.dp))
|
||||
Spacer(Modifier.width(5.dp))
|
||||
Text(stringResource(R.string.fm_new_folder), color = MaterialTheme.colorScheme.onBackground, fontSize = 12.sp)
|
||||
}
|
||||
}
|
||||
IconButton(onClick = {
|
||||
gridView = !gridView
|
||||
browsePrefs.edit().putBoolean("fmGridView", gridView).apply()
|
||||
}, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(
|
||||
if (gridView) Icons.Filled.ViewList else Icons.Filled.GridView,
|
||||
if (gridView) stringResource(R.string.fm_list_view) else stringResource(R.string.fm_grid_view),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.then(if (compactToolbar) Modifier.horizontalScroll(rememberScrollState()) else Modifier),
|
||||
) {
|
||||
if (showFavorites) {
|
||||
Text(
|
||||
text = stringResource(R.string.fm_favorites),
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontSize = 13.sp,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = if (compactToolbar) Modifier.widthIn(max = 140.dp) else Modifier.weight(1f),
|
||||
)
|
||||
} else if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
if (!compactToolbar) Spacer(Modifier.weight(1f))
|
||||
} else {
|
||||
Text(
|
||||
text = currentDir.name.ifBlank { currentDir.absolutePath },
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = if (compactToolbar) Modifier.widthIn(max = 140.dp) else Modifier.weight(1f),
|
||||
)
|
||||
}
|
||||
IconButton(onClick = { showSearch = !showSearch; if (!showSearch) searchQuery = "" }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(Icons.Filled.Search, stringResource(R.string.fm_search), tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
Box {
|
||||
IconButton(onClick = { showSortMenu = true }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(Icons.Filled.Sort, stringResource(R.string.fm_sort), tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
DropdownMenu(expanded = showSortMenu, onDismissRequest = { showSortMenu = false }) {
|
||||
listOf("name" to stringResource(R.string.fm_sort_name), "date" to stringResource(R.string.fm_sort_date), "size" to stringResource(R.string.fm_prop_size))
|
||||
.forEach { (key, label) ->
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(if (sortBy == key) "$label ${if (sortDesc) "↓" else "↑"}" else label)
|
||||
},
|
||||
onClick = {
|
||||
if (sortBy == key) sortDesc = !sortDesc else { sortBy = key; sortDesc = false }
|
||||
browsePrefs.edit().putString("fmSortBy", sortBy)
|
||||
.putBoolean("fmSortDesc", sortDesc).apply()
|
||||
showSortMenu = false
|
||||
loadDirectory(currentDir, resetScroll = false)
|
||||
},
|
||||
modifier = Modifier.focusGlide(),
|
||||
)
|
||||
}
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outline)
|
||||
DropdownMenuItem(
|
||||
text = { Text(if (compactRows) stringResource(R.string.fm_rows_comfortable) else stringResource(R.string.fm_rows_compact)) },
|
||||
onClick = {
|
||||
compactRows = !compactRows
|
||||
browsePrefs.edit().putBoolean("fmCompactRows", compactRows).apply()
|
||||
showSortMenu = false
|
||||
},
|
||||
modifier = Modifier.focusGlide(),
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(if (showHidden) stringResource(R.string.fm_hide_hidden) else stringResource(R.string.fm_show_hidden)) },
|
||||
onClick = {
|
||||
showHidden = !showHidden
|
||||
browsePrefs.edit().putBoolean("fmShowHidden", showHidden).apply()
|
||||
showSortMenu = false
|
||||
loadDirectory(currentDir, resetScroll = false)
|
||||
},
|
||||
modifier = Modifier.focusGlide(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IconButton(onClick = { showFavorites = !showFavorites }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
if (showFavorites) {
|
||||
Icon(Icons.Filled.Star, stringResource(R.string.fm_hide_favorites), tint = MaterialTheme.colorScheme.primary)
|
||||
} else {
|
||||
Icon(Icons.Filled.StarBorder, stringResource(R.string.fm_show_favorites), tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
if (launchDir != null) {
|
||||
IconButton(onClick = { requestNavigation(FileManagerNavigation.RETURN_TO_START) }, enabled = !cancellingNavigation, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(Icons.AutoMirrored.Filled.KeyboardReturn, stringResource(R.string.fm_return_to_start), tint = MaterialTheme.colorScheme.primary)
|
||||
}
|
||||
if (LocalConfiguration.current.screenWidthDp >= 700) Spacer(Modifier.width(56.dp))
|
||||
}
|
||||
|
||||
if (!showFavorites) {
|
||||
if (!pickMode) {
|
||||
OutlinedButton(
|
||||
onClick = { showNewFolderDialog = true },
|
||||
border = BorderStroke(1.dp, MaterialTheme.colorScheme.primary.copy(alpha = 0.6f)),
|
||||
contentPadding = PaddingValues(horizontal = 10.dp, vertical = 2.dp),
|
||||
modifier = Modifier.height(32.dp).focusGlide(CircleShape),
|
||||
) {
|
||||
Icon(Icons.Filled.CreateNewFolder, null, tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(16.dp))
|
||||
Spacer(Modifier.width(5.dp))
|
||||
Text(stringResource(R.string.fm_new_folder), color = MaterialTheme.colorScheme.onBackground, fontSize = 12.sp)
|
||||
}
|
||||
}
|
||||
IconButton(onClick = { showSearch = !showSearch; if (!showSearch) searchQuery = "" }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(Icons.Filled.Search, stringResource(R.string.fm_search), tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
Box {
|
||||
IconButton(onClick = { showSortMenu = true }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(Icons.Filled.Sort, stringResource(R.string.fm_sort), tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
DropdownMenu(expanded = showSortMenu, onDismissRequest = { showSortMenu = false }) {
|
||||
listOf("name" to stringResource(R.string.fm_sort_name), "date" to stringResource(R.string.fm_sort_date), "size" to stringResource(R.string.fm_prop_size))
|
||||
.forEach { (key, label) ->
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(if (sortBy == key) "$label ${if (sortDesc) "↓" else "↑"}" else label)
|
||||
},
|
||||
onClick = {
|
||||
if (sortBy == key) sortDesc = !sortDesc else { sortBy = key; sortDesc = false }
|
||||
browsePrefs.edit().putString("fmSortBy", sortBy)
|
||||
.putBoolean("fmSortDesc", sortDesc).apply()
|
||||
showSortMenu = false
|
||||
loadDirectory(currentDir, resetScroll = false)
|
||||
},
|
||||
modifier = Modifier.focusGlide(),
|
||||
)
|
||||
}
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outline)
|
||||
DropdownMenuItem(
|
||||
text = { Text(if (gridView) stringResource(R.string.fm_list_view) else stringResource(R.string.fm_grid_view)) },
|
||||
onClick = {
|
||||
gridView = !gridView
|
||||
browsePrefs.edit().putBoolean("fmGridView", gridView).apply()
|
||||
showSortMenu = false
|
||||
},
|
||||
modifier = Modifier.focusGlide(),
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(if (compactRows) stringResource(R.string.fm_rows_comfortable) else stringResource(R.string.fm_rows_compact)) },
|
||||
onClick = {
|
||||
compactRows = !compactRows
|
||||
browsePrefs.edit().putBoolean("fmCompactRows", compactRows).apply()
|
||||
showSortMenu = false
|
||||
},
|
||||
modifier = Modifier.focusGlide(),
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(if (showHidden) stringResource(R.string.fm_hide_hidden) else stringResource(R.string.fm_show_hidden)) },
|
||||
onClick = {
|
||||
showHidden = !showHidden
|
||||
browsePrefs.edit().putBoolean("fmShowHidden", showHidden).apply()
|
||||
showSortMenu = false
|
||||
loadDirectory(currentDir, resetScroll = false)
|
||||
},
|
||||
modifier = Modifier.focusGlide(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IconButton(onClick = { showFavorites = !showFavorites }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
if (showFavorites) {
|
||||
Icon(Icons.Filled.Star, stringResource(R.string.fm_hide_favorites), tint = MaterialTheme.colorScheme.primary)
|
||||
} else {
|
||||
Icon(Icons.Filled.StarBorder, stringResource(R.string.fm_show_favorites), tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!pickMode && onExit != null) {
|
||||
|
||||
@@ -335,7 +335,10 @@ object AddedGames {
|
||||
val path = canonical(exe)
|
||||
val owner = ownerFolder(app, exe)
|
||||
if (owner != null && owner.path !in SessionPrefs.removedAddedGames(app)) {
|
||||
single(app, owner.path)?.takeIf { canonical(it.exe) == path }?.let { return AddResult.Existing(it) }
|
||||
single(app, owner.path)?.takeIf { canonical(it.exe) == path }?.let {
|
||||
if (guestPath(app, exe) != null) AddedExes.put(app, AddedExes.Entry(owner.path, exe.path))
|
||||
return AddResult.Existing(it)
|
||||
}
|
||||
}
|
||||
if (guestPath(app, exe) == null) {
|
||||
(owner ?: exe.parentFile)?.takeIf { guestPath(app, it) == null }?.let { bindFolder(app, it) }
|
||||
@@ -344,7 +347,7 @@ object AddedGames {
|
||||
val folder = owner ?: exe.parentFile ?: return AddResult.NotFound
|
||||
SessionPrefs.setAddedGameRemoved(app, folder.path, false)
|
||||
SessionPrefs.setAddedGameExe(app, folder.path, exe.path)
|
||||
if (owner == null) AddedExes.put(app, AddedExes.Entry(folder.path, exe.path))
|
||||
AddedExes.put(app, AddedExes.Entry(folder.path, exe.path))
|
||||
val game = single(app, folder.path) ?: return AddResult.NotFound
|
||||
AddedGamesPublisher.later(app) { com.droiddeck.launcher.stores.SteamLiveShortcuts.sync(app, listOf(game)) { true } }
|
||||
Log.i(TAG, "added ${game.name} from its exe")
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.droiddeck.launcher.frontend
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.provider.DocumentsContract
|
||||
import android.provider.OpenableColumns
|
||||
import android.util.AtomicFile
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.core.util.readText
|
||||
@@ -13,27 +16,65 @@ import java.io.InputStream
|
||||
|
||||
object GameFiles {
|
||||
const val EXTENSION = "steam"
|
||||
private const val MAX_BYTES = 128
|
||||
private const val MAX_BYTES = 4096
|
||||
private const val MAX_NAME_BYTES = 200
|
||||
private const val INVENTORY = ".droiddeck-sync.json"
|
||||
private const val FORMAT = "droiddeck-game-files-v1"
|
||||
|
||||
fun readIntent(context: Context, request: Intent): String? = runCatching {
|
||||
fun readIntent(context: Context, request: Intent): GameRequest? = runCatching {
|
||||
if (request.action != Intent.ACTION_VIEW) return null
|
||||
val uri = request.data ?: return null
|
||||
GameLaunchLink.parse(uri.toString())?.let { return it }
|
||||
GameRequest.link(uri.toString())?.let { return GameRequest(it) }
|
||||
val name = displayName(context, uri)
|
||||
val extension = name?.substringAfterLast('.', "").orEmpty()
|
||||
if (extension.lowercase(java.util.Locale.ROOT) in GameRequest.PROGRAMS) {
|
||||
val program = localFile(context, uri)?.takeIf { it.isFile } ?: return null
|
||||
return GameRequest(title = name?.substringBeforeLast('.'), program = program.canonicalFile)
|
||||
}
|
||||
val stream = when (uri.scheme) {
|
||||
"content" -> context.contentResolver.openInputStream(uri)
|
||||
"file" -> {
|
||||
if (!uri.authority.isNullOrEmpty() || uri.query != null || uri.fragment != null) return null
|
||||
File(uri.path ?: return null).inputStream()
|
||||
}
|
||||
null -> File(uri.toString()).takeIf { it.isAbsolute }?.inputStream()
|
||||
"content" -> runCatching { context.contentResolver.openInputStream(uri) }.getOrNull()
|
||||
?: localFile(context, uri)?.takeIf { it.isFile }?.inputStream()
|
||||
"file", null -> localFile(context, uri)?.inputStream()
|
||||
else -> null
|
||||
} ?: return null
|
||||
stream.use(::read)
|
||||
val id = stream.use(::read) ?: return null
|
||||
GameRequest(id, GameRequest.sourceOf(extension), name?.substringBeforeLast('.'))
|
||||
}.getOrNull()
|
||||
|
||||
private fun displayName(context: Context, uri: Uri): String? = when (uri.scheme) {
|
||||
"content" -> runCatching {
|
||||
context.contentResolver.query(uri, arrayOf(OpenableColumns.DISPLAY_NAME), null, null, null)?.use { c ->
|
||||
if (c.moveToFirst()) c.getString(0) else null
|
||||
}
|
||||
}.getOrNull() ?: uri.lastPathSegment?.substringAfterLast('/')?.substringAfterLast(':')
|
||||
"file" -> uri.path?.let { File(it).name }
|
||||
null -> File(uri.toString()).name
|
||||
else -> null
|
||||
}?.takeIf { it.isNotEmpty() }
|
||||
|
||||
private fun localFile(context: Context, uri: Uri): File? = when (uri.scheme) {
|
||||
"file" -> {
|
||||
if (!uri.authority.isNullOrEmpty() || uri.query != null || uri.fragment != null) null
|
||||
else uri.path?.let(::File)
|
||||
}
|
||||
null -> File(uri.toString()).takeIf { it.isAbsolute }
|
||||
"content" -> storageDocument(context, uri) ?: uri.pathSegments.let { parts ->
|
||||
(0..1).asSequence().map { File("/" + parts.drop(it).joinToString("/")) }.firstOrNull { it.isFile }
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
||||
// Frontends pass SAF document URIs or FileProvider URIs whose path mirrors shared storage.
|
||||
private fun storageDocument(context: Context, uri: Uri): File? {
|
||||
if (uri.authority != "com.android.externalstorage.documents" || !DocumentsContract.isDocumentUri(context, uri)) return null
|
||||
val id = DocumentsContract.getDocumentId(uri)
|
||||
val volume = id.substringBefore(':')
|
||||
val path = id.substringAfter(':', "")
|
||||
val root = if (volume.equals("primary", ignoreCase = true)) android.os.Environment.getExternalStorageDirectory()
|
||||
else File("/storage", volume)
|
||||
return File(root, path)
|
||||
}
|
||||
|
||||
fun read(stream: InputStream): String? {
|
||||
val bytes = ByteArray(MAX_BYTES + 1)
|
||||
var count = 0
|
||||
@@ -44,8 +85,7 @@ object GameFiles {
|
||||
count += n
|
||||
}
|
||||
if (count > MAX_BYTES) return null
|
||||
val text = String(bytes, 0, count, Charsets.UTF_8).trim()
|
||||
return text.takeIf(GameLaunchLink::validId)
|
||||
return GameRequest.parse(String(bytes, 0, count, Charsets.UTF_8))
|
||||
}
|
||||
|
||||
fun filename(game: Library.SteamGame, disambiguate: Boolean = false): String {
|
||||
@@ -61,7 +101,7 @@ object GameFiles {
|
||||
}
|
||||
val title = String(points, 0, end).trimEnd { it.isWhitespace() || it == '.' }.ifBlank { "Game" }
|
||||
val suffix = if (disambiguate) " (${game.gameIdString})" else ""
|
||||
return "$title$suffix.$EXTENSION"
|
||||
return "$title$suffix.${GameRequest.extension(game)}"
|
||||
}
|
||||
|
||||
private fun contents(id: String): String {
|
||||
@@ -130,7 +170,7 @@ object GameFiles {
|
||||
}
|
||||
for (name in previous.keys()) {
|
||||
val id = previous.getString(name)
|
||||
if (!next.has(name) && name.endsWith(".$EXTENSION") && GameLaunchLink.validId(id)) {
|
||||
if (!next.has(name) && ours(name) && GameLaunchLink.validId(id)) {
|
||||
val file = child(context, folder, name)
|
||||
if (matches(file, contents(id))) {
|
||||
val retained = exports.any { java.nio.file.Files.isSameFile(it.toPath(), file.toPath()) }
|
||||
@@ -141,6 +181,9 @@ object GameFiles {
|
||||
if (previous.toString() != next.toString()) write(inventory, JSONObject().put("format", FORMAT).put("games", next).toString())
|
||||
}
|
||||
|
||||
private fun ours(name: String) = name.substringAfterLast('.', "").lowercase(java.util.Locale.ROOT)
|
||||
.let { it == EXTENSION || it in GameRequest.extensions }
|
||||
|
||||
private fun inventoryOwns(context: Context, folder: File, record: JSONObject, file: File, id: String): Boolean {
|
||||
if (record.optString(file.name) == id) return true
|
||||
if (!file.exists()) return false
|
||||
|
||||
@@ -11,22 +11,26 @@ object GameLaunchIntent {
|
||||
|
||||
fun accepts(action: String?): Boolean = action == Intent.ACTION_VIEW || action == ACTION || action == GAMENATIVE_ACTION
|
||||
|
||||
fun read(context: Context, intent: Intent): String? = when (intent.action) {
|
||||
fun read(context: Context, intent: Intent): GameRequest? = when (intent.action) {
|
||||
Intent.ACTION_VIEW -> GameFiles.readIntent(context, intent)
|
||||
ACTION, GAMENATIVE_ACTION -> readId(intent)
|
||||
ACTION, GAMENATIVE_ACTION -> readExtras(intent)
|
||||
else -> null
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
internal fun readId(intent: Intent): String? = runCatching {
|
||||
internal fun readExtras(intent: Intent): GameRequest? = runCatching {
|
||||
if (intent.action != ACTION && intent.action != GAMENATIVE_ACTION) return null
|
||||
val source = intent.extras?.get(EXTRA_GAME_SOURCE)
|
||||
if (source != null && (source !is String || !source.equals("STEAM", ignoreCase = true))) return null
|
||||
val source = when (val value = intent.extras?.get(EXTRA_GAME_SOURCE)) {
|
||||
null -> Library.SOURCE_STEAM
|
||||
is String -> GameRequest.sourceNamed(value) ?: return null
|
||||
else -> return null
|
||||
}
|
||||
val id = when (val value = intent.extras?.get(EXTRA_APP_ID)) {
|
||||
is Int -> value.takeIf { it > 0 }?.toString()
|
||||
is Long -> value.takeIf { it != 0L }?.let(java.lang.Long::toUnsignedString)
|
||||
is String -> value.takeIf(GameLaunchLink::validId)
|
||||
else -> null
|
||||
}
|
||||
id
|
||||
} ?: return null
|
||||
GameRequest(id, source)
|
||||
}.getOrNull()
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.droiddeck.launcher.frontend
|
||||
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
class GameRequest(
|
||||
val id: String? = null,
|
||||
val source: String = Library.SOURCE_STEAM,
|
||||
val title: String? = null,
|
||||
val program: File? = null,
|
||||
) {
|
||||
fun find(games: List<Library.SteamGame>, byTitle: Boolean = true): Library.SteamGame? {
|
||||
program?.let { return owner(games, it) }
|
||||
val exact = id?.let { id -> games.firstOrNull { it.gameIdString == id } }
|
||||
if (source == Library.SOURCE_STEAM) return exact ?: games.firstOrNull { it.appId > 0 && it.appId.toString() == id }
|
||||
exact?.takeIf { it.source == source }?.let { return it }
|
||||
id?.let { id -> games.firstOrNull { it.source == source && it.storeId == id } }?.let { return it }
|
||||
if (!byTitle) return null
|
||||
val key = title?.let(::titleKey)?.takeIf { it.isNotEmpty() } ?: return null
|
||||
return games.firstOrNull { it.source == source && titleKey(it.name) == key }
|
||||
}
|
||||
|
||||
private fun owner(games: List<Library.SteamGame>, program: File): Library.SteamGame? {
|
||||
val path = program.path
|
||||
return games.mapNotNull { game ->
|
||||
val folder = game.gameFiles ?: return@mapNotNull null
|
||||
val dir = folder.absolutePath.takeIf { inside(path, it) }
|
||||
?: runCatching { folder.canonicalPath }.getOrNull()?.takeIf { inside(path, it) }
|
||||
dir?.let { game to it.length }
|
||||
}.maxByOrNull { it.second }?.first
|
||||
}
|
||||
|
||||
companion object {
|
||||
val PROGRAMS = setOf("exe", "bat")
|
||||
private const val CUSTOM_GAME = "CUSTOM_GAME"
|
||||
private const val CUSTOM_EXTENSION = "pcgame"
|
||||
private val DAIJISHOU = setOf("# Daijishou Player Template", "# DST")
|
||||
private val daijishouId = Regex("""(?i)\[steamappid]\s*([0-9]+)""")
|
||||
private val steamLink = Regex("steam://rungameid/([1-9][0-9]{0,19})")
|
||||
|
||||
val extensions: Set<String> = Store.entries.map { it.id }.toSet() + CUSTOM_EXTENSION
|
||||
|
||||
fun extension(game: Library.SteamGame): String = Store.byId(game.source)?.id ?: GameFiles.EXTENSION
|
||||
|
||||
fun sourceNamed(value: String): String? = when {
|
||||
value.equals(Library.SOURCE_STEAM, ignoreCase = true) -> Library.SOURCE_STEAM
|
||||
value.equals(CUSTOM_GAME, ignoreCase = true) -> Library.ADDED
|
||||
else -> Store.entries.firstOrNull { it.name.equals(value, ignoreCase = true) }?.id
|
||||
}
|
||||
|
||||
fun sourceOf(extension: String): String = when (val ext = extension.lowercase(Locale.ROOT)) {
|
||||
CUSTOM_EXTENSION -> Library.ADDED
|
||||
else -> Store.byId(ext)?.id ?: Library.SOURCE_STEAM
|
||||
}
|
||||
|
||||
fun link(text: String): String? = text.takeIf(GameLaunchLink::validId)
|
||||
?: GameLaunchLink.parse(text)
|
||||
?: steamLink.matchEntire(text)?.groupValues?.get(1)?.takeIf(GameLaunchLink::validId)
|
||||
|
||||
fun parse(text: String): String? {
|
||||
link(text.trim())?.let { return it }
|
||||
val lines = text.lines().map { it.trim() }.filter { it.isNotEmpty() }
|
||||
val header = lines.firstOrNull() ?: return null
|
||||
return when {
|
||||
DAIJISHOU.any { header.equals(it, ignoreCase = true) } -> lines.firstNotNullOfOrNull { daijishouId.matchEntire(it) }
|
||||
?.groupValues?.get(1)?.takeIf(GameLaunchLink::validId)
|
||||
header.equals("[InternetShortcut]", ignoreCase = true) -> lines.firstOrNull { it.startsWith("URL=", ignoreCase = true) }
|
||||
?.substring(4)?.trim()?.takeIf { !GameLaunchLink.validId(it) }?.let(::link)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
internal fun titleKey(name: String): String = name.lowercase(Locale.ROOT).filter { it.isLetterOrDigit() }
|
||||
|
||||
private fun inside(path: String, dir: String) = path.startsWith(dir.trimEnd(File.separatorChar) + File.separator)
|
||||
}
|
||||
}
|
||||
@@ -222,16 +222,7 @@ object Library {
|
||||
|
||||
internal fun concealedSteamApps(root: File): Set<Long> {
|
||||
val config = AddedGames.accountConfig(root) ?: return emptySet()
|
||||
val hidden = runCatching {
|
||||
val entries = org.json.JSONArray(File(config, "cloudstorage/cloud-storage-namespace-1.json").readText())
|
||||
val entry = (0 until entries.length()).map { entries.getJSONArray(it) }
|
||||
.firstOrNull { it.optString(0) == "user-collections.hidden" }?.optJSONObject(1)
|
||||
if (entry == null || entry.optBoolean("is_deleted")) emptySet() else {
|
||||
val collection = org.json.JSONObject(entry.optString("value"))
|
||||
fun ids(key: String) = collection.optJSONArray(key)?.let { a -> (0 until a.length()).map { a.optLong(it) } }.orEmpty()
|
||||
ids("added").toSet() - ids("removed").toSet()
|
||||
}
|
||||
}.getOrDefault(emptySet())
|
||||
val hidden = SteamHidden.read(root)
|
||||
val private = runCatching {
|
||||
PRIVATE_APPS.find(File(config, "localconfig.vdf").readText())?.groupValues?.get(1)
|
||||
?.split(',')?.mapNotNull { it.trim().toLongOrNull() }?.toSet()
|
||||
@@ -302,6 +293,7 @@ object Library {
|
||||
g.steamAppId ?: g.appId.toInt(), g.name, art.portrait ?: art.header, ADDED, g.gameId,
|
||||
hero = art.hero ?: art.header, lastPlayed = maxOf(lastPlayed, recordedPlay(context, g.gameId)), gameFiles = g.folder,
|
||||
protonPrefix = if (g.source == com.droiddeck.launcher.stores.Store.BATTLENET.id) File(com.droiddeck.launcher.runtime.BattleNet.prefix(context), "pfx").takeIf { it.isDirectory }
|
||||
else if (g.source == com.droiddeck.launcher.stores.Store.UBISOFT.id) File(com.droiddeck.launcher.stores.ubisoft.UbisoftConnect.prefix(context), "pfx").takeIf { it.isDirectory }
|
||||
else protonPrefix(context, g.steamAppId?.toLong() ?: g.appId, libraries = roots),
|
||||
icon = art.icon?.takeIf { it.extension.lowercase() != "ico" },
|
||||
source = g.source, storeId = g.storeId,
|
||||
|
||||
@@ -177,9 +177,10 @@ object SoundtrackCollections {
|
||||
source = Library.SOURCE_COLLECTION, soundtrack = true,
|
||||
)
|
||||
|
||||
fun games(context: Context, favoritesLabel: String): List<Library.SteamGame> {
|
||||
fun games(context: Context, favoritesLabel: String, skipEmptyFavorites: Boolean = false): List<Library.SteamGame> {
|
||||
val s = snapshot
|
||||
return listOf(game(context, FAVORITES_ID, favoritesLabel, s.favorites)) + s.collections.map { game(context, it.id, it.name, it.tracks) }
|
||||
val favorites = if (skipEmptyFavorites && s.favorites.isEmpty()) emptyList() else listOf(game(context, FAVORITES_ID, favoritesLabel, s.favorites))
|
||||
return favorites + s.collections.map { game(context, it.id, it.name, it.tracks) }
|
||||
}
|
||||
|
||||
fun album(context: Context, id: Int): Soundtrack.Album {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.droiddeck.launcher.frontend
|
||||
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
internal object SteamHidden {
|
||||
private const val KEY = "user-collections.hidden"
|
||||
|
||||
private fun file(root: File): File? = AddedGames.accountConfig(root)?.let { File(it, "cloudstorage/cloud-storage-namespace-1.json") }
|
||||
|
||||
class Saved(val hidden: Set<Long>, val queued: Boolean)
|
||||
|
||||
private fun id(member: Any?): Long? = when (member) {
|
||||
is Int -> member.toLong()
|
||||
is Long -> member
|
||||
is String -> member.toLongOrNull()
|
||||
else -> null
|
||||
}
|
||||
|
||||
private fun ids(collection: JSONObject, key: String, strict: Boolean): List<Long> {
|
||||
if (!collection.has(key)) return emptyList()
|
||||
val array = collection.optJSONArray(key) ?: throw IllegalStateException(key)
|
||||
return (0 until array.length()).mapNotNull { index ->
|
||||
id(array.get(index)) ?: if (strict) throw IllegalStateException(key) else null
|
||||
}
|
||||
}
|
||||
|
||||
fun read(root: File): Set<Long> = readOrNull(root).orEmpty()
|
||||
|
||||
fun readOrNull(root: File): Set<Long>? = runCatching {
|
||||
val entries = JSONArray(file(root)?.readText() ?: return null)
|
||||
val slot = (0 until entries.length()).map { entries.getJSONArray(it) }.firstOrNull { it.optString(0) == KEY }
|
||||
val entry = slot?.optJSONObject(1)
|
||||
if (slot != null && entry == null) return null
|
||||
if (entry == null || entry.optBoolean("is_deleted")) emptySet() else {
|
||||
val collection = JSONObject(entry.optString("value"))
|
||||
ids(collection, "added", false).toSet() - ids(collection, "removed", false).toSet()
|
||||
}
|
||||
}.getOrNull()
|
||||
|
||||
fun write(root: File, appId: Long, hidden: Boolean, now: Long = System.currentTimeMillis() / 1000): Saved? = runCatching {
|
||||
val target = file(root) ?: return null
|
||||
val entries = JSONArray(target.readText())
|
||||
val slot = (0 until entries.length()).firstOrNull { entries.getJSONArray(it).optString(0) == KEY }
|
||||
val entry = if (slot == null) JSONObject().put("key", KEY) else entries.getJSONArray(slot).optJSONObject(1) ?: return null
|
||||
val live = !entry.optBoolean("is_deleted")
|
||||
val collection = if (live && entry.has("value")) JSONObject(entry.optString("value")) else JSONObject().put("id", "hidden")
|
||||
val added = ids(collection, "added", true).filter { it != appId }
|
||||
val removed = ids(collection, "removed", true).filter { it != appId }
|
||||
collection.put("added", JSONArray(if (hidden) added + appId else added))
|
||||
collection.put("removed", JSONArray(if (hidden) removed else removed + appId))
|
||||
entry.put("value", collection.toString())
|
||||
entry.put("timestamp", now)
|
||||
entry.put("is_deleted", false)
|
||||
entry.opt("version")?.toString()?.toLongOrNull()?.let { entry.put("version", (it + 1).toString()) }
|
||||
if (slot == null) entries.put(JSONArray().put(KEY).put(entry))
|
||||
val temp = File(target.parentFile, target.name + ".tmp")
|
||||
temp.writeText(entries.toString())
|
||||
if (!temp.renameTo(target)) {
|
||||
temp.delete()
|
||||
return null
|
||||
}
|
||||
Saved(ids(collection, "added", true).toSet() - ids(collection, "removed", true).toSet(), markModified(File(target.parentFile, "cloud-storage-namespace-1.modified.json")))
|
||||
}.getOrNull()
|
||||
|
||||
private fun markModified(file: File): Boolean {
|
||||
val pending = if (file.exists()) runCatching { JSONArray(file.readText()) }.getOrNull() ?: return false else JSONArray()
|
||||
if ((0 until pending.length()).any { pending.optString(it) == KEY }) return true
|
||||
val temp = File(file.parentFile, file.name + ".tmp")
|
||||
val saved = runCatching {
|
||||
temp.writeText(pending.put(KEY).toString())
|
||||
temp.renameTo(file)
|
||||
}.getOrDefault(false)
|
||||
if (!saved) temp.delete()
|
||||
return saved
|
||||
}
|
||||
}
|
||||
@@ -37,22 +37,22 @@ class ClockLogComponent(private val logFile: File) : SessionPart() {
|
||||
?.sortedBy { it.name.removePrefix("policy").toIntOrNull() ?: 0 } ?: emptyList()
|
||||
val gpuCandidates = gpuSources()
|
||||
val gpu = gpuCandidates.firstOrNull { !it.startsWith("/proc/") && firstNumber(it) != null }
|
||||
val stepSources = GpuLimits.stepSources()
|
||||
val maxSources = GpuLimits.maxSources()
|
||||
val minSources = GpuLimits.minSources()
|
||||
val steps = GpuLimits.first(stepSources)
|
||||
var ceiling = ceilingSource(maxSources)
|
||||
val power = app().getSystemService(Context.POWER_SERVICE) as? PowerManager
|
||||
val time = SimpleDateFormat("HH:mm:ss", Locale.US)
|
||||
try {
|
||||
FileWriter(logFile, true).use { w ->
|
||||
w.write("== clocks: ${Build.MANUFACTURER} ${Build.MODEL} (${Build.HARDWARE}), every ${PERIOD_MS / 1000}s\n")
|
||||
w.write("cpu policies: ${policies.joinToString { p -> p.name + " " + (File(p, "related_cpus").readTextOrNull()?.trim() ?: "?") }}\n")
|
||||
for (source in gpuCandidates) {
|
||||
val f = File(source)
|
||||
val state = when {
|
||||
!f.exists() -> continue
|
||||
firstNumber(source) != null -> "readable"
|
||||
else -> "refused"
|
||||
}
|
||||
w.write("gpu source $source: $state\n")
|
||||
}
|
||||
probeLines("gpu source", gpuCandidates).forEach { w.write(it + "\n") }
|
||||
w.write("gpu clock from: ${gpu ?: "nothing readable"}\n")
|
||||
(probeLines("gpu limit", stepSources, ::firstStep) + probeLines("gpu limit", maxSources, ::limit) +
|
||||
probeLines("gpu limit", minSources, ::firstStep)).distinct().forEach { w.write(it + "\n") }
|
||||
limitLines(steps, ceiling, GpuLimits.first(minSources)).forEach { w.write(it + "\n") }
|
||||
w.flush()
|
||||
while (running && logFile.length() < MAX_BYTES) {
|
||||
val line = StringBuilder(time.format(Date()))
|
||||
@@ -63,7 +63,8 @@ class ClockLogComponent(private val logFile: File) : SessionPart() {
|
||||
line.append(" ${p.name.removePrefix("policy").let { "p$it" }} ${mhz(cur)}/${mhz(max)}")
|
||||
if (hw != null && max != null && max < hw) line.append("(of ${mhz(hw)})")
|
||||
}
|
||||
gpu?.let { line.append(" | gpu ${mhz(firstNumber(it))} MHz") }
|
||||
if (ceiling == null) ceiling = ceilingSource(maxSources)?.also { w.write("gpu ceiling from: $it\n") }
|
||||
line.append(gpuField(gpu, ceiling, steps?.mhz?.last()))
|
||||
if (power != null && Build.VERSION.SDK_INT >= 29) {
|
||||
line.append(" | thermal ${power.currentThermalStatus}")
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
@@ -109,16 +110,41 @@ class ClockLogComponent(private val logFile: File) : SessionPart() {
|
||||
return list.distinct()
|
||||
}
|
||||
|
||||
internal fun probeLines(label: String, sources: List<String>, read: (String) -> Long? = ::firstNumber): List<String> = sources.mapNotNull { source ->
|
||||
when {
|
||||
!File(source).exists() -> null
|
||||
read(source) != null -> "$label $source: readable"
|
||||
else -> "$label $source: refused"
|
||||
}
|
||||
}
|
||||
|
||||
internal fun limitLines(steps: GpuLimits.Found?, ceiling: String?, floor: GpuLimits.Found?): List<String> = listOf(
|
||||
"gpu steps: " + (steps?.let { "${it.mhz.joinToString(" ")} MHz from ${it.path}" } ?: "nothing readable"),
|
||||
"gpu ceiling from: " + (ceiling ?: "nothing readable"),
|
||||
"gpu floor: " + (floor?.let { "${it.mhz.first()} MHz from ${it.path}" } ?: "nothing readable"),
|
||||
)
|
||||
|
||||
internal fun gpuField(clock: String?, ceiling: String?, top: Long?): String {
|
||||
if (clock == null && ceiling == null) return ""
|
||||
val field = StringBuilder(" | gpu ").append(mhz(clock?.let(::firstNumber)))
|
||||
ceiling?.let(::limit)?.let { max ->
|
||||
field.append('/').append(mhz(max))
|
||||
if (top != null && GpuLimits.mhz(max) < top) field.append("(of $top)")
|
||||
}
|
||||
return field.append(" MHz").toString()
|
||||
}
|
||||
|
||||
private fun File.readTextOrNull(): String? = runCatching { readText() }.getOrNull()
|
||||
|
||||
private fun firstNumber(path: String): Long? =
|
||||
runCatching { Regex("\\d+").find(File(path).readText())?.value?.toLong() }.getOrNull()
|
||||
|
||||
private fun mhz(raw: Long?): String = when {
|
||||
raw == null -> "?"
|
||||
raw > 10_000_000 -> (raw / 1_000_000).toString()
|
||||
raw > 10_000 -> (raw / 1_000).toString()
|
||||
else -> raw.toString()
|
||||
}
|
||||
internal fun limit(path: String): Long? = firstNumber(path)?.takeIf { it > 0 }
|
||||
|
||||
internal fun firstStep(path: String): Long? = GpuLimits.read(path).firstOrNull()
|
||||
|
||||
internal fun ceilingSource(sources: List<String>): String? = sources.firstOrNull { limit(it) != null }
|
||||
|
||||
private fun mhz(raw: Long?): String = raw?.let { GpuLimits.mhz(it).toString() } ?: "?"
|
||||
}
|
||||
}
|
||||
@@ -87,20 +87,10 @@ object DeviceInfo {
|
||||
private fun ghz(khz: Long) = String.format(Locale.US, "%.2f GHz", khz / 1e6)
|
||||
|
||||
private fun gpuRange(): String? {
|
||||
fun mhz(hz: Long) = "${hz / 1_000_000} MHz"
|
||||
val kgsl = read("/sys/class/kgsl/kgsl-3d0/gpu_available_frequencies")
|
||||
?.split(Regex("\\s+"))?.mapNotNull { it.toLongOrNull() }?.filter { it > 0 }.orEmpty()
|
||||
if (kgsl.isNotEmpty()) return "${mhz(kgsl.min())}–${mhz(kgsl.max())} (${kgsl.size} steps)"
|
||||
read("/sys/class/kgsl/kgsl-3d0/max_gpuclk")?.toLongOrNull()?.let { return "up to ${mhz(it)}" }
|
||||
val node = File("/sys/class/devfreq").listFiles()?.firstOrNull { f ->
|
||||
val n = f.name.lowercase()
|
||||
(n.contains("gpu") || n.contains("mali") || n.contains("kgsl-3d")) && listOf("bus", "bw", "memlat").none { n.contains(it) }
|
||||
} ?: return null
|
||||
val steps = read("${node.path}/available_frequencies")?.split(Regex("\\s+"))?.mapNotNull { it.toLongOrNull() }?.filter { it > 0 }.orEmpty()
|
||||
if (steps.isNotEmpty()) return "${mhz(steps.min())}–${mhz(steps.max())} (${steps.size} steps)"
|
||||
val min = read("${node.path}/min_freq")?.toLongOrNull()
|
||||
val max = read("${node.path}/max_freq")?.toLongOrNull() ?: return null
|
||||
return (if (min != null) "${mhz(min)}–" else "up to ") + mhz(max)
|
||||
GpuLimits.first(GpuLimits.stepSources())?.mhz?.let { return "${it.first()} MHz–${it.last()} MHz (${it.size} steps)" }
|
||||
val max = GpuLimits.first(GpuLimits.maxSources())?.mhz?.last() ?: return null
|
||||
val min = GpuLimits.first(GpuLimits.minSources())?.mhz?.first()
|
||||
return (if (min != null) "$min MHz–" else "up to ") + "$max MHz"
|
||||
}
|
||||
|
||||
private fun memory(context: Context) = Section("Memory", buildList<Pair<String, String>> {
|
||||
|
||||
@@ -18,6 +18,7 @@ object DriverPairs {
|
||||
/** RADV-Xclipse rebased on JimVulkan's upstream: a manual choice, never Auto. */
|
||||
const val NAD_RADV_XCLIPSE_UPSTREAM = "nad:radv-xclipse-upstream"
|
||||
private val XCLIPSE_MODEL = Regex("""(?i)xclipse\s*(\d{3})\b""")
|
||||
private val SUPPORTED_XCLIPSE_MODELS = setOf("530", "920", "940")
|
||||
const val NAD_MALI_JM = "nad:panvk-mali-jm"
|
||||
const val NAD_MALI_G710 = "nad:panvk-mali-g710"
|
||||
const val NAD_MALI_G615 = "nad:panvk-mali-g615"
|
||||
@@ -112,9 +113,12 @@ object DriverPairs {
|
||||
}
|
||||
}
|
||||
|
||||
/** 950 and 960 panic on the older build; a name without a model number is treated the same way. */
|
||||
private fun xclipseNeedsUpstream(name: String): Boolean =
|
||||
XCLIPSE_MODEL.find(name)?.groupValues?.get(1).let { it == null || it == "950" || it == "960" }
|
||||
internal fun xclipseNeedsUpstream(name: String): Boolean =
|
||||
XCLIPSE_MODEL.find(name)?.groupValues?.get(1) !in SUPPORTED_XCLIPSE_MODELS
|
||||
|
||||
fun autoEligible(gpu: GpuInfo, sdk: Int = android.os.Build.VERSION.SDK_INT): Boolean =
|
||||
recommendedKey(gpu, emptyList(), sdk = sdk) != null ||
|
||||
(gpu.family == Family.POWERVR && gpu.name.contains("Xclipse", ignoreCase = true))
|
||||
|
||||
fun recommendedKey(
|
||||
gpu: GpuInfo, pairs: List<DriverPair>,
|
||||
@@ -125,6 +129,7 @@ object DriverPairs {
|
||||
Family.POWERVR -> return when {
|
||||
!gpu.name.contains("Xclipse", ignoreCase = true) -> null
|
||||
xclipseNeedsUpstream(gpu.name) && pairs.any { it.key == NAD_RADV_XCLIPSE_UPSTREAM } -> NAD_RADV_XCLIPSE_UPSTREAM
|
||||
xclipseNeedsUpstream(gpu.name) -> null
|
||||
else -> NAD_RADV_XCLIPSE
|
||||
}
|
||||
Family.MALI_OTHER, Family.NOT_ADRENO -> return null
|
||||
|
||||
@@ -118,9 +118,7 @@ data class GpuInfo(
|
||||
val samsung = Build.MANUFACTURER.equals("samsung", ignoreCase = true)
|
||||
return GpuInfo(
|
||||
name = when {
|
||||
family == Family.POWERVR -> SystemVulkanDriver.gpuName().let { gpu ->
|
||||
VulkanInfo.cachedOrNull()?.get("device")?.takeIf { it.contains(gpu, ignoreCase = true) } ?: gpu
|
||||
}
|
||||
family == Family.POWERVR -> systemDriverName(SystemVulkanDriver.gpuName(), VulkanInfo.cachedOrNull())
|
||||
mali != null && mali.isNotEmpty() -> mali
|
||||
!adreno -> Build.HARDWARE.ifBlank { UNNAMED }
|
||||
model > 0 -> "Adreno $model"
|
||||
@@ -134,6 +132,9 @@ data class GpuInfo(
|
||||
)
|
||||
}
|
||||
|
||||
fun systemDriverName(gpu: String, vulkan: Map<String, String>?): String =
|
||||
vulkan?.get("device")?.takeIf { it.contains(gpu, ignoreCase = true) } ?: gpu
|
||||
|
||||
internal fun verifiedOn(model: Int, device: String): Boolean =
|
||||
model == 722 && device.equals("Retroid Pocket Duo", ignoreCase = true)
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.droiddeck.launcher.gpu
|
||||
|
||||
import java.io.File
|
||||
|
||||
object GpuLimits {
|
||||
class Found(val path: String, val mhz: List<Long>)
|
||||
|
||||
private const val KGSL = "/sys/class/kgsl/kgsl-3d0"
|
||||
private const val QCOM_GPU = "/sys/kernel/gpu"
|
||||
|
||||
fun stepSources(): List<String> = listOf(
|
||||
"$KGSL/gpu_available_frequencies", "$KGSL/freq_table_mhz", "$KGSL/devfreq/available_frequencies", "$QCOM_GPU/gpu_freq_table",
|
||||
) + devfreq("available_frequencies")
|
||||
|
||||
fun maxSources(): List<String> = listOf(
|
||||
"$KGSL/max_gpuclk", "$KGSL/max_clock_mhz", "$KGSL/devfreq/max_freq", "$QCOM_GPU/gpu_max_clock",
|
||||
) + devfreq("max_freq")
|
||||
|
||||
fun minSources(): List<String> = listOf(
|
||||
"$KGSL/min_clock_mhz", "$KGSL/devfreq/min_freq", "$QCOM_GPU/gpu_min_clock",
|
||||
) + devfreq("min_freq")
|
||||
|
||||
fun first(sources: List<String>): Found? =
|
||||
sources.firstNotNullOfOrNull { path -> read(path).takeIf { it.isNotEmpty() }?.let { Found(path, it) } }
|
||||
|
||||
fun read(path: String): List<Long> = runCatching {
|
||||
Regex("\\d+").findAll(File(path).readText()).map { mhz(it.value.toLong()) }.filter { it > 0 }.distinct().sorted().toList()
|
||||
}.getOrDefault(emptyList())
|
||||
|
||||
fun mhz(raw: Long): Long = when {
|
||||
raw > 10_000_000 -> raw / 1_000_000
|
||||
raw > 10_000 -> raw / 1_000
|
||||
else -> raw
|
||||
}
|
||||
|
||||
private fun devfreq(file: String): List<String> =
|
||||
File("/sys/class/devfreq").listFiles()?.filter { f ->
|
||||
val n = f.name.lowercase()
|
||||
(n.contains("gpu") || n.contains("mali") || n.contains("kgsl-3d")) && listOf("bus", "bw", "memlat").none { n.contains(it) }
|
||||
}?.sortedBy { it.name }?.map { "${it.path}/$file" }.orEmpty()
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import java.util.function.Supplier;
|
||||
|
||||
public final class LinuxVulkanDriver {
|
||||
private static final String TAG = "LinuxVulkanDriver";
|
||||
public static final String ENV = "BL_VK_DRIVER";
|
||||
public static final String ENV = "DD_VK_DRIVER";
|
||||
|
||||
public static final String HELP_TEXT =
|
||||
"The driver the Steam client, the games it launches and the desktop's programs render on, "
|
||||
|
||||
@@ -16,30 +16,36 @@ data class ScreenEffects(
|
||||
val hdr: Boolean = false,
|
||||
val deband: Boolean = false,
|
||||
val debandStrength: Int = 100,
|
||||
val fxaa: Boolean = false,
|
||||
val aaMode: Int = AA_OFF,
|
||||
val toon: Boolean = false,
|
||||
val crt: Boolean = false,
|
||||
val ntsc: Boolean = false,
|
||||
) {
|
||||
val fxaa: Boolean get() = aaMode == AA_FXAA
|
||||
val smaa: Boolean get() = aaMode == AA_SMAA
|
||||
val effectiveCas: Int get() = if (cas) casLevel else 0
|
||||
|
||||
val any: Boolean get() = brightness != 0 || contrast != 0 || abs(gamma - 1f) > 0.005f || saturation != 100 ||
|
||||
effectiveCas > 0 || hdr || deband || fxaa || toon || crt || ntsc
|
||||
effectiveCas > 0 || hdr || deband || aaMode != AA_OFF || toon || crt || ntsc
|
||||
|
||||
fun push(upscaler: Int) {
|
||||
WaylandCompositor.nativeSetCas(cas, casLevel)
|
||||
WaylandCompositor.nativeSetHdr(hdr)
|
||||
WaylandCompositor.nativeSetDeband(deband, debandStrength)
|
||||
WaylandCompositor.nativeSetScreenEffects(brightness.toFloat(), contrast.toFloat(), gamma, saturation.toFloat(), fxaa, toon, crt, ntsc)
|
||||
WaylandCompositor.nativeSetScreenEffects(brightness.toFloat(), contrast.toFloat(), gamma, saturation.toFloat(), aaMode, toon, crt, ntsc)
|
||||
WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(this, upscaler)?.name)
|
||||
}
|
||||
|
||||
fun encode(): JSONObject = JSONObject()
|
||||
.put("brightness", brightness).put("contrast", contrast).put("gamma", gamma.toDouble()).put("saturation", saturation)
|
||||
.put("cas", cas).put("casLevel", casLevel).put("hdr", hdr).put("deband", deband).put("debandStrength", debandStrength)
|
||||
.put("fxaa", fxaa).put("toon", toon).put("crt", crt).put("ntsc", ntsc)
|
||||
.put("aaMode", aaMode).put("fxaa", fxaa).put("toon", toon).put("crt", crt).put("ntsc", ntsc)
|
||||
|
||||
companion object {
|
||||
const val AA_OFF = 0
|
||||
const val AA_FXAA = 1
|
||||
const val AA_SMAA = 2
|
||||
|
||||
val OFF = ScreenEffects()
|
||||
|
||||
fun decode(json: JSONObject): ScreenEffects = ScreenEffects(
|
||||
@@ -52,7 +58,7 @@ data class ScreenEffects(
|
||||
hdr = json.optBoolean("hdr", false),
|
||||
deband = json.optBoolean("deband", false),
|
||||
debandStrength = json.optInt("debandStrength", 100).coerceIn(0, 200),
|
||||
fxaa = json.optBoolean("fxaa", false),
|
||||
aaMode = json.optInt("aaMode", if (json.optBoolean("fxaa", false)) AA_FXAA else AA_OFF).coerceIn(AA_OFF, AA_SMAA),
|
||||
toon = json.optBoolean("toon", false),
|
||||
crt = json.optBoolean("crt", false),
|
||||
ntsc = json.optBoolean("ntsc", false),
|
||||
@@ -79,13 +85,13 @@ object ScreenEffectLooks {
|
||||
desc = "Sharpening with a touch of contrast - the everyday one.", label = R.string.look_game_clarity, descRes = R.string.look_game_clarity_desc),
|
||||
Look("Vivid", ScreenEffects(brightness = 3, contrast = 10, gamma = 0.98f, saturation = 145, cas = true, casLevel = 30, deband = true),
|
||||
desc = "Colour pushed hard. Deband on so skies don't stripe.", label = R.string.look_vivid, descRes = R.string.look_vivid_desc),
|
||||
Look("Cinematic", ScreenEffects(brightness = -4, contrast = 22, gamma = 1.10f, saturation = 88, cas = true, casLevel = 20, fxaa = true, deband = true),
|
||||
Look("Cinematic", ScreenEffects(brightness = -4, contrast = 22, gamma = 1.10f, saturation = 88, cas = true, casLevel = 20, aaMode = ScreenEffects.AA_FXAA, deband = true),
|
||||
desc = "Deeper contrast, cooler colour, edges smoothed.", label = R.string.look_cinematic, descRes = R.string.look_cinematic_desc),
|
||||
Look("Competitive", ScreenEffects(brightness = 16, contrast = 18, gamma = 0.92f, saturation = 82, cas = true, casLevel = 75),
|
||||
desc = "Shadows lifted and heavy sharpening - spot people first.", label = R.string.look_competitive, descRes = R.string.look_competitive_desc),
|
||||
Look("Adaptive Sharpen", ScreenEffects(cas = true, casLevel = 85),
|
||||
desc = "Sharpening only, colour untouched.", label = R.string.look_adaptive_sharpen, descRes = R.string.look_adaptive_sharpen_desc),
|
||||
Look("Filmic", ScreenEffects(brightness = -2, contrast = 16, gamma = 1.14f, saturation = 92, cas = true, casLevel = 15, fxaa = true, deband = true),
|
||||
Look("Filmic", ScreenEffects(brightness = -2, contrast = 16, gamma = 1.14f, saturation = 92, cas = true, casLevel = 15, aaMode = ScreenEffects.AA_FXAA, deband = true),
|
||||
desc = "Film-like curve, slightly muted.", label = R.string.look_filmic, descRes = R.string.look_filmic_desc),
|
||||
Look("Arcade", ScreenEffects(brightness = 6, contrast = 20, gamma = 0.95f, saturation = 170, cas = true, casLevel = 45, deband = true),
|
||||
desc = "Loud and punchy.", label = R.string.look_arcade, descRes = R.string.look_arcade_desc),
|
||||
@@ -103,7 +109,7 @@ object ScreenEffectLooks {
|
||||
val t = l.effects
|
||||
t.brightness == e.brightness && t.contrast == e.contrast && abs(t.gamma - e.gamma) < 0.005f &&
|
||||
t.saturation == e.saturation && t.effectiveCas == e.effectiveCas &&
|
||||
t.fxaa == e.fxaa && t.crt == e.crt && t.toon == e.toon && t.ntsc == e.ntsc && t.deband == e.deband &&
|
||||
t.aaMode == e.aaMode && t.crt == e.crt && t.toon == e.toon && t.ntsc == e.ntsc && t.deband == e.deband &&
|
||||
(l.scalingMode == null || l.scalingMode == upscaler)
|
||||
}
|
||||
}
|
||||
@@ -256,12 +256,12 @@ public final class SystemVulkanDriver {
|
||||
if (xclipse) environment.add("DROIDDECK_HYBRIS_DXVK=dxvk-2.6.2");
|
||||
// The Android driver has a render node, but no KMS primary node. SDL presents
|
||||
// through the wrapper's Wayland Vulkan swapchain instead of a KMS-style path.
|
||||
environment.add("BL_GAMESCOPE_BACKEND=sdl");
|
||||
environment.add("DD_GAMESCOPE_BACKEND=sdl");
|
||||
// The Android pvr kernel accepts Vulkan DMA-BUF imports but rejects PRIME GEM handles.
|
||||
environment.add("BL_POWERVR_DRM_HANDLES=1");
|
||||
environment.add("BL_POWERVR_RENDER_NODE=" + node);
|
||||
environment.add("DD_POWERVR_DRM_HANDLES=1");
|
||||
environment.add("DD_POWERVR_RENDER_NODE=" + node);
|
||||
// Inner Gamescope/Xwayland lacks the bridge's Android-buffer WSI protocols.
|
||||
environment.add("BL_STEAM_GL_PRESENT=1");
|
||||
environment.add("DD_STEAM_GL_PRESENT=1");
|
||||
// Only actual Proton game launches use the bundled DXVK and X11 WSI layer.
|
||||
environment.add("DROIDDECK_POWERVR_RUNTIME=" + directory.getPath());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
internal object DroidDeckHudConfig {
|
||||
val DEFAULTS: Map<String, String> = linkedMapOf(
|
||||
"hudSize" to "minimal", "hudLocked" to "1", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid",
|
||||
"hudSize" to "minimal", "hudLocked" to "1", "hudHold" to "collapse", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid",
|
||||
"hudOutline" to "40", "hudOutlineAccent" to "1",
|
||||
"showGpuModel" to "1", "showGPULoad" to "1", "showCPUUsage" to "1", "showCPULoad" to "1",
|
||||
"showPerCore" to "1", "showTemp" to "1", "showBatteryTemp" to "1", "showGpuTemp" to "0",
|
||||
@@ -18,6 +18,8 @@ internal object DroidDeckHudConfig {
|
||||
"tempUnit" to "c", "tempBands" to "1", "tempAuto" to "1", "tempRedCpu" to "90", "tempRedGpu" to "90", "tempRedBat" to "48",
|
||||
)
|
||||
|
||||
const val HOLD_LOCKS = "lock"
|
||||
|
||||
private val NOT_READINGS = setOf("showCPULoad", "showRenderer", "fpsDecimal")
|
||||
|
||||
/** Orders saved before the GPU switch was named after the alias the HUD actually reads. */
|
||||
|
||||
@@ -119,6 +119,7 @@ class DroidDeckHudHost(context: Context) {
|
||||
}
|
||||
hud.setOnSizeCycledListener { size -> DroidDeckHudConfig.set(context, "hudSize", size); onConfigChanged?.invoke() }
|
||||
hud.setOnDockChangedListener { token -> setDock(hud, DroidDeckHudDock.from(token)) }
|
||||
hud.setOnHoldListener { rawX, rawY -> collapseAt(hud, rawX, rawY) }
|
||||
hud.setOnScaledListener { percent ->
|
||||
DroidDeckHudConfig.set(context, "hudScale", percent.toString())
|
||||
onConfigChanged?.invoke()
|
||||
@@ -291,7 +292,7 @@ class DroidDeckHudHost(context: Context) {
|
||||
DroidDeckHudDock.RIGHT -> (maxX - hud.x) / hud.width
|
||||
DroidDeckHudDock.TOP -> hud.y / hud.height
|
||||
DroidDeckHudDock.BOTTOM -> (maxY - hud.y) / hud.height
|
||||
DroidDeckHudDock.NONE -> 0f
|
||||
DroidDeckHudDock.NONE, DroidDeckHudDock.FLOAT -> 0f
|
||||
}
|
||||
if (pulled >= 1f) { setDock(hud, DroidDeckHudDock.NONE); return }
|
||||
wantX = hud.x; wantY = hud.y
|
||||
@@ -375,12 +376,30 @@ class DroidDeckHudHost(context: Context) {
|
||||
hud.scaleX = s; hud.scaleY = s
|
||||
}
|
||||
|
||||
private fun setDock(hud: DroidDeckHudView, edge: DroidDeckHudDock) {
|
||||
private fun setDock(hud: DroidDeckHudView, edge: DroidDeckHudDock, center: Pair<Float, Float>? = null) {
|
||||
if (edge == hud.dock) return
|
||||
animateDock(hud, edge) { commitDock(hud, edge) }
|
||||
animateDock(hud, edge, center) { commitDock(hud, edge) }
|
||||
}
|
||||
|
||||
private fun collapseAt(hud: DroidDeckHudView, rawX: Float, rawY: Float) {
|
||||
if (hud.dock != DroidDeckHudDock.NONE) return
|
||||
val p = hud.parent as? View ?: return
|
||||
val at = IntArray(2).also { p.getLocationOnScreen(it) }
|
||||
val x = rawX - at[0]
|
||||
val y = rawY - at[1]
|
||||
val edge = if (snaps) nearestEdge(x, y, p.width.toFloat(), p.height.toFloat()) else DroidDeckHudDock.FLOAT
|
||||
setDock(hud, edge, Pair(x, y))
|
||||
}
|
||||
|
||||
private fun nearestEdge(x: Float, y: Float, width: Float, height: Float): DroidDeckHudDock = mapOf(
|
||||
DroidDeckHudDock.LEFT to x,
|
||||
DroidDeckHudDock.RIGHT to width - x,
|
||||
DroidDeckHudDock.TOP to y,
|
||||
DroidDeckHudDock.BOTTOM to height - y,
|
||||
).minByOrNull { it.value }!!.key
|
||||
|
||||
private fun commitDock(hud: DroidDeckHudView, edge: DroidDeckHudDock) {
|
||||
snapping = false
|
||||
val tabX = hud.x; val tabY = hud.y
|
||||
if (edge != DroidDeckHudDock.NONE) {
|
||||
val p = hud.parent as? View
|
||||
@@ -407,12 +426,17 @@ class DroidDeckHudHost(context: Context) {
|
||||
SessionPrefs.setDroidDeckHudPosition(context, wantX, wantY)
|
||||
}
|
||||
|
||||
private fun animateDock(hud: DroidDeckHudView, edge: DroidDeckHudDock, commit: () -> Unit) {
|
||||
private fun animateDock(hud: DroidDeckHudView, edge: DroidDeckHudDock, center: Pair<Float, Float>?, commit: () -> Unit) {
|
||||
stopMotion(hud)
|
||||
previewFade?.cancel(); previewFade = null
|
||||
snapping = false
|
||||
hud.alpha = 1f
|
||||
val p = hud.parent as? View
|
||||
if (edge != DroidDeckHudDock.NONE && center != null) {
|
||||
val (tabW, tabH) = hud.dockTabSize()
|
||||
wantX = center.first - tabW / 2f
|
||||
wantY = center.second - tabH / 2f
|
||||
}
|
||||
if (Motion.scale == 0f || p == null || !hud.isLaidOut || hud.width <= 0) {
|
||||
hud.scaleX = 1f; hud.scaleY = 1f
|
||||
hud.setDockPreview(DroidDeckHudDock.NONE, 0f)
|
||||
@@ -424,11 +448,14 @@ class DroidDeckHudHost(context: Context) {
|
||||
hud.pivotX = 0f; hud.pivotY = 0f
|
||||
hud.x = left; hud.y = top
|
||||
val (tabW, tabH) = hud.dockTabSize()
|
||||
wantX = left + (shownW - tabW) / 2f
|
||||
wantY = top + (shownH - tabH) / 2f
|
||||
if (center == null) {
|
||||
wantX = left + (shownW - tabW) / 2f
|
||||
wantY = top + (shownH - tabH) / 2f
|
||||
}
|
||||
val (tabX, tabY) = settled(p, edge, tabW, tabH)
|
||||
val sx = tabW / hud.width; val sy = tabH / hud.height
|
||||
val from = hud.dockPreviewBlend
|
||||
snapping = true
|
||||
hud.animate().x(tabX).y(tabY).scaleX(sx).scaleY(sy).setDuration(Motion.ms(220).toLong()).setInterpolator(EASE)
|
||||
.setUpdateListener { hud.setDockPreview(edge, from + (1f - from) * it.animatedFraction) }
|
||||
.withEndAction {
|
||||
@@ -473,7 +500,7 @@ class DroidDeckHudHost(context: Context) {
|
||||
DroidDeckHudDock.RIGHT -> x = maxX
|
||||
DroidDeckHudDock.TOP -> y = 0f
|
||||
DroidDeckHudDock.BOTTOM -> y = maxY
|
||||
DroidDeckHudDock.NONE -> {}
|
||||
DroidDeckHudDock.NONE, DroidDeckHudDock.FLOAT -> {}
|
||||
}
|
||||
return Pair(x, y)
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ enum class DroidDeckHudSize(val token: String, val label: String) {
|
||||
}
|
||||
|
||||
enum class DroidDeckHudDock(val token: String) {
|
||||
NONE("none"), LEFT("left"), RIGHT("right"), TOP("top"), BOTTOM("bottom");
|
||||
NONE("none"), LEFT("left"), RIGHT("right"), TOP("top"), BOTTOM("bottom"), FLOAT("float");
|
||||
|
||||
companion object {
|
||||
fun from(token: String?): DroidDeckHudDock = values().firstOrNull { it.token == token } ?: NONE
|
||||
|
||||
@@ -191,6 +191,8 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
private var onMovedListener: BiConsumer<Float, Float>? = null
|
||||
private var onSizeCycledListener: Consumer<String>? = null
|
||||
private var onLockChangedListener: Consumer<Boolean>? = null
|
||||
private var onHoldListener: BiConsumer<Float, Float>? = null
|
||||
fun setOnHoldListener(l: BiConsumer<Float, Float>?) { onHoldListener = l }
|
||||
fun setOnMovedListener(l: BiConsumer<Float, Float>?) { onMovedListener = l }
|
||||
fun setOnSizeCycledListener(l: Consumer<String>?) { onSizeCycledListener = l }
|
||||
fun setOnLockChangedListener(l: Consumer<Boolean>?) { onLockChangedListener = l }
|
||||
@@ -209,6 +211,7 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
override fun onDragged(rawX: Float, rawY: Float) { onDraggedListener?.accept(rawX, rawY) }
|
||||
override fun onFlung(velocityX: Float, velocityY: Float) { onFlungListener?.accept(velocityX, velocityY) }
|
||||
override fun onLockChanged(locked: Boolean) { onLockChangedListener?.accept(locked) }
|
||||
override fun onHold(rawX: Float, rawY: Float) { onHoldListener?.accept(rawX, rawY) }
|
||||
override fun onPinch(factor: Float) {
|
||||
val next = (scale * factor).coerceIn(MIN_SCALE, MAX_SCALE)
|
||||
if (next == scale) return
|
||||
@@ -224,6 +227,7 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
private var tabStartX = 0f
|
||||
private var tabStartY = 0f
|
||||
private var tabDragging = false
|
||||
private var tabPressed = false
|
||||
private var onTabDraggedListener: BiConsumer<Float, Float>? = null
|
||||
private var onTabDroppedListener: Runnable? = null
|
||||
private var onTabDragCancelledListener: Runnable? = null
|
||||
@@ -237,19 +241,24 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
tabDownRawX = event.rawX; tabDownRawY = event.rawY
|
||||
tabStartX = x; tabStartY = y
|
||||
tabDragging = false
|
||||
tabPressed = true
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
MotionEvent.ACTION_MOVE -> if (tabPressed) {
|
||||
val dx = event.rawX - tabDownRawX; val dy = event.rawY - tabDownRawY
|
||||
if (!tabDragging && dx * dx + dy * dy > touchSlop * touchSlop) tabDragging = true
|
||||
if (tabDragging) onTabDraggedListener?.accept(tabStartX + dx, tabStartY + dy)
|
||||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
MotionEvent.ACTION_UP -> if (tabPressed) {
|
||||
tabPressed = false
|
||||
if (tabDragging) { tabDragging = false; onTabDroppedListener?.run() }
|
||||
else onDockChangedListener?.accept(DroidDeckHudDock.NONE.token)
|
||||
}
|
||||
MotionEvent.ACTION_CANCEL -> if (tabDragging) {
|
||||
tabDragging = false
|
||||
onTabDragCancelledListener?.run()
|
||||
MotionEvent.ACTION_CANCEL -> {
|
||||
tabPressed = false
|
||||
if (tabDragging) {
|
||||
tabDragging = false
|
||||
onTabDragCancelledListener?.run()
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
@@ -341,6 +350,7 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
showSession = switchOn("showSession")
|
||||
tempDisplay = HudMetrics.TempDisplay.from(cfg)
|
||||
lockController.setLocked(cfg.get("hudLocked", "1") == "1")
|
||||
lockController.setHoldLocks(cfg.get("hudHold", "collapse") == DroidDeckHudConfig.HOLD_LOCKS)
|
||||
dock = DroidDeckHudDock.from(cfg.get("hudDock", "none"))
|
||||
|
||||
colorIntensity = when (cfg.get("hudColor", "vivid")) {
|
||||
@@ -591,7 +601,7 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
DroidDeckHudDock.RIGHT -> intArrayOf(1, 2)
|
||||
DroidDeckHudDock.TOP -> intArrayOf(0, 1)
|
||||
DroidDeckHudDock.BOTTOM -> intArrayOf(2, 3)
|
||||
DroidDeckHudDock.NONE -> intArrayOf()
|
||||
DroidDeckHudDock.NONE, DroidDeckHudDock.FLOAT -> intArrayOf()
|
||||
}
|
||||
for (corner in edge) { round[corner * 2] = 0f; round[corner * 2 + 1] = 0f }
|
||||
tabPath.rewind()
|
||||
|
||||
@@ -275,7 +275,7 @@ internal class GameFrameFeed(
|
||||
private const val INFO_NS = 500_000_000L
|
||||
private const val SHIFT_NS = 1_000_000_000L
|
||||
private const val SHIFT_RECHECK_NS = 100_000_000L
|
||||
private const val CLOCK_CONTROL_PATH = "tmp/.bl-clock"
|
||||
private const val CLOCK_CONTROL_PATH = "tmp/.dd-clock"
|
||||
|
||||
fun forRoot(root: File) = GameFrameFeed(File(root, HudFrames.PATH), clockControl = File(root, CLOCK_CONTROL_PATH))
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ public class HudLockController {
|
||||
default void onDragged(float rawX, float rawY) {}
|
||||
default void onFlung(float velocityX, float velocityY) {}
|
||||
void onLockChanged(boolean locked);
|
||||
default void onHold(float rawX, float rawY) {}
|
||||
default void onPinch(float factor) {}
|
||||
default void onPinchEnd() {}
|
||||
}
|
||||
@@ -53,6 +54,7 @@ public class HudLockController {
|
||||
private final android.view.VelocityTracker velocity = android.view.VelocityTracker.obtain();
|
||||
|
||||
private boolean locked = false;
|
||||
private boolean holdLocks = false;
|
||||
|
||||
private float downRawX, downRawY, startX, startY;
|
||||
private boolean dragging = false;
|
||||
@@ -80,6 +82,8 @@ public class HudLockController {
|
||||
|
||||
public void setLocked(boolean locked) { this.locked = locked; }
|
||||
|
||||
public void setHoldLocks(boolean holdLocks) { this.holdLocks = holdLocks; }
|
||||
|
||||
public boolean isLocked() { return locked; }
|
||||
|
||||
public boolean isDragging() { return dragging; }
|
||||
@@ -119,6 +123,10 @@ public class HudLockController {
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
if (!holdLocks) {
|
||||
cb.onHold(e.getRawX(), e.getRawY());
|
||||
return;
|
||||
}
|
||||
locked = !locked;
|
||||
cb.onLockChanged(locked);
|
||||
flash(locked, HOLD_TOGGLE_MS);
|
||||
|
||||
@@ -82,6 +82,12 @@ object DualScreen {
|
||||
fun sessionDisplay(context: Context, displayManager: DisplayManager, primaryDisplayId: Int): Display? =
|
||||
display(context, displayManager, primaryDisplayId, SessionPrefs.dualScreenSessionMode(context))
|
||||
|
||||
fun selectedSessionDisplay(context: Context, displayManager: DisplayManager, primaryDisplayId: Int, selectedDisplayId: Int): Display? =
|
||||
displayManager.getDisplay(selectedDisplayId)?.takeIf {
|
||||
SessionPrefs.dualScreenSessionMode(context) != MODE_OFF && it.isValid && it.displayId != primaryDisplayId &&
|
||||
(it.flags and Display.FLAG_PRESENTATION) != 0 && !taken(it.displayId)
|
||||
}
|
||||
|
||||
fun display(context: Context, displayManager: DisplayManager, primaryDisplayId: Int, mode: String = SessionPrefs.dualScreenMode(context)): Display? =
|
||||
when (mode) {
|
||||
MODE_OFF -> null
|
||||
|
||||
@@ -11,6 +11,10 @@ import java.util.UUID
|
||||
|
||||
object InputLibraries {
|
||||
private const val VERSION = 14
|
||||
private val redesignVersions = 15..16
|
||||
private const val KIT_DPAD = "kit:dpad"
|
||||
private const val KEYBOARD = "builtin:keyboard"
|
||||
private const val REDESIGN_BACKUP = "library-before-controller-revert"
|
||||
private const val KEY = "library"
|
||||
private const val RECOVERY = "library-recovery."
|
||||
const val OVERLAY = "builtin.overlay"
|
||||
@@ -23,10 +27,18 @@ object InputLibraries {
|
||||
fun read(context: Context): InputLibrary {
|
||||
val p = prefs(context)
|
||||
val raw = p.getString(KEY, null)
|
||||
val decoded = raw?.let(::decode)
|
||||
val decoded = raw?.let { decode(it, context) }
|
||||
if (raw != null && decoded == null) return scopeLayouts(upgradeStockLayouts(upgradeOverlay(context, migrate(context))))
|
||||
var library = decoded ?: scopeLayouts(upgradeStockLayouts(upgradeOverlay(context, migrate(context))))
|
||||
val version = raw?.let { JSONObject(it).getInt("version") } ?: 0
|
||||
if (version in redesignVersions && raw != null) {
|
||||
val encoded = encode(library)
|
||||
if (encoded.length > 2_000_000) return library
|
||||
if (!commitWithBackup(p, raw, REDESIGN_BACKUP, encoded)) {
|
||||
android.util.Log.e("InputLibraries", "Could not save the restored input library")
|
||||
return library
|
||||
}
|
||||
}
|
||||
if (version < 5) library = scopeLayouts(upgradeStockLayouts(upgradeOverlay(context, library)))
|
||||
if (version < 11) library = neutralStockLayouts(library)
|
||||
if (version < 10) library = restyleGamepads(context, library)
|
||||
@@ -75,20 +87,35 @@ object InputLibraries {
|
||||
fun update(context: Context, change: (InputLibrary) -> InputLibrary): InputLibrary {
|
||||
val p = prefs(context)
|
||||
val stored = p.getString(KEY, null)
|
||||
val invalid = stored != null && decode(stored) == null
|
||||
val invalid = stored != null && decode(stored, context) == null
|
||||
require(!invalid || runCatching { JSONObject(stored!!).getInt("version") }.getOrNull()?.let { it <= VERSION } != false) {
|
||||
"The saved input library cannot be edited by this version."
|
||||
}
|
||||
val updated = change(read(context)).validate()
|
||||
if (invalid) {
|
||||
val backupKey = when {
|
||||
invalid -> RECOVERY + UUID.nameUUIDFromBytes(stored!!.toByteArray(Charsets.UTF_8))
|
||||
stored != null && p.getString(KEY, null) == stored &&
|
||||
JSONObject(stored).getInt("version") in redesignVersions -> REDESIGN_BACKUP
|
||||
else -> null
|
||||
}
|
||||
if (backupKey != null) {
|
||||
val encoded = encode(updated)
|
||||
require(encoded.length <= 2_000_000) { "The input library is too large to save." }
|
||||
check(p.edit().putString(RECOVERY + UUID.nameUUIDFromBytes(stored!!.toByteArray(Charsets.UTF_8)), stored)
|
||||
.putString(KEY, encoded).commit()) { "Could not save the input library and its recovery copy." }
|
||||
check(commitWithBackup(p, requireNotNull(stored), backupKey, encoded)) {
|
||||
"Could not save the input library and its recovery copy."
|
||||
}
|
||||
} else write(context, updated)
|
||||
return updated
|
||||
}
|
||||
|
||||
private fun commitWithBackup(prefs: android.content.SharedPreferences, raw: String, backupKey: String, encoded: String): Boolean {
|
||||
val previousBackup = prefs.getString(backupKey, null)
|
||||
if (prefs.edit().putString(backupKey, raw).putString(KEY, encoded).commit()) return true
|
||||
// SharedPreferences updates its in-memory values even when the disk write fails.
|
||||
prefs.edit().putString(KEY, raw).putString(backupKey, previousBackup).apply()
|
||||
return false
|
||||
}
|
||||
|
||||
private fun write(context: Context, library: InputLibrary) {
|
||||
val encoded = encode(library.validate())
|
||||
require(encoded.length <= 2_000_000) { "The input library is too large to save." }
|
||||
@@ -138,16 +165,16 @@ object InputLibraries {
|
||||
update(context) { library -> library.layouts.firstOrNull { it.id == layoutId && it.editable }?.let { library.withLayout(it.withQuickButton(button, shown)) } ?: library }
|
||||
}.isSuccess
|
||||
|
||||
fun defaultPositions(context: Context, library: InputLibrary, layout: SavedInputLayout): List<InputSurfaceElement>? {
|
||||
fun defaultPositions(context: Context, library: InputLibrary, layout: SavedInputLayout): Pair<List<InputSurfaceElement>, Float>? {
|
||||
val origin = layout.origin ?: layout.id
|
||||
InputStockLayouts.layouts().firstOrNull { it.id == origin }?.let { return it.elements }
|
||||
InputStockLayouts.layouts().firstOrNull { it.id == origin }?.let { return it.elements to it.aspect }
|
||||
if (origin == OVERLAY || origin.startsWith("migrated.layout.")) {
|
||||
val (surfaceContext, metrics) = primaryDisplay(context)
|
||||
val size = if (origin == OVERLAY) listOf(metrics.widthPixels, metrics.heightPixels)
|
||||
else origin.removePrefix("migrated.layout.").split('x').mapNotNull { it.toIntOrNull() }
|
||||
return size.takeIf { it.size == 2 && it.all { side -> side > 0 } }?.let { LegacyGamepadLayout(surfaceContext, it[0], it[1]).elements() }
|
||||
return size.takeIf { it.size == 2 && it.all { side -> side > 0 } }?.let { LegacyGamepadLayout(surfaceContext, it[0], it[1]).elements() to it[0].toFloat() / it[1] }
|
||||
}
|
||||
return library.layouts.firstOrNull { it.id == origin && it.id != layout.id }?.elements
|
||||
return library.layouts.firstOrNull { it.id == origin && it.id != layout.id }?.let { it.elements to it.aspect }
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -336,21 +363,31 @@ object InputLibraries {
|
||||
.put("profiles", profiles).put("layouts", layouts).put("bindings", bindings).toString()
|
||||
}
|
||||
|
||||
internal fun decode(raw: String): InputLibrary? = runCatching {
|
||||
internal fun decode(raw: String, context: Context? = null): InputLibrary? = runCatching {
|
||||
require(raw.length <= 2_000_000)
|
||||
val doc = JSONObject(raw); require(doc.getInt("version") in 2..VERSION)
|
||||
val doc = JSONObject(raw)
|
||||
val version = doc.getInt("version")
|
||||
val restore = context != null && version in redesignVersions
|
||||
require(version in 2..VERSION || restore)
|
||||
val generated = mutableSetOf<String>()
|
||||
val layouts = doc.getJSONArray("layouts").objects(256).map { layout ->
|
||||
val elements = layout.getJSONArray("elements").objects(64).map { e ->
|
||||
val stored = layout.getJSONArray("elements").objects(64).map { e ->
|
||||
InputSurfaceElement(requireNotNull(InputControl.fromId(e.getString("control"))), e.getDouble("x").toFloat(),
|
||||
e.getDouble("y").toFloat(), e.getDouble("width").toFloat(), e.getDouble("height").toFloat(),
|
||||
e.getString("id"), InputElementKind.valueOf(e.getString("kind")), e.getString("name"),
|
||||
e.optBoolean("floating", true), e.optBoolean("hideWhenIdle", false), e.optBoolean("mouseGestures", false), e.optBoolean("toggle", false), e.optInt("icon", 0), e.optString("image", ""),
|
||||
e.optDouble("elementOpacity", 1.0).toFloat(), InputButtonShape.valueOf(e.optString("buttonShape", InputButtonShape.ROUNDED.name)), e.optBoolean("showLabel", true), e.optBoolean("alwaysShown", false))
|
||||
}
|
||||
SavedInputLayout(layout.getString("id"), layout.getString("name"), elements, InputLayoutTemplate.valueOf(layout.getString("template")),
|
||||
val id = layout.getString("id")
|
||||
val origin = layout.optionalString("origin")
|
||||
val followsGamepad = restore && !layout.optBoolean("kitless") &&
|
||||
(id == OVERLAY || origin == OVERLAY) &&
|
||||
stored.none { it.id.startsWith("legacy:") || it.id == KIT_DPAD || it.id == KEYBOARD }
|
||||
if (followsGamepad) generated += id
|
||||
SavedInputLayout(id, layout.getString("name"), if (restore) stored.map { it.bounded() } else stored, InputLayoutTemplate.valueOf(layout.getString("template")),
|
||||
InputSurfaceStyle(if (!layout.has("tint")) ControllerPrefs.STEAM_BLUE else if (layout.isNull("tint")) null else layout.getInt("tint"), layout.optInt("opacity", 100),
|
||||
layout.optJSONArray("hidden")?.let { hidden -> (0 until hidden.length()).map { InputCommand.valueOf(hidden.getString(it)) }.toSet() }.orEmpty()),
|
||||
InputLayoutScreen.valueOf(layout.optString("screen", InputLayoutScreen.BOTH.name)), layout.optDouble("aspect", 0.0).toFloat(), layout.optionalString("origin"),
|
||||
InputLayoutScreen.valueOf(layout.optString("screen", InputLayoutScreen.BOTH.name)), layout.optDouble("aspect", 0.0).toFloat(), origin,
|
||||
layout.optDouble("scale", 1.0).toFloat())
|
||||
}
|
||||
val bindings = doc.getJSONArray("bindings").objects(512).map { b ->
|
||||
@@ -378,9 +415,41 @@ object InputLibraries {
|
||||
value.optBoolean("profileSelected", profile != InputProfiles.AUTO || parts.length() == 0))
|
||||
}
|
||||
}.orEmpty()
|
||||
InputLibrary(profiles, layouts, bindings, doc.getString("selected"), doc.getString("steam"), doc.getString("desktop"), selections).validate()
|
||||
val library = InputLibrary(profiles, layouts, bindings, doc.getString("selected"), doc.getString("steam"), doc.getString("desktop"), selections)
|
||||
(if (restore) restoreGamepads(requireNotNull(context), library, generated) else library).validate()
|
||||
}.getOrNull()
|
||||
|
||||
private fun restoreGamepads(context: Context, library: InputLibrary, generated: Set<String>): InputLibrary {
|
||||
val (display, metrics) = primaryDisplay(context)
|
||||
val height = metrics.heightPixels.coerceAtLeast(1)
|
||||
val layouts = library.layouts.map { layout ->
|
||||
if (layout.id !in generated) return@map layout
|
||||
val width = if (layout.aspect > 0f) (layout.aspect * height).toInt().coerceAtLeast(1)
|
||||
else metrics.widthPixels.coerceAtLeast(1)
|
||||
val gamepad = LegacyGamepadLayout(display, width, height, scale = layout.scale).elements()
|
||||
layout.copy(elements = gamepad.take(64 - layout.elements.size) + layout.elements,
|
||||
aspect = (width.toFloat() / height).coerceIn(.05f, 20f))
|
||||
}
|
||||
val byId = layouts.associateBy { it.id }
|
||||
val bindings = library.bindings.map { preset ->
|
||||
val layout = byId[preset.layoutId] ?: return@map preset
|
||||
val elements = layout.elements.associateBy { it.id }
|
||||
val defaults = layout.elements.mapNotNull { element ->
|
||||
val action = when (element.id) {
|
||||
KEYBOARD -> InputAction.Command(InputCommand.KEYBOARD)
|
||||
KIT_DPAD -> InputAction.Native()
|
||||
else -> return@mapNotNull null
|
||||
}
|
||||
element.id to action
|
||||
}.toMap()
|
||||
preset.copy(
|
||||
elements = defaults + preset.elements.filter { (id, action) -> elements[id]?.let { action.validFor(it) } == true },
|
||||
clicks = preset.clicks.filter { (id, action) -> elements[id]?.hasClick == true && action.validForClick() },
|
||||
)
|
||||
}
|
||||
return library.copy(layouts = layouts, bindings = bindings)
|
||||
}
|
||||
|
||||
private fun JSONArray.objects(limit: Int): List<JSONObject> {
|
||||
require(length() <= limit)
|
||||
return (0 until length()).map { getJSONObject(it) }
|
||||
|
||||
@@ -97,6 +97,16 @@ data class InputLibrary(
|
||||
fun compileActive(isDesktop: Boolean, panel: String? = null): InputProfile = compileParts(activeId(isDesktop), InputRole.entries.associateWith {
|
||||
preset(if (it == InputRole.SECONDARY) panelPart(isDesktop, panel).bindings else activePart(isDesktop, it).bindings)
|
||||
})
|
||||
fun compileStock(isDesktop: Boolean, panel: String? = null): InputProfile {
|
||||
val defaults = InputProfile.defaults(profile(activeId(isDesktop)).base)
|
||||
val stock = InputStockLayouts.presets(InputStockLayouts.layouts())
|
||||
return compileParts(defaults.id, InputRole.entries.associateWith { role ->
|
||||
val part = if (role == InputRole.SECONDARY) panelPart(isDesktop, panel) else activePart(isDesktop, role)
|
||||
val origin = layouts.firstOrNull { it.id == part.layout }?.origin ?: part.layout
|
||||
stock.firstOrNull { it.id == part.bindings || (origin != null && it.layoutId == origin) }
|
||||
?: SavedInputBindings(part.bindings, "", role == InputRole.PHYSICAL, part.layout, defaults.bindings[role].orEmpty())
|
||||
})
|
||||
}
|
||||
|
||||
fun saveSelection(isDesktop: Boolean, name: String, id: String = newInputId()): InputLibrary {
|
||||
val current = profile(activeId(isDesktop))
|
||||
|
||||
@@ -53,6 +53,16 @@ data class InputProfile(
|
||||
fun elementClickAction(role: InputRole, element: InputSurfaceElement): InputAction = clicks[role]?.get(element.id)
|
||||
?: defaultElementClick(element, elementAction(role, element.id, element.control)) { action(role, it) }
|
||||
|
||||
fun showsMouseButton(role: InputRole, shown: List<InputSurfaceElement>, stock: InputProfile): Boolean = shown.any { element ->
|
||||
val action = elementAction(role, element.id, element.control).takeIf {
|
||||
elements[role]?.get(element.id) != stock.elements[role]?.get(element.id) || it != stock.elementAction(role, element.id, element.control)
|
||||
}
|
||||
val click = elementClickAction(role, element).takeIf {
|
||||
clicks[role]?.get(element.id) != stock.clicks[role]?.get(element.id) || it != stock.elementClickAction(role, element)
|
||||
}
|
||||
listOfNotNull(action, click).any { it is InputAction.MouseButton && it.validFor(element.control) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val GAME = "game"
|
||||
const val DESKTOP = "desktop"
|
||||
|
||||
@@ -26,6 +26,8 @@ class KeyboardHost(
|
||||
var imeShowing = false
|
||||
private set
|
||||
var onImeChanged: ((Boolean) -> Unit)? = null
|
||||
val hideMeansDismissal: Boolean
|
||||
get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.R || (shown && imeShowing)
|
||||
|
||||
init {
|
||||
isFocusable = false
|
||||
|
||||
@@ -176,7 +176,7 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid
|
||||
}
|
||||
|
||||
|
||||
fun elements(): List<InputSurfaceElement> {
|
||||
fun elements(previousStickGeometry: Boolean = false): List<InputSurfaceElement> {
|
||||
fit = fitScale()
|
||||
controls.forEach { it.radius = scaled(it.radiusDp) }
|
||||
placeAuto(width.toFloat(), height.toFloat())
|
||||
@@ -189,7 +189,7 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid
|
||||
}.map { c ->
|
||||
InputSurfaceElement(requireNotNull(InputControl.fromId(c.id)), (c.cx - c.halfW) / width, (c.cy - c.halfH) / height,
|
||||
2 * c.halfW / width, 2 * c.halfH / height, floating = settings.adaptiveSticks, hideWhenIdle = c.stick >= 0 && settings.adaptiveSticks,
|
||||
buttonShape = if (c.id in shoulderIds) InputButtonShape.PILL else InputButtonShape.CIRCLE).let(::widenStick).bounded()
|
||||
buttonShape = if (c.id in shoulderIds) InputButtonShape.PILL else InputButtonShape.CIRCLE).let { if (previousStickGeometry) widenStickPreviously(it) else widenStick(it) }.bounded()
|
||||
}.toMutableList()
|
||||
if (settings.keyboardButton) result += keyboard()
|
||||
return result
|
||||
@@ -315,7 +315,7 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid
|
||||
return e.copy(x = (cx - radius) / width, y = (cy - radius) / height, width = 2 * radius / width, height = 2 * radius / height)
|
||||
}
|
||||
|
||||
private fun widenStick(e: InputSurfaceElement): InputSurfaceElement {
|
||||
private fun widenStickPreviously(e: InputSurfaceElement): InputSurfaceElement {
|
||||
val extra = e.width * (STICK_REACH - 1f)
|
||||
return when (e.control) {
|
||||
InputControl.LS -> (e.x - extra).coerceAtLeast(0f).let { x -> e.copy(x = x, width = e.x + e.width - x) }
|
||||
@@ -323,6 +323,16 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid
|
||||
else -> e
|
||||
}
|
||||
}
|
||||
|
||||
private fun widenStick(e: InputSurfaceElement): InputSurfaceElement {
|
||||
val extra = e.width * (STICK_REACH - 1f)
|
||||
val width = e.width + extra
|
||||
return when (e.control) {
|
||||
InputControl.LS -> e.copy(x = (e.x - extra).coerceIn(0f, (1f - width).coerceAtLeast(0f)), width = width)
|
||||
InputControl.RS -> e.copy(x = e.x.coerceIn(0f, (1f - width).coerceAtLeast(0f)), width = width)
|
||||
else -> e
|
||||
}
|
||||
}
|
||||
private companion object {
|
||||
const val MIN_FACE_MM = 9.5f
|
||||
const val FULL_SIZE_HEIGHT_MM = 85f
|
||||
|
||||
@@ -32,6 +32,7 @@ class OnScreenControls(context: Context, pad: PadBridge?, val dock: OnScreenLayo
|
||||
var isPinnedOnly = false
|
||||
private set
|
||||
val hasPinned get() = layout?.elements?.any { it.alwaysShown } == true
|
||||
val inputSurface: com.droiddeck.launcher.ui.InputSurfaceView get() = surface
|
||||
var onTouchMiss: ((MotionEvent) -> Unit)?
|
||||
get() = surface.onTouchMiss
|
||||
set(value) { surface.onTouchMiss = value }
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.graphics.Rect
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
object OnScreenLayout {
|
||||
data class Dock(val portrait: Boolean, val grips: Boolean, val left: InputControl = InputControl.LS, val right: InputControl = InputControl.RS) {
|
||||
@@ -41,6 +42,14 @@ object OnScreenLayout {
|
||||
return stored.mapNotNull { byId[it.id] } + placed.filter { p -> stored.none { it.id == p.id } }
|
||||
}
|
||||
|
||||
fun editorElements(context: Context, layout: SavedInputLayout, width: Int, height: Int, edited: Boolean = false): List<InputSurfaceElement> =
|
||||
elements(context, if (edited && width > 0 && height > 0) layout.copy(aspect = width.toFloat() / height) else layout, width, height, Rect())
|
||||
|
||||
fun editorFrame(layout: SavedInputLayout, displayed: List<InputSurfaceElement>): List<InputSurfaceElement> {
|
||||
val byId = displayed.associateBy { it.id }
|
||||
return layout.elements.map { byId[it.id] ?: it }
|
||||
}
|
||||
|
||||
fun fit(elements: List<InputSurfaceElement>, referenceWidth: Float, referenceHeight: Float, width: Int, height: Int, safe: Rect): List<InputSurfaceElement> {
|
||||
val w = width.toFloat()
|
||||
val h = height.toFloat()
|
||||
@@ -77,8 +86,11 @@ object OnScreenLayout {
|
||||
if (gamepad.any { it.id.startsWith("legacy:") }) {
|
||||
val named = layout.id.removePrefix("migrated.layout.").takeIf { it != layout.id }?.split('x')?.mapNotNull { it.toIntOrNull() }
|
||||
?.takeIf { it.size == 2 && it.all { size -> size > 0 } }?.let { it[0] to it[1] }
|
||||
for ((w, h) in listOfNotNull(named, width to height, long to short, short to long).distinct()) {
|
||||
if (matches(gamepad, LegacyGamepadLayout(display, w, h, scale = layout.scale).elements())) return (w.toFloat() to h.toFloat()) to true
|
||||
val aspectSize = layout.aspect.takeIf { layout.id == InputLibraries.OVERLAY && it > 0f }
|
||||
?.let { (it * height).roundToInt().coerceAtLeast(1) to height }
|
||||
for ((w, h) in listOfNotNull(named, width to height, aspectSize, long to short, short to long).distinct()) {
|
||||
val generator = LegacyGamepadLayout(display, w, h, scale = layout.scale)
|
||||
if (matches(gamepad, generator.elements()) || matches(gamepad, generator.elements(previousStickGeometry = true))) return (w.toFloat() to h.toFloat()) to true
|
||||
}
|
||||
}
|
||||
val aspect = layout.aspect.takeIf { it > 0f } ?: (long.toFloat() / short)
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.droiddeck.launcher.session.SessionState;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicIntegerArray;
|
||||
|
||||
public final class PadBridge {
|
||||
@@ -56,6 +58,7 @@ public final class PadBridge {
|
||||
private final FakeInputWriter[] playerWriters = new FakeInputWriter[SLOTS];
|
||||
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 int[] retainedSticks = new int[SLOTS];
|
||||
private final PadState effectiveState = new PadState();
|
||||
@@ -240,6 +243,7 @@ public final class PadBridge {
|
||||
clearBackQamWrites();
|
||||
releaseBackPaddles();
|
||||
activeControllerId = NO_CONTROLLER;
|
||||
rightStickLayouts.clear();
|
||||
for (int slot = 0; slot < SLOTS; slot++) {
|
||||
owners[slot] = NO_CONTROLLER;
|
||||
partners[slot] = NO_CONTROLLER;
|
||||
@@ -525,20 +529,23 @@ public final class PadBridge {
|
||||
float lx = event.getAxisValue(MotionEvent.AXIS_X);
|
||||
float ly = event.getAxisValue(MotionEvent.AXIS_Y);
|
||||
boolean wired = wiredXboxLayout(device, event.getSource());
|
||||
float rx = event.getAxisValue(wired ? MotionEvent.AXIS_RX : MotionEvent.AXIS_Z);
|
||||
float ry = event.getAxisValue(wired ? MotionEvent.AXIS_RY : MotionEvent.AXIS_RZ);
|
||||
boolean rxRyStick = rightStickUsesRxRy(event, device, rightStickLayouts);
|
||||
float rx = event.getAxisValue(rxRyStick ? MotionEvent.AXIS_RX : MotionEvent.AXIS_Z);
|
||||
float ry = event.getAxisValue(rxRyStick ? MotionEvent.AXIS_RY : MotionEvent.AXIS_RZ);
|
||||
retainStick(slot, JoyCon.LEFT, lx, ly);
|
||||
retainStick(slot, JoyCon.RIGHT, rx, ry);
|
||||
projectSticks(slot);
|
||||
int source = event.getSource();
|
||||
float lt = 0f;
|
||||
float rt = 0f;
|
||||
if (wired || hasAxis(device, source, MotionEvent.AXIS_LTRIGGER, MotionEvent.AXIS_BRAKE)) {
|
||||
lt = axisTrigger(leftTrigger(event, wired), keyTriggers[slot], 0);
|
||||
boolean signedLeft = signedZTriggers(event, device, wired, rxRyStick, true);
|
||||
boolean signedRight = signedZTriggers(event, device, wired, rxRyStick, false);
|
||||
if (signedLeft || hasAxis(device, source, MotionEvent.AXIS_LTRIGGER, MotionEvent.AXIS_BRAKE)) {
|
||||
lt = axisTrigger(triggerValue(event, device, wired, rxRyStick, true), keyTriggers[slot], 0);
|
||||
pad.leftTrigger = lt;
|
||||
}
|
||||
if (wired || hasAxis(device, source, MotionEvent.AXIS_RTRIGGER, MotionEvent.AXIS_GAS)) {
|
||||
rt = axisTrigger(rightTrigger(event, wired), keyTriggers[slot], 1);
|
||||
if (signedRight || hasAxis(device, source, MotionEvent.AXIS_RTRIGGER, MotionEvent.AXIS_GAS)) {
|
||||
rt = axisTrigger(triggerValue(event, device, wired, rxRyStick, false), keyTriggers[slot], 1);
|
||||
pad.rightTrigger = rt;
|
||||
}
|
||||
if (hasAxis(device, source, MotionEvent.AXIS_HAT_X)) {
|
||||
@@ -596,6 +603,92 @@ public final class PadBridge {
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean rightStickUsesRxRy(MotionEvent event, InputDevice device, Map<Integer, Boolean> layouts) {
|
||||
int source = event.getSource();
|
||||
if (wiredXboxLayout(device, source)) return true;
|
||||
boolean hasRxRy = hasAxis(device, source, MotionEvent.AXIS_RX)
|
||||
&& hasAxis(device, source, MotionEvent.AXIS_RY);
|
||||
boolean hasZRz = hasAxis(device, source, MotionEvent.AXIS_Z)
|
||||
&& hasAxis(device, source, MotionEvent.AXIS_RZ);
|
||||
if (!hasRxRy) return false;
|
||||
if (!hasZRz) return true;
|
||||
Boolean cached = layouts.get(event.getDeviceId());
|
||||
if (cached != null) return cached;
|
||||
boolean rxRyEvidence = atMinimum(device, source, event, MotionEvent.AXIS_Z, MotionEvent.AXIS_RZ)
|
||||
&& nearCentre(device, source, event, MotionEvent.AXIS_RX, MotionEvent.AXIS_RY);
|
||||
boolean zRzEvidence = atMinimum(device, source, event, MotionEvent.AXIS_RX, MotionEvent.AXIS_RY)
|
||||
&& nearCentre(device, source, event, MotionEvent.AXIS_Z, MotionEvent.AXIS_RZ);
|
||||
if (rxRyEvidence == zRzEvidence) return false;
|
||||
boolean useRxRy = rxRyEvidence;
|
||||
layouts.put(event.getDeviceId(), useRxRy);
|
||||
return useRxRy;
|
||||
}
|
||||
|
||||
static boolean signedZTriggers(MotionEvent event, InputDevice device, boolean wired, boolean rxRyStick, boolean left) {
|
||||
if (wired) return true;
|
||||
if (!rxRyStick) return false;
|
||||
int source = event.getSource();
|
||||
int signedAxis = left ? MotionEvent.AXIS_Z : MotionEvent.AXIS_RZ;
|
||||
int dedicatedAxis = left ? MotionEvent.AXIS_LTRIGGER : MotionEvent.AXIS_RTRIGGER;
|
||||
int alternateAxis = left ? MotionEvent.AXIS_BRAKE : MotionEvent.AXIS_GAS;
|
||||
return hasAxis(device, source, signedAxis)
|
||||
&& !hasAxis(device, source, dedicatedAxis, alternateAxis);
|
||||
}
|
||||
|
||||
static float triggerValue(MotionEvent event, InputDevice device, boolean wired, boolean rxRyStick, boolean left) {
|
||||
if (signedZTriggers(event, device, wired, rxRyStick, left)) {
|
||||
int axis = left ? MotionEvent.AXIS_Z : MotionEvent.AXIS_RZ;
|
||||
float value = event.getAxisValue(axis);
|
||||
if (!wired && device != null) {
|
||||
InputDevice.MotionRange range = device.getMotionRange(axis, event.getSource());
|
||||
if (range != null && range.getMax() > range.getMin()) {
|
||||
return Math.max(0f, Math.min(1f,
|
||||
(value - range.getMin()) / (range.getMax() - range.getMin())));
|
||||
}
|
||||
}
|
||||
return Math.max(0f, Math.min(1f, (value + 1f) / 2f));
|
||||
}
|
||||
int source = event.getSource();
|
||||
int axis = left ? MotionEvent.AXIS_LTRIGGER : MotionEvent.AXIS_RTRIGGER;
|
||||
int alternate = left ? MotionEvent.AXIS_BRAKE : MotionEvent.AXIS_GAS;
|
||||
if (device == null) {
|
||||
float value = event.getAxisValue(axis);
|
||||
return value != 0f ? value : event.getAxisValue(alternate);
|
||||
}
|
||||
if (hasAxis(device, source, axis)) {
|
||||
float value = event.getAxisValue(axis);
|
||||
return value != 0f ? value : event.getAxisValue(alternate);
|
||||
}
|
||||
if (hasAxis(device, source, alternate)) return event.getAxisValue(alternate);
|
||||
return 0f;
|
||||
}
|
||||
|
||||
private static float restDistance(InputDevice device, int source, MotionEvent event, int xAxis, int yAxis) {
|
||||
return (restDistance(device.getMotionRange(xAxis, source), event.getAxisValue(xAxis))
|
||||
+ restDistance(device.getMotionRange(yAxis, source), event.getAxisValue(yAxis))) / 2f;
|
||||
}
|
||||
|
||||
private static float restDistance(InputDevice.MotionRange range, float value) {
|
||||
float span = range.getMax() - range.getMin();
|
||||
if (span <= 0f) return 1f;
|
||||
return Math.abs(value - (range.getMin() + range.getMax()) / 2f) / span;
|
||||
}
|
||||
|
||||
private static boolean atMinimum(InputDevice device, int source, MotionEvent event, int xAxis, int yAxis) {
|
||||
return atMinimum(device.getMotionRange(xAxis, source), event.getAxisValue(xAxis))
|
||||
&& atMinimum(device.getMotionRange(yAxis, source), event.getAxisValue(yAxis));
|
||||
}
|
||||
|
||||
private static boolean atMinimum(InputDevice.MotionRange range, float value) {
|
||||
float span = range.getMax() - range.getMin();
|
||||
return value - range.getMin() <= span * 0.02f;
|
||||
}
|
||||
|
||||
private static boolean nearCentre(InputDevice device, int source, MotionEvent event, int xAxis, int yAxis) {
|
||||
return restDistance(device.getMotionRange(xAxis, source), event.getAxisValue(xAxis)) <= 0.1f
|
||||
&& restDistance(device.getMotionRange(yAxis, source), event.getAxisValue(yAxis)) <= 0.1f;
|
||||
}
|
||||
|
||||
public interface TouchRoute {
|
||||
boolean active();
|
||||
|
||||
@@ -1182,16 +1275,4 @@ public final class PadBridge {
|
||||
&& device.getMotionRange(MotionEvent.AXIS_RZ, source) != null;
|
||||
}
|
||||
|
||||
public static float leftTrigger(MotionEvent event, boolean wired) {
|
||||
if (wired) return Math.max(0f, Math.min(1f, (event.getAxisValue(MotionEvent.AXIS_Z) + 1f) / 2f));
|
||||
float value = event.getAxisValue(MotionEvent.AXIS_LTRIGGER);
|
||||
return value != 0f ? value : event.getAxisValue(MotionEvent.AXIS_BRAKE);
|
||||
}
|
||||
|
||||
public static float rightTrigger(MotionEvent event, boolean wired) {
|
||||
if (wired) return Math.max(0f, Math.min(1f, (event.getAxisValue(MotionEvent.AXIS_RZ) + 1f) / 2f));
|
||||
float value = event.getAxisValue(MotionEvent.AXIS_RTRIGGER);
|
||||
return value != 0f ? value : event.getAxisValue(MotionEvent.AXIS_GAS);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,6 +42,7 @@ class PadMouse(private val listener: Listener, private val clock: () -> Long = S
|
||||
private val total = Sticks()
|
||||
private val triggerAxes = HashMap<Int, Boolean>()
|
||||
private val wiredLayout = HashMap<Int, Boolean>()
|
||||
private val rightStickLayouts = HashMap<Int, Boolean>()
|
||||
private val down = HashMap<Int, MutableSet<Int>>()
|
||||
private val sent = HashMap<Int, IntArray>()
|
||||
private val held = LinkedHashMap<Int, Int>()
|
||||
@@ -87,14 +88,21 @@ class PadMouse(private val listener: Listener, private val clock: () -> Long = S
|
||||
fun onMotion(event: MotionEvent): Boolean {
|
||||
if (event.actionMasked != MotionEvent.ACTION_MOVE) return true
|
||||
val sticks = physical.getOrPut(event.deviceId) { Sticks() }
|
||||
val wired = wiredLayout.getOrPut(event.deviceId) { PadBridge.wiredXboxLayout(event) }
|
||||
val device = event.device
|
||||
val wired = wiredLayout.getOrPut(event.deviceId) { PadBridge.wiredXboxLayout(device, event.source) }
|
||||
val rxRyStick = PadBridge.rightStickUsesRxRy(event, device, rightStickLayouts)
|
||||
sticks.leftX = event.getAxisValue(MotionEvent.AXIS_X)
|
||||
sticks.leftY = event.getAxisValue(MotionEvent.AXIS_Y)
|
||||
sticks.rightX = scrollAxis(event, if (wired) MotionEvent.AXIS_RX else MotionEvent.AXIS_Z)
|
||||
sticks.rightY = scrollAxis(event, if (wired) MotionEvent.AXIS_RY else MotionEvent.AXIS_RZ)
|
||||
if (hasTriggerAxes(event)) {
|
||||
sticks.leftTrigger = PadBridge.leftTrigger(event, wired)
|
||||
sticks.rightTrigger = PadBridge.rightTrigger(event, wired)
|
||||
sticks.rightX = scrollAxis(event, if (rxRyStick) MotionEvent.AXIS_RX else MotionEvent.AXIS_Z)
|
||||
sticks.rightY = scrollAxis(event, if (rxRyStick) MotionEvent.AXIS_RY else MotionEvent.AXIS_RZ)
|
||||
val signedLeft = PadBridge.signedZTriggers(event, device, wired, rxRyStick, true)
|
||||
val signedRight = PadBridge.signedZTriggers(event, device, wired, rxRyStick, false)
|
||||
val analogTriggers = hasTriggerAxes(event)
|
||||
if (analogTriggers || signedLeft) {
|
||||
sticks.leftTrigger = PadBridge.triggerValue(event, device, wired, rxRyStick, true)
|
||||
}
|
||||
if (analogTriggers || signedRight) {
|
||||
sticks.rightTrigger = PadBridge.triggerValue(event, device, wired, rxRyStick, false)
|
||||
}
|
||||
val hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X)
|
||||
val hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y)
|
||||
@@ -129,6 +137,7 @@ class PadMouse(private val listener: Listener, private val clock: () -> Long = S
|
||||
physical.clear()
|
||||
triggerAxes.clear()
|
||||
wiredLayout.clear()
|
||||
rightStickLayouts.clear()
|
||||
touch.clear()
|
||||
down.clear()
|
||||
sent.clear()
|
||||
@@ -207,6 +216,7 @@ class PadMouse(private val listener: Listener, private val clock: () -> Long = S
|
||||
private fun hasTriggerAxes(event: android.view.InputEvent): Boolean = triggerAxes.getOrPut(event.deviceId) {
|
||||
val device = event.device ?: return@getOrPut true
|
||||
device.getMotionRange(MotionEvent.AXIS_LTRIGGER) != null || device.getMotionRange(MotionEvent.AXIS_BRAKE) != null ||
|
||||
device.getMotionRange(MotionEvent.AXIS_RTRIGGER) != null || device.getMotionRange(MotionEvent.AXIS_GAS) != null ||
|
||||
(event is MotionEvent && wiredLayout.getOrPut(event.deviceId) { PadBridge.wiredXboxLayout(event) })
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ class ScrollTouchGestures(
|
||||
private var flingY = 0f
|
||||
private var flingAt = 0L
|
||||
private var flinging = false
|
||||
var clicks = true
|
||||
|
||||
private val longPress = Runnable {
|
||||
held = true
|
||||
@@ -86,7 +87,7 @@ class ScrollTouchGestures(
|
||||
lastY = startY
|
||||
tracker = VelocityTracker.obtain().also { it.addMovement(event) }
|
||||
listener.onMove(startX, startY)
|
||||
handler.postDelayed(longPress, TouchTiming.HOLD_MS)
|
||||
if (clicks) handler.postDelayed(longPress, TouchTiming.HOLD_MS)
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
val index = event.findPointerIndex(pointerId).takeIf { it >= 0 } ?: return true
|
||||
@@ -153,6 +154,7 @@ class ScrollTouchGestures(
|
||||
|
||||
private fun click(button: Int) {
|
||||
releaseClick()
|
||||
if (!clicks) return
|
||||
listener.onButton(button, true)
|
||||
clicked = button
|
||||
handler.postDelayed(clickUp, TouchTiming.CLICK_MS)
|
||||
|
||||
@@ -40,6 +40,18 @@ enum class SecondScreenMode(val id: String, @StringRes val label: Int, val bindi
|
||||
data class SecondScreenDisplay(val id: Int, val label: String)
|
||||
|
||||
object SecondScreenDisplays {
|
||||
fun selection(selected: Int, available: List<Int>, gameRequested: Boolean): Int =
|
||||
if (selected in available || gameRequested && selected >= 0) selected else available.firstOrNull() ?: -1
|
||||
|
||||
fun selection(selected: Int, available: List<Int>, gameRequested: Boolean, save: (Int) -> Unit): Int =
|
||||
selection(selected, available, gameRequested).also { if (it != selected) save(it) }
|
||||
|
||||
fun keyboardOnPrimary(gameRequested: Boolean, selected: Int, available: List<Int>, visible: Boolean = true, taken: (Int) -> Boolean): Boolean =
|
||||
visible && gameRequested && selected >= 0 && (selected !in available || taken(selected))
|
||||
|
||||
fun routeKeyboard(steam: Boolean, enabled: Boolean, panel: Boolean, dock: Boolean, primaryFallback: Boolean): Boolean =
|
||||
steam && enabled && (panel || dock || primaryFallback)
|
||||
|
||||
fun available(displayManager: DisplayManager, primaryDisplayId: Int = Display.DEFAULT_DISPLAY): List<SecondScreenDisplay> =
|
||||
displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION)
|
||||
.asSequence()
|
||||
|
||||
@@ -178,4 +178,56 @@ class ShortcutsRelay : Service(), InputManager.InputDeviceListener {
|
||||
private companion object {
|
||||
const val KEY_TIMEOUT_MS = 200L
|
||||
}
|
||||
|
||||
// Frontends such as Cocoon treat a running player process as an open game, so the relay runs only while a screen is started.
|
||||
object Holder : android.app.Application.ActivityLifecycleCallbacks, android.content.ServiceConnection {
|
||||
private const val RELEASE_MS = 1_000L
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private var app: android.app.Application? = null
|
||||
private var started = 0
|
||||
private var bound = false
|
||||
private val release = Runnable { unbind() }
|
||||
|
||||
fun install(application: android.app.Application) {
|
||||
app?.unregisterActivityLifecycleCallbacks(this)
|
||||
handler.removeCallbacks(release)
|
||||
started = 0
|
||||
bound = false
|
||||
app = application
|
||||
application.registerActivityLifecycleCallbacks(this)
|
||||
}
|
||||
|
||||
override fun onActivityStarted(activity: android.app.Activity) {
|
||||
started++
|
||||
handler.removeCallbacks(release)
|
||||
if (!bound) bind()
|
||||
}
|
||||
|
||||
override fun onActivityStopped(activity: android.app.Activity) {
|
||||
started = (started - 1).coerceAtLeast(0)
|
||||
if (started == 0) handler.postDelayed(release, RELEASE_MS)
|
||||
}
|
||||
|
||||
private fun bind() {
|
||||
val context = app ?: return
|
||||
if (runCatching { context.packageManager.getPackageInfo(Relay.PACKAGE, 0) }.isFailure) return
|
||||
bound = runCatching {
|
||||
context.bindService(Intent(context, ShortcutsRelay::class.java), this, Context.BIND_AUTO_CREATE)
|
||||
}.getOrDefault(false)
|
||||
}
|
||||
|
||||
private fun unbind() {
|
||||
if (!bound) return
|
||||
bound = false
|
||||
runCatching { app?.unbindService(this) }
|
||||
}
|
||||
|
||||
override fun onServiceConnected(name: android.content.ComponentName?, service: IBinder?) = Unit
|
||||
override fun onServiceDisconnected(name: android.content.ComponentName?) = Unit
|
||||
override fun onActivityCreated(activity: android.app.Activity, savedInstanceState: android.os.Bundle?) = Unit
|
||||
override fun onActivityResumed(activity: android.app.Activity) = Unit
|
||||
override fun onActivityPaused(activity: android.app.Activity) = Unit
|
||||
override fun onActivitySaveInstanceState(activity: android.app.Activity, outState: android.os.Bundle) = Unit
|
||||
override fun onActivityDestroyed(activity: android.app.Activity) = Unit
|
||||
}
|
||||
}
|
||||
@@ -166,21 +166,14 @@ object SteamTouchConfig {
|
||||
|
||||
fun steamRoot(context: Context) = com.droiddeck.launcher.session.SessionPrefs.activeSteamRoot(context)
|
||||
|
||||
private fun controllerConfigs(context: Context) = File(steamRoot(context), "steamapps/common/Steam Controller Configs")
|
||||
|
||||
fun configDir(context: Context): File? {
|
||||
val base = controllerConfigs(context)
|
||||
val base = File(steamRoot(context), "steamapps/common/Steam Controller Configs")
|
||||
val account = accountId(context)
|
||||
if (account != null) File(base, "$account/config").takeIf { it.isDirectory }?.let { return it }
|
||||
return base.listFiles()?.filter { it.name.all(Char::isDigit) && File(it, "config").isDirectory }
|
||||
?.maxByOrNull { it.lastModified() }?.let { File(it, "config") }
|
||||
}
|
||||
|
||||
private fun writableConfigDir(context: Context): File? {
|
||||
val account = accountId(context) ?: return configDir(context)
|
||||
return File(controllerConfigs(context), "$account/config").apply { mkdirs() }.takeIf { it.isDirectory }
|
||||
}
|
||||
|
||||
private fun accountId(context: Context): Long? = try {
|
||||
val users = KeyValues.parse(File(steamRoot(context), "config/loginusers.vdf").readText())
|
||||
val node = users.child("users")
|
||||
@@ -204,7 +197,7 @@ object SteamTouchConfig {
|
||||
}
|
||||
return try {
|
||||
val text = file.readText()
|
||||
val kv = KeyValues.parse(text)
|
||||
val kv = KeyValues.parse(text.removePrefix(""))
|
||||
val mappings = kv.child("controller_mappings") ?: kv
|
||||
val layouts = mappings.string("touch_layout")?.let { hex -> decodeLayouts(hexToBytes(hex)) }
|
||||
Log.i(TAG, "steam touch: app $appId uses ${file.path} (${layouts?.layouts?.size ?: 0} layouts)")
|
||||
@@ -396,9 +389,8 @@ object SteamTouchConfig {
|
||||
bindings: Map<SteamTouchBindings.Ref, (SteamTouchBindings.Binding) -> SteamTouchBindings.Binding> = emptyMap(),
|
||||
options: Options? = null,
|
||||
): File? {
|
||||
val dir = writableConfigDir(context) ?: return null.also { Log.w(TAG, "steam touch: no controller config folder to save app $appId in") }
|
||||
val base = config.text ?: if (config.file == null && bindings.isEmpty()) "\"controller_mappings\"\n{\n\t\"controller_type\"\t\t\"controller_mobile_touch\"\n}\n"
|
||||
else return null.also { Log.w(TAG, "steam touch: ${config.file?.path ?: "default layout"} has no readable text to save into") }
|
||||
val dir = configDir(context) ?: return null
|
||||
val base = config.text ?: if (config.file == null && bindings.isEmpty()) "\"controller_mappings\"\n{\n\t\"controller_type\"\t\t\"controller_mobile_touch\"\n}\n" else return null
|
||||
val source = bindings.entries.fold(base) { text, (ref, change) ->
|
||||
SteamTouchBindings.rewrite(text, ref, change) ?: text
|
||||
}
|
||||
@@ -416,11 +408,11 @@ object SteamTouchConfig {
|
||||
val existing = Regex("""\n\s*"touch_layout"\s+"[0-9a-fA-F]*"""")
|
||||
val text = if (existing.containsMatchIn(source)) source.replace(existing, "\n$line")
|
||||
else source.replaceFirst(Regex("""("controller_type"\s+"controller_mobile_touch"[^\n]*)"""), "$1\n$line")
|
||||
if (!text.contains("touch_layout")) return null.also { Log.w(TAG, "steam touch: ${config.file?.path} is no controller_mobile_touch config") }
|
||||
if (!text.contains("touch_layout")) return null
|
||||
target.parentFile?.mkdirs()
|
||||
val tmp = File(target.path + ".tmp")
|
||||
tmp.writeText(text)
|
||||
if (!tmp.renameTo(target)) return null.also { Log.w(TAG, "steam touch: could not replace ${target.path}") }
|
||||
if (!tmp.renameTo(target)) return null
|
||||
selectAutosave(dir, key)
|
||||
dropDeviceEntry(dir, key)
|
||||
Log.i(TAG, "steam touch: saved layouts ${sets.keys} for app $appId to ${target.path}")
|
||||
@@ -438,13 +430,12 @@ object SteamTouchConfig {
|
||||
|
||||
private fun selectAutosave(dir: File, key: String) {
|
||||
val file = File(dir, CONFIGSET)
|
||||
val root = file.takeIf { it.isFile }?.readText()?.let(KeyValues::parse)?.takeIf { it.child("controller_config") != null }
|
||||
?: KeyValues.Node(mutableListOf("controller_config" to KeyValues.Node()))
|
||||
val config = root.child("controller_config") ?: return
|
||||
val entry = key to KeyValues.Node(mutableListOf("autosave" to "1"))
|
||||
val at = config.entries.indexOfFirst { it.first.equals(key, true) && it.second is KeyValues.Node }
|
||||
if (at >= 0) config.entries[at] = entry else config.entries += entry
|
||||
File(file.path + ".tmp").apply { writeText(KeyValues.write(root)) }.renameTo(file)
|
||||
val text = if (file.isFile) file.readText() else "\"controller_config\"\n{\n}\n"
|
||||
val entry = "\t\"$key\"\n\t{\n\t\t\"autosave\"\t\t\"1\"\n\t}"
|
||||
val block = Regex("""\n\s*"${Regex.escape(key)}"\s*\{[^}]*\}""", RegexOption.IGNORE_CASE)
|
||||
val next = if (block.containsMatchIn(text)) text.replace(block) { "\n$entry" }
|
||||
else text.substring(0, text.lastIndexOf('}')).trimEnd() + "\n$entry\n}\n"
|
||||
File(file.path + ".tmp").apply { writeText(next) }.renameTo(file)
|
||||
}
|
||||
|
||||
|
||||
@@ -602,48 +593,34 @@ class KeyValues private constructor() {
|
||||
fun string(key: String): String? = entries.firstOrNull { it.first.equals(key, true) && it.second is String }?.second as String?
|
||||
}
|
||||
|
||||
private class Token(val text: String, val quoted: Boolean) {
|
||||
val opens get() = !quoted && text == "{"
|
||||
val closes get() = !quoted && text == "}"
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun write(node: Node): String = write(node, "")
|
||||
|
||||
private fun write(node: Node, indent: String): String = node.entries.joinToString("") { (key, value) ->
|
||||
if (value is Node) "$indent\"${escape(key)}\"\n$indent{\n${write(value, "$indent\t")}$indent}\n"
|
||||
else "$indent\"${escape(key)}\"\t\t\"${escape(value.toString())}\"\n"
|
||||
}
|
||||
|
||||
private fun escape(text: String) = text.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n").replace("\t", "\\t")
|
||||
|
||||
fun parse(text: String): Node {
|
||||
val tokens = tokenize(text.removePrefix("\uFEFF"))
|
||||
val tokens = tokenize(text)
|
||||
var i = 0
|
||||
fun node(): Node {
|
||||
val n = Node()
|
||||
while (i < tokens.size) {
|
||||
val t = tokens[i++]
|
||||
if (t.closes) return n
|
||||
if (t.opens) continue
|
||||
if (t == "}" ) return n
|
||||
if (t == "{") continue
|
||||
if (i >= tokens.size) break
|
||||
val next = tokens[i]
|
||||
if (next.opens) { i++; n.entries += t.text to node() } else { i++; n.entries += t.text to next.text }
|
||||
if (next == "{") { i++; n.entries += t to node() } else { i++; n.entries += t to next }
|
||||
}
|
||||
return n
|
||||
}
|
||||
return node()
|
||||
}
|
||||
|
||||
private fun tokenize(text: String): List<Token> {
|
||||
val out = mutableListOf<Token>()
|
||||
private fun tokenize(text: String): List<String> {
|
||||
val out = mutableListOf<String>()
|
||||
var i = 0
|
||||
while (i < text.length) {
|
||||
val c = text[i]
|
||||
when {
|
||||
c.isWhitespace() -> i++
|
||||
c == '/' && i + 1 < text.length && text[i + 1] == '/' -> while (i < text.length && text[i] != '\n') i++
|
||||
c == '{' || c == '}' -> { out += Token(c.toString(), false); i++ }
|
||||
c == '{' || c == '}' -> { out += c.toString(); i++ }
|
||||
c == '"' -> {
|
||||
val sb = StringBuilder()
|
||||
i++
|
||||
@@ -655,13 +632,13 @@ class KeyValues private constructor() {
|
||||
i++
|
||||
}
|
||||
i++
|
||||
out += Token(sb.toString(), true)
|
||||
out += sb.toString()
|
||||
}
|
||||
c == '[' -> { while (i < text.length && text[i] != ']') i++; i++ }
|
||||
else -> {
|
||||
val start = i
|
||||
while (i < text.length && !text[i].isWhitespace() && text[i] != '{' && text[i] != '}' && text[i] != '"') i++
|
||||
out += Token(text.substring(start, i), false)
|
||||
out += text.substring(start, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@ class TouchpadGestures(
|
||||
var bounds: android.graphics.RectF = android.graphics.RectF(0f, 0f, 1f, 1f)
|
||||
var sensitivity = 1.15f
|
||||
var desktop = false
|
||||
var clicks = true
|
||||
set(value) {
|
||||
if (field != value) lastTapAt = 0L
|
||||
field = value
|
||||
}
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private var lastX = 0f
|
||||
@@ -50,12 +55,17 @@ class TouchpadGestures(
|
||||
held = true
|
||||
dragging = true
|
||||
listener.onLongPress()
|
||||
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
|
||||
press(PointerGestures.BTN_LEFT)
|
||||
}
|
||||
private val clickUp = Runnable { releaseClick() }
|
||||
|
||||
private fun press(button: Int) {
|
||||
if (clicks) listener.onButton(button, true, x, y)
|
||||
}
|
||||
|
||||
private fun click(button: Int) {
|
||||
releaseClick()
|
||||
if (!clicks) return
|
||||
listener.onButton(button, true, x, y)
|
||||
clicked = button
|
||||
handler.postDelayed(clickUp, TouchTiming.CLICK_MS)
|
||||
@@ -108,12 +118,12 @@ class TouchpadGestures(
|
||||
travelled = 0f; held = false; twoFingers = false; scrolled = false; secondWasTap = false
|
||||
fingers = 1; pinching = false
|
||||
anchorId = event.getPointerId(0); moverId = -1; holdDrag = false; scrollLocked = false
|
||||
if (event.eventTime - lastTapAt < TouchTiming.DOUBLE_TAP_MS) {
|
||||
if (clicks && event.eventTime - lastTapAt < TouchTiming.DOUBLE_TAP_MS) {
|
||||
dragging = true
|
||||
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
|
||||
press(PointerGestures.BTN_LEFT)
|
||||
} else {
|
||||
dragging = false
|
||||
handler.postDelayed(longPress, TouchTiming.HOLD_MS)
|
||||
if (clicks) handler.postDelayed(longPress, TouchTiming.HOLD_MS)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -153,7 +163,7 @@ class TouchpadGestures(
|
||||
secondWasTap = false
|
||||
if (!dragging) {
|
||||
dragging = true
|
||||
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
|
||||
press(PointerGestures.BTN_LEFT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,12 +218,15 @@ object BwrapSpawner {
|
||||
private fun runtimeLib(rootfs: String, name: String): File? =
|
||||
LIB_DIRS.map { File(rootfs, "$it/$name") }.firstOrNull { it.exists() }
|
||||
|
||||
private fun gpu(rootfs: String, root: File, env: MutableMap<String, String>): List<Bind>? {
|
||||
internal fun gpu(
|
||||
rootfs: String, root: File, env: MutableMap<String, String>,
|
||||
kgslAvailable: Boolean = File("/dev/kgsl-3d0").exists(),
|
||||
): List<Bind>? {
|
||||
env["VKBRIDGE_SOCKET"]?.let { sock -> if (File(sock).exists()) return bridgeGpu(rootfs, root, env, sock) }
|
||||
val driver = runtimeLib(rootfs, "libvulkan_freedreno.so")
|
||||
if (driver == null || !File("/dev/kgsl-3d0").exists()) return null
|
||||
if (driver == null || !kgslAvailable) return null
|
||||
if (env.containsKey("VK_ICD_FILENAMES") || env.containsKey("VK_DRIVER_FILES")) return null
|
||||
if (env["BL_DESKTOP"] == "1" && env["GAMESCOPE_WAYLAND_DISPLAY"] == null) return null
|
||||
if (env["LIBGL_ALWAYS_SOFTWARE"] == "1" && env["GAMESCOPE_WAYLAND_DISPLAY"] == null) return null
|
||||
val binds = arrayListOf(Bind(driver.canonicalPath, "$GPU_DIR/libvulkan_freedreno.so"))
|
||||
for (name in GPU_LIBS) {
|
||||
val f = runtimeLib(rootfs, name) ?: continue
|
||||
|
||||
@@ -21,6 +21,10 @@ object LegacyNames {
|
||||
"etc/bannerlator-network.json" to "etc/droiddeck-network.json",
|
||||
"etc/bannerlator-wifi-scan-request" to "etc/droiddeck-wifi-scan-request",
|
||||
)
|
||||
private val RETIRED_FILES = listOf("libblsession.so", "libblfastpath.so", "libblaudit.so").map { "usr/local/lib/$it" } +
|
||||
listOf("x86_64", "i386").map { "usr/local/lib/droiddeck-fex/$it/libblsession.so" }
|
||||
private const val LEGACY_MARKER = ".bl-"
|
||||
private val QUEUED_MARKERS = setOf(".bl-proton-extra", ".bl-steam-urls")
|
||||
private val MENU_REWRITES = listOf(
|
||||
Triple("usr/local/share/applications", "/usr/local/bin/bannerlator-", "/usr/local/bin/droiddeck-"),
|
||||
Triple("usr/share/applications", "Exec=env APPIMAGE_EXTRACT_AND_RUN=1 /opt/appimages/",
|
||||
@@ -38,6 +42,20 @@ object LegacyNames {
|
||||
fun migrateRootfs(root: File) {
|
||||
migrateEtc(root)
|
||||
for ((old, new) in MOVED_FILES) move(File(root, old), File(root, new))
|
||||
for (path in RETIRED_FILES) File(root, path).delete()
|
||||
File(root, "root").listFiles { f -> f.name.startsWith(LEGACY_MARKER) }?.forEach {
|
||||
val target = File(it.parentFile, ".dd-" + it.name.removePrefix(LEGACY_MARKER))
|
||||
if (it.name in QUEUED_MARKERS && it.isFile && !isLink(it) && target.isFile && !isLink(target)) {
|
||||
val queued = it.readText()
|
||||
if (queued.isNotBlank()) {
|
||||
val separator = if (target.length() > 0 && !target.readText().endsWith("\n")) "\n" else ""
|
||||
target.appendText(separator + if (queued.endsWith("\n")) queued else queued + "\n")
|
||||
}
|
||||
FileUtils.delete(it)
|
||||
} else {
|
||||
move(it, target)
|
||||
}
|
||||
}
|
||||
linkScripts(root)
|
||||
rewriteMenuEntries(root)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.security.MessageDigest
|
||||
|
||||
object ProotFastPath {
|
||||
private const val TAG = "ProotFastPath"
|
||||
const val LIBRARY = "/usr/local/lib/libblfastpath.so"
|
||||
const val LIBRARY = "/usr/local/lib/libddfastpath.so"
|
||||
const val MAX_BINDS = 256
|
||||
|
||||
fun allows(preference: Boolean, noSeccomp: Boolean, source: String, nativeUserland: Boolean = false): Boolean =
|
||||
|
||||
@@ -315,11 +315,11 @@ object BottomDesktop {
|
||||
main.post { if (generation == guestGeneration) watchIme(imeDir) }
|
||||
val binds = LinuxRuntime.binds(context, current.sessionRoot, runtime, Environment.getExternalStorageDirectory(), current.binds)
|
||||
val guest = ArrayList(current.guest).apply {
|
||||
add("BL_WIDTH=$width")
|
||||
add("BL_HEIGHT=$height")
|
||||
add("BL_DEBUG_DIR=" + dir.path)
|
||||
add("BL_TOP_SESSION=" + SessionState.mode)
|
||||
add("BL_IME_DIR=" + imeDir.path)
|
||||
add("DD_WIDTH=$width")
|
||||
add("DD_HEIGHT=$height")
|
||||
add("DD_DEBUG_DIR=" + dir.path)
|
||||
add("DD_TOP_SESSION=" + SessionState.mode)
|
||||
add("DD_IME_DIR=" + imeDir.path)
|
||||
add(SCRIPT)
|
||||
}
|
||||
val command = if (current.nativeUserland) {
|
||||
|
||||
@@ -282,6 +282,8 @@ object ComponentsManager {
|
||||
if (parts.size > 1) parts[1] else parts.firstOrNull()?.ifEmpty { null } ?: "unknown"
|
||||
}.getOrDefault("unknown")
|
||||
|
||||
internal fun isProtonTree(dir: File): Boolean = File(dir, WINE).isDirectory && File(dir, "proton").isFile
|
||||
|
||||
fun protons(context: Context): List<Proton> {
|
||||
val found = LinkedHashMap<String, Proton>()
|
||||
val bases = listOf(File(steam(context), "compatibilitytools.d") to false) +
|
||||
@@ -290,7 +292,7 @@ object ComponentsManager {
|
||||
for ((base, valve) in bases) {
|
||||
val entries = base.listFiles()?.sortedBy { it.name } ?: continue
|
||||
for (dir in entries) {
|
||||
if (!File(dir, WINE).isDirectory || !File(dir, "proton").isFile) continue
|
||||
if (!isProtonTree(dir)) continue
|
||||
val real = runCatching { dir.canonicalPath }.getOrDefault(dir.path)
|
||||
if (found.containsKey(real)) continue
|
||||
val guest = if (dir.absolutePath.startsWith(rootPath)) dir.absolutePath.removePrefix(rootPath) else dir.absolutePath
|
||||
@@ -900,15 +902,26 @@ object ComponentsManager {
|
||||
}
|
||||
}
|
||||
|
||||
fun forgetProton(context: Context, dirName: String) {
|
||||
synchronized(lock) {
|
||||
val id = safeName(dirName)
|
||||
if (protons(context).any { it.id == id }) return
|
||||
val state = loadState(context)
|
||||
val selected = listOf("active", "queued").map { state.sub(it).remove(id) != null }.any { it }
|
||||
if (selected && runCatching { saveState(context, state) }.onFailure { Log.w(TAG, "forget $id", it) }.isFailure) return
|
||||
File(originalsDir(context), id).deleteRecursively()
|
||||
}
|
||||
fun forgetProton(context: Context, dirName: String): Boolean = synchronized(lock) {
|
||||
val id = safeName(dirName)
|
||||
if (protons(context).any { it.id == id }) return true
|
||||
val state = loadState(context)
|
||||
val selected = listOf("active", "queued").map { state.sub(it).remove(id) != null }.any { it }
|
||||
val published = File(launchDir(context), "desired.tsv")
|
||||
val listed = published.takeIf { it.isFile }
|
||||
?.useLines { rows -> rows.any { it.split('\t').getOrNull(1) == dirName } } == true
|
||||
if ((selected || listed) && runCatching { saveState(context, state) }.onFailure { Log.w(TAG, "forget $id", it) }.isFailure) return false
|
||||
val originals = File(originalsDir(context), id)
|
||||
val store = File(launchDir(context), "store")
|
||||
val used = published.takeIf { it.isFile }?.useLines { rows ->
|
||||
rows.mapNotNull { it.substringAfterLast('\t').substringAfter("/store/", "").substringBefore('/').ifEmpty { null } }.toSet()
|
||||
}.orEmpty()
|
||||
val unpacked = originals.listFiles().orEmpty().flatMap { version ->
|
||||
version.listFiles().orEmpty().map { File(store, "original-$id-${version.name}-${it.name.removeSuffix(".wcp")}") }
|
||||
}.filter { it.name !in used }
|
||||
if (unpacked.any { File(it, ".complete").delete(); !it.deleteRecursively() && it.exists() }) return false
|
||||
originals.deleteRecursively()
|
||||
true
|
||||
}
|
||||
|
||||
private fun storePackage(context: Context, part: File, dest: File) {
|
||||
|
||||
@@ -708,10 +708,10 @@ internal object EnhancedSessionLogShare {
|
||||
}
|
||||
val logs = LinuxRuntime.logDir(context)
|
||||
for ((name, root) in listOf(SessionLogShare.STORES_DIR to File(logs, SessionLogShare.STORES_DIR), SessionPaths.TOOLS_DIR to File(logs, SessionPaths.TOOLS_DIR))) {
|
||||
val scan = directFiles(root, remaining(maxFiles, out.size))
|
||||
val scan = directFiles(root, STORE_LOG_SCAN)
|
||||
truncated = truncated || scan.truncated
|
||||
partial = partial || scan.partial
|
||||
scan.files.asSequence().filter { recent(it) }
|
||||
scan.files.filter { recent(it) }.sortedByDescending { it.lastModified() }.take(remaining(maxFiles, out.size))
|
||||
.forEach { add(it, root, "$name/${it.name}", name) }
|
||||
}
|
||||
if (legacy) {
|
||||
@@ -965,6 +965,7 @@ internal object EnhancedSessionLogShare {
|
||||
"events.jsonl", "memory.csv", "capture.json", "crash.log",
|
||||
)
|
||||
private const val RECENT_MILLIS = 7L * 24 * 60 * 60 * 1000
|
||||
private const val STORE_LOG_SCAN = 512
|
||||
private const val COPY_BUFFER_BYTES = 64 * 1024
|
||||
private const val TRACE_SCAN_BYTES = 16L * 1024 * 1024
|
||||
private const val LEGACY_LOG_MAX_BYTES = 8L * 1024 * 1024
|
||||
|
||||
@@ -440,7 +440,7 @@ object EsyncPacks {
|
||||
|
||||
fun enabled(context: Context): Boolean = SessionPrefs.syncFallback(context) || try {
|
||||
GameEnvironmentStore.read(context).let { config ->
|
||||
(listOf(config.shared) + config.games.values).any { it["BL_SYNC_FALLBACK"] == "1" }
|
||||
(listOf(config.shared) + config.games.values).any { it["DD_SYNC_FALLBACK"] == "1" }
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
false
|
||||
|
||||
@@ -0,0 +1,412 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.os.StatFs
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.core.Downloader
|
||||
import com.droiddeck.launcher.core.Hashes
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.InputStream
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.attribute.PosixFilePermission
|
||||
import java.security.DigestOutputStream
|
||||
import java.security.MessageDigest
|
||||
import java.util.zip.ZipFile
|
||||
import org.apache.commons.compress.archivers.sevenz.SevenZFile
|
||||
import org.apache.commons.compress.archivers.zip.ZipFile as CommonsZipFile
|
||||
import kotlin.io.path.ExperimentalPathApi
|
||||
import kotlin.io.path.deleteRecursively
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
object ExperimentalProtons {
|
||||
private const val TAG = "ExperimentalProtons"
|
||||
const val PREFIX = "Experimental-"
|
||||
private const val MARKER = ".droiddeck-experimental.json"
|
||||
private const val STAGING = ".droiddeck-experimental"
|
||||
private const val BACKUPS = ".droiddeck-experimental-old"
|
||||
private const val INCOMING = ".droiddeck-experimental-new"
|
||||
private const val REMOVED = ".droiddeck-experimental-gone"
|
||||
private const val GUEST_TOOLS = "/root/.local/share/Steam/compatibilitytools.d"
|
||||
private const val NEED_BYTES = 4L * 1024 * 1024 * 1024
|
||||
private const val USER_SETTINGS = "user_settings.py"
|
||||
internal val TARBALL = Regex("(?i)\\.tar(\\.(gz|xz|zst|bz2))?$")
|
||||
internal val FOREIGN_ARCH = Regex("(?i)(^|[^a-z0-9])(x86|x64|amd64|i[3-6]86)([^a-z0-9]|$)")
|
||||
private val DOWNLOAD_PREFIX = "droiddeck-"
|
||||
|
||||
data class Installed(val dir: String, val label: String, val source: String, val releaseTag: String? = null)
|
||||
data class Release(val tag: String, val asset: String, val url: String, val sha512: String?, val size: Long, val name: String = tag)
|
||||
enum class ArchiveType { ZIP, SEVEN_Z, TAR, UNKNOWN }
|
||||
|
||||
private fun toolsDir(context: Context) = File(LinuxRuntime.rootDir(context), GUEST_TOOLS.removePrefix("/"))
|
||||
|
||||
fun installed(context: Context): List<Installed> =
|
||||
toolsDir(context).listFiles()
|
||||
?.filter { it.isDirectory && File(it, MARKER).isFile }
|
||||
?.map { dir ->
|
||||
val info = runCatching { JSONObject(File(dir, MARKER).readText()) }.getOrDefault(JSONObject())
|
||||
Installed(dir.name, info.optString("label").ifEmpty { dir.name }, info.optString("source"), info.optString("releaseTag").ifEmpty { null })
|
||||
}
|
||||
?.sortedBy { it.dir }
|
||||
?: emptyList()
|
||||
|
||||
fun remove(context: Context, dir: String): Boolean {
|
||||
val tools = toolsDir(context)
|
||||
val target = File(tools, dir)
|
||||
if (!File(target, MARKER).isFile) return false
|
||||
val doomed = File(File(tools, REMOVED).apply { mkdirs() }, dir)
|
||||
if (!deleteTree(doomed)) return false
|
||||
val detached = synchronized(SessionState.startLock) { !SessionState.running && target.renameTo(doomed) }
|
||||
if (!detached) return false
|
||||
ComponentsManager.forgetProton(context, dir)
|
||||
deleteTree(doomed)
|
||||
deleteTree(File(File(tools, BACKUPS), dir))
|
||||
deleteTree(File(File(tools, INCOMING), dir))
|
||||
return true
|
||||
}
|
||||
|
||||
internal fun dirName(tree: String, label: String?): String {
|
||||
val base = ComponentsManager.safeName(tree)
|
||||
val tag = label?.let(ComponentsManager::safeName)?.takeIf { it != "unnamed" && !base.contains(it, ignoreCase = true) }
|
||||
return PREFIX + base + (tag?.let { "-$it" } ?: "")
|
||||
}
|
||||
|
||||
fun refresh(context: Context): List<Release>? {
|
||||
val tool = ProtonExtras.tools.first { it.id == ProtonExtras.OWN }
|
||||
val fetched = ProtonExtras.releasesForRemoval(tool) ?: return null
|
||||
val assets = ProtonExtras.assets(tool, fetched.releases, prerelease = true)
|
||||
val rows = assets.map { Release(it.tag, it.name, it.url, it.sha512, it.size, it.releaseName) }.distinctBy { it.tag }
|
||||
if (!SessionState.running) {
|
||||
reconcile(context, fetched)
|
||||
if (fetched.complete) removeStaleDownloads(context, fetched.releases.tags())
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
private fun JSONArray.tags(): Set<String> = (0 until length()).mapNotNull { optJSONObject(it)?.optString("tag_name")?.takeIf(String::isNotEmpty) }.toSet()
|
||||
|
||||
internal fun removeStaleDownloads(context: Context, availableTags: Set<String>) {
|
||||
val downloads = File(context.filesDir, "proton-downloads")
|
||||
downloads.listFiles()?.filter { file ->
|
||||
file.isFile && file.name.startsWith(DOWNLOAD_PREFIX) && availableTags.none { tag -> file.name.startsWith("$DOWNLOAD_PREFIX${ComponentsManager.safeName(tag)}-") }
|
||||
}?.forEach { it.delete() }
|
||||
}
|
||||
|
||||
internal fun available(releases: List<Release>, installed: List<Installed>): List<Release> =
|
||||
releases.filter { release -> installed.none { it.releaseTag == release.tag } }
|
||||
|
||||
internal fun shouldRemove(installedReleaseTag: String?, fetched: ProtonExtras.ReleaseFetch, gone: (String) -> Boolean): Boolean {
|
||||
val tag = installedReleaseTag ?: return false
|
||||
val release = (0 until fetched.releases.length()).asSequence()
|
||||
.mapNotNull { fetched.releases.optJSONObject(it) }
|
||||
.firstOrNull { it.optString("tag_name") == tag }
|
||||
return if (release != null) !release.optBoolean("prerelease", false) else fetched.complete && gone(tag)
|
||||
}
|
||||
|
||||
internal fun reconcile(
|
||||
context: Context,
|
||||
fetched: ProtonExtras.ReleaseFetch,
|
||||
gone: (String) -> Boolean = { tag -> ProtonExtras.releaseGone(ProtonExtras.tools.first { it.id == ProtonExtras.OWN }, tag) },
|
||||
) {
|
||||
for (build in installed(context)) {
|
||||
if (SessionState.running) return
|
||||
if (shouldRemove(build.releaseTag, fetched, gone)) remove(context, build.dir)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun compatVdf(name: String): String = """"compatibilitytools"
|
||||
{
|
||||
"compat_tools"
|
||||
{
|
||||
"$name"
|
||||
{
|
||||
"install_path" "."
|
||||
"display_name" "$name"
|
||||
"from_oslist" "windows"
|
||||
"to_oslist" "linux"
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
fun installFromFile(context: Context, file: File, onProgress: (String, Int) -> Unit): String? {
|
||||
preflight(context)?.let { return it }
|
||||
if (StatFs(LinuxRuntime.rootDir(context).path).availableBytes < NEED_BYTES + file.length()) {
|
||||
return context.getString(R.string.xproton_no_space)
|
||||
}
|
||||
return install(context, file, fileLabel(file.name), file.name, null, onProgress, false)
|
||||
}
|
||||
|
||||
internal fun fileLabel(name: String): String =
|
||||
if (TARBALL.containsMatchIn(name)) name.replace(TARBALL, "") else name.substringBeforeLast('.')
|
||||
|
||||
fun installRelease(context: Context, release: Release, onProgress: (String, Int) -> Unit): String? {
|
||||
preflight(context)?.let { return it }
|
||||
val downloads = File(context.filesDir, "proton-downloads").apply { mkdirs() }
|
||||
val archive = File(downloads, "droiddeck-${ComponentsManager.safeName(release.tag)}-${release.asset}")
|
||||
if (release.size > 0 && archive.length() > release.size) archive.delete()
|
||||
val missing = (release.size - archive.length()).coerceAtLeast(0L)
|
||||
val copyBytes = if (sameFileStore(archive, toolsDir(context))) 0L else release.size
|
||||
if (StatFs(LinuxRuntime.rootDir(context).path).availableBytes < NEED_BYTES + missing + copyBytes) return context.getString(R.string.xproton_no_space)
|
||||
val title = context.getString(R.string.pextra_downloading, "Proton", release.tag)
|
||||
onProgress(title, 0)
|
||||
if (!Downloader.downloadFile(release.url, archive, true) { fraction ->
|
||||
onProgress(title, if (fraction < 0) -1 else (fraction * 100f).toInt().coerceIn(0, 100))
|
||||
}) return context.getString(R.string.pextra_download_failed)
|
||||
if (release.size > 0 && archive.length() != release.size) return context.getString(R.string.pextra_incomplete)
|
||||
if (release.sha512 != null) {
|
||||
val expected = Downloader.downloadDirect(release.sha512)?.let(::checksumIn)
|
||||
?: return context.getString(R.string.pextra_checksum_unreadable)
|
||||
if (!expected.equals(Hashes.sha512(archive), true)) {
|
||||
archive.delete()
|
||||
return context.getString(R.string.pextra_checksum_mismatch)
|
||||
}
|
||||
}
|
||||
return try { install(context, archive, release.tag, release.tag, release.tag, onProgress, true) }
|
||||
finally { archive.delete() }
|
||||
}
|
||||
|
||||
private fun sameFileStore(file: File, directory: File): Boolean = runCatching {
|
||||
directory.mkdirs()
|
||||
Files.getFileStore((file.takeIf(File::exists) ?: file.parentFile).toPath()) == Files.getFileStore(directory.toPath())
|
||||
}.getOrDefault(false)
|
||||
|
||||
private fun preflight(context: Context): String? = when {
|
||||
SessionState.running -> context.getString(R.string.pextra_stop_session)
|
||||
!LinuxRuntime.isInstalled(context) -> context.getString(R.string.user_apps_runtime_required)
|
||||
else -> null
|
||||
}
|
||||
|
||||
private fun install(context: Context, archive: File, label: String, source: String, releaseTag: String?, onProgress: (String, Int) -> Unit, downloaded: Boolean): String? {
|
||||
val tools = toolsDir(context).apply { mkdirs() }
|
||||
val staging = File(tools, STAGING)
|
||||
val forget = { name: String -> ComponentsManager.forgetProton(context, name) }
|
||||
restoreInterrupted(tools, forget)
|
||||
deleteTree(staging)
|
||||
staging.mkdirs()
|
||||
try {
|
||||
LinuxRuntime.writeAccounts(context)
|
||||
SessionFiles.stage(context, LinuxRuntime.rootDir(context))
|
||||
onProgress(context.getString(R.string.xproton_unpacking), -1)
|
||||
val unpacked = File(staging, "unpacked").apply { mkdirs() }
|
||||
val type = archiveType(archive)
|
||||
if (SessionState.running) return context.getString(R.string.pextra_session_started)
|
||||
|
||||
onProgress(context.getString(R.string.xproton_unpacking), -1)
|
||||
when (type) {
|
||||
ArchiveType.ZIP -> {
|
||||
val tarball = extractTarball(archive, staging)
|
||||
if (tarball == null) {
|
||||
extractDirect(archive, unpacked, ArchiveType.ZIP)
|
||||
} else {
|
||||
val status = runGuest(context, listOf("tar", "-xf", "$GUEST_TOOLS/$STAGING/${tarball.name}", "-C", "$GUEST_TOOLS/$STAGING/unpacked"))
|
||||
tarball.delete()
|
||||
if (status != 0) return context.getString(R.string.xproton_untar_failed, status)
|
||||
}
|
||||
}
|
||||
ArchiveType.SEVEN_Z -> extractDirect(archive, unpacked, ArchiveType.SEVEN_Z)
|
||||
ArchiveType.TAR -> {
|
||||
val stagedArchive = File(staging, archive.name)
|
||||
if (!archive.canonicalFile.equals(stagedArchive.canonicalFile) && !(downloaded && archive.renameTo(stagedArchive))) {
|
||||
archive.copyTo(stagedArchive, overwrite = true)
|
||||
}
|
||||
val status = runGuest(context, listOf("tar", "-xf", "$GUEST_TOOLS/$STAGING/${stagedArchive.name}", "-C", "$GUEST_TOOLS/$STAGING/unpacked"))
|
||||
if (status != 0) return context.getString(R.string.xproton_untar_failed, status)
|
||||
}
|
||||
ArchiveType.UNKNOWN -> return context.getString(R.string.xproton_archive_invalid)
|
||||
}
|
||||
|
||||
val tree = buildTree(unpacked) ?: return context.getString(R.string.xproton_no_tree)
|
||||
val name = dirName(tree.name, label)
|
||||
ownFile(tree, "compatibilitytool.vdf").writeText(compatVdf(name))
|
||||
ownFile(tree, MARKER).writeText(
|
||||
JSONObject().put("label", name).put("source", source).putOpt("releaseTag", releaseTag).put("at", System.currentTimeMillis() / 1000).toString(),
|
||||
)
|
||||
val final = File(tools, name)
|
||||
val settings = File(final, USER_SETTINGS)
|
||||
if (Files.isRegularFile(settings.toPath(), java.nio.file.LinkOption.NOFOLLOW_LINKS)) {
|
||||
settings.copyTo(ownFile(tree, USER_SETTINGS))
|
||||
}
|
||||
if (!placeTree(tree, tools, name, forget)) return context.getString(R.string.xproton_place_failed)
|
||||
|
||||
onProgress(context.getString(R.string.pextra_installing, name), -1)
|
||||
runGuest(context, listOf("steam-compatibility", "/root/.local/share/Steam"))
|
||||
return null
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "install $source", e)
|
||||
return if (e is UnsafeArchiveException) context.getString(R.string.xproton_archive_unsafe) else context.getString(R.string.xproton_archive_invalid)
|
||||
} finally {
|
||||
deleteTree(staging)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun buildTree(unpacked: File): File? {
|
||||
val root = unpacked.canonicalFile
|
||||
return unpacked.listFiles()?.sortedBy { it.name }?.firstOrNull {
|
||||
!Files.isSymbolicLink(it.toPath()) && it.isDirectory && it.canonicalFile.parentFile == root &&
|
||||
Files.isRegularFile(File(it, "toolmanifest.vdf").toPath(), java.nio.file.LinkOption.NOFOLLOW_LINKS) &&
|
||||
ComponentsManager.isProtonTree(it)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
internal fun deleteTree(dir: File): Boolean =
|
||||
runCatching { dir.toPath().deleteRecursively() }.onFailure { Log.w(TAG, "delete $dir", it) }.isSuccess && !Files.exists(dir.toPath(), java.nio.file.LinkOption.NOFOLLOW_LINKS)
|
||||
|
||||
internal fun ownFile(tree: File, name: String): File {
|
||||
val file = File(tree, name)
|
||||
Files.deleteIfExists(file.toPath())
|
||||
return file
|
||||
}
|
||||
|
||||
internal fun placeTree(tree: File, tools: File, name: String, forget: (String) -> Boolean): Boolean {
|
||||
val incoming = File(File(tools, INCOMING).apply { mkdirs() }, name)
|
||||
if (!deleteTree(incoming) || !tree.renameTo(incoming)) return false
|
||||
return finishPlacing(tools, name, forget)
|
||||
}
|
||||
|
||||
private fun finishPlacing(tools: File, name: String, forget: (String) -> Boolean): Boolean {
|
||||
val incoming = File(File(tools, INCOMING), name)
|
||||
val final = File(tools, name)
|
||||
val backup = File(File(tools, BACKUPS).apply { mkdirs() }, name)
|
||||
val moved = !final.exists() || (deleteTree(backup) && final.renameTo(backup))
|
||||
val placed = moved && (!backup.exists() || forget(name)) && incoming.renameTo(final)
|
||||
if (!placed) {
|
||||
if (!final.exists()) backup.renameTo(final)
|
||||
deleteTree(incoming)
|
||||
}
|
||||
if (final.exists()) deleteTree(backup)
|
||||
return placed
|
||||
}
|
||||
|
||||
internal fun restoreInterrupted(tools: File, forget: (String) -> Boolean) {
|
||||
deleteTree(File(tools, REMOVED))
|
||||
File(tools, INCOMING).listFiles()?.forEach { finishPlacing(tools, it.name, forget) }
|
||||
File(tools, BACKUPS).listFiles()?.forEach { if (File(tools, it.name).exists()) deleteTree(it) else it.renameTo(File(tools, it.name)) }
|
||||
}
|
||||
|
||||
internal fun archiveType(file: File): ArchiveType {
|
||||
val head = runCatching { file.inputStream().use { ByteArray(300).also { b -> it.read(b) } } }.getOrNull() ?: return ArchiveType.UNKNOWN
|
||||
fun at(i: Int, vararg bytes: Int) = bytes.indices.all { head.getOrNull(i + it) == bytes[it].toByte() }
|
||||
return when {
|
||||
at(0, 0x50, 0x4B) -> ArchiveType.ZIP
|
||||
at(0, 0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C) -> ArchiveType.SEVEN_Z
|
||||
at(0, 0x1F, 0x8B) || at(0, 0x42, 0x5A, 0x68) || at(0, 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00) || at(0, 0x28, 0xB5, 0x2F, 0xFD) || at(257, 0x75, 0x73, 0x74, 0x61, 0x72) -> ArchiveType.TAR
|
||||
else -> ArchiveType.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractTarball(zip: File, into: File): File? = ZipFile(zip).use { z ->
|
||||
val entries = z.entries().toList().filter { !it.isDirectory }
|
||||
val entry = entries.filter { TARBALL.containsMatchIn(it.name) }.maxByOrNull { it.size } ?: return null
|
||||
val name = File(entry.name).name
|
||||
val sums = checksumEntry(entries.map { it.name }, name)?.let { checksumName -> entries.first { it.name == checksumName } }
|
||||
val expected = sums?.let { e ->
|
||||
z.getInputStream(e).use { checksumIn(it.readBytes().decodeToString()) }
|
||||
?: throw IllegalStateException("${File(e.name).name} holds no SHA-512 checksum")
|
||||
}
|
||||
val out = File(into, name)
|
||||
val digest = MessageDigest.getInstance("SHA-512")
|
||||
z.getInputStream(entry).use { input -> DigestOutputStream(FileOutputStream(out), digest).use { input.copyTo(it, 1 shl 16) } }
|
||||
if (expected != null && !expected.equals(digest.digest().joinToString("") { "%02x".format(it) }, ignoreCase = true)) {
|
||||
out.delete()
|
||||
throw IllegalStateException("Checksum mismatch in $name")
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
internal class UnsafeArchiveException : Exception()
|
||||
|
||||
internal fun extractDirect(archive: File, into: File, type: ArchiveType) {
|
||||
val root = into.toPath().toAbsolutePath().normalize()
|
||||
fun target(name: String): File {
|
||||
val clean = name.replace('\\', '/')
|
||||
val parts = clean.split('/')
|
||||
if (clean.startsWith('/') || parts.any { it == ".." }) throw UnsafeArchiveException()
|
||||
val path = root.resolve(clean).normalize()
|
||||
if (!path.startsWith(root)) throw UnsafeArchiveException()
|
||||
var parent = path.parent
|
||||
while (parent != null && parent.startsWith(root) && parent != root) {
|
||||
if (Files.isSymbolicLink(parent)) throw UnsafeArchiveException()
|
||||
parent = parent.parent
|
||||
}
|
||||
return path.toFile()
|
||||
}
|
||||
fun applyMode(file: File, mode: Int) {
|
||||
val permissions = mutableSetOf<PosixFilePermission>()
|
||||
if (mode and 0x100 != 0) permissions += PosixFilePermission.OWNER_READ
|
||||
if (mode and 0x80 != 0) permissions += PosixFilePermission.OWNER_WRITE
|
||||
if (mode and 0x40 != 0) permissions += PosixFilePermission.OWNER_EXECUTE
|
||||
if (mode and 0x20 != 0) permissions += PosixFilePermission.GROUP_READ
|
||||
if (mode and 0x10 != 0) permissions += PosixFilePermission.GROUP_WRITE
|
||||
if (mode and 0x08 != 0) permissions += PosixFilePermission.GROUP_EXECUTE
|
||||
if (mode and 0x04 != 0) permissions += PosixFilePermission.OTHERS_READ
|
||||
if (mode and 0x02 != 0) permissions += PosixFilePermission.OTHERS_WRITE
|
||||
if (mode and 0x01 != 0) permissions += PosixFilePermission.OTHERS_EXECUTE
|
||||
if (permissions.isNotEmpty()) Files.setPosixFilePermissions(file.toPath(), permissions)
|
||||
}
|
||||
val directoryModes = mutableListOf<Pair<File, Int>>()
|
||||
fun place(name: String, mode: Int, directory: Boolean, content: () -> InputStream) {
|
||||
val file = target(name)
|
||||
when {
|
||||
mode and 0xF000 == 0xA000 -> {
|
||||
val link = content().use { it.readBytes().decodeToString() }
|
||||
val parent = file.parentFile ?: throw UnsafeArchiveException()
|
||||
val climbsLater = link.split('/').filter { it != "." }.dropWhile { it == ".." }.any { it == ".." }
|
||||
if (link.startsWith('/') || climbsLater || !parent.toPath().resolve(link).normalize().startsWith(root)) throw UnsafeArchiveException()
|
||||
parent.mkdirs()
|
||||
Files.deleteIfExists(file.toPath())
|
||||
Files.createSymbolicLink(file.toPath(), java.nio.file.Paths.get(link))
|
||||
}
|
||||
directory -> {
|
||||
file.mkdirs()
|
||||
directoryModes += file to mode
|
||||
}
|
||||
else -> {
|
||||
if (Files.isSymbolicLink(file.toPath())) throw UnsafeArchiveException()
|
||||
file.parentFile?.mkdirs()
|
||||
content().use { input -> file.outputStream().use { output -> input.copyTo(output, 1 shl 16) } }
|
||||
applyMode(file, mode)
|
||||
}
|
||||
}
|
||||
}
|
||||
when (type) {
|
||||
ArchiveType.ZIP -> CommonsZipFile.builder().setFile(archive).get().use { zip ->
|
||||
for (entry in zip.entries) place(entry.name, entry.unixMode, entry.isDirectory) { zip.getInputStream(entry) }
|
||||
}
|
||||
ArchiveType.SEVEN_Z -> Files.newByteChannel(archive.toPath()).use { channel ->
|
||||
SevenZFile.builder().setSeekableByteChannel(channel).get().use { seven ->
|
||||
for (entry in seven.entries) {
|
||||
val unix = entry.hasWindowsAttributes && entry.windowsAttributes and 0x8000 != 0
|
||||
place(entry.name, if (unix) entry.windowsAttributes ushr 16 else 0, entry.isDirectory) { seven.getInputStream(entry) }
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> error("Unsupported direct archive")
|
||||
}
|
||||
directoryModes.sortedByDescending { it.first.path.length }.forEach { (directory, mode) -> applyMode(directory, mode) }
|
||||
}
|
||||
|
||||
internal fun checksumIn(text: String): String? = Regex("(?i)\\b[0-9a-f]{128}\\b").find(text)?.value
|
||||
|
||||
internal fun checksumEntry(entries: List<String>, tarball: String): String? {
|
||||
val stem = tarball.substringBefore(".tar")
|
||||
return entries.firstOrNull {
|
||||
val name = File(it).name
|
||||
!TARBALL.containsMatchIn(name) && (name.startsWith("$tarball.") || name.startsWith("$stem.")) && name.contains("sha512", true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun runGuest(context: Context, command: List<String>): Int {
|
||||
val guest = listOf(
|
||||
"/usr/bin/env", "-i", "HOME=/root", "USER=root", "PATH=/usr/local/bin:/usr/bin:/bin",
|
||||
"LANG=C.UTF-8", "XDG_DATA_HOME=/root/.local/share",
|
||||
) + command
|
||||
val child = ProtonExtras.guestProcess(context, guest).start()
|
||||
child.inputStream.bufferedReader().useLines { lines -> lines.forEach { Log.i(TAG, it) } }
|
||||
return child.waitFor()
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,8 @@ object FexCatalog {
|
||||
}
|
||||
|
||||
fun environment(build: Build, sources: List<String> = DownloadSource.candidates(build.url)): List<String> = listOf(
|
||||
"BL_FEX_TAG=${build.tag}",
|
||||
"BL_FEX_SHA256=${build.sha256}",
|
||||
"BL_FEX_URLS=" + sources.joinToString(" "),
|
||||
"DD_FEX_TAG=${build.tag}",
|
||||
"DD_FEX_SHA256=${build.sha256}",
|
||||
"DD_FEX_URLS=" + sources.joinToString(" "),
|
||||
)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AtomicFile
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.core.GameEnvironment
|
||||
import com.droiddeck.launcher.core.TextureFiltering
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
@@ -9,6 +10,7 @@ import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
object GameEnvironmentStore {
|
||||
private const val TAG = "GameEnvironmentStore"
|
||||
private const val SETTINGS = "game-environment.json"
|
||||
private const val GUEST_FILE = "root/.config/droiddeck/game-environment.json"
|
||||
const val DXVK_CONFIG = "dxvkConfig"
|
||||
@@ -19,7 +21,16 @@ object GameEnvironmentStore {
|
||||
fun read(context: Context): GameEnvironment.Config {
|
||||
val file = AtomicFile(File(context.filesDir, SETTINGS))
|
||||
val bytes = try { file.readFully() } catch (_: java.io.FileNotFoundException) { return GameEnvironment.Config() }
|
||||
return decode(JSONObject(bytes.toString(Charsets.UTF_8)))
|
||||
return try {
|
||||
decode(JSONObject(bytes.toString(Charsets.UTF_8)))
|
||||
} catch (error: Exception) {
|
||||
if (error !is org.json.JSONException && error !is IllegalArgumentException) throw error
|
||||
val aside = File(context.filesDir, "$SETTINGS.unreadable")
|
||||
Log.w(TAG, "game environment settings are unreadable, set aside as ${aside.name}", error)
|
||||
aside.delete()
|
||||
file.baseFile.renameTo(aside)
|
||||
GameEnvironment.Config()
|
||||
}
|
||||
}
|
||||
|
||||
fun decode(json: JSONObject): GameEnvironment.Config {
|
||||
@@ -29,7 +40,8 @@ object GameEnvironmentStore {
|
||||
require(GameEnvironment.validName(name))
|
||||
val entry = value.get(name)
|
||||
require(entry == JSONObject.NULL || entry is String && GameEnvironment.validValue(entry))
|
||||
put(name, if (entry == JSONObject.NULL) null else entry as String)
|
||||
val current = GameEnvironment.currentName(name)
|
||||
if (current == name || !value.has(current)) put(current, if (entry == JSONObject.NULL) null else entry as String)
|
||||
}
|
||||
}
|
||||
val games = json.optJSONObject("games")
|
||||
@@ -52,10 +64,9 @@ object GameEnvironmentStore {
|
||||
|
||||
@Synchronized
|
||||
fun save(context: Context, config: GameEnvironment.Config) {
|
||||
val json = encode(config)
|
||||
decode(json)
|
||||
write(File(context.filesDir, SETTINGS), json.toString())
|
||||
publish(context, config)
|
||||
val normalized = decode(encode(config))
|
||||
write(File(context.filesDir, SETTINGS), encode(normalized).toString())
|
||||
publish(context, normalized)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
||||
@@ -25,7 +25,7 @@ object GameSaves {
|
||||
fun label(context: Context): String = context.getString(R.string.saves_layout_zip, app)
|
||||
}
|
||||
|
||||
data class Game(val game: Library.SteamGame, val prefix: File?, val saves: List<SaveDir>) {
|
||||
data class Game(val game: Library.SteamGame, val prefix: File?, val saves: List<SaveDir>, val root: String? = null) {
|
||||
val launched get() = prefix?.let { File(it, "drive_c").isDirectory } == true
|
||||
}
|
||||
|
||||
@@ -36,7 +36,28 @@ object GameSaves {
|
||||
fun savesDir(): File = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "DroidDeck/Saves")
|
||||
private fun backupsDir(): File = File(savesDir(), "backups")
|
||||
|
||||
fun game(game: Library.SteamGame): Game = Game(game, game.protonPrefix, game.protonPrefix?.let { locate(it, game) } ?: emptyList())
|
||||
fun game(context: Context, game: Library.SteamGame): Game {
|
||||
val root = if (ubisoft(game)) ubisoftRoot(context, game) else null
|
||||
val saves = game.protonPrefix?.let { prefix -> if (ubisoft(game)) root?.let { ubisoftSaves(prefix, it) }.orEmpty() else locate(prefix, game) }.orEmpty()
|
||||
return Game(game, game.protonPrefix, saves, root)
|
||||
}
|
||||
|
||||
fun saves(context: Context, prefix: File, game: Library.SteamGame): List<SaveDir> =
|
||||
if (ubisoft(game)) ubisoftRoot(context, game)?.let { ubisoftSaves(prefix, it) }.orEmpty() else locate(prefix, game)
|
||||
|
||||
private fun ubisoftRoot(context: Context, game: Library.SteamGame): String? {
|
||||
val product = game.gameFiles?.let { com.droiddeck.launcher.stores.StoreGameSidecar.read(it) }?.extra?.get("productId")?.toLongOrNull() ?: return null
|
||||
val user = com.droiddeck.launcher.stores.ubisoft.UbisoftAuth.load(context)?.userId
|
||||
if (user.isNullOrEmpty() || user.contains('/') || user.contains("..")) return null
|
||||
return "Saved Games/Ubisoft/$user/$product"
|
||||
}
|
||||
|
||||
private fun ubisoft(game: Library.SteamGame) = game.source == com.droiddeck.launcher.stores.Store.UBISOFT.id
|
||||
|
||||
private fun ubisoftSaves(prefix: File, rel: String): List<SaveDir> {
|
||||
val files = File(profile(prefix), rel).walkTopDown().filter { it.isFile }.toList()
|
||||
return if (files.isEmpty()) emptyList() else listOf(SaveDir(rel, files.size, files.sumOf { it.length() }))
|
||||
}
|
||||
|
||||
|
||||
private val SAVE_ROOTS = listOf("Documents/My Games", "Saved Games", "AppData/Roaming", "Documents", "AppData/Local", "AppData/LocalLow")
|
||||
@@ -109,9 +130,11 @@ object GameSaves {
|
||||
|
||||
fun export(context: Context, game: Game, layout: Layout, dir: File): Pair<File, Int> {
|
||||
val prefix = game.prefix ?: error(context.getString(R.string.saves_not_launched, game.game.name))
|
||||
val roots = game.saves.map { it.relPath }
|
||||
if (roots.isEmpty() && ubisoft(game.game)) error(context.getString(R.string.saves_none_found, game.game.name))
|
||||
dir.mkdirs()
|
||||
val out = File(dir, "${safe(game.game.name)}_${stamp()}.zip")
|
||||
val count = zipProfile(profile(prefix), game.saves.map { it.relPath }.ifEmpty { null }, layout, out)
|
||||
val count = zipProfile(profile(prefix), roots.ifEmpty { null }, layout, out)
|
||||
if (count == 0) { out.delete(); error(context.getString(R.string.saves_none_found, game.game.name)) }
|
||||
return out to count
|
||||
}
|
||||
@@ -142,12 +165,21 @@ object GameSaves {
|
||||
if (!driveC.isDirectory) error(context.getString(R.string.saves_not_launched, game.game.name))
|
||||
if (!looksLikeSaveZip(zip)) error(context.getString(R.string.saves_not_save_zip, zip.name))
|
||||
|
||||
val scoped = if (ubisoft(game.game)) game.root ?: error(context.getString(R.string.saves_none_found, game.game.name)) else null
|
||||
if (scoped != null) {
|
||||
val base = File(profile(prefix), scoped).canonicalFile
|
||||
val eligible = ZipInputStream(BufferedInputStream(zip.inputStream())).use { zis ->
|
||||
generateSequence { zis.nextEntry }.any { e -> !e.isDirectory && remap(e.name)?.let { File(driveC, it).canonicalFile.path.startsWith(base.path + File.separator) } == true }
|
||||
}
|
||||
if (!eligible) error(context.getString(R.string.saves_not_save_zip, zip.name))
|
||||
}
|
||||
backupsDir().mkdirs()
|
||||
val backup = File(backupsDir(), "${safe(game.game.name)}_${stamp()}.zip")
|
||||
val backedUp = zipProfile(profile(prefix), null, Layout.GAMEHUB, backup)
|
||||
val backup = File(backupsDir(), "${safe(game.game.name)}_${stamp()}_${System.currentTimeMillis()}.zip")
|
||||
val backedUp = if (scoped != null && File(profile(prefix), scoped).walkTopDown().none { it.isFile }) 0
|
||||
else zipProfile(profile(prefix), scoped?.let(::listOf), Layout.GAMEHUB, backup)
|
||||
if (backedUp == 0) backup.delete()
|
||||
|
||||
val base = driveC.canonicalFile
|
||||
val base = (if (scoped != null) File(profile(prefix), scoped) else driveC).canonicalFile
|
||||
var written = 0
|
||||
ZipInputStream(BufferedInputStream(zip.inputStream())).use { zis ->
|
||||
var e = zis.nextEntry
|
||||
|
||||
@@ -14,10 +14,22 @@ object GpuClockPin {
|
||||
@Volatile
|
||||
private var pinned = false
|
||||
|
||||
private val supported: Boolean by lazy { File(KGSL_NODE).exists() }
|
||||
@Volatile
|
||||
var failed = false
|
||||
private set
|
||||
|
||||
val supported: Boolean by lazy { File(KGSL_NODE).exists() }
|
||||
|
||||
private var live = false
|
||||
|
||||
@Synchronized
|
||||
fun start(context: Context): String {
|
||||
live = true
|
||||
return hold(context)
|
||||
}
|
||||
|
||||
private fun hold(context: Context): String {
|
||||
failed = false
|
||||
if (!SessionPrefs.gpuClockPin(context)) return "gpu clock: governed"
|
||||
if (!supported) return "gpu clock: no $KGSL_NODE, left governed"
|
||||
return try {
|
||||
@@ -28,12 +40,21 @@ object GpuClockPin {
|
||||
} catch (t: Throwable) {
|
||||
File(context.filesDir, MARKER).delete()
|
||||
Log.w(TAG, "pin", t)
|
||||
failed = true
|
||||
"gpu clock: pin failed"
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun sync(context: Context): String? {
|
||||
if (!live) return null
|
||||
if (!SessionPrefs.gpuClockPin(context) && pinned) clear(context)
|
||||
return hold(context)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun stop(context: Context) {
|
||||
live = false
|
||||
if (pinned) clear(context)
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ object GraphicsReport {
|
||||
|
||||
/** The guest keys the report repeats: everything that decides which Vulkan driver loads. */
|
||||
private val ENV_PREFIXES = listOf(
|
||||
"VK_", "BL_VK", "BL_DRM", "BL_VKBRIDGE", "VKBRIDGE", "MESA_", "GALLIUM_", "ZINK", "TU_", "PANVK",
|
||||
"DROIDDECK_POWERVR", "DROIDDECK_HYBRIS", "BL_GAME_LOGS", "LIBGL_", "GAMESCOPE_DISABLE", "XWAYLAND",
|
||||
"VK_", "DD_VK", "DD_DRM", "DD_VKBRIDGE", "VKBRIDGE", "MESA_", "GALLIUM_", "ZINK", "TU_", "PANVK",
|
||||
"DROIDDECK_POWERVR", "DROIDDECK_HYBRIS", "DD_GAME_LOGS", "LIBGL_", "GAMESCOPE_DISABLE", "XWAYLAND",
|
||||
)
|
||||
|
||||
/** Per-game graphics logs and the guest's Vulkan summary: on for a non-Adreno GPU, or by Setup's switch. */
|
||||
|
||||
@@ -5,6 +5,11 @@ object PipPolicy {
|
||||
running && frameSeen && phase in setOf(SessionPhase.READY, SessionPhase.SUSPENDED) &&
|
||||
(!automatic || !suspended)
|
||||
|
||||
// A front end or shortcut that launched the game brings it back by moving its task to the
|
||||
// front, which Android ignores for a task in picture in picture, and draws its resume controls
|
||||
// where the picture would sit. Going home suspends the game for it instead.
|
||||
fun autoEnter(enabled: Boolean, launchedByAnotherApp: Boolean): Boolean = enabled && !launchedByAnotherApp
|
||||
|
||||
fun aspect(width: Int, height: Int): Pair<Int, Int> = when {
|
||||
width <= 0 || height <= 0 -> 16 to 9
|
||||
width.toDouble() / height > 2.39 -> 239 to 100
|
||||
|
||||
Loaded 100 of 625 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user