mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
Compare commits
64
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f639a08eb | ||
|
|
82f806ad84 | ||
|
|
7771a87695 | ||
|
|
3419391940 | ||
|
|
c46bb72631 | ||
|
|
0cd42b7217 | ||
|
|
f68a78c577 | ||
|
|
6638a7dac8 | ||
|
|
c6333350ae | ||
|
|
fbf1788647 | ||
|
|
48f587bb41 | ||
|
|
088e9994a0 | ||
|
|
29350f1bd5 | ||
|
|
498a3a653a | ||
|
|
644f8e655f | ||
|
|
7ad52166a2 | ||
|
|
872c5e1834 | ||
|
|
2d25fb91c5 | ||
|
|
56213d74b3 | ||
|
|
9c6fafec4c | ||
|
|
f06c37e279 | ||
|
|
f17406effc | ||
|
|
b072cedd16 | ||
|
|
77fffa7592 | ||
|
|
de3ed8b986 | ||
|
|
86b8ae3c99 | ||
|
|
ad6bb159d3 | ||
|
|
fe6f8638c6 | ||
|
|
26b11c6838 | ||
|
|
a9f2017aa3 | ||
|
|
bc8a970520 | ||
|
|
eefd8088dc | ||
|
|
442f1f83bf | ||
|
|
1d1c29517a | ||
|
|
be98982cfc | ||
|
|
ed763ecb9b | ||
|
|
ecbda604e2 | ||
|
|
c514c59018 | ||
|
|
b6efc4d44a | ||
|
|
b61f766b66 | ||
|
|
01c8991049 | ||
|
|
bf8faf06e1 | ||
|
|
a6ffbe7d81 | ||
|
|
34b78e2e42 | ||
|
|
bd016858c7 | ||
|
|
f761e5f1db | ||
|
|
ebb3bb6373 | ||
|
|
2aad4fbb1b | ||
|
|
b81d7d796f | ||
|
|
54e1dcb5a4 | ||
|
|
10d3b801fa | ||
|
|
00b354a40a | ||
|
|
2f16ea63aa | ||
|
|
151b2c304f | ||
|
|
b3e9ea5620 | ||
|
|
a4a5a88ab2 | ||
|
|
839a00a8aa | ||
|
|
a7f7a17a69 | ||
|
|
74a77c1402 | ||
|
|
673c9869f8 | ||
|
|
215ed5aaed | ||
|
|
7b91aea0fc | ||
|
|
2b424bdfe7 | ||
|
|
a4e6279a8d |
No files matched your search
@@ -178,8 +178,10 @@ jobs:
|
||||
PY
|
||||
after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)
|
||||
[ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
|
||||
# A pull request's cache is visible only to that pull request, and each copy is hundreds of megabytes against the
|
||||
# repository's 10 GB cache limit. Only main saves, so every pull request restores main's set.
|
||||
- name: Store Robolectric's Android jars
|
||||
if: always() && steps.robolectric-jars-final.outputs.save == 'true'
|
||||
if: always() && github.event_name != 'pull_request' && steps.robolectric-jars-final.outputs.save == 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
|
||||
@@ -68,6 +68,7 @@ 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. The fix for host stack left behind when a program leaves a signal handler without returning follows the approach suggested in [FEX-Emu/FEX#2487](https://github.com/FEX-Emu/FEX/issues/2487). The host stack fix for system calls that end a block is a backport of Ryan Houdek's [FEX-Emu/FEX#6122](https://github.com/FEX-Emu/FEX/pull/6122).
|
||||
- Anti-cheat support under FEX is the work of [StonkGuy](https://github.com/StonkGuy): the x86-64 ptrace, seccomp and `/proc` emulation from his [FEX fork](https://github.com/StonkGuy/FEX) (`eac-2611` branch, MIT) is carried as build patch 0021 with his authorship, patches 0022 to 0029 build on it, and his `eac-tests` regression suite verifies them.
|
||||
- x86-64 programs on Wayland reach the GPU through FEX's Wayland client, wayland-egl and EGL thunks. The guest `wl_list` and `wl_array` helpers follow [libwayland](https://gitlab.freedesktop.org/wayland/wayland)'s `src/wayland-util.c` (MIT). The EGL extension table comes from the [Khronos EGL registry](https://github.com/KhronosGroup/EGL-Registry) (Apache-2.0) and Mesa's `egl_other.xml` (MIT).
|
||||
- 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.
|
||||
- DwarFS AppImages are unpacked without proot by `dwarfsextract` from [DwarFS](https://github.com/mhx/dwarfs) by Marcus Holland-Moritz (MIT), the release binary uruntime embeds, taken out of its self-extracting wrapper and shipped with its licence.
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" />
|
||||
|
||||
@@ -10,6 +10,17 @@ add_subdirectory(adrenotools)
|
||||
|
||||
add_subdirectory(thirdparty/dxbc)
|
||||
|
||||
# Pin ZeroFG to a fixed revision instead of vendoring thousands of generated shader lines.
|
||||
include(FetchContent)
|
||||
set(ZEROFG_VULKAN_HEADERS_DIR "${CMAKE_SYSROOT}/usr/include" CACHE PATH "" FORCE)
|
||||
set(ZEROFG_PREBUILT_SHADERS ON CACHE STRING "" FORCE)
|
||||
FetchContent_Declare(zerofg
|
||||
GIT_REPOSITORY https://github.com/hy300leosquizz-ctrl/ZeroFG.git
|
||||
GIT_TAG e6ca7ef9f9765db89847b6d8eed352e458f1a8bb
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
FetchContent_MakeAvailable(zerofg)
|
||||
|
||||
set(DDFG_UPSTREAM "v0.3.0")
|
||||
set(DDFG_CHAIN_SRC
|
||||
framegen/ddfg/framegen.cpp
|
||||
|
||||
@@ -329,16 +329,28 @@ static constexpr int kWatchedFds = 1 << 16;
|
||||
static constexpr int kWatchedBits = sizeof(unsigned long) * 8;
|
||||
static std::atomic<unsigned long> watched_fds[kWatchedFds / kWatchedBits];
|
||||
static std::atomic<bool> watched_beyond{false};
|
||||
static std::atomic<int> watched_count{0};
|
||||
|
||||
static void watch_fd(int fd) {
|
||||
if (fd < 0) return;
|
||||
if (fd >= kWatchedFds) watched_beyond.store(true, std::memory_order_release);
|
||||
else watched_fds[fd / kWatchedBits].fetch_or(1UL << (fd % kWatchedBits), std::memory_order_release);
|
||||
if (fd >= kWatchedFds) {
|
||||
watched_beyond.store(true, std::memory_order_release);
|
||||
return;
|
||||
}
|
||||
const unsigned long bit = 1UL << (fd % kWatchedBits);
|
||||
if (!(watched_fds[fd / kWatchedBits].fetch_or(bit, std::memory_order_acq_rel) & bit))
|
||||
watched_count.fetch_add(1, std::memory_order_acq_rel);
|
||||
}
|
||||
|
||||
static void unwatch_fd(int fd) {
|
||||
if (fd >= 0 && fd < kWatchedFds)
|
||||
watched_fds[fd / kWatchedBits].fetch_and(~(1UL << (fd % kWatchedBits)), std::memory_order_release);
|
||||
if (fd < 0 || fd >= kWatchedFds) return;
|
||||
const unsigned long bit = 1UL << (fd % kWatchedBits);
|
||||
if (watched_fds[fd / kWatchedBits].fetch_and(~bit, std::memory_order_acq_rel) & bit)
|
||||
watched_count.fetch_sub(1, std::memory_order_acq_rel);
|
||||
}
|
||||
|
||||
static bool any_watched() {
|
||||
return watched_count.load(std::memory_order_acquire) > 0 || watched_beyond.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
static bool watched(int fd) {
|
||||
@@ -4269,7 +4281,7 @@ static int poll_fake(struct pollfd *fds, nfds_t nfds, int timeout,
|
||||
const auto my_poll = next_symbol<decltype(&::poll)>(Next::poll);
|
||||
const auto my_ppoll = next_symbol<decltype(&::ppoll)>(Next::ppoll);
|
||||
|
||||
nfds_t first = 0;
|
||||
nfds_t first = any_watched() ? 0 : nfds;
|
||||
while (first < nfds && !watched(fds[first].fd)) first++;
|
||||
bool has_fake_fds = false;
|
||||
std::vector<struct pollfd> real_fds;
|
||||
@@ -4372,12 +4384,12 @@ EXPORT int poll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
||||
EXPORT int ppoll(struct pollfd *fds, nfds_t nfds,
|
||||
const struct timespec *timeout, const sigset_t *sigmask) {
|
||||
const auto my_ppoll = next_symbol<decltype(&::ppoll)>(Next::ppoll);
|
||||
if (timeout && (timeout->tv_sec < 0 || timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000L)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
for (nfds_t i = 0; i < nfds; ++i) {
|
||||
for (nfds_t i = 0; any_watched() && i < nfds; ++i) {
|
||||
if (!is_fake_input_fd(fds[i].fd)) continue;
|
||||
if (timeout && (timeout->tv_sec < 0 || timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000L)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (!sigmask)
|
||||
return poll_fake(fds, nfds, static_cast<int>(timespec_to_ms(timeout)), nullptr);
|
||||
sigset_t all_signals, original_mask;
|
||||
@@ -4410,6 +4422,8 @@ EXPORT int __ppoll_chk(struct pollfd *fds, nfds_t nfds, const struct timespec *t
|
||||
EXPORT int select(int nfds, fd_set *readfds, fd_set *writefds,
|
||||
fd_set *exceptfds, struct timeval *timeout) {
|
||||
const auto my_select = next_symbol<decltype(&::select)>(Next::select);
|
||||
if (!any_watched())
|
||||
return my_select ? my_select(nfds, readfds, writefds, exceptfds, timeout) : -1;
|
||||
|
||||
fd_set original_readfds;
|
||||
fd_set original_writefds;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <jni.h>
|
||||
#include <limits.h>
|
||||
#include <linux/futex.h>
|
||||
@@ -27,3 +28,16 @@ Java_com_droiddeck_launcher_session_ThreadSignals_tgkill(JNIEnv *env, jclass cla
|
||||
(void)clazz;
|
||||
return syscall(SYS_tgkill, tgid, tid, signal) == 0 ? 0 : errno;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_droiddeck_launcher_session_PageCacheNative_fadviseDontNeed(JNIEnv *env, jclass clazz, jstring path) {
|
||||
(void)clazz;
|
||||
const char *chars = (*env)->GetStringUTFChars(env, path, NULL);
|
||||
if (!chars) return ENOMEM;
|
||||
int fd = open(chars, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);
|
||||
(*env)->ReleaseStringUTFChars(env, path, chars);
|
||||
if (fd < 0) return errno;
|
||||
int rc = posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
|
||||
close(fd);
|
||||
return rc;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
ZeroFG is fetched by CMake from hy300leosquizz-ctrl/ZeroFG (the upstream repository) at pinned commit e6ca7ef9f9765db89847b6d8eed352e458f1a8bb. DroidDeck keeps ownership of presentation; the independent presenter is not used. License: Apache-2.0 OR GPL-2.0-or-later; see the fetched ZeroFG source tree for the license text.
|
||||
@@ -64,6 +64,7 @@ if (TARGET dxbc AND EXISTS ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp
|
||||
message(STATUS "droiddeckwayland: frame-generation engines built in (LSFG Native, DD-FG Native)")
|
||||
target_sources(droiddeckwayland PRIVATE
|
||||
src/framegen_engine.cpp
|
||||
src/framegen_zerofg.cpp
|
||||
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_probe.cpp
|
||||
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_dll.cpp
|
||||
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_dxbc.cpp
|
||||
@@ -90,12 +91,12 @@ if (TARGET dxbc AND EXISTS ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../framegen
|
||||
)
|
||||
target_compile_options(droiddeckwayland PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-std=c++17 -fvisibility=hidden>)
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-std=c++20 -fvisibility=hidden>)
|
||||
target_compile_definitions(droiddeckwayland PRIVATE
|
||||
DDFG_UPSTREAM="${DDFG_UPSTREAM}"
|
||||
DDFG_CHAIN_HASH="${DDFG_CHAIN_HASH}"
|
||||
)
|
||||
target_link_libraries(droiddeckwayland dxbc atomic)
|
||||
target_link_libraries(droiddeckwayland dxbc atomic zerofg::zerofg)
|
||||
else()
|
||||
message(STATUS "droiddeckwayland: frame-generation engines NOT built in (standalone build): stub")
|
||||
target_sources(droiddeckwayland PRIVATE src/framegen_engine_stub.c)
|
||||
|
||||
@@ -343,6 +343,7 @@ volatile int g_hide_shell;
|
||||
|
||||
volatile int g_zero_copy;
|
||||
static int g_zero_copy_paused;
|
||||
static int g_mirror_capture;
|
||||
extern volatile int g_display_buffer_driver;
|
||||
extern void droiddeck_on_overlay_planes(int planes);
|
||||
static int g_overlay_planes_told = -1;
|
||||
@@ -2961,7 +2962,7 @@ static void hdr_note_route(int route, const struct hdr_scene *hs) {
|
||||
static int said = -1, said_tm = -1;
|
||||
static const char *said_why;
|
||||
const int tm = route != 0 && !droiddeck_color_output();
|
||||
if (route == said && tm == said_tm && (route != 1 || hs->why == said_why)) return;
|
||||
if (route == said && tm == said_tm && (route < 1 || route > 2 || hs->why == said_why)) return;
|
||||
int was = said;
|
||||
said = route; said_why = hs->why; said_tm = tm;
|
||||
char name[160] = "the HDR game";
|
||||
@@ -2978,6 +2979,10 @@ static void hdr_note_route(int route, const struct hdr_scene *hs) {
|
||||
"BT2020_PQ", name, hs->why ? hs->why : "?", droiddeck_color_sdr_white());
|
||||
break;
|
||||
case 2:
|
||||
if (g_mirror_capture) {
|
||||
droiddeck_log("color", "Mirror: %s is composed through the screen swapchain", name);
|
||||
break;
|
||||
}
|
||||
if (tm)
|
||||
droiddeck_log("color", "HDR with frame generation for %s, HDR output switched off: the scene is tone-mapped to "
|
||||
"SDR and presented through an SDR screen swapchain", name);
|
||||
@@ -3198,6 +3203,11 @@ static void render_scene(void) {
|
||||
const int cardboard = vkp_cardboard_active();
|
||||
struct hdr_scene hs;
|
||||
int hdr_route = hdr_plan(&dl, w, h, fx_on, framegen, &hs);
|
||||
/* Mirror's PixelCopy cannot see the separate game layer. Keep unimportable frames visible on top. */
|
||||
if (g_mirror_capture && hdr_route != 3 && hs.n_hdr > 0) {
|
||||
hdr_route = 2;
|
||||
hs.why = "Mirror needs the screen swapchain";
|
||||
}
|
||||
const char *hdr_copy = NULL;
|
||||
if (droiddeck_color_hdr_open()) {
|
||||
hdr_note_route(hdr_route, &hs);
|
||||
@@ -3263,16 +3273,16 @@ static void render_scene(void) {
|
||||
else if (rendered && how == 2) droiddeck_color_frame_shown(hs.color, DROIDDECK_HDR_TONEMAPPED, 0);
|
||||
else if (rendered) hdr_copy = "the HDR composition pass is unavailable on this driver";
|
||||
}
|
||||
if (hdr_route == 0 && vkp_quest_layer_presentation() && !framegen && !cardboard && !cursor_on &&
|
||||
if (hdr_route == 0 && !g_mirror_capture && vkp_quest_layer_presentation() && !framegen && !cardboard && !cursor_on &&
|
||||
!ahb_only) {
|
||||
settle_unwaited();
|
||||
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
|
||||
} else if (hdr_route == 0 || hdr_route == 3) {
|
||||
const int pass_on = fx_on || framegen;
|
||||
tell_overlay_planes();
|
||||
const int fg_layer = framegen && hdr_route == 0 && framegen_fits_layer();
|
||||
const int fg_layer = framegen && !g_mirror_capture && hdr_route == 0 && framegen_fits_layer();
|
||||
g_framegen_layer = fg_layer;
|
||||
int li = (g_zero_copy && (!framegen || fg_layer) && !bfi && !cardboard && !cursor_on) ? layer_candidate(&dl, w, h) : -1;
|
||||
int li = (g_zero_copy && !g_mirror_capture && (!framegen || fg_layer) && !bfi && !cardboard && !cursor_on) ? layer_candidate(&dl, w, h) : -1;
|
||||
int over = li >= 0 ? dl.n - 1 - li : 0;
|
||||
const int fx_blocks = (li >= 0 && fx_on && over > 0);
|
||||
if (fx_blocks) { li = -1; over = 0; }
|
||||
@@ -5002,6 +5012,12 @@ const char *droiddeck_client_name(struct wl_client *client) { return client_name
|
||||
struct wl_display *droiddeck_get_display(void) { return g_display; }
|
||||
void droiddeck_request_redraw(void) { schedule_render(); }
|
||||
|
||||
void droiddeck_set_mirror_capture(int on) {
|
||||
if (g_mirror_capture == on) return;
|
||||
g_mirror_capture = on;
|
||||
schedule_render();
|
||||
}
|
||||
|
||||
struct wl_resource *droiddeck_ime_target(void) {
|
||||
struct surface *s;
|
||||
if (g_ime_click && g_ime_click->mapped) return g_ime_click->resource;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "ahb_swapchain.h"
|
||||
#include "droiddeck_color.h"
|
||||
|
||||
enum host_kind { HOST_CLIPBOARD = 1, HOST_TEXT_COMMIT, HOST_TEXT_PREEDIT, HOST_TEXT_DELETE, HOST_ZERO_COPY, HOST_HDR_OUTPUT, HOST_KEY, HOST_SELECT_GAME_FIELD };
|
||||
enum host_kind { HOST_CLIPBOARD = 1, HOST_TEXT_COMMIT, HOST_TEXT_PREEDIT, HOST_TEXT_DELETE, HOST_ZERO_COPY, HOST_HDR_OUTPUT, HOST_KEY, HOST_SELECT_GAME_FIELD, HOST_MIRROR_CAPTURE };
|
||||
|
||||
struct host_msg {
|
||||
enum host_kind kind;
|
||||
@@ -91,6 +91,9 @@ void droiddeck_host_text_delete(int before, int after) {
|
||||
void droiddeck_host_zero_copy(int on, int live) {
|
||||
host_post(HOST_ZERO_COPY, NULL, 0, on, live);
|
||||
}
|
||||
void droiddeck_host_mirror_capture(int on) {
|
||||
host_post(HOST_MIRROR_CAPTURE, NULL, 0, on, 0);
|
||||
}
|
||||
void droiddeck_host_hdr_output(int on) {
|
||||
host_post(HOST_HDR_OUTPUT, NULL, 0, on, 0);
|
||||
}
|
||||
@@ -271,6 +274,9 @@ static int on_wake(int fd, uint32_t mask, void *data) {
|
||||
case HOST_ZERO_COPY:
|
||||
ahb_swapchain_set_mode(m->a, m->b);
|
||||
break;
|
||||
case HOST_MIRROR_CAPTURE:
|
||||
droiddeck_set_mirror_capture(m->a);
|
||||
break;
|
||||
case HOST_HDR_OUTPUT:
|
||||
droiddeck_color_set_output(m->a);
|
||||
break;
|
||||
|
||||
@@ -29,6 +29,8 @@ void droiddeck_host_text_commit_and_submit(const char *utf8, int len);
|
||||
void droiddeck_host_text_preedit(const char *utf8, int len, int cursor_begin, int cursor_end);
|
||||
void droiddeck_host_text_delete(int before, int after);
|
||||
void droiddeck_host_zero_copy(int on, int live);
|
||||
void droiddeck_host_mirror_capture(int on);
|
||||
void droiddeck_set_mirror_capture(int on);
|
||||
void droiddeck_host_hdr_output(int on);
|
||||
void droiddeck_host_key(int evdev, int state);
|
||||
void droiddeck_host_select_game_field(int copy);
|
||||
|
||||
@@ -366,6 +366,44 @@ void vkp_effects_forget_image(VkImage img) {
|
||||
g_context = saved;
|
||||
}
|
||||
|
||||
VkImageView vkp_effects_framegen_image_view(VkImage img, int w, int h, VkFormat fmt) {
|
||||
if (!g_dev || !img || w <= 0 || h <= 0 || fmt == VK_FORMAT_UNDEFINED) return VK_NULL_HANDLE;
|
||||
|
||||
for (int i = 0; i < FX_CONTEXTS; ++i) {
|
||||
struct fx_context *ctx = &g_contexts[i];
|
||||
if (ctx->scene.img == img && ctx->scene.view) return ctx->scene.view;
|
||||
for (int j = 0; j < 2; ++j)
|
||||
if (ctx->targets[j].img == img && ctx->targets[j].view) return ctx->targets[j].view;
|
||||
if (ctx->mid.img == img && ctx->mid.view) return ctx->mid.view;
|
||||
if (ctx->nissrc.img == img && ctx->nissrc.view) return ctx->nissrc.view;
|
||||
}
|
||||
if (g_smaa_edges.img == img && g_smaa_edges.view) return g_smaa_edges.view;
|
||||
if (g_smaa_weights.img == img && g_smaa_weights.view) return g_smaa_weights.view;
|
||||
|
||||
/* The effects chain can bypass every pass and return the compositor's scene image
|
||||
* directly. Keep a view for that image in the existing per-context cache so the
|
||||
* normal image-forget path destroys it before the image itself. */
|
||||
int saved = g_context;
|
||||
g_context = 0;
|
||||
if (g_scene.img != img || g_scene.view == VK_NULL_HANDLE ||
|
||||
g_scene.w != w || g_scene.h != h) {
|
||||
scene_release();
|
||||
VkImageView view = make_view(img, fmt);
|
||||
if (!view) {
|
||||
g_context = saved;
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
g_scene.img = img;
|
||||
g_scene.view = view;
|
||||
g_scene.w = w;
|
||||
g_scene.h = h;
|
||||
g_scene.ds = VK_NULL_HANDLE;
|
||||
}
|
||||
VkImageView result = g_scene.view;
|
||||
g_context = saved;
|
||||
return result;
|
||||
}
|
||||
|
||||
void vkp_effects_release_generated_sources(void) {
|
||||
for (g_context = 1; g_context < FX_CONTEXTS; g_context++) scene_release();
|
||||
g_context = 0;
|
||||
@@ -1026,13 +1064,18 @@ VkImage vkp_effects_run_generated(VkCommandBuffer cmd, VkImage scene, int scene_
|
||||
struct fx_source_state source_state = {0};
|
||||
VkImage result = effects_run(cmd, scene, scene_w, scene_h, out_w, out_h, res_w, res_h,
|
||||
VK_IMAGE_LAYOUT_GENERAL, &g_generated_settings, &source_state);
|
||||
barrier(cmd, result, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
if (result != scene)
|
||||
if (result != scene) {
|
||||
barrier(cmd, result, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
barrier(cmd, scene, source_state.layout, VK_IMAGE_LAYOUT_GENERAL,
|
||||
source_state.stage, source_state.access,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT);
|
||||
} else if (source_state.layout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) {
|
||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
}
|
||||
g_context = 0;
|
||||
return result;
|
||||
}
|
||||
@@ -28,6 +28,7 @@ VkImage vkp_effects_run_generated(VkCommandBuffer cmd, VkImage scene, int scene_
|
||||
void vkp_effects_destroy(void);
|
||||
|
||||
void vkp_effects_forget_image(VkImage img);
|
||||
VkImageView vkp_effects_framegen_image_view(VkImage img, int w, int h, VkFormat fmt);
|
||||
|
||||
void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt, int scene_is_pq);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "framegen_engine.h"
|
||||
#include "effects_chain.h"
|
||||
#include "vk_loader.h"
|
||||
#include "sc_layer.h"
|
||||
#include <pthread.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdio.h>
|
||||
@@ -36,7 +37,7 @@ static VkQueue g_queue;
|
||||
static uint32_t g_qfam;
|
||||
static _Atomic int g_dev_ready, g_dev_lost;
|
||||
static int g_features_enabled;
|
||||
static _Atomic int g_caps_lsfg_ok, g_caps_ddfg_ok;
|
||||
static _Atomic int g_caps_lsfg_ok, g_caps_ddfg_ok, g_caps_zero_ok;
|
||||
static VkPhysicalDeviceMemoryProperties g_memprops;
|
||||
static struct {
|
||||
PFN_vkCreateImage CreateImage;
|
||||
@@ -78,6 +79,24 @@ static int format_refused(VkFormat f) {
|
||||
|
||||
static _Atomic unsigned g_stat_generated;
|
||||
static uint64_t g_total_generated;
|
||||
|
||||
#define FG_PROVEN_FRAMES 120
|
||||
#define FG_HANG_STRIKES 2
|
||||
static _Atomic int g_hang_strikes;
|
||||
static int g_submitted_since_ready;
|
||||
static uint64_t g_generated_at_ready;
|
||||
|
||||
// A driver that hangs on the engine's shaders loses the device on its first generated frame after every
|
||||
// recovery, so the compositor would recover and hang again for as long as frame generation stays armed.
|
||||
static int framegen_loss_strike(int submitted, uint64_t completed_since_ready) {
|
||||
if (!submitted || completed_since_ready >= FG_PROVEN_FRAMES) {
|
||||
atomic_store(&g_hang_strikes, 0);
|
||||
return 0;
|
||||
}
|
||||
if (atomic_fetch_add(&g_hang_strikes, 1) + 1 < FG_HANG_STRIKES) return 0;
|
||||
atomic_store(&g_hang_strikes, 0);
|
||||
return 1;
|
||||
}
|
||||
static float g_presented_rate, g_source_rate;
|
||||
static uint32_t g_present_accum, g_source_accum;
|
||||
static int64_t g_window_start_ns;
|
||||
@@ -87,12 +106,48 @@ static int64_t now_ns(void) {
|
||||
return (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
|
||||
}
|
||||
|
||||
/* The pair the last run made, for the display probe and the pacer: when its real frame reached the
|
||||
* compositor, the game moment each generated frame shows, and the refresh the pacer timed each for. */
|
||||
static _Atomic int g_pacer_on;
|
||||
static int g_layer_path;
|
||||
static int g_out_gens;
|
||||
static int64_t g_out_planned[VKP_FG_MAX_GENERATIONS + 1];
|
||||
static int64_t g_completion_issue;
|
||||
|
||||
void vkp_framegen_set_pacer(int on) {
|
||||
if (atomic_exchange(&g_pacer_on, on ? 1 : 0) != (on ? 1 : 0)) {
|
||||
fge_pacer_reset();
|
||||
FGLOG("ZeroFG pacer %s", on ? "on: frame generation times its frames itself" : "off: the display layer times them");
|
||||
}
|
||||
}
|
||||
|
||||
static int pacer_wanted(void) { return atomic_load(&g_pacer_on); }
|
||||
|
||||
void vkp_framegen_pacer_abort(void) {
|
||||
g_completion_issue = 0;
|
||||
fge_pacer_reset();
|
||||
}
|
||||
|
||||
void vkp_framegen_output_planned(int k, int gens, int64_t *planned) {
|
||||
*planned = (k < 0 || k >= gens || k >= g_out_gens)
|
||||
? g_out_planned[g_out_gens] : g_out_planned[k];
|
||||
}
|
||||
|
||||
void vkp_framegen_completed(void) {
|
||||
if (!g_completion_issue) return;
|
||||
fge_pacer_completed(g_completion_issue, now_ns());
|
||||
g_completion_issue = 0;
|
||||
}
|
||||
|
||||
void vkp_framegen_real_shown(int64_t planned_ns, int64_t shown_ns) { fge_pacer_shown(planned_ns, shown_ns); }
|
||||
|
||||
|
||||
void vkp_framegen_set_engine(int kind) {
|
||||
if (kind != VKP_FG_ENGINE_LSFG && kind != VKP_FG_ENGINE_DDFG) kind = VKP_FG_ENGINE_LSFG;
|
||||
if (kind != VKP_FG_ENGINE_LSFG && kind != VKP_FG_ENGINE_DDFG && kind != VKP_FG_ENGINE_ZEROFG) kind = VKP_FG_ENGINE_LSFG;
|
||||
atomic_store(&g_kind, kind);
|
||||
atomic_store(&g_failed_kind, -1);
|
||||
atomic_store(&g_cfg_dirty, 1);
|
||||
atomic_store(&g_hang_strikes, 0);
|
||||
}
|
||||
|
||||
void vkp_framegen_set_armed(int armed, int multiplier, int target_fps) {
|
||||
@@ -118,6 +173,11 @@ void vkp_framegen_set_lsfg_cache_path(const char *path) {
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
}
|
||||
|
||||
void vkp_framegen_set_layer_timing(int layer) {
|
||||
g_layer_path = layer;
|
||||
fge_set_layer_timing(layer);
|
||||
}
|
||||
|
||||
void vkp_framegen_set_tuning(float flow_scale, float refresh_hz) {
|
||||
if (flow_scale < 0.25f) flow_scale = 0.25f;
|
||||
if (flow_scale > 1.0f) flow_scale = 1.0f;
|
||||
@@ -146,15 +206,15 @@ static void mark_failed(int kind) {
|
||||
int vkp_framegen_problem(void) {
|
||||
if (!atomic_load(&g_dev_ready)) return -1;
|
||||
int kind = atomic_load(&g_kind);
|
||||
int caps_ok = kind == VKP_FG_ENGINE_DDFG
|
||||
? atomic_load(&g_caps_ddfg_ok)
|
||||
: atomic_load(&g_caps_lsfg_ok);
|
||||
int caps_ok = kind == VKP_FG_ENGINE_ZEROFG ? atomic_load(&g_caps_zero_ok) :
|
||||
kind == VKP_FG_ENGINE_DDFG ? atomic_load(&g_caps_ddfg_ok) :
|
||||
atomic_load(&g_caps_lsfg_ok);
|
||||
if (!caps_ok) return 1;
|
||||
if (start_failed_for(kind)) return 2;
|
||||
if (g_engine_ok && g_engine_kind == kind && fge_unavailable()) return 2;
|
||||
return 0;
|
||||
}
|
||||
const char *vkp_framegen_caps_reason(void) { return fge_caps_reason(); }
|
||||
const char *vkp_framegen_caps_reason(void) { return fge_caps_reason(atomic_load(&g_kind)); }
|
||||
|
||||
void vkp_framegen_stats(float out[6]) {
|
||||
float accepted = 0.0f, src = 0.0f, thermal = -1.0f;
|
||||
@@ -187,16 +247,33 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f
|
||||
fge_device_ready(g_gipa, g_inst, g_pd, dev, queue, qfam, features_enabled);
|
||||
atomic_store(&g_caps_lsfg_ok, fge_caps_ok(VKP_FG_ENGINE_LSFG));
|
||||
atomic_store(&g_caps_ddfg_ok, fge_caps_ok(VKP_FG_ENGINE_DDFG));
|
||||
atomic_store(&g_caps_zero_ok, fge_caps_ok(VKP_FG_ENGINE_ZEROFG));
|
||||
atomic_store(&g_dev_lost, 0);
|
||||
g_submitted_since_ready = 0;
|
||||
g_generated_at_ready = g_total_generated;
|
||||
atomic_store(&g_dev_ready,
|
||||
vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier);
|
||||
FGLOG("engines ready on the compositor's device: LSFG Native %s (%s), DD-FG Native %s",
|
||||
fge_caps_ok(VKP_FG_ENGINE_LSFG) ? "available" : "unavailable", fge_caps_reason(),
|
||||
fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable");
|
||||
FGLOG("engines ready on compositor device: LSFG %s, DD-FG %s, ZeroFG %s",
|
||||
fge_caps_ok(VKP_FG_ENGINE_LSFG) ? "available" : "unavailable",
|
||||
fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable",
|
||||
fge_caps_ok(VKP_FG_ENGINE_ZEROFG) ? "available" : "unavailable");
|
||||
}
|
||||
|
||||
// The compositor reports one loss twice: when it happens and again while releasing the lost device.
|
||||
static int framegen_count_loss(void) {
|
||||
if (atomic_exchange(&g_dev_lost, 1)) return 0;
|
||||
int failed = framegen_loss_strike(g_submitted_since_ready, g_total_generated - g_generated_at_ready);
|
||||
g_submitted_since_ready = 0;
|
||||
return failed;
|
||||
}
|
||||
|
||||
void vkp_framegen_device_lost(void) {
|
||||
atomic_store(&g_dev_lost, 1);
|
||||
if (framegen_count_loss()) {
|
||||
int kind = atomic_load(&g_kind);
|
||||
mark_failed(kind);
|
||||
FGLOG("%s lost the GPU %d times in a row before its frames completed; frame generation stays off "
|
||||
"until it is set again", fge_engine_name(kind), FG_HANG_STRIKES);
|
||||
}
|
||||
atomic_store(&g_dev_ready, 0);
|
||||
fge_device_lost();
|
||||
if (g_dev) {
|
||||
@@ -283,16 +360,18 @@ static int engine_usable(void) {
|
||||
int kind = atomic_load(&g_kind);
|
||||
int ready = atomic_load(&g_dev_ready);
|
||||
int lost = atomic_load(&g_dev_lost);
|
||||
int caps_ok = kind == VKP_FG_ENGINE_DDFG
|
||||
? atomic_load(&g_caps_ddfg_ok)
|
||||
: atomic_load(&g_caps_lsfg_ok);
|
||||
int caps_ok = kind == VKP_FG_ENGINE_ZEROFG ? atomic_load(&g_caps_zero_ok) :
|
||||
kind == VKP_FG_ENGINE_DDFG ? atomic_load(&g_caps_ddfg_ok) :
|
||||
atomic_load(&g_caps_lsfg_ok);
|
||||
return ready && !lost && caps_ok && !start_failed_for(kind);
|
||||
}
|
||||
|
||||
int vkp_framegen_format_ok(VkFormat fmt) {
|
||||
if (fmt == VK_FORMAT_R8G8B8A8_UNORM) return 1;
|
||||
if (!g_dev_ready || g_dev_lost || format_refused(fmt)) return 0;
|
||||
return fge_format_ok(fmt);
|
||||
int kind = atomic_load(&g_kind);
|
||||
if (kind == VKP_FG_ENGINE_ZEROFG) return fge_format_ok(VKP_FG_ENGINE_ZEROFG, fmt);
|
||||
if (fmt == VK_FORMAT_R8G8B8A8_UNORM) return 1;
|
||||
return fge_format_ok(kind, fmt);
|
||||
}
|
||||
|
||||
static void refuse_format(VkFormat fmt, int kind, int w, int h, const char *what) {
|
||||
@@ -377,11 +456,14 @@ static void log_arm_transition(int armed, int kind, int mult) {
|
||||
|
||||
int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, int w, int h,
|
||||
VkFormat fmt, VkImage gens[VKP_FG_MAX_GENERATIONS]) {
|
||||
(void)scene_view;
|
||||
int kind = atomic_load(&g_kind);
|
||||
int armed = atomic_load(&g_armed);
|
||||
int mult = atomic_load(&g_mult);
|
||||
g_planned = 0;
|
||||
const int64_t issue = now_ns();
|
||||
g_out_gens = 0;
|
||||
memset(g_out_planned, 0, sizeof(g_out_planned));
|
||||
g_completion_issue = 0;
|
||||
if (!armed || !engine_usable() || w <= 0 || h <= 0) { log_arm_transition(0, kind, mult); return 0; }
|
||||
if (!ensure_engine(kind)) { log_arm_transition(0, kind, mult); return 0; }
|
||||
log_arm_transition(1, kind, mult);
|
||||
@@ -423,8 +505,31 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
||||
|
||||
++g_source_frames;
|
||||
const uint64_t game_frames = droiddeck_game_frames();
|
||||
uint32_t n_gen = fge_plan(g_ring_n, game_frames ? game_frames : g_source_frames, g_presented_rate);
|
||||
const uint64_t planning_sequence = game_frames ? game_frames : g_source_frames;
|
||||
uint32_t n_gen = fge_plan(g_ring_n, planning_sequence, g_presented_rate);
|
||||
if (n_gen > g_ring_n) n_gen = g_ring_n;
|
||||
if (kind == VKP_FG_ENGINE_ZEROFG && n_gen > 0 && !scene_view) {
|
||||
scene_view = vkp_effects_framegen_image_view(scene, w, h, fmt);
|
||||
if (!scene_view) {
|
||||
static int view_warning;
|
||||
if (!view_warning++) FGLOG("ZeroFG could not create a view for the source image; showing real frames only");
|
||||
n_gen = 0;
|
||||
}
|
||||
}
|
||||
fge_set_phases(NULL, 0);
|
||||
if (kind == VKP_FG_ENGINE_ZEROFG && pacer_wanted() && g_layer_path) {
|
||||
int64_t vsync = 0, period = 0;
|
||||
sc_layer_timeline(&vsync, &period);
|
||||
int64_t planned[VKP_FG_MAX_GENERATIONS + 1];
|
||||
float phases[VKP_FG_MAX_GENERATIONS + 1];
|
||||
const uint32_t count = period > 0
|
||||
? fge_pacer_plan((uint32_t)mult, period, vsync, issue, n_gen, planned, phases) : 0;
|
||||
if (count >= 1 && count - 1 <= n_gen) {
|
||||
n_gen = count - 1;
|
||||
for (uint32_t i = 0; i < count; i++) g_out_planned[i] = planned[i];
|
||||
fge_set_phases(phases, n_gen);
|
||||
}
|
||||
}
|
||||
g_planned = n_gen;
|
||||
|
||||
VkImageMemoryBarrier bars[1 + VKP_FG_MAX_GENERATIONS];
|
||||
@@ -452,21 +557,26 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
0, 0, NULL, 0, NULL, nb, bars);
|
||||
|
||||
fge_process(cmd, scene, (uint32_t)w, (uint32_t)h, n_gen);
|
||||
if (n_gen) g_submitted_since_ready = 1;
|
||||
fge_process(cmd, scene, scene_view, (uint32_t)w, (uint32_t)h, fmt, planning_sequence, n_gen);
|
||||
for (uint32_t g = 0; g < n_gen; g++) {
|
||||
fge_generate(cmd, g, n_gen, g_ring[g].img, g_ring[g].view, (uint32_t)w, (uint32_t)h);
|
||||
gens[g] = g_ring[g].img;
|
||||
}
|
||||
if (n_gen) {
|
||||
nb = 0;
|
||||
const VkAccessFlags generated_access = kind == VKP_FG_ENGINE_ZEROFG
|
||||
? VK_ACCESS_MEMORY_WRITE_BIT : VK_ACCESS_SHADER_WRITE_BIT;
|
||||
const VkPipelineStageFlags generated_stage = kind == VKP_FG_ENGINE_ZEROFG
|
||||
? VK_PIPELINE_STAGE_ALL_COMMANDS_BIT : VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
|
||||
for (uint32_t g = 0; g < n_gen; g++)
|
||||
bars[nb++] = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.srcAccessMask = generated_access, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL, .newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = g_ring[g].img, .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}};
|
||||
vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
vk.CmdPipelineBarrier(cmd, generated_stage, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, NULL, 0, NULL, nb, bars);
|
||||
if (!g_generating_logged) {
|
||||
g_generating_logged = 1;
|
||||
@@ -476,6 +586,8 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
||||
fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? ", FP16: the HDR picture" : "");
|
||||
}
|
||||
}
|
||||
g_out_gens = (int)n_gen;
|
||||
if (n_gen > 0) g_completion_issue = issue;
|
||||
return (int)n_gen;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#endif
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
enum { VKP_FG_ENGINE_LSFG = 0, VKP_FG_ENGINE_DDFG = 1 };
|
||||
enum { VKP_FG_ENGINE_LSFG = 0, VKP_FG_ENGINE_DDFG = 1, VKP_FG_ENGINE_ZEROFG = 2 };
|
||||
#define VKP_FG_MAX_GENERATIONS 3
|
||||
|
||||
void vkp_framegen_set_engine(int kind);
|
||||
@@ -26,6 +26,18 @@ void vkp_framegen_device_lost(void);
|
||||
|
||||
int vkp_framegen_active(void);
|
||||
int vkp_framegen_extra_images(void);
|
||||
/* 1 when the next run's frames are shown through the scene layer's timed group, 0 through the swapchain's FIFO. */
|
||||
void vkp_framegen_set_layer_timing(int layer);
|
||||
/* ZeroFG's pacer (include/zerofg/inline_pacer.h) times the layer's frames instead of the layer's own spacing. */
|
||||
void vkp_framegen_set_pacer(int on);
|
||||
/* Reset pacing history when a planned real-frame pair is aborted before presentation. */
|
||||
void vkp_framegen_pacer_abort(void);
|
||||
/* Refresh planned for output k of the last run (k == gens: its real frame; 0: use layer timing). */
|
||||
void vkp_framegen_output_planned(int k, int gens, int64_t *planned);
|
||||
/* The last run's GPU work finished (the compositor's fence signalled). */
|
||||
void vkp_framegen_completed(void);
|
||||
/* A real frame the pacer timed for planned_ns was shown at shown_ns. */
|
||||
void vkp_framegen_real_shown(int64_t planned_ns, int64_t shown_ns);
|
||||
int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, int w, int h,
|
||||
VkFormat fmt, VkImage gens[VKP_FG_MAX_GENERATIONS]);
|
||||
void vkp_framegen_presented(int generated);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -13,6 +14,9 @@
|
||||
#include "lsfg/lsfg_probe.h"
|
||||
#include "lsfg/lsfg_vkd.h"
|
||||
#include "ddfg/ddfg_engine.h"
|
||||
#include "framegen_zerofg.h"
|
||||
|
||||
#include <zerofg/inline_pacer.h>
|
||||
|
||||
#define ELOG(...) __android_log_print(ANDROID_LOG_INFO, "DroidDeckWayland", "framegen: " __VA_ARGS__)
|
||||
#define ELOGE(...) __android_log_print(ANDROID_LOG_ERROR, "DroidDeckWayland", "framegen: " __VA_ARGS__)
|
||||
@@ -22,12 +26,17 @@ namespace {
|
||||
VkTable g_table{};
|
||||
lsfg::Caps g_caps{};
|
||||
VkPhysicalDeviceVulkan12Features g_v12{};
|
||||
VkPhysicalDeviceVulkan13Features g_v13{};
|
||||
VkPhysicalDeviceFeatures2 g_f2{};
|
||||
VkPhysicalDevice g_pd = VK_NULL_HANDLE;
|
||||
VkDevice g_dev = VK_NULL_HANDLE;
|
||||
VkQueue g_queue = VK_NULL_HANDLE;
|
||||
uint32_t g_qfam = 0;
|
||||
bool g_probed = false, g_ready = false;
|
||||
bool g_zero_supported = false, g_zero_enabled = false;
|
||||
zerofg::InlinePacer g_pacer;
|
||||
zerofg::InlineReadiness g_readiness;
|
||||
std::mutex g_pacer_mutex;
|
||||
|
||||
std::unique_ptr<lsfg::Engine> g_lsfg;
|
||||
std::unique_ptr<ddfg::Engine> g_ddfg;
|
||||
@@ -88,30 +97,57 @@ const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
|
||||
if (n) enumExts(pd, nullptr, &n, exts.data());
|
||||
}
|
||||
g_caps = lsfg::Caps{};
|
||||
|
||||
|
||||
g_caps.features = lsfg::queryFeatures(g_table, pd, exts, false);
|
||||
g_caps.features = lsfg::queryFeatures(g_table, pd, exts, false);
|
||||
g_caps.probedFormat = ring_fmt;
|
||||
g_caps.storageOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties
|
||||
? lsfg::probeStorageFormat(g_table, pd, ring_fmt) : false;
|
||||
g_caps.linearBlitOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties
|
||||
? lsfg::probeLinearBlit(g_table, pd, ring_fmt) : false;
|
||||
g_probed = true;
|
||||
if (!g_caps.features.deviceGatesPass()) {
|
||||
|
||||
VkPhysicalDeviceProperties props{};
|
||||
if (g_table.GetPhysicalDeviceProperties) g_table.GetPhysicalDeviceProperties(pd, &props);
|
||||
VkPhysicalDeviceVulkan13Features supported13{};
|
||||
supported13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
|
||||
VkPhysicalDeviceFeatures2 supported2{};
|
||||
supported2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||
if (props.apiVersion >= VK_API_VERSION_1_3) supported2.pNext = &supported13;
|
||||
if (g_table.GetPhysicalDeviceFeatures2) g_table.GetPhysicalDeviceFeatures2(pd, &supported2);
|
||||
g_zero_supported = props.apiVersion >= VK_API_VERSION_1_3 &&
|
||||
supported13.synchronization2 == VK_TRUE &&
|
||||
supported2.features.shaderStorageImageExtendedFormats == VK_TRUE;
|
||||
g_zero_enabled = false;
|
||||
|
||||
const bool lsfg_supported = g_caps.features.deviceGatesPass();
|
||||
if (!lsfg_supported) {
|
||||
lsfg::explain(g_caps);
|
||||
ELOG("device gates for the LSFG chain fail: %s", g_caps.reason);
|
||||
}
|
||||
if (!lsfg_supported && !g_zero_supported) {
|
||||
g_v12 = {};
|
||||
g_v13 = {};
|
||||
g_f2 = {};
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
g_v12 = VkPhysicalDeviceVulkan12Features{};
|
||||
g_v12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
|
||||
g_v12.vulkanMemoryModel = VK_TRUE;
|
||||
g_v12.vulkanMemoryModel =
|
||||
g_caps.features.vulkanMemoryModel ? VK_TRUE : VK_FALSE;
|
||||
g_v12.vulkanMemoryModelDeviceScope =
|
||||
g_caps.features.vulkanMemoryModelDeviceScope ? VK_TRUE : VK_FALSE;
|
||||
g_v13 = VkPhysicalDeviceVulkan13Features{};
|
||||
g_v13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
|
||||
g_v13.synchronization2 = g_zero_supported ? VK_TRUE : VK_FALSE;
|
||||
if (g_zero_supported) g_v12.pNext = &g_v13;
|
||||
|
||||
g_f2 = VkPhysicalDeviceFeatures2{};
|
||||
g_f2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||
g_f2.pNext = &g_v12;
|
||||
g_f2.features.shaderStorageImageWriteWithoutFormat = VK_TRUE;
|
||||
g_f2.features.shaderStorageImageExtendedFormats = VK_TRUE;
|
||||
g_f2.features.shaderStorageImageWriteWithoutFormat =
|
||||
supported2.features.shaderStorageImageWriteWithoutFormat ? VK_TRUE : VK_FALSE;
|
||||
g_f2.features.shaderStorageImageExtendedFormats =
|
||||
supported2.features.shaderStorageImageExtendedFormats ? VK_TRUE : VK_FALSE;
|
||||
return &g_f2;
|
||||
}
|
||||
|
||||
@@ -122,9 +158,17 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
|
||||
fill_device(dev);
|
||||
g_caps.featuresEnabled = features_enabled != 0;
|
||||
lsfg::explain(g_caps);
|
||||
VkPhysicalDeviceProperties props{};
|
||||
if (g_table.GetPhysicalDeviceProperties) g_table.GetPhysicalDeviceProperties(pd, &props);
|
||||
g_zero_enabled = g_zero_supported && features_enabled != 0;
|
||||
zfg_device_ready(gipa, inst, pd, dev,
|
||||
props.apiVersion > VK_API_VERSION_1_3 ? VK_API_VERSION_1_3 : props.apiVersion,
|
||||
g_zero_enabled,
|
||||
g_zero_enabled && g_f2.features.shaderStorageImageExtendedFormats == VK_TRUE);
|
||||
g_ready = true;
|
||||
ELOG("device ready: lsfg caps '%s', storage on ring format %d", g_caps.reason,
|
||||
(int)g_caps.storageOnSwapchainFormat);
|
||||
ELOG("device ready: lsfg caps '%s', storage on ring format %d, ZeroFG %s",
|
||||
g_caps.reason, (int)g_caps.storageOnSwapchainFormat,
|
||||
g_zero_enabled ? "available" : "unavailable");
|
||||
}
|
||||
|
||||
void fge_device_lost(void) {
|
||||
@@ -149,24 +193,45 @@ void fge_device_lost(void) {
|
||||
g_v12 = {};
|
||||
g_f2 = {};
|
||||
g_build[0] = 0;
|
||||
g_zero_supported = g_zero_enabled = false;
|
||||
zfg_device_lost();
|
||||
}
|
||||
|
||||
int fge_caps_ok(int kind) {
|
||||
if (!g_ready) return 0;
|
||||
if (kind == 2) return g_zero_enabled && zfg_caps_ok();
|
||||
if (kind == 1) return g_caps.storageOnSwapchainFormat ? 1 : 0;
|
||||
return g_caps.supported() ? 1 : 0;
|
||||
}
|
||||
|
||||
const char *fge_caps_reason(void) { return g_caps.reason; }
|
||||
int fge_engine_available(int kind) { return fge_caps_ok(kind); }
|
||||
|
||||
int fge_format_ok(VkFormat fmt) {
|
||||
const char *fge_caps_reason(int kind) {
|
||||
if (kind == 2 && !g_zero_enabled)
|
||||
return "ZeroFG requires Vulkan 1.3, synchronization2 and extended storage-image formats";
|
||||
if (kind == 2) return zfg_caps_reason();
|
||||
return g_caps.reason;
|
||||
}
|
||||
|
||||
int fge_format_ok(int kind, VkFormat fmt) {
|
||||
if (kind == 2) return zfg_format_ok(fmt);
|
||||
if (!g_ready || !g_table.GetPhysicalDeviceFormatProperties || fmt == VK_FORMAT_UNDEFINED) return 0;
|
||||
return lsfg::probeStorageFormat(g_table, g_pd, fmt) && lsfg::probeLinearBlit(g_table, g_pd, fmt) ? 1 : 0;
|
||||
}
|
||||
|
||||
int fge_start(int kind, const char *cache_path) {
|
||||
fge_stop();
|
||||
fge_pacer_reset();
|
||||
if (!g_ready) return -1;
|
||||
if (kind == 2) {
|
||||
if (!g_zero_enabled || !zfg_start()) {
|
||||
ELOGE("ZeroFG engine init failed");
|
||||
return -1;
|
||||
}
|
||||
g_kind = 2;
|
||||
std::snprintf(g_build, sizeof(g_build), "ZeroFG ReallyZero, Vulkan 1.3 Compat");
|
||||
return 0;
|
||||
}
|
||||
if (kind == 1) {
|
||||
auto e = std::make_unique<ddfg::Engine>();
|
||||
if (!e->init(g_table, g_pd, g_dev, g_qfam, g_queue)) {
|
||||
@@ -201,14 +266,16 @@ int fge_start(int kind, const char *cache_path) {
|
||||
}
|
||||
|
||||
void fge_stop(void) {
|
||||
if (g_lsfg) {
|
||||
if (g_table.DeviceWaitIdle && g_dev) g_table.DeviceWaitIdle(g_dev);
|
||||
g_lsfg.reset();
|
||||
}
|
||||
if ((g_kind == 0 || g_kind == 2) && g_table.DeviceWaitIdle && g_dev)
|
||||
g_table.DeviceWaitIdle(g_dev);
|
||||
|
||||
g_lsfg.reset();
|
||||
|
||||
for (auto it = g_retained_ddfg.begin(); it != g_retained_ddfg.end();) {
|
||||
if ((*it)->destroy()) it = g_retained_ddfg.erase(it);
|
||||
else ++it;
|
||||
}
|
||||
|
||||
if (g_ddfg) {
|
||||
if (g_ddfg->destroy()) g_ddfg.reset();
|
||||
else {
|
||||
@@ -216,10 +283,13 @@ void fge_stop(void) {
|
||||
g_retained_ddfg.push_back(std::move(g_ddfg));
|
||||
}
|
||||
}
|
||||
|
||||
zfg_stop();
|
||||
g_kind = -1;
|
||||
}
|
||||
|
||||
int fge_unavailable(void) {
|
||||
if (g_kind == 2) return zfg_unavailable();
|
||||
if (g_kind == 1) return g_ddfg && g_ddfg->unavailable() ? 1 : 0;
|
||||
return g_lsfg && g_lsfg->unavailable() ? 1 : 0;
|
||||
}
|
||||
@@ -227,11 +297,13 @@ int fge_unavailable(void) {
|
||||
void fge_configure(uint32_t multiplier, uint32_t target_fps, float flow_scale, float refresh_hz,
|
||||
int model, int perf_preset) {
|
||||
if (multiplier < 2) multiplier = 2;
|
||||
if (g_kind == 2) { zfg_configure(multiplier, refresh_hz); return; }
|
||||
if (g_kind == 1 && g_ddfg) g_ddfg->configure(multiplier, model, perf_preset, flow_scale);
|
||||
else if (g_lsfg) g_lsfg->configure(multiplier, target_fps, flow_scale, refresh_hz);
|
||||
}
|
||||
|
||||
int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) {
|
||||
if (g_kind == 2) return zfg_prepare(w, h, fmt);
|
||||
if (g_kind == 1) return g_ddfg && g_ddfg->prepare(w, h, fmt) ? 1 : 0;
|
||||
if (!g_lsfg) return 0;
|
||||
g_lsfg->setGuestExtent(w, h);
|
||||
@@ -239,24 +311,74 @@ int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) {
|
||||
}
|
||||
|
||||
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate) {
|
||||
if (g_kind == 2) return zfg_plan(capacity, source_frames);
|
||||
if (g_kind == 1) return g_ddfg ? g_ddfg->plan(capacity) : 0;
|
||||
if (!g_lsfg) return 0;
|
||||
g_lsfg->setPresentedRate(presented_rate);
|
||||
return g_lsfg->plan(capacity, source_frames);
|
||||
}
|
||||
|
||||
void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens) {
|
||||
void fge_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view,
|
||||
uint32_t w, uint32_t h, VkFormat fmt, uint64_t sequence, uint32_t gens) {
|
||||
if (g_kind == 2) {
|
||||
zfg_process(cmd, source, source_view, w, h, fmt, sequence, gens);
|
||||
return;
|
||||
}
|
||||
if (g_kind == 1) { if (g_ddfg) g_ddfg->process(cmd, source, w, h, gens); return; }
|
||||
if (g_lsfg) g_lsfg->process(cmd, source, w, h, gens);
|
||||
}
|
||||
|
||||
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
||||
uint32_t w, uint32_t h) {
|
||||
if (g_kind == 2) { zfg_generate(cmd, g, count, img, view, w, h); return; }
|
||||
if (g_kind == 1) { if (g_ddfg) g_ddfg->generateInto(cmd, g, count, img, view, w, h); return; }
|
||||
if (g_lsfg) g_lsfg->generateInto(cmd, g, g, img, view, w, h);
|
||||
}
|
||||
|
||||
void fge_set_layer_timing(int layer) { zfg_set_layer_timing(layer); }
|
||||
|
||||
void fge_set_phases(const float *phases, uint32_t count) { zfg_set_phases(phases, count); }
|
||||
|
||||
float fge_phase(uint32_t index, uint32_t count) {
|
||||
if (g_kind == 2) return zfg_phase(index, count);
|
||||
return static_cast<float>(index + 1) / static_cast<float>(count + 1);
|
||||
}
|
||||
|
||||
uint32_t fge_pacer_plan(uint32_t multiplier, int64_t period_ns, int64_t vsync_ns, int64_t issue_ns, uint32_t max_generated,
|
||||
int64_t *present_ns, float *phases) {
|
||||
if (period_ns <= 0 || issue_ns <= 0) return 0;
|
||||
std::lock_guard<std::mutex> lock(g_pacer_mutex);
|
||||
g_pacer.SetMultiplier(multiplier);
|
||||
g_pacer.ObserveVsync(static_cast<uint64_t>(period_ns), static_cast<uint64_t>(vsync_ns > 0 ? vsync_ns : 0));
|
||||
const uint64_t issue = static_cast<uint64_t>(issue_ns);
|
||||
const zerofg::InlinePacer::Plan plan =
|
||||
g_pacer.PlanPair(issue, issue + g_readiness.MarginNs(static_cast<uint64_t>(period_ns)), max_generated + 1);
|
||||
for (uint32_t i = 0; i < plan.count; i++) {
|
||||
present_ns[i] = static_cast<int64_t>(plan.outputs[i].present_ns);
|
||||
phases[i] = plan.outputs[i].phase;
|
||||
}
|
||||
return plan.count;
|
||||
}
|
||||
|
||||
void fge_pacer_completed(int64_t issue_ns, int64_t done_ns) {
|
||||
std::lock_guard<std::mutex> lock(g_pacer_mutex);
|
||||
if (issue_ns > 0 && done_ns > issue_ns)
|
||||
g_readiness.ObserveCompleted(static_cast<uint64_t>(issue_ns), static_cast<uint64_t>(done_ns));
|
||||
}
|
||||
|
||||
void fge_pacer_shown(int64_t planned_ns, int64_t shown_ns) {
|
||||
std::lock_guard<std::mutex> lock(g_pacer_mutex);
|
||||
if (planned_ns > 0 && shown_ns > 0)
|
||||
g_pacer.ObserveRealShown(static_cast<uint64_t>(planned_ns), static_cast<uint64_t>(shown_ns));
|
||||
}
|
||||
|
||||
void fge_pacer_reset(void) {
|
||||
std::lock_guard<std::mutex> lock(g_pacer_mutex);
|
||||
g_pacer.Reset();
|
||||
}
|
||||
|
||||
void fge_forget_targets(void) {
|
||||
if (g_kind == 2) { zfg_forget_targets(); return; }
|
||||
if (g_lsfg) g_lsfg->forgetTargets();
|
||||
}
|
||||
|
||||
@@ -266,10 +388,14 @@ void fge_telemetry(float *accepted, float *source_rate, float *thermal) {
|
||||
*accepted = (float)g_lsfg->acceptedGenerations();
|
||||
*source_rate = g_lsfg->sourceRate();
|
||||
*thermal = (float)g_lsfg->thermalStatus();
|
||||
} else if (g_kind == 2) {
|
||||
zfg_telemetry(accepted, source_rate);
|
||||
}
|
||||
}
|
||||
|
||||
const char *fge_engine_name(int kind) { return kind == 1 ? "DD-FG Native" : "LSFG Native"; }
|
||||
const char *fge_engine_name(int kind) {
|
||||
return kind == 2 ? "ZeroFG" : kind == 1 ? "DD-FG Native" : "LSFG Native";
|
||||
}
|
||||
const char *fge_build_info(void) { return g_build; }
|
||||
|
||||
}
|
||||
@@ -16,8 +16,9 @@ void fge_device_lost(void);
|
||||
void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
|
||||
VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled);
|
||||
int fge_caps_ok(int kind);
|
||||
const char *fge_caps_reason(void);
|
||||
int fge_format_ok(VkFormat fmt);
|
||||
const char *fge_caps_reason(int kind);
|
||||
int fge_format_ok(int kind, VkFormat fmt);
|
||||
int fge_engine_available(int kind);
|
||||
|
||||
int fge_start(int kind, const char *cache_path);
|
||||
void fge_stop(void);
|
||||
@@ -26,10 +27,22 @@ void fge_configure(uint32_t multiplier, uint32_t target_fps, float flow_scale, f
|
||||
int model, int perf_preset);
|
||||
int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt);
|
||||
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate);
|
||||
void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens);
|
||||
void fge_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view,
|
||||
uint32_t w, uint32_t h, VkFormat fmt, uint64_t sequence, uint32_t gens);
|
||||
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
||||
uint32_t w, uint32_t h);
|
||||
void fge_forget_targets(void);
|
||||
void fge_set_layer_timing(int layer);
|
||||
/* The phases the pacer chose for the next pair's generated frames (engines that can take any phase). */
|
||||
void fge_set_phases(const float *phases, uint32_t count);
|
||||
/* The phase generated frame [index] of [count] shows. */
|
||||
float fge_phase(uint32_t index, uint32_t count);
|
||||
|
||||
uint32_t fge_pacer_plan(uint32_t multiplier, int64_t period_ns, int64_t vsync_ns, int64_t issue_ns, uint32_t max_generated,
|
||||
int64_t *present_ns, float *phases);
|
||||
void fge_pacer_completed(int64_t issue_ns, int64_t done_ns);
|
||||
void fge_pacer_shown(int64_t planned_ns, int64_t shown_ns);
|
||||
void fge_pacer_reset(void);
|
||||
void fge_telemetry(float *accepted, float *source_rate, float *thermal);
|
||||
const char *fge_engine_name(int kind);
|
||||
const char *fge_build_info(void);
|
||||
|
||||
@@ -10,9 +10,12 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
|
||||
(void)gipa; (void)inst; (void)pd; (void)dev; (void)queue; (void)qfam; (void)features_enabled;
|
||||
}
|
||||
void fge_device_lost(void) {}
|
||||
void zfg_discard_history_update(void) {}
|
||||
void zfg_commit_history_update(void) {}
|
||||
int fge_caps_ok(int kind) { (void)kind; return 0; }
|
||||
const char *fge_caps_reason(void) { return "frame-generation engines not built into this compositor"; }
|
||||
int fge_format_ok(VkFormat fmt) { (void)fmt; return 0; }
|
||||
const char *fge_caps_reason(int kind) { (void)kind; return "frame-generation engines not built into this compositor"; }
|
||||
int fge_format_ok(int kind, VkFormat fmt) { (void)kind; (void)fmt; return 0; }
|
||||
int fge_engine_available(int kind) { (void)kind; return 0; }
|
||||
int fge_start(int kind, const char *cache_path) { (void)kind; (void)cache_path; return -1; }
|
||||
void fge_stop(void) {}
|
||||
int fge_unavailable(void) { return 1; }
|
||||
@@ -24,16 +27,28 @@ int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) { (void)w; (void)h; (void)
|
||||
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate) {
|
||||
(void)capacity; (void)source_frames; (void)presented_rate; return 0;
|
||||
}
|
||||
void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens) {
|
||||
(void)cmd; (void)source; (void)w; (void)h; (void)gens;
|
||||
void fge_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view, uint32_t w, uint32_t h,
|
||||
VkFormat fmt, uint64_t sequence, uint32_t gens) {
|
||||
(void)cmd; (void)source; (void)source_view; (void)w; (void)h; (void)fmt; (void)sequence; (void)gens;
|
||||
}
|
||||
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
||||
uint32_t w, uint32_t h) {
|
||||
(void)cmd; (void)g; (void)count; (void)img; (void)view; (void)w; (void)h;
|
||||
}
|
||||
void fge_forget_targets(void) {}
|
||||
void fge_set_layer_timing(int layer) { (void)layer; }
|
||||
void fge_set_phases(const float *phases, uint32_t count) { (void)phases; (void)count; }
|
||||
float fge_phase(uint32_t index, uint32_t count) { return (float)(index + 1) / (float)(count + 1); }
|
||||
uint32_t fge_pacer_plan(uint32_t multiplier, int64_t period_ns, int64_t vsync_ns, int64_t issue_ns, uint32_t max_generated,
|
||||
int64_t *present_ns, float *phases) {
|
||||
(void)multiplier; (void)period_ns; (void)vsync_ns; (void)issue_ns; (void)max_generated; (void)present_ns; (void)phases;
|
||||
return 0;
|
||||
}
|
||||
void fge_pacer_completed(int64_t issue_ns, int64_t done_ns) { (void)issue_ns; (void)done_ns; }
|
||||
void fge_pacer_shown(int64_t planned_ns, int64_t shown_ns) { (void)planned_ns; (void)shown_ns; }
|
||||
void fge_pacer_reset(void) {}
|
||||
void fge_telemetry(float *accepted, float *source_rate, float *thermal) {
|
||||
*accepted = 0.0f; *source_rate = 0.0f; *thermal = -1.0f;
|
||||
}
|
||||
const char *fge_engine_name(int kind) { return kind == 1 ? "DD-FG Native" : "LSFG Native"; }
|
||||
const char *fge_engine_name(int kind) { return kind == 2 ? "ZeroFG" : kind == 1 ? "DD-FG Native" : "LSFG Native"; }
|
||||
const char *fge_build_info(void) { return "stub"; }
|
||||
@@ -14,6 +14,12 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetFrameGenArmed(JNI
|
||||
vkp_framegen_set_armed(armed ? 1 : 0, (int)multiplier, (int)targetFps);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetFrameGenPacer(JNIEnv *env, jclass clazz, jboolean on) {
|
||||
(void)env; (void)clazz;
|
||||
vkp_framegen_set_pacer(on ? 1 : 0);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetLsfgCachePath(JNIEnv *env, jclass clazz, jstring path) {
|
||||
(void)clazz;
|
||||
|
||||
@@ -0,0 +1,602 @@
|
||||
#include "framegen_zerofg.h"
|
||||
#include "sc_layer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
|
||||
#include <android/log.h>
|
||||
#include <zerofg/zerofg.h>
|
||||
|
||||
#define ZFG_LOG(...) __android_log_print(ANDROID_LOG_INFO, "DroidDeckWayland", "ZeroFG: " __VA_ARGS__)
|
||||
#define ZFG_ERR(...) __android_log_print(ANDROID_LOG_ERROR, "DroidDeckWayland", "ZeroFG: " __VA_ARGS__)
|
||||
|
||||
namespace {
|
||||
PFN_vkGetInstanceProcAddr g_gipa = nullptr;
|
||||
PFN_vkGetDeviceProcAddr g_gdpa = nullptr;
|
||||
VkInstance g_instance = VK_NULL_HANDLE;
|
||||
VkPhysicalDevice g_physical = VK_NULL_HANDLE;
|
||||
VkDevice g_device = VK_NULL_HANDLE;
|
||||
uint32_t g_api_version = VK_API_VERSION_1_0;
|
||||
bool g_synchronization2 = false, g_extended_formats = false;
|
||||
bool g_ready = false, g_supported = false, g_failed = false;
|
||||
char g_reason[160] = "device has not been checked";
|
||||
|
||||
PFN_vkGetPhysicalDeviceMemoryProperties g_GetPhysicalDeviceMemoryProperties = nullptr;
|
||||
PFN_vkGetPhysicalDeviceFormatProperties g_GetPhysicalDeviceFormatProperties = nullptr;
|
||||
PFN_vkCreateImage g_CreateImage = nullptr;
|
||||
PFN_vkDestroyImage g_DestroyImage = nullptr;
|
||||
PFN_vkCreateImageView g_CreateImageView = nullptr;
|
||||
PFN_vkDestroyImageView g_DestroyImageView = nullptr;
|
||||
PFN_vkGetImageMemoryRequirements g_GetImageMemoryRequirements = nullptr;
|
||||
PFN_vkAllocateMemory g_AllocateMemory = nullptr;
|
||||
PFN_vkFreeMemory g_FreeMemory = nullptr;
|
||||
PFN_vkBindImageMemory g_BindImageMemory = nullptr;
|
||||
PFN_vkCmdPipelineBarrier g_CmdPipelineBarrier = nullptr;
|
||||
PFN_vkCmdCopyImage g_CmdCopyImage = nullptr;
|
||||
PFN_vkDeviceWaitIdle g_DeviceWaitIdle = nullptr;
|
||||
VkPhysicalDeviceMemoryProperties g_memory_properties{};
|
||||
|
||||
std::unique_ptr<zerofg::Interpolator> g_interpolator;
|
||||
VkImage g_history = VK_NULL_HANDLE;
|
||||
VkImageView g_history_view = VK_NULL_HANDLE;
|
||||
VkDeviceMemory g_history_memory = VK_NULL_HANDLE;
|
||||
uint32_t g_width = 0, g_height = 0;
|
||||
VkFormat g_format = VK_FORMAT_UNDEFINED;
|
||||
bool g_history_layout_defined = false, g_history_valid = false;
|
||||
uint64_t g_history_sequence = 0;
|
||||
bool g_history_recorded_pending = false;
|
||||
uint64_t g_history_recorded_sequence = 0;
|
||||
std::array<bool, 4> g_fallback_outputs{};
|
||||
VkImage g_current = VK_NULL_HANDLE;
|
||||
VkImageView g_current_view = VK_NULL_HANDLE;
|
||||
uint64_t g_current_sequence = 0;
|
||||
bool g_pair_pending = false;
|
||||
|
||||
// Pacing. The compositor presents a pair's generated frames and its real frame back to back in FIFO,
|
||||
// so they reach the panel on consecutive refreshes right after the tick that drew them.
|
||||
constexpr uint64_t kBreakNs = 250000000ull;
|
||||
constexpr size_t kIntervalWindow = 8;
|
||||
constexpr size_t kMinIntervals = 4;
|
||||
constexpr double kSlotTolerance = 0.15;
|
||||
uint32_t g_multiplier = 2;
|
||||
float g_refresh_hz = 0.0f;
|
||||
bool g_layer_timing = false;
|
||||
// The phases the pacer chose for this pair (count 0: none, the timing above decides).
|
||||
std::array<float, 4> g_external_phases{};
|
||||
uint32_t g_external_count = 0;
|
||||
uint64_t g_last_sequence = 0;
|
||||
uint64_t g_last_issue_ns = 0;
|
||||
uint64_t g_pair_interval_ns = 0;
|
||||
uint32_t g_prev_count = 0, g_pair_count = 0;
|
||||
std::array<uint64_t, kIntervalWindow> g_intervals{};
|
||||
size_t g_interval_count = 0, g_interval_next = 0;
|
||||
|
||||
uint64_t now_ns() {
|
||||
return static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch()).count());
|
||||
}
|
||||
|
||||
void reset_pacing() {
|
||||
g_last_issue_ns = 0;
|
||||
g_pair_interval_ns = 0;
|
||||
g_prev_count = g_pair_count = 0;
|
||||
g_interval_count = g_interval_next = 0;
|
||||
}
|
||||
|
||||
uint64_t period_ns() {
|
||||
return g_refresh_hz > 1.0f ? static_cast<uint64_t>(1e9 / static_cast<double>(g_refresh_hz)) : 0;
|
||||
}
|
||||
|
||||
uint64_t typical_interval_ns() {
|
||||
if (g_interval_count < kMinIntervals) return 0;
|
||||
std::array<uint64_t, kIntervalWindow> sorted = g_intervals;
|
||||
std::sort(sorted.begin(), sorted.begin() + g_interval_count);
|
||||
return sorted[g_interval_count / 2];
|
||||
}
|
||||
|
||||
void note_sequence(uint64_t sequence) {
|
||||
if (sequence == g_last_sequence) return;
|
||||
const uint64_t now = now_ns();
|
||||
if (sequence < g_last_sequence) {
|
||||
// The frame counter changed source (game frames vs compositor scenes): no pair across it.
|
||||
g_history_valid = false;
|
||||
g_history_sequence = 0;
|
||||
reset_pacing();
|
||||
} else if (g_last_issue_ns && now > g_last_issue_ns) {
|
||||
const uint64_t interval = now - g_last_issue_ns;
|
||||
if (interval > kBreakNs) {
|
||||
reset_pacing();
|
||||
} else {
|
||||
g_pair_interval_ns = interval;
|
||||
g_intervals[g_interval_next] = interval;
|
||||
g_interval_next = (g_interval_next + 1) % kIntervalWindow;
|
||||
g_interval_count = std::min(g_interval_count + 1, kIntervalWindow);
|
||||
}
|
||||
}
|
||||
g_last_sequence = sequence;
|
||||
g_last_issue_ns = now;
|
||||
}
|
||||
|
||||
// Generated frames a pair can show without its presents queueing past the next game frame:
|
||||
// one refresh each, the real frame one more, all inside the game's typical frame interval.
|
||||
uint32_t pair_capacity(uint32_t wanted) {
|
||||
const uint64_t period = period_ns();
|
||||
const uint64_t typical = typical_interval_ns();
|
||||
if (!period || !typical) return wanted;
|
||||
const double slots = std::floor(static_cast<double>(typical) / static_cast<double>(period) + kSlotTolerance);
|
||||
return slots < 2.0 ? 0u : std::min<uint32_t>(wanted, static_cast<uint32_t>(slots) - 1u);
|
||||
}
|
||||
|
||||
// The scene layer (sc_layer.c) shows a group of [count] generated frames and then B, frame k of the group
|
||||
// max(k, round(k * gap / (count + 1))) refreshes after the first, a group every game frame interval.
|
||||
float layer_phase(uint32_t index, uint32_t count, uint64_t period) {
|
||||
const float even = static_cast<float>(index + 1) / static_cast<float>(count + 1);
|
||||
int64_t cadence_gap = 0;
|
||||
int cadence_frames = 0;
|
||||
sc_layer_cadence_info(&cadence_gap, &cadence_frames);
|
||||
const uint64_t gap = cadence_gap > 0 ? static_cast<uint64_t>(cadence_gap) : typical_interval_ns();
|
||||
const uint32_t group_frames = cadence_frames > static_cast<int>(count)
|
||||
? static_cast<uint32_t>(cadence_frames) : count + 1;
|
||||
if (!gap) return even;
|
||||
const int64_t slots = static_cast<int64_t>((gap + period / 2) / period);
|
||||
if (slots < static_cast<int64_t>(group_frames)) return even;
|
||||
const auto step = [&](uint32_t k) {
|
||||
const int64_t s = static_cast<int64_t>((static_cast<uint64_t>(k) * gap / group_frames + period / 2) / period);
|
||||
return std::max<int64_t>(s, k);
|
||||
};
|
||||
const double phase = static_cast<double>(step(index) - step(count) + slots) / static_cast<double>(slots);
|
||||
return static_cast<float>(std::clamp(phase, 0.05, 0.95));
|
||||
}
|
||||
|
||||
// FIFO presents the generated group and B back-to-back; phase uses the measured real-frame span.
|
||||
float pair_phase(uint32_t index, uint32_t count) {
|
||||
if (g_external_count == count && index < count) return std::clamp(g_external_phases[index], 0.01f, 0.99f);
|
||||
const float even = static_cast<float>(index + 1) / static_cast<float>(count + 1);
|
||||
const uint64_t period = period_ns();
|
||||
if (!period) return even;
|
||||
if (g_layer_timing) return layer_phase(index, count, period);
|
||||
if (!g_pair_interval_ns) return even;
|
||||
const double span = static_cast<double>(g_pair_interval_ns) +
|
||||
(static_cast<double>(count) - static_cast<double>(g_prev_count)) * static_cast<double>(period);
|
||||
if (span <= static_cast<double>(period) * (count + 1)) return even;
|
||||
const double phase = 1.0 - static_cast<double>(count - index) * static_cast<double>(period) / span;
|
||||
return static_cast<float>(std::clamp(phase, 0.05, 0.95));
|
||||
}
|
||||
|
||||
void load_device_functions() {
|
||||
if (g_gipa && g_instance) {
|
||||
g_GetPhysicalDeviceMemoryProperties =
|
||||
reinterpret_cast<PFN_vkGetPhysicalDeviceMemoryProperties>(
|
||||
g_gipa(g_instance, "vkGetPhysicalDeviceMemoryProperties"));
|
||||
g_GetPhysicalDeviceFormatProperties =
|
||||
reinterpret_cast<PFN_vkGetPhysicalDeviceFormatProperties>(
|
||||
g_gipa(g_instance, "vkGetPhysicalDeviceFormatProperties"));
|
||||
}
|
||||
if (!g_gdpa || !g_device) return;
|
||||
#define LOAD(name) g_##name = reinterpret_cast<PFN_vk##name>(g_gdpa(g_device, "vk" #name))
|
||||
LOAD(CreateImage);
|
||||
LOAD(DestroyImage);
|
||||
LOAD(CreateImageView);
|
||||
LOAD(DestroyImageView);
|
||||
LOAD(GetImageMemoryRequirements);
|
||||
LOAD(AllocateMemory);
|
||||
LOAD(FreeMemory);
|
||||
LOAD(BindImageMemory);
|
||||
LOAD(CmdPipelineBarrier);
|
||||
LOAD(CmdCopyImage);
|
||||
LOAD(DeviceWaitIdle);
|
||||
#undef LOAD
|
||||
}
|
||||
|
||||
void clear_history_state() {
|
||||
g_history_valid = false;
|
||||
g_history_sequence = 0;
|
||||
g_pair_pending = false;
|
||||
g_current = VK_NULL_HANDLE;
|
||||
g_current_view = VK_NULL_HANDLE;
|
||||
g_current_sequence = 0;
|
||||
}
|
||||
|
||||
void destroy_history() {
|
||||
if (g_device) {
|
||||
if (g_history_view && g_DestroyImageView) g_DestroyImageView(g_device, g_history_view, nullptr);
|
||||
if (g_history && g_DestroyImage) g_DestroyImage(g_device, g_history, nullptr);
|
||||
if (g_history_memory && g_FreeMemory) g_FreeMemory(g_device, g_history_memory, nullptr);
|
||||
}
|
||||
g_history = VK_NULL_HANDLE;
|
||||
g_history_view = VK_NULL_HANDLE;
|
||||
g_history_memory = VK_NULL_HANDLE;
|
||||
g_width = g_height = 0;
|
||||
g_format = VK_FORMAT_UNDEFINED;
|
||||
g_history_layout_defined = false;
|
||||
clear_history_state();
|
||||
}
|
||||
|
||||
uint32_t find_memory_type(uint32_t bits) {
|
||||
uint32_t fallback = UINT32_MAX;
|
||||
for (uint32_t i = 0; i < g_memory_properties.memoryTypeCount; ++i) {
|
||||
if ((bits & (1u << i)) == 0) continue;
|
||||
const auto flags = g_memory_properties.memoryTypes[i].propertyFlags;
|
||||
if (flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) return i;
|
||||
if (fallback == UINT32_MAX) fallback = i;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
bool make_history(uint32_t width, uint32_t height, VkFormat format) {
|
||||
if (!g_CreateImage || !g_GetImageMemoryRequirements || !g_AllocateMemory ||
|
||||
!g_BindImageMemory || !g_CreateImageView || !g_GetPhysicalDeviceMemoryProperties) {
|
||||
std::snprintf(g_reason, sizeof(g_reason), "Vulkan image functions unavailable");
|
||||
return false;
|
||||
}
|
||||
VkImageCreateInfo image_info{};
|
||||
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||
image_info.imageType = VK_IMAGE_TYPE_2D;
|
||||
image_info.format = format;
|
||||
image_info.extent = {width, height, 1};
|
||||
image_info.mipLevels = 1;
|
||||
image_info.arrayLayers = 1;
|
||||
image_info.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
image_info.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
image_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
if (g_CreateImage(g_device, &image_info, nullptr, &g_history) != VK_SUCCESS) {
|
||||
std::snprintf(g_reason, sizeof(g_reason), "could not create temporal history image");
|
||||
return false;
|
||||
}
|
||||
|
||||
VkMemoryRequirements requirements{};
|
||||
g_GetImageMemoryRequirements(g_device, g_history, &requirements);
|
||||
const uint32_t memory_index = find_memory_type(requirements.memoryTypeBits);
|
||||
if (memory_index == UINT32_MAX) {
|
||||
std::snprintf(g_reason, sizeof(g_reason), "no compatible memory for temporal history");
|
||||
destroy_history();
|
||||
return false;
|
||||
}
|
||||
VkMemoryAllocateInfo allocation{};
|
||||
allocation.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||
allocation.allocationSize = requirements.size;
|
||||
allocation.memoryTypeIndex = memory_index;
|
||||
if (g_AllocateMemory(g_device, &allocation, nullptr, &g_history_memory) != VK_SUCCESS ||
|
||||
g_BindImageMemory(g_device, g_history, g_history_memory, 0) != VK_SUCCESS) {
|
||||
std::snprintf(g_reason, sizeof(g_reason), "could not allocate temporal history memory");
|
||||
destroy_history();
|
||||
return false;
|
||||
}
|
||||
|
||||
VkImageViewCreateInfo view_info{};
|
||||
view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
view_info.image = g_history;
|
||||
view_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||
view_info.format = format;
|
||||
view_info.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
if (g_CreateImageView(g_device, &view_info, nullptr, &g_history_view) != VK_SUCCESS) {
|
||||
std::snprintf(g_reason, sizeof(g_reason), "could not create temporal history view");
|
||||
destroy_history();
|
||||
return false;
|
||||
}
|
||||
g_width = width;
|
||||
g_height = height;
|
||||
g_format = format;
|
||||
g_history_layout_defined = false;
|
||||
g_history_recorded_pending = false;
|
||||
g_history_recorded_sequence = 0;
|
||||
clear_history_state();
|
||||
return true;
|
||||
}
|
||||
|
||||
void copy_current_to_history(VkCommandBuffer cmd, VkImage source,
|
||||
uint32_t width, uint32_t height, uint64_t sequence) {
|
||||
if (!g_history || !source || !g_CmdPipelineBarrier || !g_CmdCopyImage) return;
|
||||
VkImageMemoryBarrier before{};
|
||||
before.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
const bool layout_defined = g_history_layout_defined || g_history_recorded_pending;
|
||||
before.srcAccessMask = layout_defined ? VK_ACCESS_SHADER_READ_BIT : 0;
|
||||
before.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
before.oldLayout = layout_defined ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
before.newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
before.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
before.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
before.image = g_history;
|
||||
before.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
g_CmdPipelineBarrier(cmd,
|
||||
layout_defined ? VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT : VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &before);
|
||||
|
||||
VkImageCopy region{};
|
||||
region.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
|
||||
region.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
|
||||
region.extent = {width, height, 1};
|
||||
g_CmdCopyImage(cmd, source, VK_IMAGE_LAYOUT_GENERAL, g_history, VK_IMAGE_LAYOUT_GENERAL, 1, ®ion);
|
||||
|
||||
VkImageMemoryBarrier after{};
|
||||
after.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
after.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
after.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||
after.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
after.newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
after.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
after.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
after.image = g_history;
|
||||
after.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
g_CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
0, 0, nullptr, 0, nullptr, 1, &after);
|
||||
g_history_recorded_pending = true;
|
||||
g_history_recorded_sequence = sequence;
|
||||
g_pair_pending = false;
|
||||
}
|
||||
|
||||
void copy_current_to_output(VkCommandBuffer cmd, VkImage output, uint32_t width, uint32_t height) {
|
||||
if (!g_current || !output || !g_CmdPipelineBarrier || !g_CmdCopyImage) return;
|
||||
VkImageMemoryBarrier before{};
|
||||
before.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
before.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
||||
before.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
before.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
before.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
before.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
before.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
before.image = output;
|
||||
before.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
g_CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, nullptr, 0, nullptr, 1, &before);
|
||||
VkImageCopy region{};
|
||||
region.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
|
||||
region.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
|
||||
region.extent = {width, height, 1};
|
||||
g_CmdCopyImage(cmd, g_current, VK_IMAGE_LAYOUT_GENERAL,
|
||||
output, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
|
||||
VkImageMemoryBarrier after{};
|
||||
after.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
after.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
after.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_SHADER_READ_BIT;
|
||||
after.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
after.newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
after.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
after.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
after.image = output;
|
||||
after.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
g_CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
0, 0, nullptr, 0, nullptr, 1, &after);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
extern "C" {
|
||||
void zfg_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance instance,
|
||||
VkPhysicalDevice physical_device, VkDevice device,
|
||||
uint32_t api_version, int synchronization2_enabled,
|
||||
int extended_storage_formats_enabled) {
|
||||
g_gipa = gipa;
|
||||
g_instance = instance;
|
||||
g_physical = physical_device;
|
||||
g_device = device;
|
||||
g_api_version = api_version;
|
||||
g_synchronization2 = synchronization2_enabled != 0;
|
||||
g_extended_formats = extended_storage_formats_enabled != 0;
|
||||
g_gdpa = g_gipa && g_instance
|
||||
? reinterpret_cast<PFN_vkGetDeviceProcAddr>(g_gipa(g_instance, "vkGetDeviceProcAddr"))
|
||||
: nullptr;
|
||||
load_device_functions();
|
||||
if (g_GetPhysicalDeviceMemoryProperties && g_physical)
|
||||
g_GetPhysicalDeviceMemoryProperties(g_physical, &g_memory_properties);
|
||||
g_ready = g_device != VK_NULL_HANDLE;
|
||||
g_supported = g_ready && g_api_version >= VK_API_VERSION_1_3 &&
|
||||
g_synchronization2 && g_extended_formats;
|
||||
g_failed = false;
|
||||
std::snprintf(g_reason, sizeof(g_reason), "%s", g_supported ? "available" :
|
||||
"requires Vulkan 1.3, synchronization2 and shaderStorageImageExtendedFormats");
|
||||
}
|
||||
|
||||
void zfg_device_lost(void) {
|
||||
g_interpolator.reset();
|
||||
destroy_history();
|
||||
g_gipa = nullptr; g_gdpa = nullptr;
|
||||
g_instance = VK_NULL_HANDLE; g_physical = VK_NULL_HANDLE; g_device = VK_NULL_HANDLE;
|
||||
g_ready = g_supported = g_failed = false;
|
||||
g_synchronization2 = g_extended_formats = false;
|
||||
g_api_version = VK_API_VERSION_1_0;
|
||||
g_GetPhysicalDeviceMemoryProperties = nullptr;
|
||||
g_GetPhysicalDeviceFormatProperties = nullptr;
|
||||
g_CreateImage = nullptr; g_DestroyImage = nullptr;
|
||||
g_CreateImageView = nullptr; g_DestroyImageView = nullptr;
|
||||
g_GetImageMemoryRequirements = nullptr; g_AllocateMemory = nullptr;
|
||||
g_FreeMemory = nullptr; g_BindImageMemory = nullptr;
|
||||
g_CmdPipelineBarrier = nullptr; g_CmdCopyImage = nullptr; g_DeviceWaitIdle = nullptr;
|
||||
g_memory_properties = {};
|
||||
std::snprintf(g_reason, sizeof(g_reason), "device lost");
|
||||
}
|
||||
|
||||
int zfg_caps_ok(void) { return g_supported ? 1 : 0; }
|
||||
const char *zfg_caps_reason(void) { return g_reason; }
|
||||
|
||||
int zfg_start(void) {
|
||||
if (!g_supported || !g_ready) return 0;
|
||||
if (g_interpolator) return 1;
|
||||
zerofg::CreateInfo info{};
|
||||
info.vulkan.instance = g_instance;
|
||||
info.vulkan.physical_device = g_physical;
|
||||
info.vulkan.device = g_device;
|
||||
info.vulkan.get_instance_proc_addr = g_gipa;
|
||||
info.mode = zerofg::Mode::kReallyZero;
|
||||
info.backend = zerofg::Backend::kCompat;
|
||||
info.frame_context_count = 4;
|
||||
info.capabilities.effective_api_version = g_api_version;
|
||||
info.capabilities.synchronization2_enabled = g_synchronization2;
|
||||
info.capabilities.shader_storage_image_extended_formats_enabled = g_extended_formats;
|
||||
zerofg::Status status = zerofg::Status::kSuccess;
|
||||
g_interpolator = zerofg::Interpolator::Create(info, &status);
|
||||
if (!g_interpolator) {
|
||||
std::snprintf(g_reason, sizeof(g_reason), "interpolator creation failed (%d)", (int)status);
|
||||
g_failed = true;
|
||||
ZFG_ERR("%s", g_reason);
|
||||
return 0;
|
||||
}
|
||||
g_failed = false;
|
||||
ZFG_LOG("ReallyZero engine ready (Compat backend)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void zfg_stop(void) {
|
||||
g_interpolator.reset();
|
||||
destroy_history();
|
||||
reset_pacing();
|
||||
g_last_sequence = 0;
|
||||
g_failed = false;
|
||||
}
|
||||
int zfg_unavailable(void) { return g_failed || !g_interpolator ? 1 : 0; }
|
||||
|
||||
int zfg_format_ok(VkFormat format) {
|
||||
if (!g_supported || !g_GetPhysicalDeviceFormatProperties || format == VK_FORMAT_UNDEFINED) return 0;
|
||||
VkFormatProperties input{};
|
||||
g_GetPhysicalDeviceFormatProperties(g_physical, format, &input);
|
||||
const VkFormatFeatureFlags sampled =
|
||||
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
||||
if ((input.optimalTilingFeatures & sampled) != sampled) return 0;
|
||||
if (format == VK_FORMAT_A2B10G10R10_UNORM_PACK32)
|
||||
return (input.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0;
|
||||
VkFormatProperties internal{};
|
||||
g_GetPhysicalDeviceFormatProperties(g_physical, VK_FORMAT_A2B10G10R10_UNORM_PACK32, &internal);
|
||||
const VkFormatFeatureFlags needed = VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT;
|
||||
return (input.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT) != 0 &&
|
||||
(internal.optimalTilingFeatures & needed) == needed;
|
||||
}
|
||||
|
||||
int zfg_prepare(uint32_t width, uint32_t height, VkFormat format) {
|
||||
if (!g_interpolator || g_failed || !width || !height) return 0;
|
||||
if (!zfg_format_ok(format)) {
|
||||
std::snprintf(g_reason, sizeof(g_reason), "unsupported input/output format %d", (int)format);
|
||||
g_failed = true;
|
||||
ZFG_ERR("%s", g_reason);
|
||||
return 0;
|
||||
}
|
||||
if (g_width == width && g_height == height && g_format == format && g_history) return 1;
|
||||
if (g_DeviceWaitIdle) g_DeviceWaitIdle(g_device);
|
||||
destroy_history();
|
||||
const zerofg::Status resized = g_interpolator->Resize(width, height, format, format);
|
||||
if (resized != zerofg::Status::kSuccess) {
|
||||
std::snprintf(g_reason, sizeof(g_reason), "resize failed (%d)", (int)resized);
|
||||
g_failed = true;
|
||||
ZFG_ERR("%s", g_reason);
|
||||
return 0;
|
||||
}
|
||||
if (!make_history(width, height, format)) {
|
||||
g_failed = true;
|
||||
ZFG_ERR("%s", g_reason);
|
||||
return 0;
|
||||
}
|
||||
ZFG_LOG("prepared %ux%u format %d", width, height, (int)format);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void zfg_configure(uint32_t multiplier, float refresh_hz) {
|
||||
g_multiplier = std::clamp<uint32_t>(multiplier, 2, 4);
|
||||
g_refresh_hz = refresh_hz > 1.0f ? refresh_hz : 0.0f;
|
||||
}
|
||||
|
||||
void zfg_set_layer_timing(int layer) { g_layer_timing = layer != 0; }
|
||||
|
||||
void zfg_set_phases(const float *phases, uint32_t count) {
|
||||
g_external_count = phases ? std::min<uint32_t>(count, static_cast<uint32_t>(g_external_phases.size())) : 0;
|
||||
for (uint32_t i = 0; i < g_external_count; i++) g_external_phases[i] = phases[i];
|
||||
}
|
||||
|
||||
float zfg_phase(uint32_t index, uint32_t count) { return pair_phase(index, count); }
|
||||
|
||||
uint32_t zfg_plan(uint32_t capacity, uint64_t sequence) {
|
||||
if (!g_interpolator || g_failed) return 0;
|
||||
note_sequence(sequence);
|
||||
if (!g_history_valid || sequence <= g_history_sequence || !g_pair_interval_ns) return 0;
|
||||
return pair_capacity(std::min<uint32_t>({capacity, 3u, g_multiplier - 1}));
|
||||
}
|
||||
|
||||
void zfg_telemetry(float *generated, float *source_rate) {
|
||||
const uint64_t typical = typical_interval_ns();
|
||||
*generated = static_cast<float>(g_pair_count);
|
||||
*source_rate = typical ? static_cast<float>(1e9 / static_cast<double>(typical)) : 0.0f;
|
||||
}
|
||||
|
||||
void zfg_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view,
|
||||
uint32_t width, uint32_t height, VkFormat format,
|
||||
uint64_t sequence, uint32_t generations) {
|
||||
g_pair_pending = false;
|
||||
g_fallback_outputs.fill(false);
|
||||
if (!g_interpolator || g_failed || !source || !g_history ||
|
||||
format != g_format || width != g_width || height != g_height) return;
|
||||
if (sequence > g_history_sequence) {
|
||||
g_prev_count = g_pair_count;
|
||||
g_pair_count = generations;
|
||||
}
|
||||
if (generations == 0 || !g_history_valid || sequence <= g_history_sequence) {
|
||||
copy_current_to_history(cmd, source, width, height, sequence);
|
||||
return;
|
||||
}
|
||||
if (!source_view) return;
|
||||
g_current = source;
|
||||
g_current_view = source_view;
|
||||
g_current_sequence = sequence;
|
||||
g_pair_pending = true;
|
||||
}
|
||||
|
||||
void zfg_generate(VkCommandBuffer cmd, uint32_t index, uint32_t count,
|
||||
VkImage output, VkImageView output_view, uint32_t width, uint32_t height) {
|
||||
if (!g_pair_pending || !g_interpolator || !g_history_valid || index >= count || !output || !output_view) return;
|
||||
const float phase = pair_phase(index, count);
|
||||
zerofg::Image previous{};
|
||||
previous.image = g_history; previous.view = g_history_view;
|
||||
previous.layout = VK_IMAGE_LAYOUT_GENERAL; previous.format = g_format;
|
||||
previous.width = g_width; previous.height = g_height;
|
||||
previous.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
previous.sequence = g_history_sequence;
|
||||
zerofg::Image current{};
|
||||
current.image = g_current; current.view = g_current_view;
|
||||
current.layout = VK_IMAGE_LAYOUT_GENERAL; current.format = g_format;
|
||||
current.width = g_width; current.height = g_height;
|
||||
current.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||
current.sequence = g_current_sequence;
|
||||
zerofg::Image result{};
|
||||
result.image = output; result.view = output_view;
|
||||
result.layout = VK_IMAGE_LAYOUT_GENERAL; result.format = g_format;
|
||||
result.width = width; result.height = height;
|
||||
result.usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
|
||||
const zerofg::Status status =
|
||||
g_interpolator->Interpolate(cmd, index, previous, current, phase, result);
|
||||
if (status != zerofg::Status::kSuccess) {
|
||||
ZFG_ERR("interpolation status %d; copying the real frame as fallback", (int)status);
|
||||
g_fallback_outputs[index] = true;
|
||||
copy_current_to_output(cmd, output, width, height);
|
||||
}
|
||||
if (index + 1 >= count) {
|
||||
copy_current_to_history(cmd, g_current, width, height, g_current_sequence);
|
||||
g_pair_pending = false;
|
||||
}
|
||||
}
|
||||
|
||||
void zfg_commit_history_update(void) {
|
||||
if (!g_history_recorded_pending) return;
|
||||
g_history_layout_defined = true;
|
||||
g_history_valid = true;
|
||||
g_history_sequence = g_history_recorded_sequence;
|
||||
g_history_recorded_pending = false;
|
||||
}
|
||||
|
||||
void zfg_discard_history_update(void) {
|
||||
g_history_recorded_pending = false;
|
||||
g_history_recorded_sequence = 0;
|
||||
}
|
||||
|
||||
void zfg_forget_targets(void) {
|
||||
g_pair_pending = false;
|
||||
g_history_recorded_pending = false;
|
||||
g_history_recorded_sequence = 0;
|
||||
g_history_valid = false;
|
||||
g_history_sequence = 0;
|
||||
reset_pacing();
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef FRAMEGEN_ZEROFG_H
|
||||
#define FRAMEGEN_ZEROFG_H
|
||||
#include <stdint.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void zfg_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance instance,
|
||||
VkPhysicalDevice physical_device, VkDevice device,
|
||||
uint32_t api_version, int synchronization2_enabled,
|
||||
int extended_storage_formats_enabled);
|
||||
void zfg_device_lost(void);
|
||||
int zfg_caps_ok(void);
|
||||
const char *zfg_caps_reason(void);
|
||||
int zfg_start(void);
|
||||
void zfg_stop(void);
|
||||
int zfg_unavailable(void);
|
||||
int zfg_format_ok(VkFormat format);
|
||||
int zfg_prepare(uint32_t width, uint32_t height, VkFormat format);
|
||||
void zfg_configure(uint32_t multiplier, float refresh_hz);
|
||||
void zfg_set_layer_timing(int layer);
|
||||
void zfg_set_phases(const float *phases, uint32_t count);
|
||||
float zfg_phase(uint32_t index, uint32_t count);
|
||||
uint32_t zfg_plan(uint32_t capacity, uint64_t sequence);
|
||||
void zfg_telemetry(float *generated, float *source_rate);
|
||||
void zfg_process(VkCommandBuffer command_buffer, VkImage source, VkImageView source_view,
|
||||
uint32_t width, uint32_t height, VkFormat format,
|
||||
uint64_t sequence, uint32_t generations);
|
||||
void zfg_generate(VkCommandBuffer command_buffer, uint32_t index, uint32_t count,
|
||||
VkImage output, VkImageView output_view,
|
||||
uint32_t width, uint32_t height);
|
||||
void zfg_forget_targets(void);
|
||||
void zfg_commit_history_update(void);
|
||||
void zfg_discard_history_update(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -58,6 +58,7 @@ static struct {
|
||||
void (*reparent)(ASurfaceTransaction *, ASurfaceControl *, ASurfaceControl *);
|
||||
void (*setOnComplete)(ASurfaceTransaction *, void *, sc_complete_fn);
|
||||
int (*prevReleaseFence)(ASurfaceTransactionStats *, ASurfaceControl *);
|
||||
int (*presentFence)(ASurfaceTransactionStats *);
|
||||
void (*setFrameRate)(ASurfaceTransaction *, ASurfaceControl *, float, int8_t);
|
||||
void (*setFrameRateStrategy)(ASurfaceTransaction *, ASurfaceControl *, float, int8_t, int8_t);
|
||||
void (*setBufferDataSpace)(ASurfaceTransaction *, ASurfaceControl *, int32_t);
|
||||
@@ -102,6 +103,7 @@ static int load_api(void) {
|
||||
SYM(reparent, "ASurfaceTransaction_reparent");
|
||||
SYM(setOnComplete, "ASurfaceTransaction_setOnComplete");
|
||||
SYM(prevReleaseFence, "ASurfaceTransactionStats_getPreviousReleaseFenceFd");
|
||||
SYM(presentFence, "ASurfaceTransactionStats_getPresentFenceFd");
|
||||
SYM(setFrameRate, "ASurfaceTransaction_setFrameRate");
|
||||
SYM(setFrameRateStrategy, "ASurfaceTransaction_setFrameRateWithChangeStrategy");
|
||||
SYM(setBufferDataSpace, "ASurfaceTransaction_setBufferDataSpace");
|
||||
@@ -265,7 +267,33 @@ static int64_t cadence_target(int64_t now, int64_t earliest, int64_t period) {
|
||||
return target;
|
||||
}
|
||||
|
||||
static int64_t g_planned_next_ns;
|
||||
|
||||
void sc_layer_set_planned(int64_t present_ns) {
|
||||
pthread_mutex_lock(&g_lock);
|
||||
g_planned_next_ns = present_ns;
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
}
|
||||
|
||||
void sc_layer_timeline(int64_t *present_ns, int64_t *period_ns) {
|
||||
pthread_mutex_lock(&g_timeline_lock);
|
||||
*present_ns = g_timeline_present_ns;
|
||||
*period_ns = g_timeline_period_ns;
|
||||
pthread_mutex_unlock(&g_timeline_lock);
|
||||
}
|
||||
|
||||
void sc_layer_cadence_info(int64_t *gap_ns, int *group_frames) {
|
||||
if (gap_ns) *gap_ns = g_cadence_gap_ns;
|
||||
if (group_frames) *group_frames = g_group_frames;
|
||||
}
|
||||
|
||||
static void apply_present_time(ASurfaceTransaction *tx, int game) {
|
||||
pthread_mutex_lock(&g_lock);
|
||||
const int64_t planned = game ? g_planned_next_ns : 0;
|
||||
if (game) {
|
||||
g_planned_next_ns = 0;
|
||||
}
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
if (!api.setDesiredPresentTime) return;
|
||||
pthread_mutex_lock(&g_timeline_lock);
|
||||
const int64_t present = g_timeline_present_ns, deadline = g_timeline_deadline_ns, period = g_timeline_period_ns;
|
||||
@@ -285,6 +313,9 @@ static void apply_present_time(ASurfaceTransaction *tx, int game) {
|
||||
target = cadence_target(now, target, period);
|
||||
}
|
||||
if (game && g_group_frames > 1 && ++g_group_index >= g_group_frames) { g_group_index = 0; g_group_frames = 1; }
|
||||
if (planned > 0) {
|
||||
target = planned;
|
||||
}
|
||||
api.setDesiredPresentTime(tx, target - period / 2);
|
||||
}
|
||||
|
||||
@@ -893,7 +924,9 @@ static int present_slot(struct layer *l, int idx, const int r[8], const struct d
|
||||
int translucent) {
|
||||
struct slot *s = &l->slots[idx];
|
||||
ASurfaceTransaction *tx = api.txCreate();
|
||||
if (!tx) return -1;
|
||||
if (!tx) {
|
||||
return -1;
|
||||
}
|
||||
const int was_shown = l->shown;
|
||||
const int32_t ds_applied = l->ds_applied;
|
||||
const uint32_t md_applied = l->md_applied;
|
||||
@@ -1114,7 +1147,7 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const
|
||||
if (!mapped) { vkp_pass_abort(); sc_layer_hide(); return 0; }
|
||||
idx[VKP_FG_MAX_GENERATIONS] = deep ? take_hdr_slot(l, rw, rh, &first_fd)
|
||||
: take_free_slot(l, rw, rh, AHB_RGBA8, &first_fd);
|
||||
if (idx[VKP_FG_MAX_GENERATIONS] < 0) { vkp_pass_abort(); log_drop(l); return g_alloc_failed ? -1 : 0; }
|
||||
if (idx[VKP_FG_MAX_GENERATIONS] < 0) { vkp_pass_abort(); vkp_framegen_pacer_abort(); log_drop(l); return g_alloc_failed ? -1 : 0; }
|
||||
pthread_mutex_lock(&g_lock);
|
||||
l->slots[idx[VKP_FG_MAX_GENERATIONS]].busy = 1;
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
@@ -1136,13 +1169,18 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const
|
||||
if (!have_fd) { first_fd = fd; have_fd = 1; }
|
||||
}
|
||||
if (vkp_pass_copy_generated(dst, m, real, first_fd) != 0) {
|
||||
vkp_framegen_pacer_abort();
|
||||
slots_idle(l, idx, 0, m);
|
||||
if (real) slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
|
||||
return -1;
|
||||
}
|
||||
g_group_frames = m + 1;
|
||||
for (int k = 0; k < m; k++) {
|
||||
int64_t planned;
|
||||
vkp_framegen_output_planned(k, m, &planned);
|
||||
sc_layer_set_planned(planned);
|
||||
if (present_slot(l, idx[k], r, color, 0) == 0) continue;
|
||||
vkp_framegen_pacer_abort();
|
||||
slots_idle(l, idx, k, m);
|
||||
if (real) slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
|
||||
g_group_index = 0;
|
||||
@@ -1151,7 +1189,11 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const
|
||||
}
|
||||
vkp_framegen_presented(m);
|
||||
if (real) {
|
||||
int64_t planned;
|
||||
vkp_framegen_output_planned(m, m, &planned);
|
||||
sc_layer_set_planned(planned);
|
||||
if (present_slot(l, idx[VKP_FG_MAX_GENERATIONS], r, color, 0) != 0) {
|
||||
vkp_framegen_pacer_abort();
|
||||
slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
|
||||
g_group_index = 0;
|
||||
g_group_frames = 1;
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
#include <stdint.h>
|
||||
#include <android/hardware_buffer.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct vkp_image;
|
||||
struct vkp_draw;
|
||||
struct droiddeck_color;
|
||||
@@ -51,7 +55,16 @@ void sc_layer_window_gone(void);
|
||||
|
||||
void sc_layer_frame_timeline(int64_t present_ns, int64_t deadline_ns, int64_t period_ns);
|
||||
void sc_layer_aim_take(unsigned *next, unsigned *later, unsigned *even);
|
||||
/* The refresh the next game-layer frame is timed for, instead of the layer's own spacing (0: the layer's). */
|
||||
void sc_layer_set_planned(int64_t present_ns);
|
||||
/* The display's frame timeline: the next expected present and the refresh period (0 until known). */
|
||||
void sc_layer_timeline(int64_t *present_ns, int64_t *period_ns);
|
||||
void sc_layer_cadence_info(int64_t *gap_ns, int *group_frames);
|
||||
unsigned sc_layer_frames_take(void);
|
||||
unsigned sc_layer_drops_take(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "effects_chain.h"
|
||||
#include "cardboard.h"
|
||||
#include "framegen_bridge.h"
|
||||
#include "framegen_zerofg.h"
|
||||
#include "hdr_compose.h"
|
||||
#include "blend_pass.h"
|
||||
#include "gpu_busy.h"
|
||||
@@ -604,6 +605,10 @@ static void update_map(int scene_w, int scene_h) {
|
||||
float min_y = (float)g_map.ry + g_map.rh - image_h;
|
||||
if (g_map.off_y < min_y) g_map.off_y = min_y;
|
||||
if (g_map.off_y > g_map.ry) g_map.off_y = (float)g_map.ry;
|
||||
} else if (align == VKP_ALIGN_PICTURE_TOP) {
|
||||
g_map.off_y = 0;
|
||||
} else if (align == VKP_ALIGN_PICTURE_BOTTOM) {
|
||||
g_map.off_y = H - image_h;
|
||||
} else {
|
||||
g_map.off_y = (float)g_map.ry + (g_map.rh - image_h) * 0.5f;
|
||||
}
|
||||
@@ -2895,6 +2900,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
|
||||
if (!(pass && fx)) release_external_client_draws(cmd, draws, n);
|
||||
int ngen = 0;
|
||||
int history_staged = 0;
|
||||
VkImage gens[VKP_FG_MAX_GENERATIONS] = {VK_NULL_HANDLE};
|
||||
VkImage result = scene_img;
|
||||
int rw = input_w, rh = input_h;
|
||||
@@ -2933,6 +2939,8 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
0, 0, NULL, 0, NULL, 1, &b_general);
|
||||
|
||||
if (fg) {
|
||||
vkp_framegen_set_layer_timing(0);
|
||||
history_staged = 1;
|
||||
ngen = vkp_framegen_run(cmd, result, VK_NULL_HANDLE, rw, rh, scene_fmt, gens);
|
||||
if (ngen < 0) ngen = 0;
|
||||
if (ngen > VKP_FG_MAX_GENERATIONS) ngen = VKP_FG_MAX_GENERATIONS;
|
||||
@@ -2958,7 +2966,10 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
/* Teardown may have retained this frame's pending work, or
|
||||
* acquire may have reported real device loss. Neither permits
|
||||
* a completion-marker submit or another fence wait. */
|
||||
if (g_dev_state != 1) return -1;
|
||||
if (g_dev_state != 1) {
|
||||
if (history_staged) zfg_discard_history_update();
|
||||
return -1;
|
||||
}
|
||||
droiddeck_log("framegen", "present %d/%d: no swapchain image; the frame ends early", k + 1, presents);
|
||||
pr = VK_ERROR_OUT_OF_DATE_KHR;
|
||||
break;
|
||||
@@ -2982,6 +2993,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
if (img >= g_rnd_count || !g_rnds[img]) {
|
||||
droiddeck_log("error", "present: image index %u exceeds semaphore count %u",
|
||||
img, g_rnd_count);
|
||||
if (history_staged) zfg_discard_history_update();
|
||||
destroy_swapchain();
|
||||
return -1;
|
||||
}
|
||||
@@ -2990,12 +3002,17 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
.pCommandBuffers = &g_cmds[k], .signalSemaphoreCount = 1, .pSignalSemaphores = &g_rnds[img]};
|
||||
VkResult qr = g_vk.QueueSubmit(g_queue, 1, &si, last ? g_fence : VK_NULL_HANDLE);
|
||||
if (qr != VK_SUCCESS) {
|
||||
if (history_staged) zfg_discard_history_update();
|
||||
if (qr == VK_ERROR_DEVICE_LOST) device_lost("submit");
|
||||
else LOGE("present: submit %d/%d failed (%d)", k + 1, presents, (int)qr);
|
||||
if (g_dev_state != -2) destroy_swapchain();
|
||||
return -1;
|
||||
}
|
||||
fence_submitted = last;
|
||||
if (k == 0 && history_staged) {
|
||||
zfg_commit_history_update();
|
||||
history_staged = 0;
|
||||
}
|
||||
VkPresentInfoKHR pi = {.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, .waitSemaphoreCount = 1,
|
||||
.pWaitSemaphores = &g_rnds[img], .swapchainCount = 1,
|
||||
.pSwapchains = &g_swapchain, .pImageIndices = &img};
|
||||
@@ -3003,21 +3020,37 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
pr = g_vk.QueuePresentKHR(g_queue, &pi);
|
||||
perf_add(&g_perf.present_ns, &g_perf.present_max_ns, &g_perf.presents, perf_now() - t_pres);
|
||||
if (k < ngen) presented_gen++;
|
||||
if (pr == VK_ERROR_DEVICE_LOST) { device_lost("present"); return -1; }
|
||||
if (pr == VK_ERROR_DEVICE_LOST) {
|
||||
if (history_staged) zfg_discard_history_update();
|
||||
device_lost("present");
|
||||
return -1;
|
||||
}
|
||||
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) break;
|
||||
}
|
||||
if (!fence_submitted) {
|
||||
VkSubmitInfo si = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO};
|
||||
VkResult marker = g_vk.QueueSubmit(g_queue, 1, &si, g_fence);
|
||||
if (marker != VK_SUCCESS) {
|
||||
if (history_staged) zfg_discard_history_update();
|
||||
if (marker == VK_ERROR_DEVICE_LOST) device_lost("frame completion submit");
|
||||
else quarantine_pending_work(marker, "frame completion submit");
|
||||
return -1; /* no fence was submitted; never wait on its unsignalled state */
|
||||
}
|
||||
if (history_staged) {
|
||||
zfg_discard_history_update();
|
||||
history_staged = 0;
|
||||
}
|
||||
}
|
||||
VkResult fr = timed_wait(g_fence, UINT64_MAX);
|
||||
if (fr == VK_ERROR_DEVICE_LOST || pr == VK_ERROR_DEVICE_LOST) { device_lost("present"); return -1; }
|
||||
if (fr != VK_SUCCESS) return -1;
|
||||
if (fr == VK_ERROR_DEVICE_LOST || pr == VK_ERROR_DEVICE_LOST) {
|
||||
if (history_staged) zfg_discard_history_update();
|
||||
device_lost("present");
|
||||
return -1;
|
||||
}
|
||||
if (fr != VK_SUCCESS) {
|
||||
if (history_staged) zfg_discard_history_update();
|
||||
return -1;
|
||||
}
|
||||
vkp_effects_release_generated_sources();
|
||||
if (fg) vkp_framegen_presented(presented_gen);
|
||||
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) {
|
||||
@@ -3369,6 +3402,9 @@ static struct {
|
||||
int active;
|
||||
VkImage result;
|
||||
int rw, rh;
|
||||
/* The layer buffers' size: rw x rh, or the spatial filter's output when it runs on each frame after generation. */
|
||||
int ow, oh;
|
||||
int post_upscale;
|
||||
int ngen;
|
||||
VkImage gens[VKP_FG_MAX_GENERATIONS];
|
||||
} g_pass;
|
||||
@@ -3508,10 +3544,29 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
|
||||
}
|
||||
|
||||
int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f);
|
||||
g_pass.post_upscale = generate && !hf && vkp_effects_active() && vkp_effects_upscaling() &&
|
||||
vkp_effects_prepare_generated() && (mapped_w > input_w || mapped_h > input_h);
|
||||
if (g_pass.post_upscale) {
|
||||
static int last_input_w, last_input_h, last_output_w, last_output_h;
|
||||
if (input_w != last_input_w || input_h != last_input_h || mapped_w != last_output_w || mapped_h != last_output_h) {
|
||||
droiddeck_log("framegen", "post-upscale on the display layer: interpolate %dx%d, spatial filter each "
|
||||
"frame to %dx%d", input_w, input_h, mapped_w, mapped_h);
|
||||
last_input_w = input_w; last_input_h = input_h;
|
||||
last_output_w = mapped_w; last_output_h = mapped_h;
|
||||
}
|
||||
}
|
||||
if (generate && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; }
|
||||
g_pass.rw = input_w; g_pass.rh = input_h;
|
||||
g_pass.result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h,
|
||||
&g_pass.rw, &g_pass.rh);
|
||||
if (g_pass.post_upscale) {
|
||||
g_pass.ow = (int)(scene_w * g_map.kx + 0.5f);
|
||||
g_pass.oh = (int)(scene_h * g_map.ky + 0.5f);
|
||||
g_pass.result = vkp_effects_run_before_generated(cmd, scene_img, input_w, input_h, &g_pass.rw, &g_pass.rh);
|
||||
} else {
|
||||
g_pass.result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h,
|
||||
&g_pass.rw, &g_pass.rh);
|
||||
g_pass.ow = g_pass.rw;
|
||||
g_pass.oh = g_pass.rh;
|
||||
}
|
||||
effects_overlay_draws(cmd, g_pass.result, g_pass.rw, g_pass.rh, scene_w, scene_h,
|
||||
draws ? draws + overlay_start : NULL, n - overlay_start);
|
||||
release_external_client_draws(cmd, draws, n);
|
||||
@@ -3526,38 +3581,45 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
0, 0, NULL, 0, NULL, 1, &b);
|
||||
vkp_framegen_set_layer_timing(1);
|
||||
int ngen = vkp_framegen_run(cmd, g_pass.result, VK_NULL_HANDLE, g_pass.rw, g_pass.rh, scene_fmt, g_pass.gens);
|
||||
if (ngen < 0) ngen = 0;
|
||||
g_pass.ngen = ngen > VKP_FG_MAX_GENERATIONS ? VKP_FG_MAX_GENERATIONS : ngen;
|
||||
}
|
||||
g_pass.active = 1;
|
||||
if (rw) *rw = g_pass.rw;
|
||||
if (rh) *rh = g_pass.rh;
|
||||
if (rw) *rw = g_pass.ow;
|
||||
if (rh) *rh = g_pass.oh;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pass_finish(const VkImage *srcs, VkImageLayout src_layout, struct vkp_image *const *dsts, int n,
|
||||
int wait_fd) {
|
||||
if (!g_pass.active) { if (wait_fd >= 0) close(wait_fd); return -1; }
|
||||
if (!g_pass.active) { zfg_discard_history_update(); if (wait_fd >= 0) close(wait_fd); return -1; }
|
||||
g_pass.active = 0;
|
||||
if (g_dev_state != 1) { if (wait_fd >= 0) close(wait_fd); return -1; }
|
||||
if (g_dev_state != 1) { zfg_discard_history_update(); if (wait_fd >= 0) close(wait_fd); return -1; }
|
||||
VkCommandBuffer cmd = g_cmds[0];
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (dsts[i] && dsts[i]->blit_dst) continue;
|
||||
if (wait_fd >= 0) close(wait_fd);
|
||||
g_vk.EndCommandBuffer(cmd);
|
||||
zfg_discard_history_update();
|
||||
return -1;
|
||||
}
|
||||
const int gpu_wait = take_wait_fd(wait_fd);
|
||||
if (gpu_wait < 0) { g_vk.EndCommandBuffer(cmd); return -1; }
|
||||
if (gpu_wait < 0) { zfg_discard_history_update(); g_vk.EndCommandBuffer(cmd); return -1; }
|
||||
const int post_upscale = g_pass.post_upscale && src_layout == VK_IMAGE_LAYOUT_GENERAL;
|
||||
for (int i = 0; i < n; i++) {
|
||||
struct vkp_image *dst = dsts[i];
|
||||
VkImage src = srcs[i];
|
||||
int sw = g_pass.rw, sh = g_pass.rh;
|
||||
if (post_upscale)
|
||||
src = vkp_effects_run_generated(cmd, src, g_pass.rw, g_pass.rh, g_pass.ow, g_pass.oh, i, &sw, &sh);
|
||||
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||
.srcOffsets = {{0, 0, 0}, {g_pass.rw, g_pass.rh, 1}},
|
||||
.srcOffsets = {{0, 0, 0}, {sw, sh, 1}},
|
||||
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||
.dstOffsets = {{0, 0, 0}, {dst->w, dst->h, 1}}};
|
||||
blit_to_layer(cmd, srcs[i], src_layout, dst, &blit,
|
||||
(g_pass.rw == dst->w && g_pass.rh == dst->h) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR);
|
||||
blit_to_layer(cmd, src, src_layout, dst, &blit,
|
||||
(sw == dst->w && sh == dst->h) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR);
|
||||
}
|
||||
g_vk.EndCommandBuffer(cmd);
|
||||
|
||||
@@ -3568,13 +3630,17 @@ static int pass_finish(const VkImage *srcs, VkImageLayout src_layout, struct vkp
|
||||
g_vk.ResetFences(g_dev, 1, &g_fence);
|
||||
VkResult qr = g_vk.QueueSubmit(g_queue, 1, &si, g_fence);
|
||||
if (qr != VK_SUCCESS) {
|
||||
zfg_discard_history_update();
|
||||
if (qr == VK_ERROR_DEVICE_LOST) device_lost("layer pass");
|
||||
else LOGE("layer: effects pass submit failed (%d)", (int)qr);
|
||||
return -1;
|
||||
}
|
||||
zfg_commit_history_update();
|
||||
VkResult fr = timed_wait(g_fence, 1000000000ULL);
|
||||
if (fr == VK_ERROR_DEVICE_LOST) { device_lost("layer pass"); return -1; }
|
||||
if (fr != VK_SUCCESS) { LOGE("layer: effects pass fence wait -> %s", vk_result_name(fr)); return -1; }
|
||||
if (post_upscale) vkp_effects_release_generated_sources();
|
||||
vkp_framegen_completed();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3592,6 +3658,7 @@ int vkp_pass_copy_generated(struct vkp_image *const *dsts, int n, struct vkp_ima
|
||||
}
|
||||
|
||||
void vkp_pass_abort(void) {
|
||||
zfg_discard_history_update();
|
||||
if (!g_pass.active) return;
|
||||
g_pass.active = 0;
|
||||
if (g_dev_state == 1)
|
||||
|
||||
@@ -461,6 +461,11 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetZeroCopy(JNIEnv *
|
||||
__android_log_print(ANDROID_LOG_INFO, TAG, "zero-copy layer mode %s%s", on ? "on" : "off", live ? " (live)" : "");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetMirrorCapture(JNIEnv *env, jclass clazz, jboolean on) {
|
||||
droiddeck_host_mirror_capture(on ? 1 : 0);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetDisplayBufferDriver(JNIEnv *env, jclass clazz, jboolean on) {
|
||||
g_display_buffer_driver = on ? 1 : 0;
|
||||
|
||||
@@ -200,7 +200,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
private var phantomProcessStatus by mutableStateOf(PhantomProcessStatus.NOT_APPLICABLE)
|
||||
private var showPhantomGate by mutableStateOf(false)
|
||||
private var directAudio by mutableStateOf(false)
|
||||
private var picturePosition by mutableStateOf("center")
|
||||
private var picturePositionLandscape by mutableStateOf("center")
|
||||
private var picturePositionPortrait by mutableStateOf("top")
|
||||
private var integerScaling by mutableStateOf(false)
|
||||
private var stretch16x9 by mutableStateOf(false)
|
||||
private var avoidNotch by mutableStateOf(false)
|
||||
@@ -2365,7 +2366,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
refreshHomeAppState()
|
||||
}
|
||||
if (settingsMode == SessionService.MODE_STEAM) refreshFoundSteamLibraries()
|
||||
settingsMode?.let { hdrOn = SessionPrefs.hdr(this, it) }
|
||||
settingsMode?.let { mode ->
|
||||
hdrOn = SessionPrefs.hdr(this, mode)
|
||||
if (mode == SessionService.MODE_STEAM) loadPicturePositions()
|
||||
}
|
||||
compatLaunchVisible = true
|
||||
com.droiddeck.launcher.ui.DualScreenPanel.yieldTo(taskId, false)
|
||||
com.droiddeck.launcher.ui.DualScreenPanel.ownerPaused(taskId, false)
|
||||
@@ -2924,7 +2928,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
backHold = backHold,
|
||||
backActionsInverted = backActionsInverted,
|
||||
directAudio = if (mode == SessionService.MODE_STEAM) directAudio else null,
|
||||
picturePosition = if (mode == SessionService.MODE_STEAM) picturePosition else null,
|
||||
picturePositionLandscape = picturePositionLandscape.takeIf { mode == SessionService.MODE_STEAM },
|
||||
picturePositionPortrait = picturePositionPortrait.takeIf { mode == SessionService.MODE_STEAM },
|
||||
integerScaling = if (mode == SessionService.MODE_STEAM) integerScaling else null,
|
||||
stretch16x9 = if (mode == SessionService.MODE_STEAM) stretch16x9 else null,
|
||||
avoidNotch = if (mode == SessionService.MODE_STEAM) avoidNotch else null,
|
||||
@@ -3001,7 +3006,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
backActionsInverted = inverted
|
||||
},
|
||||
onDirectAudio = { on -> SessionPrefs.setDirectAudio(this, on); directAudio = on },
|
||||
onPicturePosition = { value -> SessionPrefs.setPicturePosition(this, value); picturePosition = value },
|
||||
onPicturePosition = { portrait, value ->
|
||||
SessionPrefs.setPicturePosition(this, portrait, value)
|
||||
if (portrait) picturePositionPortrait = value else picturePositionLandscape = value
|
||||
},
|
||||
onIntegerScaling = { on -> SessionPrefs.setIntegerScaling(this, on); integerScaling = on },
|
||||
onStretch16x9 = { on -> SessionPrefs.setStretch16x9(this, on); stretch16x9 = on },
|
||||
onAvoidNotch = { on -> SessionPrefs.setAvoidNotch(this, on); avoidNotch = on },
|
||||
@@ -3318,6 +3326,11 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
resolutionPortrait = SessionPrefs.resolutionStored(this, mode, panel, true)
|
||||
}
|
||||
|
||||
private fun loadPicturePositions() {
|
||||
picturePositionLandscape = SessionPrefs.picturePosition(this, portrait = false)
|
||||
picturePositionPortrait = SessionPrefs.picturePosition(this, portrait = true)
|
||||
}
|
||||
|
||||
private fun loadModeSettings(mode: String) {
|
||||
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
||||
unfoldedControls = SessionPrefs.unfoldedControls(this)
|
||||
@@ -3353,7 +3366,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
backHold = SessionPrefs.backHold(this)
|
||||
backActionsInverted = SessionPrefs.backActionsInverted(this)
|
||||
directAudio = SessionPrefs.directAudio(this)
|
||||
picturePosition = SessionPrefs.picturePosition(this)
|
||||
loadPicturePositions()
|
||||
integerScaling = SessionPrefs.integerScaling(this)
|
||||
stretch16x9 = SessionPrefs.stretch16x9(this)
|
||||
avoidNotch = SessionPrefs.avoidNotch(this)
|
||||
|
||||
@@ -180,6 +180,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var adaptiveSticks by mutableStateOf<Boolean?>(null)
|
||||
private var quickButtons by mutableStateOf<Map<InputCommand, Boolean>>(emptyMap())
|
||||
private var picturePosition by mutableStateOf("center")
|
||||
|
||||
private fun picturePortrait(config: android.content.res.Configuration = resources.configuration): Boolean =
|
||||
config.orientation == android.content.res.Configuration.ORIENTATION_PORTRAIT
|
||||
private var integerScaling by mutableStateOf(false)
|
||||
private var gameZoom by mutableStateOf(SessionState.gameZoom)
|
||||
private var avoidNotch = false
|
||||
@@ -658,6 +661,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var effects by mutableStateOf(ScreenEffects.OFF)
|
||||
private var observedScreenEffectsProfileId by mutableStateOf<String?>(null)
|
||||
private var screenEffectsTarget by mutableStateOf(SCREEN_EFFECTS_TARGET_AUTO)
|
||||
private var screenEffectsProfileRevision by mutableIntStateOf(0)
|
||||
private var cardboard by mutableStateOf(Cardboard.OFF)
|
||||
private var headTracker: HeadTracker? = null
|
||||
private var steamVrStatus by mutableStateOf<SteamVr.Status?>(null)
|
||||
@@ -993,6 +997,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
openDeckRing("activity created")
|
||||
bridge.setOnPlayerInput(::onPadInput)
|
||||
onScreenControls = OnScreenControls(this, bridge).also { controls ->
|
||||
controls.alpha = onScreenOpacityAlpha()
|
||||
controls.updateLayout(primaryInputLayout)
|
||||
controls.onTouchMiss = miss@{ event ->
|
||||
if (!gestureTouchStreamGate.accepts(GestureTouchStreamGate.Source.ON_SCREEN_CONTROLS, event)) return@miss
|
||||
@@ -1637,8 +1642,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
effects = effects,
|
||||
screenEffectsTarget = screenEffectsTarget,
|
||||
screenEffectsTargets = screenEffectsTargetOptions(),
|
||||
screenEffectsCanDelete = screenEffectsProfileIdForTarget(screenEffectsTarget)?.let {
|
||||
SessionPrefs.hasScreenEffectsOverride(this@SessionActivity, it)
|
||||
screenEffectsCanDelete = screenEffectsProfileRevision.let {
|
||||
screenEffectsProfileIdForTarget(screenEffectsTarget)?.let {
|
||||
SessionPrefs.hasScreenEffectsOverride(this@SessionActivity, it) ||
|
||||
SessionPrefs.hasScreenEffectsUpscalerOverride(this@SessionActivity, it)
|
||||
}
|
||||
} == true,
|
||||
cardboard = cardboard,
|
||||
cardboardSensor = hasRotationSensor,
|
||||
@@ -1716,6 +1724,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
SessionState.gameZoom = gameZoom
|
||||
runCatching { WaylandCompositor.nativeSetZoom(gameZoom) }
|
||||
},
|
||||
picturePosition = picturePosition,
|
||||
onPicturePosition = { position ->
|
||||
SessionPrefs.setPicturePosition(this@SessionActivity, picturePortrait(), position)
|
||||
picturePosition = position
|
||||
},
|
||||
integerScaling = integerScaling,
|
||||
onIntegerScaling = { enabled ->
|
||||
SessionPrefs.setIntegerScaling(this@SessionActivity, enabled)
|
||||
@@ -1739,6 +1752,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
} else {
|
||||
val profileId = screenEffectsProfileIdForTarget(target)
|
||||
SessionPrefs.setScreenEffectsUpscaler(this@SessionActivity, profileId, m)
|
||||
screenEffectsProfileRevision++
|
||||
|
||||
if (target == screenEffectsTarget) {
|
||||
upscaler = m
|
||||
@@ -1774,6 +1788,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
} else {
|
||||
val profileId = screenEffectsProfileIdForTarget(target)
|
||||
SessionPrefs.setScreenEffectsUpscaler(this@SessionActivity, profileId, m)
|
||||
screenEffectsProfileRevision++
|
||||
if (target == screenEffectsTarget) {
|
||||
upscaler = m
|
||||
if (screenEffectsUpscalerTargetAppliesToLiveOutput(target)) {
|
||||
@@ -1820,7 +1835,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val profileId = screenEffectsProfileIdForTarget(editorTarget)
|
||||
SessionPrefs.setScreenEffects(this@SessionActivity, profileId, e)
|
||||
effects = e
|
||||
if (screenEffectsTargetAppliesToLiveOutput(editorTarget)) e.push(upscaler)
|
||||
if (screenEffectsTargetAppliesToLiveOutput(editorTarget)) {
|
||||
val upscalerAppliesToLiveOutput =
|
||||
screenEffectsUpscalerTargetAppliesToLiveOutput(editorTarget)
|
||||
val liveUpscaler = if (upscalerAppliesToLiveOutput) {
|
||||
SessionPrefs.screenEffectsUpscaler(
|
||||
this@SessionActivity,
|
||||
screenEffectsProfileIdForTarget(editorTarget)
|
||||
)
|
||||
} else {
|
||||
SessionPrefs.screenEffectsUpscaler(
|
||||
this@SessionActivity,
|
||||
currentScreenEffectsProfileId()
|
||||
)
|
||||
}
|
||||
e.push(liveUpscaler)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1907,6 +1937,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onWowChat = wowChat::choose,
|
||||
controller = controllerSettings,
|
||||
onControllerSize = { percent -> updateControllerPrefs { ControllerPrefs.setSize(this@SessionActivity, percent) } },
|
||||
onControllerOpacity = { percent ->
|
||||
ControllerPrefs.setOnScreenOpacity(this@SessionActivity, percent)
|
||||
controllerSettings = ControllerPrefs.read(this@SessionActivity)
|
||||
applyOnScreenOpacity()
|
||||
},
|
||||
onRumble = { on -> updateControllerPrefs { ControllerPrefs.setRumble(this@SessionActivity, on) } },
|
||||
onSteamMenu = if (SessionState.mode == SessionService.MODE_STEAM) ({ sendSteamGuide() }) else null,
|
||||
onQam = if (SessionState.mode == SessionService.MODE_STEAM) ({ triggerSteamQam() }) else null,
|
||||
@@ -2265,6 +2300,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (fieldKeyboardOnPrimary) hidePrimaryKeyboard()
|
||||
}
|
||||
|
||||
private fun onScreenOpacityAlpha() = ControllerPrefs.onScreenOpacity(this) / 100f
|
||||
|
||||
private fun applyOnScreenOpacity() {
|
||||
val alpha = onScreenOpacityAlpha()
|
||||
onScreenControls?.alpha = alpha
|
||||
bottomInputControls?.alpha = alpha
|
||||
unfoldedColumn?.alpha = alpha
|
||||
swappedInputSurface?.alpha = alpha
|
||||
secondScreenPresentation?.controlsView?.alpha = alpha
|
||||
steamTouchControls?.let { it.alpha = if (it.isEditing) 1f else alpha }
|
||||
}
|
||||
|
||||
private fun updateControllerPrefs(change: () -> Unit) {
|
||||
change()
|
||||
controllerSettings = ControllerPrefs.read(this)
|
||||
@@ -2622,10 +2669,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val targetUpscaler = SessionPrefs.screenEffectsUpscaler(this, profileId)
|
||||
effects = targetEffects
|
||||
upscaler = targetUpscaler
|
||||
val upscalerAppliesToLiveOutput = screenEffectsUpscalerTargetAppliesToLiveOutput(target)
|
||||
val liveUpscaler = if (upscalerAppliesToLiveOutput) {
|
||||
targetUpscaler
|
||||
} else {
|
||||
SessionPrefs.screenEffectsUpscaler(this, currentScreenEffectsProfileId())
|
||||
}
|
||||
if (upscalerAppliesToLiveOutput) {
|
||||
WaylandCompositor.nativeSetUpscaler(liveUpscaler)
|
||||
}
|
||||
if (screenEffectsTargetAppliesToLiveOutput(target)) {
|
||||
WaylandCompositor.nativeSetUpscaler(targetUpscaler)
|
||||
WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(targetEffects, targetUpscaler)?.name)
|
||||
targetEffects.push(targetUpscaler)
|
||||
WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(targetEffects, liveUpscaler)?.name)
|
||||
targetEffects.push(liveUpscaler)
|
||||
} else if (upscalerAppliesToLiveOutput) {
|
||||
val liveEffects = SessionPrefs.screenEffects(this, currentScreenEffectsProfileId())
|
||||
WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(liveEffects, liveUpscaler)?.name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2638,6 +2696,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private fun resetScreenEffectsTarget(target: String) {
|
||||
if (target != screenEffectsTarget) return
|
||||
SessionPrefs.resetScreenEffectsProfile(this, screenEffectsProfileIdForTarget(target))
|
||||
screenEffectsProfileRevision++
|
||||
syncScreenEffectsTarget(target)
|
||||
}
|
||||
|
||||
@@ -2645,6 +2704,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (target != screenEffectsTarget) return
|
||||
val profileId = screenEffectsProfileIdForTarget(target) ?: return
|
||||
SessionPrefs.deleteScreenEffectsProfile(this, profileId)
|
||||
screenEffectsProfileRevision++
|
||||
syncScreenEffectsTarget(target)
|
||||
}
|
||||
|
||||
@@ -2775,7 +2835,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
||||
unfoldedControls = SessionPrefs.unfoldedControls(this)
|
||||
unfoldedControlsWithController = SessionPrefs.unfoldedControlsWithController(this)
|
||||
picturePosition = SessionPrefs.picturePosition(this)
|
||||
picturePosition = SessionPrefs.picturePosition(this, picturePortrait())
|
||||
integerScaling = SessionPrefs.integerScaling(this)
|
||||
avoidNotch = SessionPrefs.avoidNotch(this)
|
||||
applyNotchInset()
|
||||
@@ -3212,6 +3272,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
override fun onConfigurationChanged(newConfig: android.content.res.Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
picturePosition = SessionPrefs.picturePosition(this, picturePortrait(newConfig))
|
||||
if (refreshActivityDisplayId() && started) {
|
||||
SessionService.setActivityDisplay(this, sessionActivityDisplayId)
|
||||
}
|
||||
@@ -5135,6 +5196,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (panel == null) {
|
||||
panel = OnScreenControls(this, padBridge, dock).also { it.updateLayout(primaryInputLayout) }
|
||||
val column = android.widget.LinearLayout(this).apply {
|
||||
alpha = onScreenOpacityAlpha()
|
||||
orientation = android.widget.LinearLayout.VERTICAL
|
||||
addView(panel, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f))
|
||||
unfoldedKeys = com.droiddeck.launcher.ui.padKeysView(
|
||||
@@ -5980,7 +6042,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val view = com.droiddeck.launcher.input.SteamTouchControls(this, device,
|
||||
onMenu = { drawerOpen = true }, onKeyboard = ::togglePcKeyboard)
|
||||
view.visibility = View.GONE
|
||||
view.onEditingChanged = { touchEditorChanged() }
|
||||
view.alpha = onScreenOpacityAlpha()
|
||||
view.onEditingChanged = { editing ->
|
||||
view.alpha = if (editing) 1f else onScreenOpacityAlpha()
|
||||
touchEditorChanged()
|
||||
}
|
||||
view.onOptions = { options ->
|
||||
steamTouchOptions = options
|
||||
applyTouchRouting()
|
||||
@@ -6085,6 +6151,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (bottom?.parent !== bottomRoot) {
|
||||
(bottom?.parent as? android.view.ViewGroup)?.removeView(bottom)
|
||||
bottom = OnScreenControls(bottomRoot.context, padBridge).also { view ->
|
||||
view.alpha = onScreenOpacityAlpha()
|
||||
view.onTouchMiss = { event -> onBottomGameTouch(event) }
|
||||
bottomRoot.addView(view, android.view.ViewGroup.LayoutParams(-1, -1))
|
||||
}
|
||||
@@ -6315,7 +6382,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun holdComposedOutput(hold: Boolean) {
|
||||
val wasHeld = composedHolds > 0
|
||||
composedHolds = (composedHolds + if (hold) 1 else -1).coerceAtLeast(0)
|
||||
val held = composedHolds > 0
|
||||
if (held == wasHeld) return
|
||||
WaylandCompositor.nativeSetMirrorCapture(held)
|
||||
// Importable HDR is redirected by the compositor hold. Keep its layer-only fallback available.
|
||||
if (zeroCopyActive()) WaylandCompositor.nativeSetZeroCopy(composedOutputFree())
|
||||
}
|
||||
|
||||
@@ -6462,7 +6534,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
displayManager.unregisterDisplayListener(displayListener)
|
||||
com.droiddeck.launcher.input.DualScreen.unwatchTaken(bottomScreenListener)
|
||||
contentResolver.unregisterContentObserver(refreshSettingObserver)
|
||||
if (!screenIsOff()) closeSecondScreen(reset = false)
|
||||
// Closing the presentation removes the docked Agent page and unregisters its picker.
|
||||
if (com.droiddeck.launcher.session.SessionVisibilityPolicy.shouldCloseSecondScreenOnStop(
|
||||
screenOff = screenIsOff(),
|
||||
dockedDrawerOpen = menuShownOnBottom(),
|
||||
attachmentPickerOpen = com.droiddeck.launcher.agent.AgentAttachments.picking,
|
||||
)
|
||||
) closeSecondScreen(reset = false)
|
||||
sessionTextInput.stop()
|
||||
startedScreens = (startedScreens - 1).coerceAtLeast(0)
|
||||
updateGlassesScreen()
|
||||
@@ -6499,6 +6577,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
com.droiddeck.launcher.agent.AgentAttachments.picking = false
|
||||
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) }
|
||||
@@ -6528,6 +6607,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
joyConVr?.refresh()
|
||||
onScreenControls?.reload()
|
||||
controllerSettings = ControllerPrefs.read(this)
|
||||
applyOnScreenOpacity()
|
||||
resumed = true
|
||||
boostGpuClock(panelOverGame)
|
||||
updateKeyboardRoute()
|
||||
@@ -6611,7 +6691,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
heldButtons.clear()
|
||||
if (!screenOff) {
|
||||
val menuUp = menuShownOnBottom()
|
||||
drawerOpen = false
|
||||
if (!com.droiddeck.launcher.agent.AgentAttachments.picking) drawerOpen = false
|
||||
if (menuUp) SessionState.bottomMenu = true
|
||||
pcKeyboardOpen = false
|
||||
achievementsOpen = false
|
||||
@@ -7036,7 +7116,10 @@ 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()).also {
|
||||
it.alpha = onScreenOpacityAlpha()
|
||||
swappedInputSurface = it
|
||||
} },
|
||||
modifier = Modifier.fillMaxWidth().weight(1f),
|
||||
onRelease = { if (swappedInputSurface === it) swappedInputSurface = null },
|
||||
)
|
||||
|
||||
@@ -19,6 +19,15 @@ object AgentAttachments {
|
||||
/** Guest paths waiting to go with the next message. */
|
||||
val pending = mutableStateListOf<String>()
|
||||
|
||||
/** True while the file picker is open over a session: it answers the drawer's agent page, so the drawer must stay. */
|
||||
@Volatile var picking = false
|
||||
|
||||
/** Launches a system screen that answers the agent page, keeping the drawer for it; the result callback clears [picking]. */
|
||||
fun pick(launch: () -> Unit) {
|
||||
picking = true
|
||||
if (runCatching(launch).isFailure) picking = false
|
||||
}
|
||||
|
||||
private const val NEW = "new"
|
||||
private const val GUEST_DIR = "/root/.cache/droiddeck/attachments"
|
||||
private val IMAGE = setOf("png", "jpg", "jpeg", "webp", "gif", "bmp")
|
||||
@@ -35,14 +44,17 @@ object AgentAttachments {
|
||||
val folder = chat ?: NEW
|
||||
val dir = File(hostDir(app), folder).apply { mkdirs() }
|
||||
return uris.mapNotNull { uri ->
|
||||
var target: File? = null
|
||||
runCatching {
|
||||
val name = displayName(app, uri).replace(Regex("[^A-Za-z0-9._-]"), "_").ifEmpty { "file" }
|
||||
var target = File(dir, name)
|
||||
var candidate = File(dir, name)
|
||||
var n = 1
|
||||
while (target.exists()) target = File(dir, "${name.substringBeforeLast('.')}-${n++}${name.substringAfterLast('.', "").let { if (it.isEmpty()) "" else ".$it" }}")
|
||||
app.contentResolver.openInputStream(uri)!!.use { input -> target.outputStream().use { input.copyTo(it) } }
|
||||
"$GUEST_DIR/$folder/${target.name}"
|
||||
}.getOrNull()
|
||||
// Created atomically, so copies running side by side never pick the same name.
|
||||
while (!candidate.createNewFile()) candidate = File(dir, "${name.substringBeforeLast('.')}-${n++}${name.substringAfterLast('.', "").let { if (it.isEmpty()) "" else ".$it" }}")
|
||||
target = candidate
|
||||
app.contentResolver.openInputStream(uri)!!.use { input -> candidate.outputStream().use { input.copyTo(it) } }
|
||||
"$GUEST_DIR/$folder/${candidate.name}"
|
||||
}.onFailure { target?.delete() }.getOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,13 @@ object FrameGen {
|
||||
const val ENGINE_DDFG = "ddfg"
|
||||
private const val LEGACY_ENGINE_WINFG = "winfg"
|
||||
const val ENGINE_LSFG = "lsfg"
|
||||
const val ENGINE_ZEROFG = "zerofg"
|
||||
|
||||
private const val DDFG_PERF_PRESET = 2
|
||||
private const val DDFG_MODEL = 4
|
||||
private const val FLOW_SCALE_DDFG = 0.60f
|
||||
private const val FLOW_SCALE_LSFG = 0.80f
|
||||
private const val FLOW_SCALE_ZEROFG = 1.0f
|
||||
|
||||
val ADAPTIVE_TARGETS = listOf(120, 90, 60)
|
||||
|
||||
@@ -69,6 +71,14 @@ object FrameGen {
|
||||
.putString("engine", mode.engine).putInt("multiplier", mode.multiplier).putInt("target", mode.target).apply()
|
||||
}
|
||||
|
||||
fun pacerEnabled(context: Context): Boolean =
|
||||
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getBoolean("pacer", false)
|
||||
|
||||
fun setPacer(context: Context, enabled: Boolean) {
|
||||
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean("pacer", enabled).apply()
|
||||
WaylandCompositor.nativeSetFrameGenPacer(enabled)
|
||||
}
|
||||
|
||||
fun clearGlobal(context: Context) {
|
||||
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit()
|
||||
.remove("engine").remove("multiplier").remove("target").apply()
|
||||
@@ -80,6 +90,7 @@ object FrameGen {
|
||||
mode.engine == ENGINE_DDFG -> context.getString(R.string.frame_gen_ddfg, mode.multiplier)
|
||||
mode.engine == ENGINE_LSFG && mode.target > 0 -> context.getString(R.string.frame_gen_lsfg_adaptive, mode.target)
|
||||
mode.engine == ENGINE_LSFG -> context.getString(R.string.frame_gen_lsfg, mode.multiplier)
|
||||
mode.engine == ENGINE_ZEROFG -> context.getString(R.string.frame_gen_zerofg, mode.multiplier)
|
||||
else -> context.getString(R.string.frame_gen_off)
|
||||
}
|
||||
|
||||
@@ -104,6 +115,7 @@ object FrameGen {
|
||||
|
||||
fun applyPrepared(context: Context, prepared: PreparedApply, refreshHz: Float): String? {
|
||||
val mode = prepared.mode
|
||||
WaylandCompositor.nativeSetFrameGenPacer(pacerEnabled(context))
|
||||
when (mode.engine) {
|
||||
ENGINE_LSFG -> {
|
||||
val status = prepared.lsfgStatus ?: LsfgNative.STATUS_NOT_INSTALLED
|
||||
@@ -127,6 +139,11 @@ object FrameGen {
|
||||
WaylandCompositor.nativeSetFrameGenTuning(FLOW_SCALE_DDFG, refreshHz)
|
||||
WaylandCompositor.nativeSetFrameGenArmed(true, mode.multiplier, 0)
|
||||
}
|
||||
ENGINE_ZEROFG -> {
|
||||
WaylandCompositor.nativeSetFrameGenEngine(WaylandCompositor.FG_ENGINE_ZEROFG)
|
||||
WaylandCompositor.nativeSetFrameGenTuning(FLOW_SCALE_ZEROFG, refreshHz)
|
||||
WaylandCompositor.nativeSetFrameGenArmed(true, mode.multiplier, 0)
|
||||
}
|
||||
else -> WaylandCompositor.nativeSetFrameGenArmed(false, 0, 0)
|
||||
}
|
||||
Log.i(TAG, "frame generation: $mode at ${refreshHz}Hz")
|
||||
|
||||
@@ -11,7 +11,7 @@ internal object DroidDeckHudConfig {
|
||||
"showPerCore" to "1", "showTemp" to "1", "showBatteryTemp" to "1", "showGpuTemp" to "0",
|
||||
"showVram" to "1", "showRAM" to "1", "showSwap" to "1", "showBattery" to "0", "showBatteryTime" to "0", "showPower" to "1",
|
||||
"showFPS" to "1", "showFPSGraph" to "1", "fpsDecimal" to "1",
|
||||
"showLatency" to "1", "showAvg" to "1", "showLow1" to "1", "showLow01" to "1", "showLow001" to "1",
|
||||
"showLatency" to "1", "showAvg" to "1", "showLow1" to "1", "showLow01" to "0", "showLow001" to "0",
|
||||
"showEngine" to "1", "showRenderer" to "1",
|
||||
"showDisplay" to "1", "showHdr" to "1", "showNet" to "1", "showResolution" to "1",
|
||||
"showProton" to "1", "showSession" to "1", "showClock" to "1", "hudOrder" to "",
|
||||
|
||||
@@ -92,8 +92,8 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
private var showBatteryTemp = false
|
||||
private var showGraph = false
|
||||
private var showLow1 = true
|
||||
private var showLow01 = true
|
||||
private var showLow001 = true
|
||||
private var showLow01 = false
|
||||
private var showLow001 = false
|
||||
private var fpsDecimal = true
|
||||
private var showClockTime = true
|
||||
private var showLatency = true
|
||||
@@ -187,6 +187,12 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
private var graphRect: RectF? = null
|
||||
private var contentW = 0f
|
||||
private var contentH = 0f
|
||||
private var viewportW = Float.POSITIVE_INFINITY
|
||||
private var viewportH = Float.POSITIVE_INFINITY
|
||||
|
||||
private val panelFit: Float
|
||||
get() = if (dPanel == null || contentW <= 0f || contentH <= 0f) 1f
|
||||
else minOf(1f, viewportW / contentW, viewportH / contentH)
|
||||
|
||||
private var onMovedListener: BiConsumer<Float, Float>? = null
|
||||
private var onSizeCycledListener: Consumer<String>? = null
|
||||
@@ -993,13 +999,20 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
viewportW = viewportLimit(widthMeasureSpec)
|
||||
viewportH = viewportLimit(heightMeasureSpec)
|
||||
if (stripRect != null) { setMeasuredDimension(contentW.roundToInt(), resolveSize(contentH.roundToInt(), heightMeasureSpec)); return }
|
||||
val fit = panelFit
|
||||
setMeasuredDimension(
|
||||
resolveSize(contentW.roundToInt(), widthMeasureSpec),
|
||||
resolveSize(contentH.roundToInt(), heightMeasureSpec),
|
||||
resolveSize((contentW * fit).roundToInt(), widthMeasureSpec),
|
||||
resolveSize((contentH * fit).roundToInt(), heightMeasureSpec),
|
||||
)
|
||||
}
|
||||
|
||||
private fun viewportLimit(spec: Int): Float =
|
||||
if (MeasureSpec.getMode(spec) == MeasureSpec.UNSPECIFIED) Float.POSITIVE_INFINITY
|
||||
else MeasureSpec.getSize(spec).toFloat()
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
if (contentW <= 0f || contentH <= 0f) { lockController.drawBadge(canvas); return }
|
||||
val blend = if (dock == DroidDeckHudDock.NONE && previewEdge != DroidDeckHudDock.NONE) previewBlend else 0f
|
||||
@@ -1034,8 +1047,10 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
}
|
||||
|
||||
private fun drawContent(canvas: Canvas) {
|
||||
|
||||
dPanel?.let { panel -> panelFrame(panel)?.let { canvas.drawBitmap(it, 0f, 0f, null) } }
|
||||
val fit = panelFit
|
||||
dPanel?.let { panel -> panelFrame(panel, fit)?.let { canvas.drawBitmap(it, 0f, 0f, null) } }
|
||||
val saved = canvas.save()
|
||||
if (fit != 1f) canvas.scale(fit, fit)
|
||||
|
||||
if (tileRects.isNotEmpty()) {
|
||||
tilePaint.color = Color.argb((14 * bgOpacity).roundToInt().coerceIn(8, 40), 255, 255, 255)
|
||||
@@ -1065,6 +1080,7 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
if (stripRect != null && layerType != LAYER_TYPE_SOFTWARE) drawCachedGraph(canvas, it) else drawGraph(canvas, it)
|
||||
}
|
||||
|
||||
canvas.restoreToCount(saved)
|
||||
lockController.drawBadge(canvas)
|
||||
}
|
||||
|
||||
@@ -1177,13 +1193,14 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
return if (dy <= 0f) p.right - stroke else if (dy >= r) cx else cx + sqrt(r * r - dy * dy)
|
||||
}
|
||||
|
||||
private fun panelFrame(panel: RectF): Bitmap? {
|
||||
private fun panelFrame(panel: RectF, fit: Float): Bitmap? {
|
||||
if (width <= 0 || height <= 0) return null
|
||||
val stroke = outlineWidth()
|
||||
val key = "$width,$height,$panel,$dRadius,$dDividerTop,$stroke,$accent,$surfaceRgb,$bgOpacity,${outlineColor()}"
|
||||
val key = "$width,$height,$fit,$panel,$dRadius,$dDividerTop,$stroke,$accent,$surfaceRgb,$bgOpacity,${outlineColor()}"
|
||||
if (key == dFrameKey) dFrame?.let { return it }
|
||||
val bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
||||
val c = Canvas(bmp)
|
||||
c.scale(fit, fit)
|
||||
val corner = sp(6f)
|
||||
val body = dShape(panel.left, panel.top, panel.right, panel.bottom, dRadius, corner)
|
||||
bgPaint.color = panelColor()
|
||||
@@ -1256,8 +1273,8 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
|
||||
internal val isStrip: Boolean get() = stripRect != null
|
||||
|
||||
internal val contentWidth: Float get() = contentW
|
||||
internal val contentHeight: Float get() = contentH
|
||||
internal val contentWidth: Float get() = contentW * panelFit
|
||||
internal val contentHeight: Float get() = contentH * panelFit
|
||||
|
||||
internal val isDragging: Boolean get() = lockController.isDragging() || tabDragging
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ object ControllerPrefs {
|
||||
)
|
||||
|
||||
val opacities = listOf(40, 60, 80, 100)
|
||||
val onScreenOpacityRange = 10..100
|
||||
|
||||
val sizes = listOf(80, 85, 90, 95, 100, 105, 110, 115, 120, 125)
|
||||
|
||||
@@ -45,6 +46,7 @@ object ControllerPrefs {
|
||||
val size: Int,
|
||||
val stickClick: Boolean,
|
||||
val adaptiveSticks: Boolean,
|
||||
val onScreenOpacity: Int,
|
||||
val rumble: Boolean,
|
||||
val steamButton: Boolean,
|
||||
val qamButton: Boolean,
|
||||
@@ -66,7 +68,8 @@ object ControllerPrefs {
|
||||
opacity = p.getInt("opacity", 100).takeIf { it in opacities } ?: 100,
|
||||
size = p.getInt("size", 100).takeIf { it in sizes } ?: 100,
|
||||
stickClick = p.getBoolean("stickClick", true),
|
||||
adaptiveSticks = p.getBoolean("adaptiveSticks", true),
|
||||
adaptiveSticks = p.getBoolean("adaptiveSticks", false),
|
||||
onScreenOpacity = onScreenOpacity(context),
|
||||
rumble = rumbleEnabled(context),
|
||||
steamButton = p.getBoolean("steamButton", true),
|
||||
qamButton = p.getBoolean("qamButton", true),
|
||||
@@ -103,6 +106,13 @@ object ControllerPrefs {
|
||||
prefs(context).edit().putBoolean("stickClick", on).apply()
|
||||
}
|
||||
|
||||
fun onScreenOpacity(context: Context): Int =
|
||||
prefs(context).getInt("onScreenOpacity", 100).coerceIn(onScreenOpacityRange)
|
||||
|
||||
fun setOnScreenOpacity(context: Context, percent: Int) {
|
||||
prefs(context).edit().putInt("onScreenOpacity", percent.coerceIn(onScreenOpacityRange)).apply()
|
||||
}
|
||||
|
||||
fun setAdaptiveSticks(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("adaptiveSticks", on).apply()
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ object ComponentsManager {
|
||||
private const val DD_COMPONENTS = "Droid-Deck/DroidDeck-Components"
|
||||
internal const val DD_NIGHTLY = "linux-nightly"
|
||||
internal const val DD_BIONIC = "bionic-stable"
|
||||
/** FEX for original Xbox games on DroidDeck-Bionic: kept apart from [DD_BIONIC] so automatic FEX updates never pick it. */
|
||||
internal const val DD_XBOX = "bionic-xbox"
|
||||
private val RELEASES = linkedMapOf(
|
||||
"FexCore-Linux" to "fex",
|
||||
"Dxvk-Linux" to "dxvk",
|
||||
@@ -38,7 +40,8 @@ object ComponentsManager {
|
||||
"Vkd3d-proton-Linux" to "vkd3d",
|
||||
)
|
||||
private val NIGHTLY_PREFIXES = linkedMapOf("DD-dxvk-" to "dxvk", "DD-vkd3d-proton-" to "vkd3d", "DD-FEXCore-" to "fex")
|
||||
private val SOURCES = RELEASES.keys.map { NIGHTLIES to it } + (DD_COMPONENTS to DD_NIGHTLY) + (DD_COMPONENTS to DD_BIONIC)
|
||||
private val SOURCES = RELEASES.keys.map { NIGHTLIES to it } + (DD_COMPONENTS to DD_NIGHTLY) + (DD_COMPONENTS to DD_BIONIC) +
|
||||
(DD_COMPONENTS to DD_XBOX)
|
||||
private val DOWNLOAD_REPOS = listOf(NIGHTLIES, DD_COMPONENTS)
|
||||
private val TYPES = mapOf("FEXCore-Linux" to "fex", "FEXCore-Bionic" to "fex", "DXVK-Linux" to "dxvk", "VKD3D-Linux" to "vkd3d")
|
||||
private val TYPE_OF = mapOf("fex" to "FEXCore-Linux", "dxvk" to "DXVK-Linux", "vkd3d" to "VKD3D-Linux")
|
||||
@@ -253,6 +256,28 @@ object ComponentsManager {
|
||||
saveState(context, state)
|
||||
}
|
||||
|
||||
internal enum class Assigned { SET, NOT_LISTED, CHANGED }
|
||||
|
||||
/**
|
||||
* Sets a game's component to a listed package, fetching it first when it is not stored. [expected] is the component
|
||||
* the caller read when it decided: if the game's component is something else once the package is ready (the player
|
||||
* chose one during the download), nothing is written. [onSet] runs under the same lock as the write.
|
||||
*/
|
||||
internal fun assignGameComponent(context: Context, scope: String, comp: String, file: String, release: String,
|
||||
expected: String?, onSet: () -> Unit = {}): Assigned {
|
||||
val wcp = File(packagesDir(context), safeName(file))
|
||||
if (!wcp.isFile || runCatching { packageInfo(context, wcp) }.isFailure) {
|
||||
wcp.delete()
|
||||
download(context, catalogItem(context, file, release) ?: return Assigned.NOT_LISTED) {}
|
||||
}
|
||||
synchronized(lock) {
|
||||
if (gameComponents(context, scope)[comp] != expected) return Assigned.CHANGED
|
||||
setGameComponent(context, scope, comp, file) { runtimeManaged(context, it) }
|
||||
onSet()
|
||||
}
|
||||
return Assigned.SET
|
||||
}
|
||||
|
||||
fun clearGameComponents(context: Context, scope: String) = synchronized(lock) {
|
||||
require(GameEnvironment.validScope(scope))
|
||||
val state = loadState(context)
|
||||
@@ -1124,7 +1149,7 @@ object ComponentsManager {
|
||||
|
||||
internal fun assetComp(release: String, name: String): String? = RELEASES[release] ?: when (release) {
|
||||
DD_NIGHTLY -> NIGHTLY_PREFIXES.entries.firstOrNull { name.startsWith(it.key) }?.value
|
||||
DD_BIONIC -> "fex"
|
||||
DD_BIONIC, DD_XBOX -> "fex"
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.util.Log
|
||||
import java.io.File
|
||||
|
||||
internal object PageCacheTrim {
|
||||
private const val TAG = "PageCacheTrim"
|
||||
private const val MIN_FILE_BYTES = 8L shl 20
|
||||
private const val POLL_MS = 3000L
|
||||
private const val RESCAN_MS = 120_000L
|
||||
|
||||
data class Mem(val freeKb: Long, val fileKb: Long)
|
||||
|
||||
fun parse(meminfo: String): Mem? {
|
||||
fun field(name: String) = Regex("""(?m)^$name:\s+(\d+) kB""").find(meminfo)?.groupValues?.get(1)?.toLongOrNull()
|
||||
val free = field("MemFree") ?: return null
|
||||
val file = (field("Active\\(file\\)") ?: return null) + (field("Inactive\\(file\\)") ?: return null)
|
||||
return Mem(free, file)
|
||||
}
|
||||
|
||||
fun shouldTrim(mem: Mem, baselineFileKb: Long): Boolean {
|
||||
val built = mem.fileKb - baselineFileKb
|
||||
return (mem.freeKb < 2560 * 1024 && built >= 768 * 1024) ||
|
||||
(mem.freeKb < 1024 * 1024 && built >= 128 * 1024)
|
||||
}
|
||||
|
||||
fun start(roots: () -> List<File>, alive: () -> Boolean) {
|
||||
Thread({
|
||||
var baseline = 0L
|
||||
var files = emptyList<File>()
|
||||
var scanned = 0L
|
||||
var trims = 0
|
||||
var failureLogged = false
|
||||
while (alive()) {
|
||||
runCatching {
|
||||
val mem = parse(File("/proc/meminfo").readText())
|
||||
if (mem != null && shouldTrim(mem, baseline)) {
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - scanned > RESCAN_MS) {
|
||||
files = roots().flatMap { root -> root.walkTopDown().onEnter { !java.nio.file.Files.isSymbolicLink(it.toPath()) }.filter { it.isFile && it.length() >= MIN_FILE_BYTES }.toList() }
|
||||
scanned = now
|
||||
}
|
||||
val began = System.nanoTime()
|
||||
files.forEach(::drop)
|
||||
val after = parse(File("/proc/meminfo").readText())
|
||||
baseline = after?.fileKb ?: mem.fileKb
|
||||
trims++
|
||||
Log.i(TAG, "trim #$trims: free ${mem.freeKb / 1024} -> ${after?.freeKb?.div(1024)} MB, file cache ${mem.fileKb / 1024} -> ${after?.fileKb?.div(1024)} MB, ${files.size} files, ${(System.nanoTime() - began) / 1_000_000} ms")
|
||||
}
|
||||
}.onFailure {
|
||||
if (!failureLogged) Log.w(TAG, "trim failed: $it")
|
||||
failureLogged = true
|
||||
}
|
||||
Thread.sleep(POLL_MS)
|
||||
}
|
||||
}, "page-cache-trim").apply { isDaemon = true }.start()
|
||||
}
|
||||
|
||||
private fun drop(file: File) {
|
||||
PageCacheNative.fadviseDontNeed(file.path)
|
||||
}
|
||||
}
|
||||
|
||||
internal object PageCacheNative {
|
||||
init {
|
||||
System.loadLibrary("sdnative")
|
||||
}
|
||||
|
||||
@JvmStatic external fun fadviseDontNeed(path: String): Int
|
||||
}
|
||||
@@ -66,11 +66,14 @@ object ProtonExtras {
|
||||
|
||||
internal fun installedIn(dir: File, tool: Tool): List<String> =
|
||||
dir.listFiles()
|
||||
?.filter { it.isDirectory && it.name.startsWith(tool.prefix) && usable(it) }
|
||||
?.filter { it.isDirectory && it.name.startsWith(tool.prefix) && !x86_64Build(it) && usable(it) }
|
||||
?.map { it.name }
|
||||
?.sortedWith { a, b -> compareVersions(a, b) }
|
||||
?: emptyList()
|
||||
|
||||
internal fun x86_64Build(dir: File): Boolean =
|
||||
File(dir, "files/lib/wine/x86_64-unix").isDirectory && !File(dir, "files/bin-arm64").isDirectory
|
||||
|
||||
private fun usable(dir: File): Boolean {
|
||||
val manifest = runCatching { File(dir, "toolmanifest.vdf").readText() }.getOrNull() ?: return false
|
||||
val command = Regex("\\\"commandline\\\"\\s+\\\"/?([^\\\" ]+)").find(manifest)?.groupValues?.getOrNull(1) ?: return false
|
||||
|
||||
@@ -16,6 +16,7 @@ object SessionDisplay {
|
||||
const val LINK_PORTRAIT = "link/portrait"
|
||||
|
||||
const val DEFAULT_RESOLUTION = "720p"
|
||||
const val DEFAULT_STEAM_PORTRAIT_RESOLUTION = "1280x800"
|
||||
private val PRESET_HEIGHTS = listOf(720, 900, 1080)
|
||||
|
||||
fun presetHeight(choice: String): Int? =
|
||||
|
||||
@@ -364,13 +364,13 @@ object SessionPrefs {
|
||||
prefs(context).edit().putInt("libraryCardLevel", level).apply()
|
||||
}
|
||||
|
||||
fun libraryShowTitle(context: Context): Boolean = prefs(context).getBoolean("libraryShowTitle", true)
|
||||
fun libraryShowTitle(context: Context): Boolean = prefs(context).getBoolean("libraryShowTitle", false)
|
||||
|
||||
fun setLibraryShowTitle(context: Context, show: Boolean) {
|
||||
prefs(context).edit().putBoolean("libraryShowTitle", show).apply()
|
||||
}
|
||||
|
||||
fun libraryShowSize(context: Context): Boolean = prefs(context).getBoolean("libraryShowSize", true)
|
||||
fun libraryShowSize(context: Context): Boolean = prefs(context).getBoolean("libraryShowSize", false)
|
||||
|
||||
fun setLibraryShowSize(context: Context, show: Boolean) {
|
||||
prefs(context).edit().putBoolean("libraryShowSize", show).apply()
|
||||
@@ -946,13 +946,21 @@ object SessionPrefs {
|
||||
}
|
||||
|
||||
|
||||
fun picturePosition(context: Context): String =
|
||||
prefs(context).getString("picturePosition", "center")
|
||||
?.takeIf { it in listOf("top", "bottom", "left", "right", "center") } ?: "center"
|
||||
private val picturePositions = setOf("center", "top", "bottom", "left", "right")
|
||||
|
||||
fun setPicturePosition(context: Context, position: String) {
|
||||
prefs(context).edit().putString("picturePosition",
|
||||
position.takeIf { it in listOf("top", "bottom", "left", "right", "center") } ?: "center").apply()
|
||||
private fun picturePositionKey(portrait: Boolean) =
|
||||
if (portrait) "picturePosition.portrait" else "picturePosition.landscape"
|
||||
|
||||
fun picturePosition(context: Context, portrait: Boolean): String {
|
||||
val preferences = prefs(context)
|
||||
return preferences.getString(picturePositionKey(portrait), null)?.takeIf { it in picturePositions }
|
||||
?: preferences.getString("picturePosition", null)?.takeIf { it in picturePositions }
|
||||
?: if (portrait) "top" else "center"
|
||||
}
|
||||
|
||||
fun setPicturePosition(context: Context, portrait: Boolean, position: String) {
|
||||
require(position in picturePositions)
|
||||
prefs(context).edit().putString(picturePositionKey(portrait), position).apply()
|
||||
}
|
||||
|
||||
fun integerScaling(context: Context): Boolean =
|
||||
@@ -964,6 +972,9 @@ object SessionPrefs {
|
||||
|
||||
fun returnAfterGame(context: Context): Boolean = prefs(context).getBoolean("returnAfterGame", true)
|
||||
|
||||
/** A sleeping session writes its memory to storage instead of zram. */
|
||||
fun diskSpill(context: Context): Boolean = prefs(context).getBoolean("diskSpill", false)
|
||||
|
||||
fun valveProtonOnDemand(context: Context): Boolean = prefs(context).getBoolean("valveProtonOnDemand", true)
|
||||
|
||||
fun setValveProtonOnDemand(context: Context, on: Boolean) {
|
||||
@@ -1513,10 +1524,12 @@ object SessionPrefs {
|
||||
|
||||
fun resolutionStored(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean): String {
|
||||
if (!portrait) return landscapeResolutionStored(context, mode, panel)
|
||||
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE
|
||||
val fallback = if (mode == SessionService.MODE_STEAM) SessionDisplay.DEFAULT_STEAM_PORTRAIT_RESOLUTION
|
||||
else SessionDisplay.LINK_LANDSCAPE
|
||||
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return fallback
|
||||
if (value == SessionDisplay.LINK_LANDSCAPE || value == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(value) ||
|
||||
SessionDisplay.presetHeight(value) != null) return value
|
||||
return parseOrientedResolution(value)?.let { "${it.first}x${it.second}" } ?: SessionDisplay.LINK_LANDSCAPE
|
||||
return parseOrientedResolution(value)?.let { "${it.first}x${it.second}" } ?: fallback
|
||||
}
|
||||
|
||||
fun parseOrientedResolution(text: String): Pair<Int, Int>? =
|
||||
@@ -1778,6 +1791,9 @@ object SessionPrefs {
|
||||
name.removeSuffix(from) + to to moved
|
||||
}
|
||||
|
||||
fun storedAddedGameAppId(context: Context, folderPath: String): Long? =
|
||||
prefs(context).getLong("addedAppId:$folderPath", 0L).takeIf { it != 0L }
|
||||
|
||||
fun addedGameAppId(context: Context, folderPath: String, first: Long): Long = synchronized(addedGameLock) {
|
||||
val p = prefs(context)
|
||||
p.getLong("addedAppId:$folderPath", 0L).takeIf { it != 0L }
|
||||
@@ -1998,24 +2014,84 @@ object SessionPrefs {
|
||||
sessionPrefs.edit().putString(SCREEN_EFFECTS_PROFILES_KEY, profiles.toString()).apply()
|
||||
}
|
||||
|
||||
private const val GAME_UPSCALER_OVERRIDES_KEY = "upscaler.gameOverrides"
|
||||
|
||||
private fun gameUpscalerOverrides(context: Context): JSONObject = runCatching {
|
||||
JSONObject(prefs(context).getString(GAME_UPSCALER_OVERRIDES_KEY, null) ?: "{}")
|
||||
}.getOrDefault(JSONObject())
|
||||
|
||||
private fun legacyScreenEffectsUpscaler(context: Context, profileId: String): Int? =
|
||||
runCatching {
|
||||
val profiles = JSONObject(prefs(context).getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
||||
val profile = profiles.optJSONObject(profileId)
|
||||
if (profile?.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY) == true) {
|
||||
profile.optInt(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY, -1).takeIf { it >= 0 }
|
||||
} else null
|
||||
}.getOrNull()?.let(::canonicalUpscaler)
|
||||
|
||||
private fun clearLegacyScreenEffectsUpscaler(context: Context, profileId: String) {
|
||||
val sessionPrefs = prefs(context)
|
||||
val profiles = runCatching {
|
||||
JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
||||
}.getOrNull() ?: return
|
||||
val profile = profiles.optJSONObject(profileId) ?: return
|
||||
if (!profile.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY)) return
|
||||
profile.remove(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY)
|
||||
if (profile.length() == 0) profiles.remove(profileId)
|
||||
sessionPrefs.edit().apply {
|
||||
if (profiles.length() == 0) remove(SCREEN_EFFECTS_PROFILES_KEY)
|
||||
else putString(SCREEN_EFFECTS_PROFILES_KEY, profiles.toString())
|
||||
}.apply()
|
||||
}
|
||||
|
||||
fun hasGameUpscalerOverride(context: Context, gameId: String): Boolean {
|
||||
if (gameId.isBlank()) return false
|
||||
val stored = gameUpscalerOverrides(context)
|
||||
return (stored.has(gameId) && stored.optInt(gameId, -1) >= 0) ||
|
||||
legacyScreenEffectsUpscaler(context, "game:$gameId") != null
|
||||
}
|
||||
|
||||
fun setGameUpscaler(context: Context, gameId: String, mode: Int) {
|
||||
if (gameId.isBlank()) return
|
||||
val overrides = gameUpscalerOverrides(context)
|
||||
overrides.put(gameId, canonicalUpscaler(mode))
|
||||
prefs(context).edit().putString(GAME_UPSCALER_OVERRIDES_KEY, overrides.toString()).apply()
|
||||
clearLegacyScreenEffectsUpscaler(context, "game:$gameId")
|
||||
}
|
||||
|
||||
fun clearGameUpscaler(context: Context, gameId: String) {
|
||||
if (gameId.isBlank()) return
|
||||
val sessionPrefs = prefs(context)
|
||||
val overrides = gameUpscalerOverrides(context)
|
||||
if (overrides.has(gameId)) {
|
||||
overrides.remove(gameId)
|
||||
sessionPrefs.edit().apply {
|
||||
if (overrides.length() == 0) remove(GAME_UPSCALER_OVERRIDES_KEY)
|
||||
else putString(GAME_UPSCALER_OVERRIDES_KEY, overrides.toString())
|
||||
}.apply()
|
||||
}
|
||||
clearLegacyScreenEffectsUpscaler(context, "game:$gameId")
|
||||
}
|
||||
|
||||
fun hasScreenEffectsUpscalerOverride(context: Context, profileId: String?): Boolean {
|
||||
if (profileId.isNullOrBlank()) return false
|
||||
return runCatching {
|
||||
val profiles = JSONObject(prefs(context).getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
||||
profiles.optJSONObject(profileId)?.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY) == true
|
||||
}.getOrDefault(false)
|
||||
if (profileId.startsWith("game:")) {
|
||||
return hasGameUpscalerOverride(context, profileId.removePrefix("game:"))
|
||||
}
|
||||
return legacyScreenEffectsUpscaler(context, profileId) != null
|
||||
}
|
||||
|
||||
fun screenEffectsUpscaler(context: Context, profileId: String?): Int {
|
||||
if (profileId.isNullOrBlank()) return upscaler(context)
|
||||
val stored = runCatching {
|
||||
val profiles = JSONObject(prefs(context).getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
||||
val profile = profiles.optJSONObject(profileId)
|
||||
if (profile?.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY) == true) {
|
||||
profile.optInt(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY, -1)
|
||||
} else -1
|
||||
}.getOrDefault(-1)
|
||||
return if (stored >= 0) canonicalUpscaler(stored) else upscaler(context)
|
||||
if (profileId.startsWith("game:")) {
|
||||
val gameId = profileId.removePrefix("game:")
|
||||
val overrides = gameUpscalerOverrides(context)
|
||||
if (overrides.has(gameId)) {
|
||||
val stored = overrides.optInt(gameId, -1)
|
||||
if (stored >= 0) return canonicalUpscaler(stored)
|
||||
}
|
||||
}
|
||||
return legacyScreenEffectsUpscaler(context, profileId) ?: upscaler(context)
|
||||
}
|
||||
|
||||
fun setScreenEffectsUpscaler(context: Context, profileId: String?, mode: Int) {
|
||||
@@ -2023,6 +2099,10 @@ object SessionPrefs {
|
||||
setUpscaler(context, mode)
|
||||
return
|
||||
}
|
||||
if (profileId.startsWith("game:")) {
|
||||
setGameUpscaler(context, profileId.removePrefix("game:"), mode)
|
||||
return
|
||||
}
|
||||
val sessionPrefs = prefs(context)
|
||||
val profiles = runCatching {
|
||||
JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
||||
@@ -2059,6 +2139,7 @@ object SessionPrefs {
|
||||
val profiles = runCatching {
|
||||
JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
||||
}.getOrElse { JSONObject() }
|
||||
if (profileId.startsWith("game:")) clearGameUpscaler(context, profileId.removePrefix("game:"))
|
||||
if (!profiles.has(profileId)) return
|
||||
profiles.remove(profileId)
|
||||
sessionPrefs.edit().apply {
|
||||
|
||||
@@ -111,6 +111,8 @@ class SessionService : Service() {
|
||||
private var suspendOperationPending = false
|
||||
private var pipTask = false
|
||||
private var suspendAttemptFailed = false
|
||||
private val resumeRecovery = SuspendRecovery()
|
||||
private val retryResume = Runnable { updateSuspendPolicy() }
|
||||
private var freezePending = false
|
||||
private var freezeCancelled = false
|
||||
private var pendingSteamGameId: String? = null
|
||||
@@ -276,7 +278,7 @@ class SessionService : Service() {
|
||||
}
|
||||
ACTION_XR_ACTIVITY_VISIBLE -> {
|
||||
xrActivityVisible = true
|
||||
resumeSession(panelVisible = false)
|
||||
resumeSession(panelVisible = false, restartRecovery = false)
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
ACTION_XR_ACTIVITY_HIDDEN -> {
|
||||
@@ -380,6 +382,8 @@ class SessionService : Service() {
|
||||
suspendOperationPending = false
|
||||
freezePending = false
|
||||
suspendAttemptFailed = false
|
||||
resumeRecovery.reset()
|
||||
mainHandler.removeCallbacks(retryResume)
|
||||
suspendController = null
|
||||
SessionState.micAvailable = false
|
||||
SessionState.micEnabled = false
|
||||
@@ -428,6 +432,11 @@ class SessionService : Service() {
|
||||
++sessionGen
|
||||
}
|
||||
}
|
||||
val trimGen = gen
|
||||
PageCacheTrim.start(
|
||||
roots = { listOfNotNull(File(filesDir, "linuxfs"), GameStorage.effective(applicationContext)?.let { File(it.path) }).filter(File::isDirectory) },
|
||||
alive = { SessionState.running && sessionGen == trimGen },
|
||||
)
|
||||
if (SessionState.stopRequested) {
|
||||
stopSession(0)
|
||||
return START_NOT_STICKY
|
||||
@@ -617,6 +626,9 @@ class SessionService : Service() {
|
||||
val size = SessionState.outputSize
|
||||
val guest = ArrayList<String>()
|
||||
val steamHere = SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP
|
||||
runCatching { SessionEvents.step("components-xbox") { XboxBackCompatComponents.ensure(this) } }
|
||||
.onSuccess { if (it != null) Log.i(TAG, it) }
|
||||
.onFailure { Log.w(TAG, "original Xbox components", it) }
|
||||
runCatching { SessionEvents.step("components-republish") { ComponentsManager.republish(this) } }
|
||||
.onSuccess { if (it) Log.i(TAG, "component selections published for the installed Proton builds") }
|
||||
.onFailure { Log.w(TAG, "component selections", it) }
|
||||
@@ -937,11 +949,15 @@ class SessionService : Service() {
|
||||
return
|
||||
}
|
||||
if (gen == sessionGen && SessionState.running) {
|
||||
val workers = ownWorkers
|
||||
suspendController = SessionSuspendController(
|
||||
sessionRoot = { sessionPid },
|
||||
// Programs handed off to worker processes are not descendants of the session root, and
|
||||
// the clock shift applied at resume would move their monotonic time backwards.
|
||||
helperRoots = {
|
||||
components.mapNotNull { it.suspendPid().takeIf { pid -> pid > 1 } } +
|
||||
listOfNotNull(BottomDesktop.suspendPid.takeIf { it > 1 })
|
||||
listOfNotNull(BottomDesktop.suspendPid.takeIf { it > 1 }) +
|
||||
(if (workers > 0) com.droiddeck.launcher.runtime.GuestWorkers.guestPids(workers) else emptyList())
|
||||
},
|
||||
suspendAudio = {
|
||||
if (!pulse.setSinkSuspended(true)) Log.w(TAG, "could not suspend audio sink")
|
||||
@@ -965,7 +981,7 @@ class SessionService : Service() {
|
||||
SessionEvents.record("session.paged_out", mapOf(
|
||||
"processes" to processes, "unacknowledged" to unacknowledged, "residentMb" to residentKb / 1024,
|
||||
"swapMb" to swapKb / 1024, "swapBeforeMb" to swapBeforeKb / 1024, "ms" to millis,
|
||||
))
|
||||
), sessionDir)
|
||||
}
|
||||
},
|
||||
pagedIn = { processes, swapKb, swapBeforeKb, availableKb, millis ->
|
||||
@@ -978,7 +994,27 @@ class SessionService : Service() {
|
||||
SessionEvents.record("session.paged_in", mapOf(
|
||||
"processes" to processes, "swapMb" to swapKb / 1024, "swapBeforeMb" to swapBeforeKb / 1024,
|
||||
"availableMb" to availableKb / 1024, "ms" to millis,
|
||||
))
|
||||
), sessionDir)
|
||||
}
|
||||
},
|
||||
spilled = { processes, spilledKb, residentKb, millis ->
|
||||
Log.i(TAG, "wrote $processes processes to storage in $millis ms: ${spilledKb / 1024} MB, " +
|
||||
"resident ${residentKb / 1024} MB")
|
||||
mainHandler.post {
|
||||
SessionEvents.record("session.spilled", mapOf(
|
||||
"processes" to processes, "spilledMb" to spilledKb / 1024, "residentMb" to residentKb / 1024,
|
||||
"ms" to millis,
|
||||
), sessionDir)
|
||||
}
|
||||
},
|
||||
restored = { processes, unacknowledged, residentKb, millis ->
|
||||
Log.i(TAG, "restored $processes processes ($unacknowledged unacknowledged) from storage in $millis ms: " +
|
||||
"resident ${residentKb / 1024} MB")
|
||||
mainHandler.post {
|
||||
SessionEvents.record("session.restored", mapOf(
|
||||
"processes" to processes, "unacknowledged" to unacknowledged,
|
||||
"residentMb" to residentKb / 1024, "ms" to millis,
|
||||
), sessionDir)
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -1749,7 +1785,7 @@ class SessionService : Service() {
|
||||
return
|
||||
}
|
||||
if (SessionState.suspended) {
|
||||
resumeSession()
|
||||
resumeSession(restartRecovery = false)
|
||||
mainHandler.postDelayed(flushSteamGame, GAME_LAUNCH_RETRY_MS)
|
||||
return
|
||||
}
|
||||
@@ -1918,8 +1954,10 @@ class SessionService : Service() {
|
||||
private fun steamGameRunning(gameId: String): Boolean =
|
||||
SteamGameProcess.running(gameId)
|
||||
|
||||
private fun resumeSession(panelVisible: Boolean = true) {
|
||||
if (SessionState.suspended) SessionState.resumeRequested = true
|
||||
private fun resumeSession(panelVisible: Boolean = true, restartRecovery: Boolean = true) {
|
||||
if (SessionState.suspended && (restartRecovery || resumeRecovery.due(SystemClock.elapsedRealtime()))) {
|
||||
SessionState.resumeRequested = true
|
||||
}
|
||||
if (panelVisible) activityVisible = true
|
||||
screenOn = readScreenOn()
|
||||
manualPauseRequested = false
|
||||
@@ -1930,6 +1968,7 @@ class SessionService : Service() {
|
||||
completeNativeSleep()
|
||||
completeSteamSleep()
|
||||
suspendAttemptFailed = false
|
||||
if (restartRecovery) resumeRecovery.reset()
|
||||
updateSuspendPolicy()
|
||||
}
|
||||
|
||||
@@ -2148,7 +2187,12 @@ class SessionService : Service() {
|
||||
controller.cancelFreeze()
|
||||
}
|
||||
if (shouldSuspend && SessionState.suspended && !suspendOperationPending) SessionState.resumeRequested = false
|
||||
if (suspendOperationPending || suspendAttemptFailed || shouldSuspend == SessionState.suspended) return
|
||||
// A session still held after a failed suspend or resume is released by paced resumes, whatever clears or
|
||||
// sets the latch; only an explicit resume (resumeSession) restarts the pacing.
|
||||
val held = SessionState.suspended && SessionState.resumeFailed && !shouldSuspend
|
||||
if (!suspendOperationPending && resumeRecovery.holds(held, SystemClock.elapsedRealtime())) return
|
||||
val recovering = suspendAttemptFailed && held
|
||||
if (suspendOperationPending || (suspendAttemptFailed && !recovering) || shouldSuspend == SessionState.suspended) return
|
||||
val gen = sessionGen
|
||||
suspendOperationPending = true
|
||||
SessionEvents.record(if (shouldSuspend) "session.suspend_requested" else "session.resume_requested", mapOf(
|
||||
@@ -2163,9 +2207,9 @@ class SessionService : Service() {
|
||||
freezeCancelled = false
|
||||
val freezeSteamToken = steamSleepToken
|
||||
val freezeNativeToken = nativeSleepToken
|
||||
controller.freeze(
|
||||
pageOut = steamSleepToken != null || nativeSleepToken != null || !activityVisible || !screenOn,
|
||||
) { success ->
|
||||
val pageOut = steamSleepToken != null || nativeSleepToken != null || !activityVisible || !screenOn
|
||||
controller.freeze(pageOut = pageOut, spill = pageOut && SessionPrefs.diskSpill(this)) { success ->
|
||||
val rollbackPending = !success && controller.rollbackPending
|
||||
mainHandler.post {
|
||||
if (gen != sessionGen || !SessionState.running) return@post
|
||||
SessionState.suspending = false
|
||||
@@ -2174,6 +2218,7 @@ class SessionService : Service() {
|
||||
if (success) {
|
||||
SessionState.suspended = true
|
||||
SessionState.resumeFailed = false
|
||||
resumeRecovery.reset()
|
||||
SessionEvents.transition(SessionPhase.SUSPENDED, "session.suspended")
|
||||
releaseLocks()
|
||||
refreshNotification()
|
||||
@@ -2188,6 +2233,12 @@ class SessionService : Service() {
|
||||
SessionState.manualPause = false
|
||||
Log.w(TAG, "could not confirm that the session stopped")
|
||||
}
|
||||
// Some processes are still held: only a resume can release them.
|
||||
if (rollbackPending) {
|
||||
SessionState.suspended = true
|
||||
SessionState.resumeFailed = true
|
||||
Log.w(TAG, "could not return the session to running after the suspend failed")
|
||||
}
|
||||
}
|
||||
updateSuspendPolicy()
|
||||
}
|
||||
@@ -2196,6 +2247,8 @@ class SessionService : Service() {
|
||||
acquireLocks()
|
||||
SessionState.resuming = true
|
||||
controller.resume { success ->
|
||||
// A loss with another spill still reading back is retried for that one; the loss is kept.
|
||||
val lost = !success && controller.guestLost && !controller.restoreOutstanding
|
||||
mainHandler.post {
|
||||
if (gen != sessionGen || !SessionState.running) return@post
|
||||
suspendOperationPending = false
|
||||
@@ -2204,13 +2257,28 @@ class SessionService : Service() {
|
||||
if (success) {
|
||||
SessionState.suspended = false
|
||||
SessionState.resumeFailed = false
|
||||
suspendAttemptFailed = false
|
||||
resumeRecovery.reset()
|
||||
mainHandler.removeCallbacks(retryResume)
|
||||
SessionEvents.transition(SessionEvents.resumePhase(), "session.resumed")
|
||||
refreshNotification()
|
||||
} else if (lost) {
|
||||
// Everything was continued, but a game ended without its memory back: no retry restores
|
||||
// it, and the failure stays reported.
|
||||
SessionState.suspended = false
|
||||
SessionState.resumeFailures++
|
||||
SessionState.resumeFailed = true
|
||||
resumeRecovery.reset()
|
||||
mainHandler.removeCallbacks(retryResume)
|
||||
SessionEvents.transition(SessionEvents.resumePhase(), "session.resume_lost_guest")
|
||||
Log.w(TAG, "a game ended before its memory was read back from storage")
|
||||
refreshNotification()
|
||||
} else {
|
||||
suspendAttemptFailed = true
|
||||
SessionState.resumeFailures++
|
||||
SessionState.resumeFailed = true
|
||||
Log.w(TAG, "could not confirm that the session resumed")
|
||||
resumeRecovery.failed(SystemClock.elapsedRealtime())?.let { mainHandler.postDelayed(retryResume, it) }
|
||||
}
|
||||
updateSuspendPolicy()
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ internal class SessionSuspendController(
|
||||
{ _, _, _, _, _, _ -> },
|
||||
private val pagedIn: (processes: Int, swapKb: Long, swapBeforeKb: Long, availableKb: Long, millis: Long) -> Unit =
|
||||
{ _, _, _, _, _ -> },
|
||||
private val spilled: (processes: Int, spilledKb: Long, residentKb: Long, millis: Long) -> Unit = { _, _, _, _ -> },
|
||||
private val restored: (processes: Int, unacknowledged: Int, residentKb: Long, millis: Long) -> Unit = { _, _, _, _ -> },
|
||||
) {
|
||||
private enum class Role { SESSION_ROOT, SESSION_CHILD, HELPER_ROOT, HELPER_CHILD }
|
||||
|
||||
@@ -53,10 +55,34 @@ internal class SessionSuspendController(
|
||||
private var frozen = emptyList<ProcessRecord>()
|
||||
private var frozenSince: Long? = null
|
||||
private var pagedOutTargets = emptyList<ProcessRecord>()
|
||||
private var spilledTargets = emptyList<ProcessRecord>()
|
||||
// Asked to spill and not yet released by a resume count they saw: acknowledged or not, each may park its process.
|
||||
private var spillAsked = emptyList<ProcessRecord>()
|
||||
private var counterUnpublished = false
|
||||
// Spilled targets whose positive answer was taken (and its acknowledgement removed).
|
||||
private var spillWritten = emptyList<ProcessRecord>()
|
||||
// Taken into the restore wait by this resume: alive then, so one that ends without its memory back is lost.
|
||||
private var adopted = emptyList<ProcessRecord>()
|
||||
// Released by this attempt on a late answer of 0 or a cancellation: not lost if they end afterwards.
|
||||
private var answeredLate = emptyList<ProcessRecord>()
|
||||
|
||||
fun freeze(pageOut: Boolean = false, completion: (Boolean) -> Unit) {
|
||||
// A spilled process ended without its memory back since the last suspend began: retrying cannot bring it
|
||||
// back, so no later resume of this suspension reports success.
|
||||
@Volatile var guestLost = false
|
||||
private set
|
||||
|
||||
// Spilled processes still reading back, which a later resume waits for again.
|
||||
@Volatile var restoreOutstanding = false
|
||||
private set
|
||||
|
||||
// A failed freeze that could not return every process to running: only a resume releases them.
|
||||
@Volatile var rollbackPending = false
|
||||
private set
|
||||
|
||||
fun freeze(pageOut: Boolean = false, spill: Boolean = false, completion: (Boolean) -> Unit) {
|
||||
cancelled = false
|
||||
submit({
|
||||
guestLost = false
|
||||
val records = frozen.associateByTo(LinkedHashMap()) { it.pid to it.started }
|
||||
var complete = false
|
||||
var interrupted = false
|
||||
@@ -74,7 +100,7 @@ internal class SessionSuspendController(
|
||||
records[it.pid to it.started] = ProcessRecord(it.pid, it.started, Role.HELPER_ROOT)
|
||||
}
|
||||
}
|
||||
if (pageOut) pageOut(records, root.pid, helpers)
|
||||
if (pageOut) pageOut(records, root.pid, helpers, spill)
|
||||
val deadline = nowMillis() + FREEZE_TIMEOUT_MS
|
||||
var previous: Map<TaskIdentity, Long>? = null
|
||||
for (pass in 0 until FREEZE_MAX_PASSES) {
|
||||
@@ -105,9 +131,14 @@ internal class SessionSuspendController(
|
||||
frozen = records.values.toList()
|
||||
if (complete && frozenSince == null) frozenSince = nowNanos()
|
||||
if (!complete) {
|
||||
if (restoreSafely(frozen)) frozen = emptyList()
|
||||
// A spilled process is back only once its helper has read it back: until then a resume retries.
|
||||
adopted = emptyList()
|
||||
answeredLate = emptyList()
|
||||
val running = startedAlive()
|
||||
if (restoreSafely(frozen) && awaitRestored(running)) frozen = emptyList()
|
||||
runAudio(resumeAudio)
|
||||
}
|
||||
rollbackPending = !complete && frozen.isNotEmpty()
|
||||
if (interrupted) Thread.currentThread().interrupt()
|
||||
}
|
||||
completion(complete)
|
||||
@@ -122,12 +153,23 @@ internal class SessionSuspendController(
|
||||
fun resume(completion: (Boolean) -> Unit) {
|
||||
submit({
|
||||
val records = frozen
|
||||
advanceClock()
|
||||
val advancedTo = advanceClock()
|
||||
adopted = emptyList()
|
||||
answeredLate = emptyList()
|
||||
val running = startedAlive()
|
||||
runAudio(resumeAudio)
|
||||
val resumed = restoreSafely(records)
|
||||
if (resumed) frozen = emptyList()
|
||||
completion(resumed)
|
||||
if (resumed) readBack()
|
||||
if (resumed) {
|
||||
frozen = emptyList()
|
||||
rollbackPending = false
|
||||
}
|
||||
// nothing was continued: the guest clock owes the time from here to the next attempt
|
||||
if (!resumed && counterUnpublished && advancedTo != null) frozenSince = advancedTo
|
||||
// a spilled process runs again only once its helper has read its memory back
|
||||
val restoredAll = resumed && awaitRestored(running)
|
||||
restoreOutstanding = frozen.isNotEmpty() || spilledTargets.isNotEmpty()
|
||||
completion(restoredAll && !guestLost)
|
||||
if (resumed) readBack(waitForRestore = false)
|
||||
}, { completion(false) })
|
||||
}
|
||||
|
||||
@@ -135,7 +177,10 @@ internal class SessionSuspendController(
|
||||
closing = true
|
||||
submit({
|
||||
advanceClock()
|
||||
val running = startedAlive()
|
||||
if (restoreSafely(frozen)) frozen = emptyList()
|
||||
// the teardown asks the guests to exit, which a process still reading back cannot answer
|
||||
if (frozen.isEmpty()) awaitRestored(running, whileClosing = true)
|
||||
completion()
|
||||
executor.shutdown()
|
||||
}, completion)
|
||||
@@ -149,22 +194,25 @@ internal class SessionSuspendController(
|
||||
}
|
||||
}
|
||||
|
||||
private fun advanceClock() {
|
||||
val since = frozenSince ?: return
|
||||
// Returns the moment the guest clock now accounts for, or null when no frozen interval was open.
|
||||
private fun advanceClock(): Long? {
|
||||
val since = frozenSince ?: return null
|
||||
frozenSince = null
|
||||
val control = clockControl?.takeIf { it.isFile && it.length() >= Long.SIZE_BYTES } ?: return
|
||||
val now = nowNanos()
|
||||
val control = clockControl?.takeIf { it.isFile && it.length() >= Long.SIZE_BYTES } ?: return now
|
||||
try {
|
||||
mapClockControl(control)
|
||||
RandomAccessFile(control, "rw").use { file ->
|
||||
val bytes = ByteArray(Long.SIZE_BYTES)
|
||||
file.readFully(bytes)
|
||||
val shift = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).long.coerceAtLeast(0L) +
|
||||
(nowNanos() - since).coerceAtLeast(0L)
|
||||
(now - since).coerceAtLeast(0L)
|
||||
file.seek(0L)
|
||||
file.write(ByteBuffer.allocate(Long.SIZE_BYTES).order(ByteOrder.LITTLE_ENDIAN).putLong(shift).array())
|
||||
}
|
||||
} catch (_: IOException) {
|
||||
}
|
||||
return now
|
||||
}
|
||||
|
||||
private fun runAudio(action: () -> Unit) {
|
||||
@@ -275,13 +323,15 @@ internal class SessionSuspendController(
|
||||
return tasks.takeIf { stopped && it.isNotEmpty() }
|
||||
}
|
||||
|
||||
private fun pageOut(records: MutableMap<Pair<Int, Long>, ProcessRecord>, root: Int, helpers: List<Int>) {
|
||||
private fun pageOut(records: MutableMap<Pair<Int, Long>, ProcessRecord>, root: Int, helpers: List<Int>, spill: Boolean) {
|
||||
val control = zramControl?.takeIf { it.isFile } ?: return
|
||||
val hold = holdFile(control)
|
||||
try {
|
||||
hold.writeText(PAGE_OUT_REQUEST)
|
||||
// A spill names the resume count it was asked under: any later count releases the helper, however
|
||||
// late it starts reading.
|
||||
hold.writeText(if (spill) "$SPILL_REQUEST ${resumeCount(control)}" else PAGE_OUT_REQUEST)
|
||||
sleep(PAGE_OUT_POLL_MS)
|
||||
pageOut(control, records, root, helpers)
|
||||
if (spill) spill(control, records, root, helpers) else pageOut(control, records, root, helpers)
|
||||
} catch (_: IOException) {
|
||||
} finally {
|
||||
hold.delete()
|
||||
@@ -290,15 +340,208 @@ internal class SessionSuspendController(
|
||||
|
||||
private fun holdFile(control: File) = File(control.parentFile, "${control.name}.hold")
|
||||
|
||||
private fun pageOut(control: File, records: MutableMap<Pair<Int, Long>, ProcessRecord>, root: Int, helpers: List<Int>) {
|
||||
private fun ackFile(control: File, kind: String, record: ProcessRecord) =
|
||||
File(control.parentFile, "${control.name}.$kind.${record.pid}")
|
||||
|
||||
private fun preloaded(records: Collection<ProcessRecord>) = records.filter { record ->
|
||||
try {
|
||||
File(procRoot, "${record.pid}/maps").useLines { lines -> lines.any { it.endsWith("/libddsession.so") } }
|
||||
} catch (_: IOException) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun readAck(ack: File): Long? = try {
|
||||
ack.readText().trim().toLongOrNull()
|
||||
} catch (_: IOException) {
|
||||
null
|
||||
}
|
||||
|
||||
// Each process parks its threads, writes its private memory to an unlinked file and stays parked until
|
||||
// the resume counter changes; its acknowledgement is the kB it wrote, 0 when it paged out to zram instead.
|
||||
private fun spill(control: File, records: MutableMap<Pair<Int, Long>, ProcessRecord>, root: Int, helpers: List<Int>) {
|
||||
addSnapshot(records, root, helpers)
|
||||
val targets = records.values.filter { record ->
|
||||
try {
|
||||
File(procRoot, "${record.pid}/maps").useLines { lines -> lines.any { it.endsWith("/libddsession.so") } }
|
||||
// A restore that finished after the last resume stopped waiting is counted before its marker goes; one
|
||||
// still reading is not asked to spill again.
|
||||
val (done, still) = spilledTargets.partition { settled(control, it) }
|
||||
release(control, done)
|
||||
spilledTargets = still
|
||||
val targets = preloaded(records.values).filterNot { it in spilledTargets }
|
||||
if (targets.isEmpty()) return
|
||||
targets.forEach { ackFile(control, "ack", it).delete(); ackFile(control, "restored", it).delete() }
|
||||
val start = nowMillis()
|
||||
spillAsked = (spillAsked + targets).distinct()
|
||||
for (record in targets) send(record, SIGURG)
|
||||
val waiting = targets.toMutableList()
|
||||
while (!closing && !cancelled && nowMillis() - start < SPILL_TIMEOUT_MS) {
|
||||
val started = nowMillis() - start >= PAGE_OUT_START_MS
|
||||
waiting.removeAll { val ack = ackFile(control, "ack", it); readAck(ack) != null || (started && !ack.exists()) || isGone(it) }
|
||||
if (waiting.isEmpty()) break
|
||||
sleep(PAGE_OUT_POLL_MS)
|
||||
}
|
||||
var total = 0L
|
||||
val acks = targets.associateWith { readAck(ackFile(control, "ack", it)) }
|
||||
val written = targets.filter { record ->
|
||||
val kb = acks[record]?.coerceAtLeast(0L) ?: 0L
|
||||
total += kb
|
||||
kb > 0L
|
||||
}
|
||||
// A process that answered 0 paged out to zram instead and has no spill to release. One whose handler
|
||||
// started (its acknowledgement is there, still empty) may still be writing: it is waited for like a
|
||||
// spilled one, its acknowledgement kept. One with no acknowledgement may have no handler, or one that has
|
||||
// not got that far: it is not waited for, but stays asked, so a resume count that cannot be written still
|
||||
// fails (a late spill waits for any count other than the one it was asked with).
|
||||
val unanswered = targets.filter { acks[it] == null && ackFile(control, "ack", it).exists() && !isGone(it) }
|
||||
spillAsked = spillAsked.filterNot { acks[it] == 0L || acks[it] == SPILL_CANCELLED }
|
||||
spilledTargets = (spilledTargets + written + unanswered).distinct()
|
||||
spillWritten = (spillWritten + written).distinct()
|
||||
pagedOutTargets = (pagedOutTargets + targets.filter { acks[it] == 0L }).distinct()
|
||||
targets.filterNot { it in unanswered }.forEach { ackFile(control, "ack", it).delete() }
|
||||
spilled(written.size, total, memoryKb(targets).first, nowMillis() - start)
|
||||
}
|
||||
|
||||
// Its memory is back, it paged out to zram after all (an answer of 0 that came late), a resume cancelled
|
||||
// it before it wrote anything, or it is gone.
|
||||
private fun settled(control: File, record: ProcessRecord): Boolean {
|
||||
val ack = readAck(ackFile(control, "ack", record))
|
||||
return readAck(ackFile(control, "restored", record)) != null || ack == 0L || ack == SPILL_CANCELLED ||
|
||||
ended(record)
|
||||
}
|
||||
|
||||
// Gone, or every thread has exited and only an unreaped zombie is left.
|
||||
private fun ended(record: ProcessRecord): Boolean {
|
||||
if (isGone(record)) return true
|
||||
val tasks = File(procRoot, "${record.pid}/task").listFiles()?.filter { it.name.toIntOrNull() != null } ?: return false
|
||||
return tasks.all { entry ->
|
||||
try { readStat(File(entry, "stat"))[0].first().let { it == 'Z' || it == 'X' } } catch (_: IOException) { false }
|
||||
}
|
||||
}
|
||||
|
||||
// Settled targets stop being tracked; one that fell back to zram late is read back like any paged-out one.
|
||||
private fun release(control: File, settledTargets: List<ProcessRecord>) {
|
||||
val lateZram = settledTargets.filter { readAck(ackFile(control, "ack", it)) == 0L && !isGone(it) }
|
||||
pagedOutTargets = (pagedOutTargets + lateZram).distinct()
|
||||
spillAsked = spillAsked.filterNot { it in settledTargets }
|
||||
spillWritten = spillWritten.filterNot { it in settledTargets }
|
||||
settledTargets.forEach {
|
||||
ackFile(control, "restored", it).delete()
|
||||
ackFile(control, "ack", it).delete()
|
||||
}
|
||||
}
|
||||
|
||||
private fun resumeFile(control: File) = File(control.parentFile, "${control.name}.resume")
|
||||
|
||||
private fun resumeCount(control: File): Long = try {
|
||||
resumeFile(control).takeIf { it.isFile }?.readText()?.trim()?.toLongOrNull() ?: 0L
|
||||
} catch (_: IOException) {
|
||||
0L
|
||||
}
|
||||
|
||||
// False when a process asked to spill may not have seen the new count: it would stay stopped. The count is
|
||||
// put in place whole, so a failed write leaves the one before.
|
||||
private fun bumpResume(): Boolean {
|
||||
val control = zramControl?.takeIf { it.isFile } ?: return spillAsked.isEmpty()
|
||||
// A late answer of 0 or a cancellation already let its process go: it needs no count.
|
||||
val answered = spillAsked.filter {
|
||||
val ack = readAck(ackFile(control, "ack", it))
|
||||
ack == 0L || ack == SPILL_CANCELLED
|
||||
}
|
||||
if (answered.isNotEmpty()) {
|
||||
answeredLate = (answeredLate + answered).distinct()
|
||||
spilledTargets = spilledTargets.filterNot { it in answered }
|
||||
release(control, answered)
|
||||
}
|
||||
val counter = resumeFile(control)
|
||||
val ok = try {
|
||||
val next = resumeCount(control) + 1
|
||||
val fresh = File(counter.parentFile, "${counter.name}.new")
|
||||
fresh.writeText(next.toString())
|
||||
java.nio.file.Files.move(fresh.toPath(), counter.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING,
|
||||
java.nio.file.StandardCopyOption.ATOMIC_MOVE)
|
||||
resumeCount(control) == next
|
||||
} catch (_: IOException) {
|
||||
false
|
||||
}
|
||||
if (ok) spillAsked = emptyList()
|
||||
return ok || spillAsked.isEmpty()
|
||||
}
|
||||
|
||||
// True when every spilled process has its memory back (or was gone already). Ones still reading stay
|
||||
// tracked, so a later resume waits for them again. One of [running] that ends without its memory back fails
|
||||
// this resume.
|
||||
private fun awaitRestored(running: Collection<ProcessRecord> = emptyList(), whileClosing: Boolean = false): Boolean {
|
||||
val control = zramControl ?: return true
|
||||
val targets = spilledTargets
|
||||
val start = nowMillis()
|
||||
val waiting = targets.toMutableList()
|
||||
val untraced = HashMap<ProcessRecord, Long>()
|
||||
val releasedWithoutMarker = HashSet<ProcessRecord>()
|
||||
try {
|
||||
while (targets.isNotEmpty() && (whileClosing || !closing) && nowMillis() - start < RESTORE_TIMEOUT_MS) {
|
||||
waiting.removeAll {
|
||||
settled(control, it) || detached(control, it, untraced).also { done -> if (done) releasedWithoutMarker += it }
|
||||
}
|
||||
if (waiting.isEmpty()) break
|
||||
sleep(PAGE_OUT_POLL_MS)
|
||||
}
|
||||
} catch (_: InterruptedException) {
|
||||
Thread.currentThread().interrupt()
|
||||
}
|
||||
val lost = (running + adopted).distinct().filterNot { it in answeredLate || it in releasedWithoutMarker }.filter { record ->
|
||||
val ack = readAck(ackFile(control, "ack", record))
|
||||
ended(record) && readAck(ackFile(control, "restored", record)) == null && ack != 0L && ack != SPILL_CANCELLED
|
||||
}
|
||||
adopted = emptyList()
|
||||
answeredLate = emptyList()
|
||||
if (lost.isNotEmpty()) guestLost = true
|
||||
if (targets.isNotEmpty()) {
|
||||
release(control, targets.filterNot { it in waiting })
|
||||
spilledTargets = waiting.toList()
|
||||
restored(targets.size, waiting.size, memoryKb(targets).first, nowMillis() - start)
|
||||
}
|
||||
return waiting.isEmpty() && lost.isEmpty()
|
||||
}
|
||||
|
||||
// A process that wrote its spill is traced by its helper until the read-back ends; one that stays untraced
|
||||
// and alive for a while has its memory back even if the helper could not write its marker (a helper that
|
||||
// dies first has its owner killed).
|
||||
private fun detached(control: File, record: ProcessRecord, untraced: MutableMap<ProcessRecord, Long>): Boolean {
|
||||
if (record !in spillWritten && (readAck(ackFile(control, "ack", record)) ?: 0L) <= 0L) return false
|
||||
// The helper detaches thread by thread, so every live thread must be out of its trace.
|
||||
val current = try { readProcess(record.pid) } catch (_: IOException) { null }
|
||||
if (current == null || current.started != record.started || ended(record) || anyThreadTraced(record)) {
|
||||
untraced.remove(record)
|
||||
return false
|
||||
}
|
||||
return nowMillis() - untraced.getOrPut(record) { nowMillis() } >= MARKER_GRACE_MS
|
||||
}
|
||||
|
||||
private fun anyThreadTraced(record: ProcessRecord): Boolean {
|
||||
val tasks = File(procRoot, "${record.pid}/task").listFiles() ?: return true
|
||||
return tasks.any { entry ->
|
||||
entry.name.toIntOrNull() != null && try {
|
||||
File(entry, "status").useLines { lines ->
|
||||
lines.firstOrNull { it.startsWith("TracerPid:") }?.substringAfter(':')?.trim()?.toIntOrNull() != 0
|
||||
}
|
||||
} catch (_: IOException) {
|
||||
false
|
||||
File(entry, "stat").exists()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Asked, started or written spills of processes alive now: one that ends without its memory back (or a 0 or
|
||||
// cancelled answer) is lost.
|
||||
private fun startedAlive(): List<ProcessRecord> {
|
||||
val control = zramControl ?: return emptyList()
|
||||
return (spilledTargets + spillAsked).distinct().filter {
|
||||
val ack = readAck(ackFile(control, "ack", it))
|
||||
ack != 0L && ack != SPILL_CANCELLED && !ended(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun pageOut(control: File, records: MutableMap<Pair<Int, Long>, ProcessRecord>, root: Int, helpers: List<Int>) {
|
||||
addSnapshot(records, root, helpers)
|
||||
val targets = preloaded(records.values)
|
||||
if (targets.isEmpty()) return
|
||||
pagedOutTargets = (pagedOutTargets + targets).distinct()
|
||||
val acks = targets.associateWith { File(control.parentFile, "${control.name}.ack.${it.pid}") }
|
||||
@@ -325,7 +568,8 @@ internal class SessionSuspendController(
|
||||
false
|
||||
}
|
||||
|
||||
private fun readBack() {
|
||||
private fun readBack(waitForRestore: Boolean = true) {
|
||||
if (waitForRestore) awaitRestored()
|
||||
val targets = pagedOutTargets.filterNot { isGone(it) }
|
||||
pagedOutTargets = emptyList()
|
||||
val control = zramControl?.takeIf { it.isFile } ?: return
|
||||
@@ -411,10 +655,12 @@ internal class SessionSuspendController(
|
||||
private fun stopThreads(record: ProcessRecord) {
|
||||
val current = try { readProcess(record.pid) } catch (_: Exception) { return }
|
||||
if (current == null || current.started != record.started) return
|
||||
// A spill helper's tracing stop ends when it detaches after reading back: the pending SIGSTOP holds then.
|
||||
val helperHeld = record in spilledTargets
|
||||
for (entry in File(procRoot, "${record.pid}/task").listFiles().orEmpty()) {
|
||||
val tid = entry.name.toIntOrNull() ?: continue
|
||||
val state = try { readStat(File(entry, "stat"))[0].first() } catch (_: IOException) { continue }
|
||||
if (state == 'T' || state == 't' || state == 'Z' || state == 'X') continue
|
||||
if (state == 'T' || (state == 't' && !helperHeld) || state == 'Z' || state == 'X') continue
|
||||
try {
|
||||
threadSignal(record.pid, tid, SIGSTOP)
|
||||
} catch (_: Throwable) {
|
||||
@@ -431,6 +677,10 @@ internal class SessionSuspendController(
|
||||
Role.HELPER_CHILD -> 3
|
||||
}
|
||||
}
|
||||
val asked = spillAsked
|
||||
counterUnpublished = !bumpResume()
|
||||
if (counterUnpublished) return false
|
||||
adoptStartedSpills(asked)
|
||||
for (record in ordered) send(record, SIGCONT)
|
||||
val waiting = ordered.toMutableList()
|
||||
repeat(RESTORE_CHECKS) { check ->
|
||||
@@ -442,6 +692,15 @@ internal class SessionSuspendController(
|
||||
return false
|
||||
}
|
||||
|
||||
// A handler that started after the spill wait ended parks its process until it has read back, like one
|
||||
// that answered in time.
|
||||
private fun adoptStartedSpills(asked: List<ProcessRecord>) {
|
||||
val control = zramControl ?: return
|
||||
val started = asked.filter { it !in spilledTargets && ackFile(control, "ack", it).exists() && !ended(it) }
|
||||
if (started.isNotEmpty()) spilledTargets = spilledTargets + started
|
||||
adopted = started
|
||||
}
|
||||
|
||||
private fun restoreSafely(records: List<ProcessRecord>): Boolean = try {
|
||||
restore(records)
|
||||
} catch (_: InterruptedException) {
|
||||
@@ -460,10 +719,12 @@ internal class SessionSuspendController(
|
||||
}
|
||||
}
|
||||
|
||||
// A spilled process's threads stay in a tracing stop until its helper has read its memory back.
|
||||
private fun isRunningOrGone(record: ProcessRecord): Boolean {
|
||||
val current = try { readProcess(record.pid) } catch (_: Exception) { return false }
|
||||
if (current == null || current.started != record.started) return true
|
||||
if (current.state == 'T' || current.state == 't') return false
|
||||
val spilled = record in spilledTargets
|
||||
if (current.state == 'T' || (current.state == 't' && !spilled)) return false
|
||||
return File(procRoot, "${record.pid}/task").listFiles().orEmpty().none { entry ->
|
||||
entry.name.toIntOrNull() != null &&
|
||||
try { readStat(File(entry, "stat"))[0].first() == 'T' } catch (_: IOException) { false }
|
||||
@@ -477,6 +738,11 @@ internal class SessionSuspendController(
|
||||
const val PAGE_OUT_ACK = "1"
|
||||
const val PAGE_OUT_REQUEST = "1"
|
||||
const val READ_BACK_REQUEST = "0"
|
||||
const val SPILL_REQUEST = "4"
|
||||
const val SPILL_CANCELLED = -2L
|
||||
const val SPILL_TIMEOUT_MS = 30_000L
|
||||
const val RESTORE_TIMEOUT_MS = 30_000L
|
||||
const val MARKER_GRACE_MS = 1_000L
|
||||
const val PAGE_OUT_POLL_MS = 100L
|
||||
const val PAGE_OUT_START_MS = 2_000L
|
||||
const val PAGE_OUT_TIMEOUT_MS = 12_000L
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
internal object SessionVisibilityPolicy {
|
||||
fun shouldCloseSecondScreenOnStop(
|
||||
screenOff: Boolean,
|
||||
dockedDrawerOpen: Boolean,
|
||||
attachmentPickerOpen: Boolean,
|
||||
): Boolean = !screenOff && !(dockedDrawerOpen && attachmentPickerOpen)
|
||||
|
||||
fun isHidden(
|
||||
activityStarted: Boolean,
|
||||
defaultDisplayOn: Boolean,
|
||||
|
||||
@@ -18,7 +18,7 @@ object SettingsReset {
|
||||
"storesInstallLanguage",
|
||||
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "dockedMenuController", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
|
||||
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
|
||||
"stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "drawerSections", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"stretch16x9", "avoidNotch", "picturePosition", "picturePosition.portrait", "picturePosition.landscape", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "drawerSections", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
|
||||
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "producerAcquireFences", "paceCores",
|
||||
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
// Paced resume retries for a session that is still held after a failed suspend or resume.
|
||||
internal class SuspendRecovery(
|
||||
private val maxAttempts: Int = 5,
|
||||
private val firstDelayMs: Long = 5_000L,
|
||||
) {
|
||||
private var attempts = 0
|
||||
private var nextAt = 0L
|
||||
|
||||
fun due(now: Long): Boolean = attempts < maxAttempts && now >= nextAt
|
||||
|
||||
// Whether a session that is still held must wait instead of starting another resume now.
|
||||
fun holds(held: Boolean, now: Long): Boolean = held && !due(now)
|
||||
|
||||
// The delay before the next attempt is due, or null when no attempt is left.
|
||||
fun failed(now: Long): Long? {
|
||||
attempts++
|
||||
if (attempts >= maxAttempts) return null
|
||||
val delay = firstDelayMs shl (attempts - 1)
|
||||
nextAt = now + delay
|
||||
return delay
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
attempts = 0
|
||||
nextAt = 0L
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.gpu.GpuInfo
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoreGameSidecar
|
||||
import com.droiddeck.launcher.stores.StoreInstallRoot
|
||||
import com.droiddeck.launcher.stores.xbox.XboxManifest
|
||||
|
||||
/**
|
||||
* Microsoft's original Xbox releases for PC run its emulator, which needs FEX and VKD3D-Proton builds with fixes of
|
||||
* their own (each off unless droiddeck-game-env turns it on for these games) and a newer DXVK than some Protons carry.
|
||||
* Each installed one gets them as its game components. A component the player chose for the game is never replaced;
|
||||
* one set here follows this list, so a newer build replaces it, and one the player cleared stays cleared.
|
||||
*/
|
||||
internal object XboxBackCompatComponents {
|
||||
private const val TAG = "XboxBackCompat"
|
||||
private const val PREFS = "xbox-backcompat-components"
|
||||
|
||||
internal data class Wanted(val comp: String, val file: String, val release: String)
|
||||
|
||||
internal fun wanted(family: GpuInfo.Family?): List<Wanted> = listOf(
|
||||
Wanted("fex", "FEXCore-2611.1-xbox-bionic.wcp", ComponentsManager.DD_XBOX),
|
||||
Wanted("vkd3d", "vkd3d-proton-arm64ec-3.1-xbox-linux.wcp", "Vkd3d-proton-Linux"),
|
||||
Wanted("dxvk", if (family == GpuInfo.Family.A6XX) "dxvk-gplasync-3.2-a6xx-1-linux.wcp" else "dxvk-gplasync-3.2-1-linux.wcp",
|
||||
"Dxvk-gplasync-Linux"),
|
||||
)
|
||||
|
||||
/** The file to set for one component of a game, or null to leave it as it is. */
|
||||
internal fun decide(current: String?, assigned: String?, wanted: String): String? = when {
|
||||
current == null && assigned == null -> wanted
|
||||
current != null && current == assigned && current != wanted -> wanted
|
||||
else -> null
|
||||
}
|
||||
|
||||
internal class Game(val scope: String, val title: String)
|
||||
|
||||
internal fun installed(context: Context): List<Game> = StoreInstallRoot.gameFolders(context).mapNotNull { folder ->
|
||||
val sidecar = StoreGameSidecar.read(folder)?.takeIf { it.store == Store.XBOX && it.isInstalled } ?: return@mapNotNull null
|
||||
if (!XboxManifest.backCompat(folder)) return@mapNotNull null
|
||||
val appId = SessionPrefs.storedAddedGameAppId(context, folder.path) ?: return@mapNotNull null
|
||||
Game(appId.toString(), sidecar.title)
|
||||
}
|
||||
|
||||
fun ensure(context: Context): String? {
|
||||
val games = installed(context)
|
||||
if (games.isEmpty()) return null
|
||||
val marks = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
||||
val wanted = wanted(runCatching { GpuInfo.detect().family }.getOrNull())
|
||||
val lines = mutableListOf<String>()
|
||||
for (game in games) {
|
||||
val current = ComponentsManager.gameComponents(context, game.scope)
|
||||
for (w in wanted) {
|
||||
val key = "${game.scope}/${w.comp}"
|
||||
val file = decide(current[w.comp], marks.getString(key, null), w.file) ?: continue
|
||||
val label = ComponentsManager.LABEL[w.comp]
|
||||
runCatching {
|
||||
ComponentsManager.assignGameComponent(context, game.scope, w.comp, file, w.release, expected = current[w.comp]) {
|
||||
marks.edit().putString(key, file).apply()
|
||||
}
|
||||
}
|
||||
.onSuccess { result ->
|
||||
lines += when (result) {
|
||||
ComponentsManager.Assigned.SET -> "${game.title}: $label ${file.removeSuffix(".wcp")}"
|
||||
ComponentsManager.Assigned.NOT_LISTED -> "${game.title}: $file is not listed; $label unchanged"
|
||||
ComponentsManager.Assigned.CHANGED -> "${game.title}: $label was chosen during the download; kept"
|
||||
}
|
||||
}
|
||||
.onFailure { e ->
|
||||
Log.w(TAG, "${game.title}: $file", e)
|
||||
lines += "${game.title}: $label unchanged (${e.message ?: e.javaClass.simpleName})"
|
||||
}
|
||||
}
|
||||
}
|
||||
return lines.joinToString("; ").ifEmpty { null }
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,9 @@ import org.json.JSONObject
|
||||
import java.time.Instant
|
||||
|
||||
internal object XboxCatalog {
|
||||
/** Package identity prefix of Microsoft's original Xbox releases for PC. */
|
||||
internal const val BACK_COMPAT_IDENTITY = "Xbox360BackwardCompatibil"
|
||||
|
||||
private val productId = Regex("[A-Z0-9]{12}")
|
||||
private val plans = setOf("CFQ7TTC0KGQ8", "CFQ7TTC0KHS0", "CFQ7TTC0P85B", "CFQ7TTC0K5DJ", "CFQ7TTC0K6L8", "CFQ7TTC10QFD")
|
||||
private val pcPlans = mapOf(
|
||||
@@ -148,6 +151,13 @@ internal object XboxCatalog {
|
||||
.flatMap { objects(it.optJSONArray("Packages")) }
|
||||
val pc = packages.filter { pkg -> objects(pkg.optJSONArray("PlatformDependencies")).any { it.optString("PlatformName") == "Windows.Desktop" } }
|
||||
val installable = pc.any { installableFormat(it.optString("PackageFormat")) }
|
||||
// An original Xbox game: its PC package is only Microsoft's emulator and an
|
||||
// index; the game data comes from the console package, so that is its size.
|
||||
val backCompat = pc.any { it.optString("PackageFamilyName").startsWith(BACK_COMPAT_IDENTITY, ignoreCase = true) }
|
||||
val console = packages.filter { pkg ->
|
||||
pkg.optString("PackageFormat").equals("XVC", true) ||
|
||||
objects(pkg.optJSONArray("PlatformDependencies")).any { it.optString("PlatformName") == "Windows.Xbox" }
|
||||
}
|
||||
// The installer needs the format, not just the fact that one exists: a
|
||||
// legacy container takes a different subcommand from a streamed package.
|
||||
val format = pc.firstOrNull { installableFormat(it.optString("PackageFormat")) }?.optString("PackageFormat").orEmpty()
|
||||
@@ -172,7 +182,8 @@ internal object XboxCatalog {
|
||||
storeUrl = "https://www.xbox.com/games/store/$id",
|
||||
publisher = localized.optString("PublisherName"), developer = localized.optString("DeveloperName"),
|
||||
description = localized.optString("ProductDescription"),
|
||||
sizeBytes = if (installable) pc.maxOfOrNull { it.optLong("MaxDownloadSizeInBytes") } ?: 0L else 0L,
|
||||
sizeBytes = if (!installable) 0L else (if (backCompat) console.maxOfOrNull { it.optLong("MaxDownloadSizeInBytes") } else null)
|
||||
?.takeIf { it > 0 } ?: pc.maxOfOrNull { it.optLong("MaxDownloadSizeInBytes") } ?: 0L,
|
||||
extra = mapOf("market" to Xodus.market(), "access" to kind.orEmpty(), "pc" to flag(installable),
|
||||
"cloud" to flag(streams), "format" to format),
|
||||
)
|
||||
|
||||
@@ -80,6 +80,10 @@ internal object XboxManifest {
|
||||
dependencies.singleOrNull().orEmpty(), ids, entries, entry.singleOrNull().orEmpty(), behavior.singleOrNull().orEmpty())
|
||||
}
|
||||
|
||||
/** Microsoft's original Xbox releases for PC, which run its emulator. */
|
||||
fun backCompat(folder: File): Boolean =
|
||||
runCatching { read(folder).name.startsWith(XboxCatalog.BACK_COMPAT_IDENTITY, ignoreCase = true) }.getOrDefault(false)
|
||||
|
||||
/**
|
||||
* A full trust package starts its executable directly. Anything else is activated
|
||||
* through the Windows app model, which this runtime has no host for, so starting
|
||||
|
||||
@@ -377,10 +377,11 @@ private fun CodeBox(label: String, text: String, color: Color) {
|
||||
internal fun AttachmentChip(path: String, onRemove: (() -> Unit)?) {
|
||||
val context = LocalContext.current
|
||||
val pal = LocalPalette.current
|
||||
var viewing by remember(path) { mutableStateOf(false) }
|
||||
Box {
|
||||
if (AgentAttachments.isImage(path)) AsyncImage(
|
||||
model = AgentAttachments.host(context, path), contentDescription = path.substringAfterLast('/'), contentScale = ContentScale.Crop,
|
||||
modifier = Modifier.size(72.dp).clip(Shape12).background(pal.surfaceVariant),
|
||||
modifier = Modifier.size(72.dp).clip(Shape12).background(pal.surfaceVariant).clickable { viewing = true },
|
||||
) else Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.heightIn(min = 40.dp).clip(Shape12).background(pal.surfaceVariant).padding(horizontal = 10.dp, vertical = 8.dp),
|
||||
@@ -396,4 +397,5 @@ internal fun AttachmentChip(path: String, onRemove: (() -> Unit)?) {
|
||||
Icon(Icons.Outlined.Close, stringResource(R.string.agent_remove_attachment), tint = pal.onSurfaceVariant, modifier = Modifier.size(14.dp))
|
||||
}
|
||||
}
|
||||
if (viewing) PictureViewer(AgentAttachments.host(context, path), path.substringAfterLast('/')) { viewing = false }
|
||||
}
|
||||
@@ -126,16 +126,16 @@ internal fun AgentReply(text: String, modifier: Modifier) {
|
||||
private fun AgentPicture(picture: ReplyPart.Picture) {
|
||||
val context = LocalContext.current
|
||||
val file = remember(picture.path) { agentHostFile(context, picture.path) }
|
||||
var full by remember(picture.path) { mutableStateOf(false) }
|
||||
var viewing by remember(picture.path) { mutableStateOf(false) }
|
||||
if (!file.isFile) {
|
||||
Text(stringResource(R.string.agent_image_missing, picture.alt.ifBlank { picture.path }), color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
return
|
||||
}
|
||||
AsyncImage(
|
||||
model = file, contentDescription = picture.alt.ifBlank { file.name }, contentScale = ContentScale.Fit,
|
||||
modifier = Modifier.widthIn(max = 560.dp).then(if (full) Modifier else Modifier.heightIn(max = 420.dp))
|
||||
.clip(Shape12).clickable { full = !full },
|
||||
modifier = Modifier.widthIn(max = 560.dp).heightIn(max = 420.dp).clip(Shape12).clickable { viewing = true },
|
||||
)
|
||||
if (viewing) PictureViewer(file, picture.alt.ifBlank { file.name }) { viewing = false }
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -5,7 +5,9 @@ import android.content.ContextWrapper
|
||||
import android.os.Build
|
||||
import android.view.KeyEvent
|
||||
import android.view.WindowManager
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.activity.compose.LocalActivityResultRegistryOwner
|
||||
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.expandVertically
|
||||
@@ -50,12 +52,12 @@ import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.Send
|
||||
import androidx.compose.material.icons.outlined.Extension
|
||||
import androidx.compose.material.icons.outlined.PhotoCamera
|
||||
import androidx.compose.material.icons.outlined.MicOff
|
||||
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.Keyboard
|
||||
import androidx.compose.material.icons.outlined.Terminal
|
||||
import androidx.compose.material.icons.outlined.Build
|
||||
import androidx.compose.material.icons.outlined.Close
|
||||
@@ -79,6 +81,7 @@ import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateMapOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
@@ -108,6 +111,7 @@ import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.platform.testTag
|
||||
@@ -301,7 +305,7 @@ private fun AgentPageContent(
|
||||
readingBack = false
|
||||
scope.launch { list.scrollToItem(maxOf(0, list.layoutInfo.totalItemsCount - 1), Int.MAX_VALUE / 2) }
|
||||
}
|
||||
val hidden = !composer.focused && !composer.hasUnconsumedFocusRequest() && readingBack && AgentHost.entries.isNotEmpty() &&
|
||||
val hidden = !composer.focused && !composer.tray && !composer.hasUnconsumedFocusRequest() && readingBack && AgentHost.entries.isNotEmpty() &&
|
||||
AgentHost.approvals.isEmpty()
|
||||
var listHeight by remember { mutableIntStateOf(0) }
|
||||
Box(
|
||||
@@ -319,6 +323,7 @@ private fun AgentPageContent(
|
||||
awaitEachGesture {
|
||||
awaitFirstDown(requireUnconsumed = false, pass = PointerEventPass.Initial)
|
||||
if (panel == AgentPanel.MODEL || panel == AgentPanel.USAGE) panel = AgentPanel.NONE
|
||||
composer.tray = false
|
||||
// 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)
|
||||
}
|
||||
@@ -344,6 +349,12 @@ private fun AgentPageContent(
|
||||
@Stable
|
||||
private class ComposerState {
|
||||
var focused by mutableStateOf(false)
|
||||
/** The photo tray stands in for the keyboard, at the height the keyboard last had. */
|
||||
var tray by mutableStateOf(false)
|
||||
var keyboardHeight by mutableStateOf(0.dp)
|
||||
/** Tray photos copied, or being copied, for this conversation, so reopening the tray keeps their marks and copies nothing twice. */
|
||||
val photoCopies = mutableStateMapOf<android.net.Uri, String>()
|
||||
val photosCopying = mutableStateMapOf<android.net.Uri, Any>()
|
||||
var focusRequests by mutableIntStateOf(0)
|
||||
private set
|
||||
private var consumedFocusRequests by mutableIntStateOf(0)
|
||||
@@ -390,7 +401,7 @@ private fun ModelChip(panel: AgentPanel, onPanel: (AgentPanel) -> Unit, firstCon
|
||||
.clickable { onPanel(AgentPanel.MODEL) }.padding(horizontal = 8.dp).testTag("agent-model"),
|
||||
) {
|
||||
val mode = AgentHost.harness.permissions.drop(1).firstOrNull { it.id == AgentHost.permission }?.let { stringResource(it.label) }
|
||||
val parts = if (compact) listOfNotNull(mode ?: model)
|
||||
val parts = if (compact) listOf(model)
|
||||
else listOfNotNull(
|
||||
AgentHost.harness.name, model, AgentHost.effort, mode,
|
||||
stringResource(R.string.agent_plan_short).takeIf { AgentHost.plan && AgentHost.harness.plans },
|
||||
@@ -748,6 +759,8 @@ private fun AgentComposer(
|
||||
if (text.isEmpty() && AgentAttachments.pending.isEmpty()) return@send
|
||||
AgentHost.send(context, text, AgentAttachments.pending.toList())
|
||||
AgentAttachments.pending.clear()
|
||||
composer.photosCopying.clear()
|
||||
composer.tray = false
|
||||
onSent()
|
||||
}
|
||||
}
|
||||
@@ -813,7 +826,34 @@ private fun AgentEditor(composer: ComposerState, draftState: MutableState<String
|
||||
var focused by remember { mutableStateOf(false) }
|
||||
val field = remember { FocusRequester() }
|
||||
LaunchedEffect(composer.focusRequests) { if (composer.hasUnconsumedFocusRequest()) runCatching { field.requestFocus() } }
|
||||
val attach = LocalActivityResultRegistryOwner.current != null
|
||||
val picks = LocalActivityResultRegistryOwner.current != null
|
||||
val density = LocalDensity.current
|
||||
val imeHeight = WindowInsets.ime.getBottom(density)
|
||||
LaunchedEffect(imeHeight) {
|
||||
val height = with(density) { imeHeight.toDp() }
|
||||
if (height > composer.keyboardHeight) composer.keyboardHeight = height
|
||||
}
|
||||
LaunchedEffect(hideAttach) { if (hideAttach) composer.tray = false }
|
||||
LaunchedEffect(AgentHost.chat) {
|
||||
composer.photoCopies.clear()
|
||||
composer.photosCopying.clear()
|
||||
}
|
||||
// BackHandler throws where the host provides no back dispatcher: the front end and the floating pet.
|
||||
if (LocalOnBackPressedDispatcherOwner.current != null) BackHandler(composer.tray) { composer.tray = false }
|
||||
val focusManager = LocalFocusManager.current
|
||||
val files = if (picks) rememberLauncherForActivityResult(ActivityResultContracts.OpenMultipleDocuments()) {
|
||||
AgentAttachments.picking = false
|
||||
attachUris(context, it)
|
||||
} else null
|
||||
val toggleTray = {
|
||||
if (composer.tray) {
|
||||
composer.tray = false
|
||||
composer.open()
|
||||
} else {
|
||||
focusManager.clearFocus(force = true)
|
||||
composer.tray = true
|
||||
}
|
||||
}
|
||||
BoxWithConstraints(
|
||||
Modifier.fillMaxWidth().padding(top = 8.dp).clip(Shape16).background(colors.surface)
|
||||
.border(if (focused) 2.dp else 1.dp, if (focused) pal.primary else pal.line, Shape16).padding(6.dp),
|
||||
@@ -841,6 +881,7 @@ private fun AgentEditor(composer: ComposerState, draftState: MutableState<String
|
||||
Modifier.fillMaxWidth().focusRequester(field).onFocusChanged {
|
||||
focused = it.isFocused
|
||||
composer.focused = it.isFocused
|
||||
if (it.isFocused) composer.tray = false
|
||||
if (it.isFocused) composer.consumeFocusRequest()
|
||||
}.testTag("agent-input"),
|
||||
textStyle = TextStyle(fontSize = 16.sp, color = colors.onSurface),
|
||||
@@ -866,19 +907,22 @@ private fun AgentEditor(composer: ComposerState, draftState: MutableState<String
|
||||
if (stacked) Column {
|
||||
text(Modifier.fillMaxWidth())
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
|
||||
AnimatedVisibility(attach && !hideAttach, enter = expandHorizontally() + fadeIn(), exit = shrinkHorizontally() + fadeOut()) { AttachButton() }
|
||||
AnimatedVisibility(AgentAttachments.gameFrame != null && !hideAttach, enter = expandHorizontally() + fadeIn(), exit = shrinkHorizontally() + fadeOut()) { GameFrameButton() }
|
||||
AnimatedVisibility(!hideAttach, enter = expandHorizontally() + fadeIn(), exit = shrinkHorizontally() + fadeOut()) { AttachButton(composer.tray, toggleTray) }
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.weight(1f).height(42.dp).horizontalScroll(rememberScrollState(), reverseScrolling = true)) { if (controls != null && !focused) controls() }
|
||||
actions()
|
||||
}
|
||||
} else Row(verticalAlignment = Alignment.Bottom) {
|
||||
AnimatedVisibility(attach && !hideAttach, enter = expandHorizontally() + fadeIn(), exit = shrinkHorizontally() + fadeOut()) { AttachButton() }
|
||||
AnimatedVisibility(AgentAttachments.gameFrame != null && !hideAttach, enter = expandHorizontally() + fadeIn(), exit = shrinkHorizontally() + fadeOut()) { GameFrameButton() }
|
||||
AnimatedVisibility(!hideAttach, enter = expandHorizontally() + fadeIn(), exit = shrinkHorizontally() + fadeOut()) { AttachButton(composer.tray, toggleTray) }
|
||||
text(Modifier.weight(1f))
|
||||
if (controls != null && !focused) Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.height(42.dp)) { controls() }
|
||||
actions()
|
||||
}
|
||||
}
|
||||
AnimatedVisibility(composer.tray, enter = expandVertically() + fadeIn(), exit = shrinkVertically() + fadeOut()) {
|
||||
val most = LocalConfiguration.current.screenHeightDp.dp * 0.45f
|
||||
val height = (if (composer.keyboardHeight > 0.dp) composer.keyboardHeight else 280.dp).coerceAtLeast(160.dp).coerceAtMost(most)
|
||||
AgentPhotoTray(height, composer.photoCopies, composer.photosCopying, files?.let { { AgentAttachments.pick { it.launch(arrayOf("*/*")) } } })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -974,51 +1018,15 @@ private fun VoiceButton(voice: AgentVoice, onStart: () -> Unit, onSend: () -> Un
|
||||
}
|
||||
}
|
||||
|
||||
/** Attaches what the running game shows, taken from its own surface so nothing drawn over it is in the picture. */
|
||||
/** Opens the photo tray in place of the keyboard; while it is open, brings the keyboard back. */
|
||||
@Composable
|
||||
private fun GameFrameButton() {
|
||||
val context = LocalContext.current
|
||||
private fun AttachButton(trayOpen: Boolean, onClick: () -> Unit) {
|
||||
val pal = LocalPalette.current
|
||||
RoundButton(Icons.Outlined.PhotoCamera, stringResource(R.string.agent_attach_game), pal.surfaceVariant, pal.onBackground, "agent-game-frame") {
|
||||
val grab = AgentAttachments.gameFrame ?: return@RoundButton
|
||||
val chat = AgentHost.chat
|
||||
grab frame@{ frame ->
|
||||
if (frame == null) {
|
||||
android.widget.Toast.makeText(context, R.string.agent_attach_game_failed, android.widget.Toast.LENGTH_SHORT).show()
|
||||
return@frame
|
||||
}
|
||||
Thread({
|
||||
val path = AgentAttachments.saveFrame(context, chat, frame)
|
||||
frame.recycle()
|
||||
android.os.Handler(android.os.Looper.getMainLooper()).post {
|
||||
when {
|
||||
path == null -> android.widget.Toast.makeText(context, R.string.agent_attach_game_failed, android.widget.Toast.LENGTH_SHORT).show()
|
||||
AgentHost.chat == chat -> AgentAttachments.pending.add(path)
|
||||
else -> AgentAttachments.discard(context, listOf(path))
|
||||
}
|
||||
}
|
||||
}, "agent-game-frame").start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AttachButton() {
|
||||
val context = LocalContext.current
|
||||
val pal = LocalPalette.current
|
||||
val picker = rememberLauncherForActivityResult(ActivityResultContracts.OpenMultipleDocuments()) { uris ->
|
||||
if (uris.isEmpty()) return@rememberLauncherForActivityResult
|
||||
val chat = AgentHost.chat
|
||||
Thread({
|
||||
val paths = AgentAttachments.copy(context, chat, uris)
|
||||
android.os.Handler(android.os.Looper.getMainLooper()).post {
|
||||
if (AgentHost.chat == chat) AgentAttachments.pending.addAll(paths) else AgentAttachments.discard(context, paths)
|
||||
}
|
||||
}, "agent-attach").start()
|
||||
}
|
||||
RoundButton(Icons.Outlined.AttachFile, stringResource(R.string.agent_attach), pal.surfaceVariant, pal.onBackground, "agent-attach") {
|
||||
runCatching { picker.launch(arrayOf("*/*")) }
|
||||
}
|
||||
RoundButton(
|
||||
if (trayOpen) Icons.Outlined.Keyboard else Icons.Outlined.AttachFile,
|
||||
stringResource(if (trayOpen) R.string.agent_keyboard else R.string.agent_attach),
|
||||
if (trayOpen) pal.primary else pal.surfaceVariant, if (trayOpen) pal.onPrimary else pal.onBackground, "agent-attach", onClick = onClick,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -21,6 +21,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
@@ -495,7 +496,13 @@ internal class PetWindows(private val context: Context) {
|
||||
* under it. Its contents are built while it is closed, so opening only animates.
|
||||
*/
|
||||
@Composable
|
||||
internal fun PetChat(open: Boolean, motion: PetMotion, onClose: () -> Unit, onClosed: () -> Unit) {
|
||||
internal fun PetChat(
|
||||
open: Boolean, motion: PetMotion, onClose: () -> Unit,
|
||||
page: @Composable ColumnScope.(AgentMenuSlot) -> Unit = { slot ->
|
||||
AgentPage(Modifier.weight(1f).fillMaxWidth(), visible = open, startTyping = AgentHost.entries.isEmpty(), hidesPet = false, menuSlot = slot)
|
||||
},
|
||||
onClosed: () -> Unit,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val density = androidx.compose.ui.platform.LocalDensity.current
|
||||
@@ -552,14 +559,16 @@ internal fun PetChat(open: Boolean, motion: PetMotion, onClose: () -> Unit, onCl
|
||||
alpha = fade.value
|
||||
}
|
||||
.clip(Shape16).background(colors.background).border(1.dp, pal.line, Shape16)
|
||||
.clickable(remember { MutableInteractionSource() }, null, enabled = open) {}
|
||||
// Never disabled: a disabled clickable leaves the focus tree, and the one it puts back on reopening
|
||||
// sits unfocused above the still-focused editor, where key events then find no focus target.
|
||||
.clickable(remember { MutableInteractionSource() }, null) {}
|
||||
.padding(start = 12.dp, end = 12.dp, top = 6.dp),
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(bottom = 2.dp)) {
|
||||
Box(Modifier.weight(1f)) { menuSlot.content?.invoke() }
|
||||
HeaderAction(Icons.Outlined.Close, stringResource(R.string.agent_close), size = 34.dp, tag = "agent-pet-close", onClick = onClose)
|
||||
}
|
||||
AgentPage(Modifier.weight(1f).fillMaxWidth(), visible = open, startTyping = AgentHost.entries.isEmpty(), hidesPet = false, menuSlot = menuSlot)
|
||||
page(menuSlot)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.Manifest
|
||||
import android.content.ContentUris
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.provider.MediaStore
|
||||
import android.provider.Settings
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.LocalActivityResultRegistryOwner
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Check
|
||||
import androidx.compose.material.icons.outlined.FolderOpen
|
||||
import androidx.compose.material.icons.outlined.PhotoCamera
|
||||
import androidx.compose.material.icons.outlined.PhotoLibrary
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.snapshots.SnapshotStateMap
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.selected
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import coil.compose.AsyncImage
|
||||
import coil.request.ImageRequest
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.agent.AgentAttachments
|
||||
import com.droiddeck.launcher.agent.AgentHost
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
/** The device's photos, newest first, as MediaStore lets the app see them. */
|
||||
internal object AgentPhotos {
|
||||
enum class Access { NONE, SELECTED, ALL }
|
||||
|
||||
/** Android stops showing the request after repeated denials and answers it at once, so a denied request sends later ones to Settings. */
|
||||
var refused = false
|
||||
|
||||
fun permissions(sdk: Int = Build.VERSION.SDK_INT): Array<String> = when {
|
||||
sdk >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> arrayOf(Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED)
|
||||
sdk >= Build.VERSION_CODES.TIRAMISU -> arrayOf(Manifest.permission.READ_MEDIA_IMAGES)
|
||||
else -> arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
}
|
||||
|
||||
fun access(context: Context): Access {
|
||||
fun granted(permission: String) = context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED
|
||||
val all = permissions().first()
|
||||
return when {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && Environment.isExternalStorageManager() -> Access.ALL
|
||||
granted(all) -> Access.ALL
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && granted(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED) -> Access.SELECTED
|
||||
else -> Access.NONE
|
||||
}
|
||||
}
|
||||
|
||||
class Photo(val uri: Uri, val name: String)
|
||||
|
||||
fun recent(context: Context, limit: Int = 300): List<Photo> = runCatching {
|
||||
val images = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
|
||||
context.contentResolver.query(
|
||||
images, arrayOf(MediaStore.Images.Media._ID, MediaStore.Images.Media.DISPLAY_NAME), null, null, "${MediaStore.Images.Media.DATE_ADDED} DESC",
|
||||
)?.use { c ->
|
||||
buildList {
|
||||
while (size < limit && c.moveToNext()) add(Photo(ContentUris.withAppendedId(images, c.getLong(0)), c.getString(1).orEmpty()))
|
||||
}
|
||||
}.orEmpty()
|
||||
}.getOrDefault(emptyList())
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies [uris] into the conversation's attachments off the main thread, then hands [onCopied] what was attached: nothing if the
|
||||
* conversation changed meanwhile or [current] says the copy was superseded.
|
||||
*/
|
||||
internal fun attachUris(context: Context, uris: List<Uri>, current: () -> Boolean = { true }, onCopied: (List<Pair<Uri, String>>) -> Unit = {}) {
|
||||
if (uris.isEmpty()) return
|
||||
val chat = AgentHost.chat
|
||||
Thread({
|
||||
val copied = uris.mapNotNull { uri -> AgentAttachments.copy(context, chat, listOf(uri)).firstOrNull()?.let { uri to it } }
|
||||
android.os.Handler(android.os.Looper.getMainLooper()).post {
|
||||
val paths = copied.map { it.second }
|
||||
if (AgentHost.chat == chat && current()) {
|
||||
AgentAttachments.pending.addAll(paths)
|
||||
onCopied(copied)
|
||||
} else {
|
||||
AgentAttachments.discard(context, paths)
|
||||
onCopied(emptyList())
|
||||
}
|
||||
}
|
||||
}, "agent-attach").start()
|
||||
}
|
||||
|
||||
/** Attaches what the running game shows, taken from its own surface so nothing drawn over it is in the picture. */
|
||||
private fun attachGameFrame(context: Context) {
|
||||
val grab = AgentAttachments.gameFrame ?: return
|
||||
val chat = AgentHost.chat
|
||||
grab frame@{ frame ->
|
||||
if (frame == null) {
|
||||
Toast.makeText(context, R.string.agent_attach_game_failed, Toast.LENGTH_SHORT).show()
|
||||
return@frame
|
||||
}
|
||||
Thread({
|
||||
val path = AgentAttachments.saveFrame(context, chat, frame)
|
||||
frame.recycle()
|
||||
android.os.Handler(android.os.Looper.getMainLooper()).post {
|
||||
when {
|
||||
path == null -> Toast.makeText(context, R.string.agent_attach_game_failed, Toast.LENGTH_SHORT).show()
|
||||
AgentHost.chat == chat -> AgentAttachments.pending.add(path)
|
||||
else -> AgentAttachments.discard(context, listOf(path))
|
||||
}
|
||||
}
|
||||
}, "agent-game-frame").start()
|
||||
}
|
||||
}
|
||||
|
||||
/** Shown in place of the keyboard: recent photos to tap onto the message, and the system picker for anything else. */
|
||||
@Composable
|
||||
internal fun AgentPhotoTray(height: Dp, copies: SnapshotStateMap<Uri, String>, copying: SnapshotStateMap<Uri, Any>, onFiles: (() -> Unit)?) {
|
||||
val context = LocalContext.current
|
||||
val pal = LocalPalette.current
|
||||
var access by remember { mutableStateOf(AgentPhotos.access(context)) }
|
||||
var photos by remember { mutableStateOf<List<AgentPhotos.Photo>?>(null) }
|
||||
var reloads by remember { mutableStateOf(0) }
|
||||
// A window no activity owns (the floating pet's chat) cannot ask for a permission, so it sends the user to the app's settings.
|
||||
val launcher = if (LocalActivityResultRegistryOwner.current != null) {
|
||||
rememberLauncherForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
|
||||
AgentAttachments.picking = false
|
||||
access = AgentPhotos.access(context)
|
||||
if (access == AgentPhotos.Access.NONE) AgentPhotos.refused = true
|
||||
reloads++
|
||||
}
|
||||
} else null
|
||||
val request = {
|
||||
if (launcher != null && !AgentPhotos.refused) {
|
||||
AgentAttachments.pick { launcher.launch(AgentPhotos.permissions()) }
|
||||
} else {
|
||||
val details = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + context.packageName)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
runCatching { context.startActivity(details) }
|
||||
}
|
||||
Unit
|
||||
}
|
||||
// Access can change in Settings, and new pictures arrive, while the app is in the background.
|
||||
val lifecycle = LocalLifecycleOwner.current.lifecycle
|
||||
DisposableEffect(lifecycle) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_RESUME) {
|
||||
access = AgentPhotos.access(context)
|
||||
reloads++
|
||||
}
|
||||
}
|
||||
lifecycle.addObserver(observer)
|
||||
onDispose { lifecycle.removeObserver(observer) }
|
||||
}
|
||||
LaunchedEffect(access, reloads) {
|
||||
photos = if (access == AgentPhotos.Access.NONE) emptyList() else withContext(Dispatchers.IO) { AgentPhotos.recent(context) }
|
||||
}
|
||||
LazyVerticalGrid(
|
||||
GridCells.Adaptive(96.dp),
|
||||
Modifier.fillMaxWidth().height(height).padding(top = 8.dp).testTag("agent-photo-tray"),
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
if (AgentAttachments.gameFrame != null) item {
|
||||
TrayTile(Icons.Outlined.PhotoCamera, stringResource(R.string.agent_attach_game), "agent-game-frame") { attachGameFrame(context) }
|
||||
}
|
||||
if (onFiles != null) item { TrayTile(Icons.Outlined.FolderOpen, stringResource(R.string.agent_attach_files), "agent-attach-files", onFiles) }
|
||||
if (access != AgentPhotos.Access.ALL) item {
|
||||
TrayTile(
|
||||
Icons.Outlined.PhotoLibrary,
|
||||
stringResource(if (access == AgentPhotos.Access.NONE) R.string.agent_photos_allow else R.string.agent_photos_more),
|
||||
"agent-photos-allow",
|
||||
onClick = request,
|
||||
)
|
||||
}
|
||||
val list = photos
|
||||
if (list != null && list.isEmpty() && access != AgentPhotos.Access.NONE) item(span = { GridItemSpan(maxLineSpan) }) {
|
||||
Text(
|
||||
stringResource(R.string.agent_photos_empty), fontSize = 13.sp, color = pal.onSurfaceVariant, textAlign = TextAlign.Center,
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
)
|
||||
}
|
||||
items(list.orEmpty(), key = { it.uri.toString() }) { photo ->
|
||||
val uri = photo.uri
|
||||
val path = copies[uri]
|
||||
val selected = path != null && path in AgentAttachments.pending
|
||||
Box(
|
||||
Modifier.aspectRatio(1f).clip(Shape12).background(pal.surfaceVariant)
|
||||
.then(if (selected) Modifier.border(3.dp, pal.primary, Shape12) else Modifier)
|
||||
.clickable {
|
||||
when {
|
||||
selected -> AgentAttachments.pending.remove(path)
|
||||
path != null && AgentAttachments.host(context, path).exists() -> AgentAttachments.pending.add(path)
|
||||
uri in copying -> Unit
|
||||
else -> {
|
||||
// Leaving the conversation clears the markers, so a copy started before that is no longer current even back in it.
|
||||
val copy = Any()
|
||||
copying[uri] = copy
|
||||
attachUris(context, listOf(uri), current = { copying[uri] === copy }) { copied ->
|
||||
copied.forEach { (u, p) -> copies[u] = p }
|
||||
if (copying[uri] === copy) copying.remove(uri)
|
||||
}
|
||||
}
|
||||
}
|
||||
}.semantics {
|
||||
contentDescription = photo.name
|
||||
this.selected = selected
|
||||
}.testTag("agent-photo"),
|
||||
) {
|
||||
AsyncImage(
|
||||
model = ImageRequest.Builder(context).data(uri).size(320).build(), contentDescription = null,
|
||||
contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize(),
|
||||
)
|
||||
if (selected) Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.align(Alignment.TopEnd).padding(6.dp).size(22.dp).clip(CircleShape).background(pal.primary),
|
||||
) {
|
||||
Icon(Icons.Outlined.Check, null, tint = pal.onPrimary, modifier = Modifier.size(16.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TrayTile(icon: ImageVector, label: String, tag: String, onClick: () -> Unit) {
|
||||
val pal = LocalPalette.current
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center,
|
||||
modifier = Modifier.aspectRatio(1f).clip(Shape12).background(pal.surfaceVariant).clickable(onClick = onClick).padding(8.dp).testTag(tag),
|
||||
) {
|
||||
Icon(icon, null, tint = pal.onBackground, modifier = Modifier.size(26.dp))
|
||||
Text(
|
||||
label, fontSize = 12.sp, color = pal.onBackground, textAlign = TextAlign.Center, maxLines = 3, overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.padding(top = 6.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.awaitEachGesture
|
||||
import androidx.compose.foundation.gestures.awaitFirstDown
|
||||
import androidx.compose.foundation.gestures.calculatePan
|
||||
import androidx.compose.foundation.gestures.calculateZoom
|
||||
import androidx.compose.foundation.gestures.detectTapGestures
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Close
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.input.pointer.positionChanged
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.IntSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Popup
|
||||
import androidx.compose.ui.window.PopupProperties
|
||||
import coil.compose.AsyncImage
|
||||
import com.droiddeck.launcher.R
|
||||
import kotlin.math.abs
|
||||
|
||||
private const val MAX_ZOOM = 5f
|
||||
private const val TAP_ZOOM = 2.5f
|
||||
|
||||
/**
|
||||
* A picture over the whole window: pinch or double-tap to zoom, drag to pan. A tap, a swipe down,
|
||||
* Back or B close it. It is a popup, not a dialog, because the pet's chat lives in an overlay window,
|
||||
* which has no activity token to show a dialog with.
|
||||
*/
|
||||
@Composable
|
||||
internal fun PictureViewer(model: Any, description: String?, onDismiss: () -> Unit) {
|
||||
Popup(
|
||||
alignment = Alignment.Center, onDismissRequest = onDismiss,
|
||||
properties = PopupProperties(focusable = true, dismissOnBackPress = true, dismissOnClickOutside = false),
|
||||
) {
|
||||
var size by remember { mutableStateOf(IntSize.Zero) }
|
||||
var scale by remember { mutableFloatStateOf(1f) }
|
||||
var offset by remember { mutableStateOf(Offset.Zero) }
|
||||
fun clamp(o: Offset, s: Float): Offset {
|
||||
val x = size.width * (s - 1f) / 2f
|
||||
val y = size.height * (s - 1f) / 2f
|
||||
return Offset(o.x.coerceIn(-x, x), o.y.coerceIn(-y, y))
|
||||
}
|
||||
val fade = if (scale == 1f && size.height > 0) (1f - abs(offset.y) / size.height * 2f).coerceIn(0.3f, 1f) else 1f
|
||||
Box(
|
||||
Modifier.fillMaxSize().onSizeChanged { size = it }.background(Color.Black.copy(alpha = 0.94f * fade))
|
||||
.pointerInput(Unit) {
|
||||
detectTapGestures(
|
||||
onDoubleTap = { at ->
|
||||
if (scale > 1f) { scale = 1f; offset = Offset.Zero } else {
|
||||
scale = TAP_ZOOM
|
||||
offset = clamp((Offset(size.width / 2f, size.height / 2f) - at) * (TAP_ZOOM - 1f), TAP_ZOOM)
|
||||
}
|
||||
},
|
||||
onTap = { if (scale == 1f) onDismiss() },
|
||||
)
|
||||
}
|
||||
.pointerInput(Unit) {
|
||||
awaitEachGesture {
|
||||
awaitFirstDown(requireUnconsumed = false)
|
||||
do {
|
||||
val event = awaitPointerEvent()
|
||||
val zoom = event.calculateZoom()
|
||||
val pan = event.calculatePan()
|
||||
if (zoom != 1f || pan != Offset.Zero) {
|
||||
val next = (scale * zoom).coerceIn(1f, MAX_ZOOM)
|
||||
offset = if (next > 1f) clamp(offset * (next / scale) + pan, next) else Offset(0f, offset.y + pan.y)
|
||||
scale = next
|
||||
event.changes.forEach { if (it.positionChanged()) it.consume() }
|
||||
}
|
||||
} while (event.changes.any { it.pressed })
|
||||
if (scale == 1f) {
|
||||
if (abs(offset.y) > size.height / 6f) onDismiss() else offset = Offset.Zero
|
||||
}
|
||||
}
|
||||
},
|
||||
) {
|
||||
AsyncImage(
|
||||
model = model, contentDescription = description, contentScale = ContentScale.Fit,
|
||||
modifier = Modifier.fillMaxSize().graphicsLayer {
|
||||
scaleX = scale; scaleY = scale; translationX = offset.x; translationY = offset.y
|
||||
},
|
||||
)
|
||||
IconButton(
|
||||
onClick = onDismiss,
|
||||
modifier = Modifier.align(Alignment.TopEnd).padding(12.dp).size(44.dp).clip(CircleShape).background(Color.Black.copy(alpha = 0.5f)),
|
||||
) {
|
||||
Icon(Icons.Outlined.Close, stringResource(R.string.common_close), tint = Color.White)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,30 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.input.InputMode
|
||||
import androidx.compose.ui.platform.LocalInputModeManager
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.stateDescription
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -29,18 +46,24 @@ internal fun FrameGenMenu(
|
||||
onResetGame: () -> Unit = {},
|
||||
focusModifier: Modifier = Modifier,
|
||||
legacyButtons: Boolean = false,
|
||||
listLayout: Boolean = false,
|
||||
sessionHost: MenuHost? = null,
|
||||
) {
|
||||
val sessionEngineAnchor = remember { FocusRequester() }
|
||||
val need = stringResource(R.string.lsfg_needs_steam)
|
||||
val selectedEngine = mode.engine.takeIf { it != FrameGen.ENGINE_OFF }
|
||||
val offLabel = FrameGen.label(LocalContext.current, FrameGen.Mode.OFF)
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val engines = listOf(FrameGen.ENGINE_LSFG to "LSFG", FrameGen.ENGINE_DDFG to "DDFG")
|
||||
val context = LocalContext.current
|
||||
var pacerEnabled by remember { mutableStateOf(FrameGen.pacerEnabled(context)) }
|
||||
val engines = listOf(FrameGen.ENGINE_LSFG to "LSFG", FrameGen.ENGINE_DDFG to "DDFG", FrameGen.ENGINE_ZEROFG to "ZeroFG")
|
||||
|
||||
if (legacyButtons) {
|
||||
val context = LocalContext.current
|
||||
val options = buildList {
|
||||
add(FrameGen.Mode.OFF.copy(multiplier = mode.multiplier))
|
||||
(2..4).forEach { add(FrameGen.Mode(FrameGen.ENGINE_DDFG, it)) }
|
||||
(2..4).forEach { add(FrameGen.Mode(FrameGen.ENGINE_ZEROFG, it)) }
|
||||
(2..4).forEach { add(FrameGen.Mode(FrameGen.ENGINE_LSFG, it)) }
|
||||
FrameGen.ADAPTIVE_TARGETS.forEach { add(FrameGen.Mode(FrameGen.ENGINE_LSFG, target = it)) }
|
||||
}
|
||||
@@ -87,60 +110,106 @@ internal fun FrameGenMenu(
|
||||
}
|
||||
|
||||
Column(Modifier.fillMaxWidth().padding(start = 10.dp, end = 10.dp, top = 0.dp, bottom = 8.dp)) {
|
||||
OutlinedButton(
|
||||
onClick = { onPick(FrameGen.Mode.OFF.copy(multiplier = mode.multiplier)) },
|
||||
modifier = Modifier.fillMaxWidth().controllerConfirm(
|
||||
if (sessionHost != null) {
|
||||
SessionFrameGenEngine(
|
||||
sessionHost, mode, listOf(FrameGen.ENGINE_OFF to offLabel) + engines,
|
||||
lossless.ready, need, focusModifier, sessionEngineAnchor, onPick,
|
||||
)
|
||||
} else {
|
||||
OutlinedButton(
|
||||
onClick = { onPick(FrameGen.Mode.OFF.copy(multiplier = mode.multiplier)) },
|
||||
),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
containerColor = if (selectedEngine == null) colors.primary.copy(alpha = 0.16f) else colors.surface,
|
||||
contentColor = if (selectedEngine == null) colors.primary else colors.onSurface,
|
||||
),
|
||||
) { Text(offLabel) }
|
||||
modifier = Modifier.fillMaxWidth().controllerConfirm(
|
||||
onClick = { onPick(FrameGen.Mode.OFF.copy(multiplier = mode.multiplier)) },
|
||||
),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
containerColor = if (selectedEngine == null) colors.primary.copy(alpha = 0.16f) else colors.surface,
|
||||
contentColor = if (selectedEngine == null) colors.primary else colors.onSurface,
|
||||
),
|
||||
) { Text(offLabel) }
|
||||
|
||||
Row(Modifier.fillMaxWidth().padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
val focusIndex = engines.indexOfFirst { (engine, _) ->
|
||||
selectedEngine == engine || engine != FrameGen.ENGINE_LSFG || lossless.ready
|
||||
}
|
||||
engines.forEachIndexed { index, (engine, label) ->
|
||||
val selected = selectedEngine == engine
|
||||
val enabled = selected || engine != FrameGen.ENGINE_LSFG || lossless.ready
|
||||
val pick = {
|
||||
onPick(if (selected) FrameGen.Mode.OFF.copy(multiplier = mode.multiplier) else FrameGen.Mode(engine, mode.multiplier.coerceIn(2, 4)))
|
||||
if (listLayout) {
|
||||
Column(Modifier.fillMaxWidth().padding(top = 8.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
engines.forEach { (engine, label) ->
|
||||
val selected = selectedEngine == engine
|
||||
val enabled = selected || engine != FrameGen.ENGINE_LSFG || lossless.ready
|
||||
val pick = {
|
||||
onPick(if (selected) FrameGen.Mode.OFF.copy(multiplier = mode.multiplier) else FrameGen.Mode(engine, mode.multiplier.coerceIn(2, 4)))
|
||||
}
|
||||
OutlinedButton(
|
||||
onClick = pick,
|
||||
enabled = enabled,
|
||||
modifier = Modifier.fillMaxWidth().controllerConfirm(enabled = enabled, onClick = pick),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
containerColor = if (selected) colors.primary.copy(alpha = 0.16f) else colors.surface,
|
||||
contentColor = if (selected) colors.primary else colors.onSurface,
|
||||
),
|
||||
) { Text(label) }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Row(Modifier.fillMaxWidth().padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
val focusIndex = engines.indexOfFirst { (engine, _) ->
|
||||
selectedEngine == engine || engine != FrameGen.ENGINE_LSFG || lossless.ready
|
||||
}
|
||||
engines.forEachIndexed { index, (engine, label) ->
|
||||
val selected = selectedEngine == engine
|
||||
val enabled = selected || engine != FrameGen.ENGINE_LSFG || lossless.ready
|
||||
val pick = {
|
||||
onPick(if (selected) FrameGen.Mode.OFF.copy(multiplier = mode.multiplier) else FrameGen.Mode(engine, mode.multiplier.coerceIn(2, 4)))
|
||||
}
|
||||
OutlinedButton(
|
||||
onClick = pick,
|
||||
enabled = enabled,
|
||||
modifier = (if (index == focusIndex) focusModifier else Modifier)
|
||||
.weight(1f).controllerConfirm(enabled = enabled, onClick = pick),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
containerColor = if (selected) colors.primary.copy(alpha = 0.16f) else colors.surface,
|
||||
contentColor = if (selected) colors.primary else colors.onSurface,
|
||||
),
|
||||
) { Text(label) }
|
||||
}
|
||||
}
|
||||
OutlinedButton(
|
||||
onClick = pick,
|
||||
enabled = enabled,
|
||||
modifier = (if (index == focusIndex) focusModifier else Modifier)
|
||||
.weight(1f).controllerConfirm(enabled = enabled, onClick = pick),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
containerColor = if (selected) colors.primary.copy(alpha = 0.16f) else colors.surface,
|
||||
contentColor = if (selected) colors.primary else colors.onSurface,
|
||||
),
|
||||
) { Text(label) }
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedEngine != null) {
|
||||
val multiplierEnabled = mode.engine != FrameGen.ENGINE_LSFG || lossless.ready
|
||||
val multiplierEnabled = mode.engine != FrameGen.ENGINE_LSFG || lossless.ready
|
||||
if (listLayout) {
|
||||
Column(
|
||||
Modifier.fillMaxWidth().padding(top = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) {
|
||||
(2..4).forEach { multiplier ->
|
||||
val selected = mode.multiplier == multiplier && mode.target == 0
|
||||
val pickMultiplier = { onPick(mode.copy(multiplier = multiplier, target = 0)) }
|
||||
OutlinedButton(
|
||||
onClick = pickMultiplier,
|
||||
enabled = multiplierEnabled,
|
||||
modifier = Modifier.fillMaxWidth().controllerConfirm(enabled = multiplierEnabled, onClick = pickMultiplier)
|
||||
.frameGenFocus(sessionHost),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
containerColor = if (selected) colors.secondary.copy(alpha = 0.18f) else colors.surface,
|
||||
contentColor = if (selected) colors.secondary else colors.onSurface,
|
||||
),
|
||||
) { Text("${multiplier}×") }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Row(
|
||||
Modifier.fillMaxWidth().padding(top = 8.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
(2..4).forEach { multiplier ->
|
||||
val selected = mode.multiplier == multiplier && mode.target == 0
|
||||
val pickMultiplier = {
|
||||
onPick(mode.copy(multiplier = multiplier, target = 0))
|
||||
}
|
||||
val pickMultiplier = { onPick(mode.copy(multiplier = multiplier, target = 0)) }
|
||||
OutlinedButton(
|
||||
onClick = pickMultiplier,
|
||||
enabled = multiplierEnabled,
|
||||
modifier = Modifier.weight(1f).controllerConfirm(
|
||||
enabled = multiplierEnabled,
|
||||
onClick = pickMultiplier,
|
||||
),
|
||||
modifier = Modifier.weight(1f).controllerConfirm(enabled = multiplierEnabled, onClick = pickMultiplier)
|
||||
.frameGenFocus(sessionHost),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
containerColor = if (selected) colors.secondary.copy(alpha = 0.18f) else colors.surface,
|
||||
@@ -151,6 +220,25 @@ internal fun FrameGenMenu(
|
||||
}
|
||||
}
|
||||
|
||||
val togglePacer = {
|
||||
val enabled = !pacerEnabled
|
||||
FrameGen.setPacer(context, enabled)
|
||||
pacerEnabled = enabled
|
||||
}
|
||||
OutlinedButton(
|
||||
onClick = togglePacer,
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 8.dp)
|
||||
.controllerConfirm(onClick = togglePacer).frameGenFocus(sessionHost),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
containerColor = if (pacerEnabled) colors.primary.copy(alpha = 0.16f) else colors.surface,
|
||||
contentColor = if (pacerEnabled) colors.primary else colors.onSurface,
|
||||
),
|
||||
) {
|
||||
Text("ZeroPacer" + if (pacerEnabled) " ✓" else "")
|
||||
}
|
||||
|
||||
|
||||
if (selectedEngine == FrameGen.ENGINE_LSFG) {
|
||||
Row(
|
||||
Modifier.fillMaxWidth().padding(top = 8.dp),
|
||||
@@ -166,7 +254,7 @@ internal fun FrameGenMenu(
|
||||
modifier = Modifier.weight(1f).controllerConfirm(
|
||||
enabled = lossless.ready,
|
||||
onClick = pickTarget,
|
||||
),
|
||||
).frameGenFocus(sessionHost),
|
||||
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 8.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
containerColor = if (selected) colors.secondary.copy(alpha = 0.18f) else colors.surface,
|
||||
@@ -179,23 +267,105 @@ internal fun FrameGenMenu(
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedEngine == FrameGen.ENGINE_LSFG && !lossless.ready) {
|
||||
if (sessionHost == null && selectedEngine == FrameGen.ENGINE_LSFG && !lossless.ready) {
|
||||
Text(need, color = colors.onSurfaceVariant,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.padding(top = 6.dp))
|
||||
}
|
||||
|
||||
if (gameProfileId != null) {
|
||||
val resetGame = onResetGame
|
||||
if (gameProfileId != null && (sessionHost == null || hasGameOverride)) {
|
||||
val input = LocalInputModeManager.current
|
||||
val resetGame = {
|
||||
if (sessionHost != null && input.inputMode == InputMode.Keyboard) {
|
||||
sessionEngineAnchor.requestFocus()
|
||||
}
|
||||
onResetGame()
|
||||
}
|
||||
OutlinedButton(
|
||||
onClick = resetGame,
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 8.dp)
|
||||
.controllerConfirm(onClick = resetGame),
|
||||
.testTag("framegen-use-global").controllerConfirm(onClick = resetGame)
|
||||
.frameGenFocus(sessionHost),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
) {
|
||||
Text(stringResource(R.string.comp_game_use_general) + if (hasGameOverride) "" else " ✓")
|
||||
Text(if (sessionHost != null) stringResource(R.string.frame_gen_use_global)
|
||||
else stringResource(R.string.comp_game_use_general) + if (hasGameOverride) "" else " ✓")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Modifier.frameGenFocus(sessionHost: MenuHost?): Modifier =
|
||||
if (sessionHost != null) focusGlide(RoundedCornerShape(percent = 50)) else this
|
||||
|
||||
@Composable
|
||||
private fun SessionFrameGenEngine(
|
||||
host: MenuHost,
|
||||
mode: FrameGen.Mode,
|
||||
options: List<Pair<String, String>>,
|
||||
losslessReady: Boolean,
|
||||
losslessNote: String,
|
||||
focusModifier: Modifier,
|
||||
anchor: FocusRequester,
|
||||
onPick: (FrameGen.Mode) -> Unit,
|
||||
) {
|
||||
val label = stringResource(R.string.frame_gen_engine)
|
||||
val selectedLabel = options.firstOrNull { (engine, _) -> engine == mode.engine }?.second
|
||||
?: options.first().second
|
||||
val key = "frame-generation-engine"
|
||||
val open = host.open == key
|
||||
val input = LocalInputModeManager.current
|
||||
var anchorFocused by remember { mutableStateOf(false) }
|
||||
val selectedOption = remember { FocusRequester() }
|
||||
var keyboardOpened by remember { mutableStateOf(false) }
|
||||
val initial = options.firstOrNull { (engine, _) -> engine == mode.engine }?.first
|
||||
?: FrameGen.ENGINE_OFF
|
||||
val close = { if (host.open == key) host.open = null }
|
||||
|
||||
// Keep the options in the drawer's focus tree. A separate popup window can
|
||||
// steal focus from the controller before Compose can focus the selected row.
|
||||
LaunchedEffect(open) {
|
||||
if (!keyboardOpened || (!open && host.open != null)) return@LaunchedEffect
|
||||
val target = if (open) selectedOption else anchor
|
||||
withFrameNanos { }
|
||||
target.requestFocus()
|
||||
if (!open) keyboardOpened = false
|
||||
}
|
||||
|
||||
val blockedSelection = !losslessReady && mode.engine == FrameGen.ENGINE_LSFG
|
||||
SettingsRow(label, losslessNote.takeIf { blockedSelection && !open }, highlighted = open) {
|
||||
ValueChip(
|
||||
selectedLabel, open,
|
||||
modifier = focusModifier.focusRequester(anchor).onFocusChanged { anchorFocused = it.isFocused }
|
||||
.heightIn(min = 48.dp).testTag("setting-$key")
|
||||
.semantics { contentDescription = label; stateDescription = selectedLabel },
|
||||
) {
|
||||
if (open) close()
|
||||
else {
|
||||
keyboardOpened = anchorFocused || input.inputMode == InputMode.Keyboard
|
||||
host.open = key
|
||||
}
|
||||
}
|
||||
}
|
||||
if (open) {
|
||||
Column(Modifier.fillMaxWidth().padding(horizontal = 8.dp).controllerBack(close)) {
|
||||
options.forEach { (engine, text) ->
|
||||
val selected = engine == mode.engine
|
||||
val enabled = selected || engine != FrameGen.ENGINE_LSFG || losslessReady
|
||||
MenuItem(
|
||||
label = text, checked = selected, enabled = enabled,
|
||||
detail = losslessNote.takeIf { engine == FrameGen.ENGINE_LSFG && !losslessReady },
|
||||
focusRequester = selectedOption.takeIf { engine == initial },
|
||||
modifier = Modifier.heightIn(min = 48.dp).testTag("framegen-engine:$engine"),
|
||||
) {
|
||||
close()
|
||||
if (!selected) {
|
||||
onPick(if (engine == FrameGen.ENGINE_OFF) FrameGen.Mode.OFF.copy(multiplier = mode.multiplier)
|
||||
else FrameGen.Mode(engine, mode.multiplier.coerceIn(2, 4)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -881,6 +881,28 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
|
||||
com.droiddeck.launcher.gpu.FrameGen.hasGameOverride(context, it)
|
||||
} ?: false)
|
||||
}
|
||||
val scalingFilterChoices = SessionPrefs.upscalerChoices(context)
|
||||
var gameUpscaler by remember(frameGenProfileKey) {
|
||||
mutableStateOf(frameGenProfileKey?.let {
|
||||
SessionPrefs.screenEffectsUpscaler(context, "game:$it")
|
||||
} ?: SessionPrefs.upscaler(context))
|
||||
}
|
||||
var gameUpscalerOverride by remember(frameGenProfileKey) {
|
||||
mutableStateOf(frameGenProfileKey?.let { SessionPrefs.hasGameUpscalerOverride(context, it) } ?: false)
|
||||
}
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
DisposableEffect(lifecycleOwner, frameGenProfileKey) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_RESUME) {
|
||||
frameGenProfileKey?.let { key ->
|
||||
gameUpscaler = SessionPrefs.screenEffectsUpscaler(context, "game:$key")
|
||||
gameUpscalerOverride = SessionPrefs.hasGameUpscalerOverride(context, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
lifecycleOwner.lifecycle.addObserver(observer)
|
||||
onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
|
||||
}
|
||||
var wincompOpen by remember(wincompKey) { mutableStateOf<Boolean?>(null) }
|
||||
val wincompPicks = remember(wincompKey, wincompOpen) { wincompKey?.let { com.droiddeck.launcher.session.WinComponents.picks(context, it) }.orEmpty() }
|
||||
val steamScope = game?.let { com.droiddeck.launcher.session.NoSteamLaunch.scope(it) }
|
||||
@@ -914,6 +936,25 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
|
||||
},
|
||||
)
|
||||
}
|
||||
val scalingFilterMenuContent: @Composable () -> Unit = {
|
||||
val key = frameGenProfileKey
|
||||
if (key != null) ScalingFilterMenu(
|
||||
mode = gameUpscaler,
|
||||
options = scalingFilterChoices,
|
||||
hasGameOverride = gameUpscalerOverride,
|
||||
onPick = { mode ->
|
||||
SessionPrefs.setGameUpscaler(context, key, mode)
|
||||
gameUpscaler = SessionPrefs.screenEffectsUpscaler(context, "game:$key")
|
||||
gameUpscalerOverride = SessionPrefs.hasGameUpscalerOverride(context, key)
|
||||
},
|
||||
onResetGame = {
|
||||
SessionPrefs.clearGameUpscaler(context, key)
|
||||
gameUpscaler = SessionPrefs.upscaler(context)
|
||||
gameUpscalerOverride = false
|
||||
},
|
||||
gameName = game?.name,
|
||||
)
|
||||
}
|
||||
val cards = if (game?.library == com.droiddeck.launcher.frontend.Library.EPIC_LAUNCHER) listOfNotNull(steamCard) else buildList<@Composable (Modifier) -> Unit> {
|
||||
add { m ->
|
||||
val back = stringResource(R.string.hop_from_games)
|
||||
@@ -938,6 +979,17 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
|
||||
|
||||
}
|
||||
}
|
||||
if (frameGenProfileKey != null) add { m ->
|
||||
Box(m) {
|
||||
SettingCard(
|
||||
stringResource(R.string.display_filter),
|
||||
scalingFilterChoices.firstOrNull { it.first == gameUpscaler }?.second ?: scalingFilterChoices.first().second,
|
||||
"card:scaling-filter", Modifier.fillMaxSize(),
|
||||
) {
|
||||
host.open = if (host.open == "scaling-filter") null else "scaling-filter"
|
||||
}
|
||||
}
|
||||
}
|
||||
if (controller != null) add { m -> SettingCard(stringResource(R.string.setup_card_controls), stringResource(R.string.setup_card_controls_hint), "card:controls", m, controller.onMapping) }
|
||||
if (steamCard != null) add(steamCard)
|
||||
val cardStore = com.droiddeck.launcher.stores.Store.byId(game?.source.orEmpty())?.takeIf { it == com.droiddeck.launcher.stores.Store.EPIC || it == com.droiddeck.launcher.stores.Store.GOG }
|
||||
@@ -972,6 +1024,11 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
|
||||
frameGenMenuContent()
|
||||
}
|
||||
}
|
||||
if (host.open == "scaling-filter") {
|
||||
Box(Modifier.fillMaxWidth().padding(top = 4.dp)) {
|
||||
scalingFilterMenuContent()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -308,7 +308,8 @@ internal fun SecondaryButton(text: String, enabled: Boolean = true, compact: Boo
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = modifier.paneItem("btn:$text").downToFirstTile().heightIn(min = if (pill) 40.dp else if (compact) 44.dp else 48.dp).graphicsLayer { scaleX = scale; scaleY = scale }.clip(shape).background(fill).glideBorder(hot, shape, pal.signal, if (pill) Color.White.copy(alpha = 0.14f) else pal.line2)
|
||||
.alpha(if (enabled) 1f else 0.5f)
|
||||
// The label always gets a layer of its own: sharing one with the fill and outline, they did not draw under the agent's latest reply.
|
||||
.graphicsLayer { alpha = if (enabled) 1f else 0.5f }
|
||||
.hoverable(src).clickable(role = androidx.compose.ui.semantics.Role.Button, interactionSource = src, indication = LocalIndication.current, enabled = enabled, onClick = onClick)
|
||||
.controllerConfirm(enabled = enabled, onClick = onClick)
|
||||
.padding(horizontal = if (pill) 16.dp else if (compact) 10.dp else 16.dp, vertical = if (pill) 8.dp else if (compact) 7.dp else 11.dp),
|
||||
|
||||
@@ -396,7 +396,7 @@ private fun GameCapsule(scores: GameScores?, actions: @Composable () -> Unit) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun GameTabBar(
|
||||
internal fun GameTabBar(
|
||||
tabs: List<String>, selected: Int, onSelect: (Int) -> Unit,
|
||||
modifier: Modifier = Modifier, focusRequesters: List<FocusRequester>? = null,
|
||||
bumpers: Boolean = true, compact: Boolean = false,
|
||||
@@ -415,10 +415,6 @@ private fun GameTabBar(
|
||||
if (bumpers) TabBarBumper("LB", stringResource(R.string.widgets_prev_tab), leading = true) { onSelect((selected + tabs.size - 1) % tabs.size) }
|
||||
androidx.compose.foundation.layout.BoxWithConstraints(Modifier.weight(1f).clip(if (bumpers) RoundedCornerShape(BumperFlat) else CircleShape).onSizeChanged { viewport = it.width }) {
|
||||
val share = maxWidth / tabs.size.coerceAtLeast(1)
|
||||
if (tabsAsMenu(maxWidth, tabs.size)) {
|
||||
TabMenu(tabs, selected, onSelect, focus = focusRequesters)
|
||||
return@BoxWithConstraints
|
||||
}
|
||||
Box(Modifier.horizontalScroll(scroll)) {
|
||||
spans.getOrNull(selected)?.takeIf { tabHeight > 0 }?.let { span ->
|
||||
TabHighlight(span, tabHeight, flatStart = bumpers && selected == 0, flatEnd = bumpers && selected == tabs.lastIndex)
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.droiddeck.launcher.ui
|
||||
import android.text.format.DateUtils
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.hoverable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -26,8 +29,11 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -41,7 +47,7 @@ import com.droiddeck.launcher.lab.LabOverlay
|
||||
* [onRebuild] offers to build a kept one again for this install, when something can.
|
||||
*/
|
||||
@Composable
|
||||
internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay.Info) -> Unit)? = null) {
|
||||
internal fun LabBuilds(sessionRunning: Boolean = false, header: (@Composable () -> Unit)? = null, onRebuild: ((LabOverlay.Info) -> Unit)? = null) {
|
||||
val context = LocalContext.current
|
||||
var version by remember { mutableIntStateOf(0) }
|
||||
var busy by remember { mutableStateOf(false) }
|
||||
@@ -54,6 +60,7 @@ internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay.
|
||||
val paused = active == null && current != null && LabOverlay.skipped == LabOverlay.SKIPPED_APP_IMAGE
|
||||
val restartFailed = stringResource(R.string.lab_restart_failed)
|
||||
val canRestart = !busy && !sessionRunning
|
||||
var showKept by androidx.compose.runtime.saveable.rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
/** Android may have given the APK an app image again, which a Lab build cannot load over. */
|
||||
fun restart() {
|
||||
@@ -73,8 +80,8 @@ internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay.
|
||||
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Column(Modifier.fillMaxWidth().padding(top = 18.dp)) {
|
||||
Text(
|
||||
Column(Modifier.fillMaxWidth().padding(top = if (header == null) 18.dp else 0.dp)) {
|
||||
if (header != null) header() else Text(
|
||||
stringResource(R.string.lab_builds).uppercase(), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp,
|
||||
color = colors.onSurfaceVariant, modifier = Modifier.padding(start = 2.dp, top = 2.dp, bottom = 10.dp),
|
||||
)
|
||||
@@ -99,7 +106,29 @@ internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay.
|
||||
PrimaryButton(stringResource(R.string.lab_restart), compact = true, enabled = canRestart) { restart() }
|
||||
}
|
||||
}
|
||||
for (build in saved) rows += {
|
||||
val foldKept = (current != null || pending != null) && saved.isNotEmpty()
|
||||
if (foldKept) rows += {
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val toggle = { showKept = !showKept }
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth().paneItem("lab:kept")
|
||||
.background(if (rememberHot(src)) pal.signal.copy(alpha = 0.14f) else Color.Transparent)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = null, role = Role.Button, onClick = toggle)
|
||||
.controllerConfirm(onClick = toggle)
|
||||
.padding(horizontal = 14.dp, vertical = 12.dp),
|
||||
) {
|
||||
Text(
|
||||
pluralStringResource(R.plurals.lab_kept_count, saved.size, saved.size), fontSize = 14.sp,
|
||||
color = colors.onSurfaceVariant, modifier = Modifier.weight(1f),
|
||||
)
|
||||
Text(
|
||||
stringResource(if (showKept) R.string.common_hide else R.string.common_show), fontSize = 13.5.sp,
|
||||
fontWeight = FontWeight.SemiBold, color = pal.signal,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!foldKept || showKept) for (build in saved) rows += {
|
||||
var armed by remember(build.dir) { mutableStateOf(false) }
|
||||
val info = build.info
|
||||
BuildRow(
|
||||
|
||||
@@ -17,6 +17,7 @@ import androidx.compose.foundation.interaction.collectIsPressedAsState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxScope
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -204,9 +205,9 @@ internal object LibraryDisplay {
|
||||
val scales = listOf(0.75f, 0.875f, 1f, 1.2f, 1.45f)
|
||||
var level by mutableIntStateOf(DEFAULT_LEVEL)
|
||||
private set
|
||||
var title by mutableStateOf(true)
|
||||
var title by mutableStateOf(false)
|
||||
private set
|
||||
var size by mutableStateOf(true)
|
||||
var size by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
fun load(context: android.content.Context) {
|
||||
@@ -914,7 +915,7 @@ private fun sourceChipsShown(sources: List<String>, manage: Boolean): Boolean =
|
||||
|
||||
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun LibraryFilters(sources: List<String>, source: String, onSource: (String) -> Unit, manage: Boolean) {
|
||||
internal fun LibraryFilters(sources: List<String>, source: String, onSource: (String) -> Unit, manage: Boolean) {
|
||||
val chips = sourceChipsShown(sources, manage)
|
||||
if (!chips && !manage) return
|
||||
val pal = LocalPalette.current
|
||||
@@ -931,42 +932,54 @@ private fun LibraryFilters(sources: List<String>, source: String, onSource: (Str
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 4.dp, bottom = 2.dp),
|
||||
) {
|
||||
Box(Modifier.weight(1f).edgeFade(scroll).horizontalScroll(scroll)) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.focusGroup()) {
|
||||
for (id in keys) {
|
||||
val store = Store.byId(id)
|
||||
val dot = sourceDot(id)
|
||||
val label = when (id) {
|
||||
LIBRARY_ALL -> stringResource(R.string.stores_tab_all)
|
||||
Library.ADDED -> stringResource(R.string.library_custom_games)
|
||||
LIBRARY_FAVORITES -> stringResource(R.string.soundtracks_favorites)
|
||||
LIBRARY_HIDDEN -> stringResource(R.string.apps_filter_hidden)
|
||||
else -> store?.shortLabel ?: sourceLabel(id)
|
||||
}
|
||||
androidx.compose.runtime.key(id) {
|
||||
val reveal = remember { BringIntoViewRequester() }
|
||||
LaunchedEffect(source) { if (source == id) reveal.bringIntoView() }
|
||||
StoreChip(
|
||||
label = label, on = source == id, under = fillShown && highlighted == id, key = id, mark = dot ?: pal.signal,
|
||||
modifier = Modifier.bringIntoViewRequester(reveal).testTag("library-source-$id")
|
||||
.onGloballyPositioned { bounds[id] = it.boundsInParent() },
|
||||
lead = {
|
||||
if (dot != null) Box(Modifier.size(9.dp).background(dot, CircleShape))
|
||||
else Icon(Icons.Filled.GridView, null, modifier = Modifier.size(14.dp))
|
||||
},
|
||||
onFocused = { focused = it },
|
||||
paneKey = "libchip:$id",
|
||||
) { onSource(id) }
|
||||
BoxWithConstraints(Modifier.weight(1f)) {
|
||||
if (sourceTabsAsMenu(maxWidth, keys.size)) {
|
||||
TabMenu(
|
||||
keys.map { librarySourceChipLabel(it) }, keys.indexOf(source), { onSource(keys[it]) },
|
||||
chipModifier = Modifier.paneItem("libchip:$source"),
|
||||
leading = { i, _ -> LibrarySourceMark(sourceDot(keys[i])) },
|
||||
)
|
||||
} else Box(Modifier.edgeFade(scroll).horizontalScroll(scroll)) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.focusGroup()) {
|
||||
for (id in keys) {
|
||||
val dot = sourceDot(id)
|
||||
androidx.compose.runtime.key(id) {
|
||||
val reveal = remember { BringIntoViewRequester() }
|
||||
LaunchedEffect(source) { if (source == id) reveal.bringIntoView() }
|
||||
StoreChip(
|
||||
label = librarySourceChipLabel(id), on = source == id, under = fillShown && highlighted == id, key = id, mark = dot ?: pal.signal,
|
||||
modifier = Modifier.bringIntoViewRequester(reveal).testTag("library-source-$id")
|
||||
.onGloballyPositioned { bounds[id] = it.boundsInParent() },
|
||||
lead = { LibrarySourceMark(dot) },
|
||||
onFocused = { focused = it },
|
||||
paneKey = "libchip:$id",
|
||||
) { onSource(id) }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (highlighted in keys) ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint, visible = fillShown)
|
||||
}
|
||||
if (highlighted in keys) ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint, visible = fillShown)
|
||||
}
|
||||
if (manage) ManageStoresChip()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun librarySourceChipLabel(id: String): String = when (id) {
|
||||
LIBRARY_ALL -> stringResource(R.string.stores_tab_all)
|
||||
Library.ADDED -> stringResource(R.string.library_custom_games)
|
||||
LIBRARY_FAVORITES -> stringResource(R.string.soundtracks_favorites)
|
||||
LIBRARY_HIDDEN -> stringResource(R.string.apps_filter_hidden)
|
||||
else -> Store.byId(id)?.shortLabel ?: sourceLabel(id)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LibrarySourceMark(dot: Color?) {
|
||||
if (dot != null) Box(Modifier.size(9.dp).background(dot, CircleShape))
|
||||
else Icon(Icons.Filled.GridView, null, modifier = Modifier.size(14.dp))
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun sourceTitle(src: String): String = when (src) {
|
||||
LIBRARY_ALL -> stringResource(R.string.library_all_games)
|
||||
|
||||
@@ -87,7 +87,8 @@ class ModeSettings(
|
||||
val fexPreset: String? = null,
|
||||
val forceSsbs: Boolean = false,
|
||||
val syncBackend: String? = null,
|
||||
val picturePosition: String? = null,
|
||||
val picturePositionLandscape: String? = null,
|
||||
val picturePositionPortrait: String? = null,
|
||||
val integerScaling: Boolean? = null,
|
||||
val stretch16x9: Boolean? = null,
|
||||
val avoidNotch: Boolean? = null,
|
||||
@@ -152,7 +153,7 @@ class ModeSettingsActions(
|
||||
val onFexPreset: (String) -> Unit = {},
|
||||
val onForceSsbs: (Boolean) -> Unit = {},
|
||||
val onSyncBackend: (String) -> Unit = {},
|
||||
val onPicturePosition: (String) -> Unit = {},
|
||||
val onPicturePosition: (Boolean, String) -> Unit = { _, _ -> },
|
||||
val onIntegerScaling: (Boolean) -> Unit = {},
|
||||
val onStretch16x9: (Boolean) -> Unit = {},
|
||||
val onAvoidNotch: (Boolean) -> Unit = {},
|
||||
@@ -262,15 +263,16 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
ResolutionRow(host, "resolution-portrait", stringResource(R.string.display_resolution_portrait), s.resolutionPortrait, portraitChoice,
|
||||
com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE,
|
||||
if (sessionDisplay.isLink(s.resolution)) portraitChoice else sessionDisplay.orientCustom(s.resolution, true),
|
||||
s.panelSize, a.onResolutionPortrait, portrait = true)
|
||||
s.picturePosition?.let { position ->
|
||||
ChoiceRow(host, "picture-position", stringResource(R.string.display_picture_position), null,
|
||||
listOf("top" to stringResource(R.string.display_position_top),
|
||||
"bottom" to stringResource(R.string.display_position_bottom),
|
||||
"left" to stringResource(R.string.display_position_left),
|
||||
"right" to stringResource(R.string.display_position_right),
|
||||
"center" to stringResource(R.string.display_position_center)),
|
||||
position, onPick = a.onPicturePosition)
|
||||
s.panelSize, a.onResolutionPortrait, portrait = true,
|
||||
defaultChoice = if (s.mode == SessionService.MODE_STEAM) sessionDisplay.DEFAULT_STEAM_PORTRAIT_RESOLUTION
|
||||
else sessionDisplay.DEFAULT_RESOLUTION)
|
||||
s.picturePositionLandscape?.let { position ->
|
||||
PicturePositionRow(host, position, key = "picture-position-landscape",
|
||||
labelRes = R.string.display_picture_position_landscape) { a.onPicturePosition(false, it) }
|
||||
}
|
||||
s.picturePositionPortrait?.let { position ->
|
||||
PicturePositionRow(host, position, key = "picture-position-portrait",
|
||||
labelRes = R.string.display_picture_position_portrait) { a.onPicturePosition(true, it) }
|
||||
}
|
||||
if (s.stretch16x9 != null && (com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(s.panelSize) ||
|
||||
com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(displaySize))) {
|
||||
@@ -742,3 +744,22 @@ internal fun CustomFollowScaleDialog(initial: Float?, onSave: (Float) -> Unit, o
|
||||
dismissButton = { androidx.compose.material3.TextButton(onClick = onDismiss, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) } },
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun PicturePositionRow(
|
||||
host: MenuHost, position: String,
|
||||
chipModifier: Modifier = Modifier,
|
||||
key: String = "picture-position",
|
||||
@androidx.annotation.StringRes labelRes: Int = R.string.display_picture_position,
|
||||
onPick: (String) -> Unit,
|
||||
) {
|
||||
ChoiceRow(host, key, stringResource(labelRes), null,
|
||||
listOf(
|
||||
"center" to stringResource(R.string.display_position_center),
|
||||
"top" to stringResource(R.string.display_position_top),
|
||||
"bottom" to stringResource(R.string.display_position_bottom),
|
||||
"left" to stringResource(R.string.display_position_left),
|
||||
"right" to stringResource(R.string.display_position_right),
|
||||
),
|
||||
position, chipModifier = chipModifier, onPick = onPick)
|
||||
}
|
||||
@@ -16,12 +16,14 @@ fun ResolutionRow(
|
||||
panel: Pair<Int, Int>, onPick: (String) -> Unit,
|
||||
chipModifier: Modifier = Modifier,
|
||||
portrait: Boolean = false,
|
||||
defaultChoice: String = SessionDisplay.DEFAULT_RESOLUTION,
|
||||
) {
|
||||
val custom = "custom"
|
||||
val linked = stored == link
|
||||
val size = SessionDisplay.resolveChoice(panel, choice, portrait)
|
||||
val screen = SessionDisplay.resolveChoice(panel, SessionDisplay.MATCH_SCREEN, portrait)
|
||||
val choices = SessionDisplay.resolutionOptions(panel)
|
||||
val presets = SessionDisplay.resolutionOptions(panel)
|
||||
val choices = if (defaultChoice == SessionDisplay.DEFAULT_RESOLUTION) presets else listOf(defaultChoice) + presets
|
||||
val customFollow = !linked && SessionDisplay.isFollow(choice) && choice !in choices
|
||||
val selected = if (linked) link else if (SessionDisplay.isFollow(choice)) choice
|
||||
else if (size == screen) SessionDisplay.MATCH_SCREEN else choice
|
||||
@@ -36,7 +38,7 @@ fun ResolutionRow(
|
||||
else if (value == SessionDisplay.FOLLOW_SCREEN) stringResource(R.string.display_follow_screen)
|
||||
else if (SessionDisplay.isFollow(value)) stringResource(R.string.display_follow_screen_scaled,
|
||||
SessionDisplay.formatScale(SessionDisplay.followScale(value) ?: 1f)) + " (${dimensions.first}×${dimensions.second})"
|
||||
else if (value == SessionDisplay.DEFAULT_RESOLUTION) stringResource(R.string.mode_res_default, "${dimensions.first}×${dimensions.second}")
|
||||
else if (value == defaultChoice) stringResource(R.string.mode_res_default, "${dimensions.first}×${dimensions.second}")
|
||||
else "${dimensions.first}×${dimensions.second}"
|
||||
} + listOf(SessionDisplay.FOLLOW_CUSTOM to stringResource(R.string.display_follow_screen_scaled,
|
||||
if (customFollow) SessionDisplay.formatScale(SessionDisplay.followScale(choice) ?: 1f) else "…"
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.droiddeck.launcher.R
|
||||
|
||||
@Composable
|
||||
internal fun ScalingFilterMenu(
|
||||
mode: Int,
|
||||
options: List<Pair<Int, String>>,
|
||||
hasGameOverride: Boolean,
|
||||
onPick: (Int) -> Unit,
|
||||
onResetGame: () -> Unit,
|
||||
gameName: String? = null,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
Column(Modifier.fillMaxWidth().padding(start = 10.dp, end = 10.dp, bottom = 8.dp)) {
|
||||
val selectedLabel = options.firstOrNull { it.first == mode }?.second ?: mode.toString()
|
||||
Text(
|
||||
stringResource(
|
||||
if (hasGameOverride) R.string.display_filter_game_profile else R.string.display_filter_default_profile,
|
||||
if (hasGameOverride) gameName.orEmpty() else selectedLabel,
|
||||
selectedLabel,
|
||||
),
|
||||
color = colors.onSurfaceVariant,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.padding(bottom = 6.dp),
|
||||
)
|
||||
options.forEachIndexed { index, (option, label) ->
|
||||
val selected = mode == option
|
||||
val pick = { onPick(option) }
|
||||
OutlinedButton(
|
||||
onClick = pick,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.padding(top = if (index == 0) 0.dp else 6.dp)
|
||||
.controllerConfirm(onClick = pick),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
containerColor = if (selected) colors.primary.copy(alpha = 0.16f) else colors.surface,
|
||||
contentColor = if (selected) colors.primary else colors.onSurface,
|
||||
),
|
||||
) { Text(label) }
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.display_filter_note),
|
||||
color = colors.onSurfaceVariant,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.padding(top = 6.dp),
|
||||
)
|
||||
OutlinedButton(
|
||||
onClick = onResetGame,
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 6.dp)
|
||||
.controllerConfirm(onClick = onResetGame),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
) {
|
||||
Text(stringResource(R.string.comp_game_use_general) + if (hasGameOverride) "" else " ✓")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import androidx.compose.material.icons.outlined.Tune
|
||||
import androidx.lifecycle.setViewTreeLifecycleOwner
|
||||
import androidx.lifecycle.setViewTreeViewModelStoreOwner
|
||||
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
||||
import com.droiddeck.launcher.input.ControllerPrefs
|
||||
import com.droiddeck.launcher.input.DeckPanel
|
||||
import com.droiddeck.launcher.input.KeyboardHost
|
||||
import com.droiddeck.launcher.input.PadBridge
|
||||
@@ -397,6 +398,7 @@ class SecondScreenPresentation(
|
||||
val layout = panelLayout(mode)
|
||||
val controls = InputSurfaceView(context, pad, layout?.elements.orEmpty(),
|
||||
surfaceStyle = layout?.style ?: com.droiddeck.launcher.input.InputSurfaceStyle())
|
||||
controls.alpha = ControllerPrefs.onScreenOpacity(context) / 100f
|
||||
controlsView = controls
|
||||
root.addView(controls, weightParams())
|
||||
attachKeyboard()
|
||||
|
||||
@@ -16,11 +16,15 @@ import androidx.compose.ui.input.key.key
|
||||
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||
import androidx.compose.ui.input.key.type
|
||||
import androidx.compose.ui.layout.LayoutCoordinates
|
||||
import androidx.compose.ui.unit.Constraints
|
||||
import androidx.compose.ui.layout.Layout
|
||||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
import androidx.compose.ui.unit.IntSize
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import kotlin.math.roundToInt
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -73,6 +77,7 @@ import androidx.compose.foundation.interaction.PressInteraction
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
@@ -82,6 +87,7 @@ import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.systemGestureExclusion
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
@@ -89,6 +95,7 @@ import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Slider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -109,6 +116,7 @@ import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.droiddeck.launcher.HomeApp
|
||||
import com.droiddeck.launcher.input.ControllerPrefs
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.animation.core.Spring
|
||||
@@ -269,6 +277,8 @@ class DrawerActions(
|
||||
val upscaleSharpness: Int = 75,
|
||||
val integerScaling: Boolean = false,
|
||||
val onIntegerScaling: (Boolean) -> Unit = {},
|
||||
val picturePosition: String = "center",
|
||||
val onPicturePosition: (String) -> Unit = {},
|
||||
val gameZoomAvailable: Boolean = false,
|
||||
val gameZoom: Float = 1.0f,
|
||||
val onGameZoom: (Float) -> Unit = {},
|
||||
@@ -331,6 +341,7 @@ class DrawerActions(
|
||||
val onEditSteamTouch: (() -> Unit)? = null,
|
||||
val controller: com.droiddeck.launcher.input.ControllerPrefs.Settings? = null,
|
||||
val onControllerSize: (Int) -> Unit = {},
|
||||
val onControllerOpacity: (Int) -> Unit = {},
|
||||
val onRumble: (Boolean) -> Unit = {},
|
||||
val onSuspendPolicy: (String) -> Unit,
|
||||
val onSteamDownloadsInBackground: (Boolean) -> Unit = {},
|
||||
@@ -478,6 +489,13 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
}
|
||||
}
|
||||
LaunchedEffect(page) { host.open = null; appToChooseDisplay = null; managing = false }
|
||||
LaunchedEffect(host.open) {
|
||||
if (host.open == "frame-generation") repeat(24) {
|
||||
androidx.compose.runtime.withFrameNanos { }
|
||||
focus.request("frame-generation")
|
||||
if (focus.focused == "frame-generation") return@LaunchedEffect
|
||||
}
|
||||
}
|
||||
LaunchedEffect(a.selectedGameProfileId) {
|
||||
if (host.open == "fex") host.open = null
|
||||
}
|
||||
@@ -534,8 +552,8 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
}
|
||||
androidx.compose.foundation.layout.BoxWithConstraints(modifier = Modifier.fillMaxSize().exposeTestTags(), contentAlignment = Alignment.CenterEnd) {
|
||||
val short = maxHeight < 440.dp
|
||||
// The handle keeps a strip on the left free, so a sheet dragged wide can always be dragged back.
|
||||
val maxSheet = (maxWidth - DRAWER_EDGE_GAP).coerceAtLeast(0.dp)
|
||||
// At full width the handle's strip sits on the screen's left edge, so the sheet can still be dragged back.
|
||||
val maxSheet = (maxWidth - DRAWER_HANDLE_STRIP).coerceAtLeast(0.dp)
|
||||
val minSheet = minOf(DRAWER_MIN_WIDTH, maxSheet)
|
||||
val defaultSheet = minOf(420.dp, maxWidth * 0.92f)
|
||||
val sheetWidth = if (docked) maxWidth else (savedWidth?.dp ?: defaultSheet).coerceIn(minSheet, maxSheet)
|
||||
@@ -651,6 +669,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
val track: (String) -> Modifier = { key -> focus.track(page, key) }
|
||||
val sections = remember(page) { DrawerSections(drawerContext, track) }
|
||||
CompositionLocalProvider(LocalChipMinWidth provides 96.dp, LocalCompactSettings provides true, LocalDrawerSections provides sections) {
|
||||
DrawerColumns(two = sheetWidth >= DRAWER_TWO_COLUMN_WIDTH && page.inColumns) {
|
||||
when (page) {
|
||||
SessionDrawerPage.CONTROLLER -> DrawerControllerPage(host, a, a.controllerConnected || controllerActive, track)
|
||||
SessionDrawerPage.HUD -> DrawerPerformancePage(host, a, track)
|
||||
@@ -667,6 +686,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
SessionDrawerPage.ACHIEVEMENTS -> a.achievementsGame?.let { DrawerAchievementsPage(it, a.achievementsTitle, track) }
|
||||
SessionDrawerPage.AGENT -> Unit
|
||||
}
|
||||
}
|
||||
} }
|
||||
}
|
||||
}
|
||||
@@ -747,6 +767,9 @@ private fun DrawerControllerPage(host: MenuHost, a: DrawerActions, padConnected:
|
||||
c?.let {
|
||||
SliderRow(stringResource(R.string.ctrl_size), null, it.size, 80..125, step = 5,
|
||||
format = { v -> "$v%" }, modifier = track("controller-size"), onChange = a.onControllerSize)
|
||||
SliderRow(stringResource(R.string.ctrl_opacity), null, it.onScreenOpacity, ControllerPrefs.onScreenOpacityRange, step = 5,
|
||||
format = { v -> "$v%" }, modifier = track("controller-opacity").testTag("controller-opacity"),
|
||||
onChange = a.onControllerOpacity)
|
||||
}
|
||||
a.adaptiveSticks?.let { adaptive ->
|
||||
ToggleRow(host, "adaptive-sticks", stringResource(R.string.ctrl_adaptive), null, adaptive,
|
||||
@@ -903,33 +926,42 @@ private fun DrawerPerformancePage(host: MenuHost, a: DrawerActions, track: (Stri
|
||||
|
||||
|
||||
@Composable
|
||||
private fun DrawerFrameGenPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
|
||||
private fun DrawerFrameGenSettings(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
|
||||
val fgLabel = FrameGen.label(LocalContext.current, a.frameGen)
|
||||
val scope = if (a.frameGenTargetGameId != null)
|
||||
"${stringResource(R.string.frame_gen_scope_game)} · ${a.frameGenTargetGameName ?: "ID ${a.frameGenTargetGameId}"}"
|
||||
else stringResource(R.string.frame_gen_scope_global)
|
||||
|
||||
SettingsGroup(stringResource(R.string.frame_gen_title), compact = true, key = "frame-generation", detail = summary(fgLabel, scope)) {
|
||||
SettingsRow(stringResource(R.string.frame_gen_title), scope, stacked = true, tightControlSpacing = true) {
|
||||
FrameGenMenu(
|
||||
a.frameGen, a.lossless, a.onFrameGenPick,
|
||||
gameProfileId = a.frameGenTargetGameId,
|
||||
hasGameOverride = a.hasGameOverride,
|
||||
onResetGame = a.onFrameGenReset,
|
||||
)
|
||||
}
|
||||
FrameGenMenu(
|
||||
mode = a.frameGen,
|
||||
lossless = a.lossless,
|
||||
onPick = a.onFrameGenPick,
|
||||
|
||||
gameProfileId = a.frameGenTargetGameId,
|
||||
hasGameOverride = a.hasGameOverride,
|
||||
onResetGame = a.onFrameGenReset,
|
||||
focusModifier = track("frame-generation"),
|
||||
sessionHost = host,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun DrawerFrameGenPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
|
||||
DrawerFrameGenSettings(host, a, track)
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
private fun DrawerDisplayPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
|
||||
val orientations = SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) }
|
||||
SettingsGroup(stringResource(R.string.drawer_page_display), key = "display",
|
||||
detail = summary(if (a.gameZoomAvailable) "${(a.gameZoom * 100.0f).toInt()}%" else null, orientations.labelOf(a.orientation))) {
|
||||
if (a.gameZoomAvailable) GameZoomRow(a, track)
|
||||
if (a.gameZoomAvailable) GameZoomRow(a.gameZoom, track, a.onGameZoom)
|
||||
ChoiceRow(host, "orientation", stringResource(R.string.setup_session_orientation), null,
|
||||
orientations, a.orientation, chipModifier = track("orientation"), onPick = a.onOrientation)
|
||||
if (a.steam) PicturePositionRow(host, a.picturePosition, track("picture-position"), onPick = a.onPicturePosition)
|
||||
}
|
||||
val filters = SessionPrefs.upscalerChoices(LocalContext.current)
|
||||
val integer = stringResource(if (a.integerScaling) R.string.display_scaling_integer else R.string.display_scaling_fit)
|
||||
@@ -948,27 +980,66 @@ private fun DrawerDisplayPage(host: MenuHost, a: DrawerActions, track: (String)
|
||||
SecondScreenGroup(host, a, track)
|
||||
}
|
||||
|
||||
private const val GAME_ZOOM_MIN = 100
|
||||
private const val GAME_ZOOM_MAX = 300
|
||||
private const val GAME_ZOOM_STEP = 25
|
||||
private const val GAME_ZOOM_INTERVALS = (GAME_ZOOM_MAX - GAME_ZOOM_MIN) / GAME_ZOOM_STEP
|
||||
|
||||
@Composable
|
||||
private fun GameZoomRow(a: DrawerActions, track: (String) -> Modifier) {
|
||||
SettingsRow(stringResource(R.string.game_zoom_title), stringResource(R.string.game_zoom_hint)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
val zoomOutEnabled = a.gameZoom > 1.0f
|
||||
val zoomInEnabled = a.gameZoom < 3.0f
|
||||
val zoomOut = { a.onGameZoom((a.gameZoom - 0.25f).coerceAtLeast(1.0f)) }
|
||||
val zoomIn = { a.onGameZoom((a.gameZoom + 0.25f).coerceAtMost(3.0f)) }
|
||||
val zoomReset = { a.onGameZoom(1.0f) }
|
||||
OutlinedButton(onClick = zoomOut, enabled = zoomOutEnabled,
|
||||
modifier = track("game-zoom-out").width(42.dp).controllerConfirm(enabled = zoomOutEnabled, onClick = zoomOut),
|
||||
contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp)) { Text("−") }
|
||||
Text("${(a.gameZoom * 100.0f).toInt()}%", fontSize = 12.sp)
|
||||
OutlinedButton(onClick = zoomIn, enabled = zoomInEnabled,
|
||||
modifier = track("game-zoom-in").width(42.dp).controllerConfirm(enabled = zoomInEnabled, onClick = zoomIn),
|
||||
contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp)) { Text("+") }
|
||||
OutlinedButton(onClick = zoomReset, enabled = zoomOutEnabled,
|
||||
modifier = track("game-zoom-reset").width(48.dp).controllerConfirm(enabled = zoomOutEnabled, onClick = zoomReset),
|
||||
contentPadding = PaddingValues(horizontal = 2.dp, vertical = 0.dp)) { Text("1×") }
|
||||
}
|
||||
internal fun GameZoomRow(
|
||||
zoom: Float,
|
||||
track: (String) -> Modifier,
|
||||
onZoom: (Float) -> Unit,
|
||||
) {
|
||||
val source = remember { MutableInteractionSource() }
|
||||
val focused by source.collectIsFocusedAsState()
|
||||
val label = stringResource(R.string.game_zoom_title)
|
||||
val percent = (zoom * 100f).roundToInt().coerceIn(GAME_ZOOM_MIN, GAME_ZOOM_MAX)
|
||||
val value = stringResource(R.string.game_zoom_value, percent)
|
||||
fun detent(value: Float): Int = ((value - GAME_ZOOM_MIN) / GAME_ZOOM_STEP).roundToInt()
|
||||
val selectedDetent = detent(percent.toFloat())
|
||||
val rtl = LocalLayoutDirection.current == LayoutDirection.Rtl
|
||||
val pal = LocalPalette.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
|
||||
fun chooseDetent(index: Int) {
|
||||
val next = GAME_ZOOM_MIN + index.coerceIn(0, GAME_ZOOM_INTERVALS) * GAME_ZOOM_STEP
|
||||
if (next != percent) onZoom(next / 100f)
|
||||
}
|
||||
Column(Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 6.dp)) {
|
||||
Row(
|
||||
Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
) {
|
||||
Text(label, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground)
|
||||
Text(value, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold,
|
||||
color = colors.onSurface, modifier = Modifier.testTag("game-zoom-value"))
|
||||
}
|
||||
Slider(
|
||||
value = (GAME_ZOOM_MIN + selectedDetent * GAME_ZOOM_STEP).toFloat(),
|
||||
onValueChange = { chooseDetent(detent(it)) },
|
||||
valueRange = GAME_ZOOM_MIN.toFloat()..GAME_ZOOM_MAX.toFloat(),
|
||||
steps = GAME_ZOOM_INTERVALS - 1,
|
||||
interactionSource = source,
|
||||
modifier = track("game-zoom-slider").fillMaxWidth().heightIn(min = 48.dp)
|
||||
.glideBorder(focused, RoundedCornerShape(10.dp), pal.signal)
|
||||
.testTag("game-zoom-slider")
|
||||
.semantics { contentDescription = label; stateDescription = value }
|
||||
.onPreviewKeyEvent { event ->
|
||||
val delta = when (event.key) {
|
||||
Key.DirectionLeft -> if (rtl) 1 else -1
|
||||
Key.DirectionRight -> if (rtl) -1 else 1
|
||||
else -> return@onPreviewKeyEvent false
|
||||
}
|
||||
if (event.type == KeyEventType.KeyDown && event.nativeKeyEvent.repeatCount == 0) {
|
||||
chooseDetent(selectedDetent + delta)
|
||||
}
|
||||
true
|
||||
},
|
||||
)
|
||||
}
|
||||
Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line))
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -1491,7 +1562,44 @@ internal fun secondScreenModes(none: Boolean, deckPad: Boolean, dashboard: Boole
|
||||
|
||||
private val DRAWER_MIN_WIDTH = 300.dp
|
||||
private val DRAWER_HANDLE_STRIP = 24.dp
|
||||
private val DRAWER_EDGE_GAP = 80.dp
|
||||
private val DRAWER_COLUMN_GAP = 10.dp
|
||||
// Two columns once each would be as wide as the narrowest single-column sheet.
|
||||
private val DRAWER_TWO_COLUMN_WIDTH = DRAWER_MIN_WIDTH * 2 + DRAWER_COLUMN_GAP
|
||||
|
||||
private val SessionDrawerPage.inColumns: Boolean
|
||||
get() = this != SessionDrawerPage.MORE && this != SessionDrawerPage.ACHIEVEMENTS
|
||||
|
||||
/**
|
||||
* On a wide sheet, lays a page's groups out in two columns, the first half on the left. The split is by count, not
|
||||
* height, so a group keeps its column while others fold and unfold.
|
||||
*/
|
||||
@Composable
|
||||
internal fun DrawerColumns(two: Boolean, content: @Composable () -> Unit) {
|
||||
// Keep a single composition so resizing only remeasures existing children.
|
||||
Layout(content, Modifier.fillMaxWidth()) { measurables, constraints ->
|
||||
val width = constraints.maxWidth
|
||||
if (!two || measurables.size < 2) {
|
||||
val placeables = measurables.map { it.measure(constraints.copy(minWidth = 0, minHeight = 0)) }
|
||||
return@Layout layout(width, placeables.sumOf { it.height }) {
|
||||
var y = 0
|
||||
placeables.forEach { it.placeRelative(0, y); y += it.height }
|
||||
}
|
||||
}
|
||||
val gap = DRAWER_COLUMN_GAP.roundToPx()
|
||||
val column = ((width - gap) / 2).coerceAtLeast(0)
|
||||
val child = Constraints(maxWidth = column)
|
||||
val placeables = measurables.map { it.measure(child) }
|
||||
val half = (placeables.size + 1) / 2
|
||||
val left = placeables.take(half)
|
||||
val right = placeables.drop(half)
|
||||
layout(width, maxOf(left.sumOf { it.height }, right.sumOf { it.height })) {
|
||||
var y = 0
|
||||
left.forEach { it.placeRelative(0, y); y += it.height }
|
||||
y = 0
|
||||
right.forEach { it.placeRelative(column + gap, y); y += it.height }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** A grip on the sheet's left edge: dragging it, or pressing left and right on a controller, resizes the sheet. */
|
||||
@Composable
|
||||
@@ -1513,6 +1621,8 @@ private fun DrawerResizeHandle(width: Dp, min: Dp, max: Dp, onWidth: (Dp) -> Uni
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = modifier.width(24.dp).height(96.dp)
|
||||
.onGloballyPositioned { coords = it }
|
||||
// On the screen's edge, Android's back swipe would take the drag.
|
||||
.systemGestureExclusion()
|
||||
.focusable(true, source)
|
||||
.onPreviewKeyEvent { event ->
|
||||
val key = event.nativeKeyEvent
|
||||
@@ -1826,7 +1936,7 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
}
|
||||
return
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components") {
|
||||
DrawerComponentSettingsGroup(stringResource(R.string.drawer_game_components_note, gameProfile.name)) {
|
||||
DrawerStackedChoice(
|
||||
host = host,
|
||||
key = "game-cmp-proton",
|
||||
@@ -1869,12 +1979,6 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.drawer_game_components_note, gameProfile.name),
|
||||
fontSize = 12.sp,
|
||||
color = colors.onSurfaceVariant,
|
||||
modifier = Modifier.padding(horizontal = 4.dp, vertical = 12.dp),
|
||||
)
|
||||
return
|
||||
}
|
||||
val running = snap.protons.filter { it.inUseByGame }
|
||||
@@ -1915,7 +2019,7 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
return
|
||||
}
|
||||
val p = view.proton
|
||||
SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components") {
|
||||
DrawerComponentSettingsGroup(stringResource(R.string.drawer_components_note)) {
|
||||
DrawerStackedChoice(
|
||||
host, "cmp-proton", stringResource(R.string.comp_proton),
|
||||
listOfNotNull(
|
||||
@@ -1951,10 +2055,16 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.drawer_components_note),
|
||||
fontSize = 12.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 4.dp, vertical = 12.dp),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun DrawerComponentSettingsGroup(note: String, content: @Composable ColumnScope.() -> Unit) {
|
||||
// The note stays visible when collapsed, but both belong to one drawer column item.
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components", content = content)
|
||||
Text(note, fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(horizontal = 4.dp, vertical = 12.dp))
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.os.SystemClock
|
||||
import androidx.compose.animation.core.Animatable
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.relocation.BringIntoViewRequester
|
||||
import androidx.compose.foundation.relocation.bringIntoViewRequester
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
|
||||
/** The row a settings search result opens, so the page it lands on can scroll to it and flash it. */
|
||||
internal object SettingsJump {
|
||||
class Target(val label: String, val at: Long = SystemClock.uptimeMillis())
|
||||
|
||||
var target: Target? by mutableStateOf(null)
|
||||
|
||||
fun to(label: String) { target = Target(label) }
|
||||
}
|
||||
|
||||
private const val JUMP_WINDOW_MS = 5_000L
|
||||
|
||||
/** False in the search results, whose rows carry the same labels as the rows they open. */
|
||||
internal val LocalSearchTargets = staticCompositionLocalOf { true }
|
||||
|
||||
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
internal fun Modifier.searchTarget(label: String): Modifier {
|
||||
val pal = LocalPalette.current
|
||||
val flash = remember { Animatable(0f) }
|
||||
val reveal = remember { BringIntoViewRequester() }
|
||||
var claimed by remember { mutableStateOf<SettingsJump.Target?>(null) }
|
||||
val target = SettingsJump.target.takeIf { LocalSearchTargets.current }
|
||||
if (target != null && target.label == label) SideEffect {
|
||||
if (SettingsJump.target === target) {
|
||||
SettingsJump.target = null
|
||||
if (SystemClock.uptimeMillis() - target.at <= JUMP_WINDOW_MS) claimed = target
|
||||
}
|
||||
}
|
||||
claimed?.let { mine ->
|
||||
LaunchedEffect(mine) {
|
||||
withFrameNanos { }
|
||||
reveal.bringIntoView()
|
||||
repeat(2) {
|
||||
flash.animateTo(1f, tween(220))
|
||||
flash.animateTo(0f, tween(420))
|
||||
}
|
||||
claimed = null
|
||||
}
|
||||
}
|
||||
return bringIntoViewRequester(reveal).drawBehind {
|
||||
if (flash.value > 0f) drawRect(pal.signal.copy(alpha = 0.28f * flash.value))
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ internal fun SettingsSearchResults(query: String, frost: Boolean, onOpen: (Setti
|
||||
Note(stringResource(R.string.settings_search_none, query.trim()))
|
||||
return
|
||||
}
|
||||
Column {
|
||||
androidx.compose.runtime.CompositionLocalProvider(LocalSearchTargets provides false) { Column {
|
||||
found.groupBy { it.place }.forEach { (place, entries) ->
|
||||
SettingsGroup(stringResource(place.title)) {
|
||||
entries.forEach { entry ->
|
||||
@@ -112,9 +112,10 @@ internal fun SettingsSearchResults(query: String, frost: Boolean, onOpen: (Setti
|
||||
val section = entry.section
|
||||
val tab = entry.tab
|
||||
if (section != null) {
|
||||
ActionRow(title, within, stringResource(R.string.store_open), onClick = { onOpen(section) })
|
||||
ActionRow(title, within, stringResource(R.string.store_open), onClick = { SettingsJump.to(title); onOpen(section) })
|
||||
} else if (tab != null) {
|
||||
ActionRow(title, within, stringResource(R.string.store_open), onClick = {
|
||||
SettingsJump.to(title)
|
||||
if (tab == NavTabs.MORE) MoreTabs.editing = true
|
||||
if (tab == "downloads") DownloadsNav.showSettings = true
|
||||
RailRequest.key = tab
|
||||
@@ -125,5 +126,5 @@ internal fun SettingsSearchResults(query: String, frost: Boolean, onOpen: (Setti
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} }
|
||||
}
|
||||
@@ -536,7 +536,7 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint
|
||||
minLines = hintLines ?: 1, maxLines = hintLines ?: Int.MAX_VALUE, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
if (compact && !stacked) Column(
|
||||
modifier = Modifier.fillMaxWidth().background(bg).padding(horizontal = 10.dp, vertical = 6.dp),
|
||||
modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding(horizontal = 10.dp, vertical = 6.dp),
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text(label, fontSize = 13.sp, lineHeight = 16.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground,
|
||||
@@ -545,7 +545,7 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint
|
||||
}
|
||||
if (hint != null || hintLines != null) hintText(11.sp)
|
||||
} else if (stacked || LocalNarrowPane.current) Column(
|
||||
modifier = Modifier.fillMaxWidth().background(bg).padding(
|
||||
modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding(
|
||||
horizontal = if (compact) 10.dp else 14.dp,
|
||||
vertical = if (tightControlSpacing) 2.dp else if (compact) 6.dp else 12.dp),
|
||||
) {
|
||||
@@ -556,7 +556,7 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint
|
||||
Box(Modifier.padding(top = if (tightControlSpacing) 2.dp else if (compact) 6.dp else 8.dp)) { control() }
|
||||
} else Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth().background(bg).padding(horizontal = 14.dp, vertical = 11.dp),
|
||||
modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding(horizontal = 14.dp, vertical = 11.dp),
|
||||
) {
|
||||
Column(modifier = Modifier.weight(1f).padding(end = 12.dp)) {
|
||||
Text(label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground)
|
||||
@@ -660,7 +660,7 @@ fun SliderRow(
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
Column(Modifier.searchTarget(label).fillMaxWidth()) {
|
||||
ValueSlider(value, range, step, enabled, label, format,
|
||||
modifier = modifier.padding(horizontal = 6.dp, vertical = 3.dp), onChange = onChange)
|
||||
if (hint != null) Text(hint, fontSize = 12.5.sp, color = colors.onSurfaceVariant,
|
||||
|
||||
@@ -453,7 +453,7 @@ private fun StoreDot(store: Store, signedIn: Boolean) {
|
||||
|
||||
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun StoreChips(
|
||||
internal fun StoreChips(
|
||||
selected: String, focused: String?, tabs: List<StoreTab>,
|
||||
onStore: (Store) -> Unit, onSettings: (Rect?) -> Unit, onFocusChip: (String?) -> Unit,
|
||||
) {
|
||||
@@ -471,41 +471,41 @@ private fun StoreChips(
|
||||
Box(Modifier.fillMaxWidth()) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(gap), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
|
||||
val shown = tabs.filter { it.shown }.map { it.store }
|
||||
androidx.compose.foundation.layout.BoxWithConstraints(Modifier.weight(1f)) {
|
||||
if (tabsAsMenu(maxWidth, shown.size)) TabMenu(
|
||||
shown.map { it.shortLabel }, shown.indexOfFirst { it.id == selected }, { onStore(shown[it]) },
|
||||
chipModifier = shown.fold(Modifier as Modifier) { m, st -> key(st) { m.paneItem("storechip:${st.id}") } },
|
||||
descriptions = shown.map { st ->
|
||||
val signedIn = StoresState.isSignedIn(st) && StoresState.expired[st] != true
|
||||
st.label + if (signedIn || !StoresState.accountsLoaded) "" else " " + stringResource(R.string.stores_chip_signed_out)
|
||||
},
|
||||
leading = { i, inList ->
|
||||
val signedIn = StoresState.isSignedIn(shown[i]) && StoresState.expired[shown[i]] != true
|
||||
if (inList) Box(Modifier.size(12.dp).background(sourceColours(shown[i].id).dot.copy(alpha = if (signedIn) 1f else 0.35f), CircleShape))
|
||||
else StoreDot(shown[i], signedIn)
|
||||
},
|
||||
) else Box(Modifier.edgeFade(tabScroll).horizontalScroll(tabScroll)) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(gap), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.focusGroup()) {
|
||||
for (tab in tabs) {
|
||||
val store = tab.store
|
||||
if (tab.shown) {
|
||||
val signedIn = StoresState.isSignedIn(store) && StoresState.expired[store] != true
|
||||
key(store) {
|
||||
val reveal = remember { BringIntoViewRequester() }
|
||||
LaunchedEffect(selected) { if (selected == store.id) reveal.bringIntoView() }
|
||||
StoreChip(
|
||||
label = store.shortLabel, on = selected == store.id, under = fillShown && highlighted == store.id, key = store.id, mark = sourceColours(store.id).dot,
|
||||
modifier = Modifier.bringIntoViewRequester(reveal).onGloballyPositioned { bounds[store.id] = it.boundsInParent() },
|
||||
lead = { StoreDot(store, signedIn) },
|
||||
description = store.label + if (signedIn || !StoresState.accountsLoaded) "" else " " + stringResource(R.string.stores_chip_signed_out),
|
||||
onFocused = onFocusChip,
|
||||
) { onStore(store) }
|
||||
BoxWithConstraints(Modifier.weight(1f)) {
|
||||
if (sourceTabsAsMenu(maxWidth, shown.size)) TabMenu(
|
||||
shown.map { it.shortLabel }, shown.indexOfFirst { it.id == selected }, { onStore(shown[it]) },
|
||||
chipModifier = shown.fold(Modifier as Modifier) { m, st -> key(st) { m.paneItem("storechip:${st.id}") } },
|
||||
descriptions = shown.map { st ->
|
||||
val signedIn = StoresState.isSignedIn(st) && StoresState.expired[st] != true
|
||||
st.label + if (signedIn || !StoresState.accountsLoaded) "" else " " + stringResource(R.string.stores_chip_signed_out)
|
||||
},
|
||||
leading = { i, inList ->
|
||||
val signedIn = StoresState.isSignedIn(shown[i]) && StoresState.expired[shown[i]] != true
|
||||
if (inList) Box(Modifier.size(12.dp).background(sourceColours(shown[i].id).dot.copy(alpha = if (signedIn) 1f else 0.35f), CircleShape))
|
||||
else StoreDot(shown[i], signedIn)
|
||||
},
|
||||
) else Box(Modifier.edgeFade(tabScroll).horizontalScroll(tabScroll)) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(gap), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.focusGroup()) {
|
||||
for (tab in tabs) {
|
||||
val store = tab.store
|
||||
if (tab.shown) {
|
||||
val signedIn = StoresState.isSignedIn(store) && StoresState.expired[store] != true
|
||||
key(store) {
|
||||
val reveal = remember { BringIntoViewRequester() }
|
||||
LaunchedEffect(selected) { if (selected == store.id) reveal.bringIntoView() }
|
||||
StoreChip(
|
||||
label = store.shortLabel, on = selected == store.id, under = fillShown && highlighted == store.id, key = store.id, mark = sourceColours(store.id).dot,
|
||||
modifier = Modifier.bringIntoViewRequester(reveal).onGloballyPositioned { bounds[store.id] = it.boundsInParent() },
|
||||
lead = { StoreDot(store, signedIn) },
|
||||
description = store.label + if (signedIn || !StoresState.accountsLoaded) "" else " " + stringResource(R.string.stores_chip_signed_out),
|
||||
onFocused = onFocusChip,
|
||||
) { onStore(store) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint, visible = fillShown)
|
||||
}
|
||||
ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint, visible = fillShown)
|
||||
}
|
||||
}
|
||||
var cogAt by remember { mutableStateOf<Rect?>(null) }
|
||||
Box(Modifier.onGloballyPositioned { cogAt = it.boundsInRoot() }) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.LocalIndication
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -30,6 +31,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
@@ -47,6 +49,11 @@ private val TAB_MIN_WIDTH = 96.dp
|
||||
internal fun tabsAsMenu(width: Dp, count: Int): Boolean =
|
||||
count > 2 && width < TAB_MENU_BELOW && width / count < TAB_MIN_WIDTH
|
||||
|
||||
@Composable
|
||||
internal fun sourceTabsAsMenu(width: Dp, count: Int): Boolean =
|
||||
count > 1 && (LocalConfiguration.current.orientation == Configuration.ORIENTATION_PORTRAIT ||
|
||||
(width < TAB_MENU_BELOW && width / count < TAB_MIN_WIDTH))
|
||||
|
||||
/**
|
||||
* Tabs as one chip naming the shown tab, which opens the list of them, as the second screen's
|
||||
* picker does. Each of [focus] lands on the chip, so callers that focus a tab still reach it.
|
||||
|
||||
@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@@ -114,36 +115,49 @@ internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
|
||||
Column(modifier = modifier) {
|
||||
BoxWithConstraints(Modifier.weight(1f).fillMaxWidth()) {
|
||||
val stacked = LocalNarrowPane.current || maxWidth < 600.dp
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) {
|
||||
val context = LocalContext.current
|
||||
val agentReady = com.droiddeck.launcher.agent.AgentHost.installed &&
|
||||
(com.droiddeck.launcher.agent.AgentSetup.ready || com.droiddeck.launcher.agent.AgentSetup.completed(context))
|
||||
val installed: @Composable () -> Unit = {
|
||||
SectionLabel(stringResource(R.string.upd_installed_label))
|
||||
InstalledCard(s, u, me)
|
||||
CheckRow(u, ua)
|
||||
SectionLabel(stringResource(R.string.upd_channel))
|
||||
if (stacked) {
|
||||
ChannelPicker(u, ua)
|
||||
Box(Modifier.height(14.dp))
|
||||
StatusPanel(s, u, ua, me)
|
||||
} else {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(18.dp)) {
|
||||
Box(Modifier.weight(1f)) { ChannelPicker(u, ua) }
|
||||
Box(Modifier.weight(1.15f)) { StatusPanel(s, u, ua, me) }
|
||||
}
|
||||
}
|
||||
SectionLabel(stringResource(R.string.upd_testers), top = 22.dp)
|
||||
ToggleRow(
|
||||
host, "build-watermark", stringResource(R.string.setup_build_watermark),
|
||||
stringResource(R.string.setup_build_watermark_hint), s.buildWatermark,
|
||||
) { a.onBuildWatermark() }
|
||||
val context = LocalContext.current
|
||||
val agentReady = com.droiddeck.launcher.agent.AgentHost.installed &&
|
||||
(com.droiddeck.launcher.agent.AgentSetup.ready || com.droiddeck.launcher.agent.AgentSetup.completed(context))
|
||||
LabBuilds(s.sessionRunning, onRebuild = if (agentReady) { info ->
|
||||
LabBuilds(s.sessionRunning, header = { SectionLabel(stringResource(R.string.lab_builds)) }, onRebuild = if (agentReady) { info ->
|
||||
com.droiddeck.launcher.agent.AgentHost.send(context, context.getString(R.string.agent_rebuild_lab, info.label))
|
||||
context.startActivity(android.content.Intent(context, com.droiddeck.launcher.FrontEndActivity::class.java)
|
||||
.putExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV, "agent")
|
||||
.addFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP or android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT))
|
||||
} else null)
|
||||
}
|
||||
val channel: @Composable () -> Unit = {
|
||||
SectionLabel(stringResource(R.string.upd_channel))
|
||||
ChannelPicker(u, ua) { StatusPanel(s, u, ua, me, embedded = it) }
|
||||
}
|
||||
val testers: @Composable () -> Unit = {
|
||||
SectionLabel(stringResource(R.string.upd_testers), top = 22.dp)
|
||||
ToggleRow(
|
||||
host, "build-watermark", stringResource(R.string.setup_build_watermark),
|
||||
stringResource(R.string.setup_build_watermark_hint), s.buildWatermark,
|
||||
) { a.onBuildWatermark() }
|
||||
}
|
||||
if (stacked) {
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) {
|
||||
installed()
|
||||
Box(Modifier.height(18.dp))
|
||||
channel()
|
||||
testers()
|
||||
}
|
||||
} else {
|
||||
Row(Modifier.fillMaxSize(), horizontalArrangement = Arrangement.spacedBy(24.dp)) {
|
||||
Column(Modifier.weight(1f).fillMaxHeight().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) {
|
||||
installed()
|
||||
testers()
|
||||
}
|
||||
Column(Modifier.weight(1.15f).fillMaxHeight().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) {
|
||||
channel()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (u.askPermission) AlertDialog(
|
||||
@@ -266,7 +280,7 @@ private fun CheckRow(u: UpdatesState, ua: UpdatesActions) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, me: AppUpdates.Installed) {
|
||||
private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, me: AppUpdates.Installed, embedded: Boolean = false) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val catalog = u.catalog
|
||||
@@ -292,13 +306,14 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m
|
||||
else -> Look(pal.good, stringResource(R.string.upd_current_status), stringResource(R.string.upd_current_headline, name), null)
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(18.dp),
|
||||
modifier = if (embedded) Modifier.fillMaxWidth().padding(start = 12.dp, end = 12.dp, bottom = 14.dp)
|
||||
else Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(18.dp),
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(7.dp)) {
|
||||
Box(Modifier.size(7.dp).clip(CircleShape).background(look.tint))
|
||||
Text(look.status, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = look.tint)
|
||||
}
|
||||
Text(look.headline, fontSize = 22.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, modifier = Modifier.padding(top = 4.dp))
|
||||
if (!embedded) Text(look.headline, fontSize = 22.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, modifier = Modifier.padding(top = 4.dp))
|
||||
if (offered) {
|
||||
val size = release!!.apk?.size?.takeIf { it > 0 }?.let { megabytes(it) }
|
||||
Text(
|
||||
@@ -419,7 +434,7 @@ private fun changeTitle(t: String): String =
|
||||
private fun megabytes(bytes: Long) = stringResource(R.string.upd_mb, ((bytes + 524_288) / 1_048_576).toInt())
|
||||
|
||||
@Composable
|
||||
private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions) {
|
||||
private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions, status: @Composable (embedded: Boolean) -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val catalog = u.catalog
|
||||
@@ -455,8 +470,9 @@ private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions) {
|
||||
}
|
||||
Text(hint, fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 4.dp))
|
||||
if (tests.isEmpty() && catalog != null && showTests) Text(stringResource(R.string.upd_tests_none), fontSize = 12.5.sp, color = colors.onSurfaceVariant)
|
||||
if (!listing) status(false)
|
||||
AnimatedVisibility(listing, enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) {
|
||||
TestList(tests, me, u, ua)
|
||||
TestList(tests, me, u, ua, status)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -675,7 +691,7 @@ private fun LinkPill(label: String, url: String) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TestList(tests: List<Release>, me: AppUpdates.Installed, u: UpdatesState, ua: UpdatesActions) {
|
||||
private fun TestList(tests: List<Release>, me: AppUpdates.Installed, u: UpdatesState, ua: UpdatesActions, status: @Composable (embedded: Boolean) -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
var query by rememberSaveable { mutableStateOf("") }
|
||||
val needle = query.trim().removePrefix("#").removePrefix("@")
|
||||
@@ -686,18 +702,25 @@ private fun TestList(tests: List<Release>, me: AppUpdates.Installed, u: UpdatesS
|
||||
val (ready, old) = matches.partition { it.versionCode >= me.versionCode }
|
||||
val followedOld = u.follow.channel == Channel.TEST && old.any { it.pr == u.follow.pr }
|
||||
var showOld by rememberSaveable { mutableStateOf(false) }
|
||||
Column(Modifier.padding(start = 18.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
if (tests.size > 5 || query.isNotEmpty()) AdbTextField(
|
||||
value = query, onValueChange = { query = it }, label = stringResource(R.string.upd_tests_find),
|
||||
keyboardType = KeyboardType.Text, imeAction = ImeAction.Search, compact = true, showLabel = false,
|
||||
placeholder = stringResource(R.string.upd_tests_find), modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
if (matches.isEmpty()) Text(stringResource(R.string.upd_tests_no_match), fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(4.dp))
|
||||
ready.forEach { t -> TestRow(t, u.follow.pr == t.pr && u.follow.channel == Channel.TEST) { ua.onFollow(Follow(Channel.TEST, t.pr)) } }
|
||||
if (old.isNotEmpty()) {
|
||||
MoreLink(stringResource(R.string.upd_tests_old, old.size, me.versionCode), "tests:old") { showOld = !showOld }
|
||||
if (showOld || followedOld || needle.isNotEmpty()) old.forEach { t ->
|
||||
TestRow(t, u.follow.pr == t.pr && u.follow.channel == Channel.TEST, tooOld = true) { ua.onFollow(Follow(Channel.TEST, t.pr)) }
|
||||
val oldShown = showOld || followedOld || needle.isNotEmpty()
|
||||
val followed = u.follow.pr.takeIf { u.follow.channel == Channel.TEST }
|
||||
val rowShown = followed != null && (ready.any { it.pr == followed } || (oldShown && old.any { it.pr == followed }))
|
||||
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
// A followed test's row carries the status; browsing Tests while following Stable or Preview shows it only for an install running or failed.
|
||||
if (if (followed != null) !rowShown else u.stage != null || u.error != null) status(false)
|
||||
Column(Modifier.padding(start = 18.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
if (tests.size > 5 || query.isNotEmpty()) AdbTextField(
|
||||
value = query, onValueChange = { query = it }, label = stringResource(R.string.upd_tests_find),
|
||||
keyboardType = KeyboardType.Text, imeAction = ImeAction.Search, compact = true, showLabel = false,
|
||||
placeholder = stringResource(R.string.upd_tests_find), modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
if (matches.isEmpty()) Text(stringResource(R.string.upd_tests_no_match), fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(4.dp))
|
||||
ready.forEach { t -> TestRow(t, followed == t.pr, status = status) { ua.onFollow(Follow(Channel.TEST, t.pr)) } }
|
||||
if (old.isNotEmpty()) {
|
||||
MoreLink(stringResource(R.string.upd_tests_old, old.size, me.versionCode), "tests:old") { showOld = !showOld }
|
||||
if (oldShown) old.forEach { t ->
|
||||
TestRow(t, followed == t.pr, tooOld = true, status = status) { ua.onFollow(Follow(Channel.TEST, t.pr)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -712,40 +735,46 @@ private fun RadioDot(selected: Boolean, size: androidx.compose.ui.unit.Dp = 22.d
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TestRow(t: Release, selected: Boolean, tooOld: Boolean = false, onClick: () -> Unit) {
|
||||
private fun TestRow(t: Release, selected: Boolean, tooOld: Boolean = false, status: @Composable (embedded: Boolean) -> Unit, onClick: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.fillMaxWidth().paneItem("test:${t.pr}")
|
||||
.heightIn(min = 52.dp)
|
||||
.clip(Shape12)
|
||||
.background(colors.surface).background(if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent)
|
||||
.glideBorder(hot, Shape12, pal.signal, pal.line)
|
||||
.alpha(if (tooOld && !selected) 0.6f else 1f)
|
||||
.hoverable(src)
|
||||
.clickable(interactionSource = src, indication = null, role = Role.RadioButton, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
Column(
|
||||
Modifier.fillMaxWidth().clip(Shape12).background(colors.surface)
|
||||
.glideBorder(hot, Shape12, pal.signal, if (selected) pal.signal.copy(alpha = 0.5f) else pal.line),
|
||||
) {
|
||||
Text("#${t.pr}", fontSize = 13.sp, fontWeight = FontWeight.Bold, color = if (selected) pal.signal else colors.onSurfaceVariant)
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(changeTitle(t.title.ifBlank { stringResource(R.string.upd_pr, t.pr) }), fontSize = 13.5.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
val detail = when {
|
||||
t.apk == null -> stringResource(R.string.upd_not_built)
|
||||
tooOld -> stringResource(R.string.upd_tests_old_row, t.versionCode)
|
||||
else -> stringResource(R.string.upd_updated, ago(t.builtAt.takeIf { it > 0 } ?: t.publishedAt))
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.fillMaxWidth().paneItem("test:${t.pr}")
|
||||
.heightIn(min = 52.dp)
|
||||
.background(if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent)
|
||||
.alpha(if (tooOld && !selected) 0.6f else 1f)
|
||||
.hoverable(src)
|
||||
.clickable(interactionSource = src, indication = null, role = Role.RadioButton, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
) {
|
||||
Text("#${t.pr}", fontSize = 13.sp, fontWeight = FontWeight.Bold, color = if (selected) pal.signal else colors.onSurfaceVariant)
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(changeTitle(t.title.ifBlank { stringResource(R.string.upd_pr, t.pr) }), fontSize = 13.5.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
val detail = when {
|
||||
t.apk == null -> stringResource(R.string.upd_not_built)
|
||||
tooOld -> stringResource(R.string.upd_tests_old_row, t.versionCode)
|
||||
else -> stringResource(R.string.upd_updated, ago(t.builtAt.takeIf { it > 0 } ?: t.publishedAt))
|
||||
}
|
||||
Text(
|
||||
listOfNotNull(detail, t.author.takeIf { it.isNotEmpty() }?.let { "@$it" }, t.shortCommit).joinToString(" · "),
|
||||
fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (t.newerCommitPushed) Text(stringResource(R.string.upd_newer_commit_short), fontSize = 12.sp, color = AttentionAmber, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
Text(
|
||||
listOfNotNull(detail, t.author.takeIf { it.isNotEmpty() }?.let { "@$it" }, t.shortCommit).joinToString(" · "),
|
||||
fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (t.newerCommitPushed) Text(stringResource(R.string.upd_newer_commit_short), fontSize = 12.sp, color = AttentionAmber, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
RadioDot(selected, 20.dp)
|
||||
}
|
||||
AnimatedVisibility(selected, enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) {
|
||||
status(true)
|
||||
}
|
||||
RadioDot(selected, 20.dp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -333,6 +333,8 @@ public final class WaylandCompositor {
|
||||
|
||||
public static native void nativeSetZeroCopy(boolean on);
|
||||
|
||||
public static native void nativeSetMirrorCapture(boolean on);
|
||||
|
||||
public static native void nativeSetDisplayBufferDriver(boolean on);
|
||||
|
||||
public static native int nativeZeroCopyFrames();
|
||||
@@ -460,12 +462,14 @@ public final class WaylandCompositor {
|
||||
public static final int SCENE_BUTTON = 3, SCENE_WHEEL = 4, SCENE_POINTER_DELTA = 6, SCENE_AXIS = 11, SCENE_AXIS_FINGER = 12;
|
||||
public static final int WHEEL_STEP_UNITS = 120, POINTER_DELTA_SCALE = 256;
|
||||
|
||||
public static final int FG_ENGINE_LSFG = 0, FG_ENGINE_DDFG = 1;
|
||||
public static final int FG_ENGINE_LSFG = 0, FG_ENGINE_DDFG = 1, FG_ENGINE_ZEROFG = 2;
|
||||
|
||||
public static native void nativeSetFrameGenEngine(int kind);
|
||||
|
||||
public static native void nativeSetFrameGenArmed(boolean armed, int multiplier, int targetFps);
|
||||
|
||||
public static native void nativeSetFrameGenPacer(boolean on);
|
||||
|
||||
public static native void nativeSetLsfgCachePath(String path);
|
||||
|
||||
public static native void nativeSetFrameGenTuning(float flowScale, float refreshHz);
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="512"
|
||||
android:viewportHeight="512">
|
||||
<path android:fillColor="#FFFFFFFF" android:fillType="evenOdd" android:pathData="M 142 335 L 148 343 L 148 345 L 155 352 L 165 365 L 166 368 L 169 370 L 171 374 L 176 379 L 177 382 L 179 383 L 181 387 L 187 393 L 187 395 L 193 401 L 196 400 L 200 392 L 206 386 L 259 419 L 262 418 L 266 411 L 264 406 L 250 398 L 249 396 L 242 391 L 237 389 L 236 387 L 231 385 L 227 381 L 215 374 L 215 371 L 222 361 L 222 356 L 220 353 Z M 472 198 L 463 195 L 446 195 L 436 198 L 431 198 L 426 200 L 418 201 L 415 203 L 382 209 L 375 212 L 361 214 L 353 217 L 349 224 L 349 226 L 346 229 L 339 245 L 336 248 L 281 354 L 274 365 L 275 370 L 279 376 L 279 379 L 311 450 L 311 453 L 317 465 L 325 473 L 327 474 L 339 474 L 348 470 L 353 465 L 360 454 L 369 436 L 369 434 L 372 430 L 374 424 L 385 404 L 388 396 L 399 376 L 463 246 L 466 243 L 470 232 L 480 214 L 479 205 Z M 444 224 L 445 226 L 337 439 L 334 435 L 332 428 L 316 393 L 315 388 L 312 384 L 312 381 L 305 367 L 305 364 L 307 362 L 348 282 L 369 244 L 369 242 L 372 239 L 381 238 L 386 236 L 390 236 L 395 234 L 409 232 L 423 228 L 432 227 L 440 224 Z M 211 187 L 201 192 L 201 194 L 203 196 L 203 198 L 228 249 L 225 251 L 166 265 L 165 266 L 169 280 L 234 264 L 242 278 L 242 280 L 265 327 L 278 321 L 278 319 L 250 261 L 252 259 L 313 244 L 310 229 L 244 246 L 235 230 L 235 228 L 226 211 L 226 209 L 224 207 L 215 186 Z M 233 127 L 233 129 L 235 131 L 240 133 L 243 136 L 248 138 L 287 162 L 287 165 L 279 178 L 281 181 L 288 183 L 290 182 L 304 186 L 310 186 L 313 188 L 316 187 L 320 189 L 343 192 L 350 195 L 352 194 L 357 196 L 362 196 L 354 186 L 351 184 L 350 181 L 347 179 L 339 168 L 335 165 L 335 163 L 324 152 L 323 149 L 320 147 L 311 135 L 307 134 L 302 136 L 302 138 L 297 144 L 297 146 L 295 148 L 292 148 L 282 141 L 276 139 L 266 132 L 264 132 L 253 125 L 247 123 L 242 119 L 237 120 Z M 221 73 L 212 70 L 195 70 L 175 75 L 170 75 L 154 80 L 140 82 L 135 84 L 130 84 L 123 87 L 103 91 L 95 103 L 88 119 L 86 121 L 79 136 L 75 141 L 73 147 L 66 158 L 59 174 L 56 177 L 23 240 L 24 245 L 34 266 L 34 269 L 44 289 L 44 292 L 60 326 L 63 335 L 67 342 L 72 347 L 76 349 L 91 348 L 95 346 L 106 334 L 118 310 L 118 308 L 120 306 L 229 88 L 228 80 Z M 193 99 L 194 100 L 190 107 L 190 109 L 183 121 L 183 123 L 181 125 L 176 137 L 174 139 L 132 224 L 130 226 L 123 242 L 112 261 L 89 307 L 88 311 L 85 314 L 58 250 L 53 241 L 62 223 L 74 202 L 118 117 L 121 114 L 129 113 L 134 111 L 139 111 L 162 105 L 167 105 L 188 99 Z" />
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M4.5,7.5 H13.8 Q15.5,7.5 15.5,9.2 V18.8 Q15.5,20.5 13.8,20.5 H4.5 Q2.8,20.5 2.8,18.8 V9.2 Q2.8,7.5 4.5,7.5 Z M7.2,4 H18.2 Q20,4 20,5.8 V9 M20,12.2 V18.2 M17,15.2 H23"
|
||||
android:fillColor="@android:color/transparent"
|
||||
android:strokeColor="#FFFFFFFF"
|
||||
android:strokeWidth="1.75"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeLineJoin="round" />
|
||||
</vector>
|
||||
@@ -1180,6 +1180,11 @@
|
||||
<string name="agent_tools_missing">أدوات الوكيل غير مثبتة: %1$s</string>
|
||||
<string name="agent_unqueue">لا تُرسل</string>
|
||||
<string name="agent_attach">إرفاق</string>
|
||||
<string name="agent_attach_files">الملفات</string>
|
||||
<string name="agent_photos_allow">السماح بالوصول إلى الصور</string>
|
||||
<string name="agent_photos_more">اختيار المزيد من الصور</string>
|
||||
<string name="agent_photos_empty">لا توجد صور بعد</string>
|
||||
<string name="agent_keyboard">لوحة المفاتيح</string>
|
||||
<string name="agent_remove_attachment">إزالة</string>
|
||||
<string name="agent_model_default">الافتراضي</string>
|
||||
<string name="agent_effort">جهد الاستدلال</string>
|
||||
@@ -3329,9 +3334,11 @@
|
||||
<string name="stores_hltb_hours">%1$s س</string>
|
||||
<string name="stores_hltb_minutes">%1$d د</string>
|
||||
<string name="display_picture_position">موضع الصورة</string>
|
||||
<string name="display_picture_position_landscape">موضع الصورة (أفقي)</string>
|
||||
<string name="display_picture_position_portrait">موضع الصورة (عمودي)</string>
|
||||
<string name="display_position_top">أعلى</string>
|
||||
<string name="display_position_bottom">أسفل</string>
|
||||
<string name="display_position_center">الوسط (افتراضي)</string>
|
||||
<string name="display_position_center">الوسط</string>
|
||||
<string name="display_position_left">يسار</string>
|
||||
<string name="display_position_right">يمين</string>
|
||||
<string name="setup_tab_storage">التخزين</string>
|
||||
@@ -4323,4 +4330,6 @@
|
||||
<string name="glasses_shortcut_group">اختصار داخل اللعبة</string>
|
||||
<string name="glasses_show_shortcut">إظهار اختصار النظارات الذكية</string>
|
||||
<string name="glasses_show_shortcut_hint">إظهار زر النظارات الذكية العائم فوق اللعبة.</string>
|
||||
<string name="display_filter_game_profile">استخدام ملف تعريف %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">استخدام الملف التعريفي الافتراضي: %1$s</string>
|
||||
</resources>
|
||||
@@ -1198,6 +1198,11 @@
|
||||
<string name="agent_tools_missing">Herramientas del agente sin instalar: %1$s</string>
|
||||
<string name="agent_unqueue">No enviar</string>
|
||||
<string name="agent_attach">Adjuntar</string>
|
||||
<string name="agent_attach_files">Archivos</string>
|
||||
<string name="agent_photos_allow">Permitir acceso a fotos</string>
|
||||
<string name="agent_photos_more">Elegir más fotos</string>
|
||||
<string name="agent_photos_empty">Aún no hay fotos</string>
|
||||
<string name="agent_keyboard">Teclado</string>
|
||||
<string name="agent_remove_attachment">Quitar</string>
|
||||
<string name="agent_model_default">Predeterminado</string>
|
||||
<string name="agent_effort">Esfuerzo de razonamiento</string>
|
||||
@@ -3205,9 +3210,11 @@
|
||||
<string name="hand_camera_group">Seguimiento de manos</string>
|
||||
<string name="hand_camera_prompt_title">¿Rastrear las manos o los mandos Joy-Con con la cámara del teléfono?</string>
|
||||
<string name="display_picture_position">Posición de la imagen</string>
|
||||
<string name="display_picture_position_landscape">Posición de la imagen (Horizontal)</string>
|
||||
<string name="display_picture_position_portrait">Posición de la imagen (Vertical)</string>
|
||||
<string name="display_position_top">Arriba</string>
|
||||
<string name="display_position_bottom">Abajo</string>
|
||||
<string name="display_position_center">Centro (predeterminado)</string>
|
||||
<string name="display_position_center">Centro</string>
|
||||
<string name="display_position_left">Izquierda</string>
|
||||
<string name="display_position_right">Derecha</string>
|
||||
<string name="setup_tab_storage">Almacenamiento</string>
|
||||
@@ -4201,4 +4208,6 @@
|
||||
<string name="glasses_shortcut_group">Acceso directo en el juego</string>
|
||||
<string name="glasses_show_shortcut">Mostrar acceso directo de Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Mostrar el botón flotante de Smart Glasses sobre el juego.</string>
|
||||
<string name="display_filter_game_profile">Usando el perfil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Usando el perfil predeterminado: %1$s</string>
|
||||
</resources>
|
||||
@@ -1168,6 +1168,11 @@
|
||||
<string name="agent_tools_missing">Инструментите на агента не са инсталирани: %1$s</string>
|
||||
<string name="agent_unqueue">Не изпращай</string>
|
||||
<string name="agent_attach">Прикачи</string>
|
||||
<string name="agent_attach_files">Файлове</string>
|
||||
<string name="agent_photos_allow">Разрешаване на достъп до снимки</string>
|
||||
<string name="agent_photos_more">Избор на още снимки</string>
|
||||
<string name="agent_photos_empty">Все още няма снимки</string>
|
||||
<string name="agent_keyboard">Клавиатура</string>
|
||||
<string name="agent_remove_attachment">Премахни</string>
|
||||
<string name="agent_model_default">По подразбиране</string>
|
||||
<string name="agent_effort">Усилие за разсъждение</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_hltb_hours">%1$s ч</string>
|
||||
<string name="stores_hltb_minutes">%1$d мин</string>
|
||||
<string name="display_picture_position">Позиция на картината</string>
|
||||
<string name="display_picture_position_landscape">Позиция на картината (Хоризонтална)</string>
|
||||
<string name="display_picture_position_portrait">Позиция на картината (Вертикална)</string>
|
||||
<string name="display_position_top">Горе</string>
|
||||
<string name="display_position_bottom">Долу</string>
|
||||
<string name="display_position_center">В средата (по подразбиране)</string>
|
||||
<string name="display_position_center">В средата</string>
|
||||
<string name="display_position_left">Наляво</string>
|
||||
<string name="display_position_right">Надясно</string>
|
||||
<string name="setup_tab_storage">Съхранение</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">Пряк път в играта</string>
|
||||
<string name="glasses_show_shortcut">Показване на прекия път за Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Показва плаващия бутон за Smart Glasses върху играта.</string>
|
||||
<string name="display_filter_game_profile">Използва се профил %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Използва се профилът по подразбиране: %1$s</string>
|
||||
</resources>
|
||||
@@ -1174,6 +1174,11 @@
|
||||
<string name="agent_tools_missing">Nástroje agenta nejsou nainstalované: %1$s</string>
|
||||
<string name="agent_unqueue">Neposílat</string>
|
||||
<string name="agent_attach">Přiložit</string>
|
||||
<string name="agent_attach_files">Soubory</string>
|
||||
<string name="agent_photos_allow">Povolit přístup k fotkám</string>
|
||||
<string name="agent_photos_more">Vybrat další fotky</string>
|
||||
<string name="agent_photos_empty">Zatím žádné fotky</string>
|
||||
<string name="agent_keyboard">Klávesnice</string>
|
||||
<string name="agent_remove_attachment">Odebrat</string>
|
||||
<string name="agent_model_default">Výchozí</string>
|
||||
<string name="agent_effort">Náročnost uvažování</string>
|
||||
@@ -3269,9 +3274,11 @@
|
||||
<string name="stores_hltb_hours">%1$s h</string>
|
||||
<string name="stores_hltb_minutes">%1$d min</string>
|
||||
<string name="display_picture_position">Poloha obrázku</string>
|
||||
<string name="display_picture_position_landscape">Poloha obrázku (Na šířku)</string>
|
||||
<string name="display_picture_position_portrait">Poloha obrázku (Na výšku)</string>
|
||||
<string name="display_position_top">Nahoře</string>
|
||||
<string name="display_position_bottom">Dole</string>
|
||||
<string name="display_position_center">Uprostřed (výchozí)</string>
|
||||
<string name="display_position_center">Uprostřed</string>
|
||||
<string name="display_position_left">Vlevo</string>
|
||||
<string name="display_position_right">Vpravo</string>
|
||||
<string name="setup_tab_storage">Úložiště</string>
|
||||
@@ -4243,4 +4250,6 @@
|
||||
<string name="glasses_shortcut_group">Zkratka ve hře</string>
|
||||
<string name="glasses_show_shortcut">Zobrazit zkratku Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Zobrazit plovoucí tlačítko Smart Glasses nad hrou.</string>
|
||||
<string name="display_filter_game_profile">Používá se profil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Používá se výchozí profil: %1$s</string>
|
||||
</resources>
|
||||
@@ -1168,6 +1168,11 @@
|
||||
<string name="agent_tools_missing">Agentens værktøjer er ikke installeret: %1$s</string>
|
||||
<string name="agent_unqueue">Send ikke</string>
|
||||
<string name="agent_attach">Vedhæft</string>
|
||||
<string name="agent_attach_files">Filer</string>
|
||||
<string name="agent_photos_allow">Tillad adgang til billeder</string>
|
||||
<string name="agent_photos_more">Vælg flere billeder</string>
|
||||
<string name="agent_photos_empty">Ingen billeder endnu</string>
|
||||
<string name="agent_keyboard">Tastatur</string>
|
||||
<string name="agent_remove_attachment">Fjern</string>
|
||||
<string name="agent_model_default">Standard</string>
|
||||
<string name="agent_effort">Ræsonneringsindsats</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_hltb_hours">%1$s t</string>
|
||||
<string name="stores_hltb_minutes">%1$d min</string>
|
||||
<string name="display_picture_position">Billedets placering</string>
|
||||
<string name="display_picture_position_landscape">Billedets placering (Liggende)</string>
|
||||
<string name="display_picture_position_portrait">Billedets placering (Stående)</string>
|
||||
<string name="display_position_top">Øverst</string>
|
||||
<string name="display_position_bottom">Nederst</string>
|
||||
<string name="display_position_center">Midten (standard)</string>
|
||||
<string name="display_position_center">Midten</string>
|
||||
<string name="display_position_left">Venstre</string>
|
||||
<string name="display_position_right">Højre</string>
|
||||
<string name="setup_tab_storage">Lager</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">Genvej i spillet</string>
|
||||
<string name="glasses_show_shortcut">Vis Smart Glasses-genvej</string>
|
||||
<string name="glasses_show_shortcut_hint">Vis den flydende Smart Glasses-knap oven på spillet.</string>
|
||||
<string name="display_filter_game_profile">Bruger profilen %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Bruger standardprofilen: %1$s</string>
|
||||
</resources>
|
||||
@@ -1160,6 +1160,11 @@
|
||||
<string name="agent_tools_missing">Agent-Werkzeuge nicht installiert: %1$s</string>
|
||||
<string name="agent_unqueue">Nicht senden</string>
|
||||
<string name="agent_attach">Anhängen</string>
|
||||
<string name="agent_attach_files">Dateien</string>
|
||||
<string name="agent_photos_allow">Zugriff auf Fotos erlauben</string>
|
||||
<string name="agent_photos_more">Weitere Fotos auswählen</string>
|
||||
<string name="agent_photos_empty">Noch keine Fotos</string>
|
||||
<string name="agent_keyboard">Tastatur</string>
|
||||
<string name="agent_remove_attachment">Entfernen</string>
|
||||
<string name="agent_model_default">Standard</string>
|
||||
<string name="agent_effort">Denkaufwand</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_storage_low">Zu wenig Speicher (%1$s frei, %2$s benötigt)</string>
|
||||
<string name="stores_target_free_unknown">Freier Speicher unbekannt</string>
|
||||
<string name="display_picture_position">Bildposition</string>
|
||||
<string name="display_picture_position_landscape">Bildposition (Querformat)</string>
|
||||
<string name="display_picture_position_portrait">Bildposition (Hochformat)</string>
|
||||
<string name="display_position_top">Oben</string>
|
||||
<string name="display_position_bottom">Unten</string>
|
||||
<string name="display_position_center">Mitte (Standard)</string>
|
||||
<string name="display_position_center">Mitte</string>
|
||||
<string name="display_position_left">Links</string>
|
||||
<string name="display_position_right">Rechts</string>
|
||||
<string name="setup_tab_storage">Speicher</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">Ingame-Verknüpfung</string>
|
||||
<string name="glasses_show_shortcut">Smart-Glasses-Verknüpfung anzeigen</string>
|
||||
<string name="glasses_show_shortcut_hint">Die schwebende Smart-Glasses-Schaltfläche über dem Spiel anzeigen.</string>
|
||||
<string name="display_filter_game_profile">Profil %1$s wird verwendet: %2$s</string>
|
||||
<string name="display_filter_default_profile">Standardprofil wird verwendet: %1$s</string>
|
||||
</resources>
|
||||
@@ -1168,6 +1168,11 @@
|
||||
<string name="agent_tools_missing">Τα εργαλεία του πράκτορα δεν εγκαταστάθηκαν: %1$s</string>
|
||||
<string name="agent_unqueue">Να μην σταλεί</string>
|
||||
<string name="agent_attach">Επισύναψη</string>
|
||||
<string name="agent_attach_files">Αρχεία</string>
|
||||
<string name="agent_photos_allow">Να επιτρέπεται η πρόσβαση στις φωτογραφίες</string>
|
||||
<string name="agent_photos_more">Επιλογή περισσότερων φωτογραφιών</string>
|
||||
<string name="agent_photos_empty">Δεν υπάρχουν φωτογραφίες ακόμα</string>
|
||||
<string name="agent_keyboard">Πληκτρολόγιο</string>
|
||||
<string name="agent_remove_attachment">Αφαίρεση</string>
|
||||
<string name="agent_model_default">Προεπιλογή</string>
|
||||
<string name="agent_effort">Προσπάθεια συλλογισμού</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_hltb_hours">%1$s ώ.</string>
|
||||
<string name="stores_hltb_minutes">%1$d λεπ.</string>
|
||||
<string name="display_picture_position">Θέση εικόνας</string>
|
||||
<string name="display_picture_position_landscape">Θέση εικόνας (Οριζόντιος προσανατολισμός)</string>
|
||||
<string name="display_picture_position_portrait">Θέση εικόνας (Κατακόρυφος)</string>
|
||||
<string name="display_position_top">Πάνω</string>
|
||||
<string name="display_position_bottom">Κάτω</string>
|
||||
<string name="display_position_center">Κέντρο (προεπιλογή)</string>
|
||||
<string name="display_position_center">Κέντρο</string>
|
||||
<string name="display_position_left">Αριστερά</string>
|
||||
<string name="display_position_right">Δεξιά</string>
|
||||
<string name="setup_tab_storage">Αποθήκευση</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">Συντόμευση μέσα στο παιχνίδι</string>
|
||||
<string name="glasses_show_shortcut">Εμφάνιση συντόμευσης Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Εμφάνιση του αιωρούμενου κουμπιού Smart Glasses πάνω από το παιχνίδι.</string>
|
||||
<string name="display_filter_game_profile">Χρήση προφίλ %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Χρήση προεπιλεγμένου προφίλ: %1$s</string>
|
||||
</resources>
|
||||
@@ -1171,6 +1171,11 @@
|
||||
<string name="agent_tools_missing">Herramientas del agente sin instalar: %1$s</string>
|
||||
<string name="agent_unqueue">No enviar</string>
|
||||
<string name="agent_attach">Adjuntar</string>
|
||||
<string name="agent_attach_files">Archivos</string>
|
||||
<string name="agent_photos_allow">Permitir acceso a las fotos</string>
|
||||
<string name="agent_photos_more">Elegir más fotos</string>
|
||||
<string name="agent_photos_empty">Aún no hay fotos</string>
|
||||
<string name="agent_keyboard">Teclado</string>
|
||||
<string name="agent_remove_attachment">Quitar</string>
|
||||
<string name="agent_model_default">Predeterminado</string>
|
||||
<string name="agent_effort">Esfuerzo de razonamiento</string>
|
||||
@@ -3239,9 +3244,11 @@
|
||||
<string name="stores_storage_low">Espacio insuficiente (%1$s libres, se necesitan %2$s)</string>
|
||||
<string name="stores_target_free_unknown">Espacio libre desconocido</string>
|
||||
<string name="display_picture_position">Posición de la imagen</string>
|
||||
<string name="display_picture_position_landscape">Posición de la imagen (Horizontal)</string>
|
||||
<string name="display_picture_position_portrait">Posición de la imagen (Vertical)</string>
|
||||
<string name="display_position_top">Arriba</string>
|
||||
<string name="display_position_bottom">Abajo</string>
|
||||
<string name="display_position_center">Centro (predeterminado)</string>
|
||||
<string name="display_position_center">Centro</string>
|
||||
<string name="display_position_left">Izquierda</string>
|
||||
<string name="display_position_right">Derecha</string>
|
||||
<string name="setup_tab_storage">Almacenamiento</string>
|
||||
@@ -4203,4 +4210,6 @@
|
||||
<string name="glasses_shortcut_group">Acceso directo en el juego</string>
|
||||
<string name="glasses_show_shortcut">Mostrar acceso directo de Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Mostrar el botón flotante de Smart Glasses sobre el juego.</string>
|
||||
<string name="display_filter_game_profile">Usando el perfil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Usando el perfil predeterminado: %1$s</string>
|
||||
</resources>
|
||||
@@ -1168,6 +1168,11 @@
|
||||
<string name="agent_tools_missing">Agentin työkaluja ei ole asennettu: %1$s</string>
|
||||
<string name="agent_unqueue">Älä lähetä</string>
|
||||
<string name="agent_attach">Liitä</string>
|
||||
<string name="agent_attach_files">Tiedostot</string>
|
||||
<string name="agent_photos_allow">Salli kuvien käyttö</string>
|
||||
<string name="agent_photos_more">Valitse lisää kuvia</string>
|
||||
<string name="agent_photos_empty">Ei vielä kuvia</string>
|
||||
<string name="agent_keyboard">Näppäimistö</string>
|
||||
<string name="agent_remove_attachment">Poista</string>
|
||||
<string name="agent_model_default">Oletus</string>
|
||||
<string name="agent_effort">Päättelyteho</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_hltb_hours">%1$s t</string>
|
||||
<string name="stores_hltb_minutes">%1$d min</string>
|
||||
<string name="display_picture_position">Kuvan sijainti</string>
|
||||
<string name="display_picture_position_landscape">Kuvan sijainti (Vaakasuunta)</string>
|
||||
<string name="display_picture_position_portrait">Kuvan sijainti (Pystysuunta)</string>
|
||||
<string name="display_position_top">Ylhäällä</string>
|
||||
<string name="display_position_bottom">Alhaalla</string>
|
||||
<string name="display_position_center">Keskellä (oletus)</string>
|
||||
<string name="display_position_center">Keskellä</string>
|
||||
<string name="display_position_left">Vasen</string>
|
||||
<string name="display_position_right">Oikea</string>
|
||||
<string name="setup_tab_storage">Tallennustila</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">Pelin aikainen pikakuvake</string>
|
||||
<string name="glasses_show_shortcut">Näytä Smart Glasses -pikakuvake</string>
|
||||
<string name="glasses_show_shortcut_hint">Näytä pelin päällä kelluva Smart Glasses -painike.</string>
|
||||
<string name="display_filter_game_profile">Käytössä profiili %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Käytössä oletusprofiili: %1$s</string>
|
||||
</resources>
|
||||
@@ -1171,6 +1171,11 @@
|
||||
<string name="agent_tools_missing">Outils de l’agent non installés : %1$s</string>
|
||||
<string name="agent_unqueue">Ne pas envoyer</string>
|
||||
<string name="agent_attach">Joindre</string>
|
||||
<string name="agent_attach_files">Fichiers</string>
|
||||
<string name="agent_photos_allow">Autoriser l\'accès aux photos</string>
|
||||
<string name="agent_photos_more">Choisir d\'autres photos</string>
|
||||
<string name="agent_photos_empty">Aucune photo pour l\'instant</string>
|
||||
<string name="agent_keyboard">Clavier</string>
|
||||
<string name="agent_remove_attachment">Supprimer</string>
|
||||
<string name="agent_model_default">Par défaut</string>
|
||||
<string name="agent_effort">Effort de raisonnement</string>
|
||||
@@ -3238,9 +3243,11 @@
|
||||
<string name="stores_storage_low">Espace insuffisant (%1$s libres, %2$s nécessaires)</string>
|
||||
<string name="stores_target_free_unknown">Espace libre inconnu</string>
|
||||
<string name="display_picture_position">Position de l\'image</string>
|
||||
<string name="display_picture_position_landscape">Position de l\'image (Paysage)</string>
|
||||
<string name="display_picture_position_portrait">Position de l\'image (Portrait)</string>
|
||||
<string name="display_position_top">Haut</string>
|
||||
<string name="display_position_bottom">Bas</string>
|
||||
<string name="display_position_center">Centre (par défaut)</string>
|
||||
<string name="display_position_center">Centre</string>
|
||||
<string name="display_position_left">Gauche</string>
|
||||
<string name="display_position_right">Droite</string>
|
||||
<string name="setup_tab_storage">Stockage</string>
|
||||
@@ -4202,4 +4209,6 @@
|
||||
<string name="glasses_shortcut_group">Raccourci en jeu</string>
|
||||
<string name="glasses_show_shortcut">Afficher le raccourci Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Afficher le bouton flottant Smart Glasses par-dessus le jeu.</string>
|
||||
<string name="display_filter_game_profile">Profil %1$s utilisé : %2$s</string>
|
||||
<string name="display_filter_default_profile">Profil par défaut utilisé : %1$s</string>
|
||||
</resources>
|
||||
@@ -1168,6 +1168,11 @@
|
||||
<string name="agent_tools_missing">एजेंट टूल इंस्टॉल नहीं हुए: %1$s</string>
|
||||
<string name="agent_unqueue">न भेजें</string>
|
||||
<string name="agent_attach">संलग्न करें</string>
|
||||
<string name="agent_attach_files">फ़ाइलें</string>
|
||||
<string name="agent_photos_allow">फ़ोटो की अनुमति दें</string>
|
||||
<string name="agent_photos_more">और फ़ोटो चुनें</string>
|
||||
<string name="agent_photos_empty">अभी कोई फ़ोटो नहीं</string>
|
||||
<string name="agent_keyboard">कीबोर्ड</string>
|
||||
<string name="agent_remove_attachment">हटाएँ</string>
|
||||
<string name="agent_model_default">डिफ़ॉल्ट</string>
|
||||
<string name="agent_effort">सोचने का स्तर</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_hltb_hours">%1$s घं</string>
|
||||
<string name="stores_hltb_minutes">%1$d मि</string>
|
||||
<string name="display_picture_position">चित्र की स्थिति</string>
|
||||
<string name="display_picture_position_landscape">चित्र की स्थिति (लैंडस्केप)</string>
|
||||
<string name="display_picture_position_portrait">चित्र की स्थिति (पोर्ट्रेट)</string>
|
||||
<string name="display_position_top">ऊपर</string>
|
||||
<string name="display_position_bottom">नीचे</string>
|
||||
<string name="display_position_center">बीच में (डिफ़ॉल्ट)</string>
|
||||
<string name="display_position_center">बीच में</string>
|
||||
<string name="display_position_left">बाएँ</string>
|
||||
<string name="display_position_right">दाएँ</string>
|
||||
<string name="setup_tab_storage">स्टोरेज</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">गेम में शॉर्टकट</string>
|
||||
<string name="glasses_show_shortcut">Smart Glasses शॉर्टकट दिखाएँ</string>
|
||||
<string name="glasses_show_shortcut_hint">गेम के ऊपर तैरता हुआ Smart Glasses बटन दिखाएँ।</string>
|
||||
<string name="display_filter_game_profile">%1$s प्रोफ़ाइल का उपयोग: %2$s</string>
|
||||
<string name="display_filter_default_profile">डिफ़ॉल्ट प्रोफ़ाइल का उपयोग: %1$s</string>
|
||||
</resources>
|
||||
@@ -1168,6 +1168,11 @@
|
||||
<string name="agent_tools_missing">Az ügynök eszközei nincsenek telepítve: %1$s</string>
|
||||
<string name="agent_unqueue">Ne küldd el</string>
|
||||
<string name="agent_attach">Csatolás</string>
|
||||
<string name="agent_attach_files">Fájlok</string>
|
||||
<string name="agent_photos_allow">Fotókhoz való hozzáférés engedélyezése</string>
|
||||
<string name="agent_photos_more">További fotók kiválasztása</string>
|
||||
<string name="agent_photos_empty">Még nincsenek fotók</string>
|
||||
<string name="agent_keyboard">Billentyűzet</string>
|
||||
<string name="agent_remove_attachment">Eltávolítás</string>
|
||||
<string name="agent_model_default">Alapértelmezett</string>
|
||||
<string name="agent_effort">Gondolkodási erőfeszítés</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_hltb_hours">%1$s óra</string>
|
||||
<string name="stores_hltb_minutes">%1$d perc</string>
|
||||
<string name="display_picture_position">A kép pozíciója</string>
|
||||
<string name="display_picture_position_landscape">A kép pozíciója (Fekvő)</string>
|
||||
<string name="display_picture_position_portrait">A kép pozíciója (Álló)</string>
|
||||
<string name="display_position_top">Fent</string>
|
||||
<string name="display_position_bottom">Lent</string>
|
||||
<string name="display_position_center">Középen (alapértelmezett)</string>
|
||||
<string name="display_position_center">Középen</string>
|
||||
<string name="display_position_left">Bal</string>
|
||||
<string name="display_position_right">Jobb</string>
|
||||
<string name="setup_tab_storage">Tárhely</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">Játékon belüli parancsikon</string>
|
||||
<string name="glasses_show_shortcut">Smart Glasses parancsikon megjelenítése</string>
|
||||
<string name="glasses_show_shortcut_hint">A játék fölött lebegő Smart Glasses gomb megjelenítése.</string>
|
||||
<string name="display_filter_game_profile">Használt profil: %1$s – %2$s</string>
|
||||
<string name="display_filter_default_profile">Alapértelmezett profil használata: %1$s</string>
|
||||
</resources>
|
||||
@@ -1165,6 +1165,11 @@
|
||||
<string name="agent_tools_missing">Alat agen tidak terpasang: %1$s</string>
|
||||
<string name="agent_unqueue">Jangan kirim</string>
|
||||
<string name="agent_attach">Lampirkan</string>
|
||||
<string name="agent_attach_files">File</string>
|
||||
<string name="agent_photos_allow">Izinkan akses foto</string>
|
||||
<string name="agent_photos_more">Pilih foto lainnya</string>
|
||||
<string name="agent_photos_empty">Belum ada foto</string>
|
||||
<string name="agent_keyboard">Keyboard</string>
|
||||
<string name="agent_remove_attachment">Hapus</string>
|
||||
<string name="agent_model_default">Default</string>
|
||||
<string name="agent_effort">Upaya penalaran</string>
|
||||
@@ -3180,9 +3185,11 @@
|
||||
<string name="stores_hltb_hours">%1$s j</string>
|
||||
<string name="stores_hltb_minutes">%1$d mnt</string>
|
||||
<string name="display_picture_position">Posisi gambar</string>
|
||||
<string name="display_picture_position_landscape">Posisi gambar (Lanskap)</string>
|
||||
<string name="display_picture_position_portrait">Posisi gambar (Potret)</string>
|
||||
<string name="display_position_top">Atas</string>
|
||||
<string name="display_position_bottom">Bawah</string>
|
||||
<string name="display_position_center">Tengah (bawaan)</string>
|
||||
<string name="display_position_center">Tengah</string>
|
||||
<string name="display_position_left">Kiri</string>
|
||||
<string name="display_position_right">Kanan</string>
|
||||
<string name="setup_tab_storage">Penyimpanan</string>
|
||||
@@ -4133,4 +4140,6 @@
|
||||
<string name="glasses_shortcut_group">Pintasan dalam game</string>
|
||||
<string name="glasses_show_shortcut">Tampilkan pintasan Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Tampilkan tombol Smart Glasses mengambang di atas game.</string>
|
||||
<string name="display_filter_game_profile">Menggunakan profil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Menggunakan profil default: %1$s</string>
|
||||
</resources>
|
||||
@@ -1163,6 +1163,11 @@
|
||||
<string name="agent_tools_missing">Strumenti dell’agente non installati: %1$s</string>
|
||||
<string name="agent_unqueue">Non inviare</string>
|
||||
<string name="agent_attach">Allega</string>
|
||||
<string name="agent_attach_files">File</string>
|
||||
<string name="agent_photos_allow">Consenti accesso alle foto</string>
|
||||
<string name="agent_photos_more">Scegli altre foto</string>
|
||||
<string name="agent_photos_empty">Ancora nessuna foto</string>
|
||||
<string name="agent_keyboard">Tastiera</string>
|
||||
<string name="agent_remove_attachment">Rimuovi</string>
|
||||
<string name="agent_model_default">Predefinito</string>
|
||||
<string name="agent_effort">Livello di ragionamento</string>
|
||||
@@ -3238,9 +3243,11 @@
|
||||
<string name="stores_storage_low">Spazio insufficiente (%1$s liberi, ne servono %2$s)</string>
|
||||
<string name="stores_target_free_unknown">Spazio libero sconosciuto</string>
|
||||
<string name="display_picture_position">Posizione immagine</string>
|
||||
<string name="display_picture_position_landscape">Posizione immagine (Orizzontale)</string>
|
||||
<string name="display_picture_position_portrait">Posizione immagine (Verticale)</string>
|
||||
<string name="display_position_top">In alto</string>
|
||||
<string name="display_position_bottom">In basso</string>
|
||||
<string name="display_position_center">Centro (predefinito)</string>
|
||||
<string name="display_position_center">Centro</string>
|
||||
<string name="display_position_left">Sinistra</string>
|
||||
<string name="display_position_right">Destra</string>
|
||||
<string name="setup_tab_storage">Archiviazione</string>
|
||||
@@ -4202,4 +4209,6 @@
|
||||
<string name="glasses_shortcut_group">Scorciatoia nel gioco</string>
|
||||
<string name="glasses_show_shortcut">Mostra scorciatoia Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Mostra il pulsante mobile Smart Glasses sopra il gioco.</string>
|
||||
<string name="display_filter_game_profile">Profilo %1$s in uso: %2$s</string>
|
||||
<string name="display_filter_default_profile">Profilo predefinito in uso: %1$s</string>
|
||||
</resources>
|
||||
@@ -1165,6 +1165,11 @@
|
||||
<string name="agent_tools_missing">エージェントのツールが未インストール: %1$s</string>
|
||||
<string name="agent_unqueue">送信しない</string>
|
||||
<string name="agent_attach">添付</string>
|
||||
<string name="agent_attach_files">ファイル</string>
|
||||
<string name="agent_photos_allow">写真へのアクセスを許可</string>
|
||||
<string name="agent_photos_more">写真をさらに選択</string>
|
||||
<string name="agent_photos_empty">まだ写真がありません</string>
|
||||
<string name="agent_keyboard">キーボード</string>
|
||||
<string name="agent_remove_attachment">削除</string>
|
||||
<string name="agent_model_default">デフォルト</string>
|
||||
<string name="agent_effort">推論レベル</string>
|
||||
@@ -3180,9 +3185,11 @@
|
||||
<string name="drawer_component_downloads_hint">ダウンロードは「コンポーネント」ページと共有されます。上でダウンロード済みのバージョンを選ぶと、次回のゲーム起動時に使用されます。</string>
|
||||
<string name="drawer_component_choose_download">ダウンロードするバージョンを選択</string>
|
||||
<string name="display_picture_position">画面の位置</string>
|
||||
<string name="display_picture_position_landscape">画面の位置(横向き)</string>
|
||||
<string name="display_picture_position_portrait">画面の位置(縦向き)</string>
|
||||
<string name="display_position_top">上</string>
|
||||
<string name="display_position_bottom">下</string>
|
||||
<string name="display_position_center">中央(既定)</string>
|
||||
<string name="display_position_center">中央</string>
|
||||
<string name="display_position_left">左</string>
|
||||
<string name="display_position_right">右</string>
|
||||
<string name="setup_tab_storage">ストレージ</string>
|
||||
@@ -4133,4 +4140,6 @@
|
||||
<string name="glasses_shortcut_group">ゲーム内ショートカット</string>
|
||||
<string name="glasses_show_shortcut">Smart Glasses のショートカットを表示</string>
|
||||
<string name="glasses_show_shortcut_hint">ゲーム画面上に Smart Glasses のフローティングボタンを表示します。</string>
|
||||
<string name="display_filter_game_profile">%1$s プロファイルを使用中: %2$s</string>
|
||||
<string name="display_filter_default_profile">デフォルトプロファイルを使用中: %1$s</string>
|
||||
</resources>
|
||||
@@ -1165,6 +1165,11 @@
|
||||
<string name="agent_tools_missing">에이전트 도구가 설치되지 않음: %1$s</string>
|
||||
<string name="agent_unqueue">보내지 않기</string>
|
||||
<string name="agent_attach">첨부</string>
|
||||
<string name="agent_attach_files">파일</string>
|
||||
<string name="agent_photos_allow">사진 접근 허용</string>
|
||||
<string name="agent_photos_more">사진 더 선택</string>
|
||||
<string name="agent_photos_empty">아직 사진이 없습니다</string>
|
||||
<string name="agent_keyboard">키보드</string>
|
||||
<string name="agent_remove_attachment">제거</string>
|
||||
<string name="agent_model_default">기본</string>
|
||||
<string name="agent_effort">추론 수준</string>
|
||||
@@ -3180,9 +3185,11 @@
|
||||
<string name="drawer_component_downloads_hint">다운로드는 구성 요소 페이지와 공유됩니다. 위에서 다운로드한 버전을 선택하면 다음 게임 실행 시 사용됩니다.</string>
|
||||
<string name="drawer_component_choose_download">다운로드할 버전 선택</string>
|
||||
<string name="display_picture_position">화면 위치</string>
|
||||
<string name="display_picture_position_landscape">화면 위치 (가로 모드)</string>
|
||||
<string name="display_picture_position_portrait">화면 위치 (세로)</string>
|
||||
<string name="display_position_top">위</string>
|
||||
<string name="display_position_bottom">아래</string>
|
||||
<string name="display_position_center">가운데(기본)</string>
|
||||
<string name="display_position_center">가운데</string>
|
||||
<string name="display_position_left">왼쪽</string>
|
||||
<string name="display_position_right">오른쪽</string>
|
||||
<string name="setup_tab_storage">저장 공간</string>
|
||||
@@ -4133,4 +4140,6 @@
|
||||
<string name="glasses_shortcut_group">게임 내 바로가기</string>
|
||||
<string name="glasses_show_shortcut">Smart Glasses 바로가기 표시</string>
|
||||
<string name="glasses_show_shortcut_hint">게임 위에 떠 있는 Smart Glasses 버튼을 표시합니다.</string>
|
||||
<string name="display_filter_game_profile">%1$s 프로필 사용 중: %2$s</string>
|
||||
<string name="display_filter_default_profile">기본 프로필 사용 중: %1$s</string>
|
||||
</resources>
|
||||
@@ -1165,6 +1165,11 @@
|
||||
<string name="agent_tools_missing">Alat ejen tidak dipasang: %1$s</string>
|
||||
<string name="agent_unqueue">Jangan hantar</string>
|
||||
<string name="agent_attach">Lampirkan</string>
|
||||
<string name="agent_attach_files">Fail</string>
|
||||
<string name="agent_photos_allow">Benarkan akses foto</string>
|
||||
<string name="agent_photos_more">Pilih lebih banyak foto</string>
|
||||
<string name="agent_photos_empty">Belum ada foto</string>
|
||||
<string name="agent_keyboard">Papan kekunci</string>
|
||||
<string name="agent_remove_attachment">Alih keluar</string>
|
||||
<string name="agent_model_default">Lalai</string>
|
||||
<string name="agent_effort">Usaha penaakulan</string>
|
||||
@@ -3180,9 +3185,11 @@
|
||||
<string name="stores_hltb_hours">%1$s j</string>
|
||||
<string name="stores_hltb_minutes">%1$d min</string>
|
||||
<string name="display_picture_position">Kedudukan gambar</string>
|
||||
<string name="display_picture_position_landscape">Kedudukan gambar (Lanskap)</string>
|
||||
<string name="display_picture_position_portrait">Kedudukan gambar (Potret)</string>
|
||||
<string name="display_position_top">Atas</string>
|
||||
<string name="display_position_bottom">Bawah</string>
|
||||
<string name="display_position_center">Tengah (lalai)</string>
|
||||
<string name="display_position_center">Tengah</string>
|
||||
<string name="display_position_left">Kiri</string>
|
||||
<string name="display_position_right">Kanan</string>
|
||||
<string name="setup_tab_storage">Storan</string>
|
||||
@@ -4133,4 +4140,6 @@
|
||||
<string name="glasses_shortcut_group">Pintasan dalam permainan</string>
|
||||
<string name="glasses_show_shortcut">Tunjukkan pintasan Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Tunjukkan butang Smart Glasses terapung di atas permainan.</string>
|
||||
<string name="display_filter_game_profile">Menggunakan profil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Menggunakan profil lalai: %1$s</string>
|
||||
</resources>
|
||||
@@ -1168,6 +1168,11 @@
|
||||
<string name="agent_tools_missing">Agentverktøy er ikke installert: %1$s</string>
|
||||
<string name="agent_unqueue">Ikke send</string>
|
||||
<string name="agent_attach">Legg ved</string>
|
||||
<string name="agent_attach_files">Filer</string>
|
||||
<string name="agent_photos_allow">Tillat tilgang til bilder</string>
|
||||
<string name="agent_photos_more">Velg flere bilder</string>
|
||||
<string name="agent_photos_empty">Ingen bilder ennå</string>
|
||||
<string name="agent_keyboard">Tastatur</string>
|
||||
<string name="agent_remove_attachment">Fjern</string>
|
||||
<string name="agent_model_default">Standard</string>
|
||||
<string name="agent_effort">Resonneringsinnsats</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_hltb_hours">%1$s t</string>
|
||||
<string name="stores_hltb_minutes">%1$d min</string>
|
||||
<string name="display_picture_position">Bildets posisjon</string>
|
||||
<string name="display_picture_position_landscape">Bildets posisjon (Liggende)</string>
|
||||
<string name="display_picture_position_portrait">Bildets posisjon (Stående)</string>
|
||||
<string name="display_position_top">Øverst</string>
|
||||
<string name="display_position_bottom">Nederst</string>
|
||||
<string name="display_position_center">Midten (standard)</string>
|
||||
<string name="display_position_center">Midten</string>
|
||||
<string name="display_position_left">Venstre</string>
|
||||
<string name="display_position_right">Høyre</string>
|
||||
<string name="setup_tab_storage">Lagring</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">Snarvei i spillet</string>
|
||||
<string name="glasses_show_shortcut">Vis Smart Glasses-snarvei</string>
|
||||
<string name="glasses_show_shortcut_hint">Vis den flytende Smart Glasses-knappen over spillet.</string>
|
||||
<string name="display_filter_game_profile">Bruker profilen %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Bruker standardprofilen: %1$s</string>
|
||||
</resources>
|
||||
@@ -1168,6 +1168,11 @@
|
||||
<string name="agent_tools_missing">Agenttools niet geïnstalleerd: %1$s</string>
|
||||
<string name="agent_unqueue">Niet verzenden</string>
|
||||
<string name="agent_attach">Bijvoegen</string>
|
||||
<string name="agent_attach_files">Bestanden</string>
|
||||
<string name="agent_photos_allow">Toegang tot foto\'s toestaan</string>
|
||||
<string name="agent_photos_more">Meer foto\'s kiezen</string>
|
||||
<string name="agent_photos_empty">Nog geen foto\'s</string>
|
||||
<string name="agent_keyboard">Toetsenbord</string>
|
||||
<string name="agent_remove_attachment">Verwijderen</string>
|
||||
<string name="agent_model_default">Standaard</string>
|
||||
<string name="agent_effort">Redeneerinspanning</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_hltb_hours">%1$s u</string>
|
||||
<string name="stores_hltb_minutes">%1$d min</string>
|
||||
<string name="display_picture_position">Positie van de afbeelding</string>
|
||||
<string name="display_picture_position_landscape">Positie van de afbeelding (Liggend)</string>
|
||||
<string name="display_picture_position_portrait">Positie van de afbeelding (Staand)</string>
|
||||
<string name="display_position_top">Boven</string>
|
||||
<string name="display_position_bottom">Onder</string>
|
||||
<string name="display_position_center">Midden (standaard)</string>
|
||||
<string name="display_position_center">Midden</string>
|
||||
<string name="display_position_left">Links</string>
|
||||
<string name="display_position_right">Rechts</string>
|
||||
<string name="setup_tab_storage">Opslag</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">Snelkoppeling in game</string>
|
||||
<string name="glasses_show_shortcut">Smart Glasses-snelkoppeling tonen</string>
|
||||
<string name="glasses_show_shortcut_hint">Toon de zwevende Smart Glasses-knop boven het spel.</string>
|
||||
<string name="display_filter_game_profile">Profiel %1$s in gebruik: %2$s</string>
|
||||
<string name="display_filter_default_profile">Standaardprofiel in gebruik: %1$s</string>
|
||||
</resources>
|
||||
@@ -1174,6 +1174,11 @@
|
||||
<string name="agent_tools_missing">Narzędzia agenta nie są zainstalowane: %1$s</string>
|
||||
<string name="agent_unqueue">Nie wysyłaj</string>
|
||||
<string name="agent_attach">Załącz</string>
|
||||
<string name="agent_attach_files">Pliki</string>
|
||||
<string name="agent_photos_allow">Zezwól na dostęp do zdjęć</string>
|
||||
<string name="agent_photos_more">Wybierz więcej zdjęć</string>
|
||||
<string name="agent_photos_empty">Brak zdjęć</string>
|
||||
<string name="agent_keyboard">Klawiatura</string>
|
||||
<string name="agent_remove_attachment">Usuń</string>
|
||||
<string name="agent_model_default">Domyślny</string>
|
||||
<string name="agent_effort">Poziom rozumowania</string>
|
||||
@@ -3269,9 +3274,11 @@
|
||||
<string name="stores_hltb_hours">%1$s godz.</string>
|
||||
<string name="stores_hltb_minutes">%1$d min</string>
|
||||
<string name="display_picture_position">Pozycja obrazu</string>
|
||||
<string name="display_picture_position_landscape">Pozycja obrazu (Pozioma)</string>
|
||||
<string name="display_picture_position_portrait">Pozycja obrazu (Pionowa)</string>
|
||||
<string name="display_position_top">Góra</string>
|
||||
<string name="display_position_bottom">Dół</string>
|
||||
<string name="display_position_center">Środek (domyślnie)</string>
|
||||
<string name="display_position_center">Środek</string>
|
||||
<string name="display_position_left">Lewo</string>
|
||||
<string name="display_position_right">Prawo</string>
|
||||
<string name="setup_tab_storage">Pamięć</string>
|
||||
@@ -4243,4 +4250,6 @@
|
||||
<string name="glasses_shortcut_group">Skrót w grze</string>
|
||||
<string name="glasses_show_shortcut">Pokaż skrót Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Pokaż pływający przycisk Smart Glasses nad grą.</string>
|
||||
<string name="display_filter_game_profile">Używany profil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Używany profil domyślny: %1$s</string>
|
||||
</resources>
|
||||
@@ -1163,6 +1163,11 @@
|
||||
<string name="agent_tools_missing">Ferramentas do agente não instaladas: %1$s</string>
|
||||
<string name="agent_unqueue">Não enviar</string>
|
||||
<string name="agent_attach">Anexar</string>
|
||||
<string name="agent_attach_files">Ficheiros</string>
|
||||
<string name="agent_photos_allow">Permitir acesso às fotos</string>
|
||||
<string name="agent_photos_more">Escolher mais fotos</string>
|
||||
<string name="agent_photos_empty">Ainda não há fotos</string>
|
||||
<string name="agent_keyboard">Teclado</string>
|
||||
<string name="agent_remove_attachment">Remover</string>
|
||||
<string name="agent_model_default">Predefinido</string>
|
||||
<string name="agent_effort">Esforço de raciocínio</string>
|
||||
@@ -3253,11 +3258,13 @@
|
||||
<string name="stores_storage_insufficient">Espaço livre insuficiente: são necessários %1$s, só há %2$s livres</string>
|
||||
<string name="stores_target_free_unknown">Espaço livre desconhecido</string>
|
||||
<string name="display_picture_position">Posição da imagem</string>
|
||||
<string name="display_picture_position_landscape">Posição da imagem (Horizontal)</string>
|
||||
<string name="display_picture_position_portrait">Posição da imagem (Vertical)</string>
|
||||
<string name="display_position_top">Topo</string>
|
||||
<string name="display_position_left">Esquerda</string>
|
||||
<string name="display_position_right">Direita</string>
|
||||
<string name="display_position_bottom">Fundo</string>
|
||||
<string name="display_position_center">Centro (predefinido)</string>
|
||||
<string name="display_position_center">Centro</string>
|
||||
<string name="setup_tab_storage">Armazenamento</string>
|
||||
<string name="storage_measuring">A medir o armazenamento…</string>
|
||||
<string name="storage_measuring_hint">Na primeira vez demora alguns segundos.</string>
|
||||
@@ -4202,4 +4209,6 @@
|
||||
<string name="glasses_shortcut_group">Atalho no jogo</string>
|
||||
<string name="glasses_show_shortcut">Mostrar atalho do Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Mostrar o botão flutuante do Smart Glasses sobre o jogo.</string>
|
||||
<string name="display_filter_game_profile">Perfil %1$s em utilização: %2$s</string>
|
||||
<string name="display_filter_default_profile">Perfil predefinido em utilização: %1$s</string>
|
||||
</resources>
|
||||
@@ -1170,6 +1170,11 @@
|
||||
<string name="agent_tools_missing">Ferramentas do agente não instaladas: %1$s</string>
|
||||
<string name="agent_unqueue">Não enviar</string>
|
||||
<string name="agent_attach">Anexar</string>
|
||||
<string name="agent_attach_files">Arquivos</string>
|
||||
<string name="agent_photos_allow">Permitir acesso às fotos</string>
|
||||
<string name="agent_photos_more">Escolher mais fotos</string>
|
||||
<string name="agent_photos_empty">Ainda não há fotos</string>
|
||||
<string name="agent_keyboard">Teclado</string>
|
||||
<string name="agent_remove_attachment">Remover</string>
|
||||
<string name="agent_model_default">Padrão</string>
|
||||
<string name="agent_effort">Esforço de raciocínio</string>
|
||||
@@ -3263,11 +3268,13 @@
|
||||
<string name="stores_storage_low">Espaço insuficiente (%1$s livres, são necessários %2$s)</string>
|
||||
<string name="stores_target_free_unknown">Espaço livre desconhecido</string>
|
||||
<string name="display_picture_position">Posição da imagem</string>
|
||||
<string name="display_picture_position_landscape">Posição da imagem (Paisagem)</string>
|
||||
<string name="display_picture_position_portrait">Posição da imagem (Retrato)</string>
|
||||
<string name="display_position_top">Topo</string>
|
||||
<string name="display_position_left">Esquerda</string>
|
||||
<string name="display_position_right">Direita</string>
|
||||
<string name="display_position_bottom">Base</string>
|
||||
<string name="display_position_center">Centro (padrão)</string>
|
||||
<string name="display_position_center">Centro</string>
|
||||
<string name="setup_tab_storage">Armazenamento</string>
|
||||
<string name="storage_measuring">Medindo o armazenamento…</string>
|
||||
<string name="storage_measuring_hint">Na primeira vez leva alguns segundos.</string>
|
||||
@@ -4210,4 +4217,6 @@
|
||||
<string name="glasses_shortcut_group">Atalho durante o jogo</string>
|
||||
<string name="glasses_show_shortcut">Mostrar atalho do Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Mostrar o botão flutuante do Smart Glasses sobre o jogo.</string>
|
||||
<string name="display_filter_game_profile">Perfil %1$s em uso: %2$s</string>
|
||||
<string name="display_filter_default_profile">Perfil predefinido em uso: %1$s</string>
|
||||
</resources>
|
||||
@@ -1171,6 +1171,11 @@
|
||||
<string name="agent_tools_missing">Instrumentele agentului nu sunt instalate: %1$s</string>
|
||||
<string name="agent_unqueue">Nu trimite</string>
|
||||
<string name="agent_attach">Atașează</string>
|
||||
<string name="agent_attach_files">Fișiere</string>
|
||||
<string name="agent_photos_allow">Permite accesul la fotografii</string>
|
||||
<string name="agent_photos_more">Alege mai multe fotografii</string>
|
||||
<string name="agent_photos_empty">Încă nu există fotografii</string>
|
||||
<string name="agent_keyboard">Tastatură</string>
|
||||
<string name="agent_remove_attachment">Elimină</string>
|
||||
<string name="agent_model_default">Implicit</string>
|
||||
<string name="agent_effort">Efort de raționament</string>
|
||||
@@ -3239,9 +3244,11 @@
|
||||
<string name="stores_hltb_hours">%1$s h</string>
|
||||
<string name="stores_hltb_minutes">%1$d min</string>
|
||||
<string name="display_picture_position">Poziția imaginii</string>
|
||||
<string name="display_picture_position_landscape">Poziția imaginii (Peisaj)</string>
|
||||
<string name="display_picture_position_portrait">Poziția imaginii (Portret)</string>
|
||||
<string name="display_position_top">Sus</string>
|
||||
<string name="display_position_bottom">Jos</string>
|
||||
<string name="display_position_center">Centru (implicit)</string>
|
||||
<string name="display_position_center">Centru</string>
|
||||
<string name="display_position_left">Stânga</string>
|
||||
<string name="display_position_right">Dreapta</string>
|
||||
<string name="setup_tab_storage">Stocare</string>
|
||||
@@ -4203,4 +4210,6 @@
|
||||
<string name="glasses_shortcut_group">Comandă rapidă în joc</string>
|
||||
<string name="glasses_show_shortcut">Afișează comanda rapidă Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Afișează butonul plutitor Smart Glasses peste joc.</string>
|
||||
<string name="display_filter_game_profile">Se folosește profilul %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Se folosește profilul implicit: %1$s</string>
|
||||
</resources>
|
||||
@@ -1174,6 +1174,11 @@
|
||||
<string name="agent_tools_missing">Инструменты агента не установлены: %1$s</string>
|
||||
<string name="agent_unqueue">Не отправлять</string>
|
||||
<string name="agent_attach">Прикрепить</string>
|
||||
<string name="agent_attach_files">Файлы</string>
|
||||
<string name="agent_photos_allow">Разрешить доступ к фото</string>
|
||||
<string name="agent_photos_more">Выбрать ещё фото</string>
|
||||
<string name="agent_photos_empty">Пока нет фото</string>
|
||||
<string name="agent_keyboard">Клавиатура</string>
|
||||
<string name="agent_remove_attachment">Удалить</string>
|
||||
<string name="agent_model_default">По умолчанию</string>
|
||||
<string name="agent_effort">Уровень рассуждений</string>
|
||||
@@ -3270,9 +3275,11 @@
|
||||
<string name="stores_storage_low">Недостаточно места (свободно %1$s, нужно %2$s)</string>
|
||||
<string name="stores_target_free_unknown">Свободное место неизвестно</string>
|
||||
<string name="display_picture_position">Положение изображения</string>
|
||||
<string name="display_picture_position_landscape">Положение изображения (Альбомная)</string>
|
||||
<string name="display_picture_position_portrait">Положение изображения (Портретная)</string>
|
||||
<string name="display_position_top">Сверху</string>
|
||||
<string name="display_position_bottom">Снизу</string>
|
||||
<string name="display_position_center">По центру (по умолчанию)</string>
|
||||
<string name="display_position_center">По центру</string>
|
||||
<string name="display_position_left">Слева</string>
|
||||
<string name="display_position_right">Справа</string>
|
||||
<string name="setup_tab_storage">Хранилище</string>
|
||||
@@ -4244,4 +4251,6 @@
|
||||
<string name="glasses_shortcut_group">Ярлык в игре</string>
|
||||
<string name="glasses_show_shortcut">Показывать ярлык Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Показывать плавающую кнопку Smart Glasses поверх игры.</string>
|
||||
<string name="display_filter_game_profile">Используется профиль %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Используется профиль по умолчанию: %1$s</string>
|
||||
</resources>
|
||||
@@ -1168,6 +1168,11 @@
|
||||
<string name="agent_tools_missing">Agentens verktyg är inte installerade: %1$s</string>
|
||||
<string name="agent_unqueue">Skicka inte</string>
|
||||
<string name="agent_attach">Bifoga</string>
|
||||
<string name="agent_attach_files">Filer</string>
|
||||
<string name="agent_photos_allow">Tillåt åtkomst till bilder</string>
|
||||
<string name="agent_photos_more">Välj fler bilder</string>
|
||||
<string name="agent_photos_empty">Inga bilder än</string>
|
||||
<string name="agent_keyboard">Tangentbord</string>
|
||||
<string name="agent_remove_attachment">Ta bort</string>
|
||||
<string name="agent_model_default">Standard</string>
|
||||
<string name="agent_effort">Resonemangsnivå</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_hltb_hours">%1$s h</string>
|
||||
<string name="stores_hltb_minutes">%1$d min</string>
|
||||
<string name="display_picture_position">Bildens position</string>
|
||||
<string name="display_picture_position_landscape">Bildens position (Liggande)</string>
|
||||
<string name="display_picture_position_portrait">Bildens position (Stående)</string>
|
||||
<string name="display_position_top">Överst</string>
|
||||
<string name="display_position_bottom">Nederst</string>
|
||||
<string name="display_position_center">Mitten (standard)</string>
|
||||
<string name="display_position_center">Mitten</string>
|
||||
<string name="display_position_left">Vänster</string>
|
||||
<string name="display_position_right">Höger</string>
|
||||
<string name="setup_tab_storage">Lagring</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">Genväg i spelet</string>
|
||||
<string name="glasses_show_shortcut">Visa Smart Glasses-genväg</string>
|
||||
<string name="glasses_show_shortcut_hint">Visa den flytande Smart Glasses-knappen ovanpå spelet.</string>
|
||||
<string name="display_filter_game_profile">Använder profilen %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Använder standardprofilen: %1$s</string>
|
||||
</resources>
|
||||
@@ -1165,6 +1165,11 @@
|
||||
<string name="agent_tools_missing">ยังไม่ได้ติดตั้งเครื่องมือของเอเจนต์: %1$s</string>
|
||||
<string name="agent_unqueue">ไม่ต้องส่ง</string>
|
||||
<string name="agent_attach">แนบ</string>
|
||||
<string name="agent_attach_files">ไฟล์</string>
|
||||
<string name="agent_photos_allow">อนุญาตให้เข้าถึงรูปภาพ</string>
|
||||
<string name="agent_photos_more">เลือกรูปภาพเพิ่ม</string>
|
||||
<string name="agent_photos_empty">ยังไม่มีรูปภาพ</string>
|
||||
<string name="agent_keyboard">แป้นพิมพ์</string>
|
||||
<string name="agent_remove_attachment">นำออก</string>
|
||||
<string name="agent_model_default">ค่าเริ่มต้น</string>
|
||||
<string name="agent_effort">ระดับการใช้เหตุผล</string>
|
||||
@@ -3180,9 +3185,11 @@
|
||||
<string name="stores_hltb_hours">%1$s ชม.</string>
|
||||
<string name="stores_hltb_minutes">%1$d นาที</string>
|
||||
<string name="display_picture_position">ตำแหน่งภาพ</string>
|
||||
<string name="display_picture_position_landscape">ตำแหน่งภาพ (แนวนอน)</string>
|
||||
<string name="display_picture_position_portrait">ตำแหน่งภาพ (แนวตั้ง)</string>
|
||||
<string name="display_position_top">บน</string>
|
||||
<string name="display_position_bottom">ล่าง</string>
|
||||
<string name="display_position_center">กลาง (ค่าเริ่มต้น)</string>
|
||||
<string name="display_position_center">กลาง</string>
|
||||
<string name="display_position_left">ซ้าย</string>
|
||||
<string name="display_position_right">ขวา</string>
|
||||
<string name="setup_tab_storage">พื้นที่จัดเก็บ</string>
|
||||
@@ -4133,4 +4140,6 @@
|
||||
<string name="glasses_shortcut_group">ทางลัดในเกม</string>
|
||||
<string name="glasses_show_shortcut">แสดงทางลัด Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">แสดงปุ่ม Smart Glasses แบบลอยทับบนเกม</string>
|
||||
<string name="display_filter_game_profile">ใช้โปรไฟล์ %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">ใช้โปรไฟล์เริ่มต้น: %1$s</string>
|
||||
</resources>
|
||||
@@ -1160,6 +1160,11 @@
|
||||
<string name="agent_tools_missing">Ajan araçları yüklenmedi: %1$s</string>
|
||||
<string name="agent_unqueue">Gönderme</string>
|
||||
<string name="agent_attach">Ekle</string>
|
||||
<string name="agent_attach_files">Dosyalar</string>
|
||||
<string name="agent_photos_allow">Fotoğraflara erişime izin ver</string>
|
||||
<string name="agent_photos_more">Daha fazla fotoğraf seç</string>
|
||||
<string name="agent_photos_empty">Henüz fotoğraf yok</string>
|
||||
<string name="agent_keyboard">Klavye</string>
|
||||
<string name="agent_remove_attachment">Kaldır</string>
|
||||
<string name="agent_model_default">Varsayılan</string>
|
||||
<string name="agent_effort">Akıl yürütme çabası</string>
|
||||
@@ -3209,9 +3214,11 @@
|
||||
<string name="stores_storage_low">Yetersiz alan (%1$s boş, %2$s gerekli)</string>
|
||||
<string name="stores_target_free_unknown">Boş alan bilinmiyor</string>
|
||||
<string name="display_picture_position">Görüntü konumu</string>
|
||||
<string name="display_picture_position_landscape">Görüntü konumu (Yatay)</string>
|
||||
<string name="display_picture_position_portrait">Görüntü konumu (Dikey)</string>
|
||||
<string name="display_position_top">Üst</string>
|
||||
<string name="display_position_bottom">Alt</string>
|
||||
<string name="display_position_center">Orta (varsayılan)</string>
|
||||
<string name="display_position_center">Orta</string>
|
||||
<string name="display_position_left">Sol</string>
|
||||
<string name="display_position_right">Sağ</string>
|
||||
<string name="setup_tab_storage">Depolama</string>
|
||||
@@ -4163,4 +4170,6 @@
|
||||
<string name="glasses_shortcut_group">Oyun içi kısayol</string>
|
||||
<string name="glasses_show_shortcut">Smart Glasses kısayolunu göster</string>
|
||||
<string name="glasses_show_shortcut_hint">Oyun üzerinde yüzen Smart Glasses düğmesini göster.</string>
|
||||
<string name="display_filter_game_profile">%1$s profili kullanılıyor: %2$s</string>
|
||||
<string name="display_filter_default_profile">Varsayılan profil kullanılıyor: %1$s</string>
|
||||
</resources>
|
||||
@@ -1174,6 +1174,11 @@
|
||||
<string name="agent_tools_missing">Інструменти агента не встановлено: %1$s</string>
|
||||
<string name="agent_unqueue">Не надсилати</string>
|
||||
<string name="agent_attach">Прикріпити</string>
|
||||
<string name="agent_attach_files">Файли</string>
|
||||
<string name="agent_photos_allow">Дозволити доступ до фото</string>
|
||||
<string name="agent_photos_more">Вибрати ще фото</string>
|
||||
<string name="agent_photos_empty">Поки немає фото</string>
|
||||
<string name="agent_keyboard">Клавіатура</string>
|
||||
<string name="agent_remove_attachment">Видалити</string>
|
||||
<string name="agent_model_default">За замовчуванням</string>
|
||||
<string name="agent_effort">Рівень міркувань</string>
|
||||
@@ -3269,9 +3274,11 @@
|
||||
<string name="stores_hltb_hours">%1$s год</string>
|
||||
<string name="stores_hltb_minutes">%1$d хв</string>
|
||||
<string name="display_picture_position">Позиція зображення</string>
|
||||
<string name="display_picture_position_landscape">Позиція зображення (Альбомна)</string>
|
||||
<string name="display_picture_position_portrait">Позиція зображення (Книжкова)</string>
|
||||
<string name="display_position_top">Угорі</string>
|
||||
<string name="display_position_bottom">Унизу</string>
|
||||
<string name="display_position_center">По центру (типово)</string>
|
||||
<string name="display_position_center">По центру</string>
|
||||
<string name="display_position_left">Ліворуч</string>
|
||||
<string name="display_position_right">Праворуч</string>
|
||||
<string name="setup_tab_storage">Сховище</string>
|
||||
@@ -4243,4 +4250,6 @@
|
||||
<string name="glasses_shortcut_group">Ярлик у грі</string>
|
||||
<string name="glasses_show_shortcut">Показувати ярлик Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Показувати плаваючу кнопку Smart Glasses поверх гри.</string>
|
||||
<string name="display_filter_game_profile">Використовується профіль %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Використовується профіль за замовчуванням: %1$s</string>
|
||||
</resources>
|
||||
@@ -1165,6 +1165,11 @@
|
||||
<string name="agent_tools_missing">Chưa cài công cụ của tác tử: %1$s</string>
|
||||
<string name="agent_unqueue">Không gửi</string>
|
||||
<string name="agent_attach">Đính kèm</string>
|
||||
<string name="agent_attach_files">Tệp</string>
|
||||
<string name="agent_photos_allow">Cho phép truy cập ảnh</string>
|
||||
<string name="agent_photos_more">Chọn thêm ảnh</string>
|
||||
<string name="agent_photos_empty">Chưa có ảnh</string>
|
||||
<string name="agent_keyboard">Bàn phím</string>
|
||||
<string name="agent_remove_attachment">Xóa</string>
|
||||
<string name="agent_model_default">Mặc định</string>
|
||||
<string name="agent_effort">Mức độ lập luận</string>
|
||||
@@ -3180,9 +3185,11 @@
|
||||
<string name="stores_hltb_hours">%1$s giờ</string>
|
||||
<string name="stores_hltb_minutes">%1$d phút</string>
|
||||
<string name="display_picture_position">Vị trí ảnh</string>
|
||||
<string name="display_picture_position_landscape">Vị trí ảnh (Ngang)</string>
|
||||
<string name="display_picture_position_portrait">Vị trí ảnh (Dọc)</string>
|
||||
<string name="display_position_top">Trên</string>
|
||||
<string name="display_position_bottom">Dưới</string>
|
||||
<string name="display_position_center">Giữa (mặc định)</string>
|
||||
<string name="display_position_center">Giữa</string>
|
||||
<string name="display_position_left">Trái</string>
|
||||
<string name="display_position_right">Phải</string>
|
||||
<string name="setup_tab_storage">Lưu trữ</string>
|
||||
@@ -4133,4 +4140,6 @@
|
||||
<string name="glasses_shortcut_group">Lối tắt trong trò chơi</string>
|
||||
<string name="glasses_show_shortcut">Hiển thị lối tắt Smart Glasses</string>
|
||||
<string name="glasses_show_shortcut_hint">Hiển thị nút Smart Glasses nổi phía trên trò chơi.</string>
|
||||
<string name="display_filter_game_profile">Đang dùng hồ sơ %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Đang dùng hồ sơ mặc định: %1$s</string>
|
||||
</resources>
|
||||
@@ -1248,6 +1248,11 @@
|
||||
<string name="agent_tools_missing">智能体工具未安装:%1$s</string>
|
||||
<string name="agent_unqueue">不发送</string>
|
||||
<string name="agent_attach">添加附件</string>
|
||||
<string name="agent_attach_files">文件</string>
|
||||
<string name="agent_photos_allow">允许访问照片</string>
|
||||
<string name="agent_photos_more">选择更多照片</string>
|
||||
<string name="agent_photos_empty">还没有照片</string>
|
||||
<string name="agent_keyboard">键盘</string>
|
||||
<string name="agent_remove_attachment">移除</string>
|
||||
<string name="agent_model_default">默认</string>
|
||||
<string name="agent_effort">推理强度</string>
|
||||
@@ -3180,9 +3185,11 @@
|
||||
<string name="drawer_component_downloads_hint">下载内容与“组件”页面共享。在上方选择已下载的版本,即可在下次启动游戏时使用。</string>
|
||||
<string name="drawer_component_choose_download">选择要下载的版本</string>
|
||||
<string name="display_picture_position">画面位置</string>
|
||||
<string name="display_picture_position_landscape">画面位置(横屏)</string>
|
||||
<string name="display_picture_position_portrait">画面位置(竖屏)</string>
|
||||
<string name="display_position_top">置顶</string>
|
||||
<string name="display_position_bottom">置底</string>
|
||||
<string name="display_position_center">居中(默认)</string>
|
||||
<string name="display_position_center">居中</string>
|
||||
<string name="display_position_left">左侧</string>
|
||||
<string name="display_position_right">右侧</string>
|
||||
<string name="setup_tab_storage">存储</string>
|
||||
@@ -4131,4 +4138,6 @@
|
||||
<string name="glasses_shortcut_group">游戏内快捷方式</string>
|
||||
<string name="glasses_show_shortcut">显示 Smart Glasses 快捷方式</string>
|
||||
<string name="glasses_show_shortcut_hint">在游戏画面上显示悬浮的 Smart Glasses 按钮。</string>
|
||||
<string name="display_filter_game_profile">正在使用 %1$s 配置:%2$s</string>
|
||||
<string name="display_filter_default_profile">正在使用默认配置:%1$s</string>
|
||||
</resources>
|
||||
Loaded 100 of 200 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user