| 122 | } |
| 123 | |
| 124 | std::string KeyboardManager::text(const std::string& suggestion, const std::string& hint, size_t maxLen) |
| 125 | { |
| 126 | if (!systemKeyboardAvailable || maxLen == 0) { |
| 127 | return ""; |
| 128 | } |
| 129 | |
| 130 | // Same PauseGuard rationale as keyboard(): the size-cache walk delays the |
| 131 | // swkbd applet launch by the walk's full remaining duration. |
| 132 | BackupSizeCache::PauseGuard pauseWalk; |
| 133 | SwkbdConfig kbd; |
| 134 | std::string out; |
| 135 | if (R_SUCCEEDED(swkbdCreate(&kbd, 0))) { |
| 136 | swkbdConfigMakePresetDefault(&kbd); |
| 137 | swkbdConfigSetGuideText(&kbd, hint.c_str()); |
| 138 | swkbdConfigSetInitialText(&kbd, suggestion.c_str()); |
| 139 | swkbdConfigSetStringLenMax(&kbd, maxLen); |
| 140 | std::vector<char> buf(maxLen * 4 + 1, 0); // UTF-8 worst case per char |
| 141 | Result rc = swkbdShow(&kbd, buf.data(), buf.size()); |
| 142 | swkbdClose(&kbd); |
| 143 | if (R_SUCCEEDED(rc)) { |
| 144 | out = buf.data(); |
| 145 | } |
| 146 | } |
| 147 | return out; |
| 148 | } |