From 76e3d2435ee3b3ffebf37d37dce71b728f44a684 Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Thu, 12 Feb 2026 23:27:48 -0500 Subject: [PATCH] Make game name search case-insensitive Serial uploader searches for games by filename (e.g., "tetris") but games are registered by their metadata NAME field (e.g., "Tetris"). This caused launch failures when case didn't match. Changed select_game_by_name() to use case-insensitive matching: - strcasecmp() for exact match - tolower() both strings before strstr() for partial match Now uploading "tetris.lua" will successfully match and launch "Tetris". Co-Authored-By: Claude --- lib/game_launcher.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/game_launcher.cpp b/lib/game_launcher.cpp index 646a258..b203e0a 100644 --- a/lib/game_launcher.cpp +++ b/lib/game_launcher.cpp @@ -9,6 +9,7 @@ #include "display/low_level_gui.h" #include #include +#include GameLauncher::GameLauncher(uint16_t width, uint16_t height, LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager) @@ -235,9 +236,9 @@ bool GameLauncher::select_game_by_name(const char* name) { selected_game = nullptr; } - // First pass: search for exact match (prefer exact matches) + // First pass: search for exact match (case-insensitive) for (size_t i = 0; i < games.size(); i++) { - if (strcmp(games[i].name, name) == 0) { + if (strcasecmp(games[i].name, name) == 0) { printf("Found exact match: %s\n", games[i].name); // Create and initialize the game @@ -255,9 +256,27 @@ bool GameLauncher::select_game_by_name(const char* name) { } } - // Second pass: search in reverse order for partial match (newest files first) + // Second pass: search in reverse order for partial match (case-insensitive, newest files first) for (int i = games.size() - 1; i >= 0; i--) { - if (strstr(games[i].name, name) != nullptr) { + // Convert both strings to lowercase for comparison + char game_name_lower[256]; + char search_name_lower[256]; + + strncpy(game_name_lower, games[i].name, sizeof(game_name_lower) - 1); + game_name_lower[sizeof(game_name_lower) - 1] = '\0'; + + strncpy(search_name_lower, name, sizeof(search_name_lower) - 1); + search_name_lower[sizeof(search_name_lower) - 1] = '\0'; + + // Convert to lowercase + for (size_t j = 0; game_name_lower[j]; j++) { + game_name_lower[j] = tolower(game_name_lower[j]); + } + for (size_t j = 0; search_name_lower[j]; j++) { + search_name_lower[j] = tolower(search_name_lower[j]); + } + + if (strstr(game_name_lower, search_name_lower) != nullptr) { printf("Found partial match: %s (searching for: %s)\n", games[i].name, name); // Create and initialize the game