fix: resolve 6 cppcheck low-style warnings in keyboard code

This commit is contained in:
pablohc
2026-04-12 23:08:50 +02:00
committed by jpirnay
parent 1d2584465d
commit 74a3fbd5db
3 changed files with 10 additions and 11 deletions
@@ -15,7 +15,7 @@ void KeyboardEntryActivity::onEnter() {
void KeyboardEntryActivity::onExit() { Activity::onExit(); }
int KeyboardEntryActivity::getContentRowCount() const { return symMode ? SYM_ROWS : ABC_ROWS; }
int KeyboardEntryActivity::getContentRowCount() const { return ABC_ROWS; }
int KeyboardEntryActivity::getTotalRowCount() const { return getContentRowCount() + 1; }
@@ -240,8 +240,8 @@ void KeyboardEntryActivity::render(RenderLock&&) {
secondaryChar = key.primary;
}
char primaryBuf[2] = {primaryChar, '\0'};
char secondaryBuf[2] = {secondaryChar, '\0'};
const char primaryBuf[2] = {primaryChar, '\0'};
const char secondaryBuf[2] = {secondaryChar, '\0'};
const bool showSecondary = !symMode && row == 0 && secondaryChar != '\0';
GUI.drawKeyboardKey(renderer, Rect{keyX, rowY, keyWidth, keyHeight}, primaryBuf, isSelected,
@@ -257,16 +257,15 @@ void KeyboardEntryActivity::render(RenderLock&&) {
const int bottomSelectedRow = isBottomRow(selectedRow);
struct BottomKeyInfo {
SpecialKeyType type;
KeyboardKeyType themeType;
const char* label;
};
const BottomKeyInfo bottomKeys[BOTTOM_KEY_COUNT] = {
{SpecShift, KeyboardKeyType::Shift, symMode ? shiftString[0] : shiftString[shiftState]},
{SpecMode, KeyboardKeyType::Mode, symMode ? "abc" : "#@!"},
{SpecSpace, KeyboardKeyType::Space, nullptr},
{SpecDel, KeyboardKeyType::Del, nullptr},
{SpecOk, KeyboardKeyType::Ok, tr(STR_OK_BUTTON)},
{KeyboardKeyType::Shift, symMode ? shiftString[0] : shiftString[shiftState]},
{KeyboardKeyType::Mode, symMode ? "abc" : "#@!"},
{KeyboardKeyType::Space, nullptr},
{KeyboardKeyType::Del, nullptr},
{KeyboardKeyType::Ok, tr(STR_OK_BUTTON)},
};
for (int i = 0; i < BOTTOM_KEY_COUNT; i++) {
+1 -1
View File
@@ -910,7 +910,7 @@ void BaseTheme::drawKeyboardKey(const GfxRenderer& renderer, Rect rect, const ch
}
const bool hasSecondary = secondaryLabel != nullptr && secondaryLabel[0] != '\0';
const int primaryOffset = hasSecondary ? 0 : 0;
const int primaryOffset = 0;
const int itemWidth = renderer.getTextWidth(UI_12_FONT_ID, label);
const int textX = rect.x + (rect.width - itemWidth) / 2;
const int textY = rect.y + (rect.height - renderer.getLineHeight(UI_12_FONT_ID)) / 2 + primaryOffset;
+1 -1
View File
@@ -829,7 +829,7 @@ void LyraTheme::drawKeyboardKey(const GfxRenderer& renderer, Rect rect, const ch
}
const bool hasSecondary = secondaryLabel != nullptr && secondaryLabel[0] != '\0';
const int primaryOffset = hasSecondary ? 0 : 0;
const int primaryOffset = 0;
const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, label);
const int textX = rect.x + (rect.width - textWidth) / 2;
const int textY = rect.y + (rect.height - renderer.getLineHeight(UI_12_FONT_ID)) / 2 + primaryOffset;