diff --git a/source/core/input/input.cpp b/source/core/input/input.cpp index e0e9e67..670e3c7 100644 --- a/source/core/input/input.cpp +++ b/source/core/input/input.cpp @@ -10,6 +10,7 @@ #include "core/locale/locale.hpp" #include "core/system/notifier.hpp" +#include "core/utils/string_utils.hpp" // Singleton Input* Input::instance = nullptr; @@ -417,7 +418,7 @@ auto Input::addGamepad(int device_index) -> std::string { notifier->notifyInfo(localeSubstitute( Locale::get().text("notification.gamepad_connected"), "{name}", - name)); + Utils::toUpperAscii(name))); } return name + " CONNECTED"; @@ -437,7 +438,7 @@ auto Input::removeGamepad(SDL_JoystickID id) -> std::string { notifier->notifyInfo(localeSubstitute( Locale::get().text("notification.gamepad_disconnected"), "{name}", - name)); + Utils::toUpperAscii(name))); } return name + " DISCONNECTED"; diff --git a/source/core/system/service_menu.cpp b/source/core/system/service_menu.cpp index 8575680..2dc6f25 100644 --- a/source/core/system/service_menu.cpp +++ b/source/core/system/service_menu.cpp @@ -23,6 +23,7 @@ #include "core/system/notifier.hpp" #include "core/system/relaunch.hpp" #include "core/types.hpp" +#include "core/utils/string_utils.hpp" #include "game/config_yaml.hpp" #include "project.h" @@ -57,17 +58,6 @@ namespace { } } - // VectorText nomes admet ASCII en majuscules. El git hash sortit de git - // rev-parse es lowercase (a-f), aixi que el passem a uppercase per al - // display sense modificar Project::GIT_HASH. - auto toUpperAscii(const std::string& s) -> std::string { - std::string result = s; - for (char& c : result) { - c = static_cast(std::toupper(static_cast(c))); - } - return result; - } - // Resol el text del label d'un item: prioritza label_text (literal) sobre // label_key (locale). Retorna cadena buida si tots dos son buits. auto resolveLabel(const System::ServiceMenu::Item& item) -> std::string { @@ -91,7 +81,7 @@ namespace { if (!pad) { return Locale::get().text("service_menu.controls_no_pad"); } - return pad->name; + return Utils::toUpperAscii(pad->name); } // Index actual del pad assignat dins de la llista de mandos detectats. @@ -582,7 +572,7 @@ namespace System { // Versio + hash com a subtitol sota el titol (apagat, mes petit). // Uppercase del hash perque VectorText nomes admet majuscules. page.subtitle_provider = [] { - return std::format("V{} - {}", Project::VERSION, toUpperAscii(Project::GIT_HASH)); + return std::format("V{} - {}", Project::VERSION, Utils::toUpperAscii(Project::GIT_HASH)); }; page.items = { // REINICIAR (amb confirmacio). diff --git a/source/core/utils/string_utils.hpp b/source/core/utils/string_utils.hpp new file mode 100644 index 0000000..157a963 --- /dev/null +++ b/source/core/utils/string_utils.hpp @@ -0,0 +1,23 @@ +// string_utils.hpp - Utilitats genèriques de cadenes +// © 2026 JailDesigner +// +// VectorText només admet ASCII en majúscules; les notificacions, el menú +// de servei i l'overlay de rebind passen els textos dinàmics per aquest +// helper abans de pintar-los. + +#pragma once + +#include +#include + +namespace Utils { + + inline auto toUpperAscii(const std::string& s) -> std::string { + std::string result = s; + for (char& c : result) { + c = static_cast(std::toupper(static_cast(c))); + } + return result; + } + +} // namespace Utils