From b0b5a40d4477cbb20d02e4bcbbfcb00aa8c7bd30 Mon Sep 17 00:00:00 2001 From: Valentin <40423291+Valent-in@users.noreply.github.com> Date: Fri, 31 Mar 2023 03:33:39 +0300 Subject: [PATCH] add overlay parameter to control x/y separation in auto-scale mode (#15106) --- input/input_driver.c | 15 +++++---------- input/input_overlay.h | 4 +++- tasks/task_overlay.c | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index fc79097e2d..31ef1fe2a3 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -1750,9 +1750,9 @@ static void input_overlay_parse_layout( return; } - /* If X separation is permitted, move elements + /* If auto-scale X separation is enabled, move elements * horizontally towards the edges of the screen */ - if (!(ol->flags & OVERLAY_BLOCK_X_SEPARATION)) + if (ol->flags & OVERLAY_AUTO_X_SEPARATION) overlay_layout->x_separation = ((1.0f / overlay_layout->x_scale) - 1.0f) * 0.5f; } /* If display is taller than overlay, @@ -1768,14 +1768,9 @@ static void input_overlay_parse_layout( return; } - /* If Y separation is permitted and display has - * a *landscape* orientation, move elements - * vertically towards the edges of the screen - * > Portrait overlays typically have all elements - * below the centre line, so Y separation - * provides no real benefit */ - if ((display_aspect_ratio > 1.0f) && - !(ol->flags & OVERLAY_BLOCK_Y_SEPARATION)) + /* If auto-scale Y separation is enabled, move elements + * vertically towards the edges of the screen */ + if (ol->flags & OVERLAY_AUTO_Y_SEPARATION) overlay_layout->y_separation = ((1.0f / overlay_layout->y_scale) - 1.0f) * 0.5f; } diff --git a/input/input_overlay.h b/input/input_overlay.h index 45748d9851..7c29292ba6 100644 --- a/input/input_overlay.h +++ b/input/input_overlay.h @@ -141,7 +141,9 @@ enum OVERLAY_FLAGS OVERLAY_FULL_SCREEN = (1 << 0), OVERLAY_BLOCK_SCALE = (1 << 1), OVERLAY_BLOCK_X_SEPARATION = (1 << 2), - OVERLAY_BLOCK_Y_SEPARATION = (1 << 3) + OVERLAY_BLOCK_Y_SEPARATION = (1 << 3), + OVERLAY_AUTO_X_SEPARATION = (1 << 4), + OVERLAY_AUTO_Y_SEPARATION = (1 << 5) }; enum OVERLAY_DESC_FLAGS diff --git a/tasks/task_overlay.c b/tasks/task_overlay.c index 20ba577431..e6c778af98 100644 --- a/tasks/task_overlay.c +++ b/tasks/task_overlay.c @@ -860,6 +860,30 @@ static void task_overlay_deferred_load(retro_task_t *task) if (config_get_bool(conf, conf_key, &tmp_bool) && tmp_bool) overlay->flags |= OVERLAY_BLOCK_Y_SEPARATION; + + /* Check whether x/y separation are enabled + * for this overlay in auto-scale mode */ + snprintf(conf_key, sizeof(conf_key), + "overlay%u_auto_x_separation", loader->pos); + overlay->flags |= OVERLAY_AUTO_X_SEPARATION; + if (config_get_bool(conf, conf_key, &tmp_bool)) + { + if (!tmp_bool) + overlay->flags &= ~OVERLAY_AUTO_X_SEPARATION; + } + else + { + if (overlay->flags & OVERLAY_BLOCK_X_SEPARATION + || overlay->image.width != 0) + overlay->flags &= ~OVERLAY_AUTO_X_SEPARATION; + } + + snprintf(conf_key, sizeof(conf_key), + "overlay%u_auto_y_separation", loader->pos); + overlay->flags &= ~OVERLAY_AUTO_Y_SEPARATION; + if (config_get_bool(conf, conf_key, &tmp_bool) + && tmp_bool) + overlay->flags |= OVERLAY_AUTO_Y_SEPARATION; } return;