* Retrieve keyboard layout from language string or (if set) config file. * Also check for invalid characters. */
| 350 | * Also check for invalid characters. |
| 351 | */ |
| 352 | void GetKeyboardLayout() |
| 353 | { |
| 354 | std::string keyboard[2]; |
| 355 | std::string errormark[2]; // used for marking invalid chars |
| 356 | bool has_error = false; // true when an invalid char is detected |
| 357 | |
| 358 | keyboard[0] = _keyboard_opt[0].empty() ? GetString(STR_OSK_KEYBOARD_LAYOUT) : _keyboard_opt[0]; |
| 359 | keyboard[1] = _keyboard_opt[1].empty() ? GetString(STR_OSK_KEYBOARD_LAYOUT_CAPS) : _keyboard_opt[1]; |
| 360 | |
| 361 | for (uint j = 0; j < 2; j++) { |
| 362 | StringConsumer consumer(keyboard[j]); |
| 363 | for (uint i = 0; i < OSK_KEYBOARD_ENTRIES; i++) { |
| 364 | /* Be lenient when the last characters are missing (is quite normal) */ |
| 365 | _keyboard[j][i] = consumer.AnyBytesLeft() ? consumer.ReadUtf8() : ' '; |
| 366 | |
| 367 | if (IsPrintable(_keyboard[j][i])) { |
| 368 | errormark[j] += ' '; |
| 369 | } else { |
| 370 | has_error = true; |
| 371 | errormark[j] += '^'; |
| 372 | _keyboard[j][i] = ' '; |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | if (has_error) { |
| 378 | ShowInfo("The keyboard layout you selected contains invalid chars. Please check those chars marked with ^."); |
| 379 | ShowInfo("Normal keyboard: {}", keyboard[0]); |
| 380 | ShowInfo(" {}", errormark[0]); |
| 381 | ShowInfo("Caps Lock: {}", keyboard[1]); |
| 382 | ShowInfo(" {}", errormark[1]); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * Show the on-screen keyboard (osk) associated with a given textbox |
no test coverage detected