Compare commits

..
445 changed files with 5820 additions and 13300 deletions

No files matched your search

-1
View File
@@ -1,6 +1,5 @@
ASEbrahim
FX192
FryMcNugget
K11MCH1
KeegantheVeganat0r
kingokksa
+1 -1
View File
@@ -25,7 +25,7 @@ jobs:
validate:
name: Validate source and build result
runs-on: ubuntu-24.04
timeout-minutes: 70
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
+6 -6
View File
@@ -195,17 +195,17 @@ jobs:
app/src/main/assets/linuxfs
!app/src/main/assets/linuxfs/usr/local/lib/droiddeck-comet
!app/src/main/assets/linuxfs/usr/local/lib/droiddeck-xbox
!app/src/main/assets/linuxfs/i386/libddsession.so
!app/src/main/assets/linuxfs/i386/libblsession.so
!app/src/main/assets/linuxfs/i386/libfakeinput.so
!app/src/main/assets/linuxfs/i386/libfaultreport.so
!app/src/main/assets/linuxfs/libddaudit.so
!app/src/main/assets/linuxfs/libddfastpath.so
!app/src/main/assets/linuxfs/libblaudit.so
!app/src/main/assets/linuxfs/libblfastpath.so
!app/src/main/assets/linuxfs/libddnatv-hook.so
!app/src/main/assets/linuxfs/libddsession.so
!app/src/main/assets/linuxfs/libblsession.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/libddsession.so
!app/src/main/assets/linuxfs/x86_64/libblsession.so
!app/src/main/assets/linuxfs/x86_64/libfakeinput.so
!app/src/main/assets/linuxfs/x86_64/libfaultreport.so
!app/src/main/assets/linuxfs/x86_64/libvulkan-thunk.so
@@ -291,7 +291,7 @@ jobs:
- name: Build the non-Adreno test additions (Mali bridge client, Venus GL probe, Xclipse layer)
run: |
set -euo pipefail
bash tools/ci/install-ubuntu-packages.sh gcc-aarch64-linux-gnu libc6-dev-arm64-cross libvulkan-dev
bash tools/ci/install-ubuntu-packages.sh gcc-aarch64-linux-gnu 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 \
+4 -5
View File
@@ -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, 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`).
Needs Docker, Java 17, the Android SDK and NDK, Rust via rustup, GitHub CLI, Python 3 and `zstd`.
```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), and its GL thunk hands X errors to the program's own error handler. 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). 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). 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`.
- 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`.
- 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,7 +97,6 @@ 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).
-13
View File
@@ -4,9 +4,6 @@
<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>
@@ -153,7 +150,6 @@
<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" />
@@ -302,15 +298,6 @@
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"
+1 -1
View File
@@ -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, "dd_udevmon_inject"));
static auto inject = reinterpret_cast<inject_fn>(dlsym(RTLD_DEFAULT, "bl_udevmon_inject"));
return inject ? inject(action, devpath, subsystem, devname, major, minor) : -1;
}
-100
View File
@@ -1,100 +0,0 @@
#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);
}
-443
View File
@@ -1,443 +0,0 @@
#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,
};
+1 -1
View File
@@ -26,7 +26,7 @@ add_library(droiddeckwayland SHARED
generated/linux-dmabuf-v1-protocol.c
generated/wayland-android-protocol.c
generated/viewporter-protocol.c
generated/droiddeck-desktop-v1-protocol.c
generated/banner-desktop-v1-protocol.c
generated/presentation-time-protocol.c
generated/pointer-constraints-unstable-v1-protocol.c
generated/relative-pointer-unstable-v1-protocol.c
@@ -38,7 +38,7 @@
extern const struct wl_interface wl_surface_interface;
static const struct wl_interface *droiddeck_desktop_v1_types[] = {
static const struct wl_interface *banner_desktop_v1_types[] = {
NULL,
&wl_surface_interface,
&wl_surface_interface,
@@ -47,16 +47,16 @@ static const struct wl_interface *droiddeck_desktop_v1_types[] = {
NULL,
};
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 },
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 },
};
WL_PRIVATE const struct wl_interface droiddeck_desktop_v1_interface = {
"droiddeck_desktop_v1", 1,
4, droiddeck_desktop_v1_requests,
WL_PRIVATE const struct wl_interface banner_desktop_v1_interface = {
"banner_desktop_v1", 1,
4, banner_desktop_v1_requests,
0, NULL,
};
@@ -1,6 +1,6 @@
#ifndef DROIDDECK_DESKTOP_V1_SERVER_PROTOCOL_H
#define DROIDDECK_DESKTOP_V1_SERVER_PROTOCOL_H
#ifndef BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
#define BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
#include <stdint.h>
#include <stddef.h>
@@ -14,7 +14,7 @@ struct wl_client;
struct wl_resource;
/*
* @section page_copyright_droiddeck_desktop_v1 Copyright
* @section page_copyright_banner_desktop_v1 Copyright
*
* Copyright 2026 The412Banner
*
@@ -42,15 +42,15 @@ struct wl_resource;
struct droiddeck_desktop_v1;
struct banner_desktop_v1;
struct wl_surface;
#ifndef DROIDDECK_DESKTOP_V1_INTERFACE
#define DROIDDECK_DESKTOP_V1_INTERFACE
extern const struct wl_interface droiddeck_desktop_v1_interface;
#ifndef BANNER_DESKTOP_V1_INTERFACE
#define BANNER_DESKTOP_V1_INTERFACE
extern const struct wl_interface banner_desktop_v1_interface;
#endif
struct droiddeck_desktop_v1_interface {
struct banner_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 droiddeck_desktop_v1_interface {
};
#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
#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
#ifdef __cplusplus
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="droiddeck_desktop_v1">
<protocol name="banner_desktop_v1">
<copyright>
Copyright 2026 The412Banner
@@ -23,7 +23,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="droiddeck_desktop_v1" version="1">
<interface name="banner_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 "droiddeck-desktop-v1-server-protocol.h"
#include "banner-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("DD_WAYLAND_LOG");
const char *given = getenv("BL_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 droiddeck_desktop_v1_interface desktop_impl = {
static const struct banner_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, &droiddeck_desktop_v1_interface, ver, id);
struct wl_resource *r = wl_resource_create(c, &banner_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, &droiddeck_desktop_v1_interface, 1, NULL, bind_desktop);
wl_global_create(display, &banner_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,7 +17,6 @@
#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"
@@ -42,7 +41,7 @@ struct fx_settings {
int color_on;
float brightness, contrast, gamma, saturation;
float b_raw, c_raw, s_raw;
int aa_mode, toon, crt, ntsc;
int fxaa, toon, crt, ntsc;
char look[48];
};
@@ -79,7 +78,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 aa_mode, int toon, int crt, int ntsc) {
int fxaa, 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;
@@ -88,8 +87,7 @@ 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.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;
g_set.fxaa = fxaa ? 1 : 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) {
@@ -105,7 +103,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->aa_mode != 0) + s->toon + s->color_on + cas_active(s) + s->hdr_on + s->ntsc + s->crt + s->deband_on;
return s->fxaa + 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) {
@@ -123,8 +121,7 @@ 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->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->fxaa) n += snprintf(line + n, sizeof(line) - n, ", FXAA 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");
@@ -155,10 +152,6 @@ 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;
@@ -209,7 +202,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_SMAA, 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_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;
@@ -445,7 +438,6 @@ 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");
@@ -454,7 +446,7 @@ static int objects_ensure(void) {
#undef MK
g_vk.DestroyShaderModule(g_dev, vert, NULL);
g_ready = 1;
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());
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());
return 0;
fail:
objects_destroy();
@@ -575,10 +567,9 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
cur = NULL; cur_ds = g_scene.ds;
}
enum { FX_FXAA, FX_SMAA, FX_TOON, FX_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND };
enum { FX_FXAA, FX_TOON, FX_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND };
int order[8], n = 0;
if (s->aa_mode == 1) order[n++] = FX_FXAA;
else if (s->aa_mode == 2) order[n++] = FX_SMAA;
if (s->fxaa) order[n++] = FX_FXAA;
if (s->toon) order[n++] = FX_TOON;
if (s->color_on) order[n++] = FX_COLOR;
if (cas_active(s)) order[n++] = FX_CAS;
@@ -593,7 +584,6 @@ 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,7 +11,6 @@ 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);
@@ -31,7 +30,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 aa_mode, int toon, int crt, int ntsc);
int fxaa, int toon, int crt, int ntsc);
void vkp_effects_set_look(const char *name);
#endif
@@ -2179,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 && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; }
if (fg) { 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, 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);
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);
}
JNIEXPORT void JNICALL
@@ -43,17 +43,15 @@ 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)
@@ -319,7 +319,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
refreshDrivers()
return
}
if (gpu.family.mali && !DriverPairs.autoEligible(gpu) &&
if (gpu.family.mali && DriverPairs.recommendedKey(gpu, emptyList()) == null &&
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}) eligible=${DriverPairs.autoEligible(gpu)}")
if (gpu.family.mali && !DriverPairs.autoEligible(gpu)) {
Log.i(TAG, "auto: ${gpu.name} (${gpu.family}) -> " + (DriverPairs.recommendedKey(gpu, emptyList()) ?: "no pair"))
if (gpu.family.mali && DriverPairs.recommendedKey(gpu, emptyList()) == null) {
// 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.autoEligible(gpu)) {
if (DriverPairs.recommendedKey(gpu, emptyList()) == null) {
autoStatus = activity.getString(R.string.drivers_none_to_set, gpu.supportText(activity, com.droiddeck.launcher.core.DeviceSupport.vkBridge(activity)).lowercase())
return
}
@@ -372,11 +372,7 @@ 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.
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)
}
SessionPrefs.ensurePowerVrAutoDrivers(activity)
autoStatus = activity.getString(R.string.drivers_powervr_builtin)
refreshDrivers()
}
@@ -208,6 +208,8 @@ 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)
@@ -909,16 +911,6 @@ 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
@@ -935,7 +927,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 ("soundtracks" !in com.droiddeck.launcher.ui.NavTabs.hidden) "sound:$soundtrackId" else "app:$soundtrackId"
navRequest = if (SessionPrefs.soundtracksEnabled(this)) "sound:$soundtrackId" else "app:$soundtrackId"
request.data = null
request.action = Intent.ACTION_MAIN
return
@@ -1243,6 +1235,8 @@ 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)
@@ -1255,8 +1249,6 @@ 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(
@@ -1340,7 +1332,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
animationsEnabled = animationsEnabled,
lowStorageWarning = lowStorageWarning,
launcherIcon = launcherIcon,
soundtracksEnabled = "soundtracks" !in com.droiddeck.launcher.ui.NavTabs.hidden,
gameStoresEnabled = gameStoresEnabled,
soundtracksEnabled = soundtracksEnabled,
soundtracksIngame = soundtracksIngame,
soundtracks = soundtracks,
soundtracksLoaded = soundtracksLoaded,
@@ -1500,7 +1493,6 @@ 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 ->
@@ -1616,6 +1608,8 @@ 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
@@ -2206,13 +2200,13 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
}
private fun refreshAndroidApps() {
if (!homeAppSelected && "android-apps" in com.droiddeck.launcher.ui.NavTabs.hidden) {
if (!homeAppSelected) {
++androidAppsListing
androidApps = emptyList()
return
}
val seq = ++androidAppsListing
if (homeAppSelected) HomePins.refresh(this)
HomePins.refresh(this)
Thread({
val apps = runCatching { HomeApp.launchableApps(this) }.getOrDefault(emptyList())
ui.post { if (seq == androidAppsListing) androidApps = apps }
@@ -2710,8 +2704,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
}
@Composable
private fun PerformanceHost(embedded: Boolean = false) {
if (embedded) androidx.compose.runtime.LaunchedEffect(Unit) { refreshCores() }
private fun PerformanceHost() {
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,
@@ -2757,7 +2750,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
SessionPrefs.setGameCpus(this, CpuCores.format(gameCores))
},
onDismiss = { showPerformance = false },
embedded = embedded,
)
}
@@ -3307,7 +3299,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.ui.DeveloperTools.load(this)
com.droiddeck.launcher.agent.AgentTab.load(this)
com.droiddeck.launcher.ui.NavTabs.load(this)
if (!switchLauncherIcon(LauncherIcon.DARK)) recreate()
}
@@ -191,7 +191,6 @@ 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
@@ -201,7 +200,6 @@ 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)
@@ -488,10 +486,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
drawerLayerOpen = false
drawerPinned = false
if (value) {
releaseHeldKeys()
drawerDocked = dockDrawer() && openDockedMenu()
}
if (value) drawerDocked = dockDrawer() && openDockedMenu()
drawerOpenState = value
if (!value && drawerDocked) closeDockedMenu()
}
@@ -505,9 +500,6 @@ 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 &&
@@ -547,9 +539,6 @@ 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)
@@ -667,13 +656,11 @@ 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) {
@@ -801,10 +788,9 @@ 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 = SessionPrefs.savedFpsLimit(this, fpsLimitKey())
SessionState.fpsLimit = 0
fpsLimit = 0
}
fpsLimit = SessionState.fpsLimit
cornerTap = SessionPrefs.drawerCornerTap(this)
applyOutputPacing()
if (!SessionState.running) {
SessionState.followScreen = followChoice()
@@ -828,7 +814,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
pointerCaptureRefused = false
if (usbMouse.active) updatePointerCapture()
} else {
releaseHeldInputOnCaptureLoss()
releaseHeldGuestInput()
uiHandler.postDelayed(::updatePointerCapture, 250)
}
}
@@ -886,10 +872,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
root.addView(controls)
}
keyboard = KeyboardHost(this).also { host ->
host.onImeChanged = ::onPrimaryImeChanged
host.onImeChanged = { updateDesktopKeyboardButton() }
root.addView(host)
}
desktopKeyboardButton = com.droiddeck.launcher.input.DesktopKeyboardButton(this) { showPrimaryKeyboard() }
desktopKeyboardButton = com.droiddeck.launcher.input.DesktopKeyboardButton(this) { keyboard?.show() }
.also { root.addView(it) }
touchpad = TouchpadGestures(PointerGestures.slop(this), pointerListener)
directTouchHold = DirectTouchHold(PointerGestures.slop(this), pointerListener, directTouchSink)
@@ -907,7 +893,6 @@ 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)
@@ -1105,7 +1090,6 @@ 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() }
@@ -1146,10 +1130,6 @@ 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,
@@ -1332,7 +1312,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; togglePrimaryKeyboard() },
onAndroidKeyboard = { pcKeyboardOpen = false; keyboard?.toggle() },
onClose = { pcKeyboardOpen = false },
)
if (!drawerDocked) SessionMenu(
@@ -1456,8 +1436,6 @@ 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(),
@@ -1620,11 +1598,8 @@ 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 ->
@@ -1654,7 +1629,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; togglePrimaryKeyboard() },
onKeyboard = { drawerOpen = false; pcKeyboardOpen = false; keyboard?.toggle() },
onHardwareKeyboard = ::togglePcKeyboard,
wowChatShown = com.droiddeck.launcher.ui.WowChat.isWow(AgentGuest.gameProgram),
wowChat = wowChat.remembered,
@@ -1885,7 +1860,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 = { togglePrimaryKeyboard() },
onKeyboard = { keyboard?.toggle() },
onSessionMenu = { drawerOpen = true },
onStopSteamVr = if (vr) ({ steamVrAction("stop") }) else null,
brightness = glasses.brightness,
@@ -1926,44 +1901,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private fun togglePcKeyboard() {
drawerOpen = false
hidePrimaryKeyboard()
keyboard?.hide()
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)
@@ -2748,7 +2691,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
val waylandLog = File(SessionPaths.beginOrCurrent(this), "wayland.log")
WaylandCompositor.setSessionLogFile(waylandLog)
try {
android.system.Os.setenv("DD_WAYLAND_LOG", waylandLog.path, true)
android.system.Os.setenv("BL_WAYLAND_LOG", waylandLog.path, true)
} catch (e: Exception) {
Log.w(TAG, "could not point the compositor's log at $waylandLog", e)
}
@@ -2941,8 +2884,7 @@ 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
// 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 running = display?.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)
@@ -3196,8 +3138,6 @@ 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() }
@@ -3716,6 +3656,7 @@ 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()
@@ -4074,23 +4015,16 @@ 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
}
selectedSecondScreenDisplay = SecondScreenDisplays.selection(selectedSecondScreenDisplay, candidates.map { it.id }, gameOnBottom) {
SessionState.secondScreenDisplay = it
}
if (selectedSecondScreenDisplay != oldSelectedDisplay) {
updateBottomGame()
}
bottomSwapAvailable = bottomGame != null || bottomGameDisplay() != null
if (selectedSecondScreenDisplay !in newIds) selectedSecondScreenDisplay = candidates.firstOrNull()?.id ?: -1
if (secondScreenMode != SecondScreenMode.NONE && candidates.isEmpty()) {
closeSecondScreen(reset = true)
SessionState.secondScreenAutoOpened = false
@@ -4112,22 +4046,12 @@ 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
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())
}
selectedSecondScreenDisplay = target.displayId
selectSecondScreenMode(openingPanel())
automaticPanel = secondScreenMode != SecondScreenMode.NONE
dualControlsProvisional = ::loading.isInitialized && loading.visible
}
@@ -4153,7 +4077,6 @@ 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)
}
@@ -4172,10 +4095,6 @@ 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)
@@ -4254,7 +4173,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
)
}
},
onSwap = if (bottomSwapAvailable) ({ putGameOnBottom(true) }) else null,
onSwap = if (bottomSwapAvailable && com.droiddeck.launcher.input.DualScreen.builtIn(target)) ({ putGameOnBottom(true) }) else null,
onDeckPanel = ::selectDeckPanel,
dashboard = if (bottomPages().isEmpty()) null else ({
DroidDeckTheme {
@@ -4358,7 +4277,6 @@ 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()
@@ -4498,7 +4416,6 @@ 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
@@ -4508,37 +4425,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
private fun openBottomKeyboard() {
val presentation = bottomKeyboardPresentation()
if (presentation == null) {
if (keyboardBelongsOnPrimary()) {
pendingFieldKeyboard = true
retryFieldKeyboard(hasWindowFocus())
}
return
}
pendingFieldKeyboard = false
if (fieldKeyboardOnPrimary) hidePrimaryKeyboard()
val presentation = bottomKeyboardPresentation() ?: return
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) {
hidePrimaryKeyboard()
keyboard?.takeIf { it.shown }?.hide()
wowChat.chatOpened()
}
}
@@ -4625,13 +4521,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
private fun updateKeyboardRoute() {
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)))
AgentGuest.routeKeyboard(this, SessionState.mode == SessionService.MODE_STEAM &&
(secondScreenPresentation?.showsKeyboard == true || dockDrawer()) &&
SessionPrefs.androidTextFieldKeyboard(this))
}
private fun dropDockedDrawer() {
@@ -4842,12 +4734,6 @@ 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)
@@ -4880,11 +4766,6 @@ 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
@@ -5034,10 +4915,6 @@ 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)
}
@@ -5072,9 +4949,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
}
}
if (screenTapsClick) directTouchHold.onTouch(event)
else if (!pointerLocked && (event.actionMasked == MotionEvent.ACTION_DOWN || event.actionMasked == MotionEvent.ACTION_MOVE))
movePointer(event.x, event.y)
directTouchHold.onTouch(event)
return true
}
@@ -5121,14 +4996,10 @@ 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()) && sessionOwnsInput() && hasWindowFocus() && mouseAttached()
val want = (pointerLocked || relativeMouseAttached()) && resumed && hasWindowFocus() && !drawerOpen && !pcKeyboardOpen && !achievementsOpen && !inputSettingsOpen && !pipUi && !bottomOutputActive && !touchEditorOpen && !wowChatOnTop && mouseAttached()
releaseDesktopMouseGrab()
updateUsbMouse(want)
if (want == view.hasPointerCapture()) return
@@ -5451,26 +5322,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private fun keyboardCoversPad() =
SessionState.mode == SessionService.MODE_STEAM && AgentGuest.steamKeyboard
private fun releaseHeldInputOnCaptureLoss() {
if (sessionOwnsInput()) releaseHeldPointerInput() else releaseHeldGuestInput()
}
private fun releaseHeldPointerInput() {
private fun releaseHeldGuestInput() {
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
@@ -5546,8 +5405,6 @@ 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
@@ -5567,7 +5424,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
guestKeysDown.toList().forEach { sendGuestKey(it, false) }
heldKeys.clear()
heldButtons.clear()
hidePrimaryKeyboard()
keyboard?.hide()
sessionClipboard.stop()
padMotion?.stop()
cursorVisible = false
@@ -5608,8 +5465,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
override fun startActivityForResult(intent: Intent, requestCode: Int, options: Bundle?) {
if (::pip.isInitialized && intent.component?.className != com.droiddeck.launcher.session.KeepTopActivity::class.java.name &&
(requestCode >= 0 || intent.component?.packageName == packageName ||
if (::pip.isInitialized && (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)
@@ -5641,7 +5497,6 @@ 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)
@@ -5685,12 +5540,6 @@ 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) }
@@ -5718,8 +5567,6 @@ 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 = {
@@ -5756,63 +5603,10 @@ 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) return
if (runtimeRemovalBlocked) { super.onPause(); return }
physicalShortcuts.clear()
backQamInput.cancel()
mouseBackInput.cancel()
@@ -5846,16 +5640,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
if (::scrollTouch.isInitialized) scrollTouch.cancel()
if (::padMouse.isInitialized) padMouse.reset()
resumed = false
updateKeyboardRoute()
updatePointerCapture()
updatePadMotion()
val pendingKeyboard = pendingFieldKeyboard
hidePrimaryKeyboard()
pendingFieldKeyboard = pendingKeyboard
keyboard?.takeIf { it.shown }?.hide()
SessionPrefs.sessionPrefs(this).unregisterOnSharedPreferenceChangeListener(cardboardPrefListener)
SessionPrefs.sessionPrefs(this).unregisterOnSharedPreferenceChangeListener(screenEffectsProfilePrefListener)
ControllerPrefs.prefs(this).unregisterOnSharedPreferenceChangeListener(shortcutPrefListener)
updateHeadTracker()
super.onPause()
}
private fun steamVrAction(action: String) {
@@ -6096,10 +5888,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
private fun bottomGameDisplay(): Display? {
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,
)
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) }
}
private fun putGameOnBottom(on: Boolean) {
@@ -6225,7 +6016,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) {
togglePrimaryKeyboard()
keyboard?.toggle()
}
val profileLayout = secondaryInputLayout
androidx.compose.foundation.layout.Box(
@@ -6253,9 +6044,8 @@ 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()).also { swappedInputSurface = it } },
surfaceStyle = profileLayout?.style ?: com.droiddeck.launcher.input.InputSurfaceStyle()) },
modifier = Modifier.fillMaxWidth().weight(1f),
onRelease = { if (swappedInputSurface === it) swappedInputSurface = null },
)
}
}
@@ -6422,7 +6212,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
releaseHeldGuestInput()
}
if (hasFocus && !pipUi) {
retryFieldKeyboard(true)
goFullscreen()
refreshClipboard()
}
@@ -6467,8 +6256,6 @@ 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,8 +58,7 @@ 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 == 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)) {
if (name == "libblfastpath.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)
@@ -74,7 +73,7 @@ object AgentEnv {
staged.delete()
throw AgentException("OVERRIDE_FAILED", "Could not stage the override")
}
if (name == "libddfastpath.so" && !arm64SharedLibrary(staged)) {
if (name == "libblfastpath.so" && !arm64SharedLibrary(staged)) {
staged.delete()
throw AgentException("INVALID_LIBRARY", "The fast path must be a 64-bit little-endian ARM64 ELF shared library")
}
@@ -87,7 +86,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 == "libddfastpath.so") {
if (name == "libblfastpath.so") {
val digest = MessageDigest.getInstance("SHA-256")
target.inputStream().use { input ->
val buffer = ByteArray(65536)
@@ -104,10 +103,10 @@ object AgentEnv {
fun fastPathLibrary(context: Context): String = synchronized(lock) {
if (!AgentAccess.commandsAllowed(context)) return@synchronized ProotFastPath.LIBRARY
if ("libddfastpath.so" !in strings(load(context).optJSONArray("activeOverrides"))) return@synchronized ProotFastPath.LIBRARY
val file = File(bin(context), "libddfastpath.so")
if ("libblfastpath.so" !in strings(load(context).optJSONArray("activeOverrides"))) return@synchronized ProotFastPath.LIBRARY
val file = File(bin(context), "libblfastpath.so")
if (!file.isFile || Files.isSymbolicLink(file.toPath())) return@synchronized ProotFastPath.LIBRARY
"$GUEST_BIN/libddfastpath.so"
"$GUEST_BIN/libblfastpath.so"
}
private fun arm64SharedLibrary(file: File): Boolean = file.inputStream().use { input ->
@@ -130,18 +129,13 @@ object AgentEnv {
}
val state = load(context)
val active = strings(state.optJSONArray("pending"))
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
val overrides = strings(state.optJSONArray("pendingOverrides"))
bin(context).listFiles()
?.filter { it.name !in overrides && !(stranded && it.name == LEGACY_FAST_PATH) }?.forEach { it.delete() }
?.filter { it.name !in overrides }?.forEach { it.delete() }
val lines = strings(state.optJSONArray("persistent")) + active
val withPath = if (overrides.none { it != "libddfastpath.so" }) lines else lines + "PATH=$GUEST_BIN:${pathOf(lines)}"
val withPath = if (overrides.none { it != "libblfastpath.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(if (stranded) listOf(FAST_PATH) else emptyList()))
state.put("activeOverrides", JSONArray(overrides)).put("pendingOverrides", JSONArray())
save(context, state)
if (withPath.isNotEmpty()) Log.i(TAG, "agent environment keys for this session: ${withPath.map { it.substringBefore('=') }}")
withPath
@@ -164,9 +158,6 @@ 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
@@ -195,9 +186,6 @@ 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
}
@@ -20,18 +20,13 @@ interface AgentHarness {
/** 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].
* Where the user makes an API key, for a CLI whose own sign-in is a terminal prompt: [signIn]
* then only opens this page, and the key is pasted into DroidDeck and saved by [saveKey].
*/
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) {}
val keyPage: String? get() = null
/** Whether a key from [keyPage] is saved under [rootfs]. */
fun hasKey(rootfs: File): Boolean = false
fun saveKey(rootfs: File, key: String) {}
/** Whether the CLI has models that need no account; [useFree] then counts as signed in. */
val free: Boolean get() = false
fun useFree(rootfs: File) {}
@@ -62,9 +57,6 @@ 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 {
@@ -420,117 +412,31 @@ object OpenCode : AgentHarness {
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!!)
"grep -q '\"type\"' /$AUTH 2>/dev/null || [ -e /$FREE ]")
override val keyPage = "https://opencode.ai/auth"
override val signIn = listOf("/root/.local/bin/android-open", 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()
}
override fun hasKey(rootfs: File) = runCatching { JSONObject(File(rootfs, AUTH).readText()).has("opencode") }.getOrDefault(false)
/**
* 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) {
/** The key opencode's own `auth login` would save for OpenCode Zen. */
override fun saveKey(rootfs: File, key: String) {
val file = File(rootfs, AUTH)
// An auth.json that cannot be read holds other providers' sign-ins too, so it is never replaced.
val auth = if (file.exists()) JSONObject(file.readText()) else JSONObject()
auth.put("opencode", JSONObject().put("type", "api").put("key", key.trim()))
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()
}
file.writeText(auth.toString(2) + "\n")
file.setReadable(false, false)
file.setReadable(true, true)
}
override fun useFree(rootfs: File) {
@@ -567,8 +473,7 @@ object OpenCode : AgentHarness {
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")
models += AgentHarness.Model(current, if (provider.isEmpty() || provider == "opencode") label else "$label · $provider")
o.optJSONObject("limit")?.optLong("context")?.takeIf { it > 0 }?.let { windows[current] = it }
}
id = null
@@ -27,52 +27,25 @@ 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>())
/** The harness has a key from its [AgentHarness.keyPage] saved; signed in without one means its free models. */
var keySaved by mutableStateOf(false)
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 saveKey(context: Context, key: String) = signInLocally(context) { harness, root -> harness.saveKey(root, key) }
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)) } }
val result = 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)
}
status[Step.SIGN_IN] = Status.UNKNOWN
result.exceptionOrNull()?.let { detail[Step.SIGN_IN] = it.message ?: "failed" }
check(app)
}
}, "agent-sign-in").start()
}
@@ -102,7 +75,7 @@ object AgentSetup {
if (!runtimeInstalled) return
AgentHost.refresh(app)
val harness = AgentHost.harness
keys = harness.keys(LinuxRuntime.rootDir(app))
keySaved = harness.hasKey(LinuxRuntime.rootDir(app))
val probes = mutableListOf<Pair<Step, List<String>>>()
for (step in Step.entries) if (status[step] != Status.WORKING) {
when (step) {
@@ -129,15 +102,10 @@ 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) = 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>?) {
fun run(context: Context, step: Step) {
val app = context.applicationContext
val harness = AgentHost.harness
val command = override ?: when (step) {
val command = when (step) {
Step.CONNECTION -> return
Step.INSTALL -> {
listOf("sh", "-c", "set -e; export DEBIAN_FRONTEND=noninteractive; " +
@@ -1,9 +1,23 @@
package com.droiddeck.launcher.agent
import com.droiddeck.launcher.ui.NavTabs
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
object AgentTab {
val shown: Boolean get() = "agent" !in NavTabs.hidden
var shown by mutableStateOf(true)
private set
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,7 +23,6 @@ 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)
@@ -98,14 +97,14 @@ object GameEnvironment {
val syncBackends = listOf(SessionPrefs.SYNC_NTSYNC, SessionPrefs.SYNC_FSYNC, SessionPrefs.SYNC_ESYNC, SessionPrefs.SYNC_WINESERVER)
val syncKeys = listOf("DD_SYNC", "DD_FSYNC_FIRST", "DD_SYNC_FALLBACK", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC", "PROTON_NO_NTSYNC", "WINEESYNC")
val syncKeys = listOf("BL_SYNC", "BL_FSYNC_FIRST", "BL_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("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")
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")
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("DD_FSYNC_FIRST", "1", R.string.game_env_fsync_first, Type.TOGGLE, listOf("0", "1")),
Option("BL_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,6 +1,5 @@
package com.droiddeck.launcher.core
import android.content.Context
import android.os.Process
import android.util.Log
import java.io.BufferedWriter
@@ -114,17 +113,7 @@ object SessionLogCapture {
}
}
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) {
fun dumpMemoryPressure(target: File) {
var temporary: File? = null
try {
val staged = File.createTempFile(target.name, ".part", target.parentFile).also { temporary = it }
@@ -161,8 +150,7 @@ 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" +
"\nAndroid's low memory killer (lmkd), read over Wireless debugging:\n${lowMemoryKiller(context)}"
"\n/proc/pressure/memory:\n$pressure\n/proc/meminfo:\n$meminfo\n/sys/class/kgsl/kgsl/page_alloc:\n$gpu"
)
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) && shortcutsCurrent(context),
shortcuts = shortcutsEnabled(context),
shortcutsRestricted = restrictedSettings(context),
suggested = !SessionPrefs.sessionPrefs(context).getBoolean("steam_integration_seen", false),
)
@@ -61,10 +61,6 @@ 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,17 +235,6 @@ 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,10 +40,12 @@ 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
@@ -725,15 +727,11 @@ fun FileManagerScreen(
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surfaceContainer)
.then(if (compactToolbar) Modifier.horizontalScroll(rememberScrollState()) else Modifier)
.padding(horizontal = 8.dp, vertical = 6.dp),
) {
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),
)
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 currentDriveLabel = stringResource(describeLocation(currentDir).driveLabel)
@@ -796,119 +794,113 @@ fun FileManagerScreen(
Spacer(Modifier.width(4.dp))
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),
)
}
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,
)
}
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) {
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))
Icon(Icons.Filled.Star, stringResource(R.string.fm_hide_favorites), tint = MaterialTheme.colorScheme.primary)
} 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 = { 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)
}
Icon(Icons.Filled.StarBorder, stringResource(R.string.fm_show_favorites), tint = MaterialTheme.colorScheme.onSurfaceVariant)
}
}
if (!pickMode && onExit != null) {
@@ -335,10 +335,7 @@ 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 {
if (guestPath(app, exe) != null) AddedExes.put(app, AddedExes.Entry(owner.path, exe.path))
return AddResult.Existing(it)
}
single(app, owner.path)?.takeIf { canonical(it.exe) == path }?.let { return AddResult.Existing(it) }
}
if (guestPath(app, exe) == null) {
(owner ?: exe.parentFile)?.takeIf { guestPath(app, it) == null }?.let { bindFolder(app, it) }
@@ -347,7 +344,7 @@ object AddedGames {
val folder = owner ?: exe.parentFile ?: return AddResult.NotFound
SessionPrefs.setAddedGameRemoved(app, folder.path, false)
SessionPrefs.setAddedGameExe(app, folder.path, exe.path)
AddedExes.put(app, AddedExes.Entry(folder.path, exe.path))
if (owner == null) 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,7 +222,16 @@ object Library {
internal fun concealedSteamApps(root: File): Set<Long> {
val config = AddedGames.accountConfig(root) ?: return emptySet()
val hidden = SteamHidden.read(root)
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 private = runCatching {
PRIVATE_APPS.find(File(config, "localconfig.vdf").readText())?.groupValues?.get(1)
?.split(',')?.mapNotNull { it.trim().toLongOrNull() }?.toSet()
@@ -1,78 +0,0 @@
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,7 +18,6 @@ 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"
@@ -113,12 +112,9 @@ object DriverPairs {
}
}
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))
/** 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" }
fun recommendedKey(
gpu: GpuInfo, pairs: List<DriverPair>,
@@ -129,7 +125,6 @@ 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,7 +118,9 @@ data class GpuInfo(
val samsung = Build.MANUFACTURER.equals("samsung", ignoreCase = true)
return GpuInfo(
name = when {
family == Family.POWERVR -> systemDriverName(SystemVulkanDriver.gpuName(), VulkanInfo.cachedOrNull())
family == Family.POWERVR -> SystemVulkanDriver.gpuName().let { gpu ->
VulkanInfo.cachedOrNull()?.get("device")?.takeIf { it.contains(gpu, ignoreCase = true) } ?: gpu
}
mali != null && mali.isNotEmpty() -> mali
!adreno -> Build.HARDWARE.ifBlank { UNNAMED }
model > 0 -> "Adreno $model"
@@ -132,9 +134,6 @@ 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 = "DD_VK_DRIVER";
public static final String ENV = "BL_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,36 +16,30 @@ data class ScreenEffects(
val hdr: Boolean = false,
val deband: Boolean = false,
val debandStrength: Int = 100,
val aaMode: Int = AA_OFF,
val fxaa: Boolean = false,
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 || aaMode != AA_OFF || toon || crt || ntsc
effectiveCas > 0 || hdr || deband || fxaa || 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(), aaMode, toon, crt, ntsc)
WaylandCompositor.nativeSetScreenEffects(brightness.toFloat(), contrast.toFloat(), gamma, saturation.toFloat(), fxaa, 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("aaMode", aaMode).put("fxaa", fxaa).put("toon", toon).put("crt", crt).put("ntsc", ntsc)
.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(
@@ -58,7 +52,7 @@ data class ScreenEffects(
hdr = json.optBoolean("hdr", false),
deband = json.optBoolean("deband", false),
debandStrength = json.optInt("debandStrength", 100).coerceIn(0, 200),
aaMode = json.optInt("aaMode", if (json.optBoolean("fxaa", false)) AA_FXAA else AA_OFF).coerceIn(AA_OFF, AA_SMAA),
fxaa = json.optBoolean("fxaa", false),
toon = json.optBoolean("toon", false),
crt = json.optBoolean("crt", false),
ntsc = json.optBoolean("ntsc", false),
@@ -85,13 +79,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, aaMode = ScreenEffects.AA_FXAA, deband = true),
Look("Cinematic", ScreenEffects(brightness = -4, contrast = 22, gamma = 1.10f, saturation = 88, cas = true, casLevel = 20, fxaa = true, 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, aaMode = ScreenEffects.AA_FXAA, deband = true),
Look("Filmic", ScreenEffects(brightness = -2, contrast = 16, gamma = 1.14f, saturation = 92, cas = true, casLevel = 15, fxaa = true, 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),
@@ -109,7 +103,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.aaMode == e.aaMode && t.crt == e.crt && t.toon == e.toon && t.ntsc == e.ntsc && t.deband == e.deband &&
t.fxaa == e.fxaa && 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("DD_GAMESCOPE_BACKEND=sdl");
environment.add("BL_GAMESCOPE_BACKEND=sdl");
// The Android pvr kernel accepts Vulkan DMA-BUF imports but rejects PRIME GEM handles.
environment.add("DD_POWERVR_DRM_HANDLES=1");
environment.add("DD_POWERVR_RENDER_NODE=" + node);
environment.add("BL_POWERVR_DRM_HANDLES=1");
environment.add("BL_POWERVR_RENDER_NODE=" + node);
// Inner Gamescope/Xwayland lacks the bridge's Android-buffer WSI protocols.
environment.add("DD_STEAM_GL_PRESENT=1");
environment.add("BL_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", "hudHold" to "collapse", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid",
"hudSize" to "minimal", "hudLocked" to "1", "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,8 +18,6 @@ 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,7 +119,6 @@ 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()
@@ -292,7 +291,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, DroidDeckHudDock.FLOAT -> 0f
DroidDeckHudDock.NONE -> 0f
}
if (pulled >= 1f) { setDock(hud, DroidDeckHudDock.NONE); return }
wantX = hud.x; wantY = hud.y
@@ -376,30 +375,12 @@ class DroidDeckHudHost(context: Context) {
hud.scaleX = s; hud.scaleY = s
}
private fun setDock(hud: DroidDeckHudView, edge: DroidDeckHudDock, center: Pair<Float, Float>? = null) {
private fun setDock(hud: DroidDeckHudView, edge: DroidDeckHudDock) {
if (edge == hud.dock) return
animateDock(hud, edge, center) { commitDock(hud, edge) }
animateDock(hud, edge) { 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
@@ -426,17 +407,12 @@ class DroidDeckHudHost(context: Context) {
SessionPrefs.setDroidDeckHudPosition(context, wantX, wantY)
}
private fun animateDock(hud: DroidDeckHudView, edge: DroidDeckHudDock, center: Pair<Float, Float>?, commit: () -> Unit) {
private fun animateDock(hud: DroidDeckHudView, edge: DroidDeckHudDock, 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)
@@ -448,14 +424,11 @@ class DroidDeckHudHost(context: Context) {
hud.pivotX = 0f; hud.pivotY = 0f
hud.x = left; hud.y = top
val (tabW, tabH) = hud.dockTabSize()
if (center == null) {
wantX = left + (shownW - tabW) / 2f
wantY = top + (shownH - tabH) / 2f
}
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 {
@@ -500,7 +473,7 @@ class DroidDeckHudHost(context: Context) {
DroidDeckHudDock.RIGHT -> x = maxX
DroidDeckHudDock.TOP -> y = 0f
DroidDeckHudDock.BOTTOM -> y = maxY
DroidDeckHudDock.NONE, DroidDeckHudDock.FLOAT -> {}
DroidDeckHudDock.NONE -> {}
}
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"), FLOAT("float");
NONE("none"), LEFT("left"), RIGHT("right"), TOP("top"), BOTTOM("bottom");
companion object {
fun from(token: String?): DroidDeckHudDock = values().firstOrNull { it.token == token } ?: NONE
@@ -191,8 +191,6 @@ 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 }
@@ -211,7 +209,6 @@ 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
@@ -227,7 +224,6 @@ 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
@@ -241,24 +237,19 @@ class DroidDeckHudView(context: Context) : View(context) {
tabDownRawX = event.rawX; tabDownRawY = event.rawY
tabStartX = x; tabStartY = y
tabDragging = false
tabPressed = true
}
MotionEvent.ACTION_MOVE -> if (tabPressed) {
MotionEvent.ACTION_MOVE -> {
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 -> if (tabPressed) {
tabPressed = false
MotionEvent.ACTION_UP -> {
if (tabDragging) { tabDragging = false; onTabDroppedListener?.run() }
else onDockChangedListener?.accept(DroidDeckHudDock.NONE.token)
}
MotionEvent.ACTION_CANCEL -> {
tabPressed = false
if (tabDragging) {
tabDragging = false
onTabDragCancelledListener?.run()
}
MotionEvent.ACTION_CANCEL -> if (tabDragging) {
tabDragging = false
onTabDragCancelledListener?.run()
}
}
return true
@@ -350,7 +341,6 @@ 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")) {
@@ -601,7 +591,7 @@ class DroidDeckHudView(context: Context) : View(context) {
DroidDeckHudDock.RIGHT -> intArrayOf(1, 2)
DroidDeckHudDock.TOP -> intArrayOf(0, 1)
DroidDeckHudDock.BOTTOM -> intArrayOf(2, 3)
DroidDeckHudDock.NONE, DroidDeckHudDock.FLOAT -> intArrayOf()
DroidDeckHudDock.NONE -> 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/.dd-clock"
private const val CLOCK_CONTROL_PATH = "tmp/.bl-clock"
fun forRoot(root: File) = GameFrameFeed(File(root, HudFrames.PATH), clockControl = File(root, CLOCK_CONTROL_PATH))
@@ -36,7 +36,6 @@ 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() {}
}
@@ -54,7 +53,6 @@ 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;
@@ -82,8 +80,6 @@ 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; }
@@ -123,10 +119,6 @@ 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,12 +82,6 @@ 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,16 +97,6 @@ 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,16 +53,6 @@ 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,8 +26,6 @@ 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(previousStickGeometry: Boolean = false): List<InputSurfaceElement> {
fun elements(): 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 { if (previousStickGeometry) widenStickPreviously(it) else widenStick(it) }.bounded()
buttonShape = if (c.id in shoulderIds) InputButtonShape.PILL else InputButtonShape.CIRCLE).let(::widenStick).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 widenStickPreviously(e: InputSurfaceElement): InputSurfaceElement {
private fun widenStick(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,16 +323,6 @@ 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,7 +32,6 @@ 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,7 +5,6 @@ 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) {
@@ -42,14 +41,6 @@ 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()
@@ -86,11 +77,8 @@ 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] }
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
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 aspect = layout.aspect.takeIf { it > 0f } ?: (long.toFloat() / short)
@@ -12,8 +12,6 @@ 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 {
@@ -58,7 +56,6 @@ 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();
@@ -243,7 +240,6 @@ 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;
@@ -529,23 +525,20 @@ public final class PadBridge {
float lx = event.getAxisValue(MotionEvent.AXIS_X);
float ly = event.getAxisValue(MotionEvent.AXIS_Y);
boolean wired = wiredXboxLayout(device, event.getSource());
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);
float rx = event.getAxisValue(wired ? MotionEvent.AXIS_RX : MotionEvent.AXIS_Z);
float ry = event.getAxisValue(wired ? 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;
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);
if (wired || hasAxis(device, source, MotionEvent.AXIS_LTRIGGER, MotionEvent.AXIS_BRAKE)) {
lt = axisTrigger(leftTrigger(event, wired), keyTriggers[slot], 0);
pad.leftTrigger = lt;
}
if (signedRight || hasAxis(device, source, MotionEvent.AXIS_RTRIGGER, MotionEvent.AXIS_GAS)) {
rt = axisTrigger(triggerValue(event, device, wired, rxRyStick, false), keyTriggers[slot], 1);
if (wired || hasAxis(device, source, MotionEvent.AXIS_RTRIGGER, MotionEvent.AXIS_GAS)) {
rt = axisTrigger(rightTrigger(event, wired), keyTriggers[slot], 1);
pad.rightTrigger = rt;
}
if (hasAxis(device, source, MotionEvent.AXIS_HAT_X)) {
@@ -603,92 +596,6 @@ 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();
@@ -1275,4 +1182,16 @@ 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,7 +42,6 @@ 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>()
@@ -88,21 +87,14 @@ 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 device = event.device
val wired = wiredLayout.getOrPut(event.deviceId) { PadBridge.wiredXboxLayout(device, event.source) }
val rxRyStick = PadBridge.rightStickUsesRxRy(event, device, rightStickLayouts)
val wired = wiredLayout.getOrPut(event.deviceId) { PadBridge.wiredXboxLayout(event) }
sticks.leftX = event.getAxisValue(MotionEvent.AXIS_X)
sticks.leftY = event.getAxisValue(MotionEvent.AXIS_Y)
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)
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)
}
val hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X)
val hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y)
@@ -137,7 +129,6 @@ 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()
@@ -216,7 +207,6 @@ 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,7 +42,6 @@ class ScrollTouchGestures(
private var flingY = 0f
private var flingAt = 0L
private var flinging = false
var clicks = true
private val longPress = Runnable {
held = true
@@ -87,7 +86,7 @@ class ScrollTouchGestures(
lastY = startY
tracker = VelocityTracker.obtain().also { it.addMovement(event) }
listener.onMove(startX, startY)
if (clicks) handler.postDelayed(longPress, TouchTiming.HOLD_MS)
handler.postDelayed(longPress, TouchTiming.HOLD_MS)
}
MotionEvent.ACTION_MOVE -> {
val index = event.findPointerIndex(pointerId).takeIf { it >= 0 } ?: return true
@@ -154,7 +153,6 @@ class ScrollTouchGestures(
private fun click(button: Int) {
releaseClick()
if (!clicks) return
listener.onButton(button, true)
clicked = button
handler.postDelayed(clickUp, TouchTiming.CLICK_MS)
@@ -40,18 +40,6 @@ 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,56 +178,4 @@ 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,11 +17,6 @@ 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
@@ -55,17 +50,12 @@ class TouchpadGestures(
held = true
dragging = true
listener.onLongPress()
press(PointerGestures.BTN_LEFT)
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
}
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)
@@ -118,12 +108,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 (clicks && event.eventTime - lastTapAt < TouchTiming.DOUBLE_TAP_MS) {
if (event.eventTime - lastTapAt < TouchTiming.DOUBLE_TAP_MS) {
dragging = true
press(PointerGestures.BTN_LEFT)
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
} else {
dragging = false
if (clicks) handler.postDelayed(longPress, TouchTiming.HOLD_MS)
handler.postDelayed(longPress, TouchTiming.HOLD_MS)
}
return true
}
@@ -163,7 +153,7 @@ class TouchpadGestures(
secondWasTap = false
if (!dragging) {
dragging = true
press(PointerGestures.BTN_LEFT)
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
}
}
}
@@ -218,15 +218,12 @@ object BwrapSpawner {
private fun runtimeLib(rootfs: String, name: String): File? =
LIB_DIRS.map { File(rootfs, "$it/$name") }.firstOrNull { it.exists() }
internal fun gpu(
rootfs: String, root: File, env: MutableMap<String, String>,
kgslAvailable: Boolean = File("/dev/kgsl-3d0").exists(),
): List<Bind>? {
private fun gpu(rootfs: String, root: File, env: MutableMap<String, String>): 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 || !kgslAvailable) return null
if (driver == null || !File("/dev/kgsl-3d0").exists()) return null
if (env.containsKey("VK_ICD_FILENAMES") || env.containsKey("VK_DRIVER_FILES")) return null
if (env["LIBGL_ALWAYS_SOFTWARE"] == "1" && env["GAMESCOPE_WAYLAND_DISPLAY"] == null) return null
if (env["BL_DESKTOP"] == "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
@@ -0,0 +1,229 @@
package com.droiddeck.launcher.runtime
import android.content.Context
import android.os.StatFs
import android.util.Log
import com.droiddeck.launcher.R
import com.droiddeck.launcher.session.GameStorage
import com.droiddeck.launcher.session.SecondaryLibrary
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.session.SessionState
import java.io.File
import java.io.IOException
import java.nio.file.Files
import java.nio.file.FileVisitResult
import java.nio.file.LinkOption
import java.nio.file.Path
import java.nio.file.SimpleFileVisitor
import java.nio.file.attribute.BasicFileAttributes
object FlatpakData {
private const val TAG = "FlatpakData"
private const val DIR = "flatpak-data"
private const val HOST = "root/.var/app"
private const val GUEST = "/root/.var/app"
private const val KEPT = ".ld.so"
private const val RESERVE = 64L shl 20
private val ID = Regex("(?!\\.+$)[A-Za-z0-9_.-]+")
private const val SEP = ">"
private val lock = Any()
fun enabled(context: Context): Set<String> = SessionPrefs.flatpakCardData(context).map { it.substringBefore(SEP) }.toSet()
fun available(context: Context): Boolean = GameStorage.effective(context) != null
private fun pins(context: Context): Map<String, File> =
SessionPrefs.flatpakCardData(context).mapNotNull { entry ->
val id = entry.substringBefore(SEP)
val path = entry.substringAfter(SEP, "")
if (path.isEmpty() || !ID.matches(id)) null else id to File(path)
}.toMap()
private fun storage(context: Context, id: String): File? {
val pinned = pins(context)[id] ?: return GameStorage.effective(context)?.let { File(it.path) }
return pinned.takeIf { GameStorage.attached(it) }
}
private fun cardIn(storage: File, id: String) = File(File(SecondaryLibrary.contentPath(storage), DIR), id)
internal fun internalDir(context: Context, id: String) = File(LinuxRuntime.rootDir(context), "$HOST/$id")
fun binds(
context: Context,
unmark: (String) -> Boolean = { SessionPrefs.setFlatpakDataMoving(context, it, false) },
writable: (File) -> Boolean = { it.canWrite() },
): List<String> = synchronized(lock) {
pins(context).toSortedMap().flatMap { (id, storage) ->
bind(context, id, storage, writable).ifEmpty { internalSession(context, id, unmark) }
}
}
private fun internalSession(context: Context, id: String, unmark: (String) -> Boolean): List<String> {
val internal = internalDir(context, id)
val marker = marker(id, internal)
if (marker !in SessionPrefs.flatpakDataMoving(context) || unmark(marker)) return emptyList()
Log.w(TAG, "$id: the move-back journal could not be cleared; the session gets an empty data folder")
val scratch = File(internal.parentFile, ".${internal.name}.unsaved")
if (!remove(scratch) || !scratch.mkdirs()) {
Log.w(TAG, "$id: the empty data folder could not be prepared")
return emptyList()
}
return listOf("${scratch.path}:$GUEST/$id")
}
private fun bind(context: Context, id: String, storage: File, writable: (File) -> Boolean): List<String> {
if (!GameStorage.attached(storage)) {
Log.w(TAG, "$id: its game storage is not attached; internal data this session")
return emptyList()
}
val card = cardIn(storage, id)
val guest = internalDir(context, id)
val kept = File(guest, KEPT)
if (linked(card) || linked(guest)) {
Log.w(TAG, "$id: a data folder is a symbolic link; internal this session")
return emptyList()
}
try {
purge(guest)
purge(card)
} catch (e: Exception) {
Log.w(TAG, "$id: the old copy of a moved folder could not be removed", e)
}
if (!card.isDirectory && !card.mkdirs() || !kept.isDirectory && !kept.mkdirs() || !File(card, KEPT).isDirectory && !File(card, KEPT).mkdirs()) {
Log.w(TAG, "$id: data folder could not be prepared; internal this session")
return emptyList()
}
if (!writable(card)) {
Log.w(TAG, "$id: game storage is read-only; internal this session")
return emptyList()
}
return listOf("${card.path}:$GUEST/$id", "${kept.path}:$GUEST/$id/$KEPT")
}
fun move(
context: Context, id: String, toCard: Boolean, onProgress: (String, Int) -> Unit,
freeBytes: (File) -> Long = { runCatching { StatFs(it.path).availableBytes }.getOrDefault(0L) },
writable: (File) -> Boolean = { it.canWrite() },
): String? = synchronized(lock) {
if (!ID.matches(id)) return@synchronized context.getString(R.string.store_data_failed)
if (SessionState.occupied) return@synchronized context.getString(R.string.store_data_session)
val storage = storage(context, id) ?: return@synchronized context.getString(R.string.store_data_no_storage)
val card = cardIn(storage, id)
val pin = marker(id, storage)
val internal = internalDir(context, id)
val from = if (toCard) internal else card
val to = if (toCard) card else internal
onProgress(context.getString(R.string.store_data_moving), -1)
val staging = File(to.parentFile, ".${to.name}.moving")
val marker = marker(id, to)
val placed = ArrayList<File>()
try {
if (linked(to) || linked(from) || hasSymlink(from)) return@synchronized context.getString(R.string.store_data_symlinks)
if (!to.isDirectory && !to.mkdirs()) throw IOException("could not create ${to.path}")
if (card.exists() && !writable(card)) throw IOException("${card.path} is read-only")
purge(from)
purge(to)
if (entries(to).isNotEmpty()) {
if (marker !in SessionPrefs.flatpakDataMoving(context)) return@synchronized context.getString(R.string.store_data_failed)
clear(to)
}
val bytes = size(from)
val free = freeBytes(to)
if (free < bytes + RESERVE) return@synchronized context.getString(R.string.store_data_space, com.droiddeck.launcher.core.FileUtils.sizeToString(free))
SessionPrefs.flatpakDataMoving(context).filter { it.startsWith("$id$SEP") && it != marker }.forEach { SessionPrefs.setFlatpakDataMoving(context, it, false) }
if (!SessionPrefs.setFlatpakDataMoving(context, marker, true)) throw IOException("could not record the move")
if (!remove(staging)) throw IOException("could not clear ${staging.path}")
staging.mkdirs()
entries(from).forEach { it.copyRecursively(File(staging, it.name), overwrite = true) }
if (size(staging) != bytes) throw IOException("copy is ${size(staging)} bytes, expected $bytes")
for (entry in entries(staging)) {
val target = File(to, entry.name)
if (!entry.renameTo(target)) throw IOException("could not place ${target.path}")
placed.add(target)
}
remove(staging)
if (!SessionPrefs.setFlatpakCardData(context, pin, toCard)) {
SessionPrefs.setFlatpakCardData(context, pin, !toCard)
throw IOException("could not save the data location")
}
} catch (e: Exception) {
Log.w(TAG, "$id: move to ${if (toCard) "game storage" else "internal"} failed", e)
val cleaned = placed.map { remove(it) }.all { it } && remove(staging) && runCatching { entries(to).isEmpty() }.getOrDefault(false)
if (cleaned) SessionPrefs.setFlatpakDataMoving(context, marker, false)
return@synchronized context.getString(R.string.store_data_failed)
}
try {
retire(from)
if (!toCard && !remove(from)) throw IOException("could not remove ${from.path}")
SessionPrefs.setFlatpakDataMoving(context, marker, false)
null
} catch (e: Exception) {
Log.w(TAG, "$id: the data moved but the old copy could not be removed", e)
context.getString(R.string.store_data_failed)
}
}
internal fun marker(id: String, to: File) = "$id$SEP${to.path}"
private fun trash(dir: File) = File(dir.parentFile, ".${dir.name}.old")
private fun purge(dir: File) {
val old = trash(dir)
if (!remove(old)) throw IOException("could not remove ${old.path}")
}
private fun retire(dir: File) {
purge(dir)
val old = trash(dir)
val entries = entries(dir)
if (entries.isEmpty()) return
if (!old.mkdirs()) throw IOException("could not create ${old.path}")
entries.forEach { if (!it.renameTo(File(old, it.name))) throw IOException("could not retire ${it.path}") }
purge(dir)
}
private fun clear(dir: File) {
entries(dir).forEach { if (!remove(it)) throw IOException("could not remove ${it.path}") }
}
internal fun entries(dir: File): List<File> {
if (!dir.exists()) return emptyList()
val all = dir.listFiles() ?: throw IOException("could not list ${dir.path}")
return all.filter { it.name != KEPT }
}
private fun remove(path: File): Boolean {
val target = path.toPath()
if (!Files.exists(target, LinkOption.NOFOLLOW_LINKS)) return true
return try {
Files.walkFileTree(target, object : SimpleFileVisitor<Path>() {
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
Files.delete(file)
return FileVisitResult.CONTINUE
}
override fun postVisitDirectory(dir: Path, exc: IOException?): FileVisitResult {
if (exc != null) throw exc
Files.delete(dir)
return FileVisitResult.CONTINUE
}
})
true
} catch (e: IOException) {
Log.w(TAG, "could not remove ${path.path}", e)
false
}
}
private fun walk(top: File) = top.walkTopDown().onFail { _, e -> throw e }
private fun isLink(dir: File) = Files.isSymbolicLink(dir.toPath())
private fun linked(dir: File) = isLink(dir) || dir.parentFile?.let(::isLink) == true
internal fun hasSymlink(dir: File): Boolean =
isLink(dir) || entries(dir).any { top -> walk(top).any { Files.isSymbolicLink(it.toPath()) } }
internal fun size(dir: File): Long =
entries(dir).sumOf { top -> walk(top).filter { Files.isRegularFile(it.toPath(), LinkOption.NOFOLLOW_LINKS) }.sumOf { it.length() } }
}
@@ -21,10 +21,6 @@ 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/",
@@ -42,20 +38,6 @@ 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/libddfastpath.so"
const val LIBRARY = "/usr/local/lib/libblfastpath.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("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("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(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["DD_SYNC_FALLBACK"] == "1" }
(listOf(config.shared) + config.games.values).any { it["BL_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(
"DD_FEX_TAG=${build.tag}",
"DD_FEX_SHA256=${build.sha256}",
"DD_FEX_URLS=" + sources.joinToString(" "),
"BL_FEX_TAG=${build.tag}",
"BL_FEX_SHA256=${build.sha256}",
"BL_FEX_URLS=" + sources.joinToString(" "),
)
}
@@ -2,7 +2,6 @@ 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
@@ -10,7 +9,6 @@ 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"
@@ -21,16 +19,7 @@ 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 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()
}
return decode(JSONObject(bytes.toString(Charsets.UTF_8)))
}
fun decode(json: JSONObject): GameEnvironment.Config {
@@ -40,8 +29,7 @@ object GameEnvironmentStore {
require(GameEnvironment.validName(name))
val entry = value.get(name)
require(entry == JSONObject.NULL || entry is String && GameEnvironment.validValue(entry))
val current = GameEnvironment.currentName(name)
if (current == name || !value.has(current)) put(current, if (entry == JSONObject.NULL) null else entry as String)
put(name, if (entry == JSONObject.NULL) null else entry as String)
}
}
val games = json.optJSONObject("games")
@@ -64,9 +52,10 @@ object GameEnvironmentStore {
@Synchronized
fun save(context: Context, config: GameEnvironment.Config) {
val normalized = decode(encode(config))
write(File(context.filesDir, SETTINGS), encode(normalized).toString())
publish(context, normalized)
val json = encode(config)
decode(json)
write(File(context.filesDir, SETTINGS), json.toString())
publish(context, config)
}
@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_", "DD_VK", "DD_DRM", "DD_VKBRIDGE", "VKBRIDGE", "MESA_", "GALLIUM_", "ZINK", "TU_", "PANVK",
"DROIDDECK_POWERVR", "DROIDDECK_HYBRIS", "DD_GAME_LOGS", "LIBGL_", "GAMESCOPE_DISABLE", "XWAYLAND",
"VK_", "BL_VK", "BL_DRM", "BL_VKBRIDGE", "VKBRIDGE", "MESA_", "GALLIUM_", "ZINK", "TU_", "PANVK",
"DROIDDECK_POWERVR", "DROIDDECK_HYBRIS", "BL_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,17 @@
package com.droiddeck.launcher.session
internal class GuestLaunchGate {
private val lock = Object()
private var pending = 0
fun begin() = synchronized(lock) { pending++ }
fun end() = synchronized(lock) {
pending--
lock.notifyAll()
}
fun await() = synchronized(lock) {
while (pending > 0) lock.wait()
}
}
@@ -1,91 +0,0 @@
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())
}
}
}
@@ -1,32 +0,0 @@
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), ".dd-proton-extra")
private fun requests(context: Context) = File(home(context), ".bl-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 libddsession")
appendLine("GPUOBJ fallback installed in Android driver and ARM64 libblsession")
appendLine("Experimental Quest 2/3/3S compatibility; 2D panel application")
}
Log.i(TAG, report)
@@ -544,7 +544,6 @@ 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() &&
@@ -598,7 +597,7 @@ object SessionArtifacts {
}
val memoryLog = File(dir, "memory-pressure.log")
if (newest && !memoryLog.exists()) {
SessionLogCapture.dumpMemoryPressure(memoryLog, context)
SessionLogCapture.dumpMemoryPressure(memoryLog)
}
if (stopWhenSessionStarts && SessionState.running) {
record.failed = true
@@ -687,21 +686,5 @@ 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",
"libddsession.so" to "usr/local/lib/libddsession.so",
"libblsession.so" to "usr/local/lib/libblsession.so",
"libfakeinput.so" to "usr/local/lib/libfakeinput.so",
"libddfastpath.so" to "usr/local/lib/libddfastpath.so",
"libblfastpath.so" to "usr/local/lib/libblfastpath.so",
"libddnatv-hook.so" to "usr/lib/libddnatv-hook.so",
"libddaudit.so" to "usr/local/lib/libddaudit.so",
"libblaudit.so" to "usr/local/lib/libblaudit.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("libddsession.so", "libfakeinput.so", "libfaultreport.so").map { "$arch/$it" to "usr/local/lib/droiddeck-fex/$arch/$it" }
listOf("libblsession.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/libddsession.so\n")
val preload = StringBuilder("/usr/local/lib/libblsession.so\n")
if (!File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()) {
preload.append("/usr/local/lib/libfakeinput.so\n")
}
@@ -203,6 +203,18 @@ 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) {
@@ -255,55 +267,16 @@ 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 developerTools(context: Context): Boolean =
prefs(context).getBoolean("developerTools", com.droiddeck.launcher.agent.AgentAccess.commandsEnabled(context))
fun agentTab(context: Context): Boolean = prefs(context).getBoolean("agentTab", true)
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 setAgentTab(context: Context, show: Boolean) {
prefs(context).edit().putBoolean("agentTab", show).apply()
}
fun libraryShowUninstalled(context: Context): Boolean = prefs(context).getBoolean("libraryShowUninstalled", false)
@@ -318,36 +291,8 @@ 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()
}
@@ -364,35 +309,13 @@ object SessionPrefs {
prefs(context).edit().putString("navTabOrder", order.joinToString(",")).apply()
}
fun navTabShelved(context: Context): Set<String>? = prefs(context).getString("navTabShelved", null)?.let { idList(it).toSet() }
fun navTabShelved(context: Context): Set<String> = idList(prefs(context).getString("navTabShelved", "soundtracks,agent")).toSet()
fun setNavTabShelved(context: Context, keys: Set<String>) {
prefs(context).edit().putString("navTabShelved", keys.joinToString(",")).apply()
}
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 navTabHidden(context: Context): Set<String> = idList(prefs(context).getString("navTabHidden", null)).toSet()
fun setNavTabHidden(context: Context, keys: Set<String>) {
prefs(context).edit().putString("navTabHidden", keys.joinToString(",")).apply()
@@ -697,42 +620,14 @@ object SessionPrefs {
}
@JvmStatic
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)
fun ensurePowerVrAutoDrivers(context: Context) {
if (com.droiddeck.launcher.core.DeviceSupport.openDriverActive(context)) return
ensurePowerVrAutoDrivers(context, SystemVulkanDriver.isPowerVr())
}
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) {
internal fun ensurePowerVrAutoDrivers(context: Context, powerVr: Boolean) {
if (!powerVr || gpuDriverMode(context) != GPU_DRIVERS_AUTO) return
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()
prefs(context).edit().putString("linuxDriver", "").putString("androidDriver", TurnipDriver.AUTO).apply()
}
fun gpuAutoInstalled(context: Context): Set<String> =
@@ -766,7 +661,7 @@ object SessionPrefs {
}
private fun shaderPrecacheApplied(context: Context) =
java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.dd-shader-precache-applied")
java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.bl-shader-precache-applied")
fun pendingShaderPrecache(context: Context): Boolean? {
val prefs = prefs(context)
@@ -1598,7 +1493,7 @@ object SessionPrefs {
}
val upscalerChoices = listOf(
2 to "Nearest", 0 to "Linear", 4 to "AMD FSR 1", 3 to "Snapdragon GSR",
0 to "Linear", 2 to "Nearest", 4 to "AMD FSR 1", 3 to "Snapdragon GSR",
8 to "Snapdragon GSR (quality)", 7 to "NVIDIA NIS", 6 to "Sharpen only",
)
@@ -1613,12 +1508,12 @@ object SessionPrefs {
fun canonicalUpscaler(mode: Int): Int = when (mode) {
1 -> 0
5 -> 4
else -> mode.takeIf { m -> upscalerChoices.any { it.first == m } } ?: 2
else -> mode.takeIf { m -> upscalerChoices.any { it.first == m } } ?: 0
}
fun upscalerHasSharpness(mode: Int): Boolean = canonicalUpscaler(mode) in 3..8
fun upscaler(context: Context): Int = canonicalUpscaler(prefs(context).getInt("upscaler", 2))
fun upscaler(context: Context): Int = canonicalUpscaler(prefs(context).getInt("upscaler", 0))
fun setUpscaler(context: Context, mode: Int) {
prefs(context).edit().putInt("upscaler", canonicalUpscaler(mode)).apply()
@@ -2016,6 +1911,21 @@ object SessionPrefs {
prefs(context).edit().putString("gameStorage", path).putString("gameStorageLabel", label).apply()
}
fun flatpakCardData(context: Context): Set<String> = idSet(context, "flatpakCardData")
fun setFlatpakCardData(context: Context, id: String, on: Boolean): Boolean = commitId(context, "flatpakCardData", id, on)
fun flatpakDataMoving(context: Context): Set<String> = idSet(context, "flatpakDataMoving")
fun setFlatpakDataMoving(context: Context, marker: String, on: Boolean): Boolean = commitId(context, "flatpakDataMoving", marker, on)
private fun idSet(context: Context, key: String): Set<String> = prefs(context).getStringSet(key, null)?.toSet().orEmpty()
private fun commitId(context: Context, key: String, id: String, on: Boolean): Boolean {
val current = idSet(context, key)
return prefs(context).edit().putStringSet(key, if (on) current + id else current - id).commit()
}
fun steamLibraries(context: Context): String = prefs(context).getString("steamLibraries", "") ?: ""
fun setSteamLibraries(context: Context, json: String) {
@@ -67,6 +67,7 @@ class SessionService : Service() {
private var wakeLock: PowerManager.WakeLock? = null
private var wifiLock: WifiManager.WifiLock? = null
private var sessionPid = -1
private val guestLaunch = GuestLaunchGate()
private val auxiliaryProcesses = HashMap<Int, Long>()
private val auxiliaryProcessesLock = Any()
private val mainHandler = Handler(Looper.getMainLooper())
@@ -411,7 +412,6 @@ 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),
@@ -497,7 +497,7 @@ class SessionService : Service() {
private fun runSession(gen: Int) {
SessionPrefs.ensurePowerVrAutoDriversAfterGpuQuery(this)
SessionPrefs.ensurePowerVrAutoDrivers(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 {
@@ -612,7 +612,7 @@ class SessionService : Service() {
stopSession(-1, gen)
return
}
if (steamHere) guest.add("DD_EPIC_APP_ID=" + com.droiddeck.launcher.stores.epic.EpicClient.shortcutAppId)
if (steamHere) guest.add("BL_EPIC_APP_ID=" + com.droiddeck.launcher.stores.epic.EpicClient.shortcutAppId)
val fastPathAt = guest.size
val pulse = SessionEvents.step("audio") { startAudio(guest, sessionDir, directAudioPack) }
@@ -624,36 +624,36 @@ class SessionService : Service() {
val encoder = VideoEncodeBridge(File(filesDir, "venc/venc.sock"))
encoder.attach(this)
components.add(encoder)
guest.add("DD_VENC_SOCKET=" + encoder.socket.absolutePath)
guest.add("BL_VENC_SOCKET=" + encoder.socket.absolutePath)
}
com.droiddeck.launcher.gpu.ClockLogComponent(File(sessionDir, "clocks.log")).let {
it.attach(this)
components.add(it)
}
guest.add("DD_WIDTH=" + size.first)
guest.add("DD_HEIGHT=" + size.second)
guest.add("BL_WIDTH=" + size.first)
guest.add("BL_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("DD_GAME_WIDTH=$w")
guest.add("DD_GAME_HEIGHT=$h")
guest.add("BL_GAME_WIDTH=$w")
guest.add("BL_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("DD_FOLLOW_OUTPUT=1")
guest.add("BL_FOLLOW_OUTPUT=1")
if (SessionState.hdr) {
guest.add("DD_HDR=1")
guest.add("BL_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("DD_REFRESH=" + Math.round(SessionState.refreshHz))
guest.add("DD_LOG=" + sessionLog.path)
guest.add("DD_DEBUG_DIR=" + sessionDir.path)
guest.add("BL_REFRESH=" + Math.round(SessionState.refreshHz))
guest.add("BL_LOG=" + sessionLog.path)
guest.add("BL_DEBUG_DIR=" + sessionDir.path)
if (EnhancedDiagnostics.isActive(this, sessionDir)) guest.add("DROIDDECK_ENHANCED_DIAGNOSTICS=1")
val fakeInputDir = File(sessionRoot, "dev/input").apply { mkdirs() }
@@ -666,7 +666,7 @@ class SessionService : Service() {
SessionEvents.step("controller-sync") { SessionState.padBridge?.syncConnectedControllers() }
}
val noSteamGame = noSteamGame()
if (noSteamGame) guest.add("DD_PIN_CORES=0")
if (noSteamGame) guest.add("BL_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) }
@@ -676,19 +676,17 @@ 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("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")
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")
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("DD_LIBRARY_LABEL=" + it.label.replace('"', ' ')) }
if (SessionState.mode == MODE_STEAM && SessionState.steamUi == "desktop") guest.add("DD_STEAM_UI=desktop")
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")
// 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("DD_GAME_LOGS=1")
if (GraphicsReport.detailed(this)) guest.add("BL_GAME_LOGS=1")
SessionEvents.step("graphics-report") { GraphicsReport.begin(this, sessionDir, guest) }
val shellGuest = ArrayList(guest).apply {
add("SHELL=/bin/bash")
@@ -823,17 +821,38 @@ class SessionService : Service() {
watchLaunchRequests(sessionRoot)
watchSyncWanted(root)
EsyncPacks.fetchInBackground(this, root)
val pid = SessionEvents.step("guest-launch") { HostProcess.start(line, hostEnv.asArray(), root, { status ->
if (gen != sessionGen) {
Log.i(TAG, "an earlier session's process ended ($status); the current one carries on")
return@start
val launchHeld = synchronized(stopLock) {
(gen == sessionGen && SessionState.running).also { if (it) guestLaunch.begin() }
}
if (!launchHeld) {
Log.i(TAG, "session stopped while it was starting; not launching it")
if (gen == sessionGen) {
launchWatcher?.stopWatching()
launchWatcher = null
syncWatcher?.stopWatching()
syncWatcher = null
}
val program = programStatus(sessionRoot)
Log.i(TAG, "session ended: $status" + if (program != null) " (program $program)" else "")
stopSession(program ?: status ?: -1, gen)
}, null, sessionLog.takeIf { "PROOT_PROFILE=1" in hostEnv.asArray() }) }
return
}
val pid = try {
SessionEvents.step("guest-launch") { HostProcess.start(line, hostEnv.asArray(), root, { status ->
if (gen != sessionGen) {
Log.i(TAG, "an earlier session's process ended ($status); the current one carries on")
return@start
}
val program = programStatus(sessionRoot)
Log.i(TAG, "session ended: $status" + if (program != null) " (program $program)" else "")
stopSession(program ?: status ?: -1, gen)
}, null, sessionLog.takeIf { "PROOT_PROFILE=1" in hostEnv.asArray() }) }
} catch (e: Throwable) {
guestLaunch.end()
throw e
}
Log.i(TAG, "session pid $pid, log ${sessionLog.path}")
if (gen != sessionGen || !SessionState.running) {
val stoppedDuringLaunch = synchronized(stopLock) {
(gen != sessionGen || !SessionState.running).also { if (!it) sessionPid = pid }
}
if (stoppedDuringLaunch) {
Log.i(TAG, "session stopped while its guest was starting; taking it down")
if (gen == sessionGen) {
launchWatcher?.stopWatching()
@@ -843,14 +862,24 @@ class SessionService : Service() {
components.reversed().forEach { runCatching { it.stop() } }
components.clear()
}
if (pid > 1) Thread({ teardown(pid) }, "session-teardown").start()
if (pid > 1) {
Thread({
try { teardown(pid) } finally { guestLaunch.end() }
}, "session-teardown").start()
} else {
guestLaunch.end()
}
return
}
sessionPid = pid
if (pid > 1) {
raiseTracer(pid, gen)
SessionEvents.guestStarted(pid)
try {
raiseTracer(pid, gen)
SessionEvents.guestStarted(pid)
} finally {
guestLaunch.end()
}
} else {
guestLaunch.end()
SessionEvents.record("guest.start_failed", mapOf("pid" to pid))
failSession(gen, "GUEST_START_FAILED", "The guest process could not be started", pid)
stopSession(-1, gen)
@@ -875,8 +904,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/.dd-zram"),
clockControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.dd-clock"),
zramControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.bl-zram"),
clockControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.bl-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: " +
@@ -945,16 +974,16 @@ class SessionService : Service() {
} else {
guest.add("LANG=C.UTF-8")
}
guest.add("DD_STEAM_LANGUAGE=" + SteamLanguage.forLocale(
guest.add("BL_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("DD_SHADER_PRECACHE=" + if (it) "1" else "0") }
if (SessionState.mode == MODE_STEAM) SessionPrefs.pendingShaderPrecache(this)?.let { guest.add("BL_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("DD_ANDROID_CLIPBOARD=" + File(filesDir, "session/android-clipboard").path)
guest.add("BL_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")
@@ -983,7 +1012,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("DD_RAISE_NOFILE=1")
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) guest.add("BL_RAISE_NOFILE=1")
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) {
val kernel = System.getProperty("os.version").orEmpty()
val old = kernelBefore(kernel, 6, 6)
@@ -997,11 +1026,11 @@ class SessionService : Service() {
if (SessionPrefs.steamGpuCompositing(this)) {
Log.i(TAG, "steam: GPU web compositing (Setup's \"Steam interface: GPU drawing\")")
} else {
guest.add("DD_STEAM_SOFT_COMPOSITING=1")
guest.add("BL_STEAM_SOFT_COMPOSITING=1")
Log.i(TAG, "steam: software web compositing for the open driver pair (GPU raster kept)")
}
guest.add("DD_OPEN_DRIVER=1")
LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("DD_DRM_STANDIN=$it") }
guest.add("BL_OPEN_DRIVER=1")
LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("BL_DRM_STANDIN=$it") }
}
val tuOverride = tuDebugOverride()
val tuDriver = sysmemDriver(linuxDriverId)
@@ -1015,10 +1044,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("DD_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
if (SessionState.mode == MODE_STEAM) guest.add("BL_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
SessionState.steamClientArch = if (steamHere) SessionPrefs.steamClientArch(this) else null
SessionState.steamClientArch?.let { arch ->
guest.add("DD_STEAM_CLIENT_ARCH=$arch")
guest.add("BL_STEAM_CLIENT_ARCH=$arch")
SessionPaths.current()?.let {
SessionArtifacts.recordClient(it, arch)
SessionArtifacts.markSteamLogs(it, File(SessionPrefs.steamRoot(this, arch), "logs"))
@@ -1026,23 +1055,23 @@ class SessionService : Service() {
}
FexCatalog.cached(this)?.let { guest.addAll(FexCatalog.environment(it)) }
if (SessionState.mode == MODE_STEAM) {
guest.add("DD_GAMESCOPE_STRETCH_16X9=" + (if (SessionPrefs.stretch16x9(this)) "1" else "0"))
guest.add("BL_GAMESCOPE_STRETCH_16X9=" + (if (SessionPrefs.stretch16x9(this)) "1" else "0"))
}
if (SessionPrefs.noXalia(this)) guest.add("PROTON_USE_XALIA=0")
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")
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")
relativeMouseForSession().takeIf { it != 0 }?.let { guest.add("gamescope_relative_mouse=$it") }
if (com.droiddeck.launcher.core.ZramSupport.supported()) {
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")
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")
}
SessionPrefs.vramCapMb(this).takeIf { it > 0 }?.let { guest.add("DD_VRAM_MB=$it") }
SessionPrefs.vramCapMb(this).takeIf { it > 0 }?.let { guest.add("BL_VRAM_MB=$it") }
guest.add("AUDIO_DIRECT_DECAY=0")
val extra = extraEnv() + agentEnvironment
guest.addAll(TurnipEnvironment.gameEnvironment(tuOverride, tuDriver, SessionPrefs.tuSysmem(this), extra))
@@ -1051,10 +1080,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("DD_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
guest.add("BL_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
}
CpuCores.gameLaunchList(SessionPrefs.gameCpus(this), clientPinned)
.takeIf { it.isNotEmpty() }?.let { guest.add("DD_GAME_CPUS=$it") }
.takeIf { it.isNotEmpty() }?.let { guest.add("BL_GAME_CPUS=$it") }
}
private fun startVkBridge(guest: MutableList<String>, sessionDir: File) {
@@ -1063,16 +1092,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("DD_VKBRIDGE=1")
if (SessionPrefs.steamGpuCompositing(this)) guest.add("DD_STEAM_GPU_COMPOSITING=1")
guest.add("BL_VKBRIDGE=1")
if (SessionPrefs.steamGpuCompositing(this)) guest.add("BL_STEAM_GPU_COMPOSITING=1")
SessionPrefs.linuxDriver(this).takeIf { it.isNotEmpty() }
?.let { runCatching { LinuxVulkanDriver.resolveIcdPath(this, it) }.getOrNull() }
?.let { guest.add("DD_VKBRIDGE_FALLBACK_ICD=$it") }
?.let { guest.add("BL_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("DD_DRM_STANDIN=$node")
guest.add("BL_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")
@@ -1086,7 +1115,7 @@ class SessionService : Service() {
SessionPrefs.directAudio(this)
val wantsMic = SessionPrefs.micEnabled(this) &&
checkSelfPermission(android.Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED
guest.add("DD_MIC_ENABLED=" + if (wantsMic) "1" else "0")
guest.add("BL_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")
@@ -1114,7 +1143,7 @@ class SessionService : Service() {
components.add(relay)
}
if (wantsDirectAudio) {
guest.add("DD_DIRECTAUDIO=/" + SessionFiles.DIRECTAUDIO_DIR)
guest.add("BL_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)
@@ -1259,6 +1288,7 @@ class SessionService : Service() {
} else {
Log.i(TAG, "game storage: internal only")
}
binds.addAll(com.droiddeck.launcher.runtime.FlatpakData.binds(this))
if (SessionState.mode == MODE_STEAM && SessionPrefs.storageDiagnosticsEnabled(this)) {
val target = storageDiagnosticLibrary ?: File(LinuxRuntime.rootDir(this), "root/.local/share/Steam")
val device = StorageDiagnostics.writeSnapshot(
@@ -1270,9 +1300,9 @@ class SessionService : Service() {
)
if (device != null) {
val envAt = guest.indexOf(LinuxRuntime.SESSION_SCRIPT).takeIf { it >= 0 } ?: guest.size
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}")
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}")
} else {
Log.w(TAG, "storage diagnostics: selected library could not be identified; metadata snapshot only")
}
@@ -1417,7 +1447,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, "DD_X64_STEAM_LIBRARIES=" + listing.path)
guest.add(envAt, "BL_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)
}
@@ -1427,32 +1457,10 @@ 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, "DD_STEAM_LIBRARIES=" + listing.path)
guest.add(envAt, "BL_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
}
@@ -2180,6 +2188,7 @@ class SessionService : Service() {
}
private fun finishSessionStop(status: Int, stoppedGen: Int, afterStopped: () -> Unit = {}) {
guestLaunch.await()
mainHandler.post {
try {
if (stoppedGen != sessionGen || SessionState.running) {
@@ -2350,8 +2359,7 @@ 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,
KeepTopActivity::class.java.name)) return
com.droiddeck.launcher.ui.SessionTypingActivity::class.java.name)) return
if (pipTask || xrActivityVisible) {
Log.i(TAG, "panel task dismissed - retaining the session under its active surface policy")
activityVisible = false
@@ -45,6 +45,8 @@ object SessionState {
@Volatile
var running = false
val occupied get() = running || (phase != SessionPhase.IDLE && phase != SessionPhase.FAILED)
@Volatile
var activityDisplayId = 0
@Volatile
@@ -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("/libddsession.so") } }
File(procRoot, "${record.pid}/maps").useLines { lines -> lines.any { it.endsWith("/libblsession.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",
"soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature",
"gameStoresEnabled", "soundtracksEnabled", "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", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
"stretch16x9", "picturePosition", "integerScaling", "railLabels", "agentTab", "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, ".dd-steam-repair").exists()
return !(stamped && File(steam, "steamrtarm64/steam").isFile) || File(home, ".bl-steam-repair").exists()
}
internal fun manifests(runtimeRoot: File, mounts: Map<String, File>): List<File> {
@@ -40,9 +40,8 @@ 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 && "Install=1" !in launchOptions) return true
if (appId == expectedAppId) 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), ".dd-steam-repair")
private fun request(context: Context) = File(home(context), ".bl-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")
@@ -1,13 +0,0 @@
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",
"DD_VENUS=1",
"BL_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.
@@ -9,10 +9,15 @@ import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.droiddeck.launcher.R
import com.droiddeck.launcher.runtime.FlatpakData
import com.droiddeck.launcher.runtime.FlatpakManager
import java.util.concurrent.atomic.AtomicInteger
object StoreState {
private val main = Handler(Looper.getMainLooper())
private val latestSnapshot = AtomicInteger()
internal class Snapshot(val ready: Boolean, val installed: List<FlatpakManager.App>, val cardData: Set<String>, val cardAvailable: Boolean)
var ready by mutableStateOf(false)
private set
@@ -24,6 +29,10 @@ object StoreState {
private set
var updatesChecked by mutableStateOf(false)
private set
var cardData by mutableStateOf<Set<String>>(emptySet())
private set
var cardAvailable by mutableStateOf(false)
private set
var busy by mutableStateOf<String?>(null)
private set
var stage by mutableStateOf<String?>(null)
@@ -50,12 +59,26 @@ object StoreState {
fun refresh(context: Context) {
val app = context.applicationContext
Thread({
val r = FlatpakManager.ready(app)
val list = if (r) FlatpakManager.installedApps(app) else emptyList()
main.post { ready = r; installed = list; updates = updates.filter { id -> list.any { it.id == id } }.toSet() }
val seq = nextSnapshot()
val snapshot = capture(app)
main.post { publish(seq, snapshot) }
}, "store-refresh").start()
}
private fun capture(app: Context): Snapshot {
val r = FlatpakManager.ready(app)
val list = if (r) FlatpakManager.installedApps(app) else emptyList()
return Snapshot(r, list, FlatpakData.enabled(app), FlatpakData.available(app))
}
internal fun nextSnapshot() = latestSnapshot.incrementAndGet()
internal fun publish(seq: Int, snapshot: Snapshot) {
if (seq != latestSnapshot.get()) return
ready = snapshot.ready; installed = snapshot.installed; cardData = snapshot.cardData; cardAvailable = snapshot.cardAvailable
updates = updates.filter { id -> snapshot.installed.any { it.id == id } }.toSet()
}
fun loadSections(force: Boolean = false) {
if (!force && sections.isNotEmpty()) return
sectionsFailed = false
@@ -100,11 +123,11 @@ object StoreState {
} catch (e: Exception) {
e.message ?: e.toString()
}
val r = FlatpakManager.ready(app)
val list = if (r) FlatpakManager.installedApps(app) else emptyList()
val seq = nextSnapshot()
val snapshot = capture(app)
main.post {
busy = null; stage = null; percent = -1
ready = r; installed = list
publish(seq, snapshot)
if (problem != null) Toast.makeText(app, app.getString(R.string.store_problem, label, problem), Toast.LENGTH_LONG).show()
}
}, "store-$what").start()
@@ -118,6 +141,9 @@ object StoreState {
fun uninstall(context: Context, id: String, name: String) =
run(context, id, name) { c, p -> FlatpakManager.uninstall(c, id, p).also { if (it == null) main.post { updates = updates - id } } }
fun moveData(context: Context, id: String, name: String, toCard: Boolean) =
run(context, id, name) { c, p -> FlatpakData.move(c, id, toCard, p) }
fun update(context: Context, id: String?, name: String) =
run(context, id ?: "update-all", name) { c, p ->
FlatpakManager.update(c, id, p).also { if (it == null) main.post { updates = if (id == null) emptySet() else updates - id } }
@@ -5,11 +5,6 @@ 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
@@ -37,7 +32,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(), val signedIn: Boolean = true)
class Status(val supported: Boolean, val folder: File?, val lastSync: Long, val reason: String, val conflicts: List<String> = emptyList())
private fun game(context: Context, store: Store, id: String): Pair<File, StoreGameSidecar>? =
StoreInstallRoot.gameFolders(context).firstNotNullOfOrNull { f ->
@@ -49,13 +44,7 @@ object CloudSaves {
return Library.protonPrefix(context, appId and 0xFFFFFFFFL)
}
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)
}
private fun prefs(context: Context, store: Store) = if (store == Store.GOG) GogPrefs.get(context) else EpicPrefs.get(context)
fun lastSync(context: Context, store: Store, id: String): Long = prefs(context, store).getLong("cloud_sync_$id", 0L)
@@ -75,10 +64,6 @@ 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", "") ?: ""
@@ -104,8 +89,7 @@ object CloudSaves {
val item = sidecar.extra["catalogItemId"].orEmpty()
if (ns.isEmpty() || item.isEmpty()) "" else EpicApiClient.getCustomAttribute(token, ns, item, "CloudSaveFolder")
}
Store.EA -> eaRules(context, id) ?: return null
Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR -> ""
Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.EA, Store.UBISOFT, Store.ROCKSTAR -> ""
} ?: return null
p.edit()
.putString("cloud_template_$id", fetched.ifEmpty { TEMPLATE_NONE })
@@ -166,16 +150,14 @@ 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.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
Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.EA, 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), signedIn(context, store))
return Status(reason != "no-cloud-saves" && reason != "not-installed", dir, lastSync(context, store, id), reason, conflicts(context, store, id))
}
@@ -193,28 +175,7 @@ object CloudSaves {
val account = EpicCredentialStore.load(context)?.accountId.orEmpty()
if (token == null || account.isEmpty()) null else EpicCloud(account, id, token)
}
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()
Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.EA, Store.UBISOFT, Store.ROCKSTAR -> null
}
private fun gogScopedToken(context: Context, id: String, clientId: String): String? {
@@ -344,10 +305,7 @@ 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) }
}
}
@@ -367,23 +325,9 @@ object CloudSaves {
return r
}
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
}
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, '/') }
internal fun md5(f: File): String = md5(f.readBytes())
@@ -398,17 +342,13 @@ object CloudSaves {
}
internal fun downWith(context: Context, store: Store, id: String, dir: File, cloud: CloudTransport, force: Boolean): Result {
val files = localFiles(dir).filterKeys(cloud::wants)
val files = localFiles(dir)
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
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")
if (take.isNotEmpty() && files.isNotEmpty()) backup(context, store, id, dir, "local")
val next = HashMap(base.orEmpty())
var bytes = 0L
for (name in take) {
@@ -431,7 +371,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).filterKeys(cloud::wants)
val files = localFiles(dir)
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)) }
@@ -457,9 +397,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 = if (send.all { cloud.committed(it) != null }) emptyMap() else remote(cloud) { it in send && cloud.committed(it) == null }
val after = remote(cloud) { it in send }
for (name in send) {
val r = cloud.committed(name) ?: after[name]
val r = after[name]
next[name] = CloudPlan.Entry(sentMd5.getValue(name), r?.md5, r?.modifiedMs ?: stamped[name] ?: -1L)
}
}
@@ -501,11 +441,10 @@ 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): Boolean {
private fun backup(context: Context, store: Store, id: String, dir: File, kind: String) {
val root = backupRoot(context, store, id)
val copied = runCatching { dir.copyRecursively(File(root, "$kind-${System.currentTimeMillis()}"), overwrite = true) }.getOrDefault(false)
runCatching { dir.copyRecursively(File(root, "$kind-${System.currentTimeMillis()}"), overwrite = true) }
prune(root, kind)
return copied
}
private fun backupCloud(context: Context, store: Store, id: String, cloud: CloudTransport, files: List<CloudFile>) {
@@ -521,27 +460,6 @@ 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,8 +27,6 @@ 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) {
EPIC("epic", "Epic Games", "Epic"),
EA("ea", "EA", "EA"),
XBOX("xbox", "Xbox", "Xbox"),
GOG("gog", "GOG", "GOG"),
ROCKSTAR("rockstar", "Rockstar Games", "Rockstar"),
ITCH("itch", "Itch.io", "Itch.io"),
UBISOFT("ubisoft", "Ubisoft Connect", "Ubisoft"),
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"),
GAMEJOLT("gamejolt", "Game Jolt", "Game Jolt");
UBISOFT("ubisoft", "Ubisoft Connect", "Ubisoft"),
EA("ea", "EA", "EA"),
ROCKSTAR("rockstar", "Rockstar Games", "Rockstar");
val folder: String get() = if (this == ITCH) "itch" else shortLabel
@@ -58,11 +58,7 @@ 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 {
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)
}
.getOrElse { JSONObject().put("ok", false).put("reason", "Xbox account service is unavailable. Sign in again and retry.") }
"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" -> {
@@ -1,70 +0,0 @@
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"),
)
}
}
}
@@ -27,20 +27,13 @@ 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).whenComplete { bytes, _ ->
StoresState.post { if (bytes != null && bytes > 0) known[item.key] = bytes else settled[item.key] = true }
resolve(context, item).thenAccept { bytes ->
if (bytes != null) StoresState.post { known[item.key] = bytes }
}
}
@@ -202,7 +202,6 @@ 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"
internal var tokenUrl = "https://accounts.ea.com/connect/token"
private const val TOKEN_URL = "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,11 +41,8 @@ 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? {
@@ -58,7 +55,6 @@ object EaAuth {
personaId = o.optString("persona_id"),
displayName = o.optString("display_name"),
eaId = o.optString("ea_id"),
rejected = o.optBoolean("refresh_rejected"),
)
}
@@ -126,15 +122,14 @@ object EaAuth {
private fun tokenCall(values: List<Pair<String, String>>): JSONObject {
val reply = EaHttp.request(
tokenUrl, "POST",
TOKEN_URL, "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()) {
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)
throw IllegalStateException("EA token request failed (${reply.status}): ${json?.optString("error_description")?.ifEmpty { json.optString("error") } ?: ""}")
}
return json
}
@@ -167,7 +162,6 @@ 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")
@@ -182,24 +176,11 @@ 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
@@ -1,255 +0,0 @@
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("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace("\"", "&quot;")
private fun unescape(s: String) = EaSaveRules.unescape(s)
}
}
@@ -1,76 +0,0 @@
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)
}
}
}
}
@@ -14,7 +14,6 @@ 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
@@ -164,16 +163,7 @@ object RockstarLibrary {
post(gen) { StoresState.status.remove(Store.ROCKSTAR); StoresState.problems[Store.ROCKSTAR] = app.getString(R.string.stores_sync_sign_in) }
return
}
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)
}
}
if (StoresState.library[Store.ROCKSTAR].isNullOrEmpty()) post(gen) { 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 ->
@@ -185,7 +175,6 @@ 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,7 +15,6 @@ 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
@@ -207,16 +206,7 @@ object UbisoftLibrary {
post(gen) { StoresState.status.remove(Store.UBISOFT); StoresState.problems[Store.UBISOFT] = app.getString(R.string.stores_sync_sign_in) }
return
}
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)
}
}
if (StoresState.library[Store.UBISOFT].isNullOrEmpty()) post(gen) { StoresState.status[Store.UBISOFT] = app.getString(R.string.stores_sync_game_list) }
val all = ArrayList<CatalogItem>()
var offset = 0
while (true) {
@@ -251,7 +241,6 @@ 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,8 +18,7 @@ internal class XboxLaunchViews {
parent.listFiles()?.filter { it.name.startsWith("launch-") }?.forEach(::remove)
recovered.add(parent.path)
}
// 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)
return Files.createTempDirectory(parent.toPath(), "launch-").toFile()
}
companion object {
@@ -19,11 +19,9 @@ 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
@@ -52,12 +50,11 @@ 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.Terminal
import androidx.compose.material.icons.outlined.AutoAwesome
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
@@ -98,7 +95,6 @@ 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
@@ -296,8 +292,7 @@ private fun AgentPageContent(
awaitEachGesture {
awaitFirstDown(requireUnconsumed = false, pass = PointerEventPass.Initial)
if (panel == AgentPanel.MODEL || panel == AgentPanel.USAGE) panel = AgentPanel.NONE
// 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)
if (composer.focused) focusManager.clearFocus()
}
},
list, following = !readingBack, onRevise = { composer.open() }, onSent = toLatest,
@@ -309,7 +304,7 @@ private fun AgentPageContent(
}
}
androidx.compose.animation.AnimatedVisibility(!hidden, enter = expandVertically() + fadeIn(), exit = shrinkVertically() + fadeOut()) {
AgentComposer(composer, draft, visible && started, inlineControls, onPanel = { panel = it }, onSent = toLatest)
AgentComposer(composer, draft, visible, inlineControls, onPanel = { panel = it }, onSent = toLatest)
}
}
}
@@ -456,7 +451,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.Terminal, null, tint = pal.primary, modifier = Modifier.size(40.dp))
Icon(Icons.Outlined.AutoAwesome, 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))
}
@@ -708,23 +703,9 @@ 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 } }
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 voiceAvailable = remember { AgentVoice.available(context) }
DisposableEffect(voice) { onDispose { voice.stop() } }
LaunchedEffect(visible) { if (!visible) voice.stop() }
val working = AgentHost.state == AgentHost.State.WORKING
if (draft.startsWith("/") && !draft.contains(' ')) {
val matches = (LOCAL_COMMANDS + CLI_COMMANDS).filter { it.startsWith(draft) && it != draft }
@@ -744,35 +725,23 @@ 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() } }
val attach = LocalActivityResultRegistryOwner.current != null
BoxWithConstraints(
Column(
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),
) {
// 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)) {
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)) {
if (draft.isEmpty()) Text(
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,
stringResource(if (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
if (voice.listening) voice.stop()
},
draft, { draft = it },
Modifier.fillMaxWidth().focusRequester(field).onFocusChanged {
focused = it.isFocused
composer.focused = it.isFocused
@@ -781,132 +750,50 @@ 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 = { sendNow() }),
keyboardActions = KeyboardActions(onSend = {
voice.stop()
send()
}),
minLines = 1,
maxLines = 8,
)
} }
val actions: @Composable () -> Unit = {
}
if (controls != null && !focused) Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.height(42.dp)) { controls() }
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) && !voice.finishing) VoiceButton(voice, onStart = { voice.start(draft) }, onSend = send, onSetup = { voiceSetup = true })
if (voice.finishing || (voice.listening && voice.locked) || (canSend && !voice.listening)) RoundButton(
if ((!canSend || voice.listening) && voiceAvailable) VoiceButton(voice) { voice.start(draft) }
else RoundButton(
Icons.AutoMirrored.Outlined.Send, stringResource(if (working) R.string.agent_queue else R.string.agent_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()
if (canSend) pal.primary else pal.surfaceVariant, if (canSend) pal.onPrimary else pal.onSurfaceVariant, "agent-send", enabled = canSend,
) {
voice.stop()
send()
}
} 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, onSend: () -> Unit, onSetup: () -> Unit) {
private fun VoiceButton(voice: AgentVoice, onStart: () -> Unit) {
val context = LocalContext.current
val pal = LocalPalette.current
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 = {
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",
) {
when {
voice.listening -> voice.finish()
!voiceReady(context) -> setup()
else -> handsFree()
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()
}
}
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. */
@@ -50,11 +50,6 @@ import androidx.compose.material3.Icon
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.relocation.bringIntoViewRequester
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.runtime.rememberCoroutineScope
import kotlinx.coroutines.launch
import com.droiddeck.launcher.agent.AgentTools
@@ -421,23 +416,14 @@ private fun ToolsRow(title: String, detail: String, action: @Composable () -> Un
}
@Composable
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
internal fun ToolsField(value: String, onValue: (String) -> Unit, hint: String, tag: String) {
// The launcher's pane focus group sends a Compose text field's focus back to the last tile it remembers,
// so these fields use the EditText the rest of the launcher types into.
val view = remember { androidx.compose.foundation.relocation.BringIntoViewRequester() }
var focused by remember { mutableStateOf(false) }
val window = androidx.compose.ui.platform.LocalView.current
// An EditText's focus does not scroll its Compose parent, so the field follows the keyboard as it opens.
val keyboard = WindowInsets.ime.getBottom(androidx.compose.ui.platform.LocalDensity.current)
LaunchedEffect(focused, keyboard) { if (focused) view.bringIntoView() }
AdbTextField(
value = value, onValueChange = onValue, label = hint, keyboardType = KeyboardType.Text, imeAction = ImeAction.Done,
modifier = Modifier.bringIntoViewRequester(view).testTag(tag), placeholder = hint, compact = true, showLabel = false,
onFocusChange = { focused = it },
onDone = {
(window.context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as? android.view.inputmethod.InputMethodManager)
?.hideSoftInputFromWindow(window.windowToken, 0)
},
)
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
Box(Modifier.fillMaxWidth().clip(Shape12).background(pal.surfaceVariant).padding(horizontal = 12.dp, vertical = 10.dp)) {
if (value.isEmpty()) Text(hint, fontSize = 14.sp, color = pal.onSurfaceVariant, maxLines = 1)
BasicTextField(
value, onValue, singleLine = true, textStyle = TextStyle(fontSize = 14.sp, fontFamily = FontFamily.Monospace, color = colors.onSurface),
cursorBrush = SolidColor(pal.primary), modifier = Modifier.fillMaxWidth().testTag(tag),
)
}
}
Loaded 100 of 445 files, more files were not shown because too many files have changed in this diff. Show more