From f3cb2bff7883a85e61df0639dcc6e8f1067b53cb Mon Sep 17 00:00:00 2001 From: BJK <58904384+Bjk8kds@users.noreply.github.com> Date: Thu, 21 May 2026 18:12:34 +0700 Subject: [PATCH] Refactor keyboard cell height logic for consistency (#10501) Adjust keyboard cell height calculation for better layout consistency across different screen sizes. Co-authored-by: Ben Meadors --- src/graphics/VirtualKeyboard.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/graphics/VirtualKeyboard.cpp b/src/graphics/VirtualKeyboard.cpp index 52f0195b3..43b33e853 100644 --- a/src/graphics/VirtualKeyboard.cpp +++ b/src/graphics/VirtualKeyboard.cpp @@ -142,8 +142,9 @@ void VirtualKeyboard::draw(OLEDDisplay *display, int16_t offsetX, int16_t offset if (keyboardStartY < 0) keyboardStartY = 0; } else { - // Default (non-wide, non-64px) behavior: use key height heuristic and place at bottom - cellH = KEY_HEIGHT; + // Default (non-wide, non-64px) e.g. SH1107 128x128: + // cellH = FONT_HEIGHT_SMALL - 2 so rows are tighter while still hosting the font + cellH = std::max((int)KEY_HEIGHT, FONT_HEIGHT_SMALL - 2); int keyboardHeight = KEYBOARD_ROWS * cellH; keyboardStartY = screenH - keyboardHeight; if (keyboardStartY < 0) @@ -446,11 +447,8 @@ void VirtualKeyboard::drawKey(OLEDDisplay *display, const VirtualKey &key, bool if (textX < x) textX = x; // guard } else { - if (display->getHeight() <= 64 && (key.character >= '0' && key.character <= '9')) { - textX = x + (width - textWidth + 1) / 2; - } else { - textX = x + (width - textWidth) / 2; - } + // Use ceil rounding for all screens (consistent with 128x64 behavior for numbers) + textX = x + (width - textWidth + 1) / 2; } int contentTop = y; int contentH = height; @@ -746,4 +744,4 @@ bool VirtualKeyboard::isTimedOut() const } } // namespace graphics -#endif \ No newline at end of file +#endif