refactor: use convStringToWstring for text input instead of uint16 helpers

GetText now returns UTF-8 directly so callers go through simdutf via
convStringToWstring(). Remove dead uint16_to_wstring helpers.
This commit is contained in:
MatthewBeshay 2026-03-30 14:10:14 +11:00
parent e89198f56c
commit 95e0a14b36
9 changed files with 19 additions and 59 deletions

View file

@ -298,11 +298,9 @@ int UIScene_AnvilMenu::KeyboardCompleteCallback(void* lpParam, bool bRes) {
pClass->setIgnoreInput(false); pClass->setIgnoreInput(false);
if (bRes) { if (bRes) {
uint16_t pchText[128]; std::wstring str = convStringToWstring(InputManager.GetText());
ZeroMemory(pchText, 128 * sizeof(uint16_t)); pClass->setEditNameValue(str);
InputManager.GetText(pchText); pClass->m_itemName = std::move(str);
pClass->setEditNameValue(uint16_to_wstring(pchText));
pClass->m_itemName = uint16_to_wstring(pchText);
pClass->updateItemName(); pClass->updateItemName();
} }
return 0; return 0;

View file

@ -718,13 +718,10 @@ int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(void* lpParam,
pClass->m_bIgnoreInput = false; pClass->m_bIgnoreInput = false;
// 4J HEG - No reason to set value if keyboard was cancelled // 4J HEG - No reason to set value if keyboard was cancelled
if (bRes) { if (bRes) {
uint16_t pchText[128]; std::wstring str = convStringToWstring(InputManager.GetText());
ZeroMemory(pchText, 128 * sizeof(uint16_t)); if (!str.empty()) {
InputManager.GetText(pchText); pClass->m_editWorldName.setLabel(str);
pClass->m_worldName = std::move(str);
if (pchText[0] != 0) {
pClass->m_editWorldName.setLabel(uint16_to_wstring(pchText));
pClass->m_worldName = uint16_to_wstring(pchText);
} }
pClass->m_buttonCreateWorld.setEnable(!pClass->m_worldName.empty()); pClass->m_buttonCreateWorld.setEnable(!pClass->m_worldName.empty());

View file

@ -141,12 +141,9 @@ int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(void* lpParam,
UIScene_DebugCreateSchematic* pClass = UIScene_DebugCreateSchematic* pClass =
(UIScene_DebugCreateSchematic*)lpParam; (UIScene_DebugCreateSchematic*)lpParam;
uint16_t pchText[128]; const char* text = InputManager.GetText();
ZeroMemory(pchText, 128 * sizeof(uint16_t)); if (text[0] != '\0') {
InputManager.GetText(pchText); std::wstring value = convStringToWstring(text);
if (pchText[0] != 0) {
std::wstring value = uint16_to_wstring(pchText);
int iVal = 0; int iVal = 0;
if (!value.empty()) iVal = _fromString<int>(value); if (!value.empty()) iVal = _fromString<int>(value);
switch (pClass->m_keyboardCallbackControl) { switch (pClass->m_keyboardCallbackControl) {

View file

@ -119,12 +119,9 @@ void UIScene_DebugSetCamera::handleCheckboxToggled(F64 controlId,
int UIScene_DebugSetCamera::KeyboardCompleteCallback(void* lpParam, bool bRes) { int UIScene_DebugSetCamera::KeyboardCompleteCallback(void* lpParam, bool bRes) {
UIScene_DebugSetCamera* pClass = (UIScene_DebugSetCamera*)lpParam; UIScene_DebugSetCamera* pClass = (UIScene_DebugSetCamera*)lpParam;
uint16_t pchText[2048]; //[128]; const char* text = InputManager.GetText();
ZeroMemory(pchText, 2048 /*128*/ * sizeof(uint16_t)); if (text[0] != '\0') {
InputManager.GetText(pchText); std::wstring value = convStringToWstring(text);
if (pchText[0] != 0) {
std::wstring value = uint16_to_wstring(pchText);
double val = 0; double val = 0;
if (!value.empty()) val = _fromString<double>(value); if (!value.empty()) val = _fromString<double>(value);
switch (pClass->m_keyboardCallbackControl) { switch (pClass->m_keyboardCallbackControl) {

View file

@ -592,17 +592,9 @@ int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback(void* lpParam,
(UIScene_LaunchMoreOptionsMenu*)lpParam; (UIScene_LaunchMoreOptionsMenu*)lpParam;
// 4J HEG - No reason to set value if keyboard was cancelled // 4J HEG - No reason to set value if keyboard was cancelled
if (bRes) { if (bRes) {
#ifdef __PSVITA__ std::wstring str = convStringToWstring(InputManager.GetText());
// CD - Changed to 2048 [SCE_IME_MAX_TEXT_LENGTH] pClass->m_editSeed.setLabel(str);
uint16_t pchText[2048]; pClass->m_params->seed = std::move(str);
ZeroMemory(pchText, 2048 * sizeof(uint16_t));
#else
uint16_t pchText[128];
ZeroMemory(pchText, 128 * sizeof(uint16_t));
#endif
InputManager.GetText(pchText);
pClass->m_editSeed.setLabel(uint16_to_wstring(pchText));
pClass->m_params->seed = uint16_to_wstring(pchText);
} }
pClass->m_bIgnoreInput = false; pClass->m_bIgnoreInput = false;
return 0; return 0;

View file

@ -1177,12 +1177,9 @@ int UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback(void* lpParam,
UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)lpParam; UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)lpParam;
pClass->m_bIgnoreInput = false; pClass->m_bIgnoreInput = false;
if (bRes) { if (bRes) {
std::uint16_t ui16Text[128]; const char* text = InputManager.GetText();
ZeroMemory(ui16Text, 128 * sizeof(std::uint16_t));
InputManager.GetText(ui16Text);
// check the name is valid // check the name is valid
if (ui16Text[0] != 0) { if (text[0] != '\0') {
#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \ #if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \
defined(__PSVITA__)) defined(__PSVITA__))
// open the save and overwrite the metadata // open the save and overwrite the metadata

View file

@ -143,10 +143,7 @@ int UIScene_SignEntryMenu::KeyboardCompleteCallback(void* lpParam, bool bRes) {
UIScene_SignEntryMenu* pClass = (UIScene_SignEntryMenu*)lpParam; UIScene_SignEntryMenu* pClass = (UIScene_SignEntryMenu*)lpParam;
pClass->m_bIgnoreInput = false; pClass->m_bIgnoreInput = false;
if (bRes && pClass->m_iEditingLine >= 0 && pClass->m_iEditingLine < 4) { if (bRes && pClass->m_iEditingLine >= 0 && pClass->m_iEditingLine < 4) {
uint16_t pchText[128]; std::wstring str = convStringToWstring(InputManager.GetText());
ZeroMemory(pchText, 128 * sizeof(uint16_t));
InputManager.GetText(pchText);
std::wstring str = uint16_to_wstring(pchText);
if (str.size() > 15) str.resize(15); if (str.size() > 15) str.resize(15);
pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(str); pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(str);
} }

View file

@ -36,18 +36,6 @@ bool equalsIgnoreCase(const std::wstring& a, const std::wstring& b) {
return out; return out;
} }
size_t uint16_len(const uint16_t* str) {
return std::char_traits<char16_t>::length(
reinterpret_cast<const char16_t*>(str));
}
std::u16string uint16_to_u16string(const uint16_t* str) {
return std::u16string(reinterpret_cast<const char16_t*>(str), uint16_len(str));
}
std::wstring uint16_to_wstring(const uint16_t* str) {
return u16string_to_wstring(uint16_to_u16string(str));
}
std::wstring convStringToWstring(const std::string& converting) { std::wstring convStringToWstring(const std::string& converting) {
std::wstring converted(converting.length(), L' '); std::wstring converted(converting.length(), L' ');

View file

@ -29,9 +29,6 @@ T _fromHEXString(const std::wstring& s) {
return t; return t;
} }
size_t uint16_len(const uint16_t* str);
std::u16string uint16_to_u16string(const uint16_t* str);
std::wstring uint16_to_wstring(const uint16_t* str);
std::wstring convStringToWstring(const std::string& converting); std::wstring convStringToWstring(const std::string& converting);
std::wstring u16string_to_wstring(const std::u16string& converting); std::wstring u16string_to_wstring(const std::u16string& converting);