mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f3b885ee0 | ||
|
|
97e84184ed | ||
|
|
66a4d28044 |
No files matched your search
@@ -99,7 +99,7 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
|
||||
- Battle.net installs drive Blizzard's Agent the way [@barncastle](https://github.com/barncastle)'s [Battle.Net-Installer](https://github.com/barncastle/Battle.Net-Installer) does, with requests from [wowdev.wiki](https://wowdev.wiki/Agent). Read without taking code: [@mubaraknumann](https://github.com/mubaraknumann)'s [unifideck](https://github.com/mubaraknumann/unifideck), [@djmittens](https://github.com/djmittens)'s [neo-mittens](https://github.com/djmittens/neo-mittens) `bnetswitch`, [@BCD1210](https://github.com/BCD1210)'s [soju](https://github.com/BCD1210/soju) and [Lutris](https://github.com/lutris/lutris)'s `product.db` reader.
|
||||
- The Rockstar launcher service looks for launcher pipe names in the executables beside the game, since [CitizenFX](https://github.com/citizenfx/fivem)'s `ros-patches-five` shows GTA V opening `GTAVLauncher_Pipe` and [@pingod](https://github.com/pingod)'s [rdr2-linux-launcher](https://github.com/pingod/rdr2-linux-launcher) notes that Rockstar's protected executables resolve such strings only at run time. Read without taking code.
|
||||
- World of Warcraft addon imports replace an addon's folder from a temporary copy, as [WowUp](https://github.com/WowUp/WowUp) does, and read flavour folders the way [WoWDeck](https://github.com/sigboe/wowdeck) does. No code from either is used.
|
||||
- The World of Warcraft addon Download window searches [WoWInterface](https://www.wowinterface.com) through its MMOUI API. Installed addons show their `.toc` version and `X-WoWI-ID`, and are checked against that list for updates, as [WowUp](https://github.com/WowUp/WowUp) does. The Addons tab installs the official [CurseForge](https://www.curseforge.com/download/app) Linux app from CurseForge's own update feed (downloaded at install time and checked against its SHA-512, not included), which keeps its own sign-in.
|
||||
- The World of Warcraft addon Download window searches [WoWInterface](https://www.wowinterface.com) through its MMOUI API. [CurseForge](https://www.curseforge.com/wow) opens in the user's browser, with no API and no key.
|
||||
- The Xbox store runs [@domsvoboda](https://github.com/domsvoboda)'s [nexus-backend](https://github.com/domsvoboda/nexus-backend) 0.2.15 (GPL-3.0, a fork of [Xodus](https://github.com/xodus-gaming/xodus)), and Xbox games load the Windows modules of his [nexus-runtime](https://github.com/domsvoboda/nexus-runtime) (LGPL-2.1-or-later), including the C++ [nexus-xgameruntime](https://github.com/domsvoboda/nexus-xgameruntime) and `wintypes.dll`. Content licensing sends delegation-compact device tickets in the licensing wire form, as nexus-backend's Store license path (commit `27c335e`) does. Minecraft's GameInput setup was checked against [@Wyze3306](https://github.com/Wyze3306)'s [BedrockOnLinux](https://github.com/Wyze3306/BedrockOnLinux) (MIT).
|
||||
- The Xbox Cloud Gaming player uses the WebRTC client of [@unknownskl](https://github.com/unknownskl)'s [Greenlight](https://github.com/unknownskl/greenlight) (MIT), and its offer tweaks and sharpening follow [@redphx](https://github.com/redphx)'s [Better xCloud](https://github.com/redphx/better-xcloud) (MIT). See `tools/xcloud-player/NOTICE.md`.
|
||||
- The itch.io butler pack ships butler's `7z.so`, itch.io's build of [7-Zip](https://www.7-zip.org) by Igor Pavlov (LGPL-2.1, unRAR restriction on RAR code), unmodified. Other archives use Apache Commons Compress and the runtime's bsdtar (libarchive).
|
||||
|
||||
@@ -518,10 +518,6 @@ static int alloc_slot(struct layer *l, struct slot *s, int w, int h, uint32_t fm
|
||||
img = vkp_image_import_dmabuf(nh->data[0], fmt == AHB_RGB10A2 ? DRM_ABGR2101010 : DRM_ABGR8888, mod, w, h,
|
||||
got.stride * 4, 0, 1);
|
||||
path = "dma-buf (QTI handle)";
|
||||
if (!img && mod == MOD_LINEAR && vkp_can_import_ahb()) {
|
||||
img = vkp_image_import_ahb(ahb, info, sizeof(info));
|
||||
if (img) { mod = SC_MOD_GRALLOC; path = "AHardwareBuffer"; }
|
||||
}
|
||||
} else {
|
||||
if (tier == TIER_UBWC) {
|
||||
char hd[256];
|
||||
@@ -945,7 +941,7 @@ int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const stru
|
||||
|
||||
int wait_fd;
|
||||
int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &wait_fd);
|
||||
if (idx < 0) { log_drop(l); return g_alloc_failed ? -1 : 0; }
|
||||
if (idx < 0) { log_drop(l); return 0; }
|
||||
if (vkp_blit_image(src, l->slots[idx].img, wait_fd) != 0) return -1;
|
||||
if (present_slot(l, idx, r, color, 0) != 0) return -1;
|
||||
if (color && color->dataspace) droiddeck_color_frame_shown(color, DROIDDECK_HDR_LAYER_COPY, AHB_RGBA8);
|
||||
@@ -1154,7 +1150,7 @@ int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int transl
|
||||
if (sw <= 0 || sh <= 0) return -1;
|
||||
int wait_fd;
|
||||
int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &wait_fd);
|
||||
if (idx < 0) { log_drop(l); return g_alloc_failed ? -1 : 0; }
|
||||
if (idx < 0) { log_drop(l); return 0; }
|
||||
if (vkp_blit_image(src, l->slots[idx].img, wait_fd) != 0) return -1;
|
||||
if (present_slot(l, idx, geo, NULL, translucent) != 0) return -1;
|
||||
if (!l->first_logged) {
|
||||
|
||||
@@ -24,12 +24,6 @@ static inline uint32_t vkp_linear_dmabuf_texel_bytes(VkFormat fmt) {
|
||||
return fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? 8u : 4u;
|
||||
}
|
||||
|
||||
static inline int vkp_padded_linear_target_needs_layout(int drm_modifiers, uint64_t modifier, VkFormat fmt,
|
||||
int w, uint32_t stride, uint32_t offset) {
|
||||
return !drm_modifiers && modifier == 0 &&
|
||||
(offset != 0 || (uint64_t)stride != (uint64_t)w * vkp_linear_dmabuf_texel_bytes(fmt));
|
||||
}
|
||||
|
||||
static inline VkDeviceSize vkp_linear_dmabuf_copy(VkFormat fmt, int w, int h, uint32_t stride, uint32_t offset,
|
||||
VkBufferImageCopy *copy) {
|
||||
const uint32_t texel = vkp_linear_dmabuf_texel_bytes(fmt);
|
||||
@@ -45,11 +39,11 @@ static inline VkDeviceSize vkp_linear_dmabuf_copy(VkFormat fmt, int w, int h, ui
|
||||
}
|
||||
|
||||
static inline VkBufferMemoryBarrier vkp_linear_dmabuf_ownership(VkBuffer buffer, uint32_t queue_family,
|
||||
VkAccessFlags access, int acquire) {
|
||||
int acquire) {
|
||||
return (VkBufferMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
|
||||
.srcAccessMask = acquire ? 0 : access,
|
||||
.dstAccessMask = acquire ? access : 0,
|
||||
.srcAccessMask = acquire ? 0 : VK_ACCESS_TRANSFER_READ_BIT,
|
||||
.dstAccessMask = acquire ? VK_ACCESS_TRANSFER_READ_BIT : 0,
|
||||
.srcQueueFamilyIndex = acquire ? VK_QUEUE_FAMILY_FOREIGN_EXT : queue_family,
|
||||
.dstQueueFamilyIndex = acquire ? queue_family : VK_QUEUE_FAMILY_FOREIGN_EXT,
|
||||
.buffer = buffer,
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
X(ResetCommandBuffer) X(BeginCommandBuffer) X(CmdPipelineBarrier) X(CmdBlitImage) \
|
||||
X(EndCommandBuffer) X(ResetFences) X(QueueSubmit) X(QueuePresentKHR) X(WaitForFences) \
|
||||
X(QueueWaitIdle) X(GetMemoryFdPropertiesKHR) X(GetAndroidHardwareBufferPropertiesANDROID) \
|
||||
X(GetImageSubresourceLayout) X(MapMemory) X(UnmapMemory) X(CmdClearColorImage) X(CmdCopyImageToBuffer) \
|
||||
X(GetImageSubresourceLayout) X(MapMemory) X(UnmapMemory) X(CmdClearColorImage) \
|
||||
X(CreateBuffer) X(DestroyBuffer) X(GetBufferMemoryRequirements) X(BindBufferMemory) \
|
||||
X(CmdCopyBufferToImage) \
|
||||
\
|
||||
|
||||
@@ -1123,7 +1123,7 @@ static void release_external_client_draws(VkCommandBuffer cmd, const struct vkp_
|
||||
static void stage_linear_dmabuf(VkCommandBuffer cmd, const struct vkp_image *img) {
|
||||
if (!img || !img->linear_buf) return;
|
||||
const VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
VkBufferMemoryBarrier acquire = vkp_linear_dmabuf_ownership(img->linear_buf, g_qfam, VK_ACCESS_TRANSFER_READ_BIT, 1);
|
||||
VkBufferMemoryBarrier acquire = vkp_linear_dmabuf_ownership(img->linear_buf, g_qfam, 1);
|
||||
VkImageMemoryBarrier write = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
@@ -1132,7 +1132,7 @@ static void stage_linear_dmabuf(VkCommandBuffer cmd, const struct vkp_image *img
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
|
||||
0, NULL, 1, &acquire, 1, &write);
|
||||
g_vk.CmdCopyBufferToImage(cmd, img->linear_buf, img->image, VK_IMAGE_LAYOUT_GENERAL, 1, &img->linear_copy);
|
||||
VkBufferMemoryBarrier release = vkp_linear_dmabuf_ownership(img->linear_buf, g_qfam, VK_ACCESS_TRANSFER_READ_BIT, 0);
|
||||
VkBufferMemoryBarrier release = vkp_linear_dmabuf_ownership(img->linear_buf, g_qfam, 0);
|
||||
VkImageMemoryBarrier read = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
@@ -1259,8 +1259,7 @@ static int import_linear_dmabuf(struct vkp_image *img, int fd, const VkBufferIma
|
||||
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO,
|
||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT};
|
||||
VkBufferCreateInfo bci = {.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = &ext, .size = size,
|
||||
.usage = img->blit_dst ? VK_BUFFER_USAGE_TRANSFER_DST_BIT : VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE};
|
||||
.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT, .sharingMode = VK_SHARING_MODE_EXCLUSIVE};
|
||||
VkResult r = g_vk.CreateBuffer(g_dev, &bci, NULL, &img->linear_buf);
|
||||
if (r != VK_SUCCESS) goto fail;
|
||||
uint32_t allowed = 0xffffffff;
|
||||
@@ -1313,8 +1312,8 @@ static int import_linear_dmabuf(struct vkp_image *img, int fd, const VkBufferIma
|
||||
img->in_general = 1;
|
||||
return 0;
|
||||
fail:
|
||||
LOGE("dmabuf: %s the linear %dx%d buffer at its row pitch failed (%s)",
|
||||
img->blit_dst ? "writing" : "reading", img->w, img->h, vk_result_name(r));
|
||||
LOGE("dmabuf: reading the linear %dx%d buffer at its row pitch failed (%s); importing it as an image",
|
||||
img->w, img->h, vk_result_name(r));
|
||||
if (dupfd >= 0) close(dupfd);
|
||||
destroy_image_objects(img);
|
||||
return -1;
|
||||
@@ -1325,20 +1324,15 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
|
||||
if (modifier == MOD_INVALID || w <= 0 || h <= 0) return NULL;
|
||||
if (dev_init() != 0) return NULL;
|
||||
|
||||
const VkFormat format = drm_to_vk(drm_format);
|
||||
const int padded_target = as_blit_dst &&
|
||||
vkp_padded_linear_target_needs_layout(g_drm_modifiers, modifier, format, w, stride, offset);
|
||||
if (padded_target && !g_vk.CmdCopyImageToBuffer) return NULL;
|
||||
|
||||
struct vkp_image *img = calloc(1, sizeof(*img));
|
||||
if (!img) return NULL;
|
||||
img->w = w; img->h = h; img->dmabuf = 1; img->blit_dst = as_blit_dst ? 1 : 0;
|
||||
img->fmt = format;
|
||||
const int through_buffer = padded_target || vkp_linear_dmabuf_through_buffer(g_drm_modifiers, modifier, as_blit_dst);
|
||||
img->fmt = drm_to_vk(drm_format);
|
||||
const int through_buffer = vkp_linear_dmabuf_through_buffer(g_drm_modifiers, modifier, as_blit_dst);
|
||||
const VkImageUsageFlags sampled_usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
const int modifier_sampled = !as_blit_dst && g_drm_modifiers && g_vk.GetPhysicalDeviceImageFormatProperties2 &&
|
||||
modifier_importable(img->fmt, modifier, sampled_usage);
|
||||
img->sampled = !as_blit_dst && (through_buffer ? optimal_sampled(img->fmt) : modifier_sampled);
|
||||
img->sampled = through_buffer ? optimal_sampled(img->fmt) : modifier_sampled;
|
||||
/* Each new format/modifier/size a client hands over, once, for the graphics report: a colour
|
||||
* or swizzle mismatch on a non-Adreno driver shows up as the pair it arrived as. */
|
||||
{
|
||||
@@ -1364,12 +1358,7 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
|
||||
if (through_buffer) {
|
||||
VkBufferImageCopy linear_copy;
|
||||
const VkDeviceSize linear_size = vkp_linear_dmabuf_copy(img->fmt, w, h, stride, offset, &linear_copy);
|
||||
if (linear_size && import_linear_dmabuf(img, fd, &linear_copy, linear_size) == 0) {
|
||||
if (padded_target) droiddeck_log("gpu", "linear layer target %dx%d writes at pitch %u via DMA-BUF",
|
||||
w, h, stride);
|
||||
return img;
|
||||
}
|
||||
if (padded_target) { free(img); return NULL; }
|
||||
if (linear_size && import_linear_dmabuf(img, fd, &linear_copy, linear_size) == 0) return img;
|
||||
img->sampled = modifier_sampled;
|
||||
}
|
||||
VkSubresourceLayout plane = {.offset = offset, .rowPitch = stride};
|
||||
@@ -2533,48 +2522,6 @@ int vkp_map_draw(const struct vkp_draw *d, int out[8]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void blit_to_layer(VkCommandBuffer cmd, VkImage src, VkImageLayout src_layout, struct vkp_image *dst,
|
||||
const VkImageBlit *blit, VkFilter filter) {
|
||||
const VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
const VkImageMemoryBarrier acquire = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.srcQueueFamilyIndex = dst->staged ? VK_QUEUE_FAMILY_IGNORED : VK_QUEUE_FAMILY_FOREIGN_EXT,
|
||||
.dstQueueFamilyIndex = dst->staged ? VK_QUEUE_FAMILY_IGNORED : g_qfam,
|
||||
.image = dst->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, NULL, 0, NULL, 1, &acquire);
|
||||
g_vk.CmdBlitImage(cmd, src, src_layout, dst->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, blit, filter);
|
||||
if (dst->staged) {
|
||||
const VkImageMemoryBarrier read = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = dst->image, .subresourceRange = range, .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT};
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, NULL, 0, NULL, 1, &read);
|
||||
const VkBufferMemoryBarrier write = vkp_linear_dmabuf_ownership(dst->linear_buf, g_qfam, VK_ACCESS_TRANSFER_WRITE_BIT, 1);
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, NULL, 1, &write, 0, NULL);
|
||||
VkBufferImageCopy copy = dst->linear_copy;
|
||||
copy.imageExtent.width = (uint32_t)blit->dstOffsets[1].x;
|
||||
copy.imageExtent.height = (uint32_t)blit->dstOffsets[1].y;
|
||||
g_vk.CmdCopyImageToBuffer(cmd, dst->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst->linear_buf, 1, ©);
|
||||
const VkBufferMemoryBarrier release = vkp_linear_dmabuf_ownership(dst->linear_buf, g_qfam, VK_ACCESS_TRANSFER_WRITE_BIT, 0);
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||
0, 0, NULL, 1, &release, 0, NULL);
|
||||
return;
|
||||
}
|
||||
const VkImageMemoryBarrier release = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = g_qfam,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .image = dst->image, .subresourceRange = range,
|
||||
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||
0, 0, NULL, 0, NULL, 1, &release);
|
||||
}
|
||||
|
||||
int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
|
||||
if (!src || src->blit_dst || !dst || !dst->blit_dst || g_dev_state == -2 || dev_init() != 0) {
|
||||
if (wait_fd >= 0) close(wait_fd);
|
||||
@@ -2593,28 +2540,41 @@ int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
|
||||
struct vkp_external_client_barrier_pair src_pair;
|
||||
const int src_external = vkp_external_client_barrier_pair(
|
||||
src->image, g_qfam, foreign_image(src), src->blit_dst, &src_pair);
|
||||
VkImageMemoryBarrier acq = src_external ? src_pair.acquire : (VkImageMemoryBarrier){
|
||||
VkImageMemoryBarrier acq[2] = {
|
||||
src_external ? src_pair.acquire : (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT};
|
||||
.image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT},
|
||||
{.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .dstQueueFamilyIndex = g_qfam,
|
||||
.image = dst->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT}};
|
||||
if (!src_external) {
|
||||
acq.oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_PREINITIALIZED;
|
||||
acq.newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
acq.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
||||
acq[0].oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_PREINITIALIZED;
|
||||
acq[0].newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
acq[0].srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
||||
src->in_general = 1;
|
||||
}
|
||||
g_vk.CmdPipelineBarrier(g_cmd, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &acq);
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 2, acq);
|
||||
int bw = src->w < dst->w ? src->w : dst->w, bh = src->h < dst->h ? src->h : dst->h;
|
||||
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||
.srcOffsets = {{0, 0, 0}, {bw, bh, 1}},
|
||||
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||
.dstOffsets = {{0, 0, 0}, {bw, bh, 1}}};
|
||||
blit_to_layer(g_cmd, src->image, src_external ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
||||
dst, &blit, VK_FILTER_NEAREST);
|
||||
g_vk.CmdBlitImage(g_cmd, src->image,
|
||||
src_external ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
||||
dst->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit, VK_FILTER_NEAREST);
|
||||
release_external_client_image(g_cmd, src);
|
||||
VkImageMemoryBarrier rel = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = g_qfam,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .image = dst->image, .subresourceRange = range,
|
||||
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
|
||||
g_vk.CmdPipelineBarrier(g_cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||
0, 0, NULL, 0, NULL, 1, &rel);
|
||||
g_vk.EndCommandBuffer(g_cmd);
|
||||
|
||||
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||
@@ -2930,14 +2890,31 @@ static int pass_finish(const VkImage *srcs, VkImageLayout src_layout, struct vkp
|
||||
}
|
||||
const int gpu_wait = take_wait_fd(wait_fd);
|
||||
if (gpu_wait < 0) { g_vk.EndCommandBuffer(cmd); return -1; }
|
||||
VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
struct vkp_image *dst = dsts[i];
|
||||
VkImageMemoryBarrier acq = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, .srcQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT,
|
||||
.dstQueueFamilyIndex = g_qfam, .image = dst->image, .subresourceRange = range,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, NULL, 0, NULL, 1, &acq);
|
||||
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||
.srcOffsets = {{0, 0, 0}, {g_pass.rw, g_pass.rh, 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);
|
||||
g_vk.CmdBlitImage(cmd, srcs[i], src_layout, dst->image,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit,
|
||||
(g_pass.rw == dst->w && g_pass.rh == dst->h) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR);
|
||||
VkImageMemoryBarrier rel = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = g_qfam,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .image = dst->image, .subresourceRange = range,
|
||||
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT};
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||
0, 0, NULL, 0, NULL, 1, &rel);
|
||||
}
|
||||
g_vk.EndCommandBuffer(cmd);
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ class App : Application() {
|
||||
com.droiddeck.launcher.input.ShortcutsRelay.Holder.install(this)
|
||||
com.droiddeck.launcher.agent.AgentHost.refresh(this)
|
||||
com.droiddeck.launcher.ui.NavTabs.load(this)
|
||||
com.droiddeck.launcher.ui.DrawerPages.load(this)
|
||||
com.droiddeck.launcher.ui.DeveloperTools.load(this)
|
||||
com.droiddeck.launcher.ui.AgentPet.install(this)
|
||||
if (com.droiddeck.launcher.agent.AgentTab.visible) com.droiddeck.launcher.lab.LabNotice.openOnInstall = "agent"
|
||||
|
||||
@@ -199,7 +199,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
private var launcherOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
|
||||
private var homePage by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM)
|
||||
private var launcherFullscreen by mutableStateOf(true)
|
||||
private var controllerHaptics by mutableStateOf(true)
|
||||
private var downloadSource by mutableStateOf(DownloadSource.MODE_AUTO)
|
||||
private var downloadMirror by mutableStateOf("")
|
||||
private var downloadPrefix by mutableStateOf("")
|
||||
@@ -530,7 +529,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
saveAction(getString(R.string.main_addons_importing, name)) {
|
||||
if (SessionState.running) return@saveAction getString(R.string.main_addons_close_session)
|
||||
val imported = try {
|
||||
com.droiddeck.launcher.runtime.WowAddons.import(zip, target, context = this@FrontEndActivity)
|
||||
com.droiddeck.launcher.runtime.WowAddons.import(zip, target)
|
||||
} catch (_: com.droiddeck.launcher.runtime.WowAddons.TooLarge) {
|
||||
return@saveAction getString(R.string.main_addons_too_large, zip.name)
|
||||
}
|
||||
@@ -539,7 +538,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}
|
||||
}
|
||||
val downloads = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS).path
|
||||
pickSaveZip.launch(InAppFilePicker.buildIntent(this, listOf("zip", "rar", "7z"), getString(R.string.main_addons_pick_zip, name), downloads))
|
||||
pickSaveZip.launch(InAppFilePicker.buildIntent(this, listOf("zip"), getString(R.string.main_addons_pick_zip, name), downloads))
|
||||
}
|
||||
|
||||
private fun exportSaves(name: String, layout: GameSaves.Layout, game: () -> GameSaves.Game) {
|
||||
@@ -586,7 +585,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}
|
||||
private var settingsMode by mutableStateOf<String?>(null)
|
||||
private var resolution by mutableStateOf(com.droiddeck.launcher.session.SessionDisplay.DEFAULT_RESOLUTION)
|
||||
private var resolutionPortrait by mutableStateOf(com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE)
|
||||
private var fexPreset by mutableStateOf("")
|
||||
private var forceSsbs by mutableStateOf(false)
|
||||
private var steamClientArch by mutableStateOf("arm64")
|
||||
@@ -1266,7 +1264,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
requestedOrientation = launcherOrientation
|
||||
homePage = com.droiddeck.launcher.core.AppUiPrefs.homePage(this)
|
||||
launcherFullscreen = SessionPrefs.launcherFullscreen(this)
|
||||
controllerHaptics = SessionPrefs.controllerHaptics(this)
|
||||
downloadSource = DownloadSource.mode(this)
|
||||
downloadMirror = DownloadSource.mirror(this)
|
||||
downloadPrefix = DownloadSource.custom(this)
|
||||
@@ -1366,7 +1363,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
launcherOrientation = launcherOrientation,
|
||||
homePage = homePage,
|
||||
launcherFullscreen = launcherFullscreen,
|
||||
controllerHaptics = controllerHaptics,
|
||||
downloadSource = downloadSource,
|
||||
downloadMirror = downloadMirror,
|
||||
downloadPrefix = downloadPrefix,
|
||||
@@ -1683,7 +1679,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
com.droiddeck.launcher.core.AppUiPrefs.setHomePage(this, value)
|
||||
homePage = value
|
||||
},
|
||||
onControllerHaptics = { on -> SessionPrefs.setControllerHaptics(this, on); controllerHaptics = on },
|
||||
onLauncherFullscreen = { on ->
|
||||
SessionPrefs.setLauncherFullscreen(this, on)
|
||||
launcherFullscreen = on
|
||||
@@ -2052,7 +2047,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
if (!compatLaunch!!.loading.ended && event.keyCode !in listOf(
|
||||
KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_MUTE)) return true
|
||||
}
|
||||
if (controllerHaptics) com.droiddeck.launcher.ui.ControllerHaptics.onKey(this, event)
|
||||
if (event.keyCode == KeyEvent.KEYCODE_BUTTON_A) com.droiddeck.launcher.ui.HeldKeys.confirm = event.action == KeyEvent.ACTION_DOWN
|
||||
if (showComponents && (event.keyCode == KeyEvent.KEYCODE_BUTTON_L1 || event.keyCode == KeyEvent.KEYCODE_BUTTON_R1)) {
|
||||
if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
|
||||
@@ -2594,7 +2588,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
if (settingsMode != mode) return
|
||||
com.droiddeck.launcher.ui.ModeSheetRows(
|
||||
ModeSettings(
|
||||
mode = mode, resolution = resolution, resolutionPortrait = resolutionPortrait,
|
||||
mode = mode, resolution = resolution,
|
||||
panelSize = com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
|
||||
hdr = hdrOn, hdrReason = hdrReason, hdrDisplay = hdrDisplay, zeroCopy = zeroCopyOn,
|
||||
upscaler = upscaler, upscaleSharpness = upscaleSharpness,
|
||||
@@ -2649,8 +2643,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
onIntegration = ::configureIntegration,
|
||||
onIntegrationAppInfo = ::openAppInfo,
|
||||
onIntegrationLocation = ::openWifiDiscoverySettings,
|
||||
onResolution = { value -> SessionPrefs.setResolutionChoice(this, mode, value); loadResolutions(mode) },
|
||||
onResolutionPortrait = { value -> SessionPrefs.setResolutionChoice(this, mode, value, portrait = true); loadResolutions(mode) },
|
||||
onResolution = { value -> SessionPrefs.setResolutionChoice(this, mode, value); resolution = value },
|
||||
onHdr = { on -> com.droiddeck.launcher.session.SessionHdr.set(this, mode, on); hdrOn = on },
|
||||
onZeroCopy = { on ->
|
||||
SessionPrefs.setZeroCopy(this, mode, on); zeroCopyOn = on
|
||||
@@ -2983,17 +2976,11 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}, "shader-precache").start()
|
||||
}
|
||||
|
||||
private fun loadResolutions(mode: String) {
|
||||
val panel = com.droiddeck.launcher.session.SessionDisplay.panelSize(this)
|
||||
resolution = SessionPrefs.resolutionStored(this, mode, panel, false)
|
||||
resolutionPortrait = SessionPrefs.resolutionStored(this, mode, panel, true)
|
||||
}
|
||||
|
||||
private fun loadModeSettings(mode: String) {
|
||||
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
||||
unfoldedControls = SessionPrefs.unfoldedControls(this)
|
||||
unfoldedControlsWithController = SessionPrefs.unfoldedControlsWithController(this)
|
||||
loadResolutions(mode)
|
||||
resolution = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||
fexPreset = SessionPrefs.fexPreset(this)
|
||||
forceSsbs = SessionPrefs.forceSsbs(this)
|
||||
fastSync = SessionPrefs.fastSync(this)
|
||||
@@ -3356,7 +3343,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
Thread({
|
||||
val ok = com.droiddeck.launcher.session.SettingsReset.resetAll(this, gameProfiles, scopes)
|
||||
ui.post {
|
||||
com.droiddeck.launcher.ui.DrawerPages.load(applicationContext)
|
||||
if (isDestroyed) return@post
|
||||
com.droiddeck.launcher.core.AppLanguage.setChosen(this, com.droiddeck.launcher.core.AppLanguage.SYSTEM)
|
||||
if (!ok) android.widget.Toast.makeText(this, R.string.setup_reset_settings_partial, android.widget.Toast.LENGTH_LONG).show()
|
||||
|
||||
@@ -244,10 +244,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
override fun key(code: Int, down: Boolean) { heldKeys.set(4, code, down) }
|
||||
override fun button(code: Int, down: Boolean) { heldButtons.set(4, code, down) }
|
||||
override fun pointer(dx: Float, dy: Float) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
if (!menuOwnsController) moveInputPointer(dx, dy)
|
||||
} else uiHandler.post {
|
||||
if (resumed && !SessionState.suspended && !pipUi && !menuOwnsController && !inputSettingsOpen)
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) moveInputPointer(dx, dy)
|
||||
else uiHandler.post {
|
||||
if (resumed && !SessionState.suspended && !pipUi && !drawerOpen && !inputSettingsOpen)
|
||||
moveInputPointer(dx, dy)
|
||||
}
|
||||
}
|
||||
@@ -546,9 +545,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
drawerOpenState = value
|
||||
if (!value && drawerDocked) closeDockedMenu()
|
||||
}
|
||||
private val dockedMenuIdle: Boolean get() = com.droiddeck.launcher.input.DualScreen.menuIdleOnBottom(drawerOpen, drawerDocked, drawerPinned, dockedMenuController)
|
||||
private val dockedTouchOnly: Boolean get() = drawerOpen && drawerDocked && !dockedMenuController
|
||||
private val menuOwnsController: Boolean get() = com.droiddeck.launcher.input.DualScreen.menuOwnsController(drawerOpen, drawerDocked, dockedMenuController)
|
||||
private var quitFrom by mutableStateOf<androidx.compose.ui.geometry.Rect?>(null)
|
||||
private var quitFlooded = false
|
||||
private var leaving by mutableStateOf(false)
|
||||
@@ -592,8 +588,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var drawerPage by mutableStateOf(SessionDrawerPage.CONTROLLER)
|
||||
private var drawerControllerActive by mutableStateOf(false)
|
||||
private var backHold by mutableStateOf(true)
|
||||
private var dockedMenuController by mutableStateOf(false)
|
||||
private var sessionOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
|
||||
private var backActionsInverted by mutableStateOf(false)
|
||||
private var backDoubleTapMs by mutableStateOf(500)
|
||||
private var lowLatency by mutableStateOf(true)
|
||||
@@ -844,7 +838,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
SessionState.programArgs = intent.getStringArrayExtra(SessionService.EXTRA_PROGRAM_ARGS)?.toList().orEmpty()
|
||||
SessionEvents.begin(this, mode, SessionPaths.label(mode, intent.getStringExtra(SessionService.EXTRA_PROGRAM)))
|
||||
SessionState.secondScreenAutoOpened = false
|
||||
SessionState.bottomMenu = false
|
||||
SessionState.secondScreenProvisional = false
|
||||
SessionState.secondScreenAutomatic = false
|
||||
SessionState.gameOnBottom = false
|
||||
@@ -1116,7 +1109,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
when {
|
||||
::loading.isInitialized && loading.ended -> finish()
|
||||
inputSettingsOpen -> inputSettingsOpen = false
|
||||
dockedTouchOnly -> routeBackAction()
|
||||
drawerOpen -> drawerOpen = false
|
||||
achievementsOpen -> closeAchievements()
|
||||
pcKeyboardOpen -> pcKeyboardOpen = false
|
||||
@@ -1145,7 +1137,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
}
|
||||
val uiPointer = appUiOwnsPointer()
|
||||
val cursorHidden = cursorHiddenByUi()
|
||||
androidx.compose.runtime.SideEffect {
|
||||
com.droiddeck.launcher.glasses.GlassesMenuMirror.setSessionMenuVisible(this@SessionActivity,
|
||||
(drawerOpen || achievementsOpen || pcKeyboardOpen) && !pipUi && steamVrStatus != SteamVr.Status.RUNNING)
|
||||
@@ -1196,7 +1187,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
} else {
|
||||
com.droiddeck.launcher.ui.FocusGlideHost(androidx.compose.ui.Modifier.fillMaxSize()) {
|
||||
CursorOverlay({ cursorPos }, cursorVisible && (!cursorHidden || onlyPcKeyboardOpen()) && !bottomOutputActive,
|
||||
CursorOverlay({ cursorPos }, cursorVisible && (!uiPointer || onlyPcKeyboardOpen()) && !bottomOutputActive,
|
||||
resources.displayMetrics.density,
|
||||
cursorImage, cursorHotX, cursorHotY, cursorImageScale)
|
||||
if (memoryHud.text.isNotEmpty()) HudText(memoryHud.text, hudColor, hudOpacity)
|
||||
@@ -1313,9 +1304,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
runCatching { com.droiddeck.launcher.session.TelemetryOutput.applyAutomatic(this@SessionActivity, nextGame) }
|
||||
}
|
||||
}
|
||||
LaunchedEffect(drawerOpen, menuOwnsController, pcKeyboardOpen, achievementsOpen, gestureSettingsOpen, inputSettingsOpen, pipUi, SessionState.suspended, resumed, appTextFocus) {
|
||||
LaunchedEffect(drawerOpen, pcKeyboardOpen, achievementsOpen, gestureSettingsOpen, inputSettingsOpen, pipUi, SessionState.suspended, resumed, appTextFocus) {
|
||||
updateOnScreenControls()
|
||||
padBridge?.setInputEnabled(resumed && !menuOwnsController && !pcKeyboardOpen && !achievementsOpen && !gestureSettingsOpen && !inputSettingsOpen && !pipUi && !appTextFocus && !SessionState.suspended)
|
||||
padBridge?.setInputEnabled(resumed && !drawerOpen && !pcKeyboardOpen && !achievementsOpen && !gestureSettingsOpen && !inputSettingsOpen && !pipUi && !appTextFocus && !SessionState.suspended)
|
||||
if (drawerOpen || pcKeyboardOpen || achievementsOpen || gestureSettingsOpen || inputSettingsOpen || pipUi || appTextFocus || SessionState.suspended) {
|
||||
backQamInput.cancel()
|
||||
com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this@SessionActivity)
|
||||
@@ -1367,17 +1358,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onDismiss = { gestureSettingsOpen = false },
|
||||
onSaved = { gestureSettingsOpen = false; refreshGestureConfig() },
|
||||
)
|
||||
androidx.compose.runtime.LaunchedEffect(drawerOpen, menuOwnsController) {
|
||||
androidx.compose.runtime.LaunchedEffect(drawerOpen) {
|
||||
if (drawerOpen) {
|
||||
syncLossless()
|
||||
if (menuOwnsController) {
|
||||
releasePads()
|
||||
androidx.compose.runtime.withFrameNanos { }
|
||||
val requested = focusDrawer()
|
||||
Log.i(TAG, "drawer root focus requested=$requested docked=$drawerDocked")
|
||||
} else {
|
||||
releaseDrawerDirection()
|
||||
}
|
||||
releasePads()
|
||||
androidx.compose.runtime.withFrameNanos { }
|
||||
val requested = focusDrawer()
|
||||
Log.i(TAG, "drawer root focus requested=$requested docked=$drawerDocked")
|
||||
} else {
|
||||
releaseDrawerDirection()
|
||||
}
|
||||
@@ -1436,7 +1423,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (!SessionState.manualPause && !SessionState.suspended) pauseAnimated = false
|
||||
}
|
||||
SessionPausedOverlay(
|
||||
suspended = (SessionState.suspended || SessionState.manualPause) && (!autoResume || SessionState.resumeFailed || SessionState.manualPause),
|
||||
suspended = SessionState.suspended && (!autoResume || SessionState.resumeFailed || SessionState.manualPause),
|
||||
engaged = SessionState.resumeRequested || SessionState.resuming,
|
||||
failures = SessionState.resumeFailures,
|
||||
frame = pausedFrame,
|
||||
@@ -1774,12 +1761,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
SessionPrefs.setBackHold(this@SessionActivity, on)
|
||||
backHold = on
|
||||
},
|
||||
dockedMenuController = dockedMenuController,
|
||||
onDockedMenuController = { on ->
|
||||
SessionPrefs.setDockedMenuController(this@SessionActivity, on)
|
||||
dockedMenuController = on
|
||||
if (!on && drawerDocked) drawerControllerActive = false
|
||||
},
|
||||
backActionsInverted = backActionsInverted,
|
||||
backDoubleTapMs = backDoubleTapMs,
|
||||
onBackDoubleTapMs = { ms ->
|
||||
@@ -1848,7 +1829,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
setRelativeMouse(mode)
|
||||
},
|
||||
onFexPreset = { v -> SessionPrefs.setFexPreset(this@SessionActivity, v); readPrefs() },
|
||||
onSelectMenuMode = ::pickMenuMode,
|
||||
onSecondScreenMode = { mode ->
|
||||
if (docked) drawerOpen = false
|
||||
pickSecondScreenMode(mode)
|
||||
@@ -1872,14 +1852,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
pipAutoEnter = pipAutoEnter,
|
||||
onPip = { pip.enter() },
|
||||
onPause = ::pauseNow,
|
||||
paused = SessionState.suspended || SessionState.manualPause,
|
||||
onResume = { SessionService.resume(this@SessionActivity) },
|
||||
orientation = sessionOrientation,
|
||||
onOrientation = { value ->
|
||||
SessionPrefs.setOrientation(this@SessionActivity, value)
|
||||
sessionOrientation = value
|
||||
applyFollowOrientation(resources.configuration)
|
||||
},
|
||||
onPipAutoEnter = { on ->
|
||||
SessionPrefs.setPipAutoEnter(this@SessionActivity, on)
|
||||
pipAutoEnter = on
|
||||
@@ -1977,7 +1949,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun sendSteamGuide() {
|
||||
if (!dockedTouchOnly) drawerOpen = false
|
||||
drawerOpen = false
|
||||
padBridge?.triggerSteamMenu()
|
||||
}
|
||||
|
||||
@@ -2024,7 +1996,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun triggerSteamQam() {
|
||||
if (!dockedTouchOnly) drawerOpen = false
|
||||
drawerOpen = false
|
||||
padBridge?.triggerQam()
|
||||
}
|
||||
|
||||
@@ -2113,7 +2085,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private fun performBackAction(double: Boolean) {
|
||||
val isSteam = SessionState.mode == SessionService.MODE_STEAM
|
||||
val opensQam = isSteam && (double xor backActionsInverted)
|
||||
if (opensQam) triggerSteamQam() else if (!dockedTouchOnly) drawerOpen = !drawerOpen
|
||||
if (opensQam) triggerSteamQam() else drawerOpen = !drawerOpen
|
||||
}
|
||||
|
||||
private fun handleHomeGuideIntent(incoming: Intent?) {
|
||||
@@ -2657,8 +2629,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
oscRearButtons = SessionPrefs.oscRearButtons(this)
|
||||
oscTrackpads = SessionPrefs.oscTrackpads(this)
|
||||
backHold = SessionPrefs.backHold(this)
|
||||
dockedMenuController = SessionPrefs.dockedMenuController(this)
|
||||
sessionOrientation = SessionPrefs.orientation(this)
|
||||
backActionsInverted = SessionPrefs.backActionsInverted(this)
|
||||
physicalShortcuts.bindings = PhysicalShortcuts.read(this)
|
||||
backDoubleTapMs = SessionPrefs.backDoubleTapMs(this)
|
||||
@@ -2988,18 +2958,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
WaylandCompositor.nativeResizeOutput(size.first, size.second)
|
||||
}
|
||||
|
||||
private fun followPortrait(): Boolean = glassesScreen == null && SessionPrefs.portrait(this)
|
||||
|
||||
private fun followScale(): Float {
|
||||
val mode = displayMode()
|
||||
val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait())
|
||||
val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||
return com.droiddeck.launcher.session.SessionDisplay.followScale(choice) ?: 1f
|
||||
}
|
||||
|
||||
private fun followChoice(): Boolean {
|
||||
val mode = displayMode()
|
||||
return com.droiddeck.launcher.session.SessionDisplay.isFollow(
|
||||
SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait()))
|
||||
SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this)))
|
||||
}
|
||||
|
||||
private fun applyFollowOrientation(config: android.content.res.Configuration) {
|
||||
@@ -3065,19 +3033,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private fun displayMode(): String = SessionPrefs.displayMode(this,
|
||||
intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM, intent.getStringExtra(SessionService.EXTRA_PROGRAM))
|
||||
|
||||
private fun portraitOutput(): Boolean = SessionPrefs.portrait(this) && !controlsBelowWanted()
|
||||
|
||||
private fun outputSize(): Pair<Int, Int> =
|
||||
com.droiddeck.launcher.session.SessionDisplay.resolveChoice(com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
|
||||
resolutionChoice(), portraitOutput())
|
||||
resolutionChoice(), SessionPrefs.portrait(this) && !controlsBelowWanted())
|
||||
|
||||
private fun resolutionChoice(portrait: Boolean = SessionPrefs.portrait(this)): String {
|
||||
private fun resolutionChoice(): String {
|
||||
val mode = displayMode()
|
||||
val program = intent.getStringExtra(SessionService.EXTRA_PROGRAM)
|
||||
return if (intent.getStringExtra(SessionService.EXTRA_MODE) == SessionService.MODE_RUN &&
|
||||
Library.drawsAtPanel(program) && !SessionPrefs.resolutionChosen(this, mode, portrait))
|
||||
Library.drawsAtPanel(program) && !SessionPrefs.resolutionChosen(this, mode))
|
||||
com.droiddeck.launcher.session.SessionDisplay.MATCH_SCREEN
|
||||
else SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), portrait)
|
||||
else SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||
}
|
||||
|
||||
private fun refreshHz(): Float = refreshHz(null)
|
||||
@@ -3553,7 +3519,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val steamVolume =
|
||||
SessionState.mode == SessionService.MODE_STEAM && SessionState.running &&
|
||||
SessionState.firstFrameSeen && !SessionState.suspended && !ended &&
|
||||
!pipUi && !menuOwnsController && !pcKeyboardOpen && !achievementsOpen &&
|
||||
!pipUi && !drawerOpen && !pcKeyboardOpen && !achievementsOpen &&
|
||||
!gestureSettingsOpen && !inputSettingsOpen && !appTextFocus && window.decorView.hasWindowFocus()
|
||||
if (steamVolume) {
|
||||
val audio = getSystemService(android.media.AudioManager::class.java)
|
||||
@@ -3567,13 +3533,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (penStream.holdsKey(event) || (penSettings.mode != SessionPrefs.PEN_TOUCH && PenStream.isPenKey(event))) return penStream.onKey(event)
|
||||
if (appTextFocus) return super.dispatchKeyEvent(event)
|
||||
if (!pipUi) {
|
||||
if (physicalInputBindings?.onKey(event, resumed && !menuOwnsController && !pcKeyboardOpen && !achievementsOpen &&
|
||||
if (physicalInputBindings?.onKey(event, resumed && !drawerOpen && !pcKeyboardOpen && !achievementsOpen &&
|
||||
!inputSettingsOpen && !gestureSettingsOpen && !SessionState.suspended && !loading.visible) == true) return true
|
||||
if (physicalShortcuts.onKey(
|
||||
event,
|
||||
enabled = resumed && SessionState.running && !SessionState.suspended &&
|
||||
!(menuOwnsController && event.keyCode == KeyEvent.KEYCODE_BUTTON_A) &&
|
||||
!(menuOwnsController && PhysicalShortcuts.isDrawerNavigationKey(event)) &&
|
||||
!(drawerOpen && event.keyCode == KeyEvent.KEYCODE_BUTTON_A) &&
|
||||
!(drawerOpen && PhysicalShortcuts.isDrawerNavigationKey(event)) &&
|
||||
(event.deviceId to event.keyCode) !in resumeKeysDown &&
|
||||
!(::loading.isInitialized && (loading.visible || loading.ended)) &&
|
||||
!pcKeyboardOpen && !achievementsOpen && !gestureSettingsOpen && !inputSettingsOpen,
|
||||
@@ -3581,12 +3547,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
) { action ->
|
||||
pendingBackAction?.let(uiHandler::removeCallbacks)
|
||||
pendingBackAction = null
|
||||
if (!dockedMenuIdle) drawerControllerActive = true
|
||||
drawerControllerActive = true
|
||||
Log.i(TAG, "physical shortcut ${action.name} device=${event.deviceId} key=${event.keyCode} scan=${event.scanCode}")
|
||||
when (action) {
|
||||
PhysicalShortcuts.Action.STEAM -> sendSteamGuide()
|
||||
PhysicalShortcuts.Action.QAM -> triggerSteamQam()
|
||||
PhysicalShortcuts.Action.DROIDDECK -> if (!dockedTouchOnly) drawerOpen = !drawerOpen
|
||||
PhysicalShortcuts.Action.DROIDDECK -> drawerOpen = !drawerOpen
|
||||
}
|
||||
}) return true
|
||||
}
|
||||
@@ -3612,7 +3578,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
}
|
||||
if (mouseBackHandled) return true
|
||||
val backToQam = !pipUi && !appTextFocus && !menuOwnsController && !pcKeyboardOpen && !achievementsOpen &&
|
||||
val backToQam = !pipUi && !appTextFocus && !drawerOpen && !pcKeyboardOpen && !achievementsOpen &&
|
||||
!inputSettingsOpen && !gestureSettingsOpen &&
|
||||
SessionState.mode == SessionService.MODE_STEAM && SessionState.running && SessionState.firstFrameSeen &&
|
||||
!SessionState.suspended && padBridge?.canHoldQam() == true
|
||||
@@ -3625,12 +3591,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val pad = com.droiddeck.launcher.input.JoyCon.normalize(event)
|
||||
if (pad !== event) return dispatchKeyEvent(pad)
|
||||
val fromController = PadBridge.isControllerKeyEvent(event)
|
||||
if (fromController && (menuOwnsController || pcKeyboardOpen || achievementsOpen || inputSettingsOpen || gestureSettingsOpen || SessionState.suspended)) {
|
||||
if (fromController && (drawerOpen || pcKeyboardOpen || achievementsOpen || inputSettingsOpen || gestureSettingsOpen || SessionState.suspended)) {
|
||||
padBridge?.setInputEnabled(false)
|
||||
padBridge?.onKeyEvent(event)
|
||||
}
|
||||
if (fromController && event.action == KeyEvent.ACTION_DOWN && !dockedMenuIdle) {
|
||||
if (menuOwnsController && !drawerControllerActive) focusDrawer()
|
||||
if (fromController && event.action == KeyEvent.ACTION_DOWN) {
|
||||
if (drawerOpen && !drawerControllerActive) focusDrawer()
|
||||
drawerControllerActive = true
|
||||
}
|
||||
if (fromController && event.keyCode == KeyEvent.KEYCODE_BUTTON_B && ::loading.isInitialized && loading.visible && !loading.ended && !drawerOpen) {
|
||||
@@ -3649,7 +3615,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
val drawerShortcutKey = event.deviceId to event.keyCode
|
||||
if (fromController && (event.keyCode == KeyEvent.KEYCODE_BUTTON_SELECT || event.keyCode == KeyEvent.KEYCODE_BUTTON_START) &&
|
||||
((menuOwnsController && SessionState.mode == SessionService.MODE_STEAM) || drawerShortcutKey in drawerShortcutKeysDown)) {
|
||||
((drawerOpen && SessionState.mode == SessionService.MODE_STEAM) || drawerShortcutKey in drawerShortcutKeysDown)) {
|
||||
if (event.action == KeyEvent.ACTION_DOWN) {
|
||||
drawerShortcutKeysDown.add(drawerShortcutKey)
|
||||
if (event.repeatCount == 0) {
|
||||
@@ -3661,7 +3627,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (drawerOpen && (menuOwnsController || (!fromController && !(dockedTouchOnly && event.keyCode == KeyEvent.KEYCODE_BACK)))) {
|
||||
if (drawerOpen) {
|
||||
if (fromController && (event.keyCode == KeyEvent.KEYCODE_BUTTON_L1 || event.keyCode == KeyEvent.KEYCODE_BUTTON_R1)) {
|
||||
if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
|
||||
drawerPage = sessionDrawerPages(glasses.present)
|
||||
@@ -3731,11 +3697,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean {
|
||||
if (pipUi) return true
|
||||
notePress(event)
|
||||
if (PadBridge.isControllerMotionEvent(event) && (menuOwnsController || pcKeyboardOpen || achievementsOpen || inputSettingsOpen || gestureSettingsOpen || SessionState.suspended)) {
|
||||
if (PadBridge.isControllerMotionEvent(event) && (drawerOpen || pcKeyboardOpen || achievementsOpen || inputSettingsOpen || gestureSettingsOpen || SessionState.suspended)) {
|
||||
padBridge?.setInputEnabled(false)
|
||||
padBridge?.onMotionEvent(event)
|
||||
}
|
||||
if (menuOwnsController && PadBridge.isControllerMotionEvent(event)) {
|
||||
if (drawerOpen && PadBridge.isControllerMotionEvent(event)) {
|
||||
if (!drawerControllerActive) focusDrawer()
|
||||
drawerControllerActive = true
|
||||
if (event.actionMasked == MotionEvent.ACTION_MOVE &&
|
||||
@@ -3912,7 +3878,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun closeDockedMenu() {
|
||||
SessionState.bottomMenu = false
|
||||
drawerDocked = false
|
||||
val presentation = secondScreenPresentation ?: return
|
||||
presentation.showMenu(false)
|
||||
@@ -4338,7 +4303,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
?: if (SessionState.gameOnBottom) bottomGameDisplay()?.displayId else null
|
||||
SessionState.secondScreenAutoOpened = true
|
||||
if (gameDisplay != null && gameDisplay != target.displayId && secondScreenDisplays.any { it.id == gameDisplay }) {
|
||||
panelMode(openingSurface())
|
||||
panelMode(openingPanel())
|
||||
} else {
|
||||
val selectionChanged = selectedSecondScreenDisplay != target.displayId
|
||||
selectedSecondScreenDisplay = target.displayId
|
||||
@@ -4357,43 +4322,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun openingPanel() = SecondScreenMode.opening(SessionPrefs.secondScreenPanel(this, desktopSession), SessionState.deckPad,
|
||||
bottomPages().isNotEmpty(), com.droiddeck.launcher.session.BottomDesktop.available())
|
||||
|
||||
private fun openingSurface() = openingPanel().takeIf { it != SecondScreenMode.MENU } ?: SecondScreenMode.KEYBOARD_TRACKPAD
|
||||
|
||||
private fun menuShownOnBottom() = drawerDocked && (drawerOpen || drawerPinned)
|
||||
|
||||
private fun pinDockedMenu() {
|
||||
if (!dockDrawer()) return
|
||||
drawerLayerOpen = false
|
||||
if (!openDockedMenu()) return
|
||||
drawerDocked = true
|
||||
drawerOpenState = false
|
||||
drawerPinned = true
|
||||
updateKeyboardRoute()
|
||||
}
|
||||
|
||||
private fun showMenuMode() {
|
||||
dualControlsProvisional = false
|
||||
selectSecondScreenMode(secondScreenMode.takeIf { it != SecondScreenMode.NONE } ?: SecondScreenMode.KEYBOARD_TRACKPAD)
|
||||
if (secondScreenMode != SecondScreenMode.NONE) pinDockedMenu()
|
||||
}
|
||||
|
||||
private fun pickMenuMode() {
|
||||
typingReturnMode = null
|
||||
automaticPanel = false
|
||||
SessionPrefs.setSecondScreenPanel(this, desktopSession, SecondScreenMode.MENU.id)
|
||||
drawerOpen = true
|
||||
}
|
||||
bottomPages().isNotEmpty(), com.droiddeck.launcher.session.BottomDesktop.available(), desktopSession)
|
||||
|
||||
private fun settleDualScreenControls() {
|
||||
if (!dualControlsProvisional || pipUi || !started || (::loading.isInitialized && loading.visible)) return
|
||||
dualControlsProvisional = false
|
||||
if (secondScreenMode == SecondScreenMode.NONE) return
|
||||
val wanted = openingPanel()
|
||||
if (wanted == SecondScreenMode.MENU) {
|
||||
if (!menuShownOnBottom()) selectSecondScreenMode(wanted) else secondScreenPresentation?.retryTerminal()
|
||||
} else if (wanted != secondScreenMode) selectSecondScreenMode(wanted) else secondScreenPresentation?.retryTerminal()
|
||||
if (wanted != secondScreenMode) selectSecondScreenMode(wanted) else secondScreenPresentation?.retryTerminal()
|
||||
}
|
||||
|
||||
private fun selectSecondScreenDisplay(displayId: Int) {
|
||||
@@ -4414,10 +4350,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
closeSecondScreen(reset = true)
|
||||
return
|
||||
}
|
||||
if (mode == SecondScreenMode.MENU) {
|
||||
showMenuMode()
|
||||
return
|
||||
}
|
||||
if (secondScreenDisplays.isEmpty()) {
|
||||
panelMode(SecondScreenMode.NONE)
|
||||
return
|
||||
@@ -4434,12 +4366,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun showSecondScreen(requested: SecondScreenMode) {
|
||||
if (pipUi || !started) return
|
||||
val mode = when {
|
||||
requested == SecondScreenMode.MENU ->
|
||||
secondScreenMode.takeIf { it != SecondScreenMode.NONE && it != SecondScreenMode.MENU } ?: SecondScreenMode.KEYBOARD_TRACKPAD
|
||||
requested == SecondScreenMode.DECK_CONTROLS && !SessionState.deckPad -> openingSurface()
|
||||
else -> requested
|
||||
}
|
||||
val mode = if (requested == SecondScreenMode.DECK_CONTROLS && !SessionState.deckPad) openingPanel() else requested
|
||||
val target = displayManager.getDisplay(selectedSecondScreenDisplay)
|
||||
if (target == null || !target.isValid || (target.flags and Display.FLAG_PRESENTATION) == 0) {
|
||||
closeSecondScreen(reset = false)
|
||||
@@ -4483,7 +4410,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private fun bottomScreenPicker(mode: SecondScreenMode) = com.droiddeck.launcher.ui.ScreenPicker(
|
||||
com.droiddeck.launcher.ui.secondScreenModes(false, SessionState.deckPad, bottomPages().isNotEmpty(),
|
||||
com.droiddeck.launcher.session.BottomDesktop.available()),
|
||||
mode, ::pickSecondScreenMode, onMenu = ::pickMenuMode,
|
||||
mode, ::pickSecondScreenMode, onMenu = { drawerOpen = true },
|
||||
)
|
||||
|
||||
private fun secondScreenPresentation(target: Display) = SecondScreenPresentation(
|
||||
@@ -4695,9 +4622,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val tabRow = unfoldedColumn?.getChildAt(0)?.height?.let {
|
||||
it - (com.droiddeck.launcher.ui.BAR_HEIGHT.value * resources.displayMetrics.density + 0.5f).toInt()
|
||||
} ?: 0
|
||||
val outputAspect = if (!wanted || SessionState.followScreen) 0f
|
||||
else outputSize().let { it.first.toFloat() / it.second.coerceAtLeast(1) }
|
||||
val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, tabRow, outputAspect)
|
||||
val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, tabRow)
|
||||
else FrameLayout.LayoutParams.MATCH_PARENT
|
||||
val params = surfaceView.layoutParams as FrameLayout.LayoutParams
|
||||
if (params.height != gameHeight) {
|
||||
@@ -4909,7 +4834,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
|
||||
private fun dropDockedDrawer() {
|
||||
if (drawerDocked && (drawerOpenState || drawerPinned)) SessionState.bottomMenu = true
|
||||
drawerPinned = false
|
||||
if (!drawerDocked) return
|
||||
drawerDocked = false
|
||||
@@ -4928,7 +4852,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (reset) {
|
||||
panelMode(SecondScreenMode.NONE)
|
||||
automaticPanel = false
|
||||
SessionState.bottomMenu = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5481,13 +5404,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private fun onlyPcKeyboardOpen(): Boolean =
|
||||
pcKeyboardOpen && !drawerOpen && !achievementsOpen && !inputSettingsOpen && !pipUi && !glassesOutputActive && !touchEditorOpen && !wowChatOnTop
|
||||
|
||||
private fun otherUiOwnsPointer(): Boolean =
|
||||
pcKeyboardOpen || achievementsOpen || inputSettingsOpen || pipUi || glassesOutputActive || bottomOutputActive || touchEditorOpen || wowChatOnTop
|
||||
|
||||
private fun appUiOwnsPointer(): Boolean = drawerOpen || otherUiOwnsPointer()
|
||||
|
||||
/** A touch-only docked menu leaves the game cursor alone, so controller pointer moves stay visible. */
|
||||
private fun cursorHiddenByUi(): Boolean = menuOwnsController || otherUiOwnsPointer()
|
||||
private fun appUiOwnsPointer(): Boolean =
|
||||
drawerOpen || pcKeyboardOpen || achievementsOpen || inputSettingsOpen || pipUi || glassesOutputActive || bottomOutputActive || touchEditorOpen || wowChatOnTop
|
||||
|
||||
private fun applyPlatformPointer(shown: Boolean) {
|
||||
if (!::sessionRoot.isInitialized || !::surfaceView.isInitialized) return
|
||||
@@ -5596,10 +5514,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
.takeIf { it.isFile }
|
||||
?.let { FileUtils.readString(it)?.trim()?.lowercase() }
|
||||
?: SessionPrefs.oscMode(this, SessionState.mode == SessionService.MODE_STEAM)
|
||||
unfoldedColumn?.let { column ->
|
||||
val shown = if (inputSettingsOpen) View.INVISIBLE else View.VISIBLE
|
||||
if (column.visibility != shown) { unfoldedPanel?.releaseAll(); unfoldedDeckSurface?.releaseInputs(); column.visibility = shown }
|
||||
}
|
||||
val controls = onScreenControls ?: return
|
||||
fun showPinned() {
|
||||
controls.setPinnedOnly(true)
|
||||
@@ -5765,44 +5679,31 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
heldKeys.set(owner, code, down)
|
||||
}
|
||||
|
||||
private fun capturePausedFrame(manual: Boolean = false, onDone: () -> Unit = {}) {
|
||||
fun skipped(reason: String) {
|
||||
if (manual) SessionEvents.record("pause.frame_skipped", mapOf("reason" to reason))
|
||||
onDone()
|
||||
}
|
||||
if (!SessionState.running || pipUi || isInPictureInPictureMode || glassesOutputActive || bottomOutputActive) {
|
||||
return skipped("state running=${SessionState.running} pip=$pipUi glasses=$glassesOutputActive bottom=$bottomOutputActive")
|
||||
}
|
||||
private fun capturePausedFrame(manual: Boolean = false) {
|
||||
if (!SessionState.running || pipUi || isInPictureInPictureMode || glassesOutputActive || bottomOutputActive) return
|
||||
if (SessionState.suspended && pausedFrame != null) return
|
||||
if ((suspendPolicy == SessionPrefs.SUSPEND_NEVER && !manual && !SessionState.manualPause) || !::surfaceView.isInitialized) return skipped("policy")
|
||||
if (surfaceView.holder.surface?.isValid != true) return skipped("surface invalid")
|
||||
if ((suspendPolicy == SessionPrefs.SUSPEND_NEVER && !manual && !SessionState.manualPause) || !::surfaceView.isInitialized) return
|
||||
if (surfaceView.holder.surface?.isValid != true) return
|
||||
val width = surfaceView.width
|
||||
val height = surfaceView.height
|
||||
if (width <= 0 || height <= 0) return skipped("size ${width}x$height")
|
||||
if (width <= 0 || height <= 0) return
|
||||
val scale = minOf(1f, PAUSED_FRAME_MAX_EDGE / maxOf(width, height).toFloat())
|
||||
val bitmap = try {
|
||||
android.graphics.Bitmap.createBitmap(
|
||||
maxOf(1, (width * scale).toInt()), maxOf(1, (height * scale).toInt()), android.graphics.Bitmap.Config.ARGB_8888,
|
||||
)
|
||||
} catch (_: OutOfMemoryError) {
|
||||
return skipped("oom")
|
||||
return
|
||||
}
|
||||
val surfaceAt = IntArray(2).also { surfaceView.getLocationInWindow(it) }
|
||||
val overlayAt = IntArray(2).also { sessionOverlay.getLocationInWindow(it) }
|
||||
val left = surfaceAt[0] - overlayAt[0]
|
||||
val top = surfaceAt[1] - overlayAt[1]
|
||||
val bounds = android.graphics.Rect(left, top, left + width, top + height)
|
||||
val requestedAt = SystemClock.elapsedRealtime()
|
||||
withPictureFrame { done ->
|
||||
try {
|
||||
android.view.PixelCopy.request(surfaceView, bitmap, { result ->
|
||||
done()
|
||||
onDone()
|
||||
if (manual) SessionEvents.record("pause.frame_copy", mapOf(
|
||||
"result" to result, "ms" to SystemClock.elapsedRealtime() - requestedAt,
|
||||
"zeroCopy" to SessionPrefs.zeroCopy(this, SessionState.mode), "size" to "${width}x$height",
|
||||
"lit" to (result == android.view.PixelCopy.SUCCESS && bitmapHasPicture(bitmap)),
|
||||
))
|
||||
if (result == android.view.PixelCopy.SUCCESS && !isDestroyed) {
|
||||
pausedFrame = com.droiddeck.launcher.ui.PausedFrame(bitmap.asImageBitmap(), bounds)
|
||||
pausedFrameWanted = false
|
||||
@@ -5813,7 +5714,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
} catch (_: IllegalArgumentException) {
|
||||
done()
|
||||
bitmap.recycle()
|
||||
skipped("copy rejected")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5821,35 +5721,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private fun pauseNow() {
|
||||
if (!SessionState.running || SessionState.suspended) return
|
||||
pauseAnimated = true
|
||||
if (!dockedTouchOnly) drawerOpen = false
|
||||
drawerOpen = false
|
||||
pausedFrame = null
|
||||
if (zeroCopyActive()) {
|
||||
WaylandCompositor.nativeSetZeroCopy(false)
|
||||
val restore = java.util.concurrent.atomic.AtomicBoolean(false)
|
||||
val back = { if (restore.compareAndSet(false, true)) WaylandCompositor.nativeSetZeroCopy(true) }
|
||||
uiHandler.postDelayed({ capturePausedFrame(manual = true, onDone = back) }, ZERO_COPY_SETTLE_MS)
|
||||
uiHandler.postDelayed({ back() }, ZERO_COPY_RESTORE_MS)
|
||||
} else {
|
||||
capturePausedFrame(manual = true)
|
||||
}
|
||||
capturePausedFrame(manual = true)
|
||||
SessionService.pause(this)
|
||||
}
|
||||
|
||||
private fun zeroCopyActive(): Boolean =
|
||||
CompositorHost.isStarted && !SessionState.hdr && SessionPrefs.zeroCopy(this, SessionState.mode)
|
||||
|
||||
private fun bitmapHasPicture(bitmap: android.graphics.Bitmap): Boolean {
|
||||
val w = bitmap.width
|
||||
val h = bitmap.height
|
||||
if (w <= 0 || h <= 0) return false
|
||||
var lit = 0
|
||||
for (i in 0 until 64) {
|
||||
val c = bitmap.getPixel((w * (i % 8 + 1)) / 9, (h * (i / 8 + 1)) / 9)
|
||||
if (android.graphics.Color.red(c) + android.graphics.Color.green(c) + android.graphics.Color.blue(c) > 24) lit++
|
||||
}
|
||||
return lit >= 3
|
||||
}
|
||||
|
||||
private fun requestPausedFrame() {
|
||||
if (pausedFrame != null) return
|
||||
pausedFrameWanted = true
|
||||
@@ -5953,11 +5830,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
reconcileDock(shownOnDisplayId)
|
||||
settleDualScreenControls()
|
||||
refreshSecondScreenDisplays()
|
||||
if (secondScreenMode != SecondScreenMode.NONE) {
|
||||
if (secondScreenPresentation == null) showSecondScreen(secondScreenMode)
|
||||
if (com.droiddeck.launcher.input.DualScreen.menuReturnsOnStart(openingPanel(), SessionState.bottomMenu, menuShownOnBottom())) pinDockedMenu()
|
||||
SessionState.bottomMenu = false
|
||||
} else openDualScreenControls()
|
||||
if (secondScreenMode != SecondScreenMode.NONE && secondScreenPresentation == null) showSecondScreen(secondScreenMode)
|
||||
else openDualScreenControls()
|
||||
startedScreens++
|
||||
SessionService.setActivityVisible(this, true, sessionActivityDisplayId)
|
||||
Glasses.rescan()
|
||||
@@ -6108,9 +5982,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
heldKeys.clear()
|
||||
heldButtons.clear()
|
||||
if (!screenOff) {
|
||||
val menuUp = menuShownOnBottom()
|
||||
drawerOpen = false
|
||||
if (menuUp) SessionState.bottomMenu = true
|
||||
pcKeyboardOpen = false
|
||||
achievementsOpen = false
|
||||
}
|
||||
@@ -6882,8 +6754,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private const val LEAVE_TIMEOUT_MS = 1_500L
|
||||
private const val TEXT_FIELD_TAP_MS = 1_000L
|
||||
private const val PAUSED_FRAME_MAX_EDGE = 1920f
|
||||
private const val ZERO_COPY_SETTLE_MS = 150L
|
||||
private const val ZERO_COPY_RESTORE_MS = 1200L
|
||||
private const val BFI_PICTURE_SETTLE_MS = 50L
|
||||
private const val PAUSED_FRAME_REDRAW_MS = 150L
|
||||
private const val BOTTOM_RECOVERY_MS = 1_000L
|
||||
|
||||
@@ -207,11 +207,9 @@ object DeviceReport {
|
||||
k("refresh_rate_mode", runCatching { Settings.Secure.getString(context.contentResolver, "refresh_rate_mode") }.getOrNull() ?: "not set")
|
||||
val panelSize = com.droiddeck.launcher.session.SessionDisplay.panelSize(context)
|
||||
for ((label, mode) in listOf("Resolution (Steam)" to SessionService.MODE_STEAM, "Resolution (Desktop)" to SessionService.MODE_DESKTOP)) {
|
||||
for ((suffix, portrait) in listOf("landscape" to false, "portrait" to true)) {
|
||||
val choice = SessionPrefs.resolutionChoice(context, mode, panelSize, portrait)
|
||||
val size = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(panelSize, choice, portrait)
|
||||
k("$label $suffix", "$choice (${size.first}x${size.second})")
|
||||
}
|
||||
val choice = SessionPrefs.resolutionChoice(context, mode, panelSize)
|
||||
val size = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(panelSize, choice)
|
||||
k(label, "$choice (${size.first}x${size.second})")
|
||||
}
|
||||
k("Foldable", context.packageManager.hasSystemFeature("android.hardware.sensor.hinge_angle"))
|
||||
|
||||
|
||||
@@ -267,12 +267,11 @@ class DroidDeckHudHost(context: Context) {
|
||||
val h = if (strip) maxOf(v.height.toFloat(), STRIP_PULL_OFF_DP * density) else v.height.toFloat()
|
||||
val x = v.x + dx
|
||||
val y = v.y + dy
|
||||
val b = HudBounds.of(p, v.width.toFloat(), v.height.toFloat())
|
||||
return mapOf(
|
||||
DroidDeckHudDock.LEFT to (b.left - x) / w,
|
||||
DroidDeckHudDock.RIGHT to (x + v.width - b.right) / w,
|
||||
DroidDeckHudDock.TOP to (b.top - y) / h,
|
||||
DroidDeckHudDock.BOTTOM to (y + v.height - b.bottom) / h,
|
||||
DroidDeckHudDock.LEFT to -x / w,
|
||||
DroidDeckHudDock.RIGHT to (x + v.width - p.width) / w,
|
||||
DroidDeckHudDock.TOP to -y / h,
|
||||
DroidDeckHudDock.BOTTOM to (y + v.height - p.height) / h,
|
||||
).maxByOrNull { it.value }
|
||||
}
|
||||
|
||||
@@ -280,19 +279,19 @@ class DroidDeckHudHost(context: Context) {
|
||||
val p = hud.parent as? View ?: return
|
||||
stopMotion(hud)
|
||||
snapping = false
|
||||
val b = HudBounds.of(p, hud.width.toFloat(), hud.height.toFloat())
|
||||
hud.x = x.coerceIn(b.left, b.maxX)
|
||||
hud.y = y.coerceIn(b.top, b.maxY)
|
||||
hud.x = x.coerceIn(0f, (p.width - hud.width).toFloat().coerceAtLeast(0f))
|
||||
hud.y = y.coerceIn(0f, (p.height - hud.height).toFloat().coerceAtLeast(0f))
|
||||
}
|
||||
|
||||
private fun dropTab(hud: DroidDeckHudView) {
|
||||
val p = hud.parent as? View ?: return
|
||||
val b = HudBounds.of(p, hud.width.toFloat(), hud.height.toFloat())
|
||||
val maxX = (p.width - hud.width).toFloat().coerceAtLeast(0f)
|
||||
val maxY = (p.height - hud.height).toFloat().coerceAtLeast(0f)
|
||||
val pulled = when (hud.dock) {
|
||||
DroidDeckHudDock.LEFT -> (hud.x - b.left) / hud.width
|
||||
DroidDeckHudDock.RIGHT -> (b.maxX - hud.x) / hud.width
|
||||
DroidDeckHudDock.TOP -> (hud.y - b.top) / hud.height
|
||||
DroidDeckHudDock.BOTTOM -> (b.maxY - hud.y) / hud.height
|
||||
DroidDeckHudDock.LEFT -> hud.x / hud.width
|
||||
DroidDeckHudDock.RIGHT -> (maxX - hud.x) / hud.width
|
||||
DroidDeckHudDock.TOP -> hud.y / hud.height
|
||||
DroidDeckHudDock.BOTTOM -> (maxY - hud.y) / hud.height
|
||||
DroidDeckHudDock.NONE, DroidDeckHudDock.FLOAT -> 0f
|
||||
}
|
||||
if (pulled >= 1f) { setDock(hud, DroidDeckHudDock.NONE); return }
|
||||
@@ -340,11 +339,12 @@ class DroidDeckHudHost(context: Context) {
|
||||
/** Sends the HUD to a side the way a chat head goes: by where the throw would carry it, springing on from its speed. */
|
||||
private fun snapToAnchor(hud: DroidDeckHudView, vx: Float, vy: Float) {
|
||||
val p = hud.parent as? View ?: return
|
||||
val b = HudBounds.of(p, hud.width.toFloat(), hud.height.toFloat())
|
||||
val right = com.droiddeck.launcher.ui.EdgeFling.toRight(hud.x - b.left + hud.width / 2f, b.right - b.left, vx, context.resources.displayMetrics.density)
|
||||
val maxX = (p.width - hud.width).toFloat().coerceAtLeast(0f)
|
||||
val maxY = (p.height - hud.height).toFloat().coerceAtLeast(0f)
|
||||
val right = com.droiddeck.launcher.ui.EdgeFling.toRight(hud.x + hud.width / 2f, p.width.toFloat(), vx, context.resources.displayMetrics.density)
|
||||
anchorX = if (right) 1f else 0f
|
||||
wantX = b.anchoredX(anchorX)
|
||||
wantY = com.droiddeck.launcher.ui.EdgeFling.restY(hud.y, vy, b.top, b.maxY)
|
||||
wantX = anchorX * maxX
|
||||
wantY = com.droiddeck.launcher.ui.EdgeFling.restY(hud.y, vy, 0f, maxY)
|
||||
SessionPrefs.setDroidDeckHudPosition(context, wantX, wantY)
|
||||
stopMotion(hud)
|
||||
hud.scaleX = 1f; hud.scaleY = 1f
|
||||
@@ -387,8 +387,7 @@ class DroidDeckHudHost(context: Context) {
|
||||
val at = IntArray(2).also { p.getLocationOnScreen(it) }
|
||||
val x = rawX - at[0]
|
||||
val y = rawY - at[1]
|
||||
val b = HudBounds.of(p, 0f, 0f)
|
||||
val edge = if (snaps) nearestEdge(x - b.left, y - b.top, b.right - b.left, b.bottom - b.top) else DroidDeckHudDock.FLOAT
|
||||
val edge = if (snaps) nearestEdge(x, y, p.width.toFloat(), p.height.toFloat()) else DroidDeckHudDock.FLOAT
|
||||
setDock(hud, edge, Pair(x, y))
|
||||
}
|
||||
|
||||
@@ -405,9 +404,8 @@ class DroidDeckHudHost(context: Context) {
|
||||
if (edge != DroidDeckHudDock.NONE) {
|
||||
val p = hud.parent as? View
|
||||
if (p != null) {
|
||||
val b = HudBounds.of(p, 0f, 0f)
|
||||
wantX = wantX.coerceIn(b.left, b.right)
|
||||
wantY = wantY.coerceIn(b.top, b.bottom)
|
||||
wantX = wantX.coerceIn(0f, p.width.toFloat())
|
||||
wantY = wantY.coerceIn(0f, p.height.toFloat())
|
||||
}
|
||||
SessionPrefs.setDroidDeckHudPosition(context, wantX, wantY)
|
||||
}
|
||||
@@ -419,11 +417,12 @@ class DroidDeckHudHost(context: Context) {
|
||||
}
|
||||
|
||||
private fun settleOutOfTab(hud: DroidDeckHudView, tabX: Float, tabY: Float) {
|
||||
val b = (hud.parent as? View)?.let { HudBounds.of(it, hud.contentWidth, hud.contentHeight) }
|
||||
wantX = if (b == null) tabX.coerceAtLeast(0f) else tabX.coerceIn(b.left, b.maxX)
|
||||
wantY = if (b == null) tabY.coerceAtLeast(0f) else tabY.coerceIn(b.top, b.maxY)
|
||||
anchorX = if (snaps && !hud.isStrip && b != null) b.anchorFor(wantX) else Float.NaN
|
||||
if (b != null && !anchorX.isNaN()) wantX = b.anchoredX(anchorX)
|
||||
val p = hud.parent as? View
|
||||
val maxX = if (p == null) Float.MAX_VALUE else (p.width - hud.contentWidth).coerceAtLeast(0f)
|
||||
val maxY = if (p == null) Float.MAX_VALUE else (p.height - hud.contentHeight).coerceAtLeast(0f)
|
||||
wantX = tabX.coerceIn(0f, maxX); wantY = tabY.coerceIn(0f, maxY)
|
||||
anchorX = if (snaps && !hud.isStrip && p != null) (if (wantX < maxX / 2f) 0f else 1f) else Float.NaN
|
||||
if (!anchorX.isNaN()) wantX = anchorX * maxX
|
||||
SessionPrefs.setDroidDeckHudPosition(context, wantX, wantY)
|
||||
}
|
||||
|
||||
@@ -494,13 +493,13 @@ class DroidDeckHudHost(context: Context) {
|
||||
if (scale > 0.999f) from else (to - from * scale) / (1f - scale)
|
||||
|
||||
private fun settled(p: View, dock: DroidDeckHudDock, w: Float, h: Float): Pair<Float, Float> {
|
||||
val b = HudBounds.of(p, w, h)
|
||||
var x = wantX.coerceIn(b.left, b.maxX); var y = wantY.coerceIn(b.top, b.maxY)
|
||||
val maxX = (p.width - w).coerceAtLeast(0f); val maxY = (p.height - h).coerceAtLeast(0f)
|
||||
var x = wantX.coerceIn(0f, maxX); var y = wantY.coerceIn(0f, maxY)
|
||||
when (dock) {
|
||||
DroidDeckHudDock.LEFT -> x = b.left
|
||||
DroidDeckHudDock.RIGHT -> x = b.maxX
|
||||
DroidDeckHudDock.TOP -> y = b.top
|
||||
DroidDeckHudDock.BOTTOM -> y = b.maxY
|
||||
DroidDeckHudDock.LEFT -> x = 0f
|
||||
DroidDeckHudDock.RIGHT -> x = maxX
|
||||
DroidDeckHudDock.TOP -> y = 0f
|
||||
DroidDeckHudDock.BOTTOM -> y = maxY
|
||||
DroidDeckHudDock.NONE, DroidDeckHudDock.FLOAT -> {}
|
||||
}
|
||||
return Pair(x, y)
|
||||
@@ -511,18 +510,21 @@ class DroidDeckHudHost(context: Context) {
|
||||
val p = v.parent as? View ?: return
|
||||
if (p.width <= 0 || p.height <= 0 || v.width <= 0 || v.height <= 0) return
|
||||
if (wantX.isNaN()) { wantX = v.x; wantY = v.y }
|
||||
val b = HudBounds.of(p, v.width.toFloat(), v.height.toFloat())
|
||||
val maxX = (p.width - v.width).toFloat().coerceAtLeast(0f)
|
||||
val maxY = (p.height - v.height).toFloat().coerceAtLeast(0f)
|
||||
val anchored = (v as? DroidDeckHudView)?.let { it.dock == DroidDeckHudDock.NONE && !it.isStrip } == true
|
||||
if (snaps && anchored && anchorX.isNaN()) anchorX = b.anchorFor(wantX)
|
||||
if (snaps && anchored && !anchorX.isNaN()) wantX = b.anchoredX(anchorX)
|
||||
var x = wantX.coerceIn(b.left, b.maxX)
|
||||
var y = wantY.coerceIn(b.top, b.maxY)
|
||||
if ((v as? DroidDeckHudView)?.isStrip == true) y = if (y + v.height / 2f < (b.top + b.bottom) / 2f) b.top else b.maxY
|
||||
if (snaps && anchored && anchorX.isNaN()) {
|
||||
anchorX = if (wantX.coerceIn(0f, maxX) < maxX / 2f) 0f else 1f
|
||||
}
|
||||
if (snaps && anchored && !anchorX.isNaN()) wantX = anchorX * maxX
|
||||
var x = wantX.coerceIn(0f, maxX)
|
||||
var y = wantY.coerceIn(0f, maxY)
|
||||
if ((v as? DroidDeckHudView)?.isStrip == true) y = if (y + v.height / 2f < p.height / 2f) 0f else maxY
|
||||
when (v.let { it as? DroidDeckHudView }?.dock) {
|
||||
DroidDeckHudDock.LEFT -> x = b.left
|
||||
DroidDeckHudDock.RIGHT -> x = b.maxX
|
||||
DroidDeckHudDock.TOP -> y = b.top
|
||||
DroidDeckHudDock.BOTTOM -> y = b.maxY
|
||||
DroidDeckHudDock.LEFT -> x = 0f
|
||||
DroidDeckHudDock.RIGHT -> x = maxX
|
||||
DroidDeckHudDock.TOP -> y = 0f
|
||||
DroidDeckHudDock.BOTTOM -> y = maxY
|
||||
else -> {}
|
||||
}
|
||||
if (v.x != x) v.x = x
|
||||
@@ -549,25 +551,3 @@ class DroidDeckHudHost(context: Context) {
|
||||
}.getOrNull()?.takeIf { it.isNotBlank() }
|
||||
}
|
||||
}
|
||||
|
||||
internal class HudBounds(val left: Float, val top: Float, val right: Float, val bottom: Float, w: Float, h: Float) {
|
||||
val maxX = (right - w).coerceAtLeast(left)
|
||||
val maxY = (bottom - h).coerceAtLeast(top)
|
||||
|
||||
fun anchorFor(x: Float): Float = if (x.coerceIn(left, maxX) - left < (maxX - left) / 2f) 0f else 1f
|
||||
|
||||
fun anchoredX(anchor: Float): Float = left + anchor * (maxX - left)
|
||||
|
||||
companion object {
|
||||
fun of(p: View, w: Float, h: Float): HudBounds {
|
||||
val left = p.paddingLeft.toFloat()
|
||||
val top = p.paddingTop.toFloat()
|
||||
return HudBounds(
|
||||
left, top,
|
||||
(p.width - p.paddingRight).toFloat().coerceAtLeast(left),
|
||||
(p.height - p.paddingBottom).toFloat().coerceAtLeast(top),
|
||||
w, h,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -934,7 +934,7 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
val rowPx = sp(11.5f); val unitPx = rowPx * 0.8f; val fpsPx = sp(15f)
|
||||
val padX = sp(10f); val groupGap = sp(13f)
|
||||
val h = sp(26f)
|
||||
val w = ((parent as? View)?.let { it.width - it.paddingLeft - it.paddingRight }?.takeIf { it > 0 } ?: resources.displayMetrics.widthPixels).toFloat()
|
||||
val w = ((parent as? View)?.width?.takeIf { it > 0 } ?: resources.displayMetrics.widthPixels).toFloat()
|
||||
val mid = h / 2f
|
||||
val baseline = mid + capHeight(fpsPx) / 2f
|
||||
|
||||
|
||||
@@ -13,13 +13,11 @@ internal class ControllerOverlayGeometry(
|
||||
private val density = metrics.density
|
||||
private val dpi = metrics.ydpi.takeIf { it in metrics.densityDpi * .6f..metrics.densityDpi * 1.6f }
|
||||
?: metrics.densityDpi.toFloat()
|
||||
private val fit = minOf(
|
||||
min(w / 1600f, h / 900f) * min(1f, 80f / max(h / dpi * 25.4f, 1f)),
|
||||
private val unit = minOf(
|
||||
min(w / 1600f, h / 900f) * min(1f, 80f / max(h / dpi * 25.4f, 1f)) * scale,
|
||||
(w - safe.left - safe.right).coerceAtLeast(1f) / 1200f,
|
||||
(h - safe.top - safe.bottom).coerceAtLeast(1f) / 900f,
|
||||
)
|
||||
private val unit = fit * min(scale, 1f)
|
||||
private val size = fit * scale
|
||||
|
||||
private fun anchor(value: Float, reference: Float, extent: Float, start: Int, end: Int): Float {
|
||||
val low = start + value * unit
|
||||
@@ -33,24 +31,24 @@ internal class ControllerOverlayGeometry(
|
||||
|
||||
private fun x(ref: Float) = anchor(ref, 1600f, w, safe.left, safe.right)
|
||||
|
||||
private fun y(ref: Float) = max(safe.top + ref * unit, h - safe.bottom - (900f - ref) * unit)
|
||||
private fun y(ref: Float) = anchor(ref, 900f, h, safe.top, safe.bottom)
|
||||
|
||||
fun place(elements: List<InputSurfaceElement>, kit: PadKit, rearButtons: Boolean, trackpads: Boolean): List<InputSurfaceElement> {
|
||||
if (!kit.steam) return placeStandardPad(elements, kit)
|
||||
val leftEdge = safe.left + 52f * density
|
||||
val middle = (w + safe.left - safe.right) / 2f
|
||||
val keyboard = Box(max(x(136f), leftEdge + 46f * size), y(848f), 46f).takeIf { elements.any { it.id == KEYBOARD } }
|
||||
val keyboard = Box(max(x(136f), leftEdge + 46f * unit), y(848f), 46f).takeIf { elements.any { it.id == KEYBOARD } }
|
||||
val row = fitRow(listOfNotNull(keyboard,
|
||||
Box(max(x(370f), leftEdge + 66f * size), y(852f), 66f, 30f),
|
||||
Box(max(x(370f), leftEdge + 66f * unit), y(852f), 66f, 30f),
|
||||
Box(middle - 140f * unit, y(850f), 46f, 26f),
|
||||
Box(middle + 140f * unit, y(850f), 46f, 26f),
|
||||
Box(x(1230f), y(852f), 66f, 30f)), leftEdge)
|
||||
val (guide, select, start, qam) = row.takeLast(4)
|
||||
val positions = shoulders() + face(1375f, 345f, 96f) + mapOf(
|
||||
InputControl.UP to Box(x(220f), y(345f) - 102.5f * size, 55.5f, 47.5f),
|
||||
InputControl.RIGHT to Box(x(220f) + 102.5f * size, y(345f), 47.5f, 55.5f),
|
||||
InputControl.DOWN to Box(x(220f), y(345f) + 102.5f * size, 55.5f, 47.5f),
|
||||
InputControl.LEFT to Box(x(220f) - 102.5f * size, y(345f), 47.5f, 55.5f),
|
||||
InputControl.UP to Box(x(220f), y(345f) - 102.5f * unit, 55.5f, 47.5f),
|
||||
InputControl.RIGHT to Box(x(220f) + 102.5f * unit, y(345f), 47.5f, 55.5f),
|
||||
InputControl.DOWN to Box(x(220f), y(345f) + 102.5f * unit, 55.5f, 47.5f),
|
||||
InputControl.LEFT to Box(x(220f) - 102.5f * unit, y(345f), 47.5f, 55.5f),
|
||||
InputControl.LS to Box(x(290f), y(640f), 96f),
|
||||
InputControl.RS to Box(x(1310f), y(640f), 96f),
|
||||
InputControl.SELECT to select,
|
||||
@@ -77,9 +75,8 @@ internal class ControllerOverlayGeometry(
|
||||
else -> positions[element.control]?.place(element) ?: element
|
||||
}
|
||||
}
|
||||
val chosen = placed.filter { it.id == "legacy:${it.control.id}" }.map { it.control }
|
||||
return placed + optional.mapNotNull { (control, box) ->
|
||||
if (chosen.any { if (control in rear) it in rear else it in pads }) null else box.place(InputSurfaceElement(control,
|
||||
if (placed.any { it.id == "legacy:${control.id}" }) null else box.place(InputSurfaceElement(control,
|
||||
0f, 0f, 0f, 0f, floating = false, buttonShape = InputButtonShape.PILL, showLabel = !control.isTrackpad))
|
||||
}
|
||||
}
|
||||
@@ -87,7 +84,7 @@ internal class ControllerOverlayGeometry(
|
||||
private fun placeStandardPad(elements: List<InputSurfaceElement>, kit: PadKit): List<InputSurfaceElement> {
|
||||
val leftEdge = safe.left + 52f * density
|
||||
val middle = (w + safe.left - safe.right) / 2f
|
||||
val keyboard = Box(max(x(136f), leftEdge + 46f * size), y(848f), 46f).takeIf { elements.any { it.id == KEYBOARD } }
|
||||
val keyboard = Box(max(x(136f), leftEdge + 46f * unit), y(848f), 46f).takeIf { elements.any { it.id == KEYBOARD } }
|
||||
val controls = if (kit.playStation) listOf(
|
||||
InputControl.QAM to Box(x(220f), y(848f), 46f),
|
||||
InputControl.SELECT to Box(middle - 160f * unit, y(850f), 50f, 30f),
|
||||
@@ -105,15 +102,15 @@ internal class ControllerOverlayGeometry(
|
||||
face(1350f, 395f, 96f) + dpad(250f, 395f, 125f, kit.dpad) + mapOf(
|
||||
InputControl.LS to Box(x(565f), y(690f), 100f),
|
||||
InputControl.RS to Box(x(1035f), y(690f), 100f),
|
||||
InputControl.L3 to Box(x(565f) - 135f * size, y(690f) - 100f * size, 42f),
|
||||
InputControl.R3 to Box(x(1035f) + 135f * size, y(690f) - 100f * size, 42f),
|
||||
InputControl.L3 to Box(x(565f) - 135f * unit, y(690f) - 100f * unit, 42f),
|
||||
InputControl.R3 to Box(x(1035f) + 135f * unit, y(690f) - 100f * unit, 42f),
|
||||
)
|
||||
} else {
|
||||
face(1375f, 400f, 94f) + dpad(470f, 675f, 118f, kit.dpad) + mapOf(
|
||||
InputControl.LS to Box(x(235f), y(400f), 104f),
|
||||
InputControl.RS to Box(x(1130f), y(690f), 104f),
|
||||
InputControl.L3 to Box(x(235f) + 150f * size, y(400f) - 110f * size, 42f),
|
||||
InputControl.R3 to Box(x(1130f) + 160f * size, y(690f) + 100f * size, 42f),
|
||||
InputControl.L3 to Box(x(235f) + 150f * unit, y(400f) - 110f * unit, 42f),
|
||||
InputControl.R3 to Box(x(1130f) + 160f * unit, y(690f) + 100f * unit, 42f),
|
||||
)
|
||||
}
|
||||
return elements.map { element ->
|
||||
@@ -126,23 +123,23 @@ internal class ControllerOverlayGeometry(
|
||||
}
|
||||
|
||||
private fun shoulders() = mapOf(
|
||||
InputControl.LT to Box(x(120f), y(96f), 80f, 34f),
|
||||
InputControl.LB to Box(x(310f), y(96f), 80f, 34f),
|
||||
InputControl.RB to Box(x(1290f), y(96f), 80f, 34f),
|
||||
InputControl.RT to Box(x(1480f), y(96f), 80f, 34f),
|
||||
InputControl.LT to Box(x(140f), y(66f), 88f, 34f),
|
||||
InputControl.LB to Box(x(140f), y(148f), 88f, 30f),
|
||||
InputControl.RT to Box(x(1460f), y(66f), 88f, 34f),
|
||||
InputControl.RB to Box(x(1460f), y(148f), 88f, 30f),
|
||||
)
|
||||
|
||||
private fun face(cx: Float, cy: Float, offset: Float) = mapOf(
|
||||
InputControl.Y to Box(x(cx), y(cy) - offset * size, 58f),
|
||||
InputControl.X to Box(x(cx) - offset * size, y(cy), 58f),
|
||||
InputControl.B to Box(x(cx) + offset * size, y(cy), 58f),
|
||||
InputControl.A to Box(x(cx), y(cy) + offset * size, 58f),
|
||||
InputControl.Y to Box(x(cx), y(cy) - offset * unit, 58f),
|
||||
InputControl.X to Box(x(cx) - offset * unit, y(cy), 58f),
|
||||
InputControl.B to Box(x(cx) + offset * unit, y(cy), 58f),
|
||||
InputControl.A to Box(x(cx), y(cy) + offset * unit, 58f),
|
||||
)
|
||||
|
||||
private fun dpad(cx: Float, cy: Float, radius: Float, style: DpadStyle): Map<InputControl, Box> {
|
||||
val inner = radius * if (style == DpadStyle.DISC) .25f else .14f
|
||||
val depth = (radius - inner) / 2f
|
||||
val offset = (radius - depth) * size
|
||||
val offset = (radius - depth) * unit
|
||||
val side = radius * .25f
|
||||
return mapOf(
|
||||
InputControl.UP to Box(x(cx), y(cy) - offset, side, depth),
|
||||
@@ -162,12 +159,12 @@ internal class ControllerOverlayGeometry(
|
||||
}
|
||||
|
||||
private inner class Box(val cx: Float, val cy: Float, val hw: Float, val hh: Float = hw) {
|
||||
val width get() = max(hw * 2f * size, w * .03f)
|
||||
val width get() = max(hw * 2f * unit, w * .03f)
|
||||
|
||||
fun at(cx: Float) = Box(cx, cy, hw, hh)
|
||||
|
||||
fun place(element: InputSurfaceElement): InputSurfaceElement {
|
||||
val height = max(hh * 2f * size, h * .03f)
|
||||
val height = max(hh * 2f * unit, h * .03f)
|
||||
return element.copy(
|
||||
x = (cx - width / 2f).coerceIn(safe.left.toFloat(), max(safe.left.toFloat(), w - safe.right - width)) / w,
|
||||
y = (cy - height / 2f).coerceIn(safe.top.toFloat(), max(safe.top.toFloat(), h - safe.bottom - height)) / h,
|
||||
|
||||
@@ -22,15 +22,15 @@ internal class ControllerPortraitGeometry(
|
||||
val rear = presented.filter { it.control in REAR && isStock(it) }
|
||||
val pads = presented.filter { it.control.isTrackpad && isStock(it) }
|
||||
if (!docked && kit.steam) {
|
||||
if (!rearButtons) presented.removeAll(rear) else if (rear.isEmpty()) REAR.forEach { addOptional(presented, it) }
|
||||
if (!trackpads) presented.removeAll(pads) else if (pads.isEmpty()) {
|
||||
if (rearButtons) REAR.forEach { addOptional(presented, it) } else presented.removeAll(rear)
|
||||
if (trackpads) {
|
||||
addOptional(presented, InputControl.LEFT_PAD)
|
||||
addOptional(presented, InputControl.RIGHT_PAD)
|
||||
}
|
||||
} else presented.removeAll(pads)
|
||||
}
|
||||
fun put(control: InputControl, box: Box) { buttons["legacy:${control.id}"] = box }
|
||||
val reserve = if (docked) 0f else min(60f * density, h * .15f)
|
||||
val panel = if (docked) h else min(minOf(h * .60f, w * 1.15f, PANEL_DP * density) * scale, h - reserve)
|
||||
val panel = if (docked) h else min(min(h * .60f, w * 1.15f) * scale, h - reserve)
|
||||
val top = height - safe.bottom - reserve - panel
|
||||
val unit = min(density, min(w / 275f, panel / 300f))
|
||||
val pad = 8f * unit
|
||||
@@ -121,7 +121,6 @@ internal class ControllerPortraitGeometry(
|
||||
|
||||
private companion object {
|
||||
const val KEYBOARD = "builtin:keyboard"
|
||||
const val PANEL_DP = 504f
|
||||
val REAR = listOf(InputControl.L4, InputControl.L5, InputControl.R5, InputControl.R4)
|
||||
}
|
||||
}
|
||||
@@ -23,14 +23,6 @@ object DualScreen {
|
||||
@Volatile private var takenDisplays: Set<Int> = emptySet()
|
||||
private val main by lazy { android.os.Handler(android.os.Looper.getMainLooper()) }
|
||||
|
||||
fun menuOwnsController(open: Boolean, docked: Boolean, optIn: Boolean): Boolean = open && (!docked || optIn)
|
||||
|
||||
fun menuReturnsOnStart(selected: SecondScreenMode, menuWasShown: Boolean, menuUp: Boolean): Boolean =
|
||||
!menuUp && (selected == SecondScreenMode.MENU || menuWasShown)
|
||||
|
||||
fun menuIdleOnBottom(open: Boolean, docked: Boolean, pinned: Boolean, optIn: Boolean): Boolean =
|
||||
docked && (open || pinned) && !menuOwnsController(open, docked, optIn)
|
||||
|
||||
fun yieldsBottom(model: String): Boolean = model.trim().lowercase().let { m -> knownModels.any(m::startsWith) }
|
||||
|
||||
fun taken(displayId: Int): Boolean = displayId in takenDisplays
|
||||
|
||||
@@ -27,9 +27,8 @@ internal class FloatingSteamOverlay(width: Int, height: Int, safe: Rect, density
|
||||
val lowered = if (lowerShortcuts) lower(visible) else visible
|
||||
if (rearButtons != true && trackpads != true) return lowered
|
||||
val placed = lowered.toMutableList()
|
||||
val chosen = lowered.filter(::isStock).map { it.control }
|
||||
fun add(control: InputControl, x: Float, y: List<Float>, widthDp: Int, heightDp: Int, shape: InputButtonShape) {
|
||||
if (chosen.any { if (control in rear) it in rear else it.isTrackpad }) return
|
||||
if (placed.any { it.id == "legacy:${control.id}" }) return
|
||||
val element = InputSurfaceElement(control, 0f, 0f, (widthDp * dp / w).coerceAtLeast(.03f),
|
||||
(heightDp * dp / h).coerceAtLeast(.03f), floating = false, buttonShape = shape, showLabel = !control.isTrackpad)
|
||||
findSpace(element, x, y, placed)?.let(placed::add)
|
||||
|
||||
@@ -324,27 +324,15 @@ object InputLibraries {
|
||||
layout.copy(screen = screen)
|
||||
})
|
||||
|
||||
private fun encodeElements(list: List<InputSurfaceElement>) = JSONArray().also { elements ->
|
||||
for (e in list) elements.put(JSONObject().put("id", e.id).put("kind", e.kind.name)
|
||||
.put("control", e.control.id).put("name", e.name).put("x", e.x.toDouble()).put("y", e.y.toDouble())
|
||||
.put("width", e.width.toDouble()).put("height", e.height.toDouble()).put("floating", e.floating).put("hideWhenIdle", e.hideWhenIdle).put("mouseGestures", e.mouseGestures).put("toggle", e.toggle).put("icon", e.icon).put("image", e.image)
|
||||
.put("elementOpacity", e.opacity.toDouble()).put("buttonShape", e.buttonShape.name).put("showLabel", e.showLabel).put("alwaysShown", e.alwaysShown))
|
||||
}
|
||||
|
||||
private fun decodeElements(array: JSONArray) = array.objects(64).map { e ->
|
||||
InputSurfaceElement(requireNotNull(InputControl.fromId(e.getString("control"))), e.getDouble("x").toFloat(),
|
||||
e.getDouble("y").toFloat(), e.getDouble("width").toFloat(), e.getDouble("height").toFloat(),
|
||||
e.getString("id"), InputElementKind.valueOf(e.getString("kind")), e.getString("name"),
|
||||
e.optBoolean("floating", true), e.optBoolean("hideWhenIdle", false), e.optBoolean("mouseGestures", false), e.optBoolean("toggle", false), e.optInt("icon", 0), e.optString("image", ""),
|
||||
e.optDouble("elementOpacity", 1.0).toFloat(), InputButtonShape.valueOf(e.optString("buttonShape", InputButtonShape.ROUNDED.name)), e.optBoolean("showLabel", true), e.optBoolean("alwaysShown", false))
|
||||
}
|
||||
|
||||
internal fun encode(library: InputLibrary): String {
|
||||
val layouts = JSONArray()
|
||||
for (layout in library.layouts) {
|
||||
val encoded = JSONObject().put("id", layout.id).put("name", layout.name).put("template", layout.template.name).put("elements", encodeElements(layout.elements))
|
||||
if (layout.rotated.isNotEmpty()) encoded.put("rotated", encodeElements(layout.rotated)).put("rotatedAspect", layout.rotatedAspect.toDouble()).put("rotatedScale", layout.rotatedScale.toDouble())
|
||||
layouts.put(encoded
|
||||
val elements = JSONArray()
|
||||
for (e in layout.elements) elements.put(JSONObject().put("id", e.id).put("kind", e.kind.name)
|
||||
.put("control", e.control.id).put("name", e.name).put("x", e.x.toDouble()).put("y", e.y.toDouble())
|
||||
.put("width", e.width.toDouble()).put("height", e.height.toDouble()).put("floating", e.floating).put("hideWhenIdle", e.hideWhenIdle).put("mouseGestures", e.mouseGestures).put("toggle", e.toggle).put("icon", e.icon).put("image", e.image)
|
||||
.put("elementOpacity", e.opacity.toDouble()).put("buttonShape", e.buttonShape.name).put("showLabel", e.showLabel).put("alwaysShown", e.alwaysShown))
|
||||
layouts.put(JSONObject().put("id", layout.id).put("name", layout.name).put("template", layout.template.name).put("elements", elements)
|
||||
.put("tint", layout.style.tint ?: JSONObject.NULL).put("opacity", layout.style.opacity).put("screen", layout.screen.name).put("aspect", layout.aspect.toDouble()).put("scale", layout.scale.toDouble())
|
||||
.put("hidden", JSONArray(layout.style.hidden.map { it.name }.sorted())).put("origin", layout.origin ?: JSONObject.NULL))
|
||||
}
|
||||
@@ -383,7 +371,13 @@ object InputLibraries {
|
||||
require(version in 2..VERSION || restore)
|
||||
val generated = mutableSetOf<String>()
|
||||
val layouts = doc.getJSONArray("layouts").objects(256).map { layout ->
|
||||
val stored = decodeElements(layout.getJSONArray("elements"))
|
||||
val stored = layout.getJSONArray("elements").objects(64).map { e ->
|
||||
InputSurfaceElement(requireNotNull(InputControl.fromId(e.getString("control"))), e.getDouble("x").toFloat(),
|
||||
e.getDouble("y").toFloat(), e.getDouble("width").toFloat(), e.getDouble("height").toFloat(),
|
||||
e.getString("id"), InputElementKind.valueOf(e.getString("kind")), e.getString("name"),
|
||||
e.optBoolean("floating", true), e.optBoolean("hideWhenIdle", false), e.optBoolean("mouseGestures", false), e.optBoolean("toggle", false), e.optInt("icon", 0), e.optString("image", ""),
|
||||
e.optDouble("elementOpacity", 1.0).toFloat(), InputButtonShape.valueOf(e.optString("buttonShape", InputButtonShape.ROUNDED.name)), e.optBoolean("showLabel", true), e.optBoolean("alwaysShown", false))
|
||||
}
|
||||
val id = layout.getString("id")
|
||||
val origin = layout.optionalString("origin")
|
||||
val followsGamepad = restore && !layout.optBoolean("kitless") &&
|
||||
@@ -394,8 +388,7 @@ object InputLibraries {
|
||||
InputSurfaceStyle(if (!layout.has("tint")) ControllerPrefs.STEAM_BLUE else if (layout.isNull("tint")) null else layout.getInt("tint"), layout.optInt("opacity", 100),
|
||||
layout.optJSONArray("hidden")?.let { hidden -> (0 until hidden.length()).map { InputCommand.valueOf(hidden.getString(it)) }.toSet() }.orEmpty()),
|
||||
InputLayoutScreen.valueOf(layout.optString("screen", InputLayoutScreen.BOTH.name)), layout.optDouble("aspect", 0.0).toFloat(), origin,
|
||||
layout.optDouble("scale", 1.0).toFloat(), layout.optJSONArray("rotated")?.let(::decodeElements).orEmpty(),
|
||||
layout.optDouble("rotatedAspect", 0.0).toFloat(), layout.optDouble("rotatedScale", layout.optDouble("scale", 1.0)).toFloat())
|
||||
layout.optDouble("scale", 1.0).toFloat())
|
||||
}
|
||||
val bindings = doc.getJSONArray("bindings").objects(512).map { b ->
|
||||
val controls = b.getJSONObject("controls").actions(28).mapKeys { requireNotNull(InputControl.fromId(it.key)) }
|
||||
|
||||
@@ -22,12 +22,8 @@ data class SavedInputLayout(
|
||||
val aspect: Float = 0f,
|
||||
val origin: String? = null,
|
||||
val scale: Float = 1f,
|
||||
val rotated: List<InputSurfaceElement> = emptyList(),
|
||||
val rotatedAspect: Float = 0f,
|
||||
val rotatedScale: Float = 1f,
|
||||
) {
|
||||
val editable get() = template == InputLayoutTemplate.CUSTOM
|
||||
val overlay get() = (origin ?: id).let { it == InputLibraries.OVERLAY || it.startsWith("migrated.layout.") }
|
||||
val quickButtons get() = QUICK_BUTTONS.filter { button -> elements.any { it.quickButton == button } }
|
||||
fun withQuickButton(button: InputCommand, shown: Boolean) =
|
||||
copy(style = style.copy(hidden = if (shown) style.hidden - button else style.hidden + button))
|
||||
@@ -253,8 +249,6 @@ data class InputLibrary(
|
||||
for (layout in layouts) {
|
||||
require(layout.style.opacity in 1..100 && layout.style.hidden.all { it in QUICK_BUTTONS })
|
||||
require(layout.aspect == 0f || layout.aspect.isFinite() && layout.aspect in .05f..20f)
|
||||
require(layout.rotated.isEmpty() || layout.rotatedAspect.isFinite() && layout.rotatedAspect in .05f..20f && layout.rotatedScale.isFinite() && layout.rotatedScale in .5f..2f)
|
||||
require(layout.rotated.size <= 64 && layout.rotated.all { r -> listOf(r.x, r.y, r.width, r.height).all { it.isFinite() } })
|
||||
require(layout.scale.isFinite() && layout.scale in .5f..2f)
|
||||
inputName(layout.name); require(layout.elements.size <= 64); unique(layout.elements.map { it.id })
|
||||
for (e in layout.elements) {
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.droiddeck.launcher.input
|
||||
import android.content.Context
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
enum class InputElementKind(val control: InputControl) {
|
||||
BUTTON(InputControl.A), STICK(InputControl.LS), TRACKPAD(InputControl.LEFT_PAD),
|
||||
@@ -65,27 +63,6 @@ internal fun List<InputSurfaceElement>.scaled(factor: Float): List<InputSurfaceE
|
||||
width = w, height = h).bounded()
|
||||
}
|
||||
|
||||
|
||||
internal val DPAD = setOf(InputControl.UP, InputControl.RIGHT, InputControl.DOWN, InputControl.LEFT)
|
||||
internal val InputSurfaceElement.dpadPiece get() = id == "legacy:${control.id}" && control in DPAD
|
||||
|
||||
internal fun List<InputSurfaceElement>.groupOf(e: InputSurfaceElement) = if (e.dpadPiece) filter { it.dpadPiece } else listOf(e)
|
||||
|
||||
internal fun List<InputSurfaceElement>.frame(): InputSurfaceElement {
|
||||
val left = minOf { it.x }; val top = minOf { it.y }
|
||||
return first().copy(x = left, y = top, width = maxOf { it.x + it.width } - left, height = maxOf { it.y + it.height } - top)
|
||||
}
|
||||
|
||||
internal fun List<InputSurfaceElement>.resizedAroundCentre(factor: Float): List<InputSurfaceElement> {
|
||||
if (isEmpty()) return this
|
||||
val f = frame()
|
||||
val k = factor.coerceIn(.03f / minOf { min(it.width, it.height) }, 1f / max(f.width, f.height))
|
||||
val w = f.width * k; val h = f.height * k
|
||||
val left = (f.x + f.width / 2 - w / 2).coerceIn(0f, 1f - w)
|
||||
val top = (f.y + f.height / 2 - h / 2).coerceIn(0f, 1f - h)
|
||||
return map { it.copy(x = left + (it.x - f.x) * k, y = top + (it.y - f.y) * k, width = it.width * k, height = it.height * k).bounded() }
|
||||
}
|
||||
|
||||
internal fun List<InputSurfaceElement>.withPositionsOf(defaults: List<InputSurfaceElement>): List<InputSurfaceElement> {
|
||||
val byId = defaults.associateBy { it.id }
|
||||
return map { e -> byId[e.id]?.let { d -> e.copy(x = d.x, y = d.y, width = d.width, height = d.height).bounded() } ?: e }
|
||||
|
||||
@@ -197,8 +197,19 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid
|
||||
|
||||
fun regenerate(stored: List<InputSurfaceElement>): List<InputSurfaceElement> = withGeometry(stored, elements())
|
||||
|
||||
fun rescale(stored: List<InputSurfaceElement>, from: LegacyGamepadLayout): List<InputSurfaceElement> =
|
||||
rescaleBetween(stored, from.elements(), elements())
|
||||
fun rescale(stored: List<InputSurfaceElement>, from: LegacyGamepadLayout): List<InputSurfaceElement> {
|
||||
val before = from.elements().associateBy { it.id }
|
||||
val after = elements().associateBy { it.id }
|
||||
return stored.map { e ->
|
||||
val b = before[e.id] ?: return@map e
|
||||
val a = after[e.id] ?: return@map e
|
||||
val w = (a.width * e.width / b.width).coerceIn(.03f, 1f)
|
||||
val h = (a.height * e.height / b.height).coerceIn(.03f, 1f)
|
||||
val cx = a.x + a.width / 2 + (e.x + e.width / 2 - b.x - b.width / 2)
|
||||
val cy = a.y + a.height / 2 + (e.y + e.height / 2 - b.y - b.height / 2)
|
||||
e.copy(x = (cx - w / 2).coerceIn(0f, 1f - w), y = (cy - h / 2).coerceIn(0f, 1f - h), width = w, height = h).bounded()
|
||||
}
|
||||
}
|
||||
|
||||
fun buttonsOnly(stored: List<InputSurfaceElement>): List<InputSurfaceElement> {
|
||||
val inset = dp(BUTTONS_ONLY_INSET_DP)
|
||||
@@ -334,6 +345,7 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid
|
||||
const val STICK_REACH = 1.25f
|
||||
const val LEGACY_DPAD_RADIUS_DP = 26f
|
||||
const val LEGACY_DPAD_OFFSET_DP = 52f
|
||||
val DPAD = setOf(InputControl.UP, InputControl.RIGHT, InputControl.DOWN, InputControl.LEFT)
|
||||
const val KEYBOARD_ID = "builtin:keyboard"
|
||||
const val KEYBOARD_RADIUS_DP = 18f
|
||||
const val KEYBOARD_X_DP = 90f
|
||||
@@ -348,22 +360,3 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid
|
||||
InputControl.R5 to GamepadGeometry.Slot.R5, InputControl.R4 to GamepadGeometry.Slot.R4)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun rescaleBetween(stored: List<InputSurfaceElement>, from: List<InputSurfaceElement>, to: List<InputSurfaceElement>,
|
||||
sizeFrom: List<InputSurfaceElement> = from, sizeTo: List<InputSurfaceElement> = to): List<InputSurfaceElement> {
|
||||
val before = from.associateBy { it.id }
|
||||
val after = to.associateBy { it.id }
|
||||
val smaller = sizeFrom.associateBy { it.id }
|
||||
val larger = sizeTo.associateBy { it.id }
|
||||
return stored.map { e ->
|
||||
val b = before[e.id] ?: return@map e
|
||||
val a = after[e.id] ?: return@map e
|
||||
val sb = smaller[e.id] ?: b
|
||||
val sa = larger[e.id] ?: a
|
||||
val w = (sa.width * e.width / sb.width).coerceIn(.03f, 1f)
|
||||
val h = (sa.height * e.height / sb.height).coerceIn(.03f, 1f)
|
||||
val cx = a.x + a.width / 2 + (e.x + e.width / 2 - b.x - b.width / 2)
|
||||
val cy = a.y + a.height / 2 + (e.y + e.height / 2 - b.y - b.height / 2)
|
||||
e.copy(x = (cx - w / 2).coerceIn(0f, 1f - w), y = (cy - h / 2).coerceIn(0f, 1f - h), width = w, height = h).bounded()
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,9 @@ import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import android.widget.FrameLayout
|
||||
import com.droiddeck.launcher.ui.InputSurfaceView
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import com.droiddeck.launcher.session.SessionService
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
|
||||
class OnScreenControls(context: Context, pad: PadBridge?, val dock: OnScreenLayout.Dock? = null) : FrameLayout(context) {
|
||||
private val surface = InputSurfaceView(context, pad, inputRole = InputRole.PRIMARY, haptics = dock != null)
|
||||
@@ -72,15 +75,15 @@ class OnScreenControls(context: Context, pad: PadBridge?, val dock: OnScreenLayo
|
||||
render()
|
||||
}
|
||||
|
||||
private data class Placement(val layout: SavedInputLayout?, val width: Int, val height: Int, val safe: Rect, val buttonsOnly: Boolean,
|
||||
val kit: PadKit?, val optional: Pair<Boolean?, Boolean?>)
|
||||
private data class Placement(val layout: SavedInputLayout?, val width: Int, val height: Int, val safe: Rect, val buttonsOnly: Boolean)
|
||||
|
||||
private fun placed(): List<InputSurfaceElement> {
|
||||
val optional = OnScreenLayout.optionalControls(context)
|
||||
val key = Placement(layout, viewWidth, viewHeight, Rect(safe), isButtonsOnly, PadKit.forOverlay(context, layout), optional)
|
||||
val key = Placement(layout, viewWidth, viewHeight, Rect(safe), isButtonsOnly)
|
||||
return placements.getOrPut(key) {
|
||||
val steam = SessionState.mode == SessionService.MODE_STEAM && SessionState.deckPad
|
||||
OnScreenLayout.elements(context, layout, viewWidth, viewHeight, safe, isButtonsOnly, dock,
|
||||
rearButtons = optional.first, trackpads = optional.second)
|
||||
rearButtons = SessionPrefs.oscRearButtons(context).takeIf { steam },
|
||||
trackpads = SessionPrefs.oscTrackpads(context).takeIf { steam })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +136,7 @@ class OnScreenControls(context: Context, pad: PadBridge?, val dock: OnScreenLayo
|
||||
params.bottomMargin = bottom
|
||||
quickToggle.layoutParams = params
|
||||
}
|
||||
val fresh = OnScreenLayout.safeInsets(insets, dock != null)
|
||||
val fresh = Rect(cutout?.safeInsetLeft ?: 0, if (dock == null) cutout?.safeInsetTop ?: 0 else 0, cutout?.safeInsetRight ?: 0, cutout?.safeInsetBottom ?: 0)
|
||||
if (fresh != safe) {
|
||||
safe.set(fresh)
|
||||
render()
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.droiddeck.launcher.input
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import com.droiddeck.launcher.session.SessionService
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
@@ -12,7 +10,7 @@ import kotlin.math.roundToInt
|
||||
|
||||
object OnScreenLayout {
|
||||
internal fun supportsFloatingSteamControls(controller: String, layout: SavedInputLayout?) =
|
||||
layout?.overlay == true &&
|
||||
layout?.id == InputLibraries.OVERLAY &&
|
||||
(controller == SessionPrefs.CONTROLLER_DECK || controller == SessionPrefs.CONTROLLER_STEAM)
|
||||
|
||||
data class Dock(val portrait: Boolean, val grips: Boolean, val left: InputControl = InputControl.LS, val right: InputControl = InputControl.RS) {
|
||||
@@ -30,28 +28,22 @@ object OnScreenLayout {
|
||||
|
||||
private const val TOLERANCE = .01f
|
||||
private const val KEYBOARD_ID = "builtin:keyboard"
|
||||
private val REAR = setOf(InputControl.L4, InputControl.L5, InputControl.R4, InputControl.R5)
|
||||
|
||||
fun elements(context: Context, saved: SavedInputLayout?, width: Int, height: Int, safe: Rect,
|
||||
fun elements(context: Context, layout: SavedInputLayout?, width: Int, height: Int, safe: Rect,
|
||||
buttonsOnly: Boolean = false, dock: Dock? = null, rearButtons: Boolean? = null,
|
||||
trackpads: Boolean? = null): List<InputSurfaceElement> {
|
||||
if (saved == null) return emptyList()
|
||||
if (width <= 0 || height <= 0) return saved.elements
|
||||
val layout = oriented(saved, width, height)
|
||||
val stored = layout.elements
|
||||
val stored = layout?.elements ?: return emptyList()
|
||||
if (width <= 0 || height <= 0) return stored
|
||||
val generator = LegacyGamepadLayout(context, width, height, safe, layout.scale)
|
||||
val (reference, matched) = reference(context, layout, width, height)
|
||||
val (reference, generated) = reference(context, layout, width, height)
|
||||
if (buttonsOnly && dock == null) return generator.buttonsOnly(stored) + fit(stored.filter { it.alwaysShown }, reference.first, reference.second, width, height, safe)
|
||||
val generated = matched || PadKit.forOverlay(context, layout) != null && stored.any(::isGamepad) &&
|
||||
(dock != null || height > width && layout.aspect >= 1f || height <= width && layout.aspect > 0f && layout.aspect < 1f)
|
||||
val gamepad = if (generated) stored.filter(::isGamepad) else emptyList()
|
||||
val others = fit(stored.filterNot { generated && isGamepad(it) || dock != null && it.alwaysShown }, reference.first, reference.second, width, height, safe)
|
||||
val regenerated = when {
|
||||
val placed = when {
|
||||
gamepad.isEmpty() -> emptyList()
|
||||
dock != null -> generator.dock(gamepad, dock.portrait, dock.grips, dock.left, dock.right)
|
||||
else -> generator.regenerate(gamepad)
|
||||
}
|
||||
val placed = regenerated + gamepad.filter { g -> dock == null && optional(g) && regenerated.none { it.id == g.id } }
|
||||
val byId = (placed + others).associateBy { it.id }
|
||||
val ordered = stored.mapNotNull { byId[it.id] } + placed.filter { p -> stored.none { it.id == p.id } }
|
||||
val kit = PadKit.forOverlay(context, layout) ?: return ordered
|
||||
@@ -70,52 +62,12 @@ object OnScreenLayout {
|
||||
.place(ordered, lowerShortcuts = generated, rearButtons = rearButtons, trackpads = trackpads)
|
||||
}
|
||||
|
||||
fun oriented(layout: SavedInputLayout, width: Int, height: Int): SavedInputLayout {
|
||||
val portrait = height > width
|
||||
if (layout.rotated.isEmpty() || layout.aspect <= 0f || (layout.aspect < 1f) == portrait || (layout.rotatedAspect < 1f) != portrait) return layout
|
||||
val rotated = layout.rotated.associateBy { it.id }
|
||||
return layout.copy(elements = layout.elements.map { e -> rotated[e.id]?.let { e.copy(x = it.x, y = it.y, width = it.width, height = it.height) } ?: e } +
|
||||
layout.rotated.filter { r -> optional(r) && layout.elements.none { it.id == r.id } },
|
||||
aspect = layout.rotatedAspect, scale = layout.rotatedScale, rotated = emptyList(), rotatedAspect = 0f, rotatedScale = 1f)
|
||||
}
|
||||
|
||||
fun withFrame(context: Context, saved: SavedInputLayout, elements: List<InputSurfaceElement>, aspect: Float, scale: Float = saved.scale): SavedInputLayout {
|
||||
val (_, metrics) = InputLibraries.primaryDisplay(context)
|
||||
val generated = generatedSize(context, saved, metrics.widthPixels, metrics.heightPixels) != null
|
||||
val portraitMain = saved.aspect > 0f && saved.aspect < 1f
|
||||
if (aspect <= 0f || aspect >= 1f || portraitMain && !generated) {
|
||||
val rotated = if (aspect >= 1f && portraitMain && !generated) Triple(saved.elements, saved.aspect, saved.scale) else Triple(saved.rotated, saved.rotatedAspect, saved.rotatedScale)
|
||||
return saved.copy(elements = elements, aspect = aspect, scale = scale, rotated = rotated.first,
|
||||
rotatedAspect = if (rotated.first.isEmpty()) 0f else rotated.second, rotatedScale = if (rotated.first.isEmpty()) 1f else rotated.third)
|
||||
}
|
||||
val main = if (portraitMain) 1f / saved.aspect else saved.aspect.takeIf { it > 0f } ?: (1f / aspect)
|
||||
val ids = elements.associateBy { it.id }
|
||||
val kept = saved.elements.mapNotNull { e -> ids[e.id]?.copy(x = e.x, y = e.y, width = e.width, height = e.height) }
|
||||
val added = fit(elements.filter { d -> !optional(d) && saved.elements.none { it.id == d.id } }, aspect, 1f, (main * 1000).roundToInt().coerceAtLeast(1), 1000, Rect())
|
||||
return saved.copy(elements = kept + added, aspect = main, rotated = elements, rotatedAspect = aspect, rotatedScale = scale)
|
||||
}
|
||||
|
||||
fun optionalControls(context: Context): Pair<Boolean?, Boolean?> {
|
||||
val steam = SessionState.mode == SessionService.MODE_STEAM && SessionState.deckPad
|
||||
return SessionPrefs.oscRearButtons(context).takeIf { steam } to SessionPrefs.oscTrackpads(context).takeIf { steam }
|
||||
}
|
||||
|
||||
fun editorElements(context: Context, layout: SavedInputLayout, width: Int, height: Int, edited: Boolean = false, safe: Rect = Rect()): List<InputSurfaceElement> {
|
||||
val (rear, pads) = optionalControls(context)
|
||||
return elements(context, if (edited && width > 0 && height > 0) layout.copy(aspect = width.toFloat() / height) else layout, width, height, safe,
|
||||
rearButtons = rear, trackpads = pads)
|
||||
}
|
||||
fun editorElements(context: Context, layout: SavedInputLayout, width: Int, height: Int, edited: Boolean = false): List<InputSurfaceElement> =
|
||||
elements(context, if (edited && width > 0 && height > 0) layout.copy(aspect = width.toFloat() / height) else layout, width, height, Rect())
|
||||
|
||||
fun editorFrame(layout: SavedInputLayout, displayed: List<InputSurfaceElement>): List<InputSurfaceElement> {
|
||||
val byId = displayed.associateBy { it.id }
|
||||
return layout.elements.map { byId[it.id] ?: it } + displayed.filter { d ->
|
||||
optional(d) && layout.elements.none { it.id == d.id }
|
||||
}
|
||||
}
|
||||
|
||||
fun safeInsets(insets: android.view.WindowInsets?, docked: Boolean): Rect {
|
||||
val cutout = if (android.os.Build.VERSION.SDK_INT >= 28) insets?.displayCutout else null
|
||||
return Rect(cutout?.safeInsetLeft ?: 0, if (docked) 0 else cutout?.safeInsetTop ?: 0, cutout?.safeInsetRight ?: 0, cutout?.safeInsetBottom ?: 0)
|
||||
return layout.elements.map { byId[it.id] ?: it }
|
||||
}
|
||||
|
||||
fun fit(elements: List<InputSurfaceElement>, referenceWidth: Float, referenceHeight: Float, width: Int, height: Int, safe: Rect): List<InputSurfaceElement> {
|
||||
@@ -141,8 +93,6 @@ object OnScreenLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private fun optional(e: InputSurfaceElement) = e.id == "legacy:${e.control.id}" && (e.control.isTrackpad || e.control in REAR)
|
||||
|
||||
private fun isGamepad(e: InputSurfaceElement) = e.id.startsWith("legacy:") || e.id == KEYBOARD_ID
|
||||
|
||||
fun generatedSize(context: Context, layout: SavedInputLayout, width: Int, height: Int): Pair<Int, Int>? =
|
||||
@@ -156,7 +106,7 @@ object OnScreenLayout {
|
||||
if (gamepad.any { it.id.startsWith("legacy:") }) {
|
||||
val named = layout.id.removePrefix("migrated.layout.").takeIf { it != layout.id }?.split('x')?.mapNotNull { it.toIntOrNull() }
|
||||
?.takeIf { it.size == 2 && it.all { size -> size > 0 } }?.let { it[0] to it[1] }
|
||||
val aspectSize = layout.aspect.takeIf { layout.overlay && it > 0f }
|
||||
val aspectSize = layout.aspect.takeIf { layout.id == InputLibraries.OVERLAY && it > 0f }
|
||||
?.let { (it * height).roundToInt().coerceAtLeast(1) to height }
|
||||
for ((w, h) in listOfNotNull(named, width to height, aspectSize, long to short, short to long).distinct()) {
|
||||
val generator = LegacyGamepadLayout(display, w, h, scale = layout.scale)
|
||||
|
||||
@@ -34,15 +34,9 @@ internal enum class PadKit(val face: FaceGlyphs, val dpad: DpadStyle, val stick:
|
||||
else -> label(control)
|
||||
}
|
||||
|
||||
fun native(element: InputSurfaceElement) = element.id == "legacy:${element.control.id}" && element.icon == 0 &&
|
||||
(element.name == element.control.label || element.name == name(element.control))
|
||||
|
||||
fun artwork(element: InputSurfaceElement) = element.image.isEmpty() && element.showLabel &&
|
||||
(native(element) || element.id == "builtin:keyboard" && element.icon == InputButtonIcons.KEYBOARD)
|
||||
|
||||
companion object {
|
||||
fun forOverlay(context: Context, layout: SavedInputLayout?): PadKit? =
|
||||
if (layout?.overlay != true) null else when (SessionPrefs.steamController(context)) {
|
||||
if (layout?.id != InputLibraries.OVERLAY) null else when (SessionPrefs.steamController(context)) {
|
||||
SessionPrefs.CONTROLLER_DECK -> STEAM_DECK
|
||||
SessionPrefs.CONTROLLER_STEAM -> STEAM_CONTROLLER
|
||||
SessionPrefs.CONTROLLER_XBOX360 -> XBOX
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
enum class SecondScreenMode(val id: String, @StringRes val label: Int, val bindings: String? = null) {
|
||||
NONE("none", R.string.second_mode_none),
|
||||
MENU("menu", R.string.touch_droiddeck_menu),
|
||||
KEYBOARD_TRACKPAD("keyboard-trackpad", R.string.second_mode_keyboard_trackpad, InputStockLayouts.TRACKPAD),
|
||||
TERMINAL("terminal", R.string.second_mode_terminal),
|
||||
DECK_CONTROLS("deck-controls", R.string.second_mode_deck_controls, InputStockLayouts.DECK),
|
||||
@@ -22,12 +21,19 @@ enum class SecondScreenMode(val id: String, @StringRes val label: Int, val bindi
|
||||
fun panel(context: Context): String? = if (this == DECK_CONTROLS) SessionPrefs.deckPanel(context).bindings else bindings
|
||||
|
||||
companion object {
|
||||
/** The mode the bottom screen opens in: the one picked last if it is still available, else the DroidDeck menu. */
|
||||
fun opening(remembered: String?, deckPad: Boolean, dashboard: Boolean = false, bottomDesktop: Boolean = false): SecondScreenMode =
|
||||
fun opening(remembered: String?, deckPad: Boolean, dashboard: Boolean = false, bottomDesktop: Boolean = false, desktopSession: Boolean = false): SecondScreenMode {
|
||||
entries.firstOrNull {
|
||||
it != NONE && it.id == remembered && (it != DECK_CONTROLS || deckPad) && (it != DASHBOARD || dashboard) &&
|
||||
(it != DESKTOP || bottomDesktop)
|
||||
} ?: MENU
|
||||
}?.let { return it }
|
||||
val picked = entries.any { it != NONE && it.id == remembered }
|
||||
return when {
|
||||
desktopSession -> KEYBOARD_TRACKPAD
|
||||
deckPad -> DECK_CONTROLS
|
||||
dashboard && !picked -> DASHBOARD
|
||||
else -> KEYBOARD_TRACKPAD
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ object BattleNet {
|
||||
|
||||
const val APP_ID = 2596113170L
|
||||
|
||||
const val FEX_REQUEST = "battlenet-fex.request"
|
||||
const val FEX_RESULT = "battlenet-fex.result"
|
||||
|
||||
const val PROGRAM = "/usr/local/bin/droiddeck-battlenet"
|
||||
|
||||
class Title(val uid: String, val name: String, val code: String, val steam: Int? = null, val shop: String? = null, val product: String? = null, val flavor: String? = null)
|
||||
@@ -159,6 +162,8 @@ object BattleNet {
|
||||
source = com.droiddeck.launcher.stores.Store.BATTLENET.id,
|
||||
)
|
||||
|
||||
fun fexInUse(context: Context): String? = ComponentsManager.gameComponents(context, APP_ID.toString())["fex"]
|
||||
|
||||
internal fun title(uid: String): Title? {
|
||||
val id = uid.lowercase()
|
||||
TITLES.firstOrNull { it.uid == id }?.let { return it }
|
||||
@@ -386,6 +391,54 @@ object BattleNet {
|
||||
Log.i(TAG, "removed")
|
||||
}
|
||||
|
||||
private val D2RFIX = Regex("""(?i)FEXCore-(\d+(?:\.\d+)*)-d2rfix(\d+)-linux\.wcp""")
|
||||
|
||||
private const val LISTING_MAX_AGE = 6 * 3600L
|
||||
|
||||
private val NEWEST = Comparator<Pair<List<Long>, Long>> { a, b ->
|
||||
for (i in 0 until minOf(a.first.size, b.first.size)) if (a.first[i] != b.first[i]) return@Comparator a.first[i].compareTo(b.first[i])
|
||||
if (a.first.size != b.first.size) a.first.size.compareTo(b.first.size) else a.second.compareTo(b.second)
|
||||
}
|
||||
|
||||
internal fun d2rfix(file: String): Pair<List<Long>, Long>? {
|
||||
val m = D2RFIX.matchEntire(file) ?: return null
|
||||
val version = m.groupValues[1].split('.').map { it.toLongOrNull() ?: return null }
|
||||
return version to (m.groupValues[2].toLongOrNull() ?: return null)
|
||||
}
|
||||
|
||||
internal fun newestD2rFix(items: List<ComponentsManager.CatalogItem>): ComponentsManager.CatalogItem? =
|
||||
items.filter { it.comp == "fex" }.mapNotNull { item -> d2rfix(item.file)?.let { item to it } }
|
||||
.maxWithOrNull { a, b -> NEWEST.compare(a.second, b.second) }?.first
|
||||
|
||||
fun ensureFex(context: Context): String = ensureFex(context) { ComponentsManager.catalog(it, true).items }
|
||||
|
||||
@Synchronized
|
||||
internal fun ensureFex(context: Context, refresh: (Context) -> List<ComponentsManager.CatalogItem>): String {
|
||||
val item = newestD2rFix(listing(context, refresh)) ?: error("no d2rfix FEXCore build in the Nightlies listing")
|
||||
val file = ComponentsManager.safeName(item.file)
|
||||
if (ComponentsManager.packages(context).none { it.file == file }) {
|
||||
Log.i(TAG, "downloading ${item.file}")
|
||||
ComponentsManager.download(context, item) {}
|
||||
}
|
||||
val scope = APP_ID.toString()
|
||||
if (ComponentsManager.gameComponents(context, scope)["fex"] != file) {
|
||||
ComponentsManager.setGameComponent(context, scope, "fex", file)
|
||||
Log.i(TAG, "FEX for the Battle.net prefix: $file")
|
||||
} else if (ComponentsManager.republish(context)) {
|
||||
Log.i(TAG, "FEX for the Battle.net prefix: $file, now in every installed Proton")
|
||||
}
|
||||
return file
|
||||
}
|
||||
|
||||
private fun listing(context: Context, refresh: (Context) -> List<ComponentsManager.CatalogItem>): List<ComponentsManager.CatalogItem> {
|
||||
val cached = ComponentsManager.catalog(context, false)
|
||||
val age = System.currentTimeMillis() / 1000 - cached.fetchedAt
|
||||
if (age in 0 until LISTING_MAX_AGE && newestD2rFix(cached.items) != null) return cached.items
|
||||
val fetched = runCatching { refresh(context) }
|
||||
.onFailure { Log.w(TAG, "Nightlies listing: ${it.message}") }.getOrNull().orEmpty()
|
||||
return if (newestD2rFix(fetched) != null) fetched else cached.items
|
||||
}
|
||||
|
||||
internal fun videoMemory(totalMb: Long): Int = (totalMb / 5 / 512 * 512).coerceIn(1536, 3584).toInt()
|
||||
|
||||
internal fun videoMemoryOptions(megabytes: Int): String =
|
||||
@@ -411,9 +464,21 @@ object BattleNet {
|
||||
return true
|
||||
}
|
||||
|
||||
fun ensureDefaults(context: Context, program: String?) {
|
||||
if (program != PROGRAM && !installed(context)) return
|
||||
runCatching { ensureVideoMemory(context) }.onFailure { Log.w(TAG, "video memory cap for the Battle.net profile", it) }
|
||||
runCatching { ensureNoSteam(context) }.onFailure { Log.w(TAG, "Start without Steam for the Battle.net profile", it) }
|
||||
fun answerFexRequest(context: Context, dir: File) {
|
||||
val app = context.applicationContext
|
||||
Thread({
|
||||
runCatching { ensureVideoMemory(app) }.onFailure { Log.w(TAG, "video memory cap for the Battle.net profile", it) }
|
||||
runCatching { ensureNoSteam(app) }.onFailure { Log.w(TAG, "Start without Steam for the Battle.net profile", it) }
|
||||
val answer = try {
|
||||
"ok " + ensureFex(app)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "FEX for the Battle.net prefix", e)
|
||||
"error " + (e.message ?: e.javaClass.simpleName)
|
||||
}
|
||||
Log.i(TAG, "FEX request: $answer")
|
||||
val result = File(dir, FEX_RESULT)
|
||||
val partial = File(dir, "$FEX_RESULT.tmp")
|
||||
runCatching { partial.writeText(answer.replace('\n', ' ') + "\n"); partial.renameTo(result) }
|
||||
}, "battlenet-fex").start()
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
object CurseForgeApp {
|
||||
const val NAME = "CurseForge"
|
||||
const val FEED = "https://curseforge.overwolf.com/electron/linux/latest-linux.yml"
|
||||
|
||||
fun find(apps: List<UserApps.App>): UserApps.App? = apps.firstOrNull { it.feed == FEED }
|
||||
|
||||
fun request(): UserApps.Request = UserApps.Request(UserApps.Source.Feed(FEED), NAME, null)
|
||||
}
|
||||
@@ -36,7 +36,6 @@ object UserApps {
|
||||
private const val GITHUB_TAG = "github-tag"
|
||||
private const val GITHUB_PUBLISHED = "github-published"
|
||||
private const val GITHUB_ASSET = "github-asset"
|
||||
private const val FEED = "update-feed"
|
||||
|
||||
enum class Kind { SCRIPT, APPIMAGE, FLATPAK }
|
||||
|
||||
@@ -44,16 +43,11 @@ object UserApps {
|
||||
val key: String, val kind: Kind, val name: String, val icon: Any?, val detail: String?,
|
||||
val program: String, val args: List<String>, val copied: Boolean = false,
|
||||
val repo: String? = null, val version: String? = null,
|
||||
val fex: String = LinuxFex.AUTO, val arch: String? = null, val feed: String? = null,
|
||||
) {
|
||||
val updatable get() = repo != null || feed != null
|
||||
}
|
||||
|
||||
class Release(
|
||||
val tag: String, val published: String, val asset: String, val url: String,
|
||||
val sha256: String? = null, val sha512: String? = null,
|
||||
val fex: String = LinuxFex.AUTO, val arch: String? = null,
|
||||
)
|
||||
|
||||
class Release(val tag: String, val published: String, val asset: String, val url: String, val sha256: String? = null)
|
||||
|
||||
sealed class UpdateCheck {
|
||||
class Current(val tag: String) : UpdateCheck()
|
||||
class Available(val release: Release) : UpdateCheck()
|
||||
@@ -64,7 +58,6 @@ object UserApps {
|
||||
class Script(val file: File) : Source()
|
||||
class AppImage(val file: File) : Source()
|
||||
class GitHub(val repo: String, val asset: String? = null) : Source()
|
||||
class Feed(val url: String) : Source()
|
||||
class Flatpak(val id: String) : Source()
|
||||
class FlatpakBundle(val file: File) : Source()
|
||||
}
|
||||
@@ -98,7 +91,6 @@ object UserApps {
|
||||
"appimage:${item.id}", Kind.APPIMAGE, item.name, item.icon, item.comment, AppImageManager.LAUNCHER, listOf(item.guestDir),
|
||||
repo = FileUtils.readString(File(dir, GITHUB_REPO))?.trim(), version = FileUtils.readString(File(dir, GITHUB_TAG))?.trim(),
|
||||
fex = LinuxFex.mode(dir), arch = FileUtils.readString(File(dir, "arch"))?.trim()?.takeIf { it.isNotEmpty() },
|
||||
feed = FileUtils.readString(File(dir, FEED))?.trim()?.takeIf { it.isNotEmpty() },
|
||||
)
|
||||
}
|
||||
val flatpaks = FlatpakManager.installedApps(context).map { app ->
|
||||
@@ -123,7 +115,6 @@ object UserApps {
|
||||
is Source.Script -> addScript(context, s.file, name, icon, request.meta, onProgress)
|
||||
is Source.AppImage -> AppImageManager.import(context, s.file, name, icon, request.meta) { onProgress(it, -1) }
|
||||
is Source.GitHub -> addFromGitHub(context, s.repo, s.asset, name, icon, onProgress)
|
||||
is Source.Feed -> addFromFeed(context, s.url, name, icon, onProgress)
|
||||
is Source.Flatpak -> addFlatpak(context, s.id, name, icon, onProgress)
|
||||
is Source.FlatpakBundle -> addFlatpakBundle(context, s.file, name, icon, onProgress)
|
||||
}
|
||||
@@ -355,15 +346,11 @@ object UserApps {
|
||||
}
|
||||
|
||||
private fun withDownload(context: Context, release: Release, onProgress: (String, Int) -> Unit, use: (File) -> String?): String? {
|
||||
val download = File(File(context.cacheDir, "user-apps").apply { mkdirs() }, release.asset)
|
||||
val download = File(context.cacheDir, "github-${release.asset}")
|
||||
try {
|
||||
val label = context.getString(R.string.user_apps_downloading, release.asset)
|
||||
val ok = Downloader.downloadFile(release.url, download, false, release.sha256) { f -> onProgress(label, if (f < 0) -1 else Math.round(f * 100f)) }
|
||||
if (!ok) return context.getString(R.string.user_apps_download_failed)
|
||||
if (release.sha512 != null && !Hashes.sha512(download).equals(release.sha512, ignoreCase = true)) {
|
||||
return context.getString(R.string.selfinst_checksum_mismatch)
|
||||
}
|
||||
return use(download)
|
||||
return if (ok) use(download) else context.getString(R.string.user_apps_download_failed)
|
||||
} finally {
|
||||
download.delete()
|
||||
}
|
||||
@@ -405,57 +392,20 @@ object UserApps {
|
||||
return urls + listOfNotNull(avatar)
|
||||
}
|
||||
|
||||
internal fun parseFeed(feed: String, body: String): Release? {
|
||||
val top = body.lineSequence().filter { it.isNotEmpty() && !it[0].isWhitespace() && ':' in it }
|
||||
.associate { it.substringBefore(':').trim() to it.substringAfter(':').trim().trim('\'', '"') }
|
||||
val version = top["version"]?.takeIf { it.isNotEmpty() } ?: return null
|
||||
val path = top["path"]?.takeIf { it.endsWith(".AppImage", ignoreCase = true) && '/' !in it && ".." !in it } ?: return null
|
||||
val sha512 = top["sha512"]?.let { runCatching { java.util.Base64.getDecoder().decode(it) }.getOrNull() }
|
||||
?.takeIf { it.size == 64 }?.joinToString("") { "%02x".format(it) } ?: return null
|
||||
val base = feed.substringBeforeLast('/', "").takeIf { it.startsWith("https://") } ?: return null
|
||||
return Release(version, top["releaseDate"].orEmpty(), path, "$base/$path", sha512 = sha512)
|
||||
}
|
||||
|
||||
private fun feedRelease(context: Context, feed: String): Release? =
|
||||
Downloader.downloadString(feed)?.let { parseFeed(feed, it) }
|
||||
|
||||
private fun feedMeta(feed: String, release: Release) =
|
||||
mapOf(FEED to feed, GITHUB_TAG to release.tag, GITHUB_PUBLISHED to release.published, GITHUB_ASSET to release.asset)
|
||||
|
||||
private fun addFromFeed(context: Context, feed: String, name: String?, icon: File?, onProgress: (String, Int) -> Unit): String? {
|
||||
onProgress(context.getString(R.string.user_apps_github_checking, name ?: feed), -1)
|
||||
val release = feedRelease(context, feed) ?: return context.getString(R.string.user_apps_update_failed)
|
||||
return withDownload(context, release, onProgress) { file ->
|
||||
AppImageManager.import(context, file, name ?: release.asset.substringBefore('-'), icon, feedMeta(feed, release)) { onProgress(it, -1) }
|
||||
}
|
||||
}
|
||||
|
||||
internal fun isNewer(release: Release, published: String, installed: String?): Boolean =
|
||||
if (published.isNotEmpty() && release.published.isNotEmpty()) {
|
||||
val feed = runCatching { java.time.Instant.parse(release.published) }.getOrNull()
|
||||
val have = runCatching { java.time.Instant.parse(published) }.getOrNull()
|
||||
if (feed != null && have != null) feed > have else release.published > published
|
||||
} else release.tag != installed
|
||||
|
||||
fun checkUpdate(context: Context, app: App): UpdateCheck {
|
||||
app.feed?.let { feed ->
|
||||
val release = feedRelease(context, feed) ?: return UpdateCheck.Failed(context.getString(R.string.user_apps_update_failed))
|
||||
val published = FileUtils.readString(File(AppImageManager.dir(context, app.key.substringAfter(':')), GITHUB_PUBLISHED))?.trim().orEmpty()
|
||||
return if (isNewer(release, published, app.version)) UpdateCheck.Available(release) else UpdateCheck.Current(app.version ?: release.tag)
|
||||
}
|
||||
val repo = app.repo ?: return UpdateCheck.Failed(context.getString(R.string.user_apps_update_failed))
|
||||
val dir = AppImageManager.dir(context, app.key.substringAfter(':'))
|
||||
val (release, problem) = latestRelease(context, repo, FileUtils.readString(File(dir, GITHUB_ASSET))?.trim()?.takeIf { it.isNotEmpty() })
|
||||
if (release == null) return UpdateCheck.Failed(problem ?: context.getString(R.string.user_apps_update_failed))
|
||||
val published = FileUtils.readString(File(dir, GITHUB_PUBLISHED))?.trim().orEmpty()
|
||||
return if (isNewer(release, published, app.version)) UpdateCheck.Available(release) else UpdateCheck.Current(app.version ?: release.tag)
|
||||
val newer = if (published.isNotEmpty() && release.published.isNotEmpty()) release.published > published else release.tag != app.version
|
||||
return if (newer) UpdateCheck.Available(release) else UpdateCheck.Current(app.version ?: release.tag)
|
||||
}
|
||||
|
||||
fun update(context: Context, app: App, release: Release, onProgress: (String, Int) -> Unit): String? {
|
||||
val meta = app.feed?.let { feedMeta(it, release) }
|
||||
?: app.repo?.let { githubMeta(it, release) } ?: return context.getString(R.string.user_apps_update_failed)
|
||||
val repo = app.repo ?: return context.getString(R.string.user_apps_update_failed)
|
||||
return withDownload(context, release, onProgress) { file ->
|
||||
AppImageManager.replace(context, app.key.substringAfter(':'), file, meta) { onProgress(it, -1) }
|
||||
AppImageManager.replace(context, app.key.substringAfter(':'), file, githubMeta(repo, release)) { onProgress(it, -1) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ object WowAddonCatalog {
|
||||
internal class Cat(val id: String, val name: String, val parents: List<String>)
|
||||
|
||||
private const val WOWI = "https://api.mmoui.com/v3/game/WOW/"
|
||||
private const val CURSEFORGE = "https://www.curseforge.com/wow/search?class=addons"
|
||||
private const val WOWI_FILES = "wowi-filelist.json"
|
||||
internal const val FRESH_MS = 6L * 60 * 60 * 1000
|
||||
|
||||
@@ -208,12 +209,10 @@ object WowAddonCatalog {
|
||||
|
||||
fun categories(context: Context): List<Category> = wowiCategories(context).map { Category(it.id, it.name) }
|
||||
|
||||
internal class Details(val url: String, val md5: String?, val version: String?)
|
||||
|
||||
internal fun parseWowiDetails(json: String): Details? {
|
||||
internal fun parseWowiDetails(json: String): Pair<String, String?>? {
|
||||
val o = JSONArray(json).optJSONObject(0) ?: return null
|
||||
val url = o.optString("UIDownload").ifEmpty { return null }
|
||||
return Details(url, o.optString("UIMD5").ifEmpty { null }, o.optString("UIVersion").trim().ifEmpty { null })
|
||||
return url to o.optString("UIMD5").ifEmpty { null }
|
||||
}
|
||||
|
||||
internal fun isHttps(url: String) = url.startsWith("https://", ignoreCase = true)
|
||||
@@ -221,11 +220,10 @@ object WowAddonCatalog {
|
||||
internal fun md5Matches(file: File, expected: String?): Boolean =
|
||||
expected.isNullOrBlank() || Hashes.md5(file).equals(expected.trim(), ignoreCase = true)
|
||||
|
||||
fun download(context: Context, addon: Addon, dest: File, progress: (Int) -> Unit): String? {
|
||||
fun download(context: Context, addon: Addon, dest: File, progress: (Int) -> Unit): File {
|
||||
val body = StoreNet.get(WOWI + "filedetails/${URLEncoder.encode(addon.id, "UTF-8")}.json", timeoutMs = 30_000)
|
||||
?: throw unreachable(context)
|
||||
val details = parseWowiDetails(body) ?: throw IOException(context.getString(R.string.addons_no_file))
|
||||
val url = details.url
|
||||
val (url, md5) = parseWowiDetails(body) ?: throw IOException(context.getString(R.string.addons_no_file))
|
||||
if (!isHttps(url)) throw IOException(context.getString(R.string.addons_no_file))
|
||||
dest.parentFile?.mkdirs()
|
||||
dest.delete()
|
||||
@@ -234,33 +232,14 @@ object WowAddonCatalog {
|
||||
dest.delete()
|
||||
throw unreachable(context)
|
||||
}
|
||||
if (!md5Matches(dest, details.md5)) {
|
||||
if (!md5Matches(dest, md5)) {
|
||||
dest.delete()
|
||||
throw IOException(context.getString(R.string.selfinst_checksum_mismatch))
|
||||
}
|
||||
progress(100)
|
||||
return details.version
|
||||
return dest
|
||||
}
|
||||
|
||||
internal fun sameVersion(a: String, b: String): Boolean {
|
||||
fun norm(v: String) = v.trim().removePrefix("v").removePrefix("V").trim().lowercase()
|
||||
return norm(a) == norm(b)
|
||||
}
|
||||
|
||||
internal fun findUpdates(entries: List<Entry>, installed: List<WowAddons.Installed>): Map<String, Addon> {
|
||||
val byId = entries.associateBy { it.addon.id }
|
||||
val seen = HashSet<String>()
|
||||
return installed.mapNotNull { item ->
|
||||
val id = item.wowiId ?: return@mapNotNull null
|
||||
val version = item.version ?: return@mapNotNull null
|
||||
val latest = byId[id]?.addon?.takeIf { it.summary.isNotBlank() } ?: return@mapNotNull null
|
||||
if (sameVersion(version, latest.summary) || !seen.add(id)) null else item.name to latest
|
||||
}.toMap()
|
||||
}
|
||||
|
||||
fun updates(context: Context, installed: List<WowAddons.Installed>, target: WowAddons.Target): Map<String, Addon> {
|
||||
if (installed.none { it.wowiId != null }) return emptyMap()
|
||||
val family = client(target).family
|
||||
return runCatching { findUpdates(wowiEntries(context).filter { flavorMatches(it.flavors, family) }, installed) }.getOrDefault(emptyMap())
|
||||
}
|
||||
internal fun curseForgeUrl(text: String): String =
|
||||
text.trim().let { if (it.isEmpty()) CURSEFORGE else CURSEFORGE + "&search=" + URLEncoder.encode(it, "UTF-8") }
|
||||
}
|
||||
@@ -2,25 +2,15 @@ package com.droiddeck.launcher.runtime
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoreArchiveUnpacker
|
||||
import com.droiddeck.launcher.stores.StoreInstalls
|
||||
import com.droiddeck.launcher.stores.itch.ItchArchives
|
||||
import org.apache.commons.compress.archivers.zip.ZipFile
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.nio.file.FileVisitResult
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.LinkOption
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.SimpleFileVisitor
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
object WowAddons {
|
||||
var imports by mutableIntStateOf(0)
|
||||
@@ -32,12 +22,6 @@ object WowAddons {
|
||||
|
||||
class Addon(val name: String, val root: String)
|
||||
|
||||
class Installed(val name: String, val version: String?, val wowiId: String?)
|
||||
|
||||
class Origin(val id: String, val version: String)
|
||||
|
||||
private const val ORIGINS = ".droiddeck-sources"
|
||||
|
||||
internal const val MAX_EXPANDED_BYTES = 4L * 1024 * 1024 * 1024
|
||||
|
||||
private val SUFFIX = Regex("[-_](standard|mainline|classic|vanilla|tbc|bcc|wrath|wotlkc|cata|mists|forever)$", RegexOption.IGNORE_CASE)
|
||||
@@ -61,149 +45,53 @@ object WowAddons {
|
||||
target.addOns.listFiles().orEmpty().filter { it.isDirectory && !it.name.startsWith(".") }
|
||||
.map { it.name }.sortedBy { it.lowercase() }
|
||||
|
||||
fun details(target: Target): List<Installed> {
|
||||
val origins = origins(target)
|
||||
return installed(target).map { name ->
|
||||
val toc = toc(File(target.addOns, name))
|
||||
val origin = origins[name]
|
||||
Installed(name, origin?.version ?: toc["Version"], origin?.id ?: toc["X-WoWI-ID"])
|
||||
}
|
||||
}
|
||||
|
||||
internal fun tocFields(text: String): Map<String, String> {
|
||||
val out = LinkedHashMap<String, String>()
|
||||
for (raw in text.lineSequence()) {
|
||||
val line = raw.trim().removePrefix("\uFEFF")
|
||||
if (!line.startsWith("##") || ':' !in line) continue
|
||||
val key = line.removePrefix("##").substringBefore(':').trim()
|
||||
val value = line.substringAfter(':').trim()
|
||||
if (key.isNotEmpty() && value.isNotEmpty() && '@' !in value) out.putIfAbsent(key, value)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
private fun toc(folder: File): Map<String, String> {
|
||||
val tocs = folder.listFiles().orEmpty().filter { it.isFile && it.name.endsWith(".toc", ignoreCase = true) }
|
||||
val main = tocs.firstOrNull { it.name.dropLast(4).equals(folder.name, ignoreCase = true) }
|
||||
?: tocs.firstOrNull { it.name.dropLast(4).replace(SUFFIX, "").equals(folder.name, ignoreCase = true) }
|
||||
?: tocs.minByOrNull { it.name.length } ?: return emptyMap()
|
||||
return runCatching { tocFields(main.readText()) }.getOrDefault(emptyMap())
|
||||
}
|
||||
|
||||
internal fun parseOrigins(text: String): Map<String, Origin> = text.lineSequence().mapNotNull { line ->
|
||||
val parts = line.split('\t')
|
||||
if (parts.size != 3 || parts.any { it.isBlank() }) null else parts[0] to Origin(parts[1], parts[2])
|
||||
}.toMap()
|
||||
|
||||
internal fun formatOrigins(origins: Map<String, Origin>): String =
|
||||
origins.entries.sortedBy { it.key.lowercase() }.joinToString("") { (name, o) -> "$name\t${o.id}\t${o.version.replace(Regex("\\s+"), " ")}\n" }
|
||||
|
||||
private fun originsFile(target: Target) = File(target.addOns, ORIGINS)
|
||||
|
||||
private fun origins(target: Target): Map<String, Origin> =
|
||||
runCatching { parseOrigins(originsFile(target).readText()) }.getOrDefault(emptyMap())
|
||||
|
||||
private val originsLock = Any()
|
||||
|
||||
private fun keepOrigins(target: Target, names: List<String>, origin: Origin?) = synchronized(originsLock) {
|
||||
val current = origins(target)
|
||||
val next = current - names.toSet() + (origin?.let { o -> names.associateWith { o } } ?: emptyMap())
|
||||
if (next != current) {
|
||||
val file = originsFile(target)
|
||||
if (next.isEmpty()) file.delete() else {
|
||||
val temp = File(target.addOns, "$ORIGINS.tmp")
|
||||
temp.writeText(formatOrigins(next))
|
||||
if (!temp.renameTo(file)) {
|
||||
temp.delete()
|
||||
throw IOException("Cannot save $ORIGINS")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun delete(target: Target, name: String) {
|
||||
val folder = target.addOns.listFiles()?.firstOrNull { it.name == name && !it.name.startsWith(".") }
|
||||
?: throw IOException("Cannot find $name")
|
||||
StoreInstalls.deleteTree(folder)
|
||||
if (Files.exists(folder.toPath(), LinkOption.NOFOLLOW_LINKS)) throw IOException("Cannot delete $name")
|
||||
runCatching { keepOrigins(target, listOf(name), null) }
|
||||
imports++
|
||||
}
|
||||
|
||||
fun import(archive: File, target: Target, origin: Origin? = null, context: Context? = null): List<String> {
|
||||
if (context == null || ItchArchives.kind(archive, archive.name) == "zip") return importZip(archive, target, origin)
|
||||
val work = File(File(context.cacheDir, "wowaddons"), "unpack-${System.nanoTime()}")
|
||||
try {
|
||||
if (!work.mkdirs()) throw IOException("Cannot create ${work.path}")
|
||||
val unpacker = StoreArchiveUnpacker(context, AtomicBoolean(), "Addons", R.string.stores_itch_archive, R.string.stores_itch_extract_failed, "addon-unpack")
|
||||
unpacker.work = work
|
||||
unpacker.limit = MAX_EXPANDED_BYTES
|
||||
try {
|
||||
unpacker.unpack(archive, archive.name, { _, _ -> }, {})
|
||||
} catch (_: StoreArchiveUnpacker.TooLarge) {
|
||||
throw TooLarge()
|
||||
}
|
||||
return importFolder(work, target, origin)
|
||||
} finally {
|
||||
StoreInstalls.deleteTree(work)
|
||||
}
|
||||
}
|
||||
|
||||
private class Entry(val path: String, val open: () -> InputStream)
|
||||
|
||||
private fun importZip(zipFile: File, target: Target, origin: Origin?): List<String> =
|
||||
fun import(zipFile: File, target: Target): List<String> {
|
||||
ZipFile.builder().setFile(zipFile).get().use { zip ->
|
||||
val all = zip.entries.toList()
|
||||
if (all.any { it.isUnixSymlink }) return emptyList()
|
||||
importEntries(all.filter { !it.isDirectory }.mapNotNull { entry -> clean(entry.name)?.let { Entry(it) { zip.getInputStream(entry) } } }, target, origin)
|
||||
}
|
||||
|
||||
internal fun importFolder(folder: File, target: Target, origin: Origin?): List<String> {
|
||||
val entries = ArrayList<Entry>()
|
||||
var links = false
|
||||
Files.walkFileTree(folder.toPath(), object : SimpleFileVisitor<Path>() {
|
||||
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
|
||||
if (!attrs.isRegularFile) links = true
|
||||
else clean(folder.toPath().relativize(file).joinToString("/"))?.let { entries.add(Entry(it) { Files.newInputStream(file, LinkOption.NOFOLLOW_LINKS) }) }
|
||||
return if (links) FileVisitResult.TERMINATE else FileVisitResult.CONTINUE
|
||||
}
|
||||
})
|
||||
return if (links) emptyList() else importEntries(entries, target, origin)
|
||||
}
|
||||
|
||||
private fun importEntries(entries: List<Entry>, target: Target, origin: Origin?): List<String> {
|
||||
val addons = addons(entries.map { it.path })
|
||||
if (addons.isEmpty()) return emptyList()
|
||||
val addOns = target.addOns
|
||||
if (!addOns.isDirectory && !addOns.mkdirs()) throw IOException("Cannot create ${addOns.path}")
|
||||
val stage = File(addOns.parentFile, ".addon-import-${System.nanoTime()}")
|
||||
try {
|
||||
val fresh = File(stage, "new")
|
||||
val buffer = ByteArray(64 * 1024)
|
||||
var written = 0L
|
||||
for (entry in entries) {
|
||||
val addon = addons.firstOrNull { entry.path.startsWith(it.root) } ?: continue
|
||||
val out = inside(fresh, addon.name + "/" + entry.path.removePrefix(addon.root)) ?: continue
|
||||
out.parentFile?.mkdirs()
|
||||
entry.open().use { input ->
|
||||
out.outputStream().use { output ->
|
||||
while (true) {
|
||||
val read = input.read(buffer)
|
||||
if (read < 0) break
|
||||
written += read
|
||||
if (written > MAX_EXPANDED_BYTES) throw TooLarge()
|
||||
output.write(buffer, 0, read)
|
||||
val entries = all.filter { clean(it.name) != null }
|
||||
val addons = addons(entries.filter { !it.isDirectory }.mapNotNull { clean(it.name) })
|
||||
if (addons.isEmpty()) return emptyList()
|
||||
val addOns = target.addOns
|
||||
if (!addOns.isDirectory && !addOns.mkdirs()) throw IOException("Cannot create ${addOns.path}")
|
||||
val stage = File(addOns.parentFile, ".addon-import-${System.nanoTime()}")
|
||||
try {
|
||||
val fresh = File(stage, "new")
|
||||
val buffer = ByteArray(64 * 1024)
|
||||
var written = 0L
|
||||
for (entry in entries) {
|
||||
if (entry.isDirectory) continue
|
||||
val path = clean(entry.name) ?: continue
|
||||
val addon = addons.firstOrNull { path.startsWith(it.root) } ?: continue
|
||||
val out = inside(fresh, addon.name + "/" + path.removePrefix(addon.root)) ?: continue
|
||||
out.parentFile?.mkdirs()
|
||||
zip.getInputStream(entry).use { input ->
|
||||
out.outputStream().use { output ->
|
||||
while (true) {
|
||||
val read = input.read(buffer)
|
||||
if (read < 0) break
|
||||
written += read
|
||||
if (written > MAX_EXPANDED_BYTES) throw TooLarge()
|
||||
output.write(buffer, 0, read)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
swap(addons.map { File(fresh, it.name) to it.name }, addOns, File(stage, "old").apply { mkdirs() })
|
||||
} finally {
|
||||
StoreInstalls.deleteTree(stage)
|
||||
}
|
||||
swap(addons.map { File(fresh, it.name) to it.name }, addOns, File(stage, "old").apply { mkdirs() })
|
||||
} finally {
|
||||
StoreInstalls.deleteTree(stage)
|
||||
imports++
|
||||
return addons.map { it.name }
|
||||
}
|
||||
runCatching { keepOrigins(target, addons.map { it.name }, origin) }
|
||||
imports++
|
||||
return addons.map { it.name }
|
||||
}
|
||||
|
||||
internal fun addons(files: List<String>): List<Addon> {
|
||||
|
||||
@@ -238,20 +238,6 @@ object ComponentsManager {
|
||||
saveState(context, state)
|
||||
}
|
||||
|
||||
private val UNPINNED_FEX = Regex("""(?i)FEXCore-\d+(?:\.\d+)*-d2rfix\d+-linux\.wcp""")
|
||||
|
||||
fun migrateBattleNetFex(context: Context) = synchronized(lock) {
|
||||
val marker = File(dataDir(context), ".battlenet-fex-unpinned")
|
||||
if (marker.isFile) return@synchronized
|
||||
migratePlugin(context)
|
||||
val scope = com.droiddeck.launcher.runtime.BattleNet.APP_ID.toString()
|
||||
if (gameComponents(context, scope)["fex"]?.let(UNPINNED_FEX::matches) == true) {
|
||||
setGameComponent(context, scope, "fex", null)
|
||||
Log.i(TAG, "Battle.net follows the selected FEX again")
|
||||
}
|
||||
marker.writeText("1\n")
|
||||
}
|
||||
|
||||
private fun migratePlugin(context: Context) {
|
||||
val marker = File(dataDir(context), ".plugin-imported")
|
||||
if (marker.isFile) return
|
||||
@@ -501,7 +487,6 @@ object ComponentsManager {
|
||||
|
||||
fun snapshotAll(context: Context) = synchronized(lock) {
|
||||
migratePlugin(context)
|
||||
runCatching { migrateBattleNetFex(context) }.onFailure { Log.w(TAG, "Battle.net FEX selection", it) }
|
||||
val state = loadState(context)
|
||||
for (p in protons(context)) for (comp in COMPONENTS) {
|
||||
runCatching { ensureOriginal(context, p, comp, state) }.onFailure { Log.w(TAG, "original $comp of ${p.name}", it) }
|
||||
@@ -512,7 +497,6 @@ object ComponentsManager {
|
||||
|
||||
fun snapshot(context: Context): Snapshot = synchronized(lock) {
|
||||
migratePlugin(context)
|
||||
runCatching { migrateBattleNetFex(context) }.onFailure { Log.w(TAG, "Battle.net FEX selection", it) }
|
||||
val state = loadState(context)
|
||||
val reapplied = HashMap<String, Long>()
|
||||
runCatching {
|
||||
|
||||
@@ -12,9 +12,6 @@ object SessionDisplay {
|
||||
const val FOLLOW_SCALE_MAX = 8f
|
||||
private const val FOLLOW_SCALED_PREFIX = "follow/"
|
||||
|
||||
const val LINK_LANDSCAPE = "link/landscape"
|
||||
const val LINK_PORTRAIT = "link/portrait"
|
||||
|
||||
const val DEFAULT_RESOLUTION = "720p"
|
||||
private val PRESET_HEIGHTS = listOf(720, 900, 1080)
|
||||
|
||||
@@ -38,23 +35,6 @@ object SessionDisplay {
|
||||
else -> null
|
||||
}
|
||||
|
||||
fun isLink(choice: String): Boolean = choice == LINK_LANDSCAPE || choice == LINK_PORTRAIT
|
||||
|
||||
fun orientCustom(choice: String, portrait: Boolean): String {
|
||||
val parts = choice.split('x').map { it.toIntOrNull() }
|
||||
if (parts.size != 2 || parts.any { it == null || it <= 0 }) return choice
|
||||
val width = parts[0]!!
|
||||
val height = parts[1]!!
|
||||
return if ((portrait && width > height) || (!portrait && height > width)) "${height}x$width" else choice
|
||||
}
|
||||
|
||||
fun effectiveChoice(landscape: String, portrait: String, forPortrait: Boolean): String {
|
||||
val own = if (forPortrait) portrait else landscape
|
||||
if (!isLink(own)) return own
|
||||
val other = if (forPortrait) landscape else portrait
|
||||
return if (isLink(other)) DEFAULT_RESOLUTION else orientCustom(other, forPortrait)
|
||||
}
|
||||
|
||||
fun screenSize(panel: Pair<Int, Int>): Pair<Int, Int> =
|
||||
(maxOf(panel.first, panel.second) and 1.inv()) to (minOf(panel.first, panel.second) and 1.inv())
|
||||
|
||||
@@ -89,12 +69,8 @@ object SessionDisplay {
|
||||
|
||||
const val UNFOLDED_MIN_DP = 600
|
||||
|
||||
fun unfoldedGameHeight(width: Int, height: Int, tabRow: Int = 0, aspect: Float = 0f): Int {
|
||||
val row = tabRow.coerceAtLeast(0)
|
||||
val cap = (height * UNFOLDED_MAX_GAME_SHARE).toInt()
|
||||
if (aspect > 0f && aspect < 16f / 9f) return minOf((width / aspect).toInt(), cap - row).coerceAtLeast(0) and 1.inv()
|
||||
return (minOf(width * 9 / 16, cap) - row).coerceAtLeast(0) and 1.inv()
|
||||
}
|
||||
fun unfoldedGameHeight(width: Int, height: Int, tabRow: Int = 0): Int =
|
||||
(minOf(width * 9 / 16, (height * UNFOLDED_MAX_GAME_SHARE).toInt()) - tabRow.coerceAtLeast(0)).coerceAtLeast(0) and 1.inv()
|
||||
|
||||
fun unfoldedControlsWanted(
|
||||
enabled: Boolean,
|
||||
|
||||
@@ -287,7 +287,6 @@ object SessionFiles {
|
||||
File(root, "usr/share/vulkan/implicit_layer.d/droiddeck_vram_cap.json").delete()
|
||||
LegacyNames.migrateRootfs(root)
|
||||
ComponentsManager.migrateLaunchDir(context)
|
||||
runCatching { ComponentsManager.migrateBattleNetFex(context) }.onFailure { Log.w(TAG, "Battle.net FEX selection", it) }
|
||||
EsyncPacks.stageBundled(context, root)
|
||||
val directAudio = arrayOf(
|
||||
"aarch64-unix/winedirectaudio.so",
|
||||
|
||||
@@ -85,12 +85,6 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("launcherFullscreen", on).apply()
|
||||
}
|
||||
|
||||
fun controllerHaptics(context: Context): Boolean = prefs(context).getBoolean("controllerHaptics", true)
|
||||
|
||||
fun setControllerHaptics(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("controllerHaptics", on).apply()
|
||||
}
|
||||
|
||||
fun blackFrameInsertion(context: Context): Boolean = prefs(context).getBoolean("blackFrameInsertion", false)
|
||||
|
||||
fun setBlackFrameInsertion(context: Context, on: Boolean) {
|
||||
@@ -425,18 +419,6 @@ object SessionPrefs {
|
||||
e.remove("gameStoresEnabled").remove("soundtracksEnabled").remove("agentTab").putInt("navTabLayout", version).apply()
|
||||
}
|
||||
|
||||
fun drawerPageOrder(context: Context): List<String> = idList(prefs(context).getString("drawerPageOrder", null))
|
||||
|
||||
fun setDrawerPageOrder(context: Context, order: List<String>) {
|
||||
prefs(context).edit().putString("drawerPageOrder", order.joinToString(",")).apply()
|
||||
}
|
||||
|
||||
fun drawerPageHidden(context: Context): Set<String> = idList(prefs(context).getString("drawerPageHidden", null)).toSet()
|
||||
|
||||
fun setDrawerPageHidden(context: Context, keys: Set<String>) {
|
||||
prefs(context).edit().putString("drawerPageHidden", keys.joinToString(",")).apply()
|
||||
}
|
||||
|
||||
fun setNavTabHidden(context: Context, keys: Set<String>) {
|
||||
prefs(context).edit().putString("navTabHidden", keys.joinToString(",")).apply()
|
||||
}
|
||||
@@ -614,12 +596,6 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("backHold", on).apply()
|
||||
}
|
||||
|
||||
fun dockedMenuController(context: Context): Boolean = prefs(context).getBoolean("dockedMenuController", false)
|
||||
|
||||
fun setDockedMenuController(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("dockedMenuController", on).apply()
|
||||
}
|
||||
|
||||
fun backActionsInverted(context: Context): Boolean = prefs(context).getBoolean("backActionsInverted", false)
|
||||
|
||||
fun setBackActionsInverted(context: Context, inverted: Boolean) {
|
||||
@@ -1320,31 +1296,14 @@ object SessionPrefs {
|
||||
|
||||
private fun resolutionCap(context: Context, mode: String): Int = prefs(context).getInt("resolutionCap.$mode", 720)
|
||||
|
||||
fun resolutionChosen(context: Context, mode: String, portrait: Boolean = false): Boolean =
|
||||
fun resolutionChosen(context: Context, mode: String): Boolean =
|
||||
prefs(context).contains("displayResolution.$mode") ||
|
||||
prefs(context).contains("resolutionCap.$mode") || customResolution(context, mode) != null ||
|
||||
(portrait && prefs(context).contains("displayResolution.portrait.$mode"))
|
||||
prefs(context).contains("resolutionCap.$mode") || customResolution(context, mode) != null
|
||||
|
||||
fun resolutionChoice(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean = false): String =
|
||||
SessionDisplay.effectiveChoice(
|
||||
resolutionStored(context, mode, panel, false), resolutionStored(context, mode, panel, true), portrait)
|
||||
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
fun parseOrientedResolution(text: String): Pair<Int, Int>? =
|
||||
parseResolution(text) ?: text.trim().split('x', 'X', '×', '*').takeIf { it.size == 2 }
|
||||
?.let { parseResolution("${it[1]}x${it[0]}") }?.let { it.second to it.first }
|
||||
|
||||
private fun landscapeResolutionStored(context: Context, mode: String, panel: Pair<Int, Int>): String {
|
||||
fun resolutionChoice(context: Context, mode: String, panel: Pair<Int, Int>): String {
|
||||
val saved = prefs(context)
|
||||
saved.getString("displayResolution.$mode", null)?.let { value ->
|
||||
if (value == SessionDisplay.MATCH_SCREEN || value == SessionDisplay.LINK_PORTRAIT || SessionDisplay.isFollow(value) ||
|
||||
if (value == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(value) ||
|
||||
SessionDisplay.presetHeight(value) != null) return value
|
||||
parseResolution(value)?.let { return "${it.first}x${it.second}" }
|
||||
}
|
||||
@@ -1356,22 +1315,13 @@ object SessionPrefs {
|
||||
else "${legacy.first}x${legacy.second}"
|
||||
}
|
||||
|
||||
fun setResolutionChoice(context: Context, mode: String, choice: String, portrait: Boolean = false) {
|
||||
val link = if (portrait) SessionDisplay.LINK_LANDSCAPE else SessionDisplay.LINK_PORTRAIT
|
||||
val value = if (choice == link || choice == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(choice) ||
|
||||
fun setResolutionChoice(context: Context, mode: String, choice: String) {
|
||||
val value = if (choice == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(choice) ||
|
||||
SessionDisplay.presetHeight(choice) != null) choice else {
|
||||
val size = requireNotNull(if (portrait) parseOrientedResolution(choice) else parseResolution(choice)) { "Invalid resolution" }
|
||||
val size = requireNotNull(parseResolution(choice)) { "Invalid resolution" }
|
||||
"${size.first}x${size.second}"
|
||||
}
|
||||
val panel = SessionDisplay.panelSize(context)
|
||||
val landscapeStored = resolutionStored(context, mode, panel, false)
|
||||
val portraitStored = resolutionStored(context, mode, panel, true)
|
||||
val edit = prefs(context).edit()
|
||||
if (value == link && SessionDisplay.isLink(if (portrait) landscapeStored else portraitStored)) {
|
||||
val concrete = SessionDisplay.effectiveChoice(landscapeStored, portraitStored, !portrait)
|
||||
edit.putString(if (portrait) "displayResolution.$mode" else "displayResolution.portrait.$mode", concrete)
|
||||
}
|
||||
edit.putString(if (portrait) "displayResolution.portrait.$mode" else "displayResolution.$mode", value).apply()
|
||||
prefs(context).edit().putString("displayResolution.$mode", value).apply()
|
||||
}
|
||||
|
||||
fun fexPreset(context: Context): String = prefs(context).getString("fexPreset", DEFAULT_FEX_PRESET) ?: DEFAULT_FEX_PRESET
|
||||
@@ -2010,7 +1960,7 @@ object SessionPrefs {
|
||||
|
||||
fun displayMode(context: Context, mode: String, program: String?): String =
|
||||
if (mode == SessionService.MODE_RUN && com.droiddeck.launcher.runtime.UserApps.launches(program) &&
|
||||
(resolutionChosen(context, SessionService.MODE_DESKTOP) || resolutionChosen(context, SessionService.MODE_DESKTOP, true))) SessionService.MODE_DESKTOP
|
||||
resolutionChosen(context, SessionService.MODE_DESKTOP)) SessionService.MODE_DESKTOP
|
||||
else prefMode(mode)
|
||||
|
||||
fun pipAutoEnter(context: Context): Boolean = prefs(context).getBoolean("pipAutoEnter", true)
|
||||
|
||||
@@ -589,10 +589,7 @@ class SessionService : Service() {
|
||||
|
||||
val sessionDir = openSessionFolder()
|
||||
try {
|
||||
SessionEvents.step("game-environment") {
|
||||
com.droiddeck.launcher.runtime.BattleNet.ensureDefaults(this, SessionState.program)
|
||||
GameEnvironmentStore.publish(this)
|
||||
}
|
||||
SessionEvents.step("game-environment") { GameEnvironmentStore.publish(this) }
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "could not publish the game environment", e)
|
||||
failSession(gen, "GAME_ENVIRONMENT_FAILED", getString(R.string.session_game_environment_failed), -1)
|
||||
@@ -1954,6 +1951,11 @@ class SessionService : Service() {
|
||||
}
|
||||
return
|
||||
}
|
||||
if (path == com.droiddeck.launcher.runtime.BattleNet.FEX_REQUEST) {
|
||||
File(dir, path).delete()
|
||||
com.droiddeck.launcher.runtime.BattleNet.answerFexRequest(this@SessionService, dir)
|
||||
return
|
||||
}
|
||||
if (path != null && path.startsWith("desktop-import-") && path.endsWith(".request")) {
|
||||
val request = File(dir, path)
|
||||
val text = runCatching { request.readText() }.getOrNull() ?: return
|
||||
|
||||
@@ -133,7 +133,6 @@ object SessionState {
|
||||
@Volatile var padBridge: com.droiddeck.launcher.input.PadBridge? = null
|
||||
|
||||
@Volatile var secondScreenMode = com.droiddeck.launcher.input.SecondScreenMode.NONE
|
||||
@Volatile var bottomMenu = false
|
||||
@Volatile var secondScreenDisplay = -1
|
||||
@Volatile var secondScreenAutoOpened = false
|
||||
@Volatile var secondScreenProvisional = false
|
||||
|
||||
@@ -12,13 +12,13 @@ object SettingsReset {
|
||||
private const val TAG = "SettingsReset"
|
||||
|
||||
internal val SESSION_KEYS = setOf(
|
||||
"orientation", "launcherFullscreen", "controllerHaptics", "animations", "lowStorageWarning", "theme", "runSteamAtStartup", "startupSession", "addedGamesArt",
|
||||
"orientation", "launcherFullscreen", "animations", "lowStorageWarning", "theme", "runSteamAtStartup", "startupSession", "addedGamesArt",
|
||||
"dualScreenMode", "dualScreenSessionMode", "dualScreenLauncher", "dualScreenSessionControls", "androidTextFieldKeyboard",
|
||||
"soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature",
|
||||
"storesInstallLanguage",
|
||||
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "dockedMenuController", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
|
||||
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
|
||||
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
|
||||
"stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
|
||||
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "paceCores",
|
||||
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
|
||||
|
||||
@@ -28,26 +28,20 @@ internal class StoreArchiveUnpacker(
|
||||
private val logName: String,
|
||||
) {
|
||||
var work: File = File("")
|
||||
var limit = Long.MAX_VALUE
|
||||
|
||||
class TooLarge : java.io.IOException()
|
||||
|
||||
fun unpack(archive: File, filename: String, handle: DownloadQueue.JobHandle) =
|
||||
unpack(archive, filename, { done, total -> handle.stageProgress(done, total) }, handle::log)
|
||||
|
||||
fun unpack(archive: File, filename: String, progress: (Long, Long) -> Unit, log: (String) -> Unit) {
|
||||
fun unpack(archive: File, filename: String, handle: DownloadQueue.JobHandle) {
|
||||
when (val kind = ItchArchives.kind(archive, filename)) {
|
||||
"zip" -> unzip(archive, progress, log)
|
||||
"zip" -> unzip(archive, handle)
|
||||
"7z" -> try {
|
||||
sevenZip(archive, progress, log)
|
||||
sevenZip(archive, handle)
|
||||
} catch (e: MemoryLimitException) {
|
||||
log("$label: ${archive.name} needs more memory than the app has, unpacking it in the runtime")
|
||||
unrar(archive, progress, log, kind)
|
||||
handle.log("$label: ${archive.name} needs more memory than the app has, unpacking it in the runtime")
|
||||
unrar(archive, handle, kind)
|
||||
}
|
||||
"rar" -> unrar(archive, progress, log, kind)
|
||||
"rar" -> unrar(archive, handle, kind)
|
||||
"exe" -> copy(archive, File(work, filename.ifBlank { "game.exe" }))
|
||||
"tar" -> untar(archive, null, progress, log)
|
||||
"gz", "bz2", "xz" -> untar(archive, kind, progress, log) ?: single(archive, kind, progress, log)
|
||||
"tar" -> untar(archive, null, handle)
|
||||
"gz", "bz2", "xz" -> untar(archive, kind, handle) ?: single(archive, kind, handle)
|
||||
else -> copy(archive, File(work, filename.ifBlank { "game" }))
|
||||
}
|
||||
}
|
||||
@@ -59,7 +53,7 @@ internal class StoreArchiveUnpacker(
|
||||
return if (path == root || path.startsWith(root + File.separator)) file else null
|
||||
}
|
||||
|
||||
private fun unrar(archive: File, progress: (Long, Long) -> Unit, log: (String) -> Unit, kind: String) {
|
||||
private fun unrar(archive: File, handle: DownloadQueue.JobHandle, kind: String) {
|
||||
if (!LinuxRuntime.isInstalled(app)) throw IllegalStateException(app.getString(unsupported, kind))
|
||||
val binds = if (listOf(app.filesDir, app.cacheDir).any { work.absolutePath.startsWith(it.absolutePath + "/") }) null
|
||||
else listOf(work.absolutePath)
|
||||
@@ -68,28 +62,23 @@ internal class StoreArchiveUnpacker(
|
||||
if (!line.startsWith("proot ")) onLine(line)
|
||||
}
|
||||
var entries = 0L
|
||||
var size = 0L
|
||||
bsdtar(listOf("-tvf", archive.absolutePath)) { line ->
|
||||
entries++
|
||||
size += LISTED_SIZE.find(line)?.groupValues?.get(1)?.toLongOrNull() ?: 0L
|
||||
}
|
||||
if (size > limit) throw TooLarge()
|
||||
bsdtar(listOf("-tf", archive.absolutePath)) { entries++ }
|
||||
var done = 0L
|
||||
val tail = ArrayDeque<String>()
|
||||
val code = bsdtar(listOf("-xvf", archive.absolutePath, "-C", work.absolutePath)) { line ->
|
||||
if (line.startsWith("x ")) progress(++done, entries) else {
|
||||
if (line.startsWith("x ")) handle.stageProgress(++done, entries) else {
|
||||
if (tail.size == 5) tail.removeFirst()
|
||||
tail.addLast(line)
|
||||
}
|
||||
}
|
||||
if (cancelled.get()) return
|
||||
if (code != 0) {
|
||||
log("$label: bsdtar exited $code: ${tail.joinToString(" | ")}")
|
||||
handle.log("$label: bsdtar exited $code: ${tail.joinToString(" | ")}")
|
||||
throw IllegalStateException(app.getString(extractFailed, code))
|
||||
}
|
||||
}
|
||||
|
||||
private fun sevenZip(archive: File, progress: (Long, Long) -> Unit, log: (String) -> Unit) {
|
||||
private fun sevenZip(archive: File, handle: DownloadQueue.JobHandle) {
|
||||
val total = archive.length()
|
||||
var written = 0L
|
||||
val buffer = ByteArray(64 * 1024)
|
||||
@@ -101,7 +90,7 @@ internal class StoreArchiveUnpacker(
|
||||
val entry = seven.nextEntry ?: break
|
||||
val file = target(entry.name)
|
||||
if (file == null) {
|
||||
log("$label: skipped an entry outside the game folder")
|
||||
handle.log("$label: skipped an entry outside the game folder")
|
||||
continue
|
||||
}
|
||||
if (entry.isDirectory) {
|
||||
@@ -116,8 +105,7 @@ internal class StoreArchiveUnpacker(
|
||||
if (read < 0) break
|
||||
out.write(buffer, 0, read)
|
||||
written += read
|
||||
if (written > limit) throw TooLarge()
|
||||
progress(written, total)
|
||||
handle.stageProgress(written, total)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +113,7 @@ internal class StoreArchiveUnpacker(
|
||||
}
|
||||
}
|
||||
|
||||
private fun untar(archive: File, codec: String?, progress: (Long, Long) -> Unit, log: (String) -> Unit): Unit? {
|
||||
private fun untar(archive: File, codec: String?, handle: DownloadQueue.JobHandle): Unit? {
|
||||
val total = archive.length()
|
||||
var written = 0L
|
||||
var entries = 0
|
||||
@@ -146,7 +134,7 @@ internal class StoreArchiveUnpacker(
|
||||
entries++
|
||||
val file = target(entry.name)
|
||||
if (file == null) {
|
||||
log("$label: skipped an entry outside the game folder")
|
||||
handle.log("$label: skipped an entry outside the game folder")
|
||||
continue
|
||||
}
|
||||
if (entry.isDirectory) {
|
||||
@@ -161,8 +149,7 @@ internal class StoreArchiveUnpacker(
|
||||
if (read < 0) break
|
||||
out.write(buffer, 0, read)
|
||||
written += read
|
||||
if (written > limit) throw TooLarge()
|
||||
progress(written, total)
|
||||
handle.stageProgress(written, total)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,7 +163,7 @@ internal class StoreArchiveUnpacker(
|
||||
return null
|
||||
}
|
||||
|
||||
private fun single(archive: File, codec: String, progress: (Long, Long) -> Unit, log: (String) -> Unit) {
|
||||
private fun single(archive: File, codec: String, handle: DownloadQueue.JobHandle) {
|
||||
val name = archive.name.substringBeforeLast('.')
|
||||
val file = target(name.ifBlank { "game" }) ?: throw IllegalStateException("archive")
|
||||
file.parentFile?.mkdirs()
|
||||
@@ -197,8 +184,7 @@ internal class StoreArchiveUnpacker(
|
||||
if (read < 0) break
|
||||
out.write(buffer, 0, read)
|
||||
written += read
|
||||
if (written > limit) throw TooLarge()
|
||||
progress(written, total)
|
||||
handle.stageProgress(written, total)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,7 +196,7 @@ internal class StoreArchiveUnpacker(
|
||||
FileInputStream(source).use { input -> FileOutputStream(target).use { out -> input.copyTo(out, 128 * 1024) } }
|
||||
}
|
||||
|
||||
private fun unzip(archive: File, progress: (Long, Long) -> Unit, log: (String) -> Unit) {
|
||||
private fun unzip(archive: File, handle: DownloadQueue.JobHandle) {
|
||||
val total = archive.length()
|
||||
var written = 0L
|
||||
val buffer = ByteArray(64 * 1024)
|
||||
@@ -219,7 +205,7 @@ internal class StoreArchiveUnpacker(
|
||||
if (cancelled.get()) return
|
||||
val target = target(entry.name)
|
||||
if (target == null) {
|
||||
log("$label: skipped an entry outside the game folder")
|
||||
handle.log("$label: skipped an entry outside the game folder")
|
||||
continue
|
||||
}
|
||||
if (entry.isDirectory) {
|
||||
@@ -235,16 +221,11 @@ internal class StoreArchiveUnpacker(
|
||||
if (read < 0) break
|
||||
out.write(buffer, 0, read)
|
||||
written += read
|
||||
if (written > limit) throw TooLarge()
|
||||
progress(written, total)
|
||||
handle.stageProgress(written, total)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
val LISTED_SIZE = Regex("""^\S+\s+\d+\s+\S+\s+\S+\s+(\d+)\s""")
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,6 @@ internal fun AppDialog(
|
||||
width: Dp? = null, fitContent: Boolean = false,
|
||||
back: (() -> Unit)? = null,
|
||||
scrollable: Boolean = true,
|
||||
fillHeight: Boolean = false,
|
||||
scrollState: androidx.compose.foundation.ScrollState = rememberScrollState(),
|
||||
side: (@Composable () -> Unit)? = null,
|
||||
sideRoom: Dp = 0.dp,
|
||||
@@ -349,7 +348,6 @@ internal fun AppDialog(
|
||||
},
|
||||
)
|
||||
.heightIn(max = (LocalConfiguration.current.screenHeightDp - 24).dp)
|
||||
.then(if (fillHeight) Modifier.fillMaxHeight() else Modifier)
|
||||
.shadow(24.dp, Shape16, ambientColor = Color.Black, spotColor = Color.Black)
|
||||
.clip(Shape16)
|
||||
.background(pal.surfaceVariant.copy(alpha = 0.97f))
|
||||
|
||||
@@ -1,32 +1,28 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.LocalIndication
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.hoverable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
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.layout.widthIn
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridState
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Check
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -38,29 +34,16 @@ import androidx.compose.runtime.produceState
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.snapshotFlow
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.drawWithContent
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.geometry.CornerRadius
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.InputMode
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalInputModeManager
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.runtime.WowAddonCatalog
|
||||
import com.droiddeck.launcher.runtime.WowAddons
|
||||
@@ -79,10 +62,6 @@ private class AddonResults {
|
||||
var more by mutableStateOf(false)
|
||||
}
|
||||
|
||||
private enum class AddonStatus { INSTALL, UPDATE, INSTALLED }
|
||||
|
||||
private const val PAGES_AHEAD = 8
|
||||
|
||||
@Composable
|
||||
internal fun AddonBrowserDialog(targets: List<WowAddons.Target>, initial: WowAddons.Target, onDismiss: () -> Unit) {
|
||||
val context = LocalContext.current.applicationContext
|
||||
@@ -95,19 +74,10 @@ internal fun AddonBrowserDialog(targets: List<WowAddons.Target>, initial: WowAdd
|
||||
var sort by remember { mutableStateOf(WowAddonCatalog.Sort.POPULAR) }
|
||||
val results = remember(text, category, sort, target) { AddonResults() }
|
||||
val installing = remember { mutableStateMapOf<String, Int>() }
|
||||
val installed = remember { mutableStateMapOf<String, Pair<String, String>>() }
|
||||
val installed = remember { mutableStateMapOf<String, Boolean>() }
|
||||
val categories by produceState(emptyList<WowAddonCatalog.Category>()) {
|
||||
value = withContext(Dispatchers.IO) { runCatching { WowAddonCatalog.categories(context) }.getOrDefault(emptyList()) }
|
||||
}
|
||||
val present by produceState(emptyMap<String, String?>(), target.addOns, WowAddons.imports) {
|
||||
value = withContext(Dispatchers.IO) { WowAddons.details(target).mapNotNull { item -> item.wowiId?.let { it to item.version } }.toMap() }
|
||||
}
|
||||
fun status(addon: WowAddonCatalog.Addon): AddonStatus {
|
||||
if (addon.id !in present) return AddonStatus.INSTALL
|
||||
val have = present[addon.id]
|
||||
val latest = installed[installKey(addon, target)]?.takeIf { it.first == addon.summary }?.second ?: addon.summary
|
||||
return if (have == null || latest.isBlank() || WowAddonCatalog.sameVersion(have, latest)) AddonStatus.INSTALLED else AddonStatus.UPDATE
|
||||
}
|
||||
fun load(page: Int) {
|
||||
if (results.loading) return
|
||||
results.loading = true
|
||||
@@ -145,93 +115,48 @@ internal fun AddonBrowserDialog(targets: List<WowAddons.Target>, initial: WowAdd
|
||||
scope.launch {
|
||||
val message = withContext(Dispatchers.IO) { installAddon(context, addon, into) { pct -> scope.launch { if (key in installing) installing[key] = pct } } }
|
||||
installing.remove(key)
|
||||
message.second?.let { installed[key] = addon.summary to it }
|
||||
if (message.second) installed[key] = true
|
||||
Toast.makeText(context, message.first, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
val sourceName = stringResource(R.string.addons_source_wowi)
|
||||
val grid = rememberLazyGridState()
|
||||
LaunchedEffect(results, grid) {
|
||||
snapshotFlow { grid.layoutInfo.visibleItemsInfo.lastOrNull()?.index to grid.layoutInfo.totalItemsCount }.collect { (last, total) ->
|
||||
if (last != null && results.more && results.failed == null && last >= total - PAGES_AHEAD) load(results.page + 1)
|
||||
AppDialog(shown, close, "addonBrowser", wide = true, scrollable = false) {
|
||||
DialogTitleRow(stringResource(R.string.addons_download), close)
|
||||
ModeHeader(sourceName, text, { text = it }, stringResource(R.string.stores_search_catalog, sourceName)) {
|
||||
BrowseChip(stringResource(R.string.addons_source_curse), false) {
|
||||
runCatching { context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(WowAddonCatalog.curseForgeUrl(text))).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
val firstAction = remember(results) { FocusRequester() }
|
||||
val inputMode = LocalInputModeManager.current
|
||||
var searching by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(results, results.items.isNotEmpty()) {
|
||||
if (results.items.isNotEmpty() && !searching && inputMode.inputMode == InputMode.Keyboard) focusSoon { firstAction }
|
||||
}
|
||||
AppDialog(shown, close, "addonBrowser", wide = true, maxWidth = 980.dp, scrollable = false, fillHeight = true) {
|
||||
val sortChip: @Composable () -> Unit = {
|
||||
ChipRow {
|
||||
BrowseDropdown(sortLabel(sort)) { first, done ->
|
||||
WowAddonCatalog.Sort.entries.forEachIndexed { index, option ->
|
||||
MenuItem(sortLabel(option), sort == option, focusRequester = if (index == 0) first else null) { sort = option; done() }
|
||||
}
|
||||
}
|
||||
}
|
||||
val categoryChip: @Composable () -> Unit = {
|
||||
if (categories.isNotEmpty()) BrowseDropdown(category?.name ?: stringResource(R.string.addons_category_all)) { first, done ->
|
||||
MenuItem(stringResource(R.string.addons_category_all), category == null, focusRequester = first) { category = null; done() }
|
||||
categories.forEach { option -> MenuItem(option.name, category?.id == option.id) { category = option; done() } }
|
||||
}
|
||||
}
|
||||
val flavorChip: @Composable () -> Unit = {
|
||||
if (targets.size > 1) BrowseDropdown(target.flavor) { first, done ->
|
||||
targets.forEachIndexed { index, option ->
|
||||
MenuItem(option.flavor, option.addOns == target.addOns, focusRequester = if (index == 0) first else null) { target = option; done() }
|
||||
}
|
||||
}
|
||||
}
|
||||
val search: @Composable (Modifier) -> Unit = { modifier ->
|
||||
AdbTextField(
|
||||
value = text, onValueChange = { text = it }, label = "", keyboardType = KeyboardType.Text, imeAction = ImeAction.Search,
|
||||
placeholder = stringResource(R.string.stores_search_catalog, sourceName), compact = true, showLabel = false, modifier = modifier, onFocusChange = { searching = it },
|
||||
)
|
||||
}
|
||||
val closeButton: @Composable () -> Unit = {
|
||||
SmallIconButton(Icons.Filled.Close, stringResource(R.string.common_close), tint = MaterialTheme.colorScheme.error, onClick = close)
|
||||
}
|
||||
BoxWithConstraints(Modifier.fillMaxWidth()) {
|
||||
if (maxWidth >= 640.dp) Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
search(Modifier.weight(1f))
|
||||
sortChip()
|
||||
categoryChip()
|
||||
flavorChip()
|
||||
closeButton()
|
||||
} else Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
search(Modifier.weight(1f))
|
||||
closeButton()
|
||||
}
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
modifier = Modifier.horizontalScroll(rememberScrollState()),
|
||||
) {
|
||||
sortChip()
|
||||
categoryChip()
|
||||
flavorChip()
|
||||
}
|
||||
}
|
||||
}
|
||||
val thumb = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f)
|
||||
val height = (LocalConfiguration.current.screenHeightDp * 0.62f).dp
|
||||
LazyVerticalGrid(
|
||||
GridCells.Adaptive(400.dp), Modifier.fillMaxWidth().weight(1f).scrollThumb(grid, thumb), state = grid,
|
||||
contentPadding = PaddingValues(end = 8.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
GridCells.Adaptive(libraryTileWidth() + 40.dp), Modifier.fillMaxWidth().height(height),
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp), verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
items(results.items, key = { it.id }) { addon ->
|
||||
val key = installKey(addon, target)
|
||||
AddonRow(addon, status(addon), installing[key], if (addon.id == results.items.firstOrNull()?.id) Modifier.focusRequester(firstAction) else Modifier) { install(addon) }
|
||||
AddonCard(addon, installing[installKey(addon, target)], installed[installKey(addon, target)] == true) { install(addon) }
|
||||
}
|
||||
item(span = { GridItemSpan(maxLineSpan) }) {
|
||||
Column(Modifier.fillMaxWidth().padding(vertical = 8.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
item(key = "tail", span = { GridItemSpan(maxLineSpan) }) {
|
||||
Box(Modifier.fillMaxWidth().padding(vertical = 8.dp), contentAlignment = Alignment.Center) {
|
||||
when {
|
||||
results.loading -> LinearProgressIndicator(Modifier.fillMaxWidth())
|
||||
results.failed != null -> {
|
||||
Text(stringResource(R.string.addons_unreachable, sourceName), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
BrowseChip(stringResource(R.string.stores_dl_retry), false) { load(if (results.items.isEmpty()) 0 else results.page + 1) }
|
||||
}
|
||||
results.failed != null -> BrowseChip(stringResource(R.string.stores_dl_retry), false) { load(if (results.items.isEmpty()) 0 else results.page + 1) }
|
||||
results.more -> BrowseChip(stringResource(R.string.stores_itch_load_more), false) { load(results.page + 1) }
|
||||
results.items.isEmpty() -> Text(stringResource(R.string.addons_none_found), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
}
|
||||
@@ -241,45 +166,29 @@ internal fun AddonBrowserDialog(targets: List<WowAddons.Target>, initial: WowAdd
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AddonRow(addon: WowAddonCatalog.Addon, status: AddonStatus, progress: Int?, action: Modifier, onInstall: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
private fun AddonCard(addon: WowAddonCatalog.Addon, progress: Int?, done: Boolean, onInstall: () -> Unit) {
|
||||
val pal = LocalPalette.current
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
modifier = Modifier.fillMaxWidth().clip(Shape12).background(colors.surface.copy(alpha = 0.6f)).border(1.dp, pal.line, Shape12)
|
||||
.padding(start = 8.dp, end = 8.dp, top = 6.dp, bottom = 6.dp),
|
||||
val src = remember { androidx.compose.foundation.interaction.MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
val shape = androidx.compose.foundation.shape.RoundedCornerShape(10.dp)
|
||||
Column(
|
||||
Modifier.fillMaxWidth().clip(shape).glideBorder(hot, shape, pal.signal, pal.line)
|
||||
.hoverable(src)
|
||||
.clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Button, onClick = onInstall)
|
||||
.controllerConfirm(onClick = onInstall),
|
||||
) {
|
||||
Box(Modifier.size(44.dp).clip(Shape12).background(artBrush(hueOf(addon.name)))) {
|
||||
if (addon.thumb != null) AsyncImage(model = addon.thumb, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.matchParentSize())
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(addon.name, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(
|
||||
listOf(addon.author, addon.summary, formatCount(addon.downloads)).filter { it.isNotEmpty() }.joinToString(" · "),
|
||||
fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
val size = Modifier.widthIn(min = 104.dp).then(action)
|
||||
when {
|
||||
progress != null -> SecondaryButton(stringResource(R.string.store_installing), compact = true, modifier = size, progress = progress / 100f, onClick = onInstall)
|
||||
status == AddonStatus.INSTALLED -> SecondaryButton(stringResource(R.string.stores_installed_chip), enabled = false, compact = true, modifier = size) {}
|
||||
else -> PrimaryButton(stringResource(if (status == AddonStatus.UPDATE) R.string.common_update else R.string.store_install), compact = true, modifier = size, onClick = onInstall)
|
||||
ArtCard(addon.name, addon.thumb, null, null, hot, capsule = false, chip = progress?.let { "$it%" }) {
|
||||
if (done) Icon(Icons.Filled.Check, stringResource(R.string.stores_installed_chip), tint = pal.good, modifier = Modifier.height(11.dp))
|
||||
else Text(stringResource(if (progress != null) R.string.store_installing else R.string.store_install), fontSize = 10.sp, color = pal.signal, maxLines = 1)
|
||||
}
|
||||
Text(
|
||||
listOf(addon.author, formatCount(addon.downloads)).filter { it.isNotEmpty() }.joinToString(" · "),
|
||||
fontSize = 11.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.padding(horizontal = 8.dp, vertical = 6.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun Modifier.scrollThumb(state: LazyGridState, color: Color): Modifier = drawWithContent {
|
||||
drawContent()
|
||||
val info = state.layoutInfo
|
||||
val visible = info.visibleItemsInfo
|
||||
if (visible.isEmpty() || visible.size >= info.totalItemsCount) return@drawWithContent
|
||||
val total = info.totalItemsCount.toFloat()
|
||||
val length = (size.height * visible.size / total).coerceAtLeast(24.dp.toPx())
|
||||
val top = (size.height - length) * (visible.first().index / (total - visible.size).coerceAtLeast(1f)).coerceIn(0f, 1f)
|
||||
val width = 3.dp.toPx()
|
||||
drawRoundRect(color, Offset(size.width - width, top), Size(width, length), CornerRadius(width / 2))
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun sortLabel(sort: WowAddonCatalog.Sort): String = stringResource(
|
||||
when (sort) {
|
||||
@@ -297,18 +206,18 @@ private fun formatCount(count: Long): String = when {
|
||||
else -> count.toString()
|
||||
}
|
||||
|
||||
internal fun installAddon(context: Context, addon: WowAddonCatalog.Addon, target: WowAddons.Target, progress: (Int) -> Unit): Pair<String, String?> {
|
||||
private fun installAddon(context: Context, addon: WowAddonCatalog.Addon, target: WowAddons.Target, progress: (Int) -> Unit): Pair<String, Boolean> {
|
||||
val zip = File(File(context.cacheDir, "wowaddons"), "download-wowi-${addon.id.filter(Char::isLetterOrDigit)}-${java.util.UUID.randomUUID()}.zip")
|
||||
return try {
|
||||
val version = WowAddonCatalog.download(context, addon, zip, progress) ?: addon.summary
|
||||
if (SessionState.running) return context.getString(R.string.main_addons_close_session) to null
|
||||
val names = WowAddons.import(zip, target, WowAddons.Origin(addon.id, version).takeIf { version.isNotBlank() }, context)
|
||||
if (names.isEmpty()) context.getString(R.string.main_addons_none, addon.name) to null
|
||||
else context.resources.getQuantityString(R.plurals.main_addons_imported, names.size, names.size, target.flavor) to version
|
||||
WowAddonCatalog.download(context, addon, zip, progress)
|
||||
if (SessionState.running) return context.getString(R.string.main_addons_close_session) to false
|
||||
val names = WowAddons.import(zip, target)
|
||||
if (names.isEmpty()) context.getString(R.string.main_addons_none, addon.name) to false
|
||||
else context.resources.getQuantityString(R.plurals.main_addons_imported, names.size, names.size, target.flavor) to true
|
||||
} catch (_: WowAddons.TooLarge) {
|
||||
context.getString(R.string.main_addons_too_large, addon.name) to null
|
||||
context.getString(R.string.main_addons_too_large, addon.name) to false
|
||||
} catch (e: Exception) {
|
||||
context.getString(R.string.stores_dl_failed_reason, e.message ?: e.javaClass.simpleName) to null
|
||||
context.getString(R.string.stores_dl_failed_reason, e.message ?: e.javaClass.simpleName) to false
|
||||
} finally {
|
||||
zip.delete()
|
||||
}
|
||||
|
||||
@@ -230,7 +230,6 @@ internal fun BarButton(
|
||||
|
||||
internal val SecondScreenMode.icon: ImageVector get() = when (this) {
|
||||
SecondScreenMode.NONE -> Icons.Outlined.DesktopAccessDisabled
|
||||
SecondScreenMode.MENU -> Icons.Outlined.MoreHoriz
|
||||
SecondScreenMode.KEYBOARD_TRACKPAD -> Icons.Outlined.Keyboard
|
||||
SecondScreenMode.TERMINAL -> Icons.Outlined.Terminal
|
||||
SecondScreenMode.DECK_CONTROLS -> Icons.Outlined.SportsEsports
|
||||
@@ -291,11 +290,17 @@ private fun ScreenPickerMenu(picker: ScreenPicker, open: Boolean, dismiss: () ->
|
||||
leading = { Icon(painterResource(R.drawable.ic_stat_session), contentDescription = null, tint = colors.onBackground, modifier = Modifier.size(18.dp)) },
|
||||
focusRequester = first.takeIf { target == null }, modifier = Modifier.testTag("screen-picker-menu"),
|
||||
) { dismiss(); menu() }
|
||||
Box(Modifier.fillMaxWidth().padding(vertical = 4.dp).height(1.dp).background(pal.line))
|
||||
Text(
|
||||
stringResource(R.string.drawer_second_screen).uppercase(), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp,
|
||||
color = colors.onSurfaceVariant, modifier = Modifier.padding(start = 10.dp, top = 6.dp, bottom = 4.dp),
|
||||
)
|
||||
}
|
||||
picker.modes.forEach { mode ->
|
||||
val current = mode == picker.current
|
||||
MenuItem(
|
||||
stringResource(mode.label), checked = current && !picker.menuShown,
|
||||
detail = if (current && picker.menuShown) stringResource(R.string.screen_picker_last_used) else null,
|
||||
leading = { Icon(mode.icon, contentDescription = null, tint = colors.onBackground, modifier = Modifier.size(18.dp)) },
|
||||
focusRequester = first.takeIf { mode == target }, modifier = Modifier.testTag("screen-picker:${mode.id}"),
|
||||
) { dismiss(); picker.onPick(mode) }
|
||||
|
||||
@@ -1495,26 +1495,22 @@ private fun ChoiceLine(
|
||||
if (progress != null) ProgressBit(progress)
|
||||
}
|
||||
if (!removable) Spacer(Modifier.padding(end = 6.dp).size(44.dp))
|
||||
else DeleteButton(name, onDelete = onDelete)
|
||||
else {
|
||||
val delSrc = remember { MutableInteractionSource() }
|
||||
val delHot = rememberHot(delSrc)
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.padding(end = 6.dp).size(44.dp).clip(ROW_SHAPE)
|
||||
.background(if (delHot) colors.error.copy(alpha = 0.14f) else Color.Transparent)
|
||||
.glideBorder(delHot, ROW_SHAPE, colors.error)
|
||||
.hoverable(delSrc).clickable(role = androidx.compose.ui.semantics.Role.Button, interactionSource = delSrc, indication = null, onClick = onDelete)
|
||||
.controllerConfirm(onClick = onDelete),
|
||||
) { Icon(Icons.Outlined.Delete, contentDescription = stringResource(R.string.common_delete_named, name), tint = if (delHot) colors.error else colors.onSurfaceVariant, modifier = Modifier.size(19.dp)) }
|
||||
}
|
||||
}
|
||||
Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line))
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun DeleteButton(name: String, modifier: Modifier = Modifier, enabled: Boolean = true, onDelete: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val delSrc = remember { MutableInteractionSource() }
|
||||
val delHot = rememberHot(delSrc) && enabled
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = modifier.padding(end = 6.dp).size(44.dp).clip(ROW_SHAPE)
|
||||
.background(if (delHot) colors.error.copy(alpha = 0.14f) else Color.Transparent)
|
||||
.glideBorder(delHot, ROW_SHAPE, colors.error)
|
||||
.hoverable(delSrc).clickable(role = androidx.compose.ui.semantics.Role.Button, interactionSource = delSrc, indication = null, enabled = enabled, onClick = onDelete)
|
||||
.controllerConfirm(enabled = enabled, onClick = onDelete),
|
||||
) { Icon(Icons.Outlined.Delete, contentDescription = stringResource(R.string.common_delete_named, name), tint = if (delHot) colors.error else colors.onSurfaceVariant, modifier = Modifier.size(19.dp)) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun GetLine(
|
||||
name: String, detail: String, progress: Int?, enabled: Boolean,
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.VibrationEffect
|
||||
import android.os.Vibrator
|
||||
import android.os.VibratorManager
|
||||
import android.view.InputDevice
|
||||
import android.view.KeyEvent
|
||||
|
||||
object ControllerHaptics {
|
||||
private val navKeys = setOf(
|
||||
KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_DPAD_DOWN, KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_RIGHT,
|
||||
KeyEvent.KEYCODE_BUTTON_A, KeyEvent.KEYCODE_BUTTON_L1, KeyEvent.KEYCODE_BUTTON_R1,
|
||||
)
|
||||
|
||||
fun onKey(context: Context, event: KeyEvent) {
|
||||
if (event.action != KeyEvent.ACTION_DOWN || event.keyCode !in navKeys) return
|
||||
if (event.keyCode == KeyEvent.KEYCODE_BUTTON_A && event.repeatCount > 0) return
|
||||
val fromController = event.isFromSource(InputDevice.SOURCE_GAMEPAD) ||
|
||||
event.isFromSource(InputDevice.SOURCE_DPAD) || event.isFromSource(InputDevice.SOURCE_JOYSTICK)
|
||||
if (!fromController) return
|
||||
tick(context)
|
||||
}
|
||||
|
||||
fun tick(context: Context) {
|
||||
val vibrator = if (Build.VERSION.SDK_INT >= 31) {
|
||||
context.getSystemService(VibratorManager::class.java)?.defaultVibrator
|
||||
} else {
|
||||
@Suppress("DEPRECATION") context.getSystemService(Context.VIBRATOR_SERVICE) as? Vibrator
|
||||
} ?: return
|
||||
if (!vibrator.hasVibrator()) return
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
vibrator.vibrate(VibrationEffect.createPredefined(VibrationEffect.EFFECT_TICK))
|
||||
} else if (Build.VERSION.SDK_INT >= 26) {
|
||||
vibrator.vibrate(VibrationEffect.createOneShot(10, VibrationEffect.DEFAULT_AMPLITUDE))
|
||||
} else {
|
||||
@Suppress("DEPRECATION") vibrator.vibrate(10)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -477,7 +477,7 @@ private fun UserAppIcon(app: UserApps.App, size: Int) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun UserAppsProgress() {
|
||||
private fun UserAppsProgress() {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val working = UserAppsState.working
|
||||
Column(verticalArrangement = Arrangement.spacedBy(6.dp), modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp)) {
|
||||
@@ -514,9 +514,7 @@ private fun UserAppPage(app: UserApps.App, s: FrontEndState, a: FrontEndActions,
|
||||
Column {
|
||||
Text(app.name, fontSize = if (narrow) 22.sp else 26.sp, fontWeight = FontWeight.Bold, color = colors.onBackground)
|
||||
Text(
|
||||
(app.repo?.let { stringResource(R.string.user_apps_github_version, it, app.version.orEmpty()) }
|
||||
?: app.version?.takeIf { app.feed != null }?.let { stringResource(R.string.user_apps_github_version, stringResource(app.kind.label()), it) }
|
||||
?: stringResource(app.kind.label())) +
|
||||
(app.repo?.let { stringResource(R.string.user_apps_github_version, it, app.version.orEmpty()) } ?: stringResource(app.kind.label())) +
|
||||
(if (app.arch == "x86_64" || app.arch == "i386") " · " + stringResource(R.string.app_fex_x86, app.arch) else ""),
|
||||
fontSize = 14.sp, color = colors.onSurfaceVariant,
|
||||
)
|
||||
@@ -528,7 +526,7 @@ private fun UserAppPage(app: UserApps.App, s: FrontEndState, a: FrontEndActions,
|
||||
PrimaryButton(stringResource(R.string.user_apps_open, app.name), enabled = !s.busy, main = true) { a.onUserApp(app) }
|
||||
BusyChip(s)
|
||||
SecondaryButton(stringResource(R.string.user_apps_edit), enabled = UserAppsState.working == null) { editing = true }
|
||||
if (app.updatable) UpdateButton(app, s)
|
||||
if (app.repo != null) UpdateButton(app, s)
|
||||
RemoveAppButton(app, enabled = !s.busy && !s.sessionRunning && UserAppsState.working == null) {
|
||||
UserAppsState.remove(ctx, app); onSelect("desktop")
|
||||
}
|
||||
|
||||
@@ -174,7 +174,6 @@ class FrontEndState(
|
||||
val launcherOrientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER,
|
||||
val homePage: String = com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM,
|
||||
val launcherFullscreen: Boolean = true,
|
||||
val controllerHaptics: Boolean = true,
|
||||
val downloadSource: String = DownloadSource.MODE_AUTO,
|
||||
val downloadMirror: String = "",
|
||||
val downloadPrefix: String = "",
|
||||
@@ -280,7 +279,6 @@ class FrontEndActions(
|
||||
val onLauncherOrientation: (Int) -> Unit = {},
|
||||
val onHomePage: (String) -> Unit = {},
|
||||
val onLauncherFullscreen: (Boolean) -> Unit = {},
|
||||
val onControllerHaptics: (Boolean) -> Unit = {},
|
||||
val onAnimationsEnabled: (Boolean) -> Unit = {},
|
||||
val onLowStorageWarning: (Boolean) -> Unit = {},
|
||||
val onDualScreenMode: (String) -> Unit = {},
|
||||
|
||||
@@ -516,11 +516,6 @@ internal fun SetupPanel(
|
||||
if (s.launcherFullscreen) stringResource(R.string.setup_fullscreen_on) else stringResource(R.string.setup_fullscreen_off),
|
||||
s.launcherFullscreen,
|
||||
) { a.onLauncherFullscreen(it) }
|
||||
ToggleRow(
|
||||
host, "controller-haptics", stringResource(R.string.setup_controller_haptics),
|
||||
stringResource(R.string.setup_controller_haptics_hint),
|
||||
s.controllerHaptics,
|
||||
) { a.onControllerHaptics(it) }
|
||||
if (s.dualScreenDevice) {
|
||||
val dualModes = listOf(
|
||||
com.droiddeck.launcher.input.DualScreen.MODE_AUTO to stringResource(R.string.setup_dual_screen_auto),
|
||||
|
||||
@@ -42,7 +42,6 @@ import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Favorite
|
||||
import androidx.compose.material.icons.filled.FavoriteBorder
|
||||
import androidx.compose.material.icons.filled.PlayArrow
|
||||
import androidx.compose.material.icons.outlined.Download
|
||||
import androidx.compose.material.icons.outlined.Delete
|
||||
import androidx.compose.material.icons.outlined.Edit
|
||||
import androidx.compose.material.icons.outlined.VideogameAsset
|
||||
@@ -55,7 +54,6 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.key
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.produceState
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -96,11 +94,7 @@ import coil.compose.AsyncImage
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.frontend.GameRemoval
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.runtime.CurseForgeApp
|
||||
import com.droiddeck.launcher.runtime.UserApps
|
||||
import com.droiddeck.launcher.runtime.WowAddonCatalog
|
||||
import com.droiddeck.launcher.runtime.WowAddons
|
||||
import com.droiddeck.launcher.store.UserAppsState
|
||||
import com.droiddeck.launcher.session.GameSaves
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
import com.droiddeck.launcher.stores.CatalogItem
|
||||
@@ -966,14 +960,9 @@ private fun AddonsTab(g: Library.SteamGame, targets: List<WowAddons.Target>, a:
|
||||
var browsing by remember(g.gameId) { mutableStateOf<WowAddons.Target?>(null) }
|
||||
browsing?.let { AddonBrowserDialog(targets, it) { browsing = null } }
|
||||
Column(Modifier.fillMaxWidth().tabPanel(), verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
CurseForgeEntry(a)
|
||||
targets.forEach { target ->
|
||||
val names by produceState(emptyList<WowAddons.Installed>(), target.addOns, WowAddons.imports) {
|
||||
value = withContext(Dispatchers.IO) { WowAddons.details(target) }
|
||||
}
|
||||
val context = LocalContext.current
|
||||
val updates by produceState(emptyMap<String, WowAddonCatalog.Addon>(), names) {
|
||||
value = withContext(Dispatchers.IO) { WowAddonCatalog.updates(context, names, target) }
|
||||
val names by produceState(emptyList<String>(), target.addOns, WowAddons.imports) {
|
||||
value = withContext(Dispatchers.IO) { WowAddons.installed(target) }
|
||||
}
|
||||
if (targets.size > 1) SectionLabel(target.flavor)
|
||||
MenuItem(stringResource(R.string.addons_download), checked = false) { browsing = target }
|
||||
@@ -985,85 +974,17 @@ private fun AddonsTab(g: Library.SteamGame, targets: List<WowAddons.Target>, a:
|
||||
target.addOns.mkdirs()
|
||||
a.onBrowseFiles(target.addOns)
|
||||
}
|
||||
names.forEach { item -> key(target.addOns, item.name) { AddonRow(item, updates[item.name], target, a) } }
|
||||
names.forEach { name -> AddonRow(name, target, a) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CurseForgeEntry(a: FrontEndActions) {
|
||||
val ctx = LocalContext.current
|
||||
val name = stringResource(R.string.addons_source_curse)
|
||||
LaunchedEffect(Unit) { UserAppsState.refresh(ctx) }
|
||||
val app = CurseForgeApp.find(UserAppsState.items)
|
||||
val idle = UserAppsState.working == null
|
||||
if (app == null) {
|
||||
MenuItem(stringResource(R.string.content_install_named, name), checked = false, enabled = idle && !SessionState.running) {
|
||||
UserAppsState.add(ctx, CurseForgeApp.request(), name)
|
||||
}
|
||||
} else {
|
||||
var asking by remember(app.key) { mutableStateOf(false) }
|
||||
var checked by remember { mutableStateOf<String?>(null) }
|
||||
val checkKey = app.key + "@" + app.version
|
||||
LaunchedEffect(checkKey, UserAppsState.checking) {
|
||||
if (UserAppsState.checking == null && checked != checkKey) {
|
||||
checked = checkKey
|
||||
UserAppsState.checkUpdate(ctx, app)
|
||||
}
|
||||
}
|
||||
val update = (UserAppsState.updates[app.key] as? UserApps.UpdateCheck.Available)?.release
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
|
||||
MenuItem(
|
||||
stringResource(R.string.user_apps_open, name), checked = false, enabled = idle,
|
||||
detail = app.version, modifier = Modifier.weight(1f),
|
||||
) { a.onUserApp(app) }
|
||||
DeleteButton(name, enabled = idle && !SessionState.running) { asking = true }
|
||||
}
|
||||
if (update != null) MenuItem(stringResource(R.string.user_apps_update_to, update.tag), checked = false, enabled = idle && !SessionState.running) {
|
||||
UserAppsState.update(ctx, app, update)
|
||||
}
|
||||
(UserAppsState.updates[app.key] as? UserApps.UpdateCheck.Failed)?.let { failed ->
|
||||
MenuItem(stringResource(R.string.user_apps_check_updates), checked = false, enabled = idle && UserAppsState.checking == null, detail = failed.message) {
|
||||
UserAppsState.checkUpdate(ctx, app)
|
||||
}
|
||||
}
|
||||
if (asking) ConfirmDialog(
|
||||
title = stringResource(R.string.flathub_remove_title, name),
|
||||
text = stringResource(R.string.flathub_remove_note),
|
||||
confirm = stringResource(R.string.user_apps_remove),
|
||||
onConfirm = { asking = false; UserAppsState.remove(ctx, app) },
|
||||
onDismiss = { asking = false },
|
||||
)
|
||||
}
|
||||
if (UserAppsState.working == name || (UserAppsState.lastError?.startsWith(name) == true)) UserAppsProgress()
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AddonRow(item: WowAddons.Installed, update: WowAddonCatalog.Addon?, target: WowAddons.Target, a: FrontEndActions) {
|
||||
val name = item.name
|
||||
private fun AddonRow(name: String, target: WowAddons.Target, a: FrontEndActions) {
|
||||
var asking by remember(target.addOns, name) { mutableStateOf(false) }
|
||||
var progress by remember(target.addOns, name) { mutableStateOf<Int?>(null) }
|
||||
val context = LocalContext.current
|
||||
val scope = rememberCoroutineScope()
|
||||
val delete = stringResource(R.string.common_delete)
|
||||
val colors = MaterialTheme.colorScheme
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(start = 16.dp, top = 2.dp, bottom = 2.dp)) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(name, fontSize = 14.sp, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
val detail = listOfNotNull(item.version, update?.let { stringResource(R.string.upd_available) }).joinToString(" · ")
|
||||
if (detail.isNotEmpty()) Text(
|
||||
progress?.let { stringResource(R.string.ctrl_percent, it) } ?: detail, fontSize = 12.sp,
|
||||
color = if (update != null) LocalPalette.current.signal else colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
if (update != null && !SessionState.running) IconAction(Icons.Outlined.Download, stringResource(R.string.common_update), "addon:update:${target.flavor}:$name", enabled = progress == null) {
|
||||
progress = 0
|
||||
scope.launch {
|
||||
val message = withContext(Dispatchers.IO) { installAddon(context, update, target) { pct -> scope.launch { progress = pct } } }
|
||||
progress = null
|
||||
android.widget.Toast.makeText(context, message.first, android.widget.Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
Text(name, fontSize = 14.sp, color = MaterialTheme.colorScheme.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f))
|
||||
if (!SessionState.running) IconAction(Icons.Outlined.Delete, delete, "addon:delete:${target.flavor}:$name", danger = true) { asking = true }
|
||||
}
|
||||
if (asking) ConfirmDialog(
|
||||
|
||||
@@ -278,7 +278,7 @@ private fun InputSettingsContent(onBack: () -> Unit, onChanged: () -> Unit, embe
|
||||
else InputHint(layout.name)
|
||||
InputNavigationRow(stringResource(R.string.input_saved_layouts), stringResource(R.string.input_saved_layouts_hint)) { go(InputPage.LAYOUTS) }
|
||||
if (layout.editable) {
|
||||
if (PadKit.forOverlay(context, layout).let { kit -> role != InputRole.PRIMARY || kit == null || layout.elements.any { !kit.artwork(it) } }) {
|
||||
if (role != InputRole.PRIMARY || PadKit.forOverlay(context, layout) == null) {
|
||||
InputColorRow(host, layout.style.tint) { color -> update { it.withLayout(layout.copy(style = layout.style.copy(tint = color))) } }
|
||||
}
|
||||
SliderRow(stringResource(R.string.ctrl_opacity), null, layout.style.opacity, 1..100, step = 1,
|
||||
|
||||
@@ -63,17 +63,10 @@ import com.droiddeck.launcher.session.SessionState
|
||||
private data class SurfaceSnapshot(val elements: List<InputSurfaceElement>, val actions: Map<String, InputAction>,
|
||||
val clicks: Map<String, InputAction>, val scale: Float, val aspect: Float)
|
||||
|
||||
private class GamepadScaler(private val context: android.content.Context, private val width: Int, private val height: Int,
|
||||
private val layout: SavedInputLayout) {
|
||||
private class GamepadScaler(private val context: android.content.Context, private val width: Int, private val height: Int) {
|
||||
private fun generator(scale: Float) = LegacyGamepadLayout(context, width, height, scale = scale)
|
||||
val ids = generator(1f).elements().map { it.id }.toSet()
|
||||
fun stock(scale: Float) = generator(scale).elements()
|
||||
private fun placed(scale: Float) = OnScreenLayout.editorElements(context,
|
||||
layout.copy(elements = stock(scale), aspect = 0f, rotated = emptyList(), scale = scale), width, height)
|
||||
fun rescale(stored: List<InputSurfaceElement>, from: Float, to: Float) =
|
||||
if (PadKit.forOverlay(context, layout) == null || OnScreenLayout.generatedSize(context, layout.copy(elements = stored, scale = from), width, height) != null)
|
||||
generator(to).rescale(stored, generator(from))
|
||||
else rescaleBetween(stored, placed(from), placed(to), stock(from), stock(to))
|
||||
fun rescale(stored: List<InputSurfaceElement>, from: Float, to: Float) = generator(to).rescale(stored, generator(from))
|
||||
fun reset(stored: List<InputSurfaceElement>) = generator(1f).regenerate(stored).associateBy { it.id }.let { placed -> stored.map { placed[it.id] ?: it } }
|
||||
}
|
||||
|
||||
@@ -85,28 +78,21 @@ private class SurfaceDraft(val layout: SavedInputLayout, val preset: SavedInputB
|
||||
var clicks by mutableStateOf(preset.clicks)
|
||||
var selected by mutableStateOf<String?>(null)
|
||||
var toolsExpanded by mutableStateOf(false)
|
||||
var toolsX by mutableFloatStateOf(-1f)
|
||||
var toolsX by mutableFloatStateOf(.02f)
|
||||
var toolsY by mutableFloatStateOf(.02f)
|
||||
var snap by mutableStateOf(snap)
|
||||
var adding by mutableStateOf(false)
|
||||
var properties by mutableStateOf(false)
|
||||
var clickProperties by mutableStateOf(false)
|
||||
var history by mutableStateOf<List<SurfaceSnapshot>>(emptyList())
|
||||
var canvas by mutableStateOf(IntSize.Zero)
|
||||
var layoutScale by mutableFloatStateOf(layout.scale)
|
||||
var aspect by mutableFloatStateOf(layout.aspect)
|
||||
private var scaleBase by mutableStateOf<Triple<List<InputSurfaceElement>, List<InputSurfaceElement>, Float>?>(null)
|
||||
private var scaleValue by mutableIntStateOf(100)
|
||||
private var pieceBase by mutableStateOf<Triple<List<InputSurfaceElement>, List<InputSurfaceElement>, Int>?>(null)
|
||||
private var pieceLayout: List<InputSurfaceElement>? = null
|
||||
private val piece get() = element?.let { e -> (if (elements.any { it.id == e.id }) elements else shown).groupOf(e) }.orEmpty()
|
||||
val scaleRange get() = if (piece.isEmpty()) 80..125 else 50..200
|
||||
private val rescales get() = gamepad?.let { pad -> elements.any { it.id in pad.ids } } == true
|
||||
val scale get() = when {
|
||||
piece.isNotEmpty() -> pieceBase?.takeIf { it.second == piece && pieceLayout == elements }?.third ?: 100
|
||||
scaleBase?.second == elements -> scaleValue
|
||||
rescales -> ((if (canvas.width > 0 && canvas.height > 0 && aspect > 0f && (aspect < 1f) != (canvasAspect < 1f))
|
||||
OnScreenLayout.oriented(layout, canvas.width, canvas.height).scale else layoutScale) * 100).roundToInt()
|
||||
rescales -> (layoutScale * 100).roundToInt()
|
||||
else -> 100
|
||||
}
|
||||
val positioned get() = (if (rescales) gamepad!!.reset(elements) else defaults?.let { elements.withPositionsOf(refit(it, defaultsFrame)) })
|
||||
@@ -116,29 +102,18 @@ private class SurfaceDraft(val layout: SavedInputLayout, val preset: SavedInputB
|
||||
if (from <= 0f || aspect <= 0f || abs(from / aspect - 1f) < .01f) return placed
|
||||
return OnScreenLayout.fit(placed, from, 1f, (aspect * 1000).roundToInt().coerceAtLeast(1), 1000, Rect())
|
||||
}
|
||||
val element get() = elements.firstOrNull { it.id == selected } ?: shown.firstOrNull { it.id == selected }
|
||||
val element get() = elements.firstOrNull { it.id == selected }
|
||||
val dirty get() = elements != layout.elements || actions != preset.elements || clicks != preset.clicks || layoutScale != layout.scale || aspect != layout.aspect
|
||||
fun checkpoint() { history = (history + SurfaceSnapshot(elements, actions, clicks, layoutScale, aspect)).takeLast(40) }
|
||||
fun undo() { history.lastOrNull()?.let { elements = it.elements; actions = it.actions; clicks = it.clicks; layoutScale = it.scale; aspect = it.aspect; history = history.dropLast(1) } }
|
||||
private fun adoptDisplayedFrame(context: android.content.Context): Boolean {
|
||||
if (canvas.width <= 0 || canvas.height <= 0 || shown.isEmpty() || aspect <= 0f || (aspect < 1f) == (canvasAspect < 1f)) return false
|
||||
val open = toolsExpanded
|
||||
beginEdit(shown, canvasAspect, gamepad?.let { GamepadScaler(context, canvas.width, canvas.height, layout) })
|
||||
toolsExpanded = open
|
||||
return true
|
||||
}
|
||||
|
||||
fun beginEdit(displayed: List<InputSurfaceElement>, aspect: Float, scaler: GamepadScaler? = gamepad) {
|
||||
checkpoint()
|
||||
toolsExpanded = false
|
||||
elements = OnScreenLayout.editorFrame(layout.copy(elements = elements), displayed)
|
||||
if (this.aspect > 0f && aspect > 0f && (this.aspect < 1f) != (aspect < 1f)) layoutScale = OnScreenLayout.oriented(layout, (aspect * 1000).roundToInt(), 1000).scale
|
||||
this.aspect = aspect
|
||||
scaler?.let { gamepad = it }
|
||||
}
|
||||
fun scaleAll(context: android.content.Context, percent: Int) {
|
||||
val adopted = adoptDisplayedFrame(context)
|
||||
val base = scaleBase?.takeIf { it.second == elements } ?: Triple(elements, elements, if (rescales) layoutScale else 0f).also { if (!adopted) checkpoint() }
|
||||
fun scaleAll(percent: Int) {
|
||||
val base = scaleBase?.takeIf { it.second == elements } ?: Triple(elements, elements, if (rescales) layoutScale else 0f).also { checkpoint() }
|
||||
val factor = percent / 100f
|
||||
val pad = gamepad
|
||||
elements = if (base.third > 0f && pad != null) {
|
||||
@@ -148,65 +123,7 @@ private class SurfaceDraft(val layout: SavedInputLayout, val preset: SavedInputB
|
||||
} else base.first.scaled(factor)
|
||||
scaleValue = percent; scaleBase = Triple(base.first, elements, base.third)
|
||||
}
|
||||
fun scaleSelected(context: android.content.Context, percent: Int) {
|
||||
val id = selected ?: return
|
||||
val adopted = adoptDisplayedFrame(context)
|
||||
val base = pieceBase?.takeIf { it.second == piece && pieceLayout == elements } ?: run {
|
||||
if (!adopted && canvas.width > 0 && canvas.height > 0 && shown.isNotEmpty()) {
|
||||
val open = toolsExpanded
|
||||
beginEdit(shown, canvasAspect)
|
||||
toolsExpanded = open
|
||||
} else if (!adopted) checkpoint()
|
||||
val start = elements.firstOrNull { it.id == id }?.let { elements.groupOf(it) } ?: return
|
||||
Triple(start, start, 100)
|
||||
}
|
||||
val resized = base.first.resizedAroundCentre(percent / 100f)
|
||||
val byId = resized.associateBy { it.id }
|
||||
elements = elements.map { byId[it.id] ?: it }
|
||||
pieceBase = Triple(base.first, resized, percent)
|
||||
pieceLayout = elements
|
||||
}
|
||||
var shown by mutableStateOf<List<InputSurfaceElement>>(emptyList())
|
||||
private val canvasAspect get() = canvas.width.toFloat() / canvas.height.coerceAtLeast(1)
|
||||
|
||||
private fun stored(id: String): Boolean {
|
||||
if (elements.any { it.id == id }) return true
|
||||
if (shown.none { it.id == id }) return false
|
||||
beginEdit(shown, canvasAspect)
|
||||
return true
|
||||
}
|
||||
|
||||
fun missing(context: android.content.Context): List<InputSurfaceElement> {
|
||||
val pad = gamepad ?: return emptyList()
|
||||
if (canvas.width <= 0 || canvas.height <= 0) return emptyList()
|
||||
val ids = shown.map { it.id }.toSet()
|
||||
return OnScreenLayout.editorElements(context, layout.copy(elements = pad.stock(layoutScale), aspect = 0f, rotated = emptyList(), scale = layoutScale),
|
||||
canvas.width, canvas.height).filter { it.id !in ids }
|
||||
}
|
||||
|
||||
fun restore(context: android.content.Context, element: InputSurfaceElement) {
|
||||
val legacy = gamepad?.stock(layoutScale)?.firstOrNull { it.id == element.id }
|
||||
val generated = OnScreenLayout.generatedSize(context, layout.copy(elements = elements), canvas.width, canvas.height) != null
|
||||
if (generated && legacy != null) { checkpoint(); elements = elements + legacy }
|
||||
else { beginEdit(shown, canvasAspect); elements = elements + element }
|
||||
if (element.id == "builtin:keyboard" && actions[element.id] == null) actions = actions + (element.id to InputAction.Command(InputCommand.KEYBOARD))
|
||||
selected = element.id
|
||||
}
|
||||
|
||||
fun remove(id: String) {
|
||||
if (elements.any { it.id == id }) checkpoint() else stored(id)
|
||||
elements = elements.filterNot { it.id == id }; actions = actions - id; clicks = clicks - id; selected = null
|
||||
}
|
||||
|
||||
fun update(element: InputSurfaceElement) {
|
||||
stored(element.id)
|
||||
elements = elements.map { if (it.id == element.id) element else it }
|
||||
}
|
||||
|
||||
fun resetPositions(context: android.content.Context) {
|
||||
val adopted = adoptDisplayedFrame(context)
|
||||
positioned?.let { if (!adopted) checkpoint(); elements = it; if (rescales) layoutScale = 1f }
|
||||
}
|
||||
fun resetPositions() { positioned?.let { checkpoint(); elements = it; if (rescales) layoutScale = 1f } }
|
||||
fun action(e: InputSurfaceElement) = preset.copy(elements = actions).action(e)
|
||||
fun clickAction(e: InputSurfaceElement) = preset.copy(elements = actions, clicks = clicks).clickAction(e)
|
||||
}
|
||||
@@ -225,7 +142,7 @@ fun InputSurfaceDialog(profile: String, onDismiss: () -> Unit, onChanged: () ->
|
||||
val (display, metrics) = InputLibraries.primaryDisplay(context)
|
||||
val gamepad = savedLayout.elements.takeIf { e -> e.any { it.id.startsWith("legacy:") } }?.let {
|
||||
val (w, h) = OnScreenLayout.generatedSize(context, savedLayout, metrics.widthPixels, metrics.heightPixels) ?: (metrics.widthPixels to metrics.heightPixels)
|
||||
GamepadScaler(display, w, h, savedLayout)
|
||||
GamepadScaler(display, w, h)
|
||||
}
|
||||
val defaults = InputLibraries.defaultPositions(context, library, savedLayout)
|
||||
SurfaceDraft(savedLayout, savedBindings, defaults?.first, defaults?.second ?: 0f, gamepad, ControllerPrefs.snap(context))
|
||||
@@ -249,7 +166,7 @@ fun InputSurfaceDialog(profile: String, onDismiss: () -> Unit, onChanged: () ->
|
||||
InputLibraries.update(context) { latest ->
|
||||
val l = latest.layouts.first { it.id == savedLayout.id }
|
||||
val p = latest.preset(savedBindings.id)
|
||||
latest.withLayout(OnScreenLayout.withFrame(context, l, draft.elements, draft.aspect, draft.layoutScale)).withPreset(p.copy(elements = draft.actions.filterKeys { id -> draft.elements.any { it.id == id } },
|
||||
latest.withLayout(l.copy(elements = draft.elements, aspect = draft.aspect, scale = draft.layoutScale)).withPreset(p.copy(elements = draft.actions.filterKeys { id -> draft.elements.any { it.id == id } },
|
||||
clicks = draft.clicks.filterKeys { id -> draft.elements.any { it.id == id && it.hasClick } }))
|
||||
}
|
||||
}.onSuccess { onChanged(); onDismiss() }.onFailure { failure = it.message ?: context.getString(R.string.input_save_failed) }
|
||||
@@ -308,7 +225,7 @@ fun InputSurfaceDialog(profile: String, onDismiss: () -> Unit, onChanged: () ->
|
||||
else "${library.profile(profile).name} · ${roleLabel(role)}", onSave = { action ->
|
||||
draft.checkpoint()
|
||||
if (draft.clickProperties) draft.clicks = draft.clicks + (element.id to action) else draft.actions = draft.actions + (element.id to action)
|
||||
draft.update(properties.copy(name = properties.name.trim().ifBlank { element.name }))
|
||||
draft.elements = draft.elements.map { if (it.id == element.id) properties.copy(name = properties.name.trim().ifBlank { element.name }) else it }
|
||||
draft.properties = false
|
||||
})
|
||||
}
|
||||
@@ -328,7 +245,7 @@ fun InputSurfaceDialog(profile: String, onDismiss: () -> Unit, onChanged: () ->
|
||||
}
|
||||
}
|
||||
}
|
||||
if (draft.adding) AlertDialog(onDismissRequest = { draft.adding = false }, title = { Text(stringResource(R.string.input_add_element)) }, confirmButton = {}, text = { Column(Modifier.verticalScroll(rememberScrollState())) {
|
||||
if (draft.adding) AlertDialog(onDismissRequest = { draft.adding = false }, title = { Text(stringResource(R.string.input_add_element)) }, confirmButton = {}, text = { Column {
|
||||
for (kind in InputElementKind.entries) PadTextButton(onClick = { draft.checkpoint()
|
||||
val w = if (kind.control.dimensions == 2) .4f else .2f
|
||||
val h = .3f
|
||||
@@ -336,11 +253,6 @@ fun InputSurfaceDialog(profile: String, onDismiss: () -> Unit, onChanged: () ->
|
||||
val element = InputSurfaceElement(kind.control, (1f - w) / 2, (1f - h) / 2, w, h, newInputId(), kind, name)
|
||||
draft.elements = draft.elements + element; draft.selected = element.id
|
||||
draft.adding = false; draft.toolsExpanded = false }) { Text(stringResource(kind.label())) }
|
||||
val missing = remember(draft.elements, draft.canvas) { draft.missing(context) }
|
||||
if (missing.isNotEmpty()) HorizontalDivider()
|
||||
for (element in missing) PadTextButton(onClick = { draft.restore(context, element); draft.adding = false; draft.toolsExpanded = false }) {
|
||||
Text(PadKit.forOverlay(context, savedLayout)?.name(element.control)?.takeIf { element.name == element.control.label } ?: element.name)
|
||||
}
|
||||
} })
|
||||
if (discard) AlertDialog(onDismissRequest = { discard = false }, title = { Text(stringResource(R.string.input_editor_discard)) },
|
||||
confirmButton = { PadTextButton(onClick = onDismiss) { Text(stringResource(R.string.common_ok)) } },
|
||||
@@ -354,13 +266,11 @@ private fun SurfaceCanvas(draft: SurfaceDraft, transparent: Boolean = false) {
|
||||
AndroidView(factory = { InputSurfaceEditorView(it) }, modifier = Modifier.fillMaxSize().testTag("input-layout-canvas"),
|
||||
update = { view ->
|
||||
view.setBackgroundColor(if (transparent) android.graphics.Color.TRANSPARENT else android.graphics.Color.rgb(10, 11, 13))
|
||||
view.style = draft.layout.style.copy(hidden = emptySet()); view.sourceLayout = draft.layout.copy(scale = draft.layoutScale); view.aspect = draft.aspect; view.elements = draft.elements; view.selected = draft.selected; view.snap = draft.snap
|
||||
view.style = draft.layout.style.copy(hidden = emptySet()); view.sourceLayout = draft.layout; view.aspect = draft.aspect; view.elements = draft.elements; view.selected = draft.selected; view.snap = draft.snap
|
||||
view.isEnabled = !draft.properties && !draft.adding
|
||||
view.onSelect = { if (!draft.properties) draft.selected = it }
|
||||
view.onBeginEdit = { e, w, h -> draft.beginEdit(e, w.toFloat() / h, if (draft.hasGamepad) GamepadScaler(view.context, w, h, draft.layout) else null) }
|
||||
view.onResize = { w, h -> draft.canvas = IntSize(w, h) }
|
||||
view.onDisplayed = { draft.shown = it }
|
||||
view.onChange = { changed -> if (!draft.properties) changed.associateBy { it.id }.let { byId -> draft.elements = draft.elements.map { byId[it.id] ?: it } } }
|
||||
view.onBeginEdit = { e, w, h -> draft.beginEdit(e, w.toFloat() / h, if (draft.hasGamepad) GamepadScaler(view.context, w, h) else null) }
|
||||
view.onChange = { e -> if (!draft.properties) draft.elements = draft.elements.map { if (it.id == e.id) e else it } }
|
||||
|
||||
})
|
||||
}
|
||||
@@ -373,8 +283,7 @@ private fun FloatingSurfaceTools(draft: SurfaceDraft, onSave: () -> Unit, onLeav
|
||||
val screenHeight = with(density) { maxHeight.toPx() }
|
||||
val margin = with(density) { 8.dp.toPx() }
|
||||
var panelSize by remember { mutableStateOf(IntSize.Zero) }
|
||||
val x = (if (draft.toolsX < 0f) (screenWidth - panelSize.width) / 2f else draft.toolsX * screenWidth)
|
||||
.coerceIn(margin, (screenWidth - panelSize.width - margin).coerceAtLeast(margin))
|
||||
val x = (draft.toolsX * screenWidth).coerceIn(margin, (screenWidth - panelSize.width - margin).coerceAtLeast(margin))
|
||||
val y = (draft.toolsY * screenHeight).coerceIn(margin, (screenHeight - panelSize.height - margin).coerceAtLeast(margin))
|
||||
val position by rememberUpdatedState(Offset(x, y))
|
||||
val expandedWidth = minOf(420.dp, maxWidth - 16.dp)
|
||||
@@ -423,15 +332,15 @@ private fun SurfaceToolbar(draft: SurfaceDraft, onSave: () -> Unit, onLeave: ()
|
||||
SecondaryButton(stringResource(R.string.common_cancel), compact = true, onClick = onLeave)
|
||||
SecondaryButton(stringResource(R.string.input_editor_add), enabled = draft.elements.size < 64, compact = true) { draft.adding = true }
|
||||
SecondaryButton(stringResource(R.string.input_editor_undo), enabled = draft.history.isNotEmpty(), compact = true) { draft.undo() }
|
||||
if (draft.defaults != null) SecondaryButton(stringResource(R.string.input_reset_positions), enabled = draft.positioned != null, compact = true) { draft.resetPositions(context) }
|
||||
if (draft.defaults != null) SecondaryButton(stringResource(R.string.input_reset_positions), enabled = draft.positioned != null, compact = true) { draft.resetPositions() }
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Checkbox(draft.snap, { draft.snap = it; ControllerPrefs.setSnap(context, it) })
|
||||
Text(stringResource(R.string.ctrl_editor_snap))
|
||||
}
|
||||
PrimaryButton(stringResource(R.string.input_editor_done), compact = true, onClick = onSave)
|
||||
}
|
||||
if (draft.elements.isNotEmpty()) SliderRow(stringResource(R.string.ctrl_size), null, draft.scale, draft.scaleRange, step = 5,
|
||||
format = { "$it%" }, modifier = Modifier.testTag("input-editor-scale")) { if (draft.element != null) draft.scaleSelected(context, it) else draft.scaleAll(context, it) }
|
||||
if (draft.elements.isNotEmpty()) SliderRow(stringResource(R.string.ctrl_size), null, draft.scale, 80..125, step = 5,
|
||||
format = { "$it%" }, modifier = Modifier.testTag("input-editor-scale")) { draft.scaleAll(it) }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@@ -443,7 +352,9 @@ private fun SurfaceSelection(draft: SurfaceDraft) {
|
||||
FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
PrimaryButton(stringResource(R.string.input_properties), compact = true) { draft.clickProperties = false; draft.properties = true }
|
||||
if (e.hasClick) SecondaryButton(stringResource(R.string.input_click_properties), compact = true) { draft.clickProperties = true; draft.properties = true }
|
||||
SecondaryButton(stringResource(R.string.input_remove_element), compact = true) { draft.remove(e.id) }
|
||||
SecondaryButton(stringResource(R.string.input_remove_element), compact = true) {
|
||||
draft.checkpoint(); draft.elements = draft.elements.filterNot { it.id == e.id }; draft.actions = draft.actions - e.id; draft.clicks = draft.clicks - e.id; draft.selected = null
|
||||
}
|
||||
}
|
||||
} ?: Text(stringResource(R.string.input_editor_hint))
|
||||
}
|
||||
|
||||
@@ -5,20 +5,15 @@ import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Rect
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.MotionEvent
|
||||
import android.view.ViewConfiguration
|
||||
import android.view.WindowInsets
|
||||
import android.widget.FrameLayout
|
||||
import com.droiddeck.launcher.input.OnScreenLayout
|
||||
import com.droiddeck.launcher.input.PadKit
|
||||
import com.droiddeck.launcher.input.SavedInputLayout
|
||||
import com.droiddeck.launcher.input.InputSurfaceElement
|
||||
import com.droiddeck.launcher.input.InputSurfaceStyle
|
||||
import com.droiddeck.launcher.input.dpadPiece
|
||||
import com.droiddeck.launcher.input.frame
|
||||
import com.droiddeck.launcher.input.groupOf
|
||||
import com.droiddeck.launcher.input.snapSurfaceElement
|
||||
import kotlin.math.abs
|
||||
|
||||
@@ -44,13 +39,11 @@ internal class InputSurfaceEditorView(context: Context) : FrameLayout(context) {
|
||||
set(value) { field = value; invalidate() }
|
||||
var onSelect: (String?) -> Unit = {}
|
||||
var onBeginEdit: (List<InputSurfaceElement>, Int, Int) -> Unit = { _, _, _ -> }
|
||||
var onChange: (List<InputSurfaceElement>) -> Unit = {}
|
||||
var onResize: (Int, Int) -> Unit = { _, _ -> }
|
||||
var onDisplayed: (List<InputSurfaceElement>) -> Unit = {}
|
||||
var onChange: (InputSurfaceElement) -> Unit = {}
|
||||
private val preview = InputSurfaceView(context)
|
||||
private val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply { color = Color.rgb(26, 159, 255); strokeWidth = 2 * resources.displayMetrics.density }
|
||||
private val radius = 14 * resources.displayMetrics.density
|
||||
private var original: List<InputSurfaceElement> = emptyList()
|
||||
private var original: InputSurfaceElement? = null
|
||||
private var downX = 0f
|
||||
private var downY = 0f
|
||||
private var corner = 0
|
||||
@@ -67,35 +60,16 @@ internal class InputSurfaceEditorView(context: Context) : FrameLayout(context) {
|
||||
preview.updateStyle(style, PadKit.forOverlay(context, sourceLayout))
|
||||
}
|
||||
|
||||
private var safe = Rect()
|
||||
private var frameWidth = 0
|
||||
private var frameHeight = 0
|
||||
|
||||
private fun refreshElements() {
|
||||
visibleElements = sourceLayout?.let { layout ->
|
||||
OnScreenLayout.editorElements(context, layout.copy(elements = elements, aspect = aspect), frameWidth, frameHeight, safe = safe)
|
||||
OnScreenLayout.editorElements(context, layout.copy(elements = elements, aspect = aspect), width, height)
|
||||
} ?: elements
|
||||
preview.updateCustomLayout(visibleElements)
|
||||
onDisplayed(visibleElements)
|
||||
}
|
||||
|
||||
override fun onApplyWindowInsets(insets: WindowInsets): WindowInsets {
|
||||
val fresh = OnScreenLayout.safeInsets(insets, false)
|
||||
if (fresh != safe) { safe = fresh; refreshElements(); invalidate() }
|
||||
return super.onApplyWindowInsets(insets)
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
if (measuredWidth == frameWidth && measuredHeight == frameHeight) return
|
||||
frameWidth = measuredWidth; frameHeight = measuredHeight
|
||||
refreshElements()
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
onResize(w, h)
|
||||
refreshElements()
|
||||
}
|
||||
|
||||
override fun dispatchDraw(canvas: Canvas) {
|
||||
@@ -103,15 +77,13 @@ internal class InputSurfaceEditorView(context: Context) : FrameLayout(context) {
|
||||
paint.style = Paint.Style.STROKE
|
||||
guideX?.let { canvas.drawLine(width * it, 0f, width * it, height.toFloat(), paint) }
|
||||
guideY?.let { canvas.drawLine(0f, height * it, width.toFloat(), height * it, paint) }
|
||||
val e = visibleElements.firstOrNull { it.id == selected }?.let { visibleElements.groupOf(it).frame() } ?: return
|
||||
val e = visibleElements.firstOrNull { it.id == selected } ?: return
|
||||
val l = width * e.x; val t = height * e.y; val r = l + width * e.width; val b = t + height * e.height
|
||||
paint.style = Paint.Style.STROKE; canvas.drawRect(l, t, r, b, paint)
|
||||
paint.style = Paint.Style.FILL
|
||||
for (x in listOf(l, r)) for (y in listOf(t, b)) canvas.drawCircle(x, y, radius / 3, paint)
|
||||
}
|
||||
|
||||
private fun contains(e: InputSurfaceElement, x: Float, y: Float) = x / width in e.x..(e.x + e.width) && y / height in e.y..(e.y + e.height)
|
||||
|
||||
private fun clearGuides() { guideX = null; guideY = null; invalidate() }
|
||||
|
||||
override fun onInterceptTouchEvent(event: MotionEvent) = true
|
||||
@@ -123,7 +95,7 @@ internal class InputSurfaceEditorView(context: Context) : FrameLayout(context) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
clearGuides()
|
||||
downX = event.x; downY = event.y; dragging = false; corner = 0
|
||||
val current = visibleElements.firstOrNull { it.id == selected }?.let { visibleElements.groupOf(it).frame() }
|
||||
val current = visibleElements.firstOrNull { it.id == selected }
|
||||
if (current != null) {
|
||||
val left = width * current.x; val top = height * current.y
|
||||
val right = left + width * current.width; val bottom = top + height * current.height
|
||||
@@ -131,16 +103,13 @@ internal class InputSurfaceEditorView(context: Context) : FrameLayout(context) {
|
||||
val vertical = if (abs(downY - top) < radius) 4 else if (abs(downY - bottom) < radius) 8 else 0
|
||||
if (horizontal != 0 && vertical != 0) corner = horizontal or vertical
|
||||
}
|
||||
val touched = if (corner != 0) visibleElements.firstOrNull { it.id == selected }
|
||||
else visibleElements.asReversed().firstOrNull { contains(it, downX, downY) }
|
||||
?: visibleElements.filter { it.dpadPiece }.takeIf { it.isNotEmpty() && contains(it.frame(), downX, downY) }
|
||||
?.let { pad -> pad.firstOrNull { it.id == selected } ?: pad.first() }
|
||||
original = touched?.let { visibleElements.groupOf(it) }.orEmpty()
|
||||
selected = touched?.id; onSelect(selected)
|
||||
original = if (corner != 0) current else visibleElements.asReversed().firstOrNull {
|
||||
downX / width in it.x..(it.x + it.width) && downY / height in it.y..(it.y + it.height)
|
||||
}
|
||||
selected = original?.id; onSelect(selected)
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
if (original.isEmpty()) return true
|
||||
val e = original.frame()
|
||||
val e = original ?: return true
|
||||
if (!dragging && abs(event.x - downX) + abs(event.y - downY) > ViewConfiguration.get(context).scaledTouchSlop) {
|
||||
dragging = true; onBeginEdit(visibleElements, width, height)
|
||||
}
|
||||
@@ -148,24 +117,20 @@ internal class InputSurfaceEditorView(context: Context) : FrameLayout(context) {
|
||||
val dx = (event.x - downX) / width; val dy = (event.y - downY) / height
|
||||
val next = if (corner == 0) e.copy(x = (e.x + dx).coerceIn(0f, 1f - e.width), y = (e.y + dy).coerceIn(0f, 1f - e.height))
|
||||
else {
|
||||
val minW = (.03f * e.width / original.minOf { it.width }).coerceIn(.03f, e.width.coerceAtLeast(.03f))
|
||||
val minH = (.03f * e.height / original.minOf { it.height }).coerceIn(.03f, e.height.coerceAtLeast(.03f))
|
||||
val left = if (corner and 1 != 0) (e.x + dx).coerceIn(0f, (e.x + e.width - minW).coerceAtLeast(0f)) else e.x
|
||||
val top = if (corner and 4 != 0) (e.y + dy).coerceIn(0f, (e.y + e.height - minH).coerceAtLeast(0f)) else e.y
|
||||
val right = if (corner and 2 != 0) (e.x + e.width + dx).coerceIn((left + minW).coerceAtMost(1f), 1f) else e.x + e.width
|
||||
val bottom = if (corner and 8 != 0) (e.y + e.height + dy).coerceIn((top + minH).coerceAtMost(1f), 1f) else e.y + e.height
|
||||
val left = if (corner and 1 != 0) (e.x + dx).coerceIn(0f, e.x + e.width - .03f) else e.x
|
||||
val top = if (corner and 4 != 0) (e.y + dy).coerceIn(0f, e.y + e.height - .03f) else e.y
|
||||
val right = if (corner and 2 != 0) (e.x + e.width + dx).coerceIn(left + .03f, 1f) else e.x + e.width
|
||||
val bottom = if (corner and 8 != 0) (e.y + e.height + dy).coerceIn(top + .03f, 1f) else e.y + e.height
|
||||
e.copy(x = left, y = top, width = right - left, height = bottom - top).bounded()
|
||||
}
|
||||
val aligned = if (snap) snapSurfaceElement(next, visibleElements.filter { v -> original.none { it.id == v.id } }, 9 * resources.displayMetrics.density / width,
|
||||
val aligned = if (snap) snapSurfaceElement(next, visibleElements.filter { it.id != e.id }, 9 * resources.displayMetrics.density / width,
|
||||
9 * resources.displayMetrics.density / height, corner) else null
|
||||
if (aligned != null && (aligned.x != null && aligned.x != guideX || aligned.y != null && aligned.y != guideY)) performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||
guideX = aligned?.x; guideY = aligned?.y
|
||||
val f = aligned?.element ?: next
|
||||
val sx = f.width / e.width; val sy = f.height / e.height
|
||||
onChange(original.map { it.copy(x = f.x + (it.x - e.x) * sx, y = f.y + (it.y - e.y) * sy, width = it.width * sx, height = it.height * sy) })
|
||||
onChange(aligned?.element ?: next)
|
||||
invalidate()
|
||||
}
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { original = emptyList(); dragging = false; clearGuides() }
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { original = null; dragging = false; clearGuides() }
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ class InputSurfaceView(
|
||||
canvas.addView(when (element.kind) {
|
||||
InputElementKind.STICK -> StickView(context, element, source, element.floating, element.hideWhenIdle && pad != null)
|
||||
InputElementKind.TRACKPAD -> TrackpadView(context, element.control == InputControl.RIGHT_PAD, captioned = element.showLabel,
|
||||
stock = element.id == "legacy:${element.control.id}", source = source)
|
||||
stock = element.id == "legacy:${element.control.id}" && element.name == element.control.label, source = source)
|
||||
InputElementKind.DPAD -> DirectionPad(context, element, source)
|
||||
else -> HoldButton(context, element, source)
|
||||
}.apply { tag = element; contentDescription = element.name; styleElement(this); source?.onStateChanged = { postInvalidate() } })
|
||||
@@ -241,13 +241,8 @@ class InputSurfaceView(
|
||||
}
|
||||
canvas.getChildAt(index) as? HoldButton
|
||||
}
|
||||
val previous = artworkDpad
|
||||
artworkDpad = if (crossed(buttons)) buttons else emptyList()
|
||||
if (artworkDpad != previous) (previous + artworkDpad).forEach { it.invalidate() }
|
||||
}
|
||||
|
||||
private fun crossed(buttons: List<HoldButton>): Boolean {
|
||||
if (buttons.size != DIRECTIONS.size) return false
|
||||
artworkDpad = emptyList()
|
||||
if (buttons.size != DIRECTIONS.size) return
|
||||
val (up, right, down, left) = buttons
|
||||
val centerX = (left.left + right.right) / 2f
|
||||
val centerY = (up.top + down.bottom) / 2f
|
||||
@@ -255,9 +250,9 @@ class InputSurfaceView(
|
||||
kotlin.math.abs((down.left + down.right) / 2f - centerX) > 2f ||
|
||||
kotlin.math.abs((left.top + left.bottom) / 2f - centerY) > 2f ||
|
||||
kotlin.math.abs((right.top + right.bottom) / 2f - centerY) > 2f ||
|
||||
up.bottom >= down.top || left.right >= right.left) return false
|
||||
up.bottom >= down.top || left.right >= right.left) return
|
||||
artworkDpadBounds.set(left.left.toFloat(), up.top.toFloat(), right.right.toFloat(), down.bottom.toFloat())
|
||||
return true
|
||||
artworkDpad = buttons
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
@@ -410,7 +405,11 @@ class InputSurfaceView(
|
||||
art.system(canvas, width.toFloat(), height.toFloat(), PadArt.Shape.ROUND, PadArt.Icon.KEYBOARD, lit)
|
||||
return
|
||||
}
|
||||
if (kit.native(element) && art.button(canvas, width, height, element.control, kit, lit)) return
|
||||
val control = element.control
|
||||
val native = element.id == "legacy:${control.id}" && element.icon == 0 &&
|
||||
(element.name == control.label || element.name == kit.name(control)) &&
|
||||
usesStockShape(control, element.buttonShape)
|
||||
if (native && art.button(canvas, width, height, control, kit, lit)) return
|
||||
}
|
||||
drawSurface(canvas, lit, element.buttonShape, classic)
|
||||
val cx = width / 2f
|
||||
@@ -606,7 +605,7 @@ class InputSurfaceView(
|
||||
val cx = if (touching) originX else centreX()
|
||||
val cy = if (touching) originY else height / 2f
|
||||
val kit = artwork
|
||||
if (kit != null && classic(element)) {
|
||||
if (kit != null && classic(element) && element.name == element.control.label) {
|
||||
val radius = min(width, height) / 2f - 2f * density
|
||||
if (radius > 0f) {
|
||||
art.stick(canvas, cx, cy, radius, kit, knobX, knobY, touching || clicking)
|
||||
@@ -791,6 +790,12 @@ class InputSurfaceView(
|
||||
private fun classic(element: InputSurfaceElement) = (element.id == "legacy:${element.control.id}" || element.id == "builtin:keyboard") &&
|
||||
(element.buttonShape == InputButtonShape.CIRCLE || element.buttonShape == InputButtonShape.PILL)
|
||||
|
||||
private fun usesStockShape(control: InputControl, shape: InputButtonShape): Boolean = when (control) {
|
||||
InputControl.LT, InputControl.LB, InputControl.RB, InputControl.RT -> shape == InputButtonShape.PILL
|
||||
InputControl.L4, InputControl.L5, InputControl.R4, InputControl.R5 -> shape == InputButtonShape.PILL || shape == InputButtonShape.ROUNDED
|
||||
else -> shape == InputButtonShape.CIRCLE
|
||||
}
|
||||
|
||||
private val DIRECTIONS = listOf(InputControl.UP, InputControl.RIGHT, InputControl.DOWN, InputControl.LEFT)
|
||||
|
||||
internal fun shade(tint: Int, alpha: Int, f: Float) =
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.DragHandle
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.focus.focusProperties
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.activity.compose.BackHandler
|
||||
import com.droiddeck.launcher.R
|
||||
|
||||
@Composable
|
||||
internal fun ManageDrawerPages(offeredNow: List<SessionDrawerPage>, modifier: Modifier = Modifier, releaseSignal: Int = 0, onDone: () -> Unit) {
|
||||
val ctx = LocalContext.current
|
||||
val current by rememberUpdatedState(offeredNow)
|
||||
val previewing = DevPreview.drawer != null
|
||||
DisposableEffect(Unit) { onDispose { DrawerPages.heldFrom = null } }
|
||||
DisposableEffect(previewing) { onDispose { if (previewing) DrawerPages.load(ctx) } }
|
||||
val colors = MaterialTheme.colorScheme
|
||||
BackHandler { onDone() }
|
||||
Column(modifier.verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(
|
||||
stringResource(R.string.drawer_manage_pages), fontSize = 15.sp, fontWeight = FontWeight.SemiBold,
|
||||
color = colors.onBackground, modifier = Modifier.weight(1f),
|
||||
)
|
||||
if (!DrawerPages.isDefault()) DrawerOutlineButton(stringResource(R.string.drawer_pages_reset)) { DrawerPages.reset(ctx) }
|
||||
Spacer(Modifier.width(8.dp))
|
||||
DrawerOutlineButton(stringResource(R.string.drawer_pages_done), onClick = onDone)
|
||||
}
|
||||
SortableRows(
|
||||
rows = { current.map { it.name } },
|
||||
commit = { names -> DrawerPages.rearrange(ctx, names.mapNotNull { n -> current.firstOrNull { it.name == n } }) },
|
||||
movable = { true },
|
||||
rowHeight = STORE_ROW, handleWidth = STORE_HANDLE,
|
||||
releaseSignal = releaseSignal,
|
||||
onGrab = { before -> DrawerPages.heldFrom = before?.mapNotNull { n -> current.firstOrNull { it.name == n } } },
|
||||
onActivate = { name ->
|
||||
current.firstOrNull { it.name == name }?.let { DrawerPages.setHidden(ctx, it, it !in DrawerPages.hidden) }
|
||||
},
|
||||
) { name, held, offset, hint, rowModifier, onFocus ->
|
||||
val page = current.first { it.name == name }
|
||||
val shown = page !in DrawerPages.hidden
|
||||
val pal = LocalPalette.current
|
||||
val label = stringResource(page.title)
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
SortRowFrame(held, offset, rowModifier.testTag("drawer-page-row-$name"), hot, src, onFocus) {
|
||||
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(width = STORE_HANDLE, height = STORE_ROW)) {
|
||||
Icon(Icons.Filled.DragHandle, null, tint = if (held) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(20.dp))
|
||||
}
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.weight(1f).alpha(if (shown) 1f else 0.5f),
|
||||
) {
|
||||
Icon(page.icon, null, tint = colors.onSurfaceVariant, modifier = Modifier.size(20.dp))
|
||||
Text(label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
if (hint != null) KeyHint("Y", hint)
|
||||
ToggleSwitch(
|
||||
shown, DrawerPages.hideable(page), label,
|
||||
Modifier.testTag("drawer-page-shown-$name").focusProperties { canFocus = false },
|
||||
) { DrawerPages.setHidden(ctx, page, !it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,8 +221,8 @@ internal fun SideSheet(open: Boolean, onClose: () -> Unit, returnFocus: FocusReq
|
||||
}
|
||||
}
|
||||
|
||||
internal val STORE_ROW = 60.dp
|
||||
internal val STORE_HANDLE = 44.dp
|
||||
private val STORE_ROW = 60.dp
|
||||
private val STORE_HANDLE = 44.dp
|
||||
|
||||
@Composable
|
||||
internal fun ManageStoresSheet() {
|
||||
@@ -302,7 +302,7 @@ private fun StoreSortRow(
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun SortRowFrame(
|
||||
private fun SortRowFrame(
|
||||
held: Boolean, offset: Float, modifier: Modifier, hot: Boolean, src: MutableInteractionSource, onFocus: (Boolean) -> Unit,
|
||||
content: @Composable androidx.compose.foundation.layout.RowScope.() -> Unit,
|
||||
) {
|
||||
|
||||
@@ -56,7 +56,6 @@ class DownloadRow(val key: String, val label: String, val detail: String, val pr
|
||||
class ModeSettings(
|
||||
val mode: String,
|
||||
val resolution: String,
|
||||
val resolutionPortrait: String = com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE,
|
||||
val panelSize: Pair<Int, Int> = 1280 to 720,
|
||||
val hdr: Boolean,
|
||||
val hdrReason: String?,
|
||||
@@ -117,7 +116,6 @@ class ModeSettings(
|
||||
|
||||
class ModeSettingsActions(
|
||||
val onResolution: (String) -> Unit,
|
||||
val onResolutionPortrait: (String) -> Unit = {},
|
||||
val onHdr: (Boolean) -> Unit,
|
||||
val onZeroCopy: (Boolean) -> Unit = {},
|
||||
val onGpuDrivers: () -> Unit = {},
|
||||
@@ -236,20 +234,9 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
val controlsBelow = SessionPrefs.controlsBelowWanted(context, s.mode,
|
||||
if (portraitWindow) shortSide else longSide, if (portraitWindow) longSide else shortSide)
|
||||
val portrait = portraitWindow && !controlsBelow
|
||||
val sessionDisplay = com.droiddeck.launcher.session.SessionDisplay
|
||||
val landscapeChoice = sessionDisplay.effectiveChoice(s.resolution, s.resolutionPortrait, false)
|
||||
val portraitChoice = sessionDisplay.effectiveChoice(s.resolution, s.resolutionPortrait, true)
|
||||
val activeChoice = if (portraitWindow) portraitChoice else landscapeChoice
|
||||
val displaySize = sessionDisplay.resolveChoice(s.panelSize, activeChoice, portrait)
|
||||
val displaySize = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(s.panelSize, s.resolution, portrait)
|
||||
SettingsGroup(stringResource(R.string.display_session)) {
|
||||
ResolutionRow(host, "resolution", stringResource(R.string.display_resolution_landscape), s.resolution, landscapeChoice,
|
||||
com.droiddeck.launcher.session.SessionDisplay.LINK_PORTRAIT,
|
||||
if (sessionDisplay.isLink(s.resolutionPortrait)) landscapeChoice else sessionDisplay.orientCustom(s.resolutionPortrait, false),
|
||||
s.panelSize, a.onResolution, portrait = false)
|
||||
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)
|
||||
ResolutionRow(host, s.resolution, s.panelSize, a.onResolution, portrait = portrait)
|
||||
s.picturePosition?.let { position ->
|
||||
ChoiceRow(host, "picture-position", stringResource(R.string.display_picture_position), null,
|
||||
listOf("top" to stringResource(R.string.display_position_top),
|
||||
@@ -261,7 +248,7 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
}
|
||||
if (s.stretch16x9 != null && (com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(s.panelSize) ||
|
||||
com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(displaySize))) {
|
||||
val canStretch = !com.droiddeck.launcher.session.SessionDisplay.isFollow(activeChoice) &&
|
||||
val canStretch = !com.droiddeck.launcher.session.SessionDisplay.isFollow(s.resolution) &&
|
||||
com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(displaySize)
|
||||
ChoiceRow(host, "game-fit", stringResource(R.string.display_game_fit),
|
||||
stringResource(if (canStretch) R.string.display_game_fit_hint else R.string.display_game_fit_unavailable),
|
||||
@@ -720,10 +707,10 @@ internal fun SgdbKeyDialog(hasKey: Boolean, onSave: (String) -> Unit, onDismiss:
|
||||
|
||||
@OptIn(androidx.compose.foundation.layout.ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
internal fun CustomResolutionDialog(initial: Pair<Int, Int>?, onSave: (Pair<Int, Int>) -> Unit, onDismiss: () -> Unit, portrait: Boolean = false) {
|
||||
internal fun CustomResolutionDialog(initial: Pair<Int, Int>?, onSave: (Pair<Int, Int>) -> Unit, onDismiss: () -> Unit) {
|
||||
var w by remember { mutableStateOf(initial?.first?.toString() ?: "") }
|
||||
var h by remember { mutableStateOf(initial?.second?.toString() ?: "") }
|
||||
val parsed = if (portrait) SessionPrefs.parseOrientedResolution("${w}x$h") else SessionPrefs.parseResolution("${w}x$h")
|
||||
val parsed = SessionPrefs.parseResolution("${w}x$h")
|
||||
com.droiddeck.launcher.ui.GlideAlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
title = { Text(stringResource(R.string.mode_custom_res_title)) },
|
||||
|
||||
@@ -50,7 +50,6 @@ internal class PadArt(context: Context) {
|
||||
InputControl.LB, InputControl.RB, InputControl.LT, InputControl.RT -> shoulder(canvas, w, h, control, kit, pressed)
|
||||
InputControl.L4, InputControl.L5, InputControl.R4, InputControl.R5 -> grip(canvas, w, h, control.label, pressed)
|
||||
InputControl.L3, InputControl.R3 -> small(canvas, w, h, control.label, pressed)
|
||||
InputControl.UP, InputControl.RIGHT, InputControl.DOWN, InputControl.LEFT -> arrow(canvas, w, h, control, pressed)
|
||||
InputControl.SELECT, InputControl.START, InputControl.GUIDE, InputControl.QAM -> {
|
||||
val (shape, icon) = systemLook(kit, control)
|
||||
system(canvas, w, h, shape, icon, pressed)
|
||||
@@ -239,19 +238,6 @@ internal class PadArt(context: Context) {
|
||||
op(bar, Path.Op.UNION)
|
||||
}
|
||||
|
||||
fun arrow(canvas: Canvas, w: Float, h: Float, control: InputControl, pressed: Boolean) {
|
||||
val cx = w / 2f; val cy = h / 2f
|
||||
val s = min(w, h) / 2f - dp(2f)
|
||||
val (dx, dy) = when (control) {
|
||||
InputControl.UP -> 0f to -1f
|
||||
InputControl.RIGHT -> 1f to 0f
|
||||
InputControl.DOWN -> 0f to 1f
|
||||
else -> -1f to 0f
|
||||
}
|
||||
glass(canvas, roundRect(cx - s, cy - s, cx + s, cy + s, s * .32f), pressed)
|
||||
chevron(canvas, cx, cy, dx, dy, s * .3f, if (pressed) ON_ACCENT else INK, s * .14f)
|
||||
}
|
||||
|
||||
/** [held] bits: up 1, right 2, down 4, left 8. */
|
||||
fun dpad(canvas: Canvas, w: Float, h: Float, kit: PadKit, held: Int, chevrons: Boolean = true, ink: Int = INK) {
|
||||
val cx = w / 2f; val cy = h / 2f
|
||||
|
||||
@@ -12,25 +12,20 @@ import com.droiddeck.launcher.session.SessionDisplay
|
||||
|
||||
@Composable
|
||||
fun ResolutionRow(
|
||||
host: MenuHost, id: String, title: String, stored: String, choice: String, link: String, followTarget: String,
|
||||
panel: Pair<Int, Int>, onPick: (String) -> Unit,
|
||||
host: MenuHost, choice: String, panel: Pair<Int, Int>, onPick: (String) -> Unit,
|
||||
chipModifier: Modifier = Modifier,
|
||||
portrait: Boolean = false,
|
||||
) {
|
||||
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 customFollow = !linked && SessionDisplay.isFollow(choice) && choice !in choices
|
||||
val selected = if (linked) link else if (SessionDisplay.isFollow(choice)) choice
|
||||
val customFollow = SessionDisplay.isFollow(choice) && choice !in choices
|
||||
val selected = if (SessionDisplay.isFollow(choice)) choice
|
||||
else if (size == screen) SessionDisplay.MATCH_SCREEN else choice
|
||||
var editCustom by remember { mutableStateOf(false) }
|
||||
var editFollow by remember { mutableStateOf(false) }
|
||||
val followSize = SessionDisplay.resolveChoice(panel, followTarget, portrait)
|
||||
val linkLabel = stringResource(if (link == SessionDisplay.LINK_LANDSCAPE) R.string.display_follow_landscape else R.string.display_follow_portrait,
|
||||
followSize.first, followSize.second)
|
||||
val options = listOf(link to linkLabel) + choices.map { value ->
|
||||
val options = choices.map { value ->
|
||||
val dimensions = SessionDisplay.resolveChoice(panel, value, portrait)
|
||||
value to if (value == SessionDisplay.MATCH_SCREEN) stringResource(R.string.display_match_screen, screen.first, screen.second)
|
||||
else if (value == SessionDisplay.FOLLOW_SCREEN) stringResource(R.string.display_follow_screen)
|
||||
@@ -40,18 +35,18 @@ fun ResolutionRow(
|
||||
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 "…"
|
||||
) + if (customFollow) " (${size.first}×${size.second})" else "") + (custom to if (selected in choices || linked) stringResource(R.string.mode_res_custom)
|
||||
) + if (customFollow) " (${size.first}×${size.second})" else "") + (custom to if (selected in choices) stringResource(R.string.mode_res_custom)
|
||||
else stringResource(R.string.mode_res_custom_value, size.first, size.second))
|
||||
ChoiceRow(host, id, title,
|
||||
ChoiceRow(host, "resolution", stringResource(R.string.display_resolution),
|
||||
stringResource(R.string.common_applies_next_session),
|
||||
options, if (linked || selected in choices) selected else if (customFollow) SessionDisplay.FOLLOW_CUSTOM else custom, chipModifier = chipModifier,
|
||||
options, if (selected in choices) selected else if (customFollow) SessionDisplay.FOLLOW_CUSTOM else custom, chipModifier = chipModifier,
|
||||
onPick = { value ->
|
||||
if (value == custom) editCustom = true
|
||||
else if (value == SessionDisplay.FOLLOW_CUSTOM) editFollow = true
|
||||
else onPick(value) })
|
||||
if (editCustom) CustomResolutionDialog(size,
|
||||
onSave = { value -> editCustom = false; onPick("${value.first}x${value.second}") },
|
||||
onDismiss = { editCustom = false }, portrait = portrait)
|
||||
onDismiss = { editCustom = false })
|
||||
if (editFollow) CustomFollowScaleDialog(SessionDisplay.followScale(choice)?.takeIf { it > 1f },
|
||||
onSave = { value -> editFollow = false; onPick(SessionDisplay.followScaled(value)) },
|
||||
onDismiss = { editFollow = false })
|
||||
|
||||
@@ -305,7 +305,7 @@ class SecondScreenPresentation(
|
||||
(onSteamMenu to onQam).takeIf { SessionState.mode == SessionService.MODE_STEAM }, onSwap,
|
||||
picker = picker?.let { pick -> { pick(SecondScreenMode.DESKTOP) } }), weightParams())
|
||||
}
|
||||
SecondScreenMode.NONE, SecondScreenMode.MENU -> Unit
|
||||
SecondScreenMode.NONE -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
internal enum class SessionDrawerPage(val firstControl: String) {
|
||||
CONTROLLER("input-profile"),
|
||||
GLASSES("glasses-game"),
|
||||
@@ -18,69 +12,14 @@ internal enum class SessionDrawerPage(val firstControl: String) {
|
||||
SESSION("suspend"),
|
||||
}
|
||||
|
||||
internal object DrawerPages {
|
||||
var order by mutableStateOf(SessionDrawerPage.entries.toList())
|
||||
private set
|
||||
var hidden by mutableStateOf(emptySet<SessionDrawerPage>())
|
||||
private set
|
||||
|
||||
/** The order captured when a page row was grabbed in Arrange pages; Back restores it. */
|
||||
var heldFrom: List<SessionDrawerPage>? = null
|
||||
|
||||
fun hideable(page: SessionDrawerPage) = page != SessionDrawerPage.SESSION
|
||||
|
||||
fun load(context: Context) {
|
||||
order = arrange(SessionPrefs.drawerPageOrder(context))
|
||||
hidden = SessionPrefs.drawerPageHidden(context).mapNotNull { name -> SessionDrawerPage.entries.firstOrNull { it.name == name } }
|
||||
.filter(::hideable).toSet()
|
||||
}
|
||||
|
||||
fun arrange(saved: List<String>): List<SessionDrawerPage> {
|
||||
val all = SessionDrawerPage.entries
|
||||
val out = saved.mapNotNull { name -> all.firstOrNull { it.name == name } }.distinct().toMutableList()
|
||||
for (page in all.filterNot { it in out }) {
|
||||
val before = all.subList(0, all.indexOf(page)).lastOrNull { it in out }
|
||||
out.add(if (before == null) 0 else out.indexOf(before) + 1, page)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
fun setHidden(context: Context, page: SessionDrawerPage, hide: Boolean) {
|
||||
hidden = if (hide && hideable(page)) hidden + page else hidden - page
|
||||
if (DevPreview.drawer == null) SessionPrefs.setDrawerPageHidden(context, hidden.map { it.name }.toSet())
|
||||
}
|
||||
|
||||
/** [placed] holds the pages on offer in their new order; pages not on offer keep their slots. */
|
||||
fun rearrange(context: Context, placed: List<SessionDrawerPage>) {
|
||||
if (placed.isEmpty() || !order.containsAll(placed)) return
|
||||
val next = placed.iterator()
|
||||
order = order.map { if (it in placed) next.next() else it }
|
||||
if (DevPreview.drawer == null) SessionPrefs.setDrawerPageOrder(context, order.map { it.name })
|
||||
}
|
||||
|
||||
fun reset(context: Context) {
|
||||
order = SessionDrawerPage.entries.toList()
|
||||
hidden = emptySet()
|
||||
if (DevPreview.drawer != null) return
|
||||
SessionPrefs.setDrawerPageOrder(context, order.map { it.name })
|
||||
SessionPrefs.setDrawerPageHidden(context, emptySet())
|
||||
}
|
||||
|
||||
fun isDefault() = order == SessionDrawerPage.entries.toList() && hidden.isEmpty()
|
||||
}
|
||||
|
||||
internal fun offeredDrawerPages(
|
||||
internal fun sessionDrawerPages(
|
||||
hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown,
|
||||
): List<SessionDrawerPage> =
|
||||
DrawerPages.order.filter {
|
||||
SessionDrawerPage.entries.filter {
|
||||
(hasGlasses || it != SessionDrawerPage.GLASSES) &&
|
||||
(hasAgent || it != SessionDrawerPage.AGENT)
|
||||
}
|
||||
|
||||
internal fun sessionDrawerPages(
|
||||
hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown,
|
||||
): List<SessionDrawerPage> = offeredDrawerPages(hasGlasses, hasAgent).filter { it !in DrawerPages.hidden }
|
||||
|
||||
internal fun List<SessionDrawerPage>.step(current: SessionDrawerPage, direction: Int): SessionDrawerPage {
|
||||
val index = indexOf(current).coerceAtLeast(0)
|
||||
return this[Math.floorMod(index + direction, size)]
|
||||
|
||||
@@ -44,11 +44,9 @@ import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.material.icons.outlined.DesktopWindows
|
||||
import androidx.compose.material.icons.outlined.Layers
|
||||
import androidx.compose.material.icons.outlined.Pause
|
||||
import androidx.compose.material.icons.outlined.PlayArrow
|
||||
import androidx.compose.material.icons.outlined.PictureInPictureAlt
|
||||
import androidx.compose.material.icons.automirrored.outlined.ExitToApp
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material.icons.outlined.Tune
|
||||
import androidx.compose.material.icons.outlined.Speed
|
||||
import androidx.compose.material.icons.outlined.SportsEsports
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -164,7 +162,7 @@ import com.droiddeck.launcher.input.TouchGestureConfig.Companion.MOUSE_BEHAVIOR_
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import java.util.Locale
|
||||
|
||||
internal val SessionDrawerPage.title: Int get() = when (this) {
|
||||
private val SessionDrawerPage.title: Int get() = when (this) {
|
||||
SessionDrawerPage.CONTROLLER -> R.string.drawer_page_controller
|
||||
SessionDrawerPage.GLASSES -> R.string.drawer_page_glasses
|
||||
SessionDrawerPage.DISPLAY -> R.string.drawer_page_display
|
||||
@@ -176,7 +174,7 @@ internal val SessionDrawerPage.title: Int get() = when (this) {
|
||||
SessionDrawerPage.SESSION -> R.string.mode_session
|
||||
}
|
||||
|
||||
internal val SessionDrawerPage.icon get() = when (this) {
|
||||
private val SessionDrawerPage.icon get() = when (this) {
|
||||
SessionDrawerPage.CONTROLLER -> Icons.Outlined.SportsEsports
|
||||
SessionDrawerPage.GLASSES -> GlassesIcon
|
||||
SessionDrawerPage.DISPLAY -> Icons.Outlined.DesktopWindows
|
||||
@@ -231,8 +229,6 @@ class DrawerActions(
|
||||
val onMicEnabled: (Boolean) -> Unit = {},
|
||||
val backHold: Boolean = true,
|
||||
val onBackHold: (Boolean) -> Unit = {},
|
||||
val dockedMenuController: Boolean = false,
|
||||
val onDockedMenuController: (Boolean) -> Unit = {},
|
||||
val backActionsInverted: Boolean,
|
||||
val backDoubleTapMs: Int = 500,
|
||||
val onBackDoubleTapMs: (Int) -> Unit = {},
|
||||
@@ -335,7 +331,6 @@ class DrawerActions(
|
||||
val onSteamVr: (String) -> Unit = {},
|
||||
val onTextureAnisotropy: (Int?) -> Unit = {},
|
||||
val onTextureLodBias: (String?) -> Unit = {},
|
||||
val onSelectMenuMode: () -> Unit = {},
|
||||
val onSecondScreenMode: (SecondScreenMode) -> Unit,
|
||||
val onSecondScreenDisplay: (Int) -> Unit,
|
||||
val onLaunchAndroidApp: (HomeApp.LaunchableApp, Int?) -> Unit,
|
||||
@@ -344,10 +339,6 @@ class DrawerActions(
|
||||
val pipAutoEnter: Boolean = false,
|
||||
val onPip: () -> Unit = {},
|
||||
val onPause: () -> Unit = {},
|
||||
val paused: Boolean = false,
|
||||
val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
|
||||
val onOrientation: (Int) -> Unit = {},
|
||||
val onResume: () -> Unit = {},
|
||||
val onPipAutoEnter: (Boolean) -> Unit = {},
|
||||
val unfoldedControls: Boolean? = null,
|
||||
val adaptiveSticks: Boolean? = null,
|
||||
@@ -401,10 +392,7 @@ class DrawerActions(
|
||||
internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, controllerActive: Boolean, onPageChange: (SessionDrawerPage) -> Unit, a: DrawerActions, docked: Boolean = false,
|
||||
backRequest: Int = 0, onLayerChange: (Boolean) -> Unit = {}) {
|
||||
val pages = sessionDrawerPages(a.glassesPresent)
|
||||
val page = requestedPage.takeIf { it in pages } ?: pages.first()
|
||||
var managing by rememberSaveable { mutableStateOf(false) }
|
||||
var releaseSignal by remember { mutableStateOf(0) }
|
||||
val drawerContext = androidx.compose.ui.platform.LocalContext.current
|
||||
val page = requestedPage.takeIf { it in pages } ?: SessionDrawerPage.CONTROLLER
|
||||
LaunchedEffect(requestedPage, pages) { if (page != requestedPage) onPageChange(page) }
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
@@ -521,24 +509,16 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
.blockTouches()
|
||||
.focusGroup()
|
||||
.controllerBack {
|
||||
when {
|
||||
host.open != null -> host.open = null
|
||||
managing -> DrawerPages.heldFrom?.let { held ->
|
||||
DrawerPages.rearrange(drawerContext, held)
|
||||
releaseSignal++
|
||||
} ?: run { managing = false }
|
||||
else -> a.onClose()
|
||||
}
|
||||
if (host.open != null) host.open = null else a.onClose()
|
||||
}
|
||||
.padding(12.dp),
|
||||
) {
|
||||
val showPicker = a.secondScreenDisplays.isNotEmpty()
|
||||
val roomyHeader = sheetWidth >= if (showPicker) 560.dp else 408.dp
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp), modifier = Modifier.fillMaxWidth()) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
modifier = Modifier.weight(1f).heightIn(min = 44.dp)
|
||||
modifier = Modifier.fillMaxWidth().heightIn(min = 44.dp)
|
||||
.then(if (roomyHeader) Modifier else Modifier.horizontalScroll(rememberScrollState())),
|
||||
) {
|
||||
SteamActionPill(
|
||||
@@ -549,18 +529,18 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
ScreenPicker(
|
||||
secondScreenModes(a.secondScreenNone, com.droiddeck.launcher.session.SessionState.deckPad, a.dashboardAvailable, a.desktopAvailable),
|
||||
a.secondScreenMode, onPick = { host.open = null; a.onSecondScreenMode(it) },
|
||||
onMenu = if (docked) ({ host.open = null; a.onSelectMenuMode() }) else null, menuShown = docked,
|
||||
onMenu = if (docked) ({ host.open = null }) else null, menuShown = docked,
|
||||
),
|
||||
focus.track(page, "screen").testTag("drawer-screen-picker"),
|
||||
)
|
||||
} else if (roomyHeader) Spacer(Modifier.weight(1f))
|
||||
SteamActionPill(
|
||||
stringResource(if (a.paused) R.string.resume_session else R.string.stores_dl_pause),
|
||||
if (a.paused) Icons.Outlined.PlayArrow else Icons.Outlined.Pause, focus.track(page, "pause"),
|
||||
) { host.open = null; if (a.paused) a.onResume() else a.onPause() }
|
||||
stringResource(R.string.stores_dl_pause), Icons.Outlined.Pause, focus.track(page, "pause"),
|
||||
) { host.open = null; a.onPause() }
|
||||
if (a.pipSupported) SteamActionPill(
|
||||
stringResource(R.string.pip_title), Icons.Outlined.PictureInPictureAlt, focus.track(page, "pip"),
|
||||
) { host.open = null; a.onPip() }
|
||||
if (docked) StopSessionButton(modifier = focus.track(page, "stop").onGloballyPositioned { stopCoords = it }) { host.open = null; confirmStop = true }
|
||||
val steamActions = a.steam && a.onSteamMenu != null && a.onQam != null
|
||||
val qamInteraction = remember { MutableInteractionSource() }
|
||||
var qamStartedOnPress by remember { mutableStateOf(false) }
|
||||
@@ -590,8 +570,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
onQamConfirm = { host.open = null; a.onQam?.invoke() },
|
||||
showShortcuts = !docked,
|
||||
)
|
||||
}
|
||||
StopSessionButton(modifier = focus.track(page, "stop").onGloballyPositioned { stopCoords = it }) { host.open = null; confirmStop = true }
|
||||
if (!docked) StopSessionButton(modifier = focus.track(page, "stop").onGloballyPositioned { stopCoords = it }) { host.open = null; confirmStop = true }
|
||||
}
|
||||
a.onAchievements?.let { show ->
|
||||
DrawerAchievementsRow(a.achievementsProgress, Modifier.padding(top = if (short) 6.dp else 10.dp).then(focus.track(page, "achievements"))) {
|
||||
@@ -610,15 +589,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
DrawerBumper("RB", stringResource(R.string.drawer_next_page), modifier = focus.track(page, "next")) {
|
||||
host.open = null; onPageChange(pages.step(page, 1))
|
||||
}
|
||||
SmallIconButton(
|
||||
Icons.Outlined.Tune, stringResource(R.string.drawer_manage_pages), colors.onSurfaceVariant,
|
||||
) { host.open = null; managing = !managing }
|
||||
}
|
||||
if (managing) ManageDrawerPages(
|
||||
offeredDrawerPages(a.glassesPresent),
|
||||
Modifier.weight(1f).fillMaxWidth().padding(top = 8.dp, start = 14.dp, end = 14.dp),
|
||||
releaseSignal,
|
||||
) { managing = false } else {
|
||||
if (page == SessionDrawerPage.GLASSES) SegmentedTabs(
|
||||
glassesPages, glassesTab, modifier = Modifier.fillMaxWidth().padding(top = 8.dp),
|
||||
tabModifier = { key -> focus.track(page, "glasses-tab-$key").testTag("glasses-tab-$key") },
|
||||
@@ -673,11 +644,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
}
|
||||
}
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.setup_orientation)) {
|
||||
ChoiceRow(host, "orientation", stringResource(R.string.setup_session_orientation), null,
|
||||
SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) },
|
||||
a.orientation, chipModifier = focus.track(page, "orientation"), onPick = a.onOrientation)
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.display_image_scaling)) {
|
||||
if (a.steam) SettingsRow(stringResource(R.string.display_integer_scaling), null) {
|
||||
PadTextButton(
|
||||
@@ -794,9 +760,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
SessionPrefs.BACK_DOUBLE_TAP_MS_OPTIONS.map { it to stringResource(R.string.back_tap_ms, it) },
|
||||
a.backDoubleTapMs, chipModifier = focus.track(page, "back-double-tap"), onPick = a.onBackDoubleTapMs)
|
||||
PhysicalShortcutRows(modifierFor = { focus.track(page, "physical-shortcut-${it.name}") })
|
||||
if (a.secondScreenDisplays.isNotEmpty()) ToggleRow(host, "docked-menu-controller", stringResource(R.string.drawer_docked_menu_controller),
|
||||
null, a.dockedMenuController,
|
||||
chipModifier = focus.track(page, "docked-menu-controller"), onChange = a.onDockedMenuController)
|
||||
ToggleRow(host, "corner-tap", stringResource(R.string.drawer_corner_tap),
|
||||
stringResource(R.string.drawer_corner_tap_hint), a.cornerTap,
|
||||
chipModifier = focus.track(page, "corner-tap"), onChange = a.onCornerTap)
|
||||
@@ -963,7 +926,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
}
|
||||
}
|
||||
} }
|
||||
}
|
||||
}
|
||||
StopConfirm(
|
||||
open = confirmStop,
|
||||
@@ -1021,7 +983,7 @@ private fun DrawerActionButton(text: String, icon: androidx.compose.ui.graphics.
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun DrawerOutlineButton(text: String, modifier: Modifier = Modifier, progress: Float? = null, onClick: () -> Unit) {
|
||||
private fun DrawerOutlineButton(text: String, modifier: Modifier = Modifier, progress: Float? = null, onClick: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val source = remember { MutableInteractionSource() }
|
||||
@@ -1043,14 +1005,15 @@ private fun StopSessionButton(modifier: Modifier = Modifier, onClick: () -> Unit
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = src.collectIsFocusedAsState().value || src.collectIsHoveredAsState().value
|
||||
val fill by animateColorAsState(if (hot) colors.error.copy(alpha = 0.18f) else Color.Transparent, Motion.tw(220), label = "dangerFill")
|
||||
val shape = androidx.compose.foundation.shape.CircleShape
|
||||
val shape = RoundedCornerShape(20.dp)
|
||||
val stopDescription = stringResource(R.string.stop_session)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center,
|
||||
modifier = modifier.size(44.dp).semantics { contentDescription = stopDescription }.testTag("drawer-stop")
|
||||
modifier = modifier.heightIn(min = 44.dp).widthIn(min = 44.dp).semantics { contentDescription = stopDescription }.testTag("drawer-stop")
|
||||
.clip(shape).background(fill).glideBorder(hot, shape, colors.error.copy(alpha = 0.9f), colors.error.copy(alpha = 0.55f))
|
||||
.hoverable(src).clickable(role = androidx.compose.ui.semantics.Role.Button, interactionSource = src, indication = LocalIndication.current, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick),
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.padding(horizontal = 12.dp),
|
||||
) {
|
||||
Icon(Icons.Outlined.PowerSettingsNew, contentDescription = null, tint = colors.error, modifier = Modifier.size(18.dp))
|
||||
}
|
||||
|
||||
@@ -108,7 +108,6 @@ internal object SettingsIndex {
|
||||
s(SettingsSection.LAUNCHER, R.string.setup_launcher_orientation, "rotate", "portrait"),
|
||||
s(SettingsSection.LAUNCHER, R.string.setup_session_orientation, "rotate", "portrait"),
|
||||
s(SettingsSection.LAUNCHER, R.string.setup_fullscreen),
|
||||
s(SettingsSection.LAUNCHER, R.string.setup_controller_haptics, "vibration", "rumble"),
|
||||
s(SettingsSection.LAUNCHER, R.string.setup_dual_screen_launcher, "thor", "second screen", "bottom screen"),
|
||||
s(SettingsSection.LAUNCHER, R.string.setup_low_storage_warning),
|
||||
s(SettingsSection.LAUNCHER, R.string.mode_sgdb_key, "artwork", "steamgriddb"),
|
||||
|
||||
@@ -118,8 +118,6 @@ internal fun SortableRows(
|
||||
rowHeight: androidx.compose.ui.unit.Dp,
|
||||
handleWidth: androidx.compose.ui.unit.Dp,
|
||||
onActivate: (String) -> Unit,
|
||||
onGrab: (before: List<String>?) -> Unit = {},
|
||||
releaseSignal: Int = 0,
|
||||
row: @Composable (key: String, held: Boolean, offset: Float, hint: String?, modifier: Modifier, onFocus: (Boolean) -> Unit) -> Unit,
|
||||
) {
|
||||
val pad = LocalInputModeManager.current.inputMode == InputMode.Keyboard
|
||||
@@ -131,9 +129,6 @@ internal fun SortableRows(
|
||||
val rowPx = with(LocalDensity.current) { rowHeight.toPx() }
|
||||
val handlePx = with(LocalDensity.current) { handleWidth.toPx() }
|
||||
val list = rows()
|
||||
val grab by rememberUpdatedState(onGrab)
|
||||
LaunchedEffect(grabbed) { grab(if (grabbed != null) before else null) }
|
||||
LaunchedEffect(releaseSignal) { if (releaseSignal > 0) grabbed = null }
|
||||
Column(
|
||||
Modifier.fillMaxWidth().pointerInput(Unit) {
|
||||
awaitEachGesture {
|
||||
|
||||
@@ -964,7 +964,7 @@
|
||||
<string name="setup_launcher_orientation_auto">اتّباع تدوير الجهاز</string>
|
||||
<string name="setup_orientation_portrait">عمودي</string>
|
||||
<string name="setup_session_orientation">اتجاه الجلسة</string>
|
||||
<string name="setup_session_orientation_hint">يُطبَّق على Steam والألعاب وسطح المكتب ومحرّر وحدة التحكم. تدور الدقّات المُعدّة مسبقًا مع الجلسة، وعندما يتبع أحد الاتجاهين الآخر ينعكس العرض والارتفاع المخصّصان ليتطابقا.</string>
|
||||
<string name="setup_session_orientation_hint">يُطبَّق على Steam والألعاب وسطح المكتب ومحرّر وحدة التحكم. تدور الدقّات المُعدّة مسبقًا مع الجلسة، ويبقى العرض والارتفاع المخصّصان كما أُدخلا.</string>
|
||||
<string name="setup_orientation_auto">أفقي تلقائي</string>
|
||||
<string name="setup_orientation_landscape">أفقي</string>
|
||||
<string name="setup_orientation_reverse">أفقي معكوس</string>
|
||||
@@ -2565,10 +2565,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">شاشة الجلسة</string>
|
||||
<string name="display_zero_copy">العرض بدون نسخ</string>
|
||||
<string name="display_resolution_landscape">دقة الوضع الأفقي</string>
|
||||
<string name="display_resolution_portrait">دقة الوضع العمودي</string>
|
||||
<string name="display_follow_landscape">اتباع الأفقي (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">اتباع العمودي (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">الدقة</string>
|
||||
<string name="display_game_fit">ملاءمة اللعبة لنسبة 16:9</string>
|
||||
<string name="display_game_fit_hint">كيفية ملاءمة ألعاب 16:9 لهذه الشاشة. يُطبَّق في الجلسة التالية.</string>
|
||||
<string name="display_game_fit_unavailable">اختر «مطابقة الشاشة» أو حجمًا مخصَّصًا أضيق من 16:9.</string>
|
||||
|
||||
@@ -982,7 +982,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Seguir la rotación del dispositivo</string>
|
||||
<string name="setup_orientation_portrait">Vertical</string>
|
||||
<string name="setup_session_orientation">Orientación de la sesión</string>
|
||||
<string name="setup_session_orientation_hint">Se aplica a Steam, los juegos, el escritorio y el editor de controles. Los ajustes predefinidos de resolución giran con la sesión; cuando una orientación sigue a la otra, el ancho y el alto personalizados se invierten para coincidir.</string>
|
||||
<string name="setup_session_orientation_hint">Se aplica a Steam, los juegos, el escritorio y el editor de controles. Los ajustes predefinidos de resolución giran con la sesión; el ancho y el alto personalizados se mantienen como se ingresaron.</string>
|
||||
<string name="setup_orientation_auto">Horizontal automática</string>
|
||||
<string name="setup_orientation_landscape">Horizontal</string>
|
||||
<string name="setup_orientation_reverse">Horizontal invertida</string>
|
||||
@@ -2557,10 +2557,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Pantalla de la sesión</string>
|
||||
<string name="display_zero_copy">Presentación sin copia</string>
|
||||
<string name="display_resolution_landscape">Resolución horizontal</string>
|
||||
<string name="display_resolution_portrait">Resolución vertical</string>
|
||||
<string name="display_follow_landscape">Igual que horizontal (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Igual que vertical (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Resolución</string>
|
||||
<string name="display_game_fit">Ajuste de juegos 16:9</string>
|
||||
<string name="display_game_fit_hint">Cómo se ajustan los juegos 16:9 a esta pantalla. Próxima sesión.</string>
|
||||
<string name="display_game_fit_unavailable">Elige Igual a la pantalla o un tamaño personalizado más estrecho que 16:9.</string>
|
||||
|
||||
@@ -952,7 +952,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Следва завъртането на устройството</string>
|
||||
<string name="setup_orientation_portrait">Вертикална</string>
|
||||
<string name="setup_session_orientation">Ориентация на сесията</string>
|
||||
<string name="setup_session_orientation_hint">Прилага се за Steam, игрите, работния плот и редактора на контролера. Предварително зададените резолюции се завъртат със сесията; когато едната ориентация следва другата, персонализираните ширина и височина се разменят, за да съвпадат.</string>
|
||||
<string name="setup_session_orientation_hint">Прилага се за Steam, игрите, работния плот и редактора на контролера. Предварително зададените резолюции се завъртат със сесията; персонализираните ширина и височина остават както са въведени.</string>
|
||||
<string name="setup_orientation_auto">Автоматичен хоризонтален</string>
|
||||
<string name="setup_orientation_landscape">Хоризонтална</string>
|
||||
<string name="setup_orientation_reverse">Обърната хоризонтална</string>
|
||||
@@ -2461,10 +2461,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Екран на сесията</string>
|
||||
<string name="display_zero_copy">Представяне без копиране</string>
|
||||
<string name="display_resolution_landscape">Резолюция в пейзажен режим</string>
|
||||
<string name="display_resolution_portrait">Резолюция в портретен режим</string>
|
||||
<string name="display_follow_landscape">Като пейзажния (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Като портретния (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Разделителна способност</string>
|
||||
<string name="display_game_fit">Напасване на игра 16:9</string>
|
||||
<string name="display_game_fit_hint">Как игрите с 16:9 се напасват на този екран. При следващата сесия.</string>
|
||||
<string name="display_game_fit_unavailable">Избери „Напасване на екрана“ или собствен размер, по-тесен от 16:9.</string>
|
||||
|
||||
@@ -958,7 +958,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Podle otočení zařízení</string>
|
||||
<string name="setup_orientation_portrait">Na výšku</string>
|
||||
<string name="setup_session_orientation">Orientace relace</string>
|
||||
<string name="setup_session_orientation_hint">Platí pro Steam, hry, Plochu a editor ovladače. Předvolby rozlišení se otáčejí s relací; když jedna orientace sleduje druhou, vlastní šířka a výška se prohodí, aby odpovídaly.</string>
|
||||
<string name="setup_session_orientation_hint">Platí pro Steam, hry, Plochu a editor ovladače. Předvolby rozlišení se otáčejí s relací; vlastní šířka a výška zůstávají, jak jsou zadány.</string>
|
||||
<string name="setup_orientation_auto">Automaticky na šířku</string>
|
||||
<string name="setup_orientation_landscape">Na šířku</string>
|
||||
<string name="setup_orientation_reverse">Na šířku obráceně</string>
|
||||
@@ -2513,10 +2513,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Obrazovka relace</string>
|
||||
<string name="display_zero_copy">Zobrazení bez kopírování</string>
|
||||
<string name="display_resolution_landscape">Rozlišení na šířku</string>
|
||||
<string name="display_resolution_portrait">Rozlišení na výšku</string>
|
||||
<string name="display_follow_landscape">Jako na šířku (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Jako na výšku (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Rozlišení</string>
|
||||
<string name="display_game_fit">Přizpůsobení hry 16:9</string>
|
||||
<string name="display_game_fit_hint">Jak se hry s poměrem 16:9 přizpůsobí této obrazovce. Příští relace.</string>
|
||||
<string name="display_game_fit_unavailable">Vyberte Podle obrazovky nebo vlastní velikost užší než 16:9.</string>
|
||||
|
||||
@@ -952,7 +952,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Følg enhedens rotation</string>
|
||||
<string name="setup_orientation_portrait">Stående</string>
|
||||
<string name="setup_session_orientation">Sessionens retning</string>
|
||||
<string name="setup_session_orientation_hint">Gælder Steam, spil, skrivebordet og controllereditoren. Opløsningsforudindstillinger roterer med sessionen; når den ene orientering følger den anden, byttes brugerdefineret bredde og højde, så de passer.</string>
|
||||
<string name="setup_session_orientation_hint">Gælder Steam, spil, skrivebordet og controllereditoren. Opløsningsforudindstillinger roterer med sessionen; brugerdefineret bredde og højde forbliver som angivet.</string>
|
||||
<string name="setup_orientation_auto">Automatisk liggende</string>
|
||||
<string name="setup_orientation_landscape">Liggende</string>
|
||||
<string name="setup_orientation_reverse">Omvendt liggende</string>
|
||||
@@ -2461,10 +2461,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Sessionsskærm</string>
|
||||
<string name="display_zero_copy">Præsentation uden kopiering</string>
|
||||
<string name="display_resolution_landscape">Opløsning i landskab</string>
|
||||
<string name="display_resolution_portrait">Opløsning i portræt</string>
|
||||
<string name="display_follow_landscape">Følg landskab (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Følg portræt (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Opløsning</string>
|
||||
<string name="display_game_fit">16:9-spiltilpasning</string>
|
||||
<string name="display_game_fit_hint">Hvordan 16:9-spil tilpasses denne skærm. Fra næste session.</string>
|
||||
<string name="display_game_fit_unavailable">Vælg Match skærm eller en brugerdefineret størrelse, der er smallere end 16:9.</string>
|
||||
|
||||
@@ -944,7 +944,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Gerätedrehung folgen</string>
|
||||
<string name="setup_orientation_portrait">Hochformat</string>
|
||||
<string name="setup_session_orientation">Sitzungsausrichtung</string>
|
||||
<string name="setup_session_orientation_hint">Gilt für Steam, Spiele, Desktop und den Controller-Editor. Auflösungsvoreinstellungen drehen sich mit der Sitzung; folgt eine Ausrichtung der anderen, werden eigene Breite und Höhe passend vertauscht.</string>
|
||||
<string name="setup_session_orientation_hint">Gilt für Steam, Spiele, Desktop und den Controller-Editor. Auflösungsvoreinstellungen drehen sich mit der Sitzung; eigene Breite und Höhe bleiben wie eingegeben.</string>
|
||||
<string name="setup_orientation_auto">Automatisch Querformat</string>
|
||||
<string name="setup_orientation_landscape">Querformat</string>
|
||||
<string name="setup_orientation_reverse">Umgekehrtes Querformat</string>
|
||||
@@ -2453,10 +2453,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Sitzungsanzeige</string>
|
||||
<string name="display_zero_copy">Kopierfreie Darstellung</string>
|
||||
<string name="display_resolution_landscape">Auflösung im Querformat</string>
|
||||
<string name="display_resolution_portrait">Auflösung im Hochformat</string>
|
||||
<string name="display_follow_landscape">Wie Querformat (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Wie Hochformat (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Auflösung</string>
|
||||
<string name="display_game_fit">16:9-Spielanpassung</string>
|
||||
<string name="display_game_fit_hint">Wie 16:9-Spiele auf dieses Display passen. Ab der nächsten Sitzung.</string>
|
||||
<string name="display_game_fit_unavailable">Wähle „An Bildschirm anpassen“ oder eine eigene Größe schmaler als 16:9.</string>
|
||||
|
||||
@@ -952,7 +952,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Ακολουθεί την περιστροφή της συσκευής</string>
|
||||
<string name="setup_orientation_portrait">Κατακόρυφος</string>
|
||||
<string name="setup_session_orientation">Προσανατολισμός συνεδρίας</string>
|
||||
<string name="setup_session_orientation_hint">Ισχύει για το Steam, τα παιχνίδια, την επιφάνεια εργασίας και τον επεξεργαστή χειριστηρίου. Οι προκαθορισμένες αναλύσεις περιστρέφονται με τη συνεδρία· όταν ένας προσανατολισμός ακολουθεί τον άλλον, το προσαρμοσμένο πλάτος και ύψος αντιστρέφονται ώστε να ταιριάζουν.</string>
|
||||
<string name="setup_session_orientation_hint">Ισχύει για το Steam, τα παιχνίδια, την επιφάνεια εργασίας και τον επεξεργαστή χειριστηρίου. Οι προκαθορισμένες αναλύσεις περιστρέφονται με τη συνεδρία· το προσαρμοσμένο πλάτος και ύψος μένουν όπως καταχωρίστηκαν.</string>
|
||||
<string name="setup_orientation_auto">Αυτόματος οριζόντιος προσανατολισμός</string>
|
||||
<string name="setup_orientation_landscape">Οριζόντιος προσανατολισμός</string>
|
||||
<string name="setup_orientation_reverse">Αντίστροφος οριζόντιος προσανατολισμός</string>
|
||||
@@ -2461,10 +2461,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Οθόνη συνεδρίας</string>
|
||||
<string name="display_zero_copy">Παρουσίαση χωρίς αντιγραφή</string>
|
||||
<string name="display_resolution_landscape">Ανάλυση σε οριζόντιο προσανατολισμό</string>
|
||||
<string name="display_resolution_portrait">Ανάλυση σε κατακόρυφο προσανατολισμό</string>
|
||||
<string name="display_follow_landscape">Ίδια με οριζόντιο (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Ίδια με κατακόρυφο (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Ανάλυση</string>
|
||||
<string name="display_game_fit">Προσαρμογή παιχνιδιού 16:9</string>
|
||||
<string name="display_game_fit_hint">Πώς προσαρμόζονται τα παιχνίδια 16:9 σε αυτή την οθόνη. Από την επόμενη συνεδρία.</string>
|
||||
<string name="display_game_fit_unavailable">Επιλέξτε Αντιστοίχιση οθόνης ή ένα προσαρμοσμένο μέγεθος πιο στενό από 16:9.</string>
|
||||
|
||||
@@ -955,7 +955,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Seguir la rotación del dispositivo</string>
|
||||
<string name="setup_orientation_portrait">Vertical</string>
|
||||
<string name="setup_session_orientation">Orientación de la sesión</string>
|
||||
<string name="setup_session_orientation_hint">Se aplica a Steam, los juegos, el escritorio y el editor de mandos. Los ajustes predefinidos de resolución giran con la sesión; cuando una orientación sigue a la otra, el ancho y el alto personalizados se invierten para coincidir.</string>
|
||||
<string name="setup_session_orientation_hint">Se aplica a Steam, los juegos, el escritorio y el editor de mandos. Los ajustes predefinidos de resolución giran con la sesión; el ancho y el alto personalizados se mantienen como se introdujeron.</string>
|
||||
<string name="setup_orientation_auto">Horizontal automática</string>
|
||||
<string name="setup_orientation_landscape">Horizontal</string>
|
||||
<string name="setup_orientation_reverse">Horizontal invertida</string>
|
||||
@@ -2487,10 +2487,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Pantalla de la sesión</string>
|
||||
<string name="display_zero_copy">Presentación sin copia</string>
|
||||
<string name="display_resolution_landscape">Resolución horizontal</string>
|
||||
<string name="display_resolution_portrait">Resolución vertical</string>
|
||||
<string name="display_follow_landscape">Igual que horizontal (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Igual que vertical (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Resolución</string>
|
||||
<string name="display_game_fit">Ajuste de juegos 16:9</string>
|
||||
<string name="display_game_fit_hint">Cómo se ajustan los juegos 16:9 a esta pantalla. Próxima sesión.</string>
|
||||
<string name="display_game_fit_unavailable">Elige Igual a la pantalla o un tamaño personalizado más estrecho que 16:9.</string>
|
||||
|
||||
@@ -952,7 +952,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Seuraa laitteen kiertoa</string>
|
||||
<string name="setup_orientation_portrait">Pystysuunta</string>
|
||||
<string name="setup_session_orientation">Istunnon suunta</string>
|
||||
<string name="setup_session_orientation_hint">Koskee Steamia, pelejä, työpöytää ja ohjainmuokkainta. Resoluution esiasetukset kääntyvät istunnon mukana; kun toinen suunta seuraa toista, mukautettu leveys ja korkeus vaihtavat paikkaa vastaamaan toisiaan.</string>
|
||||
<string name="setup_session_orientation_hint">Koskee Steamia, pelejä, työpöytää ja ohjainmuokkainta. Resoluution esiasetukset kääntyvät istunnon mukana; mukautettu leveys ja korkeus pysyvät syötetyn mukaisina.</string>
|
||||
<string name="setup_orientation_auto">Automaattinen vaakasuunta</string>
|
||||
<string name="setup_orientation_landscape">Vaakasuunta</string>
|
||||
<string name="setup_orientation_reverse">Käänteinen vaakasuunta</string>
|
||||
@@ -2461,10 +2461,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Istunnon näyttö</string>
|
||||
<string name="display_zero_copy">Kopioimaton esitys</string>
|
||||
<string name="display_resolution_landscape">Vaakatilan resoluutio</string>
|
||||
<string name="display_resolution_portrait">Pystytilan resoluutio</string>
|
||||
<string name="display_follow_landscape">Seuraa vaakaa (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Seuraa pystyä (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Tarkkuus</string>
|
||||
<string name="display_game_fit">16:9-pelin sovitus</string>
|
||||
<string name="display_game_fit_hint">Miten 16:9-pelit sovitetaan tähän näyttöön. Seuraava istunto.</string>
|
||||
<string name="display_game_fit_unavailable">Valitse Sovita näyttöön tai mukautettu koko, joka on 16:9:ää kapeampi.</string>
|
||||
|
||||
@@ -955,7 +955,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Suivre la rotation de l\'appareil</string>
|
||||
<string name="setup_orientation_portrait">Portrait</string>
|
||||
<string name="setup_session_orientation">Orientation de la session</string>
|
||||
<string name="setup_session_orientation_hint">S\'applique à Steam, aux jeux, au bureau et à l\'éditeur de manette. Les préréglages de résolution pivotent avec la session ; lorsqu\'une orientation suit l\'autre, la largeur et la hauteur personnalisées sont inversées pour correspondre.</string>
|
||||
<string name="setup_session_orientation_hint">S\'applique à Steam, aux jeux, au bureau et à l\'éditeur de manette. Les préréglages de résolution pivotent avec la session ; la largeur et la hauteur personnalisées restent telles que saisies.</string>
|
||||
<string name="setup_orientation_auto">Paysage automatique</string>
|
||||
<string name="setup_orientation_landscape">Paysage</string>
|
||||
<string name="setup_orientation_reverse">Paysage inversé</string>
|
||||
@@ -2486,10 +2486,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Affichage de la session</string>
|
||||
<string name="display_zero_copy">Affichage sans copie</string>
|
||||
<string name="display_resolution_landscape">Résolution en paysage</string>
|
||||
<string name="display_resolution_portrait">Résolution en portrait</string>
|
||||
<string name="display_follow_landscape">Comme le paysage (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Comme le portrait (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Résolution</string>
|
||||
<string name="display_game_fit">Ajustement des jeux 16:9</string>
|
||||
<string name="display_game_fit_hint">Comment les jeux 16:9 s\'adaptent à cet écran. À la prochaine session.</string>
|
||||
<string name="display_game_fit_unavailable">Choisissez « Adapter à l\'écran » ou une taille personnalisée plus étroite que 16:9.</string>
|
||||
|
||||
@@ -952,7 +952,7 @@
|
||||
<string name="setup_launcher_orientation_auto">डिवाइस रोटेशन के अनुसार</string>
|
||||
<string name="setup_orientation_portrait">पोर्ट्रेट</string>
|
||||
<string name="setup_session_orientation">सेशन ओरिएंटेशन</string>
|
||||
<string name="setup_session_orientation_hint">Steam, गेम, डेस्कटॉप और कंट्रोलर एडिटर पर लागू होता है। रिज़ॉल्यूशन प्रीसेट सेशन के साथ घूमते हैं; जब एक ओरिएंटेशन दूसरे को फ़ॉलो करता है, तो कस्टम चौड़ाई और ऊंचाई बदलकर मेल खाती हैं।</string>
|
||||
<string name="setup_session_orientation_hint">Steam, गेम, डेस्कटॉप और कंट्रोलर एडिटर पर लागू होता है। रिज़ॉल्यूशन प्रीसेट सेशन के साथ घूमते हैं; कस्टम चौड़ाई और ऊंचाई जैसी डाली गई वैसी ही रहती हैं।</string>
|
||||
<string name="setup_orientation_auto">ऑटोमैटिक लैंडस्केप</string>
|
||||
<string name="setup_orientation_landscape">लैंडस्केप</string>
|
||||
<string name="setup_orientation_reverse">उलटा लैंडस्केप</string>
|
||||
@@ -2461,10 +2461,7 @@
|
||||
<string name="phantom_warning">%1$s। %2$s\n\n%3$s</string>
|
||||
<string name="display_session">सेशन डिस्प्ले</string>
|
||||
<string name="display_zero_copy">बिना कॉपी प्रस्तुति</string>
|
||||
<string name="display_resolution_landscape">लैंडस्केप रेज़ोल्यूशन</string>
|
||||
<string name="display_resolution_portrait">पोर्ट्रेट रेज़ोल्यूशन</string>
|
||||
<string name="display_follow_landscape">लैंडस्केप जैसा (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">पोर्ट्रेट जैसा (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">रिज़ॉल्यूशन</string>
|
||||
<string name="display_game_fit">16:9 गेम फ़िट</string>
|
||||
<string name="display_game_fit_hint">16:9 गेम इस डिस्प्ले में कैसे फ़िट होते हैं। अगले सेशन से।</string>
|
||||
<string name="display_game_fit_unavailable">Match screen चुनें या 16:9 से पतला कस्टम आकार चुनें।</string>
|
||||
|
||||
@@ -952,7 +952,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Az eszköz elforgatásának követése</string>
|
||||
<string name="setup_orientation_portrait">Álló</string>
|
||||
<string name="setup_session_orientation">Munkamenet tájolása</string>
|
||||
<string name="setup_session_orientation_hint">A Steamre, a játékokra, az asztalra és a kontrollerszerkesztőre vonatkozik. A felbontás-előbeállítások a munkamenettel együtt forognak; ha az egyik tájolás a másikat követi, az egyéni szélesség és magasság felcserélődik.</string>
|
||||
<string name="setup_session_orientation_hint">A Steamre, a játékokra, az asztalra és a kontrollerszerkesztőre vonatkozik. A felbontás-előbeállítások a munkamenettel együtt forognak; az egyéni szélesség és magasság a megadott módon marad.</string>
|
||||
<string name="setup_orientation_auto">Automatikus fekvő</string>
|
||||
<string name="setup_orientation_landscape">Fekvő</string>
|
||||
<string name="setup_orientation_reverse">Fordított fekvő</string>
|
||||
@@ -2461,10 +2461,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Munkamenet kijelzője</string>
|
||||
<string name="display_zero_copy">Másolásmentes megjelenítés</string>
|
||||
<string name="display_resolution_landscape">Fekvő felbontás</string>
|
||||
<string name="display_resolution_portrait">Álló felbontás</string>
|
||||
<string name="display_follow_landscape">Mint a fekvő (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Mint az álló (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Felbontás</string>
|
||||
<string name="display_game_fit">16:9 játék illesztése</string>
|
||||
<string name="display_game_fit_hint">Hogyan illeszkednek a 16:9 játékok ehhez a kijelzőhöz. A következő munkamenettől.</string>
|
||||
<string name="display_game_fit_unavailable">Válassza a Képernyőhöz illesztést, vagy egy 16:9-nél szűkebb egyéni méretet.</string>
|
||||
|
||||
@@ -949,7 +949,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Ikuti rotasi perangkat</string>
|
||||
<string name="setup_orientation_portrait">Potret</string>
|
||||
<string name="setup_session_orientation">Orientasi sesi</string>
|
||||
<string name="setup_session_orientation_hint">Berlaku untuk Steam, gim, desktop, dan editor pengontrol. Preset resolusi ikut berputar dengan sesi; saat satu orientasi mengikuti yang lain, lebar dan tinggi kustom ditukar agar sesuai.</string>
|
||||
<string name="setup_session_orientation_hint">Berlaku untuk Steam, gim, desktop, dan editor pengontrol. Preset resolusi ikut berputar dengan sesi; lebar dan tinggi kustom tetap seperti yang dimasukkan.</string>
|
||||
<string name="setup_orientation_auto">Lanskap otomatis</string>
|
||||
<string name="setup_orientation_landscape">Lanskap</string>
|
||||
<string name="setup_orientation_reverse">Lanskap terbalik</string>
|
||||
@@ -2436,10 +2436,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Tampilan sesi</string>
|
||||
<string name="display_zero_copy">Presentasi tanpa salin</string>
|
||||
<string name="display_resolution_landscape">Resolusi lanskap</string>
|
||||
<string name="display_resolution_portrait">Resolusi potret</string>
|
||||
<string name="display_follow_landscape">Ikuti lanskap (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Ikuti potret (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Resolusi</string>
|
||||
<string name="display_game_fit">Penyesuaian gim 16:9</string>
|
||||
<string name="display_game_fit_hint">Cara gim 16:9 disesuaikan dengan tampilan ini. Berlaku pada sesi berikutnya.</string>
|
||||
<string name="display_game_fit_unavailable">Pilih Sesuaikan layar atau ukuran khusus yang lebih sempit dari 16:9.</string>
|
||||
|
||||
@@ -947,7 +947,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Segui la rotazione del dispositivo</string>
|
||||
<string name="setup_orientation_portrait">Verticale</string>
|
||||
<string name="setup_session_orientation">Orientamento della sessione</string>
|
||||
<string name="setup_session_orientation_hint">Si applica a Steam, ai giochi, al desktop e all\'editor del controller. I preset di risoluzione ruotano con la sessione; quando un\'orientamento segue l\'altro, larghezza e altezza personalizzate vengono invertite per corrispondere.</string>
|
||||
<string name="setup_session_orientation_hint">Si applica a Steam, ai giochi, al desktop e all\'editor del controller. I preset di risoluzione ruotano con la sessione; larghezza e altezza personalizzate restano come inserite.</string>
|
||||
<string name="setup_orientation_auto">Orizzontale automatico</string>
|
||||
<string name="setup_orientation_landscape">Orizzontale</string>
|
||||
<string name="setup_orientation_reverse">Orizzontale invertito</string>
|
||||
@@ -2478,10 +2478,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Schermo della sessione</string>
|
||||
<string name="display_zero_copy">Presentazione senza copia</string>
|
||||
<string name="display_resolution_landscape">Risoluzione orizzontale</string>
|
||||
<string name="display_resolution_portrait">Risoluzione verticale</string>
|
||||
<string name="display_follow_landscape">Come orizzontale (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Come verticale (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Risoluzione</string>
|
||||
<string name="display_game_fit">Adattamento giochi 16:9</string>
|
||||
<string name="display_game_fit_hint">Come i giochi 16:9 si adattano a questo schermo. Dalla prossima sessione.</string>
|
||||
<string name="display_game_fit_unavailable">Scegli Adatta allo schermo o una dimensione personalizzata più stretta di 16:9.</string>
|
||||
|
||||
@@ -949,7 +949,7 @@
|
||||
<string name="setup_launcher_orientation_auto">デバイスの回転に合わせる</string>
|
||||
<string name="setup_orientation_portrait">縦向き</string>
|
||||
<string name="setup_session_orientation">セッションの向き</string>
|
||||
<string name="setup_session_orientation_hint">Steam、ゲーム、デスクトップ、コントローラーエディターに適用されます。解像度プリセットはセッションに合わせて回転し、一方の向きがもう一方に従う場合、カスタムの幅と高さは向きに合わせて入れ替わります。</string>
|
||||
<string name="setup_session_orientation_hint">Steam、ゲーム、デスクトップ、コントローラーエディターに適用されます。解像度プリセットはセッションに合わせて回転し、カスタムの幅と高さは入力したとおりになります。</string>
|
||||
<string name="setup_orientation_auto">横向き(自動回転)</string>
|
||||
<string name="setup_orientation_landscape">横向き</string>
|
||||
<string name="setup_orientation_reverse">横向き(反転)</string>
|
||||
@@ -2436,10 +2436,7 @@
|
||||
<string name="phantom_warning">%1$s。%2$s\n\n%3$s</string>
|
||||
<string name="display_session">セッションの表示</string>
|
||||
<string name="display_zero_copy">ゼロコピー表示</string>
|
||||
<string name="display_resolution_landscape">横向きの解像度</string>
|
||||
<string name="display_resolution_portrait">縦向きの解像度</string>
|
||||
<string name="display_follow_landscape">横向きに合わせる (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">縦向きに合わせる (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">解像度</string>
|
||||
<string name="display_game_fit">16:9ゲームの表示</string>
|
||||
<string name="display_game_fit_hint">16:9のゲームをこのディスプレイにどう合わせるか。次回のセッションから。</string>
|
||||
<string name="display_game_fit_unavailable">「画面に合わせる」か、16:9より縦長のカスタムサイズを選んでください。</string>
|
||||
|
||||
@@ -949,7 +949,7 @@
|
||||
<string name="setup_launcher_orientation_auto">기기 회전 따르기</string>
|
||||
<string name="setup_orientation_portrait">세로</string>
|
||||
<string name="setup_session_orientation">세션 방향</string>
|
||||
<string name="setup_session_orientation_hint">Steam, 게임, 데스크톱 및 컨트롤러 편집기에 적용됩니다. 해상도 프리셋은 세션에 맞춰 회전하며, 한 방향이 다른 방향을 따를 때 사용자 정의 너비와 높이는 방향에 맞게 서로 바뀝니다.</string>
|
||||
<string name="setup_session_orientation_hint">Steam, 게임, 데스크톱 및 컨트롤러 편집기에 적용됩니다. 해상도 프리셋은 세션에 맞춰 회전하며, 사용자 정의 너비와 높이는 입력한 그대로 유지됩니다.</string>
|
||||
<string name="setup_orientation_auto">자동 가로 모드</string>
|
||||
<string name="setup_orientation_landscape">가로 모드</string>
|
||||
<string name="setup_orientation_reverse">역방향 가로 모드</string>
|
||||
@@ -2436,10 +2436,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">세션 디스플레이</string>
|
||||
<string name="display_zero_copy">제로카피 표시</string>
|
||||
<string name="display_resolution_landscape">가로 해상도</string>
|
||||
<string name="display_resolution_portrait">세로 해상도</string>
|
||||
<string name="display_follow_landscape">가로와 동일 (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">세로와 동일 (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">해상도</string>
|
||||
<string name="display_game_fit">16:9 게임 맞춤</string>
|
||||
<string name="display_game_fit_hint">16:9 게임을 이 디스플레이에 맞추는 방식입니다. 다음 세션부터 적용됩니다.</string>
|
||||
<string name="display_game_fit_unavailable">화면에 맞춤 또는 16:9보다 좁은 사용자 정의 크기를 선택하세요.</string>
|
||||
|
||||
@@ -949,7 +949,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Ikut putaran peranti</string>
|
||||
<string name="setup_orientation_portrait">Potret</string>
|
||||
<string name="setup_session_orientation">Orientasi sesi</string>
|
||||
<string name="setup_session_orientation_hint">Berkuat kuasa pada Steam, permainan, desktop dan editor pengawal. Pratetap resolusi berputar bersama sesi; apabila satu orientasi mengikuti yang lain, lebar dan tinggi tersuai ditukar supaya sepadan.</string>
|
||||
<string name="setup_session_orientation_hint">Berkuat kuasa pada Steam, permainan, desktop dan editor pengawal. Pratetap resolusi berputar bersama sesi; lebar dan tinggi tersuai kekal seperti yang dimasukkan.</string>
|
||||
<string name="setup_orientation_auto">Lanskap automatik</string>
|
||||
<string name="setup_orientation_landscape">Lanskap</string>
|
||||
<string name="setup_orientation_reverse">Lanskap songsang</string>
|
||||
@@ -2436,10 +2436,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Paparan sesi</string>
|
||||
<string name="display_zero_copy">Paparan tanpa salinan</string>
|
||||
<string name="display_resolution_landscape">Resolusi landskap</string>
|
||||
<string name="display_resolution_portrait">Resolusi potret</string>
|
||||
<string name="display_follow_landscape">Ikut landskap (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Ikut potret (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Resolusi</string>
|
||||
<string name="display_game_fit">Suaian permainan 16:9</string>
|
||||
<string name="display_game_fit_hint">Cara permainan 16:9 disuaikan ke paparan ini. Sesi seterusnya.</string>
|
||||
<string name="display_game_fit_unavailable">Pilih Sepadan skrin atau saiz tersuai lebih nipis daripada 16:9.</string>
|
||||
|
||||
@@ -952,7 +952,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Følg enhetens rotasjon</string>
|
||||
<string name="setup_orientation_portrait">Stående</string>
|
||||
<string name="setup_session_orientation">Retning for sesjonen</string>
|
||||
<string name="setup_session_orientation_hint">Gjelder Steam, spill, skrivebordet og kontrollerredigeringen. Forhåndsinnstilte oppløsninger roterer med sesjonen; når én retning følger den andre, byttes egendefinert bredde og høyde slik at de passer.</string>
|
||||
<string name="setup_session_orientation_hint">Gjelder Steam, spill, skrivebordet og kontrollerredigeringen. Forhåndsinnstilte oppløsninger roterer med sesjonen; egendefinert bredde og høyde forblir som angitt.</string>
|
||||
<string name="setup_orientation_auto">Automatisk liggende</string>
|
||||
<string name="setup_orientation_landscape">Liggende</string>
|
||||
<string name="setup_orientation_reverse">Omvendt liggende</string>
|
||||
@@ -2461,10 +2461,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Sesjonsskjerm</string>
|
||||
<string name="display_zero_copy">Presentasjon uten kopiering</string>
|
||||
<string name="display_resolution_landscape">Oppløsning i liggende</string>
|
||||
<string name="display_resolution_portrait">Oppløsning i stående</string>
|
||||
<string name="display_follow_landscape">Følg liggende (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Følg stående (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Oppløsning</string>
|
||||
<string name="display_game_fit">16:9-spilltilpasning</string>
|
||||
<string name="display_game_fit_hint">Hvordan 16:9-spill tilpasses denne skjermen. Fra neste sesjon.</string>
|
||||
<string name="display_game_fit_unavailable">Velg Tilpass skjerm eller en egendefinert størrelse smalere enn 16:9.</string>
|
||||
|
||||
@@ -952,7 +952,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Apparaatrotatie volgen</string>
|
||||
<string name="setup_orientation_portrait">Staand</string>
|
||||
<string name="setup_session_orientation">Oriëntatie van sessie</string>
|
||||
<string name="setup_session_orientation_hint">Geldt voor Steam, games, desktop en de controllereditor. Resolutievoorinstellingen draaien mee met de sessie; als de ene oriëntatie de andere volgt, worden aangepaste breedte en hoogte omgewisseld.</string>
|
||||
<string name="setup_session_orientation_hint">Geldt voor Steam, games, desktop en de controllereditor. Resolutievoorinstellingen draaien mee met de sessie; aangepaste breedte en hoogte blijven zoals ingevoerd.</string>
|
||||
<string name="setup_orientation_auto">Automatisch liggend</string>
|
||||
<string name="setup_orientation_landscape">Liggend</string>
|
||||
<string name="setup_orientation_reverse">Liggend omgekeerd</string>
|
||||
@@ -2461,10 +2461,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Sessiescherm</string>
|
||||
<string name="display_zero_copy">Weergave zonder kopie</string>
|
||||
<string name="display_resolution_landscape">Resolutie in liggend</string>
|
||||
<string name="display_resolution_portrait">Resolutie in staand</string>
|
||||
<string name="display_follow_landscape">Volg liggend (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Volg staand (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Resolutie</string>
|
||||
<string name="display_game_fit">16:9-beeldvulling</string>
|
||||
<string name="display_game_fit_hint">Hoe 16:9-games dit scherm vullen. Volgende sessie.</string>
|
||||
<string name="display_game_fit_unavailable">Kies Schermformaat of een aangepast formaat dat smaller is dan 16:9.</string>
|
||||
|
||||
@@ -958,7 +958,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Zgodnie z obrotem urządzenia</string>
|
||||
<string name="setup_orientation_portrait">Pionowa</string>
|
||||
<string name="setup_session_orientation">Orientacja sesji</string>
|
||||
<string name="setup_session_orientation_hint">Dotyczy Steam, gier, pulpitu i edytora kontrolera. Presety rozdzielczości obracają się z sesją; gdy jedna orientacja podąża za drugą, własna szerokość i wysokość są zamieniane.</string>
|
||||
<string name="setup_session_orientation_hint">Dotyczy Steam, gier, pulpitu i edytora kontrolera. Presety rozdzielczości obracają się z sesją; własna szerokość i wysokość pozostają jak wpisano.</string>
|
||||
<string name="setup_orientation_auto">Automatyczna pozioma</string>
|
||||
<string name="setup_orientation_landscape">Pozioma</string>
|
||||
<string name="setup_orientation_reverse">Odwrócona pozioma</string>
|
||||
@@ -2513,10 +2513,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Ekran sesji</string>
|
||||
<string name="display_zero_copy">Prezentacja bez kopiowania</string>
|
||||
<string name="display_resolution_landscape">Rozdzielczość w poziomie</string>
|
||||
<string name="display_resolution_portrait">Rozdzielczość w pionie</string>
|
||||
<string name="display_follow_landscape">Jak w poziomie (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Jak w pionie (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Rozdzielczość</string>
|
||||
<string name="display_game_fit">Dopasowanie gier 16:9</string>
|
||||
<string name="display_game_fit_hint">Jak gry 16:9 mieszczą się na tym ekranie. Od następnej sesji.</string>
|
||||
<string name="display_game_fit_unavailable">Wybierz „Dopasuj do ekranu” lub własny rozmiar węższy niż 16:9.</string>
|
||||
|
||||
@@ -947,7 +947,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Seguir a rotação do dispositivo</string>
|
||||
<string name="setup_orientation_portrait">Vertical</string>
|
||||
<string name="setup_session_orientation">Orientação da sessão</string>
|
||||
<string name="setup_session_orientation_hint">Aplica-se ao Steam, aos jogos, ao ambiente de trabalho e ao editor de comandos. As predefinições de resolução rodam com a sessão; quando uma orientação segue a outra, a largura e a altura personalizadas são trocadas para corresponder.</string>
|
||||
<string name="setup_session_orientation_hint">Aplica-se ao Steam, aos jogos, ao ambiente de trabalho e ao editor de comandos. As predefinições de resolução rodam com a sessão; a largura e a altura personalizadas ficam como foram introduzidas.</string>
|
||||
<string name="setup_orientation_auto">Horizontal automática</string>
|
||||
<string name="setup_orientation_landscape">Horizontal</string>
|
||||
<string name="setup_orientation_reverse">Horizontal invertida</string>
|
||||
@@ -2492,10 +2492,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Ecrã da sessão</string>
|
||||
<string name="display_zero_copy">Apresentação sem cópia</string>
|
||||
<string name="display_resolution_landscape">Resolução na horizontal</string>
|
||||
<string name="display_resolution_portrait">Resolução na vertical</string>
|
||||
<string name="display_follow_landscape">Igual à horizontal (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Igual à vertical (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Resolução</string>
|
||||
<string name="display_game_fit">Ajuste de jogos 16:9</string>
|
||||
<string name="display_game_fit_hint">Como os jogos 16:9 se ajustam a este ecrã. Próxima sessão.</string>
|
||||
<string name="display_game_fit_unavailable">Escolha «Igual ao ecrã» ou um tamanho personalizado mais estreito do que 16:9.</string>
|
||||
|
||||
@@ -954,7 +954,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Seguir a rotação do dispositivo</string>
|
||||
<string name="setup_orientation_portrait">Retrato</string>
|
||||
<string name="setup_session_orientation">Orientação da sessão</string>
|
||||
<string name="setup_session_orientation_hint">Vale para a Steam, os jogos, a área de trabalho e o editor de controle. As predefinições de resolução giram com a sessão; quando uma orientação segue a outra, largura e altura personalizadas são trocadas para corresponder.</string>
|
||||
<string name="setup_session_orientation_hint">Vale para a Steam, os jogos, a área de trabalho e o editor de controle. As predefinições de resolução giram com a sessão; largura e altura personalizadas ficam como foram digitadas.</string>
|
||||
<string name="setup_orientation_auto">Paisagem automática</string>
|
||||
<string name="setup_orientation_landscape">Paisagem</string>
|
||||
<string name="setup_orientation_reverse">Paisagem invertida</string>
|
||||
@@ -2500,10 +2500,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Tela da sessão</string>
|
||||
<string name="display_zero_copy">Apresentação sem cópia</string>
|
||||
<string name="display_resolution_landscape">Resolução na horizontal</string>
|
||||
<string name="display_resolution_portrait">Resolução na vertical</string>
|
||||
<string name="display_follow_landscape">Igual à horizontal (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Igual à vertical (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Resolução</string>
|
||||
<string name="display_game_fit">Ajuste de jogos 16:9</string>
|
||||
<string name="display_game_fit_hint">Como os jogos 16:9 se ajustam a esta tela. Na próxima sessão.</string>
|
||||
<string name="display_game_fit_unavailable">Escolha Igual à tela ou um tamanho personalizado mais estreito que 16:9.</string>
|
||||
|
||||
@@ -955,7 +955,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Urmează rotirea dispozitivului</string>
|
||||
<string name="setup_orientation_portrait">Portret</string>
|
||||
<string name="setup_session_orientation">Orientarea sesiunii</string>
|
||||
<string name="setup_session_orientation_hint">Se aplică pentru Steam, jocuri, desktop și editorul de controller. Presetările de rezoluție se rotesc odată cu sesiunea; când o orientare o urmează pe cealaltă, lățimea și înălțimea personalizate se inversează pentru a se potrivi.</string>
|
||||
<string name="setup_session_orientation_hint">Se aplică pentru Steam, jocuri, desktop și editorul de controller. Presetările de rezoluție se rotesc odată cu sesiunea; lățimea și înălțimea personalizate rămân cum au fost introduse.</string>
|
||||
<string name="setup_orientation_auto">Peisaj automat</string>
|
||||
<string name="setup_orientation_landscape">Peisaj</string>
|
||||
<string name="setup_orientation_reverse">Peisaj inversat</string>
|
||||
@@ -2487,10 +2487,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Afișajul sesiunii</string>
|
||||
<string name="display_zero_copy">Prezentare fără copiere</string>
|
||||
<string name="display_resolution_landscape">Rezoluție în peisaj</string>
|
||||
<string name="display_resolution_portrait">Rezoluție în portret</string>
|
||||
<string name="display_follow_landscape">Ca peisajul (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Ca portretul (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Rezoluție</string>
|
||||
<string name="display_game_fit">Potrivire joc 16:9</string>
|
||||
<string name="display_game_fit_hint">Cum se potrivesc jocurile 16:9 cu acest afișaj. Sesiunea următoare.</string>
|
||||
<string name="display_game_fit_unavailable">Alege Potrivire ecran sau o dimensiune personalizată mai îngustă decât 16:9.</string>
|
||||
|
||||
@@ -958,7 +958,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Следовать повороту устройства</string>
|
||||
<string name="setup_orientation_portrait">Портретная</string>
|
||||
<string name="setup_session_orientation">Ориентация сессии</string>
|
||||
<string name="setup_session_orientation_hint">Применяется к Steam, играм, рабочему столу и редактору контроллера. Предустановки разрешения поворачиваются вместе с сессией; когда одна ориентация следует за другой, свои ширина и высота меняются местами.</string>
|
||||
<string name="setup_session_orientation_hint">Применяется к Steam, играм, рабочему столу и редактору контроллера. Предустановки разрешения поворачиваются вместе с сессией; свои ширина и высота остаются как введены.</string>
|
||||
<string name="setup_orientation_auto">Альбомная (авто)</string>
|
||||
<string name="setup_orientation_landscape">Альбомная</string>
|
||||
<string name="setup_orientation_reverse">Перевернутая альбомная</string>
|
||||
@@ -2513,10 +2513,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Экран сессии</string>
|
||||
<string name="display_zero_copy">Вывод без копирования</string>
|
||||
<string name="display_resolution_landscape">Разрешение в альбомной ориентации</string>
|
||||
<string name="display_resolution_portrait">Разрешение в портретной ориентации</string>
|
||||
<string name="display_follow_landscape">Как в альбомной (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Как в портретной (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Разрешение</string>
|
||||
<string name="display_game_fit">Игры 16:9</string>
|
||||
<string name="display_game_fit_hint">Как игры 16:9 вписываются в этот экран. Вступит в силу в следующей сессии.</string>
|
||||
<string name="display_game_fit_unavailable">Выберите «По размеру экрана» или свой размер уже 16:9.</string>
|
||||
|
||||
@@ -952,7 +952,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Följ enhetens rotation</string>
|
||||
<string name="setup_orientation_portrait">Stående</string>
|
||||
<string name="setup_session_orientation">Sessionens orientering</string>
|
||||
<string name="setup_session_orientation_hint">Gäller Steam, spel, skrivbordet och kontrollredigeraren. Upplösningsförinställningar roterar med sessionen; när en orientering följer den andra byts anpassad bredd och höjd så att de passar.</string>
|
||||
<string name="setup_session_orientation_hint">Gäller Steam, spel, skrivbordet och kontrollredigeraren. Upplösningsförinställningar roterar med sessionen; anpassad bredd och höjd förblir som angivet.</string>
|
||||
<string name="setup_orientation_auto">Automatiskt liggande</string>
|
||||
<string name="setup_orientation_landscape">Liggande</string>
|
||||
<string name="setup_orientation_reverse">Liggande, upp och ned</string>
|
||||
@@ -2461,10 +2461,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Sessionsskärm</string>
|
||||
<string name="display_zero_copy">Presentation utan kopiering</string>
|
||||
<string name="display_resolution_landscape">Upplösning i liggande</string>
|
||||
<string name="display_resolution_portrait">Upplösning i stående</string>
|
||||
<string name="display_follow_landscape">Följ liggande (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Följ stående (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Upplösning</string>
|
||||
<string name="display_game_fit">16:9-spelanpassning</string>
|
||||
<string name="display_game_fit_hint">Hur 16:9-spel anpassas till den här skärmen. Nästa session.</string>
|
||||
<string name="display_game_fit_unavailable">Välj Matcha skärmen eller en anpassad storlek som är smalare än 16:9.</string>
|
||||
|
||||
@@ -949,7 +949,7 @@
|
||||
<string name="setup_launcher_orientation_auto">หมุนตามอุปกรณ์</string>
|
||||
<string name="setup_orientation_portrait">แนวตั้ง</string>
|
||||
<string name="setup_session_orientation">การวางแนวของเซสชัน</string>
|
||||
<string name="setup_session_orientation_hint">มีผลกับ Steam เกม เดสก์ท็อป และตัวแก้ไขคอนโทรลเลอร์ ค่าความละเอียดที่ตั้งไว้ล่วงหน้าจะหมุนตามเซสชัน เมื่อแนวหนึ่งตามอีกแนวหนึ่ง ความกว้างและความสูงที่กำหนดเองจะสลับกันให้ตรงกัน</string>
|
||||
<string name="setup_session_orientation_hint">มีผลกับ Steam เกม เดสก์ท็อป และตัวแก้ไขคอนโทรลเลอร์ ค่าความละเอียดที่ตั้งไว้ล่วงหน้าจะหมุนตามเซสชัน ส่วนความกว้างและความสูงที่กำหนดเองจะคงตามที่ป้อนไว้</string>
|
||||
<string name="setup_orientation_auto">แนวนอนอัตโนมัติ</string>
|
||||
<string name="setup_orientation_landscape">แนวนอน</string>
|
||||
<string name="setup_orientation_reverse">แนวนอนกลับด้าน</string>
|
||||
@@ -2436,10 +2436,7 @@
|
||||
<string name="phantom_warning">%1$s %2$s\n\n%3$s</string>
|
||||
<string name="display_session">การแสดงผลของเซสชัน</string>
|
||||
<string name="display_zero_copy">การแสดงผลแบบไม่คัดลอก</string>
|
||||
<string name="display_resolution_landscape">ความละเอียดแนวนอน</string>
|
||||
<string name="display_resolution_portrait">ความละเอียดแนวตั้ง</string>
|
||||
<string name="display_follow_landscape">ตามแนวนอน (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">ตามแนวตั้ง (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">ความละเอียด</string>
|
||||
<string name="display_game_fit">การแสดงเกม 16:9 ให้พอดี</string>
|
||||
<string name="display_game_fit_hint">วิธีที่เกม 16:9 แสดงพอดีกับหน้าจอนี้ มีผลในเซสชันถัดไป</string>
|
||||
<string name="display_game_fit_unavailable">เลือกพอดีหน้าจอ หรือขนาดกำหนดเองที่แคบกว่า 16:9</string>
|
||||
|
||||
@@ -944,7 +944,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Cihaz dönüşünü izle</string>
|
||||
<string name="setup_orientation_portrait">Dikey</string>
|
||||
<string name="setup_session_orientation">Oturum yönü</string>
|
||||
<string name="setup_session_orientation_hint">Steam, oyunlar, masaüstü ve kumanda düzenleyicisi için geçerlidir. Çözünürlük ön ayarları oturumla birlikte döner; bir yön diğerini izlediğinde özel genişlik ve yükseklik eşleşmek üzere yer değiştirir.</string>
|
||||
<string name="setup_session_orientation_hint">Steam, oyunlar, masaüstü ve kumanda düzenleyicisi için geçerlidir. Çözünürlük ön ayarları oturumla birlikte döner; özel genişlik ve yükseklik girildiği gibi kalır.</string>
|
||||
<string name="setup_orientation_auto">Otomatik yatay</string>
|
||||
<string name="setup_orientation_landscape">Yatay</string>
|
||||
<string name="setup_orientation_reverse">Ters yatay</string>
|
||||
@@ -2453,10 +2453,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Oturum ekranı</string>
|
||||
<string name="display_zero_copy">Kopyasız sunum</string>
|
||||
<string name="display_resolution_landscape">Yatay çözünürlük</string>
|
||||
<string name="display_resolution_portrait">Dikey çözünürlük</string>
|
||||
<string name="display_follow_landscape">Yatayı izle (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Dikeyi izle (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Çözünürlük</string>
|
||||
<string name="display_game_fit">16:9 oyun sığdırma</string>
|
||||
<string name="display_game_fit_hint">16:9 oyunların bu ekrana nasıl sığacağı. Sonraki oturumda.</string>
|
||||
<string name="display_game_fit_unavailable">Ekrana Uydur\'u veya 16:9\'dan daha dar özel bir boyutu seçin.</string>
|
||||
|
||||
@@ -958,7 +958,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Слідувати повороту пристрою</string>
|
||||
<string name="setup_orientation_portrait">Книжкова</string>
|
||||
<string name="setup_session_orientation">Орієнтація сеансу</string>
|
||||
<string name="setup_session_orientation_hint">Застосовується до Steam, ігор, робочого столу й редактора контролера. Готові роздільні здатності повертаються разом із сеансом; коли одна орієнтація слідує за іншою, власні ширина й висота міняються місцями.</string>
|
||||
<string name="setup_session_orientation_hint">Застосовується до Steam, ігор, робочого столу й редактора контролера. Готові роздільні здатності повертаються разом із сеансом; власні ширина й висота залишаються як введено.</string>
|
||||
<string name="setup_orientation_auto">Автоматично альбомна</string>
|
||||
<string name="setup_orientation_landscape">Альбомна</string>
|
||||
<string name="setup_orientation_reverse">Перевернута альбомна</string>
|
||||
@@ -2513,10 +2513,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Дисплей сеансу</string>
|
||||
<string name="display_zero_copy">Показ без копіювання</string>
|
||||
<string name="display_resolution_landscape">Роздільна здатність в альбомній орієнтації</string>
|
||||
<string name="display_resolution_portrait">Роздільна здатність у портретній орієнтації</string>
|
||||
<string name="display_follow_landscape">Як в альбомній (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Як у портретній (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Роздільна здатність</string>
|
||||
<string name="display_game_fit">Вписування гри 16:9</string>
|
||||
<string name="display_game_fit_hint">Як ігри 16:9 вписуються в цей дисплей. З наступного сеансу.</string>
|
||||
<string name="display_game_fit_unavailable">Виберіть «Під екран» або власний розмір, вужчий за 16:9.</string>
|
||||
|
||||
@@ -949,7 +949,7 @@
|
||||
<string name="setup_launcher_orientation_auto">Theo hướng xoay thiết bị</string>
|
||||
<string name="setup_orientation_portrait">Dọc</string>
|
||||
<string name="setup_session_orientation">Hướng màn hình phiên</string>
|
||||
<string name="setup_session_orientation_hint">Áp dụng cho Steam, game, desktop và trình chỉnh sửa tay cầm. Độ phân giải đặt sẵn xoay theo phiên; khi một hướng theo hướng còn lại, chiều rộng và chiều cao tùy chỉnh được hoán đổi cho khớp.</string>
|
||||
<string name="setup_session_orientation_hint">Áp dụng cho Steam, game, desktop và trình chỉnh sửa tay cầm. Độ phân giải đặt sẵn xoay theo phiên; chiều rộng và chiều cao tùy chỉnh giữ nguyên như đã nhập.</string>
|
||||
<string name="setup_orientation_auto">Ngang tự động</string>
|
||||
<string name="setup_orientation_landscape">Ngang</string>
|
||||
<string name="setup_orientation_reverse">Ngang ngược</string>
|
||||
@@ -2436,10 +2436,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Hiển thị phiên</string>
|
||||
<string name="display_zero_copy">Hiển thị không sao chép</string>
|
||||
<string name="display_resolution_landscape">Độ phân giải chiều ngang</string>
|
||||
<string name="display_resolution_portrait">Độ phân giải chiều dọc</string>
|
||||
<string name="display_follow_landscape">Theo chiều ngang (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Theo chiều dọc (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Độ phân giải</string>
|
||||
<string name="display_game_fit">Khớp game 16:9</string>
|
||||
<string name="display_game_fit_hint">Cách game 16:9 khớp với màn hình này. Từ phiên sau.</string>
|
||||
<string name="display_game_fit_unavailable">Chọn Khớp màn hình hoặc một kích thước tùy chỉnh hẹp hơn 16:9.</string>
|
||||
|
||||
@@ -949,7 +949,7 @@
|
||||
<string name="setup_launcher_orientation_auto">跟随设备旋转</string>
|
||||
<string name="setup_orientation_portrait">竖屏</string>
|
||||
<string name="setup_session_orientation">会话方向</string>
|
||||
<string name="setup_session_orientation_hint">适用于 Steam、游戏、桌面和手柄编辑器。分辨率预设会随会话旋转;当一个方向跟随另一个方向时,自定义宽度和高度会互换以保持一致。</string>
|
||||
<string name="setup_session_orientation_hint">适用于 Steam、游戏、桌面和手柄编辑器。分辨率预设会随会话旋转;自定义宽度和高度保持输入值不变。</string>
|
||||
<string name="setup_orientation_auto">自动横屏</string>
|
||||
<string name="setup_orientation_landscape">横屏</string>
|
||||
<string name="setup_orientation_reverse">反向横屏</string>
|
||||
@@ -2513,10 +2513,7 @@
|
||||
<string name="phantom_warning">%1$s。%2$s\n\n%3$s</string>
|
||||
<string name="display_session">会话显示</string>
|
||||
<string name="display_zero_copy">零拷贝呈现</string>
|
||||
<string name="display_resolution_landscape">横屏分辨率</string>
|
||||
<string name="display_resolution_portrait">竖屏分辨率</string>
|
||||
<string name="display_follow_landscape">跟随横屏 (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">跟随竖屏 (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">分辨率</string>
|
||||
<string name="display_game_fit">16:9 游戏适配</string>
|
||||
<string name="display_game_fit_hint">16:9 游戏如何适配此屏幕。下次会话生效。</string>
|
||||
<string name="display_game_fit_unavailable">请选择“匹配屏幕”或比 16:9 更窄的自定义尺寸。</string>
|
||||
|
||||
@@ -948,7 +948,7 @@
|
||||
<string name="setup_launcher_orientation_auto">跟隨裝置旋轉</string>
|
||||
<string name="setup_orientation_portrait">直向</string>
|
||||
<string name="setup_session_orientation">會話方向</string>
|
||||
<string name="setup_session_orientation_hint">套用至 Steam、遊戲、桌面和控制器編輯器。解像度預設會隨會話旋轉;當一個方向跟隨另一個方向時,自訂的寬度和高度會互換以保持一致。</string>
|
||||
<string name="setup_session_orientation_hint">套用至 Steam、遊戲、桌面和控制器編輯器。解像度預設會隨會話旋轉;自訂的寬度和高度則維持輸入值。</string>
|
||||
<string name="setup_orientation_auto">自動橫向</string>
|
||||
<string name="setup_orientation_landscape">橫向</string>
|
||||
<string name="setup_orientation_reverse">反向橫向</string>
|
||||
@@ -2433,10 +2433,7 @@
|
||||
<string name="phantom_warning">%1$s。%2$s\n\n%3$s</string>
|
||||
<string name="display_session">會話顯示</string>
|
||||
<string name="display_zero_copy">零複製呈現</string>
|
||||
<string name="display_resolution_landscape">橫向解析度</string>
|
||||
<string name="display_resolution_portrait">直向解析度</string>
|
||||
<string name="display_follow_landscape">跟隨橫向 (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">跟隨直向 (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">解像度</string>
|
||||
<string name="display_game_fit">16:9 遊戲顯示方式</string>
|
||||
<string name="display_game_fit_hint">16:9 遊戲如何配合此螢幕。下次會話生效。</string>
|
||||
<string name="display_game_fit_unavailable">請選擇「配合螢幕」或比 16:9 更窄的自訂尺寸。</string>
|
||||
|
||||
@@ -948,7 +948,7 @@
|
||||
<string name="setup_launcher_orientation_auto">跟隨裝置旋轉</string>
|
||||
<string name="setup_orientation_portrait">直向</string>
|
||||
<string name="setup_session_orientation">工作階段方向</string>
|
||||
<string name="setup_session_orientation_hint">套用至 Steam、遊戲、桌面和控制器編輯器。解析度預設會隨工作階段旋轉;當一個方向跟隨另一個方向時,自訂的寬度和高度會互換以保持一致。</string>
|
||||
<string name="setup_session_orientation_hint">套用至 Steam、遊戲、桌面和控制器編輯器。解析度預設會隨工作階段旋轉;自訂的寬度和高度則維持輸入值。</string>
|
||||
<string name="setup_orientation_auto">自動橫向</string>
|
||||
<string name="setup_orientation_landscape">橫向</string>
|
||||
<string name="setup_orientation_reverse">反向橫向</string>
|
||||
@@ -2433,10 +2433,7 @@
|
||||
<string name="phantom_warning">%1$s。%2$s\n\n%3$s</string>
|
||||
<string name="display_session">工作階段顯示</string>
|
||||
<string name="display_zero_copy">零複製呈現</string>
|
||||
<string name="display_resolution_landscape">橫向解析度</string>
|
||||
<string name="display_resolution_portrait">直向解析度</string>
|
||||
<string name="display_follow_landscape">跟隨橫向 (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">跟隨直向 (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">解析度</string>
|
||||
<string name="display_game_fit">16:9 遊戲顯示方式</string>
|
||||
<string name="display_game_fit_hint">16:9 遊戲如何配合此螢幕。下次工作階段生效。</string>
|
||||
<string name="display_game_fit_unavailable">請選擇「符合螢幕」或比 16:9 更窄的自訂尺寸。</string>
|
||||
|
||||
@@ -708,9 +708,6 @@
|
||||
<string name="drawer_open_qam">Open Quick Access Menu</string>
|
||||
<string name="drawer_prev_page">Previous page</string>
|
||||
<string name="drawer_next_page">Next page</string>
|
||||
<string name="drawer_manage_pages">Arrange pages</string>
|
||||
<string name="drawer_pages_reset">Reset</string>
|
||||
<string name="drawer_pages_done">Done</string>
|
||||
<string name="drawer_hud">Performance HUD</string>
|
||||
<string name="drawer_hud_fps">Frame rate</string>
|
||||
<string name="drawer_hud_battery">Battery temperature</string>
|
||||
@@ -1028,15 +1025,13 @@
|
||||
<string name="setup_launcher_orientation_auto">Follow device rotation</string>
|
||||
<string name="setup_orientation_portrait">Portrait</string>
|
||||
<string name="setup_session_orientation">Session orientation</string>
|
||||
<string name="setup_session_orientation_hint">Applies to Steam, games, desktop, and the controller editor. Resolution presets rotate with the session; when one orientation follows the other, custom width and height flip to match.</string>
|
||||
<string name="setup_session_orientation_hint">Applies to Steam, games, desktop, and the controller editor. Resolution presets rotate with the session; custom width and height stay as entered.</string>
|
||||
<string name="setup_orientation_auto">Automatic landscape</string>
|
||||
<string name="setup_orientation_landscape">Landscape</string>
|
||||
<string name="setup_orientation_reverse">Reverse landscape</string>
|
||||
<string name="setup_fullscreen">Fullscreen</string>
|
||||
<string name="setup_fullscreen_on">Hides the Android status and navigation bars</string>
|
||||
<string name="setup_fullscreen_off">Shows the Android status and navigation bars</string>
|
||||
<string name="setup_controller_haptics">Controller haptics</string>
|
||||
<string name="setup_controller_haptics_hint">A light tick when the D-pad, A or the shoulder buttons move or select in the launcher. Touch stays silent</string>
|
||||
<string name="setup_dual_screen_launcher">Dual screen launcher</string>
|
||||
<string name="setup_dual_screen_launcher_hint">Automatic puts the launcher sections (Steam, Library, Stores and the rest) on the second screen of handhelds with a built-in one. On uses any second display. Off keeps the launcher on one screen.</string>
|
||||
<string name="setup_dual_screen_sessions">Dual screen sessions</string>
|
||||
@@ -2723,10 +2718,7 @@
|
||||
<string name="phantom_warning">%1$s. %2$s\n\n%3$s</string>
|
||||
<string name="display_session">Session display</string>
|
||||
<string name="display_zero_copy">Zero-copy presentation</string>
|
||||
<string name="display_resolution_landscape">Landscape resolution</string>
|
||||
<string name="display_resolution_portrait">Portrait resolution</string>
|
||||
<string name="display_follow_landscape">Follow landscape (%1$d×%2$d)</string>
|
||||
<string name="display_follow_portrait">Follow portrait (%1$d×%2$d)</string>
|
||||
<string name="display_resolution">Resolution</string>
|
||||
<string name="display_game_fit">16:9 game fit</string>
|
||||
<string name="display_game_fit_hint">How 16:9 games fit this display. Next session.</string>
|
||||
<string name="display_game_fit_unavailable">Choose Match screen or a custom size that isn\'t 16:9.</string>
|
||||
@@ -4342,7 +4334,6 @@
|
||||
<string name="drawer_hint_button">%1$s opens this menu</string>
|
||||
<string name="drawer_hint_steam_inverted">Back twice opens this menu · Back once opens Steam\'s menu</string>
|
||||
<string name="drawer_corner_tap">Corner tap opens this menu</string>
|
||||
<string name="drawer_docked_menu_controller">Physical controls can use bottom screen</string>
|
||||
<string name="drawer_corner_tap_hint">Double-tap the top-right corner, for devices without a Back button</string>
|
||||
<string name="drawer_handle">Open the session menu</string>
|
||||
<string name="play_needs_you">Settings need you</string>
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.droiddeck.launcher.hud
|
||||
|
||||
import android.os.Looper
|
||||
import android.provider.Settings
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import com.droiddeck.launcher.ui.Motion
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33], qualifiers = "xhdpi")
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class DroidDeckHudHostInsetTest {
|
||||
private fun animate(scale: Float) {
|
||||
val app = RuntimeEnvironment.getApplication()
|
||||
Settings.Global.putFloat(app.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, scale)
|
||||
Motion.refresh(app)
|
||||
}
|
||||
|
||||
@Before fun noAnimation() = animate(0f)
|
||||
|
||||
@After fun restoreAnimation() = animate(1f)
|
||||
|
||||
private fun show(size: String, x: Float, y: Float, padLeft: Int, padRight: Int): DroidDeckHudView {
|
||||
val app = RuntimeEnvironment.getApplication()
|
||||
SessionPrefs.setDroidDeckHudConfig(app, DroidDeckHudConfig.encode(DroidDeckHudConfig.DEFAULTS + ("hudSnap" to "1") + ("hudSize" to size)))
|
||||
SessionPrefs.setDroidDeckHudPosition(app, x, y)
|
||||
val root = FrameLayout(app)
|
||||
root.setPadding(padLeft, 0, padRight, 0)
|
||||
DroidDeckHudHost(app).attach(root, 0)
|
||||
val hud = root.getChildAt(0) as DroidDeckHudView
|
||||
hud.visibility = View.VISIBLE
|
||||
val exactly = { s: Int -> View.MeasureSpec.makeMeasureSpec(s, View.MeasureSpec.EXACTLY) }
|
||||
root.measure(exactly(2000), exactly(1000))
|
||||
root.layout(0, 0, 2000, 1000)
|
||||
hud.showForTest(DroidDeckHudPanelTest.SNAPSHOT, "DXVK", 0L)
|
||||
hud.requestLayout()
|
||||
root.measure(exactly(2000), exactly(1000))
|
||||
root.layout(0, 0, 2000, 1000)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
return hud
|
||||
}
|
||||
|
||||
@Test fun theStripSpansOnlyTheAreaInsideTheNotchPadding() {
|
||||
val hud = show("strip", 0f, 0f, padLeft = 120, padRight = 40)
|
||||
assertEquals(120f, hud.x, 0.5f)
|
||||
assertEquals(2000 - 120 - 40, hud.width)
|
||||
}
|
||||
|
||||
@Test fun aHudSnappedLeftSitsBesideTheNotchInsteadOfUnderIt() {
|
||||
val hud = show("full", 0f, 300f, padLeft = 120, padRight = 0)
|
||||
assertEquals(120f, hud.x, 0.5f)
|
||||
}
|
||||
|
||||
@Test fun aHudSnappedRightStopsAtTheRightPadding() {
|
||||
val hud = show("full", 1990f, 300f, padLeft = 0, padRight = 90)
|
||||
assertEquals(2000f - 90f, hud.x + hud.width, 0.5f)
|
||||
}
|
||||
|
||||
@Test fun withoutPaddingTheHudStillReachesTheScreenEdges() {
|
||||
assertEquals(0f, show("full", 0f, 300f, 0, 0).x, 0.5f)
|
||||
val strip = show("strip", 0f, 0f, 0, 0)
|
||||
assertEquals(0f, strip.x, 0.5f)
|
||||
assertEquals(2000, strip.width)
|
||||
}
|
||||
|
||||
@Test fun boundsAnchorBetweenThePaddedEdges() {
|
||||
val b = HudBounds(120f, 0f, 2000f, 1000f, 400f, 200f)
|
||||
assertEquals(1600f, b.maxX, 0f)
|
||||
assertEquals(800f, b.maxY, 0f)
|
||||
assertEquals(120f, b.anchoredX(0f), 0f)
|
||||
assertEquals(1600f, b.anchoredX(1f), 0f)
|
||||
assertEquals(0f, b.anchorFor(0f), 0f)
|
||||
assertEquals(0f, b.anchorFor(850f), 0f)
|
||||
assertEquals(1f, b.anchorFor(870f), 0f)
|
||||
}
|
||||
|
||||
@Test fun boundsNeverInvertWhenTheHudIsWiderThanTheArea() {
|
||||
val b = HudBounds(120f, 50f, 600f, 300f, 900f, 900f)
|
||||
assertEquals(120f, b.maxX, 0f)
|
||||
assertEquals(50f, b.maxY, 0f)
|
||||
}
|
||||
}
|
||||
@@ -23,34 +23,6 @@ class DualScreenTest {
|
||||
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||
private val displays = context.getSystemService(DisplayManager::class.java)
|
||||
|
||||
@Test fun dockedMenuOnlyTakesTheControllerWhenOptedIn() {
|
||||
assertFalse(DualScreen.menuOwnsController(open = false, docked = false, optIn = true))
|
||||
assertTrue(DualScreen.menuOwnsController(open = true, docked = false, optIn = false))
|
||||
assertFalse(DualScreen.menuOwnsController(open = true, docked = true, optIn = false))
|
||||
assertTrue(DualScreen.menuOwnsController(open = true, docked = true, optIn = true))
|
||||
}
|
||||
|
||||
@Test fun theMenuComesBackOnStartWhenItIsTheSelectedModeOrWasShowingWhenTheScreenClosed() {
|
||||
val menu = SecondScreenMode.MENU
|
||||
val terminal = SecondScreenMode.TERMINAL
|
||||
assertTrue(DualScreen.menuReturnsOnStart(menu, menuWasShown = false, menuUp = false))
|
||||
assertTrue(DualScreen.menuReturnsOnStart(menu, menuWasShown = true, menuUp = false))
|
||||
assertTrue(DualScreen.menuReturnsOnStart(terminal, menuWasShown = true, menuUp = false))
|
||||
assertFalse(DualScreen.menuReturnsOnStart(terminal, menuWasShown = false, menuUp = false))
|
||||
assertFalse(DualScreen.menuReturnsOnStart(menu, menuWasShown = true, menuUp = true))
|
||||
assertFalse(DualScreen.menuReturnsOnStart(terminal, menuWasShown = true, menuUp = true))
|
||||
}
|
||||
|
||||
@Test fun aVisibleDockedMenuThatDoesNotOwnTheControllerIsIdle() {
|
||||
assertFalse(DualScreen.menuIdleOnBottom(open = false, docked = false, pinned = false, optIn = false))
|
||||
assertFalse(DualScreen.menuIdleOnBottom(open = true, docked = false, pinned = false, optIn = false))
|
||||
assertTrue(DualScreen.menuIdleOnBottom(open = true, docked = true, pinned = false, optIn = false))
|
||||
assertTrue(DualScreen.menuIdleOnBottom(open = false, docked = true, pinned = true, optIn = false))
|
||||
assertTrue(DualScreen.menuIdleOnBottom(open = false, docked = true, pinned = true, optIn = true))
|
||||
assertFalse(DualScreen.menuIdleOnBottom(open = true, docked = true, pinned = false, optIn = true))
|
||||
assertFalse(DualScreen.menuIdleOnBottom(open = false, docked = true, pinned = false, optIn = false))
|
||||
}
|
||||
|
||||
@Test fun internalPanelsCountAsBuiltIn() {
|
||||
assertTrue(DualScreen.isBuiltIn(1, "Anything"))
|
||||
assertFalse(DualScreen.isBuiltIn(2, "Retroid Pocket Duo"))
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.robolectric.annotation.Config
|
||||
class InputLayoutToolsTest {
|
||||
private val context: Context get() = RuntimeEnvironment.getApplication()
|
||||
@Before fun reset() {
|
||||
for (name in listOf("input-profiles", "input-surfaces", "controller")) context.getSharedPreferences(name, Context.MODE_PRIVATE).edit().clear().commit()
|
||||
for (name in listOf("input-profiles", "input-surfaces", "controller", "session")) context.getSharedPreferences(name, Context.MODE_PRIVATE).edit().clear().commit()
|
||||
}
|
||||
|
||||
@Test fun scaleAllResizesEveryElementAroundItsCentreInsideTheScreen() {
|
||||
@@ -132,7 +132,6 @@ class InputLayoutToolsTest {
|
||||
}
|
||||
|
||||
@Test fun aScaledGamepadStaysGeneratedAndRegeneratesOnRotation() {
|
||||
com.droiddeck.launcher.session.SessionPrefs.setSteamController(context, com.droiddeck.launcher.session.SessionPrefs.CONTROLLER_NONE)
|
||||
val (display, metrics) = InputLibraries.primaryDisplay(context)
|
||||
val long = maxOf(metrics.widthPixels, metrics.heightPixels)
|
||||
val short = minOf(metrics.widthPixels, metrics.heightPixels)
|
||||
@@ -140,7 +139,9 @@ class InputLayoutToolsTest {
|
||||
val scaled = gamepad.copy(scale = 1.25f, elements = LegacyGamepadLayout(display, long, short, scale = 1.25f).regenerate(gamepad.elements))
|
||||
assertEquals(long to short, OnScreenLayout.generatedSize(context, scaled, long, short))
|
||||
val rotated = OnScreenLayout.elements(context, scaled, short, long, android.graphics.Rect())
|
||||
assertEquals(LegacyGamepadLayout(context, short, long, scale = 1.25f).regenerate(scaled.elements), rotated)
|
||||
val stock = OnScreenLayout.elements(context, gamepad, short, long, android.graphics.Rect())
|
||||
assertEquals(stock.map { it.id }, rotated.map { it.id })
|
||||
assertTrue(rotated.first { it.control == InputControl.LS }.width > stock.first { it.control == InputControl.LS }.width)
|
||||
assertNull(OnScreenLayout.generatedSize(context, scaled.copy(scale = 1f), long, short))
|
||||
InputLibraries.update(context) { it.withLayout(scaled) }
|
||||
assertEquals(1.25f, InputLibraries.read(context).layouts.first { it.id == gamepad.id }.scale)
|
||||
|
||||
@@ -79,7 +79,7 @@ class OnScreenLayoutTest {
|
||||
assertEquals(original.map { it.id }, placed(true, true).map { it.id })
|
||||
assertEquals(placed(false, false), placed(true, true))
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
val edited = layout.copy(elements = layout.elements.map { e -> if (e.control == InputControl.START) e.copy(y = .3f) else e }, aspect = w.toFloat() / h)
|
||||
val edited = layout.copy(elements = layout.elements.map { e -> if (e.control == InputControl.START) e.copy(y = .3f) else e })
|
||||
val fitted = OnScreenLayout.elements(context, edited, w, h, safe)
|
||||
assertTrue(fitted.single { it.control == InputControl.START }.y < .5f)
|
||||
}
|
||||
@@ -197,10 +197,8 @@ class OnScreenLayoutTest {
|
||||
assertEquals(control.id, x, cx, .01f)
|
||||
assertEquals(control.id, y, cy, .01f)
|
||||
}
|
||||
assertCenter(InputControl.LT, 120f, 96f)
|
||||
assertCenter(InputControl.LB, 310f, 96f)
|
||||
assertCenter(InputControl.RB, 1290f, 96f)
|
||||
assertCenter(InputControl.RT, 1480f, 96f)
|
||||
assertCenter(InputControl.LT, 140f, 66f)
|
||||
assertCenter(InputControl.LB, 140f, 148f)
|
||||
assertCenter(InputControl.UP, 220f, 242.5f)
|
||||
assertCenter(InputControl.RIGHT, 322.5f, 345f)
|
||||
assertCenter(InputControl.LS, 290f, 640f)
|
||||
@@ -494,164 +492,4 @@ class OnScreenLayoutTest {
|
||||
assertEquals(InputStockLayouts.layouts().filter { it.id != DeckPanel.GAMEPAD.layout }.map { it.elements },
|
||||
others.filter { l -> InputStockLayouts.layouts().any { it.id == l.id } }.map { it.elements })
|
||||
}
|
||||
|
||||
private val kits = listOf(SessionPrefs.CONTROLLER_DECK, SessionPrefs.CONTROLLER_STEAM, SessionPrefs.CONTROLLER_XBOX360,
|
||||
SessionPrefs.CONTROLLER_DS4, SessionPrefs.CONTROLLER_DUALSENSE)
|
||||
|
||||
private fun List<InputSurfaceElement>.at(control: InputControl) = single { it.id == "legacy:${control.id}" }
|
||||
|
||||
@Test @Config(qualifiers = "w800dp-h450dp-land-320dpi")
|
||||
fun everyKitPutsTriggersBesideTheirBumpers() {
|
||||
for (kit in kits) {
|
||||
SessionPrefs.setSteamController(context, kit)
|
||||
val placed = OnScreenLayout.elements(context, gamepad(), 1600, 900, Rect(), rearButtons = true, trackpads = true)
|
||||
val lt = placed.at(InputControl.LT); val lb = placed.at(InputControl.LB)
|
||||
val rb = placed.at(InputControl.RB); val rt = placed.at(InputControl.RT)
|
||||
for ((outer, inner) in listOf(lt to lb, rt to rb)) assertEquals(kit, outer.y + outer.height / 2f, inner.y + inner.height / 2f, .001f)
|
||||
assertTrue(kit, lt.x + lt.width <= lb.x)
|
||||
assertTrue(kit, rb.x + rb.width <= rt.x)
|
||||
assertInside(placed, 1600, 900)
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w800dp-h450dp-land-320dpi")
|
||||
fun buttonSizeGrowsAndShrinksControlsOnAScreenWhoseHeightAlreadyLimitsTheLayout() {
|
||||
val (display, _) = InputLibraries.primaryDisplay(context)
|
||||
val stock = gamepad()
|
||||
fun at(scale: Float) = OnScreenLayout.elements(context, stock.copy(scale = scale,
|
||||
elements = LegacyGamepadLayout(display, 1600, 900, scale = scale).regenerate(stock.elements)), 1600, 900, Rect())
|
||||
fun List<InputSurfaceElement>.centre(controls: List<InputControl>) = controls.map { at(it) }.let { c ->
|
||||
c.sumOf { (it.x + it.width / 2).toDouble() } / c.size to c.sumOf { (it.y + it.height / 2).toDouble() } / c.size }
|
||||
val face = listOf(InputControl.A, InputControl.B, InputControl.X, InputControl.Y)
|
||||
val dpad = listOf(InputControl.UP, InputControl.RIGHT, InputControl.DOWN, InputControl.LEFT)
|
||||
for (kit in kits) {
|
||||
SessionPrefs.setSteamController(context, kit)
|
||||
val normal = at(1f)
|
||||
for (scale in listOf(.8f, 1.25f)) {
|
||||
val placed = at(scale)
|
||||
assertEquals("$kit $scale", normal.at(InputControl.A).width * scale, placed.at(InputControl.A).width, .002f)
|
||||
assertEquals("$kit $scale", normal.at(InputControl.LS).height * scale, placed.at(InputControl.LS).height, .002f)
|
||||
if (scale > 1f) for (cluster in listOf(face, dpad)) {
|
||||
val (x0, y0) = normal.centre(cluster); val (x1, y1) = placed.centre(cluster)
|
||||
assertEquals("$kit", x0, x1, .01); assertEquals("$kit", y0, y1, .01)
|
||||
}
|
||||
assertInside(placed, 1600, 900)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w1280dp-h800dp-land-mdpi")
|
||||
fun tabletOverlaysStayInTheLowerHalfOfTheScreen() {
|
||||
for (kit in kits) {
|
||||
SessionPrefs.setSteamController(context, kit)
|
||||
val placed = OnScreenLayout.elements(context, gamepad(), 1280, 800, Rect(), rearButtons = true, trackpads = true)
|
||||
for (e in placed) assertTrue("$kit ${e.id}", e.y >= .45f)
|
||||
assertInside(placed, 1280, 800)
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w800dp-h450dp-land-320dpi")
|
||||
fun phoneOverlaysStillUseTheFullHeight() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
val placed = OnScreenLayout.elements(context, gamepad(), 1600, 900, Rect())
|
||||
assertTrue(placed.at(InputControl.LT).y < .15f)
|
||||
assertTrue(placed.at(InputControl.START).let { it.y + it.height } > .9f)
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w800dp-h450dp-land-320dpi")
|
||||
fun aLayoutEditedInOneOrientationKeepsTheKitInTheOther() {
|
||||
for (kit in kits) {
|
||||
SessionPrefs.setSteamController(context, kit)
|
||||
val layout = gamepad()
|
||||
val landscape = OnScreenLayout.elements(context, layout, 1600, 900, Rect())
|
||||
val moved = landscape.map { if (it.control == InputControl.A) it.copy(x = .5f, y = .5f) else it }
|
||||
val edited = layout.copy(elements = moved, aspect = 1600f / 900f)
|
||||
assertEquals(kit, .5f, OnScreenLayout.elements(context, edited, 1600, 900, Rect()).at(InputControl.A).x, .001f)
|
||||
val kitPortrait = OnScreenLayout.elements(context, layout, 900, 1600, Rect())
|
||||
val editedPortrait = OnScreenLayout.elements(context, edited, 900, 1600, Rect())
|
||||
for (control in listOf(InputControl.A, InputControl.LT, InputControl.RB, InputControl.LS, InputControl.UP))
|
||||
assertEquals("$kit ${control.id}", kitPortrait.at(control), editedPortrait.at(control))
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w800dp-h450dp-land-320dpi")
|
||||
fun eachOrientationKeepsItsOwnEdits() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_XBOX360)
|
||||
val layout = gamepad()
|
||||
val landscape = OnScreenLayout.elements(context, layout, 1600, 900, Rect()).map { if (it.control == InputControl.A) it.copy(x = .5f, y = .5f) else it }
|
||||
val edited = OnScreenLayout.withFrame(context, layout, landscape, 1600f / 900f)
|
||||
val portrait = OnScreenLayout.elements(context, edited, 900, 1600, Rect()).map { if (it.control == InputControl.B) it.copy(x = .1f, y = .2f) else it }
|
||||
val both = OnScreenLayout.withFrame(context, edited, portrait, 900f / 1600f)
|
||||
assertEquals(landscape.map { it.id to floatArrayOf(it.x, it.y).toList() }, both.elements.map { it.id to floatArrayOf(it.x, it.y).toList() })
|
||||
val wide = OnScreenLayout.elements(context, both, 1600, 900, Rect())
|
||||
val tall = OnScreenLayout.elements(context, both, 900, 1600, Rect())
|
||||
assertEquals(.5f, wide.at(InputControl.A).x, .001f)
|
||||
assertEquals(.1f, tall.at(InputControl.B).x, .001f)
|
||||
assertEquals(.2f, tall.at(InputControl.B).y, .001f)
|
||||
val renamed = OnScreenLayout.withFrame(context, both, both.elements.map { if (it.control == InputControl.A) it.copy(name = "Jump") else it }, both.aspect)
|
||||
assertEquals("Jump", OnScreenLayout.elements(context, renamed, 900, 1600, Rect()).at(InputControl.A).name)
|
||||
assertEquals(.1f, OnScreenLayout.elements(context, renamed, 900, 1600, Rect()).at(InputControl.B).x, .001f)
|
||||
val library = InputLibraries.read(context).withLayout(both)
|
||||
assertEquals(both, InputLibraries.decode(InputLibraries.encode(library))!!.layouts.first { it.id == both.id })
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w800dp-h450dp-land-320dpi")
|
||||
fun aRemovedRearButtonStaysRemovedWhileTheOthersRemain() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
val layout = gamepad()
|
||||
val displayed = OnScreenLayout.elements(context, layout, 1600, 900, Rect(), rearButtons = true, trackpads = true)
|
||||
val frozen = OnScreenLayout.editorFrame(layout, displayed).filterNot { it.control == InputControl.L4 || it.control == InputControl.LEFT_PAD }
|
||||
val edited = layout.copy(elements = frozen, aspect = 1600f / 900f)
|
||||
for ((w, h) in listOf(1600 to 900, 900 to 1600)) {
|
||||
val placed = OnScreenLayout.elements(context, edited, w, h, Rect(), rearButtons = true, trackpads = true).map { it.control }
|
||||
assertFalse(InputControl.L4 in placed)
|
||||
assertFalse(InputControl.LEFT_PAD in placed)
|
||||
assertTrue(InputControl.R5 in placed)
|
||||
assertTrue(InputControl.RIGHT_PAD in placed)
|
||||
}
|
||||
val hidden = OnScreenLayout.elements(context, edited, 1600, 900, Rect(), rearButtons = false, trackpads = false).map { it.control }
|
||||
assertFalse(InputControl.R5 in hidden)
|
||||
assertFalse(InputControl.RIGHT_PAD in hidden)
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w800dp-h450dp-land-320dpi")
|
||||
fun aPortraitMainLayoutUsesTheStockControlsInLandscape() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_XBOX360)
|
||||
val layout = gamepad()
|
||||
val portrait = OnScreenLayout.elements(context, layout, 900, 1600, Rect()).map { if (it.control == InputControl.A) it.copy(x = .1f, y = .1f) else it }
|
||||
val edited = layout.copy(elements = portrait, aspect = 900f / 1600f)
|
||||
assertEquals(OnScreenLayout.elements(context, layout, 1600, 900, Rect()), OnScreenLayout.elements(context, edited, 1600, 900, Rect()))
|
||||
assertEquals(.1f, OnScreenLayout.elements(context, edited, 900, 1600, Rect()).at(InputControl.A).x, .001f)
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w800dp-h450dp-land-320dpi")
|
||||
fun aPortraitSaveKeepsOptionalControlsInThePortraitFrameOnly() {
|
||||
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK)
|
||||
val layout = gamepad()
|
||||
val landscape = OnScreenLayout.elements(context, layout, 1600, 900, Rect())
|
||||
val edited = OnScreenLayout.withFrame(context, layout, landscape, 1600f / 900f)
|
||||
val portrait = OnScreenLayout.elements(context, edited, 900, 1600, Rect(), rearButtons = true, trackpads = true)
|
||||
.map { if (it.control == InputControl.B) it.copy(x = .1f, y = .2f) else it }
|
||||
assertTrue(portrait.any { it.control == InputControl.L4 })
|
||||
val both = OnScreenLayout.withFrame(context, edited, portrait, 900f / 1600f)
|
||||
assertTrue(both.elements.none { it.control == InputControl.L4 || it.control == InputControl.LEFT_PAD })
|
||||
assertTrue(both.rotated.any { it.control == InputControl.L4 })
|
||||
assertEquals(OnScreenLayout.elements(context, edited, 1600, 900, Rect(), rearButtons = true, trackpads = true),
|
||||
OnScreenLayout.elements(context, both, 1600, 900, Rect(), rearButtons = true, trackpads = true))
|
||||
val tall = OnScreenLayout.elements(context, both, 900, 1600, Rect(), rearButtons = true, trackpads = true)
|
||||
for (control in listOf(InputControl.L4, InputControl.LEFT_PAD, InputControl.B)) assertEquals(control.id, portrait.at(control), tall.at(control))
|
||||
assertTrue(OnScreenLayout.elements(context, both, 900, 1600, Rect(), rearButtons = false, trackpads = false)
|
||||
.none { it.control == InputControl.L4 || it.control == InputControl.LEFT_PAD })
|
||||
}
|
||||
|
||||
@Test fun stockControlsUseTheKitArtworkWhileAddedAndTrackpadControlsStillUseTheTint() {
|
||||
for (kit in listOf(PadKit.XBOX, PadKit.DUALSENSE)) {
|
||||
SessionPrefs.setSteamController(context, if (kit == PadKit.XBOX) SessionPrefs.CONTROLLER_XBOX360 else SessionPrefs.CONTROLLER_DUALSENSE)
|
||||
val layout = gamepad()
|
||||
assertTrue(kit.name, layout.elements.all { kit.artwork(it) })
|
||||
val added = InputSurfaceElement(InputControl.A, 0f, 0f, .1f, .1f, "custom", name = "Fire")
|
||||
assertFalse(kit.artwork(added))
|
||||
assertFalse(kit.artwork(layout.elements.first { it.control == InputControl.A }.copy(image = "picture")))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,10 +53,14 @@ class SecondScreenModeTest {
|
||||
assertEquals(-1, SecondScreenDisplays.selection(-1, emptyList(), false))
|
||||
}
|
||||
|
||||
@Test fun withNothingRememberedTheDroidDeckMenuOpens() {
|
||||
for (deckPad in listOf(false, true)) for (dashboard in listOf(false, true)) for (desktop in listOf(false, true)) {
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening(null, deckPad, dashboard, desktop))
|
||||
}
|
||||
@Test fun withNothingRememberedDeckPadsGetControlsAndOthersTheDashboard() {
|
||||
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening(null, deckPad = true, dashboard = true))
|
||||
assertEquals(SecondScreenMode.DASHBOARD, SecondScreenMode.opening(null, deckPad = false, dashboard = true))
|
||||
}
|
||||
|
||||
@Test fun withNothingRememberedAndNoDashboardTheControllerPicksThePanel() {
|
||||
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening(null, deckPad = true))
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening(null, deckPad = false))
|
||||
}
|
||||
|
||||
@Test fun thePanelTheUserPickedLastOpensAgain() {
|
||||
@@ -66,18 +70,9 @@ class SecondScreenModeTest {
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("keyboard-trackpad", deckPad = true))
|
||||
}
|
||||
|
||||
@Test fun theMenuIsAModeAndOpensAgainWhenItWasPickedLast() {
|
||||
for (deckPad in listOf(false, true)) {
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("menu", deckPad, dashboard = true, bottomDesktop = true))
|
||||
}
|
||||
assertEquals("menu", SecondScreenMode.MENU.id)
|
||||
assertEquals(false, SecondScreenMode.MENU.controls)
|
||||
assertEquals(null, SecondScreenMode.MENU.bindings)
|
||||
}
|
||||
|
||||
@Test fun deckControlsNeedTheDeckPad() {
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("deck-controls", deckPad = false))
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("deck-controls", deckPad = false, dashboard = true))
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("deck-controls", deckPad = false))
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("deck-controls", deckPad = false, dashboard = true))
|
||||
}
|
||||
|
||||
@Test fun customControlsReopenWithEitherControllerType() {
|
||||
@@ -86,23 +81,37 @@ class SecondScreenModeTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun anUnknownOrClosedChoiceFallsBackToTheMenu() {
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("none", deckPad = true, dashboard = true))
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("gone", deckPad = false, dashboard = true))
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("none", deckPad = true))
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("gone", deckPad = false))
|
||||
@Test fun anUnknownOrClosedChoiceFallsBackToTheDefault() {
|
||||
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening("none", deckPad = true, dashboard = true))
|
||||
assertEquals(SecondScreenMode.DASHBOARD, SecondScreenMode.opening("gone", deckPad = false, dashboard = true))
|
||||
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening("none", deckPad = true))
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("gone", deckPad = false))
|
||||
}
|
||||
|
||||
@Test fun theDashboardOpensAgainOnlyWhileItHasPages() {
|
||||
assertEquals(SecondScreenMode.DASHBOARD, SecondScreenMode.opening("dashboard", deckPad = true, dashboard = true))
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("dashboard", deckPad = true, dashboard = false))
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("dashboard", deckPad = false))
|
||||
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening("dashboard", deckPad = true, dashboard = false))
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("dashboard", deckPad = false))
|
||||
}
|
||||
|
||||
@Test fun theDesktopOpensAgainOnlyWhileItCanRun() {
|
||||
assertEquals(SecondScreenMode.DESKTOP, SecondScreenMode.opening("desktop", deckPad = true, dashboard = true, bottomDesktop = true))
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("desktop", deckPad = true, dashboard = true))
|
||||
assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("desktop", deckPad = false))
|
||||
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening("desktop", deckPad = true, dashboard = true))
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("desktop", deckPad = false))
|
||||
}
|
||||
|
||||
@Test fun withNothingRememberedTheDesktopIsNeverPicked() {
|
||||
assertEquals(SecondScreenMode.DASHBOARD, SecondScreenMode.opening(null, deckPad = false, dashboard = true, bottomDesktop = true))
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening(null, deckPad = false, bottomDesktop = true))
|
||||
}
|
||||
|
||||
@Test fun desktopSessionsOpenTheTrackpadUntilTheUserPicksAnotherPanel() {
|
||||
for (deckPad in listOf(false, true)) for (dashboard in listOf(false, true)) {
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening(null, deckPad, dashboard, desktopSession = true))
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("gone", deckPad, dashboard, desktopSession = true))
|
||||
assertEquals(SecondScreenMode.CUSTOM_CONTROLS, SecondScreenMode.opening("custom-controls", deckPad, dashboard, desktopSession = true))
|
||||
assertEquals(SecondScreenMode.TERMINAL, SecondScreenMode.opening("terminal", deckPad, dashboard, desktopSession = true))
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun theEditorOpensOnTheChosenBottomScreenUnlessAnotherAppHoldsIt() {
|
||||
|
||||
@@ -48,14 +48,20 @@ class SecondScreenProfileMigrationTest {
|
||||
SessionState.deckPad = previousDeckPad
|
||||
}
|
||||
|
||||
@Test fun firstOpeningKeepsTheLibraryAndOpensTheMenuOverTheTrackpad() {
|
||||
@Test fun firstOpeningKeepsTheLibraryAndOpensTheTrackpadOnDesktopAndTheControllerPanelInGames() {
|
||||
for (desktop in listOf(false, true)) for (deckPad in listOf(false, true)) {
|
||||
val original = customLibrary(desktop)
|
||||
open(desktop, deckPad)
|
||||
assertEquals(original, InputLibraries.read(activity))
|
||||
assertNull(SessionPrefs.secondScreenPanel(activity, desktop))
|
||||
assertEquals(SecondScreenMode.MENU, ReflectionHelpers.callInstanceMethod<SecondScreenMode>(activity, "openingPanel"))
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SessionState.secondScreenMode)
|
||||
val dashboard = ReflectionHelpers.callInstanceMethod<List<*>>(activity, "bottomPages").isNotEmpty()
|
||||
val expected = when {
|
||||
desktop -> SecondScreenMode.KEYBOARD_TRACKPAD
|
||||
deckPad -> SecondScreenMode.DECK_CONTROLS
|
||||
dashboard -> SecondScreenMode.DASHBOARD
|
||||
else -> SecondScreenMode.KEYBOARD_TRACKPAD
|
||||
}
|
||||
assertEquals(expected, SessionState.secondScreenMode)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,8 +107,9 @@ class SecondScreenProfileMigrationTest {
|
||||
customLibrary(desktop)
|
||||
SessionState.deckPad = false
|
||||
show(SecondScreenMode.DECK_CONTROLS)
|
||||
val fallback = ReflectionHelpers.callInstanceMethod<SecondScreenMode>(activity, "openingSurface")
|
||||
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, fallback)
|
||||
val fallback = ReflectionHelpers.callInstanceMethod<SecondScreenMode>(activity, "openingPanel")
|
||||
assertNotEquals(SecondScreenMode.DECK_CONTROLS, fallback)
|
||||
if (desktop) assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, fallback)
|
||||
assertEquals(fallback, SessionState.secondScreenMode)
|
||||
assertNotEquals(InputLibraries.DECK, routedLayout()?.id)
|
||||
}
|
||||
|
||||
@@ -73,6 +73,72 @@ class BattleNetTest {
|
||||
assertEquals(crc or 0x80000000L, BattleNet.APP_ID)
|
||||
}
|
||||
|
||||
@Test fun theNewestD2rfixIsTheHighestFexThenTheHighestFix() {
|
||||
val items = listOf(
|
||||
item("FEXCore-2610-linux.wcp"),
|
||||
item("FEXCore-2609-d2rfix25-linux.wcp"),
|
||||
item("FEXCore-2610-d2rfix9-linux.wcp"),
|
||||
item("FEXCore-2610-d2rfix28-linux.wcp"),
|
||||
item("FEXCore-2509.1-d2rfix40-linux.wcp"),
|
||||
)
|
||||
assertEquals("FEXCore-2610-d2rfix28-linux.wcp", BattleNet.newestD2rFix(items)?.file)
|
||||
assertEquals("FEXCore-2610.1-d2rfix1-linux.wcp", BattleNet.newestD2rFix(items + item("FEXCore-2610.1-d2rfix1-linux.wcp"))?.file)
|
||||
assertEquals("FexCore-2611-D2RFIX2-linux.wcp", BattleNet.newestD2rFix(items + item("FexCore-2611-D2RFIX2-linux.wcp"))?.file)
|
||||
}
|
||||
|
||||
@Test fun onlyFexD2rfixPackagesCount() {
|
||||
assertNull(BattleNet.newestD2rFix(listOf(item("FEXCore-2610-linux.wcp"), item("FEXCore-2610-d2rfix28-linux.wcp", comp = "dxvk"))))
|
||||
assertNull(BattleNet.d2rfix("FEXCore-2610-d2rfix28-linux.wcp.part"))
|
||||
assertNull(BattleNet.d2rfix("FEXCore-2610-d2rfix-linux.wcp"))
|
||||
assertEquals(listOf(2610L) to 28L, BattleNet.d2rfix("FEXCore-2610-d2rfix28-linux.wcp"))
|
||||
}
|
||||
|
||||
@Test fun theNewestStoredBuildIsSetForThePrefix() {
|
||||
catalog("FEXCore-2609-d2rfix25-linux.wcp", "FEXCore-2610-d2rfix28-linux.wcp", "FEXCore-2610-linux.wcp")
|
||||
store("FEXCore-2610-d2rfix28-linux.wcp")
|
||||
|
||||
assertEquals("FEXCore-2610-d2rfix28-linux.wcp", BattleNet.ensureFex(context, ::noRefresh))
|
||||
|
||||
assertEquals(mapOf("fex" to "FEXCore-2610-d2rfix28-linux.wcp"), ComponentsManager.gameComponents(context, BattleNet.APP_ID.toString()))
|
||||
assertEquals("FEXCore-2610-d2rfix28-linux.wcp", BattleNet.ensureFex(context, ::noRefresh))
|
||||
}
|
||||
|
||||
@Test fun aNewerBuildReplacesTheOldOne() {
|
||||
catalog("FEXCore-2609-d2rfix25-linux.wcp")
|
||||
store("FEXCore-2609-d2rfix25-linux.wcp")
|
||||
BattleNet.ensureFex(context, ::noRefresh)
|
||||
catalog("FEXCore-2609-d2rfix25-linux.wcp", "FEXCore-2610-d2rfix28-linux.wcp")
|
||||
store("FEXCore-2610-d2rfix28-linux.wcp")
|
||||
|
||||
BattleNet.ensureFex(context, ::noRefresh)
|
||||
|
||||
assertEquals("FEXCore-2610-d2rfix28-linux.wcp", ComponentsManager.gameComponents(context, BattleNet.APP_ID.toString())["fex"])
|
||||
}
|
||||
|
||||
@Test fun aStaleListingIsFetchedAgain() {
|
||||
catalog("FEXCore-2609-d2rfix25-linux.wcp", fetchedAt = 1)
|
||||
store("FEXCore-2610-d2rfix28-linux.wcp")
|
||||
|
||||
BattleNet.ensureFex(context) { listOf(item("FEXCore-2609-d2rfix25-linux.wcp"), item("FEXCore-2610-d2rfix28-linux.wcp")) }
|
||||
|
||||
assertEquals("FEXCore-2610-d2rfix28-linux.wcp", ComponentsManager.gameComponents(context, BattleNet.APP_ID.toString())["fex"])
|
||||
}
|
||||
|
||||
@Test fun aFailedFetchFallsBackOnTheCachedListing() {
|
||||
catalog("FEXCore-2609-d2rfix25-linux.wcp", fetchedAt = 1)
|
||||
store("FEXCore-2609-d2rfix25-linux.wcp")
|
||||
|
||||
assertEquals("FEXCore-2609-d2rfix25-linux.wcp", BattleNet.ensureFex(context) { error("offline") })
|
||||
}
|
||||
|
||||
@Test fun aListingWithoutD2rfixIsAnError() {
|
||||
catalog("FEXCore-2610-linux.wcp")
|
||||
var refreshed = 0
|
||||
assertThrows(IllegalStateException::class.java) { BattleNet.ensureFex(context) { refreshed++; emptyList() } }
|
||||
assertEquals(1, refreshed)
|
||||
assertEquals(emptyMap<String, String>(), ComponentsManager.gameComponents(context, BattleNet.APP_ID.toString()))
|
||||
}
|
||||
|
||||
@Test fun installedIsTheLauncherInThePrefix() {
|
||||
assertFalse(BattleNet.installed(context))
|
||||
launcher().apply { parentFile!!.mkdirs(); writeText("MZ") }
|
||||
@@ -86,9 +152,9 @@ class BattleNetTest {
|
||||
}
|
||||
|
||||
@Test fun removeTakesThePrefixItsMenuEntryAndCacheButNothingItLinksTo() {
|
||||
store("FEXCore-2610-linux.wcp")
|
||||
ComponentsManager.setGameComponent(context, BattleNet.APP_ID.toString(), "fex", "FEXCore-2610-linux.wcp")
|
||||
assertEquals(mapOf("fex" to "FEXCore-2610-linux.wcp"), ComponentsManager.gameComponents(context, BattleNet.APP_ID.toString()))
|
||||
catalog("FEXCore-2610-d2rfix28-linux.wcp")
|
||||
store("FEXCore-2610-d2rfix28-linux.wcp")
|
||||
BattleNet.ensureFex(context, ::noRefresh)
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
fun put(relative: String) = File(root, relative).apply { parentFile!!.mkdirs(); writeText("x") }
|
||||
launcher().apply { parentFile!!.mkdirs(); writeText("MZ") }
|
||||
@@ -110,7 +176,7 @@ class BattleNetTest {
|
||||
assertTrue(otherMenu.isFile)
|
||||
assertFalse(log.parentFile!!.exists())
|
||||
assertTrue(otherPrefix.isFile)
|
||||
assertEquals(emptyMap<String, String>(), ComponentsManager.gameComponents(context, BattleNet.APP_ID.toString()))
|
||||
assertNull(BattleNet.fexInUse(context))
|
||||
outside.deleteRecursively()
|
||||
}
|
||||
|
||||
@@ -415,22 +481,6 @@ class BattleNetTest {
|
||||
assertTrue(BattleNet.ensureVideoMemory(context))
|
||||
}
|
||||
|
||||
@Test fun theProfileDefaultsAreSetForTheBattleNetProgramOrOnceInstalledAndNeverForAnythingElse() {
|
||||
File(context.filesDir, "game-environment.json").delete()
|
||||
val manager = context.getSystemService(android.app.ActivityManager::class.java)
|
||||
org.robolectric.Shadows.shadowOf(manager).setMemoryInfo(android.app.ActivityManager.MemoryInfo().apply { totalMem = 11113L shl 20 })
|
||||
val scope = BattleNet.APP_ID.toString()
|
||||
BattleNet.ensureDefaults(context, null)
|
||||
assertNull(GameEnvironmentStore.read(context).games[scope]?.get("DXVK_CONFIG"))
|
||||
BattleNet.ensureDefaults(context, BattleNet.PROGRAM)
|
||||
assertEquals(BattleNet.videoMemoryOptions(2048), GameEnvironmentStore.read(context).games[scope]?.get("DXVK_CONFIG"))
|
||||
assertTrue(com.droiddeck.launcher.session.SessionPrefs.battleNetNoSteamSet(context))
|
||||
File(context.filesDir, "game-environment.json").delete()
|
||||
launcher().apply { parentFile!!.mkdirs(); writeText("MZ") }
|
||||
BattleNet.ensureDefaults(context, null)
|
||||
assertEquals(BattleNet.videoMemoryOptions(2048), GameEnvironmentStore.read(context).games[scope]?.get("DXVK_CONFIG"))
|
||||
}
|
||||
|
||||
private fun launcher() = File(BattleNet.prefix(context), "pfx/drive_c/Program Files (x86)/Battle.net/Battle.net Launcher.exe")
|
||||
|
||||
private fun varint(value: Long): ByteArray {
|
||||
@@ -446,6 +496,21 @@ class BattleNetTest {
|
||||
private fun varintField(number: Int, value: Long) = varint((number shl 3).toLong()) + varint(value)
|
||||
private fun message(vararg fields: ByteArray) = fields.fold(ByteArray(0)) { all, f -> all + f }
|
||||
|
||||
private fun noRefresh(context: Context): List<ComponentsManager.CatalogItem> = error("the cached listing was fresh")
|
||||
|
||||
private fun item(file: String, comp: String = "fex") = ComponentsManager.CatalogItem(
|
||||
file, comp, "FexCore-Linux", "https://github.com/The412Banner/Nightlies/releases/download/FexCore-Linux/$file", 4, "sha256:" + "ab".repeat(32),
|
||||
)
|
||||
|
||||
private fun catalog(vararg files: String, fetchedAt: Long = System.currentTimeMillis() / 1000) {
|
||||
val cache = File(context.filesDir, "components/catalog.json")
|
||||
cache.parentFile!!.mkdirs()
|
||||
val items = JSONArray()
|
||||
for (file in files) items.put(JSONObject().put("file", file).put("comp", "fex").put("release", "FexCore-Linux")
|
||||
.put("url", item(file).url).put("size", 4).put("digest", item(file).digest))
|
||||
cache.writeText(JSONObject().put("items", items).put("fetchedAt", fetchedAt).toString())
|
||||
}
|
||||
|
||||
private fun store(file: String) {
|
||||
val wcp = File(context.filesDir, "components/packages/$file")
|
||||
wcp.parentFile!!.mkdirs()
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class UserAppsFeedTest {
|
||||
private val feed = "https://example.com/apps/linux/latest-linux.yml"
|
||||
private val sha = "ajcSve2Wq1CgocS5zWlmdfb0pI0C+JqNvbFx6Vm9j9/fW1Q/u2dnnNvNGmi0gulEXp7tnRkYCCc7rfwtjKcoNw=="
|
||||
|
||||
private fun body(path: String = "App-1.2.0-7.AppImage", hash: String = sha) = """
|
||||
version: 1.2.0-7
|
||||
files:
|
||||
- url: App-1.2.0-7.AppImage
|
||||
sha512: $hash
|
||||
size: 100
|
||||
- url: App_1.2.0-7_amd64.deb
|
||||
sha512: other
|
||||
path: $path
|
||||
sha512: $hash
|
||||
releaseDate: '2026-11-15T18:08:09.118Z'
|
||||
""".trimIndent()
|
||||
|
||||
@Test fun feedGivesTheAppImageRelease() {
|
||||
val release = UserApps.parseFeed(feed, body())!!
|
||||
assertEquals("1.2.0-7", release.tag)
|
||||
assertEquals("App-1.2.0-7.AppImage", release.asset)
|
||||
assertEquals("https://example.com/apps/linux/App-1.2.0-7.AppImage", release.url)
|
||||
assertEquals("2026-11-15T18:08:09.118Z", release.published)
|
||||
assertEquals(128, release.sha512!!.length)
|
||||
assertEquals("6a3712bded96ab50a0a1c4b9cd696675f6f4a48d02f89a8dbdb171e959bd8fdfdf5b543fbb67679cdbcd1a68b482e9445e9eed9d191808273badfc2d8ca72837", release.sha512)
|
||||
assertNull(release.sha256)
|
||||
}
|
||||
|
||||
@Test fun feedWithoutAnAppImageOrHashIsRefused() {
|
||||
assertNull(UserApps.parseFeed(feed, body(path = "App_1.2.0-7_amd64.deb")))
|
||||
assertNull(UserApps.parseFeed(feed, body(path = "../App.AppImage")))
|
||||
assertNull(UserApps.parseFeed(feed, body(path = "sub/App.AppImage")))
|
||||
assertNull(UserApps.parseFeed(feed, body(hash = "c2hvcnQ=")))
|
||||
assertNull(UserApps.parseFeed("http://example.com/latest-linux.yml", body()))
|
||||
assertNull(UserApps.parseFeed(feed, "path: App.AppImage\n"))
|
||||
}
|
||||
|
||||
@Test fun curseForgeIsFoundByItsFeed() {
|
||||
val other = UserApps.App("appimage:a", UserApps.Kind.APPIMAGE, "CurseForge", null, null, AppImageManager.LAUNCHER, emptyList())
|
||||
val official = UserApps.App("appimage:b", UserApps.Kind.APPIMAGE, "Mods", null, null, AppImageManager.LAUNCHER, emptyList(), feed = CurseForgeApp.FEED)
|
||||
assertEquals("appimage:b", CurseForgeApp.find(listOf(other, official))?.key)
|
||||
assertNull(CurseForgeApp.find(listOf(other)))
|
||||
}
|
||||
|
||||
@Test fun olderOrEqualFeedReleasesAreNotOffered() {
|
||||
val release = UserApps.parseFeed(feed, body())!!
|
||||
assertTrue(UserApps.isNewer(release, "2026-11-01T00:00:00.000Z", "1.0"))
|
||||
assertFalse(UserApps.isNewer(release, "2099-01-01T00:00:00.000Z", "9.9"))
|
||||
assertFalse(UserApps.isNewer(release, "", release.tag))
|
||||
assertTrue(UserApps.isNewer(release, "", "0.1"))
|
||||
}
|
||||
|
||||
@Test fun publicationTimesCompareAsInstantsWhateverTheirPrecision() {
|
||||
val release = UserApps.parseFeed(feed, body())!!
|
||||
assertTrue(UserApps.isNewer(release, "2026-11-15T18:08:09Z", "1.0"))
|
||||
assertFalse(UserApps.isNewer(release, "2026-11-15T18:08:09.118000Z", "1.0"))
|
||||
assertFalse(UserApps.isNewer(release, "2026-11-15T18:08:10Z", "1.0"))
|
||||
}
|
||||
}
|
||||
Loaded 100 of 136 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user