mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-04 12:05:39 +00:00
Compare commits
75
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86190c62dc | ||
|
|
a113656196 | ||
|
|
dba3fcd99e | ||
|
|
bb5218746f | ||
|
|
f1fccfac26 | ||
|
|
ca7b7e74ec | ||
|
|
9ba5be4943 | ||
|
|
0a8d6669bf | ||
|
|
c9a0c03292 | ||
|
|
9e05e4c00c | ||
|
|
5926662170 | ||
|
|
617ce33310 | ||
|
|
0a167e41c2 | ||
|
|
1702f2d72d | ||
|
|
7d47c61e24 | ||
|
|
7d134ae459 | ||
|
|
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 | ||
|
|
f0557302ac | ||
|
|
a8c1a9ff4d | ||
|
|
37a816c212 | ||
|
|
1ab090405e |
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:
|
||||
|
||||
@@ -152,6 +152,9 @@ jobs:
|
||||
runs-on: ${{ fromJSON(needs.components-runner.outputs.labels) }}
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- name: Reclaim files a cancelled container build left owned by root
|
||||
if: runner.environment == 'self-hosted'
|
||||
run: sudo -n chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" || echo "::warning::could not reclaim $GITHUB_WORKSPACE"
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
|
||||
@@ -192,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
|
||||
@@ -288,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 \
|
||||
@@ -350,6 +353,9 @@ jobs:
|
||||
outputs:
|
||||
variants: ${{ steps.variants.outputs.list }}
|
||||
steps:
|
||||
- name: Reclaim files a cancelled container build left owned by root
|
||||
if: runner.environment == 'self-hosted'
|
||||
run: sudo -n chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" || echo "::warning::could not reclaim $GITHUB_WORKSPACE"
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
|
||||
|
||||
@@ -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,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" />
|
||||
@@ -298,6 +302,15 @@
|
||||
android:resizeableActivity="true"
|
||||
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboard|keyboardHidden|navigation|uiMode|density" />
|
||||
|
||||
<activity
|
||||
android:name=".session.KeepTopActivity"
|
||||
android:exported="false"
|
||||
android:excludeFromRecents="true"
|
||||
android:noHistory="true"
|
||||
android:taskAffinity="${applicationId}.keeptop"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
|
||||
android:resizeableActivity="true"
|
||||
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboard|keyboardHidden|navigation|uiMode|density" />
|
||||
<activity
|
||||
android:name=".ui.SessionTypingActivity"
|
||||
android:exported="false"
|
||||
|
||||
@@ -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 {
|
||||
@@ -1796,14 +1796,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 +4083,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
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "quest_device.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <sys/system_properties.h>
|
||||
#include <unistd.h>
|
||||
@@ -416,7 +417,13 @@ static void update_map(int scene_w, int scene_h) {
|
||||
if (mode == VKP_MODE_FILL) aspect = sx > sy ? sx : sy;
|
||||
else if (mode == VKP_MODE_INTEGER) {
|
||||
float m = sx < sy ? sx : sy;
|
||||
aspect = m >= 1.0f ? (float)(int)m : m;
|
||||
float nearest = roundf(m);
|
||||
if (nearest >= 1.0f && nearest > m &&
|
||||
nearest - m < 0.15f) {
|
||||
aspect = nearest;
|
||||
} else {
|
||||
aspect = m >= 1.0f ? (float)(int)m : m;
|
||||
}
|
||||
} else aspect = sx < sy ? sx : sy;
|
||||
g_map.kx = g_map.ky = aspect;
|
||||
g_map.off_x = (float)(g_map.rx + (int)((g_map.rw - scene_w * aspect) * 0.5f));
|
||||
@@ -2172,7 +2179,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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -31,7 +31,6 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.droiddeck.launcher.core.AppLanguage
|
||||
@@ -45,10 +44,6 @@ import java.lang.ref.WeakReference
|
||||
/** Floats a sign-in code over the browser page that asks for it. */
|
||||
class DeviceCodeActivity : ComponentActivity() {
|
||||
private var code by mutableStateOf("")
|
||||
private var label by mutableStateOf("")
|
||||
private var message by mutableStateOf<String?>(null)
|
||||
private var paste = false
|
||||
private var agent = true
|
||||
private var url = ""
|
||||
private var display: Int? = null
|
||||
private var inPip by mutableStateOf(false)
|
||||
@@ -90,18 +85,6 @@ class DeviceCodeActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
super.onWindowFocusChanged(hasFocus)
|
||||
if (hasFocus && paste && !inPip) tryPaste()
|
||||
}
|
||||
|
||||
/** Android hands the clipboard only to the app in front, which this float is once expanded. */
|
||||
private fun tryPaste() {
|
||||
val text = runCatching { getSystemService(ClipboardManager::class.java)?.primaryClip?.getItemAt(0)?.coerceToText(this)?.toString() }.getOrNull()
|
||||
if (text.isNullOrBlank()) return
|
||||
if (onPaste?.invoke(this, text) == true) returnToApp()
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
||||
inPip = isInPictureInPictureMode
|
||||
@@ -111,16 +94,12 @@ class DeviceCodeActivity : ComponentActivity() {
|
||||
private fun read(intent: Intent) {
|
||||
code = intent.getStringExtra(EXTRA_CODE).orEmpty()
|
||||
url = intent.getStringExtra(EXTRA_URL).orEmpty()
|
||||
label = intent.getStringExtra(EXTRA_LABEL) ?: getString(R.string.agent_step_github)
|
||||
agent = intent.getBooleanExtra(EXTRA_AGENT, true)
|
||||
message = intent.getStringExtra(EXTRA_MESSAGE)
|
||||
paste = intent.getBooleanExtra(EXTRA_PASTE, false)
|
||||
display = intent.getIntExtra(EXTRA_DISPLAY, -1).takeIf { it > 0 }
|
||||
if (agent) copy()
|
||||
copy()
|
||||
}
|
||||
|
||||
private fun copy() {
|
||||
runCatching { getSystemService(ClipboardManager::class.java)?.setPrimaryClip(ClipData.newPlainText(label, code)) }
|
||||
runCatching { getSystemService(ClipboardManager::class.java)?.setPrimaryClip(ClipData.newPlainText("GitHub", code)) }
|
||||
}
|
||||
|
||||
private fun enterPip() {
|
||||
@@ -137,8 +116,7 @@ class DeviceCodeActivity : ComponentActivity() {
|
||||
if (at == null) startActivity(intent)
|
||||
else startActivity(intent, ActivityOptions.makeBasic().setLaunchDisplayId(at).toBundle())
|
||||
}.recoverCatching { startActivity(intent) }.isSuccess
|
||||
if (agent) com.droiddeck.launcher.agent.AgentHost.deviceCodeOpened(applicationContext, opened)
|
||||
else if (!opened) finish()
|
||||
com.droiddeck.launcher.agent.AgentHost.deviceCodeOpened(applicationContext, opened)
|
||||
}
|
||||
|
||||
@androidx.compose.runtime.Composable
|
||||
@@ -152,16 +130,12 @@ class DeviceCodeActivity : ComponentActivity() {
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(if (inPip) 2.dp else 16.dp),
|
||||
) {
|
||||
Text(label, style = MaterialTheme.typography.labelLarge, color = colors.onSurfaceVariant)
|
||||
val shown = message
|
||||
if (shown != null) Text(shown, fontSize = if (inPip) 12.sp else 22.sp, fontWeight = FontWeight.Bold, color = accent,
|
||||
maxLines = 4, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth())
|
||||
else FitText(code, maxSize = if (inPip) 40.sp else 56.sp, fontWeight = FontWeight.Bold, color = accent,
|
||||
Text(stringResource(R.string.agent_step_github), style = MaterialTheme.typography.labelLarge, color = colors.onSurfaceVariant)
|
||||
FitText(code, maxSize = if (inPip) 40.sp else 56.sp, fontWeight = FontWeight.Bold, color = accent,
|
||||
modifier = Modifier.fillMaxWidth())
|
||||
if (!paste) Text(Uri.parse(url).let { it.host + it.path }, style = MaterialTheme.typography.labelMedium, color = colors.onSurfaceVariant, maxLines = 2, textAlign = TextAlign.Center)
|
||||
Text(Uri.parse(url).let { it.host + it.path }, style = MaterialTheme.typography.labelMedium, color = colors.onSurfaceVariant, maxLines = 1)
|
||||
if (!inPip) Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||
if (paste) PrimaryButton(stringResource(R.string.fm_paste), onClick = ::tryPaste)
|
||||
else PrimaryButton(stringResource(R.string.fm_copy), onClick = ::copy)
|
||||
PrimaryButton(stringResource(R.string.fm_copy), onClick = ::copy)
|
||||
SecondaryButton(stringResource(R.string.common_close), onClick = ::finish)
|
||||
}
|
||||
}
|
||||
@@ -172,24 +146,13 @@ class DeviceCodeActivity : ComponentActivity() {
|
||||
private const val EXTRA_CODE = "code"
|
||||
private const val EXTRA_URL = "url"
|
||||
private const val EXTRA_DISPLAY = "display"
|
||||
private const val EXTRA_LABEL = "label"
|
||||
private const val EXTRA_AGENT = "agent"
|
||||
private const val EXTRA_MESSAGE = "message"
|
||||
private const val EXTRA_PASTE = "paste"
|
||||
|
||||
/** Takes what the user copied from the page; true once it was accepted. */
|
||||
@Volatile var onPaste: ((Context, String) -> Boolean)? = null
|
||||
private var current: WeakReference<DeviceCodeActivity>? = null
|
||||
|
||||
/**
|
||||
* False when this device cannot float a window, so the caller opens the page itself. [message]
|
||||
* replaces the code; [paste] shows a Paste button that hands the clipboard to [onPaste].
|
||||
*/
|
||||
fun show(context: Context, code: String, url: String, display: Int, label: String? = null, message: String? = null, paste: Boolean = false): Boolean {
|
||||
/** False when this device cannot float a window, so the caller opens the page itself. */
|
||||
fun show(context: Context, code: String, url: String, display: Int): Boolean {
|
||||
if (!PairingGuideActivity.canFloat(context)) return false
|
||||
val intent = Intent(context, DeviceCodeActivity::class.java)
|
||||
.putExtra(EXTRA_CODE, code).putExtra(EXTRA_URL, url).putExtra(EXTRA_DISPLAY, display)
|
||||
.putExtra(EXTRA_AGENT, label == null).also { if (label != null) it.putExtra(EXTRA_LABEL, label); if (message != null) it.putExtra(EXTRA_MESSAGE, message); it.putExtra(EXTRA_PASTE, paste) }
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
return runCatching {
|
||||
if (display > 0) context.startActivity(intent, ActivityOptions.makeBasic().setLaunchDisplayId(display).toBundle())
|
||||
@@ -201,12 +164,4 @@ class DeviceCodeActivity : ComponentActivity() {
|
||||
current?.get()?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun returnToApp() {
|
||||
runCatching {
|
||||
startActivity(Intent(this, FrontEndActivity::class.java)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT))
|
||||
}
|
||||
finish()
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -208,8 +208,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)
|
||||
@@ -911,6 +909,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 +935,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
|
||||
@@ -1235,8 +1243,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 +1255,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 +1340,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,
|
||||
@@ -1493,6 +1500,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
},
|
||||
onSaveExport = { sg, layout -> exportSaves(sg.name, layout) { GameSaves.game(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 +1616,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
|
||||
@@ -1974,7 +1980,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
if (hasFocus) {
|
||||
com.droiddeck.launcher.ui.DualScreenPanel.yieldTo(taskId, false)
|
||||
applyLauncherFullscreen()
|
||||
com.droiddeck.launcher.stores.epic.EpicCodeLogin.resumed(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2201,13 +2206,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 }
|
||||
@@ -2705,7 +2710,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,
|
||||
@@ -2751,6 +2757,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
SessionPrefs.setGameCpus(this, CpuCores.format(gameCores))
|
||||
},
|
||||
onDismiss = { showPerformance = false },
|
||||
embedded = embedded,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3300,7 +3307,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()
|
||||
}
|
||||
|
||||
@@ -191,6 +191,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 +201,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 +488,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 +505,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,6 +547,9 @@ 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)
|
||||
@@ -656,11 +667,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 +801,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 +828,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
pointerCaptureRefused = false
|
||||
if (usbMouse.active) updatePointerCapture()
|
||||
} else {
|
||||
releaseHeldGuestInput()
|
||||
releaseHeldInputOnCaptureLoss()
|
||||
uiHandler.postDelayed(::updatePointerCapture, 250)
|
||||
}
|
||||
}
|
||||
@@ -872,10 +886,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 +907,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)
|
||||
@@ -1090,6 +1105,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 +1146,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,
|
||||
@@ -1312,7 +1332,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(
|
||||
@@ -1436,6 +1456,8 @@ 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(),
|
||||
@@ -1447,6 +1469,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onHudReset = { hudConfig = DroidDeckHudConfig.reset(this@SessionActivity); hud.applyConfig() },
|
||||
onHudOrderReset = { hudConfig = DroidDeckHudConfig.clearOrder(this@SessionActivity); hud.applyConfig() },
|
||||
onHudExport = { exportHudDiagnostics() },
|
||||
integerScaling = integerScaling,
|
||||
onIntegerScaling = { enabled ->
|
||||
SessionPrefs.setIntegerScaling(this@SessionActivity, enabled)
|
||||
integerScaling = enabled
|
||||
applyGameAlignment()
|
||||
},
|
||||
onUpscaler = { m ->
|
||||
val target = effectsEditorTarget ?: screenEffectsTarget
|
||||
val activeProfileId =
|
||||
@@ -1592,8 +1620,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 ->
|
||||
@@ -1623,7 +1654,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,
|
||||
@@ -1854,7 +1885,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,
|
||||
@@ -1895,12 +1926,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)
|
||||
@@ -2685,7 +2748,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)
|
||||
}
|
||||
@@ -2878,7 +2941,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)
|
||||
@@ -3132,6 +3196,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun onSessionEnded(status: Int) {
|
||||
ended = true
|
||||
uiHandler.removeCallbacks(guardWhenRunning)
|
||||
com.droiddeck.launcher.session.KeepTopActivity.release()
|
||||
++steamVrRequestGeneration
|
||||
if (isInPictureInPictureMode) {
|
||||
runOnUiThread { finish() }
|
||||
@@ -3650,7 +3716,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()
|
||||
@@ -4009,16 +4074,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
|
||||
@@ -4040,12 +4112,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
|
||||
}
|
||||
@@ -4071,6 +4153,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)
|
||||
}
|
||||
|
||||
@@ -4089,6 +4172,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)
|
||||
@@ -4167,7 +4254,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 {
|
||||
@@ -4271,6 +4358,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()
|
||||
@@ -4410,6 +4498,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
|
||||
@@ -4419,16 +4508,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()
|
||||
}
|
||||
}
|
||||
@@ -4515,9 +4625,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() {
|
||||
@@ -4728,6 +4842,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)
|
||||
@@ -4760,6 +4880,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
|
||||
@@ -4909,6 +5034,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)
|
||||
}
|
||||
@@ -4943,7 +5072,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
|
||||
}
|
||||
|
||||
@@ -4990,10 +5121,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
|
||||
@@ -5316,14 +5451,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
|
||||
@@ -5399,6 +5546,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
|
||||
@@ -5418,7 +5567,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
|
||||
@@ -5459,7 +5608,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
override fun startActivityForResult(intent: Intent, requestCode: Int, options: Bundle?) {
|
||||
if (::pip.isInitialized && (requestCode >= 0 || intent.component?.packageName == packageName ||
|
||||
if (::pip.isInitialized && intent.component?.className != com.droiddeck.launcher.session.KeepTopActivity::class.java.name &&
|
||||
(requestCode >= 0 || intent.component?.packageName == packageName ||
|
||||
intent.action in setOf(Intent.ACTION_CHOOSER, Intent.ACTION_SEND, Intent.ACTION_OPEN_DOCUMENT,
|
||||
Intent.ACTION_GET_CONTENT, "android.settings.PICTURE_IN_PICTURE_SETTINGS"))) pip.background()
|
||||
super.startActivityForResult(intent, requestCode, options)
|
||||
@@ -5491,6 +5641,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
if (lightPause.stopped()) departureCleanup()
|
||||
if (runtimeRemovalBlocked) { super.onStop(); return }
|
||||
started = false
|
||||
if (::hud.isInitialized) hud.setBackgrounded(true)
|
||||
@@ -5534,6 +5685,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
uiHandler.removeCallbacks(lightPauseCheck)
|
||||
when (lightPause.resumed(com.droiddeck.launcher.session.KeepTopActivity.bounces)) {
|
||||
com.droiddeck.launcher.session.LightPause.Resume.LIGHT -> return
|
||||
com.droiddeck.launcher.session.LightPause.Resume.CLEANUP_FIRST -> departureCleanup()
|
||||
com.droiddeck.launcher.session.LightPause.Resume.NORMAL -> Unit
|
||||
}
|
||||
drawerGameInventoryRevision++
|
||||
com.droiddeck.launcher.input.SystemKeyCapture.attach(this, { hasWindowFocus() && !appUiOwnsPointer() && CompositorHost.isStarted }) { event ->
|
||||
com.droiddeck.launcher.input.GuestKeys.send(event) { code, down -> sendGuestKey(code, down, 8) }
|
||||
@@ -5561,6 +5718,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 = {
|
||||
@@ -5597,10 +5756,63 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
SessionPrefs.sessionPrefs(this).registerOnSharedPreferenceChangeListener(cardboardPrefListener)
|
||||
}
|
||||
|
||||
private var memoryPressureAt = 0L
|
||||
private var focusBounce = false
|
||||
private val lightPause = com.droiddeck.launcher.session.LightPause()
|
||||
private val lightPauseCheck = Runnable { if (lightPause.timedOut()) departureCleanup() }
|
||||
private var topResumed = false
|
||||
private val guardWhenRunning = object : Runnable {
|
||||
override fun run() {
|
||||
if (!topResumed || isFinishing) return
|
||||
if (SessionState.running) guardOtherDisplays() else uiHandler.postDelayed(this, 2_000)
|
||||
}
|
||||
}
|
||||
|
||||
// RUNNING_LOW and RUNNING_CRITICAL are not delivered from API 34, so the guard also goes up
|
||||
// as soon as a running session is on top.
|
||||
override fun onTrimMemory(level: Int) {
|
||||
super.onTrimMemory(level)
|
||||
if (!com.droiddeck.launcher.session.TopUnderPressure.isPressure(level)) return
|
||||
memoryPressureAt = android.os.SystemClock.elapsedRealtime()
|
||||
guardOtherDisplays()
|
||||
}
|
||||
|
||||
override fun onTopResumedActivityChanged(isTopResumedActivity: Boolean) {
|
||||
super.onTopResumedActivityChanged(isTopResumedActivity)
|
||||
topResumed = isTopResumedActivity
|
||||
uiHandler.removeCallbacks(guardWhenRunning)
|
||||
if (isTopResumedActivity) uiHandler.post(guardWhenRunning)
|
||||
else if (com.droiddeck.launcher.session.TopUnderPressure.shouldReclaim(
|
||||
android.os.SystemClock.elapsedRealtime(), memoryPressureAt, SessionState.running, isFinishing)) guardOtherDisplays()
|
||||
}
|
||||
|
||||
private fun guardOtherDisplays() {
|
||||
if (!SessionState.running || isFinishing) return
|
||||
val wasResumed = lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.RESUMED)
|
||||
val bounced = com.droiddeck.launcher.session.KeepTopActivity.guardOtherDisplays(this, display?.displayId ?: android.view.Display.DEFAULT_DISPLAY)
|
||||
if (com.droiddeck.launcher.session.KeepTopActivity.hasPendingStarts()) {
|
||||
uiHandler.removeCallbacks(guardWhenRunning)
|
||||
uiHandler.postDelayed(guardWhenRunning, com.droiddeck.launcher.session.KeepTopActivity.RETRY_MS)
|
||||
}
|
||||
if (!bounced) return
|
||||
if (!wasResumed) return
|
||||
focusBounce = true
|
||||
uiHandler.postDelayed({ focusBounce = false }, 500)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
if (focusBounce) {
|
||||
focusBounce = false
|
||||
lightPause.paused(com.droiddeck.launcher.session.KeepTopActivity.bounces)
|
||||
uiHandler.postDelayed(lightPauseCheck, 200)
|
||||
} else 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()
|
||||
@@ -5634,14 +5846,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) {
|
||||
@@ -5882,9 +6096,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) {
|
||||
@@ -6010,7 +6225,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(
|
||||
@@ -6038,8 +6253,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 },
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -6206,6 +6422,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
releaseHeldGuestInput()
|
||||
}
|
||||
if (hasFocus && !pipUi) {
|
||||
retryFieldKeyboard(true)
|
||||
goFullscreen()
|
||||
refreshClipboard()
|
||||
}
|
||||
@@ -6250,6 +6467,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
uiHandler.removeCallbacks(guardWhenRunning)
|
||||
com.droiddeck.launcher.session.KeepTopActivity.release()
|
||||
synchronized(frameGenGlobalLock) {
|
||||
frameGenActivityActive = false
|
||||
frameGenRequests.incrementAndGet()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,22 @@ 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) {}
|
||||
/** Whether [Options.plan] means anything to this CLI. */
|
||||
val plans: Boolean
|
||||
/** Reasoning effort levels the CLI accepts, lowest first; empty when it has none. */
|
||||
@@ -46,10 +62,13 @@ interface AgentHarness {
|
||||
|
||||
data class Model(val id: String, val label: String)
|
||||
|
||||
/** 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)
|
||||
|
||||
data class Options(val model: String? = null, val plan: Boolean = false, val brief: String? = null, val effort: String? = null)
|
||||
|
||||
companion object {
|
||||
val all: List<AgentHarness> = listOf(ClaudeCode, Codex)
|
||||
val all: List<AgentHarness> = listOf(ClaudeCode, Codex, OpenCode)
|
||||
fun byId(id: String?): AgentHarness = all.firstOrNull { it.id == id } ?: ClaudeCode
|
||||
}
|
||||
}
|
||||
@@ -392,6 +411,271 @@ object Codex : AgentHarness {
|
||||
}
|
||||
}
|
||||
|
||||
/** OpenCode: `opencode run --format json`, 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
|
||||
}
|
||||
}
|
||||
|
||||
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) }
|
||||
}
|
||||
|
||||
/** 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+$""")
|
||||
|
||||
private class Spent(var cost: Double = 0.0, var input: Long = 0, var output: Long = 0)
|
||||
private val spent = Spent()
|
||||
@Volatile private var model: String? = null
|
||||
|
||||
override fun turn(message: String, conversation: String?, options: AgentHarness.Options): List<String> {
|
||||
synchronized(spent) { spent.cost = 0.0; spent.input = 0; spent.output = 0 }
|
||||
model = options.model
|
||||
// DroidDeck runs the agent unattended; --auto approves all the agent does not deny itself, and plan mode denies edits.
|
||||
return buildList {
|
||||
addAll(listOf(binary, "run", "--format", "json", "--auto", "--thinking"))
|
||||
if (conversation != null) addAll(listOf("-s", conversation))
|
||||
if (options.plan) addAll(listOf("--agent", "plan"))
|
||||
options.model?.let { addAll(listOf("-m", it)) }
|
||||
options.effort?.let { addAll(listOf("--variant", it)) }
|
||||
add("--")
|
||||
// opencode run 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 usage(rootfs: File, conversation: String?): AgentEvent? {
|
||||
val id = model ?: return null
|
||||
return listed(rootfs)?.windows?.get(id)?.let { AgentEvent(window = it) }
|
||||
}
|
||||
|
||||
override fun parse(line: String): AgentEvent? {
|
||||
val o = runCatching { JSONObject(line) }.getOrNull() ?: return null
|
||||
val conversation = o.optString("sessionID").takeIf { it.isNotEmpty() }
|
||||
val part = o.optJSONObject("part")
|
||||
return when (o.optString("type")) {
|
||||
"text" -> AgentEvent(conversation, text(part) { AgentHost.Entry.Said(it) })
|
||||
"reasoning" -> AgentEvent(conversation, text(part) { AgentHost.Entry.Thought(it) })
|
||||
"tool_use" -> AgentEvent(conversation, part?.let { tool(it) }.orEmpty())
|
||||
"step_finish" -> {
|
||||
val tokens = part?.optJSONObject("tokens")
|
||||
val cache = tokens?.optJSONObject("cache")
|
||||
val total = synchronized(spent) {
|
||||
spent.cost += part?.optDouble("cost", 0.0) ?: 0.0
|
||||
spent.input += (tokens?.optLong("input") ?: 0) + (cache?.optLong("read") ?: 0) + (cache?.optLong("write") ?: 0)
|
||||
spent.output += (tokens?.optLong("output") ?: 0) + (tokens?.optLong("reasoning") ?: 0)
|
||||
AgentHost.Usage(0, spent.cost, spent.input, spent.output)
|
||||
}
|
||||
val context = tokens?.optLong("total")?.takeIf { it > 0 }
|
||||
// A step that ends to run tools is followed by another; any other reason ends the turn.
|
||||
if (part?.optString("reason") == "tool-calls") AgentEvent(conversation, context = context)
|
||||
else AgentEvent(conversation, listOf(AgentHost.Entry.Finished(null)), context = context, usage = total)
|
||||
}
|
||||
"error" -> {
|
||||
val error = o.optJSONObject("error")
|
||||
val message = error?.optJSONObject("data")?.optString("message")?.takeIf { it.isNotEmpty() }
|
||||
?: error?.optString("message")?.takeIf { it.isNotEmpty() } ?: error?.optString("name")?.takeIf { it.isNotEmpty() } ?: "error"
|
||||
AgentEvent(conversation, listOf(AgentHost.Entry.Finished(message)))
|
||||
}
|
||||
else -> conversation?.let { AgentEvent(it) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun text(part: JSONObject?, entry: (String) -> AgentHost.Entry) =
|
||||
part?.optString("text")?.trim()?.takeIf { it.isNotEmpty() }?.let { listOf(entry(it)) }.orEmpty()
|
||||
|
||||
private fun tool(part: JSONObject): List<AgentHost.Entry> {
|
||||
val id = part.optString("callID").ifEmpty { part.optString("id") }
|
||||
val state = part.optJSONObject("state") ?: JSONObject()
|
||||
val input = state.optJSONObject("input") ?: JSONObject()
|
||||
val path = input.optString("filePath")
|
||||
val (name, detail, full) = when (val tool = part.optString("tool")) {
|
||||
"bash" -> Triple("Bash", firstLine(input.optString("command")), input.optString("command"))
|
||||
"edit" -> Triple("Edit", path, path + "\n" + lineDiff(input.optString("oldString"), input.optString("newString")))
|
||||
"write" -> Triple("Write", path, path + "\n" + lineDiff("", input.optString("content")))
|
||||
"todowrite" -> Triple("TodoWrite", "", todos(input.optJSONArray("todos")))
|
||||
else -> Triple(tool.replaceFirstChar { it.uppercase() }.ifEmpty { "Tool" }, detail(input), input.toString(2))
|
||||
}
|
||||
val used = AgentHost.Entry.Used(id, name, detail, full)
|
||||
return when (state.optString("status")) {
|
||||
"completed" -> {
|
||||
val exit = state.optJSONObject("metadata")?.opt("exit")
|
||||
listOf(used, AgentHost.Entry.Result(id, state.optString("output"), exit is Number && exit.toInt() != 0))
|
||||
}
|
||||
"error" -> listOf(used, AgentHost.Entry.Result(id, state.optString("error"), true))
|
||||
else -> listOf(used)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -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,10 +129,15 @@ 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; " +
|
||||
|
||||
@@ -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")),
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.ActivityOptions
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.util.Log
|
||||
import android.view.Display
|
||||
import android.view.WindowManager
|
||||
|
||||
// While a session runs, sits invisibly on top of every other display until it ends, so
|
||||
// that display's home launcher is not its top activity. lmkd kills the launcher first; restarted as a
|
||||
// top activity it takes focus from the session, which then drops to adj 50 and is killed next.
|
||||
class KeepTopActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@Suppress("DEPRECATION") overridePendingTransition(0, 0)
|
||||
if (intent.getBooleanExtra(EXTRA_BOUNCE, false)) {
|
||||
bounces++
|
||||
finish()
|
||||
return
|
||||
}
|
||||
if (intent.getIntExtra(EXTRA_GENERATION, -1) != generation) {
|
||||
finishAndRemoveTask()
|
||||
return
|
||||
}
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
|
||||
val id = display?.displayId ?: Display.INVALID_DISPLAY
|
||||
starting.remove(id)
|
||||
guards[id]?.takeIf { it !== this && !it.isFinishing }?.finishAndRemoveTask()
|
||||
guards[id] = this
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
guards.values.remove(this)
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "KeepTop"
|
||||
private const val EXTRA_BOUNCE = "bounce"
|
||||
private const val EXTRA_GENERATION = "generation"
|
||||
private var generation = 0
|
||||
var bounces = 0
|
||||
private set
|
||||
private val guards = HashMap<Int, KeepTopActivity>()
|
||||
private const val START_TIMEOUT_MS = 2_000L
|
||||
private val starting = HashMap<Int, Long>()
|
||||
|
||||
fun guardOtherDisplays(context: Context, sessionDisplay: Int): Boolean {
|
||||
val displays = context.getSystemService(DisplayManager::class.java)?.displays ?: return false
|
||||
var started = false
|
||||
for (display in displays) {
|
||||
val id = display.displayId
|
||||
if (id == sessionDisplay || display.state != Display.STATE_ON || guards[id]?.isFinishing == false ||
|
||||
starting[id]?.let { SystemClock.elapsedRealtime() - it < START_TIMEOUT_MS } == true) continue
|
||||
runCatching {
|
||||
launch(context, id, bounce = false)
|
||||
starting[id] = SystemClock.elapsedRealtime()
|
||||
started = true
|
||||
Log.i(TAG, "guarding display $id from a home launcher restart")
|
||||
}.onFailure { Log.w(TAG, "could not guard display $id", it) }
|
||||
}
|
||||
if (!started) return false
|
||||
return runCatching { launch(context, sessionDisplay, bounce = true) }
|
||||
.onFailure { Log.w(TAG, "could not return focus to display $sessionDisplay", it) }.isSuccess
|
||||
}
|
||||
|
||||
fun hasPendingStarts() = starting.isNotEmpty()
|
||||
|
||||
const val RETRY_MS = START_TIMEOUT_MS + 250
|
||||
|
||||
fun release() {
|
||||
generation++
|
||||
guards.values.toList().forEach { it.finishAndRemoveTask() }
|
||||
guards.clear()
|
||||
starting.clear()
|
||||
}
|
||||
|
||||
private fun launch(context: Context, displayId: Int, bounce: Boolean) {
|
||||
val intent = Intent(context, KeepTopActivity::class.java)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION)
|
||||
.putExtra(EXTRA_BOUNCE, bounce)
|
||||
.putExtra(EXTRA_GENERATION, generation)
|
||||
context.startActivity(intent, ActivityOptions.makeBasic().setLaunchDisplayId(displayId).toBundle())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
// Tracks a pause that skipped the session's departure cleanup for the keep-top focus bounce.
|
||||
internal class LightPause {
|
||||
private var pending = false
|
||||
private var bouncesAtPause = 0
|
||||
|
||||
fun paused(bounces: Int) {
|
||||
pending = true
|
||||
bouncesAtPause = bounces
|
||||
}
|
||||
|
||||
// The bounce resumes the session within tens of milliseconds; still paused at the timeout means
|
||||
// something else holds the pause.
|
||||
fun timedOut(): Boolean = take()
|
||||
|
||||
fun stopped(): Boolean = take()
|
||||
|
||||
fun resumed(bounces: Int): Resume {
|
||||
if (!pending) return Resume.NORMAL
|
||||
pending = false
|
||||
return if (bounces != bouncesAtPause) Resume.LIGHT else Resume.CLEANUP_FIRST
|
||||
}
|
||||
|
||||
private fun take(): Boolean {
|
||||
val was = pending
|
||||
pending = false
|
||||
return was
|
||||
}
|
||||
|
||||
enum class Resume { NORMAL, LIGHT, CLEANUP_FIRST }
|
||||
}
|
||||
@@ -37,7 +37,7 @@ object ProtonExtras {
|
||||
)
|
||||
|
||||
private fun home(context: Context) = File(LinuxRuntime.rootDir(context), "root")
|
||||
private fun requests(context: Context) = File(home(context), ".bl-proton-extra")
|
||||
private fun requests(context: Context) = File(home(context), ".dd-proton-extra")
|
||||
private fun toolsDir(context: Context) = File(home(context), ".local/share/Steam/compatibilitytools.d")
|
||||
private fun releasesFile(context: Context) = File(context.filesDir, "proton-extras.json")
|
||||
private fun latestFile(context: Context) = File(context.filesDir, "proton-latest.json")
|
||||
|
||||
@@ -68,7 +68,7 @@ object QuestExperimental {
|
||||
appendLine("driverMode=${SessionPrefs.gpuDriverMode(context)}")
|
||||
appendLine("androidDriver=${SessionPrefs.androidDriver(context)}")
|
||||
appendLine("steamSurfaceControlWorkaround=${SessionPrefs.hdr(context, "steam")}")
|
||||
appendLine("GPUOBJ fallback installed in Android driver and ARM64 libblsession")
|
||||
appendLine("GPUOBJ fallback installed in Android driver and ARM64 libddsession")
|
||||
appendLine("Experimental Quest 2/3/3S compatibility; 2D panel application")
|
||||
}
|
||||
Log.i(TAG, report)
|
||||
|
||||
@@ -544,6 +544,7 @@ object SessionArtifacts {
|
||||
"session died of a crash, the entry is in there unless the device rebooted.\n" +
|
||||
(if (newest) exitReasons(context) else "")
|
||||
)
|
||||
restartNote(File(dir, "device.txt").lastModified(), bootedAt())?.let { recoveryNote.appendText(it) }
|
||||
if (newest && lastExitForMemory(context)) killedForMemory = true
|
||||
}
|
||||
if (recoveryPreviouslyAttempted && !runtimeCaptured.exists() &&
|
||||
@@ -597,7 +598,7 @@ object SessionArtifacts {
|
||||
}
|
||||
val memoryLog = File(dir, "memory-pressure.log")
|
||||
if (newest && !memoryLog.exists()) {
|
||||
SessionLogCapture.dumpMemoryPressure(memoryLog)
|
||||
SessionLogCapture.dumpMemoryPressure(memoryLog, context)
|
||||
}
|
||||
if (stopWhenSessionStarts && SessionState.running) {
|
||||
record.failed = true
|
||||
@@ -686,5 +687,21 @@ object SessionArtifacts {
|
||||
return gone.size
|
||||
}
|
||||
|
||||
private fun bootedAt(): Long = System.currentTimeMillis() - android.os.SystemClock.elapsedRealtime()
|
||||
|
||||
internal fun restartNote(sessionStartedAt: Long, bootedAt: Long): String? {
|
||||
if (sessionStartedAt <= 0L) return null
|
||||
val stamp = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US)
|
||||
return if (bootedAt > sessionStartedAt + BOOT_CLOCK_SLACK_MS) {
|
||||
"The device itself probably restarted after this session began (estimated boot ${stamp.format(Date(bootedAt))}, from the clock and uptime, so a clock change can fake it):\n" +
|
||||
"if so, the whole system went down and crash.log is the new boot's buffer and says nothing about the session.\n"
|
||||
} else {
|
||||
"The device does not appear to have restarted since this session began (estimated boot ${stamp.format(Date(bootedAt))}, from the clock and uptime):\n" +
|
||||
"only this app's processes ended, so crash.log and the exit records cover the end.\n"
|
||||
}
|
||||
}
|
||||
|
||||
private const val BOOT_CLOCK_SLACK_MS = 60_000L
|
||||
|
||||
private fun now(): String = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(Date())
|
||||
}
|
||||
@@ -109,11 +109,11 @@ object SessionFiles {
|
||||
"usr/local/bin/droiddeck-steam-compat" to "usr/local/bin/droiddeck-steam-compat",
|
||||
"usr/local/bin/droiddeck-steam-taskset" to "usr/local/libexec/droiddeck-steam/taskset",
|
||||
"usr/local/bin/droiddeck-fex" to "usr/local/bin/droiddeck-fex",
|
||||
"libblsession.so" to "usr/local/lib/libblsession.so",
|
||||
"libddsession.so" to "usr/local/lib/libddsession.so",
|
||||
"libfakeinput.so" to "usr/local/lib/libfakeinput.so",
|
||||
"libblfastpath.so" to "usr/local/lib/libblfastpath.so",
|
||||
"libddfastpath.so" to "usr/local/lib/libddfastpath.so",
|
||||
"libddnatv-hook.so" to "usr/lib/libddnatv-hook.so",
|
||||
"libblaudit.so" to "usr/local/lib/libblaudit.so",
|
||||
"libddaudit.so" to "usr/local/lib/libddaudit.so",
|
||||
"libssbs.so" to "usr/local/lib/libssbs.so",
|
||||
"usr/local/bin/droiddeck-session" to "usr/local/bin/droiddeck-session",
|
||||
"usr/local/bin/droiddeck-fonts" to "usr/local/bin/droiddeck-fonts",
|
||||
@@ -238,7 +238,7 @@ object SessionFiles {
|
||||
"usr/local/lib/droiddeck-gpuload/VK_LAYER_DROIDDECK_vram_cap.json" to "usr/share/vulkan/implicit_layer.d/droiddeck_vram_cap.json",
|
||||
)
|
||||
val fexPreloads = listOf("x86_64", "i386").flatMap { arch ->
|
||||
listOf("libblsession.so", "libfakeinput.so", "libfaultreport.so").map { "$arch/$it" to "usr/local/lib/droiddeck-fex/$arch/$it" }
|
||||
listOf("libddsession.so", "libfakeinput.so", "libfaultreport.so").map { "$arch/$it" to "usr/local/lib/droiddeck-fex/$arch/$it" }
|
||||
} + listOf("libvulkan-thunk.so", "libwebkitinput.so").map { "x86_64/$it" to "usr/local/lib/droiddeck-fex/x86_64/$it" }
|
||||
// The Mali compatibility layer (tools/venus/layer, David Cimo): an implicit Vulkan layer that
|
||||
// fills in the features DXVK requires and Mali lacks. Idle outside Wine and on GPUs that have them.
|
||||
@@ -315,7 +315,7 @@ object SessionFiles {
|
||||
for (pack in SERVICE_PACKS.keys) stageStoreService(context, root, pack, ledger)
|
||||
ledger.save()
|
||||
for (old in arrayOf("aarch64-unix", "aarch64-windows", "i386-windows")) File(root, "$DIRECTAUDIO_DIR/lib/wine/$old").deleteRecursively()
|
||||
val preload = StringBuilder("/usr/local/lib/libblsession.so\n")
|
||||
val preload = StringBuilder("/usr/local/lib/libddsession.so\n")
|
||||
if (!File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()) {
|
||||
preload.append("/usr/local/lib/libfakeinput.so\n")
|
||||
}
|
||||
|
||||
@@ -203,18 +203,6 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("androidTextFieldKeyboard", on).apply()
|
||||
}
|
||||
|
||||
fun gameStoresEnabled(context: Context): Boolean = prefs(context).getBoolean("gameStoresEnabled", true)
|
||||
|
||||
fun setGameStoresEnabled(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("gameStoresEnabled", on).apply()
|
||||
}
|
||||
|
||||
fun soundtracksEnabled(context: Context): Boolean = prefs(context).getBoolean("soundtracksEnabled", true)
|
||||
|
||||
fun setSoundtracksEnabled(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("soundtracksEnabled", on).apply()
|
||||
}
|
||||
|
||||
fun soundtracksIngame(context: Context): Boolean = prefs(context).getBoolean("soundtracksIngame", false)
|
||||
|
||||
fun setSoundtracksIngame(context: Context, on: Boolean) {
|
||||
@@ -267,16 +255,55 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("libraryShowSize", show).apply()
|
||||
}
|
||||
|
||||
fun libraryShowHidden(context: Context): Boolean = prefs(context).getBoolean("libraryShowHidden", false)
|
||||
|
||||
fun setLibraryShowHidden(context: Context, show: Boolean) {
|
||||
prefs(context).edit().putBoolean("libraryShowHidden", show).apply()
|
||||
}
|
||||
|
||||
fun libraryHidden(context: Context): Set<String> = prefs(context).getStringSet("libraryHidden", null)?.toSet().orEmpty()
|
||||
|
||||
fun setLibraryHidden(context: Context, keys: Set<String>) {
|
||||
prefs(context).edit().putStringSet("libraryHidden", keys.toSet()).apply()
|
||||
}
|
||||
|
||||
fun railLabels(context: Context): Boolean = prefs(context).getBoolean("railLabels", false)
|
||||
|
||||
fun setRailLabels(context: Context, show: Boolean) {
|
||||
prefs(context).edit().putBoolean("railLabels", show).apply()
|
||||
}
|
||||
|
||||
fun agentTab(context: Context): Boolean = prefs(context).getBoolean("agentTab", true)
|
||||
fun developerTools(context: Context): Boolean =
|
||||
prefs(context).getBoolean("developerTools", com.droiddeck.launcher.agent.AgentAccess.commandsEnabled(context))
|
||||
|
||||
fun setAgentTab(context: Context, show: Boolean) {
|
||||
prefs(context).edit().putBoolean("agentTab", show).apply()
|
||||
fun setDeveloperTools(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("developerTools", on).apply()
|
||||
}
|
||||
|
||||
fun fpsLimitKey(mode: String?, game: String?): String? = when (mode) {
|
||||
SessionService.MODE_RUN -> game?.trim()?.takeIf(com.droiddeck.launcher.frontend.GameLaunchLink::validId)?.let { "fpsLimit.game.$it" }
|
||||
SessionService.MODE_DESKTOP -> "fpsLimit.desktop"
|
||||
else -> null
|
||||
}
|
||||
|
||||
fun savedFpsLimit(context: Context, key: String?): Int = key?.let { prefs(context).getInt(it, 0) } ?: 0
|
||||
|
||||
fun saveFpsLimit(context: Context, key: String?, fps: Int) {
|
||||
key ?: return
|
||||
prefs(context).edit().apply { if (fps > 0) putInt(key, fps) else remove(key) }.apply()
|
||||
}
|
||||
|
||||
fun drawerCornerTap(context: Context): Boolean =
|
||||
prefs(context).getBoolean("drawerCornerTap", android.os.Build.MANUFACTURER.equals("Oculus", true) || android.os.Build.MANUFACTURER.equals("Meta", true))
|
||||
|
||||
fun setDrawerCornerTap(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("drawerCornerTap", on).apply()
|
||||
}
|
||||
|
||||
fun drawerHintShown(context: Context): Int = prefs(context).getInt("drawerHintShown", 0)
|
||||
|
||||
fun countDrawerHint(context: Context) {
|
||||
prefs(context).edit().putInt("drawerHintShown", drawerHintShown(context) + 1).apply()
|
||||
}
|
||||
|
||||
fun libraryShowUninstalled(context: Context): Boolean = prefs(context).getBoolean("libraryShowUninstalled", false)
|
||||
@@ -291,8 +318,36 @@ object SessionPrefs {
|
||||
prefs(context).edit().putStringSet("libraryFavorites", keys.toSet()).apply()
|
||||
}
|
||||
|
||||
fun storesTabOrderCustomized(context: Context): Boolean =
|
||||
prefs(context).getBoolean("storesTabOrderCustomized", false)
|
||||
|
||||
fun setStoresTabOrderCustomized(context: Context, customized: Boolean) {
|
||||
prefs(context).edit().putBoolean("storesTabOrderCustomized", customized).apply()
|
||||
}
|
||||
|
||||
fun storesTabOrder(context: Context): List<String> = idList(prefs(context).getString("storesTabOrder", null))
|
||||
|
||||
/** An order nobody arranged stays unsaved, so it keeps following the default. */
|
||||
fun saveStoresTabs(context: Context, order: List<String>, hidden: Set<String>, arranged: Boolean) {
|
||||
if (arranged) setStoresTabOrderCustomized(context, true)
|
||||
if (storesTabOrderCustomized(context)) setStoresTabOrder(context, order)
|
||||
setStoresTabHidden(context, hidden)
|
||||
}
|
||||
|
||||
private val LEGACY_STORES_TAB_ORDER = listOf("gog", "epic", "amazon", "xbox", "itch", "gamejolt", "battlenet", "ubisoft", "ea", "rockstar")
|
||||
|
||||
/**
|
||||
* Forgets an order the user never arranged, so the Stores tabs and Library pills follow whatever the default is now.
|
||||
* Earlier versions saved the default of their day, which is why a saved order alone does not mean the user chose it.
|
||||
*/
|
||||
fun settleStoresTabOrder(context: Context, defaults: List<String>) {
|
||||
if (storesTabOrderCustomized(context)) return
|
||||
val saved = storesTabOrder(context)
|
||||
if (saved.isEmpty()) return
|
||||
if (saved == LEGACY_STORES_TAB_ORDER || saved == defaults) prefs(context).edit().remove("storesTabOrder").apply()
|
||||
else setStoresTabOrderCustomized(context, true)
|
||||
}
|
||||
|
||||
fun setStoresTabOrder(context: Context, order: List<String>) {
|
||||
prefs(context).edit().putString("storesTabOrder", order.joinToString(",")).apply()
|
||||
}
|
||||
@@ -309,13 +364,35 @@ object SessionPrefs {
|
||||
prefs(context).edit().putString("navTabOrder", order.joinToString(",")).apply()
|
||||
}
|
||||
|
||||
fun navTabShelved(context: Context): Set<String> = idList(prefs(context).getString("navTabShelved", "soundtracks,agent")).toSet()
|
||||
fun navTabShelved(context: Context): Set<String>? = prefs(context).getString("navTabShelved", null)?.let { idList(it).toSet() }
|
||||
|
||||
fun setNavTabShelved(context: Context, keys: Set<String>) {
|
||||
prefs(context).edit().putString("navTabShelved", keys.joinToString(",")).apply()
|
||||
}
|
||||
|
||||
fun navTabHidden(context: Context): Set<String> = idList(prefs(context).getString("navTabHidden", null)).toSet()
|
||||
fun navTabHidden(context: Context): Set<String>? = prefs(context).getString("navTabHidden", null)?.let { idList(it).toSet() }
|
||||
|
||||
fun navTabLayoutVersion(context: Context): Int = prefs(context).getInt("navTabLayout", 0)
|
||||
|
||||
class LegacyTabSwitches(val touched: Boolean, val stores: Boolean, val soundtracks: Boolean, val agent: Boolean)
|
||||
|
||||
fun legacyTabSwitches(context: Context): LegacyTabSwitches {
|
||||
val p = prefs(context)
|
||||
val keys = listOf("navTabOrder", "navTabShelved", "navTabHidden", "gameStoresEnabled", "soundtracksEnabled", "agentTab")
|
||||
return LegacyTabSwitches(
|
||||
touched = keys.any { p.contains(it) },
|
||||
stores = p.getBoolean("gameStoresEnabled", true),
|
||||
soundtracks = p.getBoolean("soundtracksEnabled", true),
|
||||
agent = p.getBoolean("agentTab", false) && p.getBoolean("developerTools", true),
|
||||
)
|
||||
}
|
||||
|
||||
fun finishTabSwitchMigration(context: Context, version: Int) {
|
||||
val p = prefs(context)
|
||||
val e = p.edit()
|
||||
if (!p.contains("developerTools") && p.getBoolean("agentTab", false)) e.putBoolean("developerTools", true)
|
||||
e.remove("gameStoresEnabled").remove("soundtracksEnabled").remove("agentTab").putInt("navTabLayout", version).apply()
|
||||
}
|
||||
|
||||
fun setNavTabHidden(context: Context, keys: Set<String>) {
|
||||
prefs(context).edit().putString("navTabHidden", keys.joinToString(",")).apply()
|
||||
@@ -620,14 +697,42 @@ object SessionPrefs {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun ensurePowerVrAutoDrivers(context: Context) {
|
||||
if (com.droiddeck.launcher.core.DeviceSupport.openDriverActive(context)) return
|
||||
ensurePowerVrAutoDrivers(context, SystemVulkanDriver.isPowerVr())
|
||||
fun ensurePowerVrAutoDrivers(context: Context) = reconcilePowerVrAutoDrivers(
|
||||
context, SystemVulkanDriver.isPowerVr(), SystemVulkanDriver.isXclipse(),
|
||||
com.droiddeck.launcher.gpu.VulkanInfo::cachedOrNull,
|
||||
)
|
||||
|
||||
fun ensurePowerVrAutoDriversAfterGpuQuery(context: Context) = reconcilePowerVrAutoDrivers(
|
||||
context, SystemVulkanDriver.isPowerVr(), SystemVulkanDriver.isXclipse(),
|
||||
com.droiddeck.launcher.gpu.VulkanInfo::query,
|
||||
)
|
||||
|
||||
internal fun reconcilePowerVrAutoDrivers(
|
||||
context: Context, powerVr: Boolean, xclipse: Boolean, vulkan: () -> Map<String, String>?,
|
||||
) {
|
||||
val device = if (xclipse) vulkan() ?: return else null
|
||||
val unsupported = unsupportedXclipse(xclipse) {
|
||||
com.droiddeck.launcher.gpu.GpuInfo.systemDriverName(SystemVulkanDriver.gpuName(), device)
|
||||
}
|
||||
val activeKey = com.droiddeck.launcher.gpu.DriverBundle.active(context)
|
||||
?.id
|
||||
?.let(com.droiddeck.launcher.gpu.DriverPairs::nonAdreno)
|
||||
val upstreamBundle = activeKey == com.droiddeck.launcher.gpu.DriverPairs.NAD_RADV_XCLIPSE_UPSTREAM ||
|
||||
(activeKey != null && activeKey.startsWith("${com.droiddeck.launcher.gpu.DriverPairs.NAD_RADV_XCLIPSE_UPSTREAM}-"))
|
||||
if (com.droiddeck.launcher.core.DeviceSupport.openDriverActive(context) && (!unsupported || upstreamBundle)) return
|
||||
ensurePowerVrAutoDrivers(context, powerVr, unsupported)
|
||||
}
|
||||
|
||||
internal fun ensurePowerVrAutoDrivers(context: Context, powerVr: Boolean) {
|
||||
internal fun unsupportedXclipse(xclipse: Boolean, gpuName: () -> String): Boolean =
|
||||
xclipse && com.droiddeck.launcher.gpu.DriverPairs.xclipseNeedsUpstream(gpuName())
|
||||
|
||||
internal fun ensurePowerVrAutoDrivers(context: Context, powerVr: Boolean, autoOwnedOnly: Boolean = false) {
|
||||
if (!powerVr || gpuDriverMode(context) != GPU_DRIVERS_AUTO) return
|
||||
prefs(context).edit().putString("linuxDriver", "").putString("androidDriver", TurnipDriver.AUTO).apply()
|
||||
val owned = gpuAutoInstalled(context)
|
||||
val edit = prefs(context).edit()
|
||||
if (!autoOwnedOnly || linuxDriver(context) in owned) edit.putString("linuxDriver", "")
|
||||
if (!autoOwnedOnly || androidDriver(context) in owned) edit.putString("androidDriver", TurnipDriver.AUTO)
|
||||
edit.apply()
|
||||
}
|
||||
|
||||
fun gpuAutoInstalled(context: Context): Set<String> =
|
||||
@@ -661,7 +766,7 @@ object SessionPrefs {
|
||||
}
|
||||
|
||||
private fun shaderPrecacheApplied(context: Context) =
|
||||
java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.bl-shader-precache-applied")
|
||||
java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.dd-shader-precache-applied")
|
||||
|
||||
fun pendingShaderPrecache(context: Context): Boolean? {
|
||||
val prefs = prefs(context)
|
||||
@@ -1493,7 +1598,7 @@ object SessionPrefs {
|
||||
}
|
||||
|
||||
val upscalerChoices = listOf(
|
||||
0 to "Linear", 2 to "Nearest", 4 to "AMD FSR 1", 3 to "Snapdragon GSR",
|
||||
2 to "Nearest", 0 to "Linear", 4 to "AMD FSR 1", 3 to "Snapdragon GSR",
|
||||
8 to "Snapdragon GSR (quality)", 7 to "NVIDIA NIS", 6 to "Sharpen only",
|
||||
)
|
||||
|
||||
@@ -1508,12 +1613,12 @@ object SessionPrefs {
|
||||
fun canonicalUpscaler(mode: Int): Int = when (mode) {
|
||||
1 -> 0
|
||||
5 -> 4
|
||||
else -> mode.takeIf { m -> upscalerChoices.any { it.first == m } } ?: 0
|
||||
else -> mode.takeIf { m -> upscalerChoices.any { it.first == m } } ?: 2
|
||||
}
|
||||
|
||||
fun upscalerHasSharpness(mode: Int): Boolean = canonicalUpscaler(mode) in 3..8
|
||||
|
||||
fun upscaler(context: Context): Int = canonicalUpscaler(prefs(context).getInt("upscaler", 0))
|
||||
fun upscaler(context: Context): Int = canonicalUpscaler(prefs(context).getInt("upscaler", 2))
|
||||
|
||||
fun setUpscaler(context: Context, mode: Int) {
|
||||
prefs(context).edit().putInt("upscaler", canonicalUpscaler(mode)).apply()
|
||||
|
||||
@@ -411,6 +411,7 @@ class SessionService : Service() {
|
||||
?.takeIf(GameLaunchLink::validId)
|
||||
?: steamUrlGameId
|
||||
SessionState.gameId = resolvedGameId
|
||||
SessionState.fpsLimit = SessionPrefs.savedFpsLimit(this, SessionPrefs.fpsLimitKey(SessionState.mode, resolvedGameId))
|
||||
SessionPrefs.setActiveScreenEffectsProfile(
|
||||
this,
|
||||
SessionPrefs.screenEffectsProfileId(SessionState.mode, resolvedGameId, SessionState.program),
|
||||
@@ -496,7 +497,7 @@ class SessionService : Service() {
|
||||
|
||||
|
||||
private fun runSession(gen: Int) {
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(this)
|
||||
SessionPrefs.ensurePowerVrAutoDriversAfterGpuQuery(this)
|
||||
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) {
|
||||
com.droiddeck.launcher.gpu.VulkanInfo.query()["api"]?.let { SessionPrefs.setHostVulkanApi(this, it) }
|
||||
if (SessionPrefs.venus(this)) VenusComponent.hostVulkanTooOld(this)?.let {
|
||||
@@ -611,7 +612,7 @@ class SessionService : Service() {
|
||||
stopSession(-1, gen)
|
||||
return
|
||||
}
|
||||
if (steamHere) guest.add("BL_EPIC_APP_ID=" + com.droiddeck.launcher.stores.epic.EpicClient.shortcutAppId)
|
||||
if (steamHere) guest.add("DD_EPIC_APP_ID=" + com.droiddeck.launcher.stores.epic.EpicClient.shortcutAppId)
|
||||
val fastPathAt = guest.size
|
||||
|
||||
val pulse = SessionEvents.step("audio") { startAudio(guest, sessionDir, directAudioPack) }
|
||||
@@ -623,36 +624,36 @@ class SessionService : Service() {
|
||||
val encoder = VideoEncodeBridge(File(filesDir, "venc/venc.sock"))
|
||||
encoder.attach(this)
|
||||
components.add(encoder)
|
||||
guest.add("BL_VENC_SOCKET=" + encoder.socket.absolutePath)
|
||||
guest.add("DD_VENC_SOCKET=" + encoder.socket.absolutePath)
|
||||
}
|
||||
com.droiddeck.launcher.gpu.ClockLogComponent(File(sessionDir, "clocks.log")).let {
|
||||
it.attach(this)
|
||||
components.add(it)
|
||||
}
|
||||
|
||||
guest.add("BL_WIDTH=" + size.first)
|
||||
guest.add("BL_HEIGHT=" + size.second)
|
||||
guest.add("DD_WIDTH=" + size.first)
|
||||
guest.add("DD_HEIGHT=" + size.second)
|
||||
if (noSteamGame()) runCatching {
|
||||
val scope = NoSteamLaunch.scopeOf(SessionState.program, SessionState.programArgs) { NoSteamLaunch.battleNetTitleScope(this, it) }
|
||||
NoSteamLaunch.resolution(GameEnvironmentStore.read(this), scope, size)
|
||||
}.onFailure { Log.w(TAG, "game resolution", it) }.getOrNull()?.let { (w, h) ->
|
||||
guest.add("BL_GAME_WIDTH=$w")
|
||||
guest.add("BL_GAME_HEIGHT=$h")
|
||||
guest.add("DD_GAME_WIDTH=$w")
|
||||
guest.add("DD_GAME_HEIGHT=$h")
|
||||
Log.i(TAG, "game resolution: ${w}x$h on a ${size.first}x${size.second} output")
|
||||
}
|
||||
if (SessionState.followScreen || size.first < size.second ||
|
||||
SessionPrefs.orientation(this) == android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
|
||||
guest.add("BL_FOLLOW_OUTPUT=1")
|
||||
guest.add("DD_FOLLOW_OUTPUT=1")
|
||||
if (SessionState.hdr) {
|
||||
guest.add("BL_HDR=1")
|
||||
guest.add("DD_HDR=1")
|
||||
guest.add("DXVK_HDR=1")
|
||||
Log.i(TAG, "hdr: gamescope --hdr-enabled, DXVK_HDR=1")
|
||||
}
|
||||
guest.add("DROIDDECK_WSI_BYPASS_CHECK_MS=100")
|
||||
guest.add("WINE_OFFSCREEN_CHECK_MS=100")
|
||||
guest.add("BL_REFRESH=" + Math.round(SessionState.refreshHz))
|
||||
guest.add("BL_LOG=" + sessionLog.path)
|
||||
guest.add("BL_DEBUG_DIR=" + sessionDir.path)
|
||||
guest.add("DD_REFRESH=" + Math.round(SessionState.refreshHz))
|
||||
guest.add("DD_LOG=" + sessionLog.path)
|
||||
guest.add("DD_DEBUG_DIR=" + sessionDir.path)
|
||||
if (EnhancedDiagnostics.isActive(this, sessionDir)) guest.add("DROIDDECK_ENHANCED_DIAGNOSTICS=1")
|
||||
|
||||
val fakeInputDir = File(sessionRoot, "dev/input").apply { mkdirs() }
|
||||
@@ -665,7 +666,7 @@ class SessionService : Service() {
|
||||
SessionEvents.step("controller-sync") { SessionState.padBridge?.syncConnectedControllers() }
|
||||
}
|
||||
val noSteamGame = noSteamGame()
|
||||
if (noSteamGame) guest.add("BL_PIN_CORES=0")
|
||||
if (noSteamGame) guest.add("DD_PIN_CORES=0")
|
||||
if ((steamHere || SessionState.program == NoSteamLaunch.EPIC) && com.droiddeck.launcher.stores.epic.EpicClient.read(this).installed) {
|
||||
runCatching { SessionEvents.step("epic-library") { com.droiddeck.launcher.stores.epic.EpicClientLibrary.sync(this) } }
|
||||
.onFailure { Log.w(TAG, "Epic library sync failed", it) }
|
||||
@@ -675,17 +676,19 @@ class SessionService : Service() {
|
||||
if (steamHere || noSteamGame) {
|
||||
val added = SessionEvents.step("added-games-scan") { com.droiddeck.launcher.frontend.AddedGames.scan(this) }
|
||||
val listing = SessionEvents.step("added-games-listing") { com.droiddeck.launcher.frontend.AddedGames.writeListing(this, added) }
|
||||
guest.add("BL_ADDED_GAMES=" + listing.path)
|
||||
if (OfflineMode.enabled(this)) guest.add("BL_STEAM_OFFLINE=1")
|
||||
if (com.droiddeck.launcher.gpu.Lossless.owned(this)) guest.add("BL_LOSSLESS_OWNED=1")
|
||||
guest.add("DD_ADDED_GAMES=" + listing.path)
|
||||
if (OfflineMode.enabled(this)) guest.add("DD_STEAM_OFFLINE=1")
|
||||
if (com.droiddeck.launcher.gpu.Lossless.owned(this)) guest.add("DD_LOSSLESS_OWNED=1")
|
||||
if (added.isNotEmpty()) Log.i(TAG, "added games: " + added.joinToString { "${it.name} (${it.exe.name})" })
|
||||
}
|
||||
guest.add("DD_LAUNCH_DIR=" + sessionRoot.path)
|
||||
// Proton builds up to 11.12 report X11 text fields under this name.
|
||||
guest.add("BL_LAUNCH_DIR=" + sessionRoot.path)
|
||||
GameStorage.effective(this)?.let { guest.add("BL_LIBRARY_LABEL=" + it.label.replace('"', ' ')) }
|
||||
if (SessionState.mode == MODE_STEAM && SessionState.steamUi == "desktop") guest.add("BL_STEAM_UI=desktop")
|
||||
GameStorage.effective(this)?.let { guest.add("DD_LIBRARY_LABEL=" + it.label.replace('"', ' ')) }
|
||||
if (SessionState.mode == MODE_STEAM && SessionState.steamUi == "desktop") guest.add("DD_STEAM_UI=desktop")
|
||||
// Detailed graphics logs: per-game logs and the guest's Vulkan summary (a GPU that is not
|
||||
// an Adreno, or Setup's switch), and graphics-report.txt for every session.
|
||||
if (GraphicsReport.detailed(this)) guest.add("BL_GAME_LOGS=1")
|
||||
if (GraphicsReport.detailed(this)) guest.add("DD_GAME_LOGS=1")
|
||||
SessionEvents.step("graphics-report") { GraphicsReport.begin(this, sessionDir, guest) }
|
||||
val shellGuest = ArrayList(guest).apply {
|
||||
add("SHELL=/bin/bash")
|
||||
@@ -872,8 +875,8 @@ class SessionService : Service() {
|
||||
if (!pulse.setSinkSuspended(false)) Log.w(TAG, "could not resume audio sink")
|
||||
if (!pulse.setMicSuspended(false)) Log.w(TAG, "could not resume microphone source")
|
||||
},
|
||||
zramControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.bl-zram"),
|
||||
clockControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.bl-clock"),
|
||||
zramControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.dd-zram"),
|
||||
clockControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.dd-clock"),
|
||||
mapClockControl = { WaylandCompositor.nativeSetClockControl(it.path) },
|
||||
pagedOut = { processes, unacknowledged, residentKb, swapKb, swapBeforeKb, millis ->
|
||||
Log.i(TAG, "paged out $processes processes ($unacknowledged unacknowledged) in $millis ms: " +
|
||||
@@ -942,16 +945,16 @@ class SessionService : Service() {
|
||||
} else {
|
||||
guest.add("LANG=C.UTF-8")
|
||||
}
|
||||
guest.add("BL_STEAM_LANGUAGE=" + SteamLanguage.forLocale(
|
||||
guest.add("DD_STEAM_LANGUAGE=" + SteamLanguage.forLocale(
|
||||
com.droiddeck.launcher.core.AppLanguage.effective(this),
|
||||
com.droiddeck.launcher.core.AppLanguage.system(this).country,
|
||||
))
|
||||
guest.add("TZ=" + java.util.TimeZone.getDefault().id)
|
||||
if (SessionState.mode == MODE_STEAM) SessionPrefs.pendingShaderPrecache(this)?.let { guest.add("BL_SHADER_PRECACHE=" + if (it) "1" else "0") }
|
||||
if (SessionState.mode == MODE_STEAM) SessionPrefs.pendingShaderPrecache(this)?.let { guest.add("DD_SHADER_PRECACHE=" + if (it) "1" else "0") }
|
||||
guest.add("XDG_RUNTIME_DIR=" + LinuxRuntime.GUEST_RUNTIME_DIR)
|
||||
guest.add("XDG_SESSION_TYPE=wayland")
|
||||
guest.add("WAYLAND_DISPLAY=wayland-0")
|
||||
guest.add("BL_ANDROID_CLIPBOARD=" + File(filesDir, "session/android-clipboard").path)
|
||||
guest.add("DD_ANDROID_CLIPBOARD=" + File(filesDir, "session/android-clipboard").path)
|
||||
guest.add("GAMESCOPE_FORCE_GENERAL_QUEUE=1")
|
||||
guest.add("MESA_LOADER_DRIVER_OVERRIDE=zink")
|
||||
guest.add("GALLIUM_DRIVER=zink")
|
||||
@@ -980,7 +983,7 @@ class SessionService : Service() {
|
||||
guest.add("XWAYLAND_NO_GLAMOR=1")
|
||||
Log.w(TAG, "xwayland: the last session's Xwayland crashed; glamor off for this one (XWAYLAND_NO_GLAMOR=1)")
|
||||
}
|
||||
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) guest.add("BL_RAISE_NOFILE=1")
|
||||
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) guest.add("DD_RAISE_NOFILE=1")
|
||||
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) {
|
||||
val kernel = System.getProperty("os.version").orEmpty()
|
||||
val old = kernelBefore(kernel, 6, 6)
|
||||
@@ -994,11 +997,11 @@ class SessionService : Service() {
|
||||
if (SessionPrefs.steamGpuCompositing(this)) {
|
||||
Log.i(TAG, "steam: GPU web compositing (Setup's \"Steam interface: GPU drawing\")")
|
||||
} else {
|
||||
guest.add("BL_STEAM_SOFT_COMPOSITING=1")
|
||||
guest.add("DD_STEAM_SOFT_COMPOSITING=1")
|
||||
Log.i(TAG, "steam: software web compositing for the open driver pair (GPU raster kept)")
|
||||
}
|
||||
guest.add("BL_OPEN_DRIVER=1")
|
||||
LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("BL_DRM_STANDIN=$it") }
|
||||
guest.add("DD_OPEN_DRIVER=1")
|
||||
LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("DD_DRM_STANDIN=$it") }
|
||||
}
|
||||
val tuOverride = tuDebugOverride()
|
||||
val tuDriver = sysmemDriver(linuxDriverId)
|
||||
@@ -1012,10 +1015,10 @@ class SessionService : Service() {
|
||||
guest.add("MESA_DISK_CACHE_DATABASE=1")
|
||||
guest.addAll(GpuStatsComponent.guestEnv(LinuxRuntime.rootDir(this)))
|
||||
guest.add("GLIBC_TUNABLES=glibc.pthread.rseq=0:glibc.malloc.top_pad=16777216")
|
||||
if (SessionState.mode == MODE_STEAM) guest.add("BL_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
|
||||
if (SessionState.mode == MODE_STEAM) guest.add("DD_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
|
||||
SessionState.steamClientArch = if (steamHere) SessionPrefs.steamClientArch(this) else null
|
||||
SessionState.steamClientArch?.let { arch ->
|
||||
guest.add("BL_STEAM_CLIENT_ARCH=$arch")
|
||||
guest.add("DD_STEAM_CLIENT_ARCH=$arch")
|
||||
SessionPaths.current()?.let {
|
||||
SessionArtifacts.recordClient(it, arch)
|
||||
SessionArtifacts.markSteamLogs(it, File(SessionPrefs.steamRoot(this, arch), "logs"))
|
||||
@@ -1023,23 +1026,23 @@ class SessionService : Service() {
|
||||
}
|
||||
FexCatalog.cached(this)?.let { guest.addAll(FexCatalog.environment(it)) }
|
||||
if (SessionState.mode == MODE_STEAM) {
|
||||
guest.add("BL_GAMESCOPE_STRETCH_16X9=" + (if (SessionPrefs.stretch16x9(this)) "1" else "0"))
|
||||
guest.add("DD_GAMESCOPE_STRETCH_16X9=" + (if (SessionPrefs.stretch16x9(this)) "1" else "0"))
|
||||
}
|
||||
if (SessionPrefs.noXalia(this)) guest.add("PROTON_USE_XALIA=0")
|
||||
guest.add("BL_SYNC=" + (if (SessionPrefs.fastSync(this)) "1" else "0"))
|
||||
guest.add("BL_SYNC_FALLBACK=" + (if (SessionPrefs.syncFallback(this)) "1" else "0"))
|
||||
guest.add("BL_FSYNC_FIRST=" + (if (SessionPrefs.fsyncFirst(this)) "1" else "0"))
|
||||
guest.add("BL_PACE_CORES=" + (if (SessionPrefs.paceCores(this)) "1" else "0"))
|
||||
guest.add("BL_GAMESCOPE_REALTIME=" + (if (SessionPrefs.gamescopeRealtime(this)) "1" else "0"))
|
||||
if (SessionPrefs.cursorComposite(this)) guest.add("BL_CURSOR_COMPOSITE=1")
|
||||
guest.add("DD_SYNC=" + (if (SessionPrefs.fastSync(this)) "1" else "0"))
|
||||
guest.add("DD_SYNC_FALLBACK=" + (if (SessionPrefs.syncFallback(this)) "1" else "0"))
|
||||
guest.add("DD_FSYNC_FIRST=" + (if (SessionPrefs.fsyncFirst(this)) "1" else "0"))
|
||||
guest.add("DD_PACE_CORES=" + (if (SessionPrefs.paceCores(this)) "1" else "0"))
|
||||
guest.add("DD_GAMESCOPE_REALTIME=" + (if (SessionPrefs.gamescopeRealtime(this)) "1" else "0"))
|
||||
if (SessionPrefs.cursorComposite(this)) guest.add("DD_CURSOR_COMPOSITE=1")
|
||||
relativeMouseForSession().takeIf { it != 0 }?.let { guest.add("gamescope_relative_mouse=$it") }
|
||||
if (com.droiddeck.launcher.core.ZramSupport.supported()) {
|
||||
guest.add("BL_ZRAM=1")
|
||||
if (steamHere) SessionPrefs.ramCapMb(this).takeIf { it > 0 }?.let { guest.add("BL_RAM_CAP_MB=$it") }
|
||||
if (!SessionPrefs.zramClient(this)) guest.add("BL_ZRAM_CLIENT=0")
|
||||
if (!SessionPrefs.zramIdle(this)) guest.add("BL_ZRAM_IDLE=0")
|
||||
guest.add("DD_ZRAM=1")
|
||||
if (steamHere) SessionPrefs.ramCapMb(this).takeIf { it > 0 }?.let { guest.add("DD_RAM_CAP_MB=$it") }
|
||||
if (!SessionPrefs.zramClient(this)) guest.add("DD_ZRAM_CLIENT=0")
|
||||
if (!SessionPrefs.zramIdle(this)) guest.add("DD_ZRAM_IDLE=0")
|
||||
}
|
||||
SessionPrefs.vramCapMb(this).takeIf { it > 0 }?.let { guest.add("BL_VRAM_MB=$it") }
|
||||
SessionPrefs.vramCapMb(this).takeIf { it > 0 }?.let { guest.add("DD_VRAM_MB=$it") }
|
||||
guest.add("AUDIO_DIRECT_DECAY=0")
|
||||
val extra = extraEnv() + agentEnvironment
|
||||
guest.addAll(TurnipEnvironment.gameEnvironment(tuOverride, tuDriver, SessionPrefs.tuSysmem(this), extra))
|
||||
@@ -1048,10 +1051,10 @@ class SessionService : Service() {
|
||||
com.droiddeck.launcher.gpu.TpUbwcHint.forThisDevice(this)?.let { guest.add("${com.droiddeck.launcher.gpu.TpUbwcHint.ENV}=$it") }
|
||||
val clientPinned = steamHere && SessionPrefs.clientCpusOverride(this)
|
||||
if (clientPinned) {
|
||||
guest.add("BL_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
|
||||
guest.add("DD_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
|
||||
}
|
||||
CpuCores.gameLaunchList(SessionPrefs.gameCpus(this), clientPinned)
|
||||
.takeIf { it.isNotEmpty() }?.let { guest.add("BL_GAME_CPUS=$it") }
|
||||
.takeIf { it.isNotEmpty() }?.let { guest.add("DD_GAME_CPUS=$it") }
|
||||
}
|
||||
|
||||
private fun startVkBridge(guest: MutableList<String>, sessionDir: File) {
|
||||
@@ -1060,16 +1063,16 @@ class SessionService : Service() {
|
||||
val bridge = com.droiddeck.launcher.gpu.VkBridgeComponent(socket, File(sessionDir, "vkbridge-server.log"))
|
||||
bridge.attach(this)
|
||||
components.add(bridge)
|
||||
guest.add("BL_VKBRIDGE=1")
|
||||
if (SessionPrefs.steamGpuCompositing(this)) guest.add("BL_STEAM_GPU_COMPOSITING=1")
|
||||
guest.add("DD_VKBRIDGE=1")
|
||||
if (SessionPrefs.steamGpuCompositing(this)) guest.add("DD_STEAM_GPU_COMPOSITING=1")
|
||||
SessionPrefs.linuxDriver(this).takeIf { it.isNotEmpty() }
|
||||
?.let { runCatching { LinuxVulkanDriver.resolveIcdPath(this, it) }.getOrNull() }
|
||||
?.let { guest.add("BL_VKBRIDGE_FALLBACK_ICD=$it") }
|
||||
?.let { guest.add("DD_VKBRIDGE_FALLBACK_ICD=$it") }
|
||||
guest.add("VKBRIDGE_SOCKET=" + socket.path)
|
||||
guest.add("VKBRIDGE_CLIENT_LOG=" + File(sessionDir, "vkbridge-client.log").path)
|
||||
guest.add("VKBRIDGE_MODE=" + SessionPrefs.vkBridgeMode(this))
|
||||
LinuxRuntime.gpuStandIn(this)?.let { node ->
|
||||
guest.add("BL_DRM_STANDIN=$node")
|
||||
guest.add("DD_DRM_STANDIN=$node")
|
||||
LinuxRuntime.deviceNumbers(node)?.let { guest.add("VKBRIDGE_DRM_RENDER=$it") }
|
||||
}
|
||||
Log.i(TAG, "vkbridge: on (${com.droiddeck.launcher.core.DeviceSupport.gpuName(this)}, ${SessionPrefs.vkBridgeMode(this)} mode), socket $socket")
|
||||
@@ -1083,7 +1086,7 @@ class SessionService : Service() {
|
||||
SessionPrefs.directAudio(this)
|
||||
val wantsMic = SessionPrefs.micEnabled(this) &&
|
||||
checkSelfPermission(android.Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED
|
||||
guest.add("BL_MIC_ENABLED=" + if (wantsMic) "1" else "0")
|
||||
guest.add("DD_MIC_ENABLED=" + if (wantsMic) "1" else "0")
|
||||
guest.add("AUDIO_DIRECT_MIC=" + if (wantsMic) "1" else "0")
|
||||
val audioDir = File(filesDir, "directaudio").apply { mkdirs() }
|
||||
val relaySocket = File(audioDir, "relay.sock")
|
||||
@@ -1111,7 +1114,7 @@ class SessionService : Service() {
|
||||
components.add(relay)
|
||||
}
|
||||
if (wantsDirectAudio) {
|
||||
guest.add("BL_DIRECTAUDIO=/" + SessionFiles.DIRECTAUDIO_DIR)
|
||||
guest.add("DD_DIRECTAUDIO=/" + SessionFiles.DIRECTAUDIO_DIR)
|
||||
guest.add("AUDIO_DIRECT_RELAY=" + relaySocket.absolutePath)
|
||||
val lowLatency = com.droiddeck.launcher.audio.DirectAudioTiming.lowLatencyOutput()
|
||||
val timing = com.droiddeck.launcher.audio.DirectAudioTiming.environment(lowLatency)
|
||||
@@ -1267,9 +1270,9 @@ class SessionService : Service() {
|
||||
)
|
||||
if (device != null) {
|
||||
val envAt = guest.indexOf(LinuxRuntime.SESSION_SCRIPT).takeIf { it >= 0 } ?: guest.size
|
||||
guest.add(envAt, "BL_STORAGE_DIAGNOSTICS=1")
|
||||
guest.add(envAt + 1, "BL_STORAGE_DEVICE=$device")
|
||||
guest.add(envAt + 2, "BL_STORAGE_LOG=${File(sessionDir, "storage.log").absolutePath}")
|
||||
guest.add(envAt, "DD_STORAGE_DIAGNOSTICS=1")
|
||||
guest.add(envAt + 1, "DD_STORAGE_DEVICE=$device")
|
||||
guest.add(envAt + 2, "DD_STORAGE_LOG=${File(sessionDir, "storage.log").absolutePath}")
|
||||
} else {
|
||||
Log.w(TAG, "storage diagnostics: selected library could not be identified; metadata snapshot only")
|
||||
}
|
||||
@@ -1414,7 +1417,7 @@ class SessionService : Service() {
|
||||
val listing = File(filesDir, "session/steam-libraries-x64.json").apply { parentFile?.mkdirs() }
|
||||
listing.writeText(x64Libraries.toString())
|
||||
val envAt = guest.indexOf(LinuxRuntime.SESSION_SCRIPT).takeIf { it >= 0 } ?: guest.size
|
||||
guest.add(envAt, "BL_X64_STEAM_LIBRARIES=" + listing.path)
|
||||
guest.add(envAt, "DD_X64_STEAM_LIBRARIES=" + listing.path)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "x86-64 steam library: the list could not be written; internal storage alone this session", e)
|
||||
}
|
||||
@@ -1424,10 +1427,32 @@ class SessionService : Service() {
|
||||
for ((path, label) in libraries) json.put(org.json.JSONObject().put("path", path).put("label", label.replace('"', ' ').replace('\\', ' ')))
|
||||
listing.writeText(json.toString())
|
||||
val envAt = guest.indexOf(LinuxRuntime.SESSION_SCRIPT).takeIf { it >= 0 } ?: guest.size
|
||||
guest.add(envAt, "BL_STEAM_LIBRARIES=" + listing.path)
|
||||
guest.add(envAt, "DD_STEAM_LIBRARIES=" + listing.path)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "steam library: the list could not be written; the card alone this session", e)
|
||||
}
|
||||
if (SessionState.mode == MODE_DESKTOP) {
|
||||
try {
|
||||
val listing = File(filesDir, "session/desktop-volumes.json").apply { parentFile?.mkdirs() }
|
||||
val volumes = org.json.JSONArray()
|
||||
var room = if (ProotFastPath.enabled(this)) {
|
||||
ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size
|
||||
} else Int.MAX_VALUE
|
||||
for (root in com.droiddeck.launcher.files.StorageRoots.list(this)) {
|
||||
if (!root.removable || !root.readable) continue
|
||||
val path = root.dir.absolutePath
|
||||
if (':' in path || '|' in path || room <= 0) continue
|
||||
binds.add(path)
|
||||
room--
|
||||
volumes.put(org.json.JSONObject().put("path", path).put("label", root.label))
|
||||
}
|
||||
listing.writeText(volumes.toString())
|
||||
val envAt = guest.indexOf(LinuxRuntime.SESSION_SCRIPT).takeIf { it >= 0 } ?: guest.size
|
||||
guest.add(envAt, "DD_DESKTOP_VOLUMES=" + listing.path)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "desktop volumes: the list could not be written", e)
|
||||
}
|
||||
}
|
||||
return binds
|
||||
}
|
||||
|
||||
@@ -2325,7 +2350,8 @@ class SessionService : Service() {
|
||||
override fun onTaskRemoved(rootIntent: Intent?) {
|
||||
if (rootIntent?.component?.className in setOf(
|
||||
com.droiddeck.launcher.ui.DualScreenActivity::class.java.name,
|
||||
com.droiddeck.launcher.ui.SessionTypingActivity::class.java.name)) return
|
||||
com.droiddeck.launcher.ui.SessionTypingActivity::class.java.name,
|
||||
KeepTopActivity::class.java.name)) return
|
||||
if (pipTask || xrActivityVisible) {
|
||||
Log.i(TAG, "panel task dismissed - retaining the session under its active surface policy")
|
||||
activityVisible = false
|
||||
|
||||
@@ -286,7 +286,7 @@ internal class SessionSuspendController(
|
||||
}
|
||||
val targets = records.values.filter { record ->
|
||||
try {
|
||||
File(procRoot, "${record.pid}/maps").useLines { lines -> lines.any { it.endsWith("/libblsession.so") } }
|
||||
File(procRoot, "${record.pid}/maps").useLines { lines -> lines.any { it.endsWith("/libddsession.so") } }
|
||||
} catch (_: IOException) {
|
||||
false
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ object SettingsReset {
|
||||
internal val SESSION_KEYS = setOf(
|
||||
"orientation", "launcherFullscreen", "animations", "lowStorageWarning", "theme", "runSteamAtStartup", "startupSession", "addedGamesArt",
|
||||
"dualScreenMode", "dualScreenSessionMode", "dualScreenLauncher", "dualScreenSessionControls", "androidTextFieldKeyboard",
|
||||
"gameStoresEnabled", "soundtracksEnabled", "soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature",
|
||||
"soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature",
|
||||
"storesInstallLanguage",
|
||||
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
|
||||
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
|
||||
"stretch16x9", "picturePosition", "integerScaling", "railLabels", "agentTab", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"stretch16x9", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
|
||||
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "paceCores", "ramCapMb", "vramCapMb", "zramClient", "zramIdle",
|
||||
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
|
||||
|
||||
@@ -115,7 +115,7 @@ internal class SteamDownloadMonitor {
|
||||
val steam = File(home, ".local/share/Steam")
|
||||
val stamped = File(steam, "package/droiddeck-installed").isFile ||
|
||||
File(steam, "package/bannerlator-installed").isFile
|
||||
return !(stamped && File(steam, "steamrtarm64/steam").isFile) || File(home, ".bl-steam-repair").exists()
|
||||
return !(stamped && File(steam, "steamrtarm64/steam").isFile) || File(home, ".dd-steam-repair").exists()
|
||||
}
|
||||
|
||||
internal fun manifests(runtimeRoot: File, mounts: Map<String, File>): List<File> {
|
||||
|
||||
@@ -40,8 +40,9 @@ object SteamGameProcess {
|
||||
val appId = args.getOrNull(i + 1)
|
||||
?.takeIf { it.startsWith("AppId=") }
|
||||
?.removePrefix("AppId=")
|
||||
val launchOptions = args.drop(i + 2).takeWhile { it != "--" }
|
||||
|
||||
if (appId == expectedAppId) return true
|
||||
if (appId == expectedAppId && "Install=1" !in launchOptions) return true
|
||||
}
|
||||
|
||||
if (args[i] == "-applaunch" &&
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.io.File
|
||||
|
||||
object SteamRepair {
|
||||
private fun home(context: Context) = File(LinuxRuntime.rootDir(context), "root")
|
||||
private fun request(context: Context) = File(home(context), ".bl-steam-repair")
|
||||
private fun request(context: Context) = File(home(context), ".dd-steam-repair")
|
||||
private fun unconfirmed(context: Context) = File(home(context), ".local/share/Steam/package/droiddeck-unconfirmed")
|
||||
private fun x64Unconfirmed(context: Context) = File(home(context), ".droiddeck-x64/.local/share/Steam/package/droiddeck-unconfirmed")
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.ComponentCallbacks2
|
||||
|
||||
internal object TopUnderPressure {
|
||||
const val WINDOW_MS = 5_000L
|
||||
|
||||
fun isPressure(level: Int) =
|
||||
level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL || level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW
|
||||
|
||||
fun shouldReclaim(nowMs: Long, pressureAtMs: Long, sessionRunning: Boolean, finishing: Boolean) =
|
||||
sessionRunning && !finishing && pressureAtMs > 0 && nowMs - pressureAtMs in 0..WINDOW_MS
|
||||
}
|
||||
@@ -102,7 +102,7 @@ class VenusComponent(private val logFile: File?) : SessionPart() {
|
||||
// (Steam's GL, Xwayland's glamor) requires robustness2's nullDescriptor, which the
|
||||
// layer stands in for. The session script checks it and falls back to llvmpipe.
|
||||
"DROIDDECK_MALI_COMPAT=1",
|
||||
"BL_VENUS=1",
|
||||
"DD_VENUS=1",
|
||||
// gamescope's composite layout without immutable YCbCr samplers from the start
|
||||
// (patch 0930): a Mali-G615 refused every composite pipeline with them, and testing
|
||||
// that through Venus took the render server down.
|
||||
|
||||
@@ -5,6 +5,11 @@ import android.content.SharedPreferences
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.frontend.AddedGames
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.stores.ea.EaAuth
|
||||
import com.droiddeck.launcher.stores.ea.EaCloud
|
||||
import com.droiddeck.launcher.stores.ea.EaLibrary
|
||||
import com.droiddeck.launcher.stores.ea.EaPrefs
|
||||
import com.droiddeck.launcher.stores.ea.EaSaveRules
|
||||
import com.droiddeck.launcher.stores.epic.EpicApiClient
|
||||
import com.droiddeck.launcher.stores.epic.EpicCredentialStore
|
||||
import com.droiddeck.launcher.stores.epic.EpicPrefs
|
||||
@@ -32,7 +37,7 @@ object CloudSaves {
|
||||
if (detail.isNotEmpty()) " detail=\"$detail\"" else ""
|
||||
}
|
||||
|
||||
class Status(val supported: Boolean, val folder: File?, val lastSync: Long, val reason: String, val conflicts: List<String> = emptyList())
|
||||
class Status(val supported: Boolean, val folder: File?, val lastSync: Long, val reason: String, val conflicts: List<String> = emptyList(), val signedIn: Boolean = true)
|
||||
|
||||
private fun game(context: Context, store: Store, id: String): Pair<File, StoreGameSidecar>? =
|
||||
StoreInstallRoot.gameFolders(context).firstNotNullOfOrNull { f ->
|
||||
@@ -44,7 +49,13 @@ object CloudSaves {
|
||||
return Library.protonPrefix(context, appId and 0xFFFFFFFFL)
|
||||
}
|
||||
|
||||
private fun prefs(context: Context, store: Store) = if (store == Store.GOG) GogPrefs.get(context) else EpicPrefs.get(context)
|
||||
fun supports(store: Store?): Boolean = store == Store.GOG || store == Store.EPIC || store == Store.EA
|
||||
|
||||
private fun prefs(context: Context, store: Store) = when (store) {
|
||||
Store.GOG -> GogPrefs.get(context)
|
||||
Store.EA -> EaPrefs.get(context)
|
||||
else -> EpicPrefs.get(context)
|
||||
}
|
||||
|
||||
fun lastSync(context: Context, store: Store, id: String): Long = prefs(context, store).getLong("cloud_sync_$id", 0L)
|
||||
|
||||
@@ -64,6 +75,10 @@ object CloudSaves {
|
||||
|
||||
fun template(context: Context, store: Store, id: String, folder: File, sidecar: StoreGameSidecar): String? {
|
||||
val p = prefs(context, store)
|
||||
if (store == Store.EA) eaRules(context, id)?.let { fresh ->
|
||||
if (fresh.isEmpty()) rememberNoCloud(p, id) else p.edit().putString("cloud_template_$id", fresh).remove("cloud_template_at_$id").apply()
|
||||
return fresh
|
||||
}
|
||||
var retryNone = false
|
||||
if (p.contains("cloud_template_$id")) {
|
||||
val cached = p.getString("cloud_template_$id", "") ?: ""
|
||||
@@ -89,7 +104,8 @@ object CloudSaves {
|
||||
val item = sidecar.extra["catalogItemId"].orEmpty()
|
||||
if (ns.isEmpty() || item.isEmpty()) "" else EpicApiClient.getCustomAttribute(token, ns, item, "CloudSaveFolder")
|
||||
}
|
||||
Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.EA, Store.UBISOFT, Store.ROCKSTAR -> ""
|
||||
Store.EA -> eaRules(context, id) ?: return null
|
||||
Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR -> ""
|
||||
} ?: return null
|
||||
p.edit()
|
||||
.putString("cloud_template_$id", fetched.ifEmpty { TEMPLATE_NONE })
|
||||
@@ -150,14 +166,16 @@ object CloudSaves {
|
||||
val dir = when (store) {
|
||||
Store.GOG -> CloudSavePaths.gog(template, pfx, folder)
|
||||
Store.EPIC -> CloudSavePaths.epic(template, pfx, folder, EpicCredentialStore.load(context)?.accountId.orEmpty(), id)
|
||||
Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.EA, Store.UBISOFT, Store.ROCKSTAR -> null
|
||||
Store.EA -> if (sidecar.extra["masterTitleId"].isNullOrEmpty()) null
|
||||
else EaSaveRules.parse(template)?.base()?.let(EaSaveRules::template)?.let { CloudSavePaths.gog(it, pfx, folder) }
|
||||
Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR -> null
|
||||
}
|
||||
return dir to (if (dir == null) "unresolved" else "ok")
|
||||
}
|
||||
|
||||
fun status(context: Context, store: Store, id: String): Status {
|
||||
val (dir, reason) = saveFolder(context, store, id)
|
||||
return Status(reason != "no-cloud-saves" && reason != "not-installed", dir, lastSync(context, store, id), reason, conflicts(context, store, id))
|
||||
return Status(reason != "no-cloud-saves" && reason != "not-installed", dir, lastSync(context, store, id), reason, conflicts(context, store, id), signedIn(context, store))
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +193,28 @@ object CloudSaves {
|
||||
val account = EpicCredentialStore.load(context)?.accountId.orEmpty()
|
||||
if (token == null || account.isEmpty()) null else EpicCloud(account, id, token)
|
||||
}
|
||||
Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.EA, Store.UBISOFT, Store.ROCKSTAR -> null
|
||||
Store.EA -> {
|
||||
val sidecar = StoreGameSidecar.read(folder)
|
||||
val rules = sidecar?.let { template(context, store, id, folder, it) }?.let(EaSaveRules::parse)
|
||||
val base = rules?.base()
|
||||
val token = EaAuth.accessToken(context)
|
||||
val uid = EaAuth.load(context)?.userId.orEmpty()
|
||||
val master = sidecar?.extra?.get("masterTitleId").orEmpty()
|
||||
if (rules == null || base == null || token == null || uid.isEmpty() || master.isEmpty()) null
|
||||
else EaCloud(token, uid, EaCloud.keys(master, sidecar?.extra?.get("multiplayerId").orEmpty()), base, rules, saveFolder(context, store, id).first)
|
||||
}
|
||||
Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR -> null
|
||||
}
|
||||
|
||||
private fun signedIn(context: Context, store: Store): Boolean = when (store) {
|
||||
Store.EA -> EaAuth.signedIn(context)
|
||||
else -> true
|
||||
}
|
||||
|
||||
private fun eaRules(context: Context, id: String): String? {
|
||||
val games = EaLibrary.cached(context)
|
||||
if (games.isEmpty()) return null
|
||||
return games.firstOrNull { it.offerId == id }?.cloudSaves.orEmpty()
|
||||
}
|
||||
|
||||
private fun gogScopedToken(context: Context, id: String, clientId: String): String? {
|
||||
@@ -305,7 +344,10 @@ object CloudSaves {
|
||||
val cloud = if (dir != null) transport(context, store, id, g.first) else null
|
||||
when {
|
||||
dir == null -> Result("skipped", 0, 0, reason)
|
||||
cloud == null && store == Store.EA && signedIn(context, store) -> Result("failed", 0, 0, "sign-in-unreachable")
|
||||
cloud == null -> Result("skipped", 0, 0, "not-signed-in")
|
||||
cloud is EaCloud && cloud.localDir?.canonicalPath != dir.canonicalPath -> Result("skipped", 0, 0, "rules-changed")
|
||||
cloud is EaCloud && localFiles(dir).keys.groupBy { it.lowercase() }.any { it.value.size > 1 } -> Result("failed", 0, 0, "case-collision")
|
||||
else -> body(dir, cloud).also { if (it.result == "ok") markSynced(context, store, id) }
|
||||
}
|
||||
}
|
||||
@@ -325,9 +367,23 @@ object CloudSaves {
|
||||
return r
|
||||
}
|
||||
|
||||
private fun localFiles(dir: File): Map<String, File> =
|
||||
if (!dir.isDirectory) emptyMap()
|
||||
else dir.walkTopDown().filter { it.isFile }.associateBy { it.relativeTo(dir).path.replace(File.separatorChar, '/') }
|
||||
private fun localFiles(dir: File): Map<String, File> {
|
||||
if (!dir.isDirectory) return emptyMap()
|
||||
val root = runCatching { dir.toPath().toRealPath() }.getOrNull() ?: return emptyMap()
|
||||
val found = LinkedHashMap<String, File>()
|
||||
fun walk(d: File, prefix: String, ancestry: Set<java.nio.file.Path>) {
|
||||
for (child in d.listFiles().orEmpty()) {
|
||||
val real = runCatching { child.toPath().toRealPath() }.getOrNull() ?: continue
|
||||
if (!real.startsWith(root)) continue
|
||||
val name = prefix + child.name
|
||||
if (child.isDirectory) {
|
||||
if (real !in ancestry) walk(child, "$name/", ancestry + real)
|
||||
} else if (child.isFile) found[name] = child
|
||||
}
|
||||
}
|
||||
walk(dir, "", setOf(root))
|
||||
return found
|
||||
}
|
||||
|
||||
internal fun md5(f: File): String = md5(f.readBytes())
|
||||
|
||||
@@ -342,13 +398,17 @@ object CloudSaves {
|
||||
}
|
||||
|
||||
internal fun downWith(context: Context, store: Store, id: String, dir: File, cloud: CloudTransport, force: Boolean): Result {
|
||||
val files = localFiles(dir)
|
||||
val files = localFiles(dir).filterKeys(cloud::wants)
|
||||
val remote = remote(cloud) { it in files }
|
||||
val local = files.mapValues { CloudPlan.Local(md5(it.value)) }
|
||||
val base = baseline(context, store, id)
|
||||
val plan = CloudPlan.down(local, remote.mapValues { CloudPlan.Remote(it.value.md5, it.value.modifiedMs) }, base)
|
||||
val take = if (force) plan.transfer + plan.conflicts else plan.transfer
|
||||
if (take.isNotEmpty() && files.isNotEmpty()) backup(context, store, id, dir, "local")
|
||||
val inside = dir.canonicalPath + File.separator
|
||||
val replaced = take.mapNotNull { name ->
|
||||
files[name] ?: File(dir, name).takeIf { it.isFile && runCatching { it.canonicalPath.startsWith(inside) }.getOrDefault(false) }
|
||||
}
|
||||
if (!backupReplaced(context, store, id, dir, replaced)) return Result("failed", 0, 0, "backup-failed")
|
||||
val next = HashMap(base.orEmpty())
|
||||
var bytes = 0L
|
||||
for (name in take) {
|
||||
@@ -371,7 +431,7 @@ object CloudSaves {
|
||||
|
||||
internal fun upWith(context: Context, store: Store, id: String, dir: File, cloud: CloudTransport, force: Boolean): Result {
|
||||
val base = baseline(context, store, id) ?: return Result("skipped", 0, 0, "no-baseline")
|
||||
val files = localFiles(dir)
|
||||
val files = localFiles(dir).filterKeys(cloud::wants)
|
||||
if (files.isEmpty()) return Result("skipped", 0, 0, "nothing-local")
|
||||
val remote = remote(cloud) { it in files }
|
||||
val local = files.mapValues { CloudPlan.Local(md5(it.value)) }
|
||||
@@ -397,9 +457,9 @@ object CloudSaves {
|
||||
stamped += cloud.put(data, send.associateWith { files.getValue(it).lastModified() })
|
||||
for ((name, t) in stamped) if (t > 0) files[name]?.setLastModified(t)
|
||||
}
|
||||
val after = remote(cloud) { it in send }
|
||||
val after = if (send.all { cloud.committed(it) != null }) emptyMap() else remote(cloud) { it in send && cloud.committed(it) == null }
|
||||
for (name in send) {
|
||||
val r = after[name]
|
||||
val r = cloud.committed(name) ?: after[name]
|
||||
next[name] = CloudPlan.Entry(sentMd5.getValue(name), r?.md5, r?.modifiedMs ?: stamped[name] ?: -1L)
|
||||
}
|
||||
}
|
||||
@@ -441,10 +501,11 @@ object CloudSaves {
|
||||
private fun backupRoot(context: Context, store: Store, id: String) =
|
||||
File(context.filesDir, "stores/cloud-backups/${store.id}-${id.replace(Regex("[^A-Za-z0-9._-]"), "_")}")
|
||||
|
||||
private fun backup(context: Context, store: Store, id: String, dir: File, kind: String) {
|
||||
private fun backup(context: Context, store: Store, id: String, dir: File, kind: String): Boolean {
|
||||
val root = backupRoot(context, store, id)
|
||||
runCatching { dir.copyRecursively(File(root, "$kind-${System.currentTimeMillis()}"), overwrite = true) }
|
||||
val copied = runCatching { dir.copyRecursively(File(root, "$kind-${System.currentTimeMillis()}"), overwrite = true) }.getOrDefault(false)
|
||||
prune(root, kind)
|
||||
return copied
|
||||
}
|
||||
|
||||
private fun backupCloud(context: Context, store: Store, id: String, cloud: CloudTransport, files: List<CloudFile>) {
|
||||
@@ -460,6 +521,27 @@ object CloudSaves {
|
||||
prune(root, "cloud")
|
||||
}
|
||||
|
||||
private fun backupReplaced(context: Context, store: Store, id: String, dir: File, replaced: List<File>): Boolean {
|
||||
if (replaced.isEmpty()) return true
|
||||
val base = runCatching { dir.canonicalPath + File.separator }.getOrNull() ?: return false
|
||||
val root = backupRoot(context, store, id)
|
||||
val stamp = "${System.currentTimeMillis()}-${java.util.UUID.randomUUID().toString().take(8)}"
|
||||
val staging = File(root, "staging-$stamp")
|
||||
val copied = runCatching {
|
||||
for (f in replaced) {
|
||||
check(f.canonicalPath.startsWith(base))
|
||||
f.copyTo(File(staging, f.relativeTo(dir).path), overwrite = true)
|
||||
}
|
||||
check(staging.renameTo(File(root, "local-$stamp")))
|
||||
}.isSuccess
|
||||
if (!copied) {
|
||||
staging.deleteRecursively()
|
||||
return false
|
||||
}
|
||||
prune(root, "local")
|
||||
return true
|
||||
}
|
||||
|
||||
private fun prune(root: File, kind: String) {
|
||||
root.listFiles { f -> f.name.startsWith("$kind-") }?.sortedByDescending { it.name }?.drop(BACKUPS)?.forEach { it.deleteRecursively() }
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ class CloudFile(val name: String, var modifiedMs: Long, var md5: String? = null,
|
||||
class CloudPut(val modifiedMs: Long, val md5: String?)
|
||||
|
||||
interface CloudTransport {
|
||||
fun wants(name: String): Boolean = true
|
||||
fun committed(name: String): CloudFile? = null
|
||||
fun list(): List<CloudFile>
|
||||
fun details(file: CloudFile) {}
|
||||
fun get(file: CloudFile): Pair<ByteArray, Long>
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.droiddeck.launcher.stores
|
||||
|
||||
enum class Store(val id: String, val label: String, val shortLabel: String) {
|
||||
GOG("gog", "GOG", "GOG"),
|
||||
EPIC("epic", "Epic Games", "Epic"),
|
||||
AMAZON("amazon", "Amazon Games", "Amazon"),
|
||||
XBOX("xbox", "Xbox", "Xbox"),
|
||||
ITCH("itch", "Itch.io", "Itch.io"),
|
||||
GAMEJOLT("gamejolt", "Game Jolt", "Game Jolt"),
|
||||
BATTLENET("battlenet", "Battle.net", "Battle.net"),
|
||||
UBISOFT("ubisoft", "Ubisoft Connect", "Ubisoft"),
|
||||
EA("ea", "EA", "EA"),
|
||||
ROCKSTAR("rockstar", "Rockstar Games", "Rockstar");
|
||||
XBOX("xbox", "Xbox", "Xbox"),
|
||||
GOG("gog", "GOG", "GOG"),
|
||||
ROCKSTAR("rockstar", "Rockstar Games", "Rockstar"),
|
||||
ITCH("itch", "Itch.io", "Itch.io"),
|
||||
UBISOFT("ubisoft", "Ubisoft Connect", "Ubisoft"),
|
||||
AMAZON("amazon", "Amazon Games", "Amazon"),
|
||||
BATTLENET("battlenet", "Battle.net", "Battle.net"),
|
||||
GAMEJOLT("gamejolt", "Game Jolt", "Game Jolt");
|
||||
|
||||
val folder: String get() = if (this == ITCH) "itch" else shortLabel
|
||||
|
||||
|
||||
@@ -58,7 +58,11 @@ object StoreLaunchRequests {
|
||||
}
|
||||
"xbox-renew" -> JSONObject().put("ok", com.droiddeck.launcher.stores.xbox.XboxRuntime.renew(app, request.optString("id"), request.optString("lease")))
|
||||
"xbox-prepare" -> runCatching { com.droiddeck.launcher.stores.xbox.XboxRuntime.prepare(app, request.getString("id")) }
|
||||
.getOrElse { JSONObject().put("ok", false).put("reason", "Xbox account service is unavailable. Sign in again and retry.") }
|
||||
.getOrElse {
|
||||
StoresState.logLine("Xbox: launch prepare failed (${it.javaClass.simpleName}: ${it.message})")
|
||||
val reason = (it as? IllegalStateException)?.message ?: "Xbox account service is unavailable. Sign in again and retry."
|
||||
JSONObject().put("ok", false).put("reason", reason)
|
||||
}
|
||||
"ea-prepare" -> runCatching { lastLaunched = Store.EA to request.optString("id"); com.droiddeck.launcher.stores.ea.EaLaunch.prepare(app, request) }
|
||||
.getOrElse { JSONObject().put("ok", false).put("reason", "error-" + it.javaClass.simpleName) }
|
||||
"ea-exited" -> {
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.droiddeck.launcher.stores
|
||||
|
||||
import android.content.Context
|
||||
import java.io.File
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
internal object StoreLibraryCache {
|
||||
private fun file(context: Context, store: Store) = File(context.filesDir, "store-library/${store.id}.json")
|
||||
|
||||
fun load(context: Context, store: Store): List<CatalogItem>? {
|
||||
val f = file(context, store)
|
||||
if (!f.isFile) return null
|
||||
return runCatching { decode(store, f.readText()) }.getOrNull()
|
||||
}
|
||||
|
||||
private val locks = Store.entries.associateWith { Any() }
|
||||
|
||||
fun save(context: Context, store: Store, items: List<CatalogItem>, current: () -> Boolean) = synchronized(locks.getValue(store)) {
|
||||
if (!current()) return@synchronized
|
||||
val f = file(context, store)
|
||||
runCatching {
|
||||
f.parentFile?.mkdirs()
|
||||
val tmp = File(f.parentFile, f.name + ".tmp")
|
||||
tmp.writeText(encode(items))
|
||||
if (!tmp.renameTo(f)) { f.delete(); tmp.renameTo(f) }
|
||||
}
|
||||
}
|
||||
|
||||
fun clear(context: Context, store: Store) = synchronized(locks.getValue(store)) {
|
||||
file(context, store).delete()
|
||||
}
|
||||
|
||||
internal fun encode(items: List<CatalogItem>): String {
|
||||
val out = JSONArray()
|
||||
items.forEach { i ->
|
||||
out.put(JSONObject()
|
||||
.put("id", i.id).put("title", i.title)
|
||||
.put("image", i.imageUrl ?: "").put("tall", i.tallImageUrl ?: "").put("logo", i.logoUrl ?: "")
|
||||
.put("tags", i.tags).put("free", i.isFree).put("hasPrice", i.hasPrice)
|
||||
.put("finalPrice", i.finalPrice).put("originalPrice", i.originalPrice).put("discount", i.discountPercent)
|
||||
.put("url", i.storeUrl).put("developer", i.developer).put("publisher", i.publisher)
|
||||
.put("releaseDate", i.releaseDate).put("description", i.description)
|
||||
.put("owned", i.owned).put("size", i.sizeBytes).put("extra", JSONObject(i.extra))
|
||||
.put("mature", i.mature).put("subscription", i.subscription).put("includedWith", i.includedWith))
|
||||
}
|
||||
return out.toString()
|
||||
}
|
||||
|
||||
internal fun decode(store: Store, text: String): List<CatalogItem> {
|
||||
val raw = JSONArray(text)
|
||||
return (0 until raw.length()).mapNotNull { n ->
|
||||
val o = raw.optJSONObject(n) ?: return@mapNotNull null
|
||||
val extra = o.optJSONObject("extra")
|
||||
val map = HashMap<String, String>()
|
||||
extra?.keys()?.forEach { k -> map[k] = extra.optString(k) }
|
||||
CatalogItem(
|
||||
store = store, id = o.optString("id"), title = o.optString("title"),
|
||||
imageUrl = o.optString("image").ifBlank { null }, tallImageUrl = o.optString("tall").ifBlank { null },
|
||||
logoUrl = o.optString("logo").ifBlank { null },
|
||||
tags = o.optString("tags"), isFree = o.optBoolean("free"), hasPrice = o.optBoolean("hasPrice"),
|
||||
finalPrice = o.optString("finalPrice"), originalPrice = o.optString("originalPrice"), discountPercent = o.optInt("discount"),
|
||||
storeUrl = o.optString("url"), developer = o.optString("developer"), publisher = o.optString("publisher"),
|
||||
releaseDate = o.optString("releaseDate"), description = o.optString("description"),
|
||||
owned = o.optBoolean("owned"), sizeBytes = o.optLong("size"), extra = map,
|
||||
mature = o.optBoolean("mature"), subscription = o.optBoolean("subscription"), includedWith = o.optString("includedWith"),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,15 +156,6 @@ class StoreLoginActivity : ComponentActivity() {
|
||||
setTextColor(0xFFF2F4F7.toInt()); textSize = 16f; setPadding(dp(16), 0, dp(8), 0)
|
||||
layoutParams = LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)
|
||||
}
|
||||
val browser = Button(this, null, android.R.attr.borderlessButtonStyle).apply {
|
||||
text = getString(R.string.stores_login_in_browser); setTextColor(0xFFF2F4F7.toInt()); isAllCaps = false
|
||||
visibility = if (store == Store.EPIC && clientUrl == null) View.VISIBLE else View.GONE
|
||||
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dp(48))
|
||||
setOnClickListener {
|
||||
com.droiddeck.launcher.stores.epic.EpicCodeLogin.begin(this@StoreLoginActivity)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
val reload = ImageButton(this).apply {
|
||||
setImageResource(android.R.drawable.ic_menu_rotate); setBackgroundColor(Color.TRANSPARENT)
|
||||
contentDescription = getString(R.string.stores_login_reload); layoutParams = LinearLayout.LayoutParams(dp(48), dp(48))
|
||||
@@ -176,7 +167,7 @@ class StoreLoginActivity : ComponentActivity() {
|
||||
setOnClickListener { finish() }
|
||||
}
|
||||
topBar = bar; reloadButton = reload; closeButton = close
|
||||
bar.addView(titleText); bar.addView(browser); bar.addView(reload); bar.addView(close)
|
||||
bar.addView(titleText); bar.addView(reload); bar.addView(close)
|
||||
progressBar = ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal).apply {
|
||||
max = 100; isIndeterminate = false
|
||||
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp(3))
|
||||
|
||||
@@ -27,13 +27,20 @@ object StoreSizes {
|
||||
|
||||
fun size(item: CatalogItem): Long = known[item.key] ?: item.sizeBytes
|
||||
|
||||
private val NO_REMOTE_SIZE = setOf(Store.GOG, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR)
|
||||
private val settled = mutableStateMapOf<String, Boolean>()
|
||||
|
||||
// A size that can still arrive this session: not known yet, the store can report one, and no lookup came back empty.
|
||||
fun coming(item: CatalogItem): Boolean =
|
||||
item.accessible && item.sizeBytes <= 0 && item.store !in NO_REMOTE_SIZE && !known.containsKey(item.key) && settled[item.key] != true
|
||||
|
||||
private val caches = ConcurrentHashMap<Store, SizeCache>()
|
||||
private fun cache(context: Context, store: Store) = caches.getOrPut(store) { SizeCache.forStore(context.applicationContext.filesDir, store) }
|
||||
|
||||
fun request(context: Context, item: CatalogItem) {
|
||||
if (!item.accessible || item.sizeBytes > 0 || item.store == Store.GOG || known.containsKey(item.key)) return
|
||||
resolve(context, item).thenAccept { bytes ->
|
||||
if (bytes != null) StoresState.post { known[item.key] = bytes }
|
||||
resolve(context, item).whenComplete { bytes, _ ->
|
||||
StoresState.post { if (bytes != null && bytes > 0) known[item.key] = bytes else settled[item.key] = true }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +202,7 @@ object StoresState {
|
||||
backend?.signOut(app)
|
||||
if (store == Store.GOG) com.droiddeck.launcher.stores.gog.GogComet.replaceAccount { StoreAccounts.clear(app, store) }
|
||||
else if (store != Store.XBOX || backend == null) StoreAccounts.clear(app, store)
|
||||
StoreLibraryCache.clear(app, store)
|
||||
if (store == Store.GAMEJOLT) {
|
||||
com.droiddeck.launcher.stores.gamejolt.GameJoltCollections.clear()
|
||||
com.droiddeck.launcher.stores.gamejolt.GameJoltUpdates.clear(app)
|
||||
|
||||
@@ -17,7 +17,7 @@ object EaAuth {
|
||||
const val CLIENT_ID = "JUNO_PC_CLIENT"
|
||||
private const val CLIENT_SECRET = "4mRLtYMb6vq9qglomWEaT4ChxsXWcyqbQpuBNfMPOYOiDmYYQmjuaBsF2Zp0RyVeWkfqhE9TuGgAw7te"
|
||||
const val AUTH_URL = "https://accounts.ea.com/connect/auth"
|
||||
private const val TOKEN_URL = "https://accounts.ea.com/connect/token"
|
||||
internal var tokenUrl = "https://accounts.ea.com/connect/token"
|
||||
const val REDIRECT = "qrc:///html/login_successful.html"
|
||||
private const val REFRESH_MARGIN_MS = 5 * 60 * 1000L
|
||||
private val refreshLock = Any()
|
||||
@@ -41,8 +41,11 @@ object EaAuth {
|
||||
val personaId: String,
|
||||
val displayName: String,
|
||||
val eaId: String,
|
||||
val rejected: Boolean = false,
|
||||
)
|
||||
|
||||
private class Rejected(message: String) : IllegalStateException(message)
|
||||
|
||||
class Pending(val url: String, val verifier: String)
|
||||
|
||||
internal fun fromJson(o: JSONObject): Account? {
|
||||
@@ -55,6 +58,7 @@ object EaAuth {
|
||||
personaId = o.optString("persona_id"),
|
||||
displayName = o.optString("display_name"),
|
||||
eaId = o.optString("ea_id"),
|
||||
rejected = o.optBoolean("refresh_rejected"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -122,14 +126,15 @@ object EaAuth {
|
||||
|
||||
private fun tokenCall(values: List<Pair<String, String>>): JSONObject {
|
||||
val reply = EaHttp.request(
|
||||
TOKEN_URL, "POST",
|
||||
tokenUrl, "POST",
|
||||
mapOf("Content-Type" to "application/x-www-form-urlencoded"),
|
||||
EaHttp.form(values + listOf("client_id" to CLIENT_ID, "client_secret" to CLIENT_SECRET)).toByteArray(),
|
||||
follow = false,
|
||||
)
|
||||
val json = runCatching { JSONObject(reply.text) }.getOrNull()
|
||||
if (!reply.ok || json == null || json.optString("access_token").isEmpty()) {
|
||||
throw IllegalStateException("EA token request failed (${reply.status}): ${json?.optString("error_description")?.ifEmpty { json.optString("error") } ?: ""}")
|
||||
val message = "EA token request failed (${reply.status}): ${json?.optString("error_description")?.ifEmpty { json.optString("error") } ?: ""}"
|
||||
throw if (reply.status == 400 || reply.status == 401 || reply.status == 403) Rejected(message) else IllegalStateException(message)
|
||||
}
|
||||
return json
|
||||
}
|
||||
@@ -162,6 +167,7 @@ object EaAuth {
|
||||
tokenCall(listOf("grant_type" to "refresh_token", "refresh_token" to a.refreshToken))
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "refresh: ${e.message}")
|
||||
if (e is Rejected) markRejected(context, a.refreshToken)
|
||||
return null
|
||||
}
|
||||
val access = token.getString("access_token")
|
||||
@@ -176,11 +182,24 @@ object EaAuth {
|
||||
val record = StoreAccounts.read(app, Store.EA) ?: return false
|
||||
record.put("access_token", access).put("expires_at", System.currentTimeMillis() + expiresIn * 1000)
|
||||
refresh.takeIf { it.isNotEmpty() }?.let { record.put("refresh_token", it) }
|
||||
record.remove("refresh_rejected")
|
||||
player?.let { record.put("user_id", it.userId).put("persona_id", it.personaId).put("display_name", it.displayName).put("ea_id", it.eaId) }
|
||||
StoreAccounts.write(app, Store.EA, record)
|
||||
true
|
||||
}
|
||||
|
||||
private fun markRejected(context: Context, refresh: String) = synchronized(refreshLock) {
|
||||
val app = context.applicationContext
|
||||
val record = StoreAccounts.read(app, Store.EA) ?: return@synchronized
|
||||
if (record.optString("refresh_token") != refresh) return@synchronized
|
||||
StoreAccounts.write(app, Store.EA, record.put("refresh_rejected", true))
|
||||
}
|
||||
|
||||
fun signedIn(context: Context): Boolean {
|
||||
val a = load(context) ?: return false
|
||||
return a.userId.isNotEmpty() && !(a.rejected && a.expiresAt <= System.currentTimeMillis())
|
||||
}
|
||||
|
||||
fun accessToken(context: Context): String? {
|
||||
val current = load(context) ?: return null
|
||||
if (fresh(current)) return current.accessToken
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
package com.droiddeck.launcher.stores.ea
|
||||
|
||||
import android.util.Base64
|
||||
import android.util.Xml
|
||||
import com.droiddeck.launcher.stores.CloudFile
|
||||
import com.droiddeck.launcher.stores.CloudTransport
|
||||
import java.io.File
|
||||
import java.io.StringReader
|
||||
import java.security.MessageDigest
|
||||
import java.time.Instant
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
|
||||
internal class EaCloud(
|
||||
private val token: String,
|
||||
private val uid: String,
|
||||
private val keys: List<String>,
|
||||
private val base: String,
|
||||
private val rules: EaSaveRules,
|
||||
val localDir: File? = null,
|
||||
) : CloudTransport {
|
||||
class Entry(val size: Long, val href: String, val md5: String, val created: String, val modified: String, val localName: String)
|
||||
|
||||
class Manifest(val lineage: String, val files: List<Entry>, val snapshots: List<String>)
|
||||
|
||||
private class Signed(val url: String, val headers: Map<String, String>)
|
||||
|
||||
private class Request(val verb: String, val resource: String, val md5: String? = null, val type: String? = null)
|
||||
|
||||
private var key: String? = null
|
||||
private var found = false
|
||||
private var listed: Map<String, String?>? = null
|
||||
private val committed = HashMap<String, CloudFile>()
|
||||
|
||||
override fun wants(name: String): Boolean = rules.matches(base + name)
|
||||
|
||||
override fun committed(name: String): CloudFile? = committed[name]
|
||||
|
||||
override fun list(): List<CloudFile> {
|
||||
val manifest = pick()
|
||||
val files = manifest?.files.orEmpty().mapNotNull { e ->
|
||||
val path = EaSaveRules.normalize(e.localName)
|
||||
if (!path.startsWith(base, ignoreCase = true) || !rules.matches(path)) return@mapNotNull null
|
||||
val md5 = hex(e.md5) ?: error("EA listed ${path.substring(base.length)} without a valid checksum")
|
||||
CloudFile(localName(path.substring(base.length)), parseTime(e.modified), md5, readLink = e.href)
|
||||
}
|
||||
val twins = files.groupBy { it.name.lowercase() }.values.firstOrNull { it.size > 1 }
|
||||
check(twins == null) { "EA lists more than one save named ${twins!!.first().name} in different cases" }
|
||||
listed = files.associate { it.name.lowercase() to it.md5 }
|
||||
return files
|
||||
}
|
||||
|
||||
private fun localName(name: String): String {
|
||||
var dir = localDir ?: return name
|
||||
val parts = name.split('/')
|
||||
val out = ArrayList<String>()
|
||||
for (part in parts) {
|
||||
val match = dir.listFiles()?.filter { it.name.equals(part, ignoreCase = true) }.orEmpty()
|
||||
check(match.size <= 1) { "The save folder holds more than one file named $part in different cases" }
|
||||
val pick = match.singleOrNull()
|
||||
if (pick == null) return (out + parts.drop(out.size)).joinToString("/")
|
||||
out += pick.name
|
||||
dir = pick
|
||||
}
|
||||
return out.joinToString("/")
|
||||
}
|
||||
|
||||
override fun get(file: CloudFile): Pair<ByteArray, Long> {
|
||||
val href = file.readLink ?: error("EA has no data for ${file.name}")
|
||||
return locked("read", key ?: keys.first()) { lock, _ ->
|
||||
val signed = authorize(lock, listOf(Request("GET", href))).single()
|
||||
val reply = EaHttp.request(signed.url, headers = signed.headers)
|
||||
check(reply.ok) { "EA cloud save download answered ${reply.status}" }
|
||||
val want = file.md5 ?: error("EA listed ${file.name} without a valid checksum")
|
||||
check(hex(b64(md5(reply.body))) == want) { "EA cloud save ${file.name} failed its checksum" }
|
||||
reply.body to file.modifiedMs
|
||||
}
|
||||
}
|
||||
|
||||
override fun put(files: Map<String, ByteArray>, modifiedMs: Map<String, Long>): Map<String, Long> {
|
||||
if (key == null) pick()
|
||||
check(found || keys.size == 1) { "EA has no cloud save record for this game yet; play it once in the EA app" }
|
||||
val target = key ?: keys.first()
|
||||
val seen = listed
|
||||
return locked("write", target) { lock, body ->
|
||||
val locked = manifestUrl(body)?.let { fetchManifest(it) }
|
||||
check(locked != null || !found) { "EA's cloud save record disappeared" }
|
||||
val current = locked ?: Manifest("{00000000-0000-0000-0000-000000000000}", emptyList(), emptyList())
|
||||
if (seen != null) for (name in files.keys) {
|
||||
val entry = current.files.firstOrNull { EaSaveRules.normalize(it.localName).equals(base + name, ignoreCase = true) }
|
||||
val now = entry?.let { hex(it.md5) ?: error("EA lists $name without a valid checksum") }
|
||||
check(now == seen[name.lowercase()]) { "EA's cloud saves changed since they were read" }
|
||||
}
|
||||
val now = System.currentTimeMillis()
|
||||
val added = files.map { (name, data) ->
|
||||
val sum = md5(data)
|
||||
val stamp = stamp(modifiedMs[name]?.takeIf { it > 0 } ?: now)
|
||||
val old = current.files.firstOrNull { EaSaveRules.normalize(it.localName).equals(base + name, ignoreCase = true) }
|
||||
Entry(data.size.toLong(), "content/${data.size}-${hexOf(sum)}", b64(sum), old?.created ?: stamp, stamp, base + name) to data
|
||||
}
|
||||
val names = added.map { it.first.localName.lowercase() }.toSet()
|
||||
val next = Manifest(current.lineage, current.files.filter { EaSaveRules.normalize(it.localName).lowercase() !in names } + added.map { it.first }, current.snapshots)
|
||||
val xml = write(next).toByteArray()
|
||||
val xmlMd5 = b64(md5(xml))
|
||||
val requests = added.map { Request("PUT", it.first.href, it.first.md5, "application/octet-stream") } + Request("PUT", "manifest.xml", xmlMd5, "text/xml")
|
||||
val signed = authorize(lock, requests)
|
||||
for ((i, pair) in added.withIndex()) upload(signed[i], pair.second)
|
||||
upload(signed.last(), xml)
|
||||
found = true
|
||||
for ((entry, _) in added) {
|
||||
val name = entry.localName.substring(base.length)
|
||||
committed[name] = CloudFile(name, parseTime(entry.modified), hex(entry.md5), readLink = entry.href)
|
||||
}
|
||||
listed = null
|
||||
files.mapValues { (name, _) -> modifiedMs[name]?.takeIf { it > 0 } ?: now }
|
||||
}
|
||||
}
|
||||
|
||||
private fun pick(): Manifest? {
|
||||
for (candidate in keys) {
|
||||
val manifest = locked("read", candidate, missing = { null }) { _, body -> manifestUrl(body)?.let { fetchManifest(it) } }
|
||||
if (manifest != null) {
|
||||
key = candidate
|
||||
found = true
|
||||
return manifest
|
||||
}
|
||||
}
|
||||
key = keys.first()
|
||||
found = false
|
||||
return null
|
||||
}
|
||||
|
||||
private fun upload(signed: Signed, data: ByteArray) {
|
||||
val reply = EaHttp.request(signed.url, "PUT", signed.headers, data)
|
||||
check(reply.ok) { "EA cloud save upload answered ${reply.status}" }
|
||||
}
|
||||
|
||||
private fun fetchManifest(url: String): Manifest? {
|
||||
val reply = EaHttp.request(url)
|
||||
if (reply.status == 404) return null
|
||||
check(reply.ok) { "EA cloud save manifest answered ${reply.status}" }
|
||||
return parse(reply.text)
|
||||
}
|
||||
|
||||
private fun <T> locked(kind: String, key: String, missing: (() -> T)? = null, body: (String, String) -> T): T {
|
||||
val reply = EaHttp.request("$HOST/lock/$kind/$uid/$key", "POST", mapOf(AUTH to token, "Content-Type" to "application/xml"), ByteArray(0))
|
||||
if (reply.status == 404 && missing != null) return missing()
|
||||
check(reply.ok) { "EA cloud saves answered ${reply.status}" }
|
||||
val lock = reply.header(LOCK) ?: error("EA did not grant a cloud save lock")
|
||||
try {
|
||||
return body(lock, reply.text)
|
||||
} finally {
|
||||
runCatching { EaHttp.request("$HOST/lock/delete/$uid", "DELETE", mapOf(AUTH to token, LOCK to lock)) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun authorize(lock: String, requests: List<Request>): List<Signed> {
|
||||
val body = buildString {
|
||||
append("<requests>")
|
||||
for ((i, r) in requests.withIndex()) {
|
||||
append("<request id=\"").append(i).append("\"><verb>").append(r.verb).append("</verb><resource>").append(escape(r.resource)).append("</resource>")
|
||||
r.md5?.let { append("<md5>").append(it).append("</md5>") }
|
||||
r.type?.let { append("<content-type>").append(it).append("</content-type>") }
|
||||
append("</request>")
|
||||
}
|
||||
append("</requests>")
|
||||
}
|
||||
val reply = EaHttp.request("$HOST/lock/authorize/$uid", "PUT", mapOf(AUTH to token, LOCK to lock, "Content-Type" to "application/xml"), body.toByteArray())
|
||||
check(reply.ok) { "EA cloud saves refused the transfer (${reply.status})" }
|
||||
return signedRequests(reply.text, requests.size)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val HOST = "https://cloudsync.juno.ea.com"
|
||||
private const val AUTH = "X-Origin-AuthToken"
|
||||
private const val LOCK = "X-Origin-Sync-Lock"
|
||||
private val FILE = Regex("<file\\b([^>]*)>(.*?)</file>", RegexOption.DOT_MATCHES_ALL)
|
||||
private val LOCAL = Regex("<localName\\b([^>]*)>([^<]*)</localName>")
|
||||
private val SNAPSHOT = Regex("<snapshot>([^<]*)</snapshot>")
|
||||
private val REQUEST = Regex("<request\\b[^>]*\\bid=\"(\\d+)\"[^>]*>(.*?)</request>", RegexOption.DOT_MATCHES_ALL)
|
||||
private val HEADER = Regex("<header\\b([^>]*)/?>")
|
||||
|
||||
fun keys(masterTitleId: String, multiplayerId: String): List<String> =
|
||||
if (multiplayerId.isNotEmpty()) listOf("${masterTitleId}_$multiplayerId") else listOf(masterTitleId, "${masterTitleId}_$masterTitleId")
|
||||
|
||||
fun manifestUrl(lockBody: String): String? = Regex("<manifest>([^<]+)</manifest>").find(lockBody)?.groupValues?.get(1)?.let(::unescape)
|
||||
|
||||
fun parse(xml: String): Manifest {
|
||||
check(wellFormed(xml)) { "EA sent an incomplete cloud save manifest" }
|
||||
val lineage = attr(Regex("<manifest\\b([^>]*)>").find(xml)?.groupValues?.get(1).orEmpty(), "lineage")
|
||||
?: "{00000000-0000-0000-0000-000000000000}"
|
||||
val files = FILE.findAll(xml).mapNotNull { m ->
|
||||
val a = m.groupValues[1]
|
||||
val local = LOCAL.find(m.groupValues[2]) ?: return@mapNotNull null
|
||||
Entry(attr(a, "size")?.toLongOrNull() ?: 0, attr(a, "href").orEmpty(), attr(a, "md5").orEmpty(),
|
||||
attr(local.groupValues[1], "created").orEmpty(), attr(local.groupValues[1], "lastModified").orEmpty(), unescape(local.groupValues[2]))
|
||||
}.toList()
|
||||
return Manifest(lineage, files, SNAPSHOT.findAll(xml).map { unescape(it.groupValues[1]) }.toList())
|
||||
}
|
||||
|
||||
private fun wellFormed(xml: String): Boolean = runCatching {
|
||||
val p = Xml.newPullParser()
|
||||
p.setInput(StringReader(xml))
|
||||
var root: String? = null
|
||||
var depth = 0
|
||||
var closed = false
|
||||
while (p.next() != XmlPullParser.END_DOCUMENT) when (p.eventType) {
|
||||
XmlPullParser.START_TAG -> { if (root == null) root = p.name; depth++ }
|
||||
XmlPullParser.END_TAG -> { depth--; if (depth == 0) closed = true }
|
||||
}
|
||||
root == "manifest" && depth == 0 && closed
|
||||
}.getOrDefault(false)
|
||||
|
||||
fun write(m: Manifest): String = buildString {
|
||||
append("<manifest xmlns=\"http://origin.com/cloudsaves/manifest\" lineage=\"").append(escape(m.lineage)).append("\">\n")
|
||||
for (f in m.files) {
|
||||
append(" <file size=\"").append(f.size).append("\" href=\"").append(escape(f.href)).append("\" md5=\"").append(escape(f.md5)).append("\">\n")
|
||||
append(" <localName created=\"").append(escape(f.created)).append("\" lastModified=\"").append(escape(f.modified)).append("\">")
|
||||
append(escape(f.localName)).append("</localName>\n </file>\n")
|
||||
}
|
||||
for (s in m.snapshots) append(" <snapshot>").append(escape(s)).append("</snapshot>\n")
|
||||
append("</manifest>\n")
|
||||
}
|
||||
|
||||
private fun signedRequests(xml: String, count: Int): List<Signed> {
|
||||
val byId = REQUEST.findAll(xml).associate { m ->
|
||||
val inner = m.groupValues[2]
|
||||
val url = Regex("<url>([^<]+)</url>").find(inner)?.groupValues?.get(1)?.let(::unescape) ?: error("EA sent no transfer URL")
|
||||
val headers = HEADER.findAll(inner).mapNotNull { h ->
|
||||
val k = attr(h.groupValues[1], "key") ?: return@mapNotNull null
|
||||
k to (attr(h.groupValues[1], "value") ?: "")
|
||||
}.toMap()
|
||||
m.groupValues[1].toInt() to Signed(url, headers)
|
||||
}
|
||||
return (0 until count).map { byId[it] ?: error("EA signed ${byId.size} of $count cloud save transfers") }
|
||||
}
|
||||
|
||||
fun stamp(ms: Long): String = Instant.ofEpochMilli(ms / 1000 * 1000).toString() + "Z"
|
||||
|
||||
fun parseTime(s: String): Long = runCatching { Instant.parse(s.trimEnd('Z') + "Z").toEpochMilli() }.getOrDefault(-1L)
|
||||
|
||||
private fun attr(attrs: String, name: String): String? = Regex("\\b$name=\"([^\"]*)\"").find(attrs)?.groupValues?.get(1)?.let(::unescape)
|
||||
|
||||
private fun md5(data: ByteArray) = MessageDigest.getInstance("MD5").digest(data)
|
||||
|
||||
private fun b64(sum: ByteArray) = Base64.encodeToString(sum, Base64.NO_WRAP)
|
||||
|
||||
private fun hexOf(sum: ByteArray) = sum.joinToString("") { "%02x".format(it) }
|
||||
|
||||
fun hex(b64: String): String? = runCatching { hexOf(Base64.decode(b64, Base64.DEFAULT)) }.getOrNull()?.takeIf { it.length == 32 }
|
||||
|
||||
private fun escape(s: String) = s.replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """)
|
||||
|
||||
private fun unescape(s: String) = EaSaveRules.unescape(s)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.droiddeck.launcher.stores.ea
|
||||
|
||||
internal class EaSaveRules(val includes: List<String>, val excludes: List<String>) {
|
||||
|
||||
fun base(): String? {
|
||||
val dirs = includes.map { pattern ->
|
||||
val wild = pattern.indexOfFirst { it == '*' || it == '?' }
|
||||
val fixed = if (wild < 0) pattern else pattern.substring(0, wild)
|
||||
if (fixed.endsWith('/')) fixed else fixed.substringBeforeLast('/', "") + "/"
|
||||
}
|
||||
val parts = dirs.map { it.trimEnd('/').split('/') }
|
||||
if (parts.isEmpty()) return null
|
||||
val common = ArrayList<String>()
|
||||
for (i in parts.minOf { it.size }.let { 0 until it }) {
|
||||
val seg = parts[0][i]
|
||||
if (parts.all { it[i].equals(seg, ignoreCase = true) }) common += seg else break
|
||||
}
|
||||
if (common.isEmpty() || !VARIABLE.matches(common[0])) return null
|
||||
return common.joinToString("/") + "/"
|
||||
}
|
||||
|
||||
fun matches(path: String): Boolean {
|
||||
val p = normalize(path)
|
||||
return includes.any { hit(it, p) } && excludes.none { hit(it, p) }
|
||||
}
|
||||
|
||||
private fun hit(pattern: String, path: String): Boolean = when {
|
||||
pattern.endsWith('/') -> path.startsWith(pattern, ignoreCase = true)
|
||||
pattern.any { it == '*' || it == '?' } -> glob(pattern).matches(path)
|
||||
else -> path.equals(pattern, ignoreCase = true)
|
||||
}
|
||||
|
||||
private fun glob(pattern: String): Regex = Regex(
|
||||
pattern.split('*').joinToString("[^/]*") { part -> part.split('?').joinToString("[^/]") { Regex.escape(it) } },
|
||||
RegexOption.IGNORE_CASE,
|
||||
)
|
||||
|
||||
companion object {
|
||||
private val VARIABLE = Regex("%[A-Za-z]+%")
|
||||
private val RULE = Regex("<(include|exclude)\\b[^>]*>([^<]*)</\\1>", RegexOption.IGNORE_CASE)
|
||||
private val TOKENS = mapOf(
|
||||
"documents" to "%DOCUMENTS%", "savedgames" to "%SAVED_GAMES%", "appdata" to "%APPDATA%",
|
||||
"localappdata" to "%LOCALAPPDATA%", "programdata" to "%PROGRAMDATA%", "userprofile" to "%USERPROFILE%",
|
||||
)
|
||||
|
||||
private val COMMENT = Regex("<!--.*?-->", RegexOption.DOT_MATCHES_ALL)
|
||||
private val ENTITY = Regex("&(#x[0-9a-fA-F]+|#[0-9]+|lt|gt|quot|apos|amp);")
|
||||
|
||||
fun normalize(path: String) = path.replace('\\', '/')
|
||||
|
||||
fun parse(xml: String): EaSaveRules? {
|
||||
val rules = RULE.findAll(COMMENT.replace(xml, "")).map { it.groupValues[1].lowercase() to normalize(unescape(it.groupValues[2]).trim()) }
|
||||
.filter { it.second.isNotEmpty() }.toList()
|
||||
val includes = rules.filter { it.first == "include" }.map { it.second }
|
||||
if (includes.isEmpty()) return null
|
||||
return EaSaveRules(includes, rules.filter { it.first == "exclude" }.map { it.second })
|
||||
}
|
||||
|
||||
fun template(base: String): String? {
|
||||
val variable = VARIABLE.find(base)?.takeIf { it.range.first == 0 } ?: return null
|
||||
val token = TOKENS[variable.value.trim('%').lowercase()] ?: return null
|
||||
return token + base.substring(variable.value.length)
|
||||
}
|
||||
|
||||
fun unescape(s: String): String = ENTITY.replace(s) { m ->
|
||||
when (val e = m.groupValues[1]) {
|
||||
"lt" -> "<"
|
||||
"gt" -> ">"
|
||||
"quot" -> "\""
|
||||
"apos" -> "'"
|
||||
"amp" -> "&"
|
||||
else -> runCatching { String(Character.toChars(if (e.startsWith("#x")) e.substring(2).toInt(16) else e.substring(1).toInt())) }.getOrDefault(m.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
package com.droiddeck.launcher.stores.epic
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.Browser
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import com.droiddeck.launcher.DeviceCodeActivity
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* Epic's login page in the browser ends on the launcher's authorization code shown as text, since
|
||||
* its page script keeps the launcher client from being sent back to an app; the user copies it and
|
||||
* DroidDeck takes it from the clipboard when it is in front again.
|
||||
*/
|
||||
internal object EpicCodeLogin {
|
||||
private const val TAG = "EpicCodeLogin"
|
||||
private const val CHROME = "com.android.chrome"
|
||||
private const val PENDING_MS = 15 * 60 * 1000L
|
||||
private val ANY_CODE = Regex("(?<![0-9a-fA-F])[0-9a-fA-F]{32}(?![0-9a-fA-F])")
|
||||
|
||||
@Volatile private var pendingUntil = 0L
|
||||
private val main = Handler(Looper.getMainLooper())
|
||||
|
||||
fun begin(context: Context) {
|
||||
val app = context.applicationContext
|
||||
Thread({
|
||||
val url = EpicNative.call("auth.config")?.optString("startUrl").orEmpty()
|
||||
if (url.isEmpty()) {
|
||||
Log.w(TAG, "no sign-in page")
|
||||
main.post { failed(app) }
|
||||
return@Thread
|
||||
}
|
||||
pendingUntil = System.currentTimeMillis() + PENDING_MS
|
||||
main.post {
|
||||
DeviceCodeActivity.onPaste = { ctx, text -> offer(ctx, text) }
|
||||
val floated = DeviceCodeActivity.show(app, "", url, 0, Store.EPIC.label, app.getString(R.string.epic_copy_code), paste = true)
|
||||
if (!floated && !openBrowser(app, url)) { pendingUntil = 0; failed(app) }
|
||||
}
|
||||
}, "epic-code-login").apply { isDaemon = true }.start()
|
||||
}
|
||||
|
||||
/** Called when a DroidDeck window gains focus, the only moment Android lets it read the clipboard. */
|
||||
fun resumed(activity: Activity) {
|
||||
if (System.currentTimeMillis() > pendingUntil) return
|
||||
val text = runCatching {
|
||||
activity.getSystemService(ClipboardManager::class.java)?.primaryClip?.getItemAt(0)?.coerceToText(activity)?.toString()
|
||||
}.getOrNull() ?: return
|
||||
offer(activity, text)
|
||||
}
|
||||
|
||||
private fun offer(context: Context, text: String): Boolean {
|
||||
if (System.currentTimeMillis() > pendingUntil) return false
|
||||
val trimmed = text.trim()
|
||||
val code = EpicNative.call("auth.codeFromPage", JSONObject().put("text", trimmed))?.optString("code").orEmpty()
|
||||
.ifEmpty { ANY_CODE.find(trimmed)?.value.orEmpty() }
|
||||
if (code.isEmpty()) return false
|
||||
pendingUntil = 0
|
||||
val app = context.applicationContext
|
||||
runCatching { app.getSystemService(ClipboardManager::class.java)?.clearPrimaryClip() }
|
||||
DeviceCodeActivity.close()
|
||||
Thread({
|
||||
val problem = signIn(app, code)
|
||||
main.post {
|
||||
if (problem == null) StoresState.refresh(app)
|
||||
else {
|
||||
// Epic's codes last only minutes; the page in the signed-in browser hands out a fresh one.
|
||||
Toast.makeText(app, problem, Toast.LENGTH_LONG).show()
|
||||
begin(app)
|
||||
}
|
||||
}
|
||||
}, "epic-code-login").apply { isDaemon = true }.start()
|
||||
return true
|
||||
}
|
||||
|
||||
private fun signIn(app: Context, code: String): String? {
|
||||
val answer = EpicNative.call("auth.signIn", JSONObject().put("code", code))
|
||||
val tokens = answer?.let(EpicCredentialStore.TokenResult::from)
|
||||
if (tokens == null) {
|
||||
Log.w(TAG, "code exchange failed: ${answer?.optString("error").orEmpty().ifEmpty { "no answer" }}")
|
||||
return app.getString(R.string.stores_login_error_generic)
|
||||
}
|
||||
return try {
|
||||
EpicCredentialStore.save(app, tokens, merge = false)
|
||||
null
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "saving the sign-in failed: ${e.javaClass.simpleName}")
|
||||
app.getString(R.string.stores_login_error_generic)
|
||||
}
|
||||
}
|
||||
|
||||
private fun openBrowser(app: Context, url: String): Boolean {
|
||||
for (pkg in listOf(CHROME, null)) {
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
.addCategory(Intent.CATEGORY_BROWSABLE)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra(Browser.EXTRA_APPLICATION_ID, app.packageName)
|
||||
if (pkg != null) intent.setPackage(pkg)
|
||||
if (runCatching { app.startActivity(intent) }.isSuccess) return true
|
||||
}
|
||||
Log.w(TAG, "no browser took the sign-in")
|
||||
return false
|
||||
}
|
||||
|
||||
private fun failed(app: Context) = Toast.makeText(app, R.string.stores_login_error_generic, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import com.droiddeck.launcher.stores.StoreFront
|
||||
import com.droiddeck.launcher.stores.StoreInstallRoot
|
||||
import com.droiddeck.launcher.stores.StoreLoginActivity
|
||||
import com.droiddeck.launcher.stores.StoreShelves
|
||||
import com.droiddeck.launcher.stores.StoreLibraryCache
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import com.droiddeck.launcher.stores.WebCookies
|
||||
import com.droiddeck.launcher.stores.download.DownloadEntry
|
||||
@@ -163,7 +164,16 @@ object RockstarLibrary {
|
||||
post(gen) { StoresState.status.remove(Store.ROCKSTAR); StoresState.problems[Store.ROCKSTAR] = app.getString(R.string.stores_sync_sign_in) }
|
||||
return
|
||||
}
|
||||
if (StoresState.library[Store.ROCKSTAR].isNullOrEmpty()) post(gen) { StoresState.status[Store.ROCKSTAR] = app.getString(R.string.stores_sync_game_list) }
|
||||
val cached = StoreLibraryCache.load(app, Store.ROCKSTAR)
|
||||
post(gen) {
|
||||
if (StoresState.library[Store.ROCKSTAR] == null) {
|
||||
if (cached != null) {
|
||||
StoresState.library[Store.ROCKSTAR] = cached
|
||||
StoresState.shelves[Store.ROCKSTAR]?.let { StoresState.shelves[Store.ROCKSTAR] = StoreFront.markOwned(it, cached, RockstarCatalog::sameGame) }
|
||||
}
|
||||
else StoresState.status[Store.ROCKSTAR] = app.getString(R.string.stores_sync_game_list)
|
||||
}
|
||||
}
|
||||
val account = RockstarApps.fetch(t.ticket) { StoresState.logLine(it) }
|
||||
val games = games(account)
|
||||
owned(account).filter { o -> games.none { it.id == o.id } }.takeIf { it.isNotEmpty() }?.let { elsewhere ->
|
||||
@@ -175,6 +185,7 @@ object RockstarLibrary {
|
||||
StoresState.library[Store.ROCKSTAR] = games
|
||||
StoresState.shelves[Store.ROCKSTAR]?.let { StoresState.shelves[Store.ROCKSTAR] = StoreFront.markOwned(it, games, RockstarCatalog::sameGame) }
|
||||
}
|
||||
StoreLibraryCache.save(app, Store.ROCKSTAR, games) { generation.get() == gen }
|
||||
StoresState.logLine("Rockstar: ${games.size} owned games")
|
||||
} catch (e: Exception) {
|
||||
StoresState.logLine("Rockstar: library sync failed: ${e.javaClass.simpleName} ${e.message.orEmpty().take(300)}")
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.droiddeck.launcher.stores.StoreInstallRoot
|
||||
import com.droiddeck.launcher.stores.download.DownloadEntry
|
||||
import com.droiddeck.launcher.stores.download.DownloadQueue
|
||||
import com.droiddeck.launcher.stores.StoreLoginActivity
|
||||
import com.droiddeck.launcher.stores.StoreLibraryCache
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import com.droiddeck.launcher.stores.WebCookies
|
||||
import org.json.JSONObject
|
||||
@@ -206,7 +207,16 @@ object UbisoftLibrary {
|
||||
post(gen) { StoresState.status.remove(Store.UBISOFT); StoresState.problems[Store.UBISOFT] = app.getString(R.string.stores_sync_sign_in) }
|
||||
return
|
||||
}
|
||||
if (StoresState.library[Store.UBISOFT].isNullOrEmpty()) post(gen) { StoresState.status[Store.UBISOFT] = app.getString(R.string.stores_sync_game_list) }
|
||||
val cached = StoreLibraryCache.load(app, Store.UBISOFT)
|
||||
post(gen) {
|
||||
if (StoresState.library[Store.UBISOFT] == null) {
|
||||
if (cached != null) {
|
||||
StoresState.library[Store.UBISOFT] = cached
|
||||
StoresState.shelves[Store.UBISOFT]?.let { StoresState.shelves[Store.UBISOFT] = StoreFront.markOwned(it, cached, UbisoftStore::sameGame) }
|
||||
}
|
||||
else StoresState.status[Store.UBISOFT] = app.getString(R.string.stores_sync_game_list)
|
||||
}
|
||||
}
|
||||
val all = ArrayList<CatalogItem>()
|
||||
var offset = 0
|
||||
while (true) {
|
||||
@@ -241,6 +251,7 @@ object UbisoftLibrary {
|
||||
StoresState.library[Store.UBISOFT] = games
|
||||
StoresState.shelves[Store.UBISOFT]?.let { StoresState.shelves[Store.UBISOFT] = StoreFront.markOwned(it, games, UbisoftStore::sameGame) }
|
||||
}
|
||||
StoreLibraryCache.save(app, Store.UBISOFT, games) { generation.get() == gen }
|
||||
StoresState.logLine("Ubisoft: ${games.size} owned games")
|
||||
} catch (e: Exception) {
|
||||
StoresState.logLine("Ubisoft: library sync failed: ${e.javaClass.simpleName} ${e.message.orEmpty().take(200)}")
|
||||
|
||||
@@ -18,7 +18,8 @@ internal class XboxLaunchViews {
|
||||
parent.listFiles()?.filter { it.name.startsWith("launch-") }?.forEach(::remove)
|
||||
recovered.add(parent.path)
|
||||
}
|
||||
return Files.createTempDirectory(parent.toPath(), "launch-").toFile()
|
||||
// The guest binds the files directory by the path Android reports, not its canonical one.
|
||||
return File(files, "xbox-runtime/views/" + Files.createTempDirectory(parent.toPath(), "launch-").fileName)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
package com.droiddeck.launcher.stores.xbox
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.CookieManager
|
||||
import android.webkit.WebResourceRequest
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import android.widget.Button
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageButton
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.activity.ComponentActivity
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.webkit.WebViewCompat
|
||||
import androidx.webkit.WebViewFeature
|
||||
import com.droiddeck.launcher.core.AddonPack
|
||||
@@ -24,8 +33,10 @@ import org.json.JSONObject
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class XboxLoginActivity : ComponentActivity() {
|
||||
private lateinit var host: LinearLayout
|
||||
private lateinit var host: FrameLayout
|
||||
private lateinit var status: TextView
|
||||
private lateinit var retry: Button
|
||||
private lateinit var progressBar: ProgressBar
|
||||
private var view: WebView? = null
|
||||
@Volatile private var child: Xodus.Child? = null
|
||||
@Volatile private var session = 0L
|
||||
@@ -37,11 +48,7 @@ class XboxLoginActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
requestedOrientation = com.droiddeck.launcher.core.AppUiPrefs.orientation(this)
|
||||
host = LinearLayout(this).apply { orientation = LinearLayout.VERTICAL; setBackgroundColor(Color.BLACK) }
|
||||
status = TextView(this).apply { setTextColor(Color.WHITE); text = "Preparing Microsoft sign-in…"; setPadding(24, 16, 24, 16) }
|
||||
host.addView(status)
|
||||
host.addView(Button(this).apply { text = getString(com.droiddeck.launcher.R.string.stores_login_close); setOnClickListener { finish() } })
|
||||
setContentView(host)
|
||||
setContentView(buildChrome())
|
||||
if (android.os.Build.VERSION.SDK_INT < 28 || !WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER) ||
|
||||
!WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) {
|
||||
status.text = "Update Android System WebView to sign in to Xbox."
|
||||
@@ -148,15 +155,60 @@ class XboxLoginActivity : ComponentActivity() {
|
||||
val failed = step
|
||||
val reason = failure(e)
|
||||
logStep("failed while $failed: $reason")
|
||||
if (e is java.io.IOException) logStep("I/O detail: ${e.message.orEmpty().take(300)}")
|
||||
runOnUiThread {
|
||||
disposeView()
|
||||
val details = if (codes.isEmpty()) "" else "\nDetails: ${codes.joinToString(", ")}"
|
||||
status.text = "Microsoft sign-in did not complete.\nFailed while $failed: $reason$details\nClose this window and try again."
|
||||
status.text = "Microsoft sign-in did not complete.\nFailed while $failed: $reason$details"
|
||||
retry.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}, "xbox-login").start()
|
||||
}
|
||||
|
||||
private fun dp(value: Int): Int = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value.toFloat(), resources.displayMetrics).toInt()
|
||||
|
||||
/** The other stores' sign-in frame: a title bar with close, a load bar, and a centered status. */
|
||||
private fun buildChrome(): View {
|
||||
val root = LinearLayout(this).apply { orientation = LinearLayout.VERTICAL; setBackgroundColor(BACKGROUND) }
|
||||
val bar = LinearLayout(this).apply {
|
||||
orientation = LinearLayout.HORIZONTAL; gravity = Gravity.CENTER_VERTICAL; setBackgroundColor(BAR)
|
||||
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp(48))
|
||||
}
|
||||
bar.addView(TextView(this).apply {
|
||||
text = getString(R.string.stores_login_title, Store.XBOX.label)
|
||||
setTextColor(TEXT); textSize = 16f; setPadding(dp(16), 0, dp(8), 0)
|
||||
layoutParams = LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)
|
||||
})
|
||||
bar.addView(ImageButton(this).apply {
|
||||
setImageResource(android.R.drawable.ic_menu_close_clear_cancel); setBackgroundColor(Color.TRANSPARENT)
|
||||
contentDescription = getString(R.string.stores_login_close); layoutParams = LinearLayout.LayoutParams(dp(48), dp(48))
|
||||
setOnClickListener { finish() }
|
||||
})
|
||||
progressBar = ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal).apply {
|
||||
max = 100; visibility = View.GONE
|
||||
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp(3))
|
||||
}
|
||||
host = FrameLayout(this).apply {
|
||||
setBackgroundColor(BACKGROUND)
|
||||
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f)
|
||||
}
|
||||
val panel = LinearLayout(this).apply {
|
||||
orientation = LinearLayout.VERTICAL; gravity = Gravity.CENTER; setBackgroundColor(BACKGROUND)
|
||||
setPadding(dp(24), dp(24), dp(24), dp(24))
|
||||
}
|
||||
status = TextView(this).apply { setTextColor(TEXT); textSize = 15f; gravity = Gravity.CENTER; text = "Preparing Microsoft sign-in…" }
|
||||
retry = Button(this).apply {
|
||||
text = getString(R.string.stores_login_retry); visibility = View.GONE
|
||||
setOnClickListener { startActivity(Intent(intent)); finish() }
|
||||
}
|
||||
panel.addView(status)
|
||||
panel.addView(retry, LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { topMargin = dp(16) })
|
||||
host.addView(panel, FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
|
||||
root.addView(bar); root.addView(progressBar); root.addView(host)
|
||||
return root
|
||||
}
|
||||
|
||||
private fun show(text: String) = runOnUiThread { if (!closed && view == null) status.text = text }
|
||||
|
||||
private fun progress(name: String, text: String) { step = name; show(text) }
|
||||
@@ -191,7 +243,6 @@ class XboxLoginActivity : ComponentActivity() {
|
||||
override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean = !trusted(request.url.toString())
|
||||
override fun onPageFinished(view: WebView, url: String) {
|
||||
if (!trusted(url)) { finish(); return }
|
||||
status.text = "Microsoft sign-in"
|
||||
val uri = Uri.parse(url)
|
||||
if (uri.host == "login.live.com" && uri.path == "/ppsecure/post.srf") {
|
||||
view.evaluateJavascript("JSON.stringify(globalThis.ServerData ?? null)") { raw ->
|
||||
@@ -203,7 +254,14 @@ class XboxLoginActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
host.addView(web, LinearLayout.LayoutParams(-1, 0, 1f))
|
||||
web.setBackgroundColor(BACKGROUND)
|
||||
web.webChromeClient = object : android.webkit.WebChromeClient() {
|
||||
override fun onProgressChanged(view: WebView?, newProgress: Int) {
|
||||
progressBar.progress = newProgress
|
||||
progressBar.visibility = if (newProgress in 1..99) View.VISIBLE else View.GONE
|
||||
}
|
||||
}
|
||||
host.addView(web, FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
|
||||
val headers = frame.getJSONObject("headers")
|
||||
val values = headers.keys().asSequence().associateWith { key ->
|
||||
require(key in allowedHeaders)
|
||||
@@ -212,7 +270,11 @@ class XboxLoginActivity : ComponentActivity() {
|
||||
web.loadUrl(frame.getString("url"), values)
|
||||
}
|
||||
|
||||
private fun disposeView() { view?.let { host.removeView(it); it.stopLoading(); it.destroy() }; view = null }
|
||||
private fun disposeView() {
|
||||
view?.let { host.removeView(it); it.stopLoading(); it.destroy() }
|
||||
view = null
|
||||
if (::progressBar.isInitialized) progressBar.visibility = View.GONE
|
||||
}
|
||||
override fun onDestroy() {
|
||||
closed = true
|
||||
val current = child; child = null
|
||||
@@ -225,6 +287,9 @@ class XboxLoginActivity : ComponentActivity() {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "XboxLogin"
|
||||
private const val BACKGROUND = 0xFF0A0B0D.toInt()
|
||||
private const val BAR = 0xFF121417.toInt()
|
||||
private const val TEXT = 0xFFF2F4F7.toInt()
|
||||
|
||||
internal fun failure(e: Exception): String {
|
||||
val message = e.message.orEmpty()
|
||||
|
||||
@@ -19,9 +19,11 @@ import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.gestures.awaitEachGesture
|
||||
import androidx.compose.foundation.gestures.awaitFirstDown
|
||||
import androidx.compose.foundation.gestures.waitForUpOrCancellation
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
@@ -50,11 +52,12 @@ import androidx.compose.material.icons.outlined.Mic
|
||||
import androidx.compose.material.icons.outlined.Add
|
||||
import androidx.compose.material.icons.outlined.ArrowDownward
|
||||
import androidx.compose.material.icons.outlined.AttachFile
|
||||
import androidx.compose.material.icons.outlined.AutoAwesome
|
||||
import androidx.compose.material.icons.outlined.Terminal
|
||||
import androidx.compose.material.icons.outlined.Build
|
||||
import androidx.compose.material.icons.outlined.Close
|
||||
import androidx.compose.material.icons.outlined.ExpandMore
|
||||
import androidx.compose.material.icons.outlined.History
|
||||
import androidx.compose.material.icons.outlined.Lock
|
||||
import androidx.compose.material.icons.outlined.Memory
|
||||
import androidx.compose.material.icons.outlined.MoreHoriz
|
||||
import androidx.compose.material.icons.outlined.Pets
|
||||
@@ -95,6 +98,7 @@ import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.input.pointer.PointerEventPass
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
@@ -292,7 +296,8 @@ private fun AgentPageContent(
|
||||
awaitEachGesture {
|
||||
awaitFirstDown(requireUnconsumed = false, pass = PointerEventPass.Initial)
|
||||
if (panel == AgentPanel.MODEL || panel == AgentPanel.USAGE) panel = AgentPanel.NONE
|
||||
if (composer.focused) focusManager.clearFocus()
|
||||
// Forced: the unforced path walks the focus chain and throws ("ActiveParent with no focused child") when a tap lands while focus is moving.
|
||||
if (composer.focused) focusManager.clearFocus(force = true)
|
||||
}
|
||||
},
|
||||
list, following = !readingBack, onRevise = { composer.open() }, onSent = toLatest,
|
||||
@@ -304,7 +309,7 @@ private fun AgentPageContent(
|
||||
}
|
||||
}
|
||||
androidx.compose.animation.AnimatedVisibility(!hidden, enter = expandVertically() + fadeIn(), exit = shrinkVertically() + fadeOut()) {
|
||||
AgentComposer(composer, draft, visible, inlineControls, onPanel = { panel = it }, onSent = toLatest)
|
||||
AgentComposer(composer, draft, visible && started, inlineControls, onPanel = { panel = it }, onSent = toLatest)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -451,7 +456,7 @@ private fun AgentConversation(modifier: Modifier, list: LazyListState, following
|
||||
}
|
||||
if (AgentHost.entries.isEmpty() && !working) {
|
||||
Column(modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center) {
|
||||
Icon(Icons.Outlined.AutoAwesome, null, tint = pal.primary, modifier = Modifier.size(40.dp))
|
||||
Icon(Icons.Outlined.Terminal, null, tint = pal.primary, modifier = Modifier.size(40.dp))
|
||||
Text(stringResource(R.string.agent_empty), fontSize = 15.sp, color = pal.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center, modifier = Modifier.widthIn(max = 460.dp).padding(top = 12.dp))
|
||||
}
|
||||
@@ -703,9 +708,23 @@ private fun AgentEditor(composer: ComposerState, draftState: MutableState<String
|
||||
val pal = LocalPalette.current
|
||||
var draft by draftState
|
||||
val voice = remember { AgentVoice(context.applicationContext, { draftState.value }) { draftState.value = it } }
|
||||
val voiceAvailable = remember { AgentVoice.available(context) }
|
||||
DisposableEffect(voice) { onDispose { voice.stop() } }
|
||||
LaunchedEffect(visible) { if (!visible) voice.stop() }
|
||||
DisposableEffect(voice) { onDispose { voice.settle() } }
|
||||
var voiceSetup by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(voice.serviceMicBlocked) {
|
||||
if (voice.serviceMicBlocked) {
|
||||
voice.serviceMicBlocked = false
|
||||
voiceSetup = true
|
||||
}
|
||||
}
|
||||
LaunchedEffect(visible) { if (!visible) voice.settle() }
|
||||
// Sends once dictation has written its last words; while a send already waits on them, there is nothing more to do.
|
||||
val sendNow = {
|
||||
when {
|
||||
voice.listening -> voice.finish(send)
|
||||
voice.finishing -> Unit
|
||||
else -> send()
|
||||
}
|
||||
}
|
||||
val working = AgentHost.state == AgentHost.State.WORKING
|
||||
if (draft.startsWith("/") && !draft.contains(' ')) {
|
||||
val matches = (LOCAL_COMMANDS + CLI_COMMANDS).filter { it.startsWith(draft) && it != draft }
|
||||
@@ -725,23 +744,35 @@ private fun AgentEditor(composer: ComposerState, draftState: MutableState<String
|
||||
) {
|
||||
for (path in AgentAttachments.pending.toList()) AttachmentChip(path) { AgentAttachments.pending.remove(path) }
|
||||
}
|
||||
if (voiceSetup) AgentVoiceSetup(onReady = { voiceSetup = false }, onClose = { voiceSetup = false })
|
||||
var focused by remember { mutableStateOf(false) }
|
||||
val field = remember { FocusRequester() }
|
||||
LaunchedEffect(composer.focusRequests) { if (composer.hasUnconsumedFocusRequest()) runCatching { field.requestFocus() } }
|
||||
Column(
|
||||
val attach = LocalActivityResultRegistryOwner.current != null
|
||||
BoxWithConstraints(
|
||||
Modifier.fillMaxWidth().padding(top = 8.dp).clip(Shape16).background(colors.surface)
|
||||
.border(if (focused) 2.dp else 1.dp, if (focused) pal.primary else pal.line, Shape16).padding(6.dp),
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.Bottom) {
|
||||
if (LocalActivityResultRegistryOwner.current != null) AttachButton()
|
||||
if (AgentAttachments.gameFrame != null) GameFrameButton()
|
||||
Box(Modifier.weight(1f).padding(start = 8.dp, top = 10.dp, bottom = 10.dp)) {
|
||||
// A narrow editor gives the buttons a row of their own so the text keeps room to be tapped.
|
||||
val stacked = maxWidth < (if (controls != null) 560.dp else 320.dp)
|
||||
val text: @Composable (Modifier) -> Unit = { modifier -> Box(modifier.padding(start = 8.dp, top = 10.dp, bottom = 10.dp)) {
|
||||
if (draft.isEmpty()) Text(
|
||||
stringResource(if (working) R.string.agent_hint_working else R.string.agent_hint), fontSize = 16.sp,
|
||||
stringResource(
|
||||
when {
|
||||
voice.listening && !voice.locked -> R.string.agent_voice_hold
|
||||
voice.listening -> R.string.agent_voice_listening
|
||||
working -> R.string.agent_hint_working
|
||||
else -> R.string.agent_hint
|
||||
},
|
||||
),
|
||||
fontSize = 16.sp,
|
||||
color = pal.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
BasicTextField(
|
||||
draft, { draft = it },
|
||||
draft, {
|
||||
draft = it
|
||||
if (voice.listening) voice.stop()
|
||||
},
|
||||
Modifier.fillMaxWidth().focusRequester(field).onFocusChanged {
|
||||
focused = it.isFocused
|
||||
composer.focused = it.isFocused
|
||||
@@ -750,50 +781,132 @@ private fun AgentEditor(composer: ComposerState, draftState: MutableState<String
|
||||
textStyle = TextStyle(fontSize = 16.sp, color = colors.onSurface),
|
||||
cursorBrush = SolidColor(pal.primary),
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Send),
|
||||
keyboardActions = KeyboardActions(onSend = {
|
||||
voice.stop()
|
||||
send()
|
||||
}),
|
||||
keyboardActions = KeyboardActions(onSend = { sendNow() }),
|
||||
minLines = 1,
|
||||
maxLines = 8,
|
||||
)
|
||||
}
|
||||
if (controls != null && !focused) Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.height(42.dp)) { controls() }
|
||||
} }
|
||||
val actions: @Composable () -> Unit = {
|
||||
if (working) RoundButton(Icons.Outlined.Stop, stringResource(R.string.agent_stop), pal.error.copy(alpha = 0.22f), colors.error, "agent-stop") {
|
||||
AgentHost.stop(context)
|
||||
}
|
||||
val canSend = draft.isNotBlank() || AgentAttachments.pending.isNotEmpty()
|
||||
// An empty message has nothing to send, so the button there dictates one instead.
|
||||
if ((!canSend || voice.listening) && voiceAvailable) VoiceButton(voice) { voice.start(draft) }
|
||||
else RoundButton(
|
||||
if ((!canSend || voice.listening) && !voice.finishing) VoiceButton(voice, onStart = { voice.start(draft) }, onSend = send, onSetup = { voiceSetup = true })
|
||||
if (voice.finishing || (voice.listening && voice.locked) || (canSend && !voice.listening)) RoundButton(
|
||||
Icons.AutoMirrored.Outlined.Send, stringResource(if (working) R.string.agent_queue else R.string.agent_send),
|
||||
if (canSend) pal.primary else pal.surfaceVariant, if (canSend) pal.onPrimary else pal.onSurfaceVariant, "agent-send", enabled = canSend,
|
||||
) {
|
||||
voice.stop()
|
||||
send()
|
||||
pal.primary, pal.onPrimary, "agent-send", enabled = !voice.finishing,
|
||||
) { sendNow() }
|
||||
}
|
||||
if (stacked) Column {
|
||||
text(Modifier.fillMaxWidth())
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
|
||||
if (attach) AttachButton()
|
||||
if (AgentAttachments.gameFrame != null) GameFrameButton()
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.weight(1f).height(42.dp)) { if (controls != null && !focused) controls() }
|
||||
actions()
|
||||
}
|
||||
} else Row(verticalAlignment = Alignment.Bottom) {
|
||||
if (attach) AttachButton()
|
||||
if (AgentAttachments.gameFrame != null) GameFrameButton()
|
||||
text(Modifier.weight(1f))
|
||||
if (controls != null && !focused) Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.height(42.dp)) { controls() }
|
||||
actions()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Held, it listens until let go and then sends; slid up, it keeps listening hands-free; slid left, it puts the text back.
|
||||
* A tap or a controller press also listens hands-free.
|
||||
*/
|
||||
@Composable
|
||||
private fun VoiceButton(voice: AgentVoice, onStart: () -> Unit) {
|
||||
private fun VoiceButton(voice: AgentVoice, onStart: () -> Unit, onSend: () -> Unit, onSetup: () -> Unit) {
|
||||
val context = LocalContext.current
|
||||
val pal = LocalPalette.current
|
||||
val ask = if (LocalActivityResultRegistryOwner.current != null) rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
|
||||
if (granted) onStart() else android.widget.Toast.makeText(context, R.string.agent_voice_denied, android.widget.Toast.LENGTH_SHORT).show()
|
||||
} else null
|
||||
RoundButton(
|
||||
if (voice.listening) Icons.Outlined.MicOff else Icons.Outlined.Mic, stringResource(if (voice.listening) R.string.agent_voice_stop else R.string.agent_voice),
|
||||
if (voice.listening) pal.primary else pal.surfaceVariant, if (voice.listening) pal.onPrimary else pal.onBackground, "agent-voice",
|
||||
) {
|
||||
val start by rememberUpdatedState(onStart)
|
||||
val send by rememberUpdatedState(onSend)
|
||||
val setup by rememberUpdatedState(onSetup)
|
||||
val handsFree = {
|
||||
start()
|
||||
if (voice.listening) voice.locked = true
|
||||
}
|
||||
val toggle = {
|
||||
when {
|
||||
voice.listening -> voice.finish()
|
||||
context.checkSelfPermission(android.Manifest.permission.RECORD_AUDIO) == android.content.pm.PackageManager.PERMISSION_GRANTED -> onStart()
|
||||
ask != null -> ask.launch(android.Manifest.permission.RECORD_AUDIO)
|
||||
else -> android.widget.Toast.makeText(context, R.string.agent_voice_denied, android.widget.Toast.LENGTH_SHORT).show()
|
||||
!voiceReady(context) -> setup()
|
||||
else -> handsFree()
|
||||
}
|
||||
}
|
||||
val density = LocalDensity.current
|
||||
val lockPx = with(density) { 56.dp.toPx() }
|
||||
val cancelPx = with(density) { 72.dp.toPx() }
|
||||
var drag by remember { mutableStateOf(Offset.Zero) }
|
||||
val holding = voice.listening && !voice.locked
|
||||
val icon = when {
|
||||
voice.locked -> Icons.Outlined.MicOff
|
||||
holding && -drag.x > cancelPx / 2 && -drag.x > -drag.y -> Icons.Outlined.Close
|
||||
holding && -drag.y > lockPx / 2 -> Icons.Outlined.Lock
|
||||
else -> Icons.Outlined.Mic
|
||||
}
|
||||
val scale = if (holding) 1.12f + 0.12f * voice.level else 1f
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.padding(start = 6.dp).size(42.dp).graphicsLayer {
|
||||
scaleX = scale
|
||||
scaleY = scale
|
||||
}.clip(CircleShape).background(if (voice.listening) pal.primary else pal.surfaceVariant)
|
||||
.pointerInput(voice) {
|
||||
awaitEachGesture {
|
||||
val down = awaitFirstDown(pass = PointerEventPass.Initial)
|
||||
down.consume()
|
||||
if (voice.listening || !voiceReady(context)) {
|
||||
waitForUpOrCancellation(PointerEventPass.Initial)?.let {
|
||||
it.consume()
|
||||
toggle()
|
||||
}
|
||||
return@awaitEachGesture
|
||||
}
|
||||
start()
|
||||
var resolved = !voice.listening
|
||||
try {
|
||||
while (!resolved) {
|
||||
val change = awaitPointerEvent(PointerEventPass.Initial).changes.firstOrNull { it.id == down.id } ?: break
|
||||
// Compose ends a cancelled touch stream with a lift that arrives already consumed; that is not a release.
|
||||
if (!change.pressed && change.isConsumed) break
|
||||
change.consume()
|
||||
drag = change.position - down.position
|
||||
when {
|
||||
!voice.listening -> resolved = true
|
||||
drag.y < -lockPx -> {
|
||||
voice.locked = true
|
||||
resolved = true
|
||||
}
|
||||
drag.x < -cancelPx -> {
|
||||
voice.cancel()
|
||||
resolved = true
|
||||
}
|
||||
!change.pressed -> {
|
||||
val tap = change.uptimeMillis - down.uptimeMillis < viewConfiguration.longPressTimeoutMillis / 2 &&
|
||||
drag.getDistance() < viewConfiguration.touchSlop
|
||||
if (tap) voice.locked = true else voice.finish(send)
|
||||
resolved = true
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
drag = Offset.Zero
|
||||
if (!resolved && voice.listening && !voice.locked) voice.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
.clickable(onClick = toggle).testTag("agent-voice"),
|
||||
) {
|
||||
Icon(
|
||||
icon, stringResource(if (voice.listening) R.string.agent_voice_stop else R.string.agent_voice),
|
||||
tint = if (voice.listening) pal.onPrimary else pal.onBackground, modifier = Modifier.size(21.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** Attaches what the running game shows, taken from its own surface so nothing drawn over it is in the picture. */
|
||||
|
||||
Loaded 100 of 444 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user