diff --git a/src/core/config.cpp b/src/core/config.cpp index 81b918b09..f10b22fe6 100644 --- a/src/core/config.cpp +++ b/src/core/config.cpp @@ -22,6 +22,7 @@ JsonDocument BruceConfig::toJson() const { setting["soundVolume"] = soundVolume; setting["wifiAtStartup"] = wifiAtStartup; setting["instantBoot"] = instantBoot; + setting["keyboardLang"] = keyboardLang; #ifdef HAS_RGB_LED setting["ledBright"] = ledBright; @@ -208,6 +209,11 @@ void BruceConfig::fromFile(bool checkFS) { count++; log_e("Fail"); } + if (!setting["keyboardLang"].isNull()) { + keyboardLang = setting["keyboardLang"].as(); + } else { + keyboardLang = "QWERTY"; + } #ifdef HAS_RGB_LED if (!setting["ledBright"].isNull()) { diff --git a/src/core/config.h b/src/core/config.h index 04fa143dc..1aeea72ce 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -46,6 +46,7 @@ class BruceConfig : public BruceTheme { int soundVolume = 100; int wifiAtStartup = 0; int instantBoot = 0; + String keyboardLang = "QWERTY"; // "QWERTY" | "AZERTY" | "QWERTZ" #ifdef HAS_RGB_LED // Led diff --git a/src/core/menu_items/ConfigMenu.cpp b/src/core/menu_items/ConfigMenu.cpp index 53cdf25e9..2b606096f 100644 --- a/src/core/menu_items/ConfigMenu.cpp +++ b/src/core/menu_items/ConfigMenu.cpp @@ -5,6 +5,7 @@ #include "core/settings.h" #include "core/utils.h" #include "core/wifi/wifi_common.h" +#include "../mykeyboard.h" #ifdef HAS_RGB_LED #include "core/led_control.h" #endif @@ -169,6 +170,7 @@ void ConfigMenu::systemMenu() { {"Startup App", [this]() { setStartupApp(); } }, {"Hide/Show Apps", [this]() { mainMenu.hideAppsMenu(); }}, {"Clock", [this]() { setClock(); } }, + {String("Keyboard Language: ") + bruceConfig.keyboardLang, [this]() { setKeyboardLanguage(); } }, {"Advanced", [this]() { advancedMenu(); } }, {"Back", []() {} }, }; diff --git a/src/core/mykeyboard.cpp b/src/core/mykeyboard.cpp index e55f49790..d831da20c 100644 --- a/src/core/mykeyboard.cpp +++ b/src/core/mykeyboard.cpp @@ -66,6 +66,122 @@ char qwerty_keyset[qwerty_keyboard_height][qwerty_keyboard_width][2] = { {'/', '/'} } }; +// AZERTY KEYSET (French) +const int azerty_keyboard_width = 12; +const int azerty_keyboard_height = 4; +char azerty_keyset[azerty_keyboard_height][azerty_keyboard_width][2] = { + // Row 1: numbers / symbols + {{'1', '&'}, + {'2', '\xc3'}, // é + {'3', '"'}, + {'4', '\''}, + {'5', '('}, + {'6', '-'}, + {'7', '\xe8'}, // è + {'8', '_'}, + {'9', '\xe7'}, // ç + {'0', '\xe0'}, // à + {')', '\xb0'}, + {'=', '+'} }, + // Row 2: AZERTY row + {{'a', 'A'}, + {'z', 'Z'}, + {'e', 'E'}, + {'r', 'R'}, + {'t', 'T'}, + {'y', 'Y'}, + {'u', 'U'}, + {'i', 'I'}, + {'o', 'O'}, + {'p', 'P'}, + {'.', '\xa8'}, // ^ / ¨ + {'$', '\xa3'} },// $ / £ + // Row 3: QSDFGH row + {{'q', 'Q'}, + {'s', 'S'}, + {'d', 'D'}, + {'f', 'F'}, + {'g', 'G'}, + {'h', 'H'}, + {'j', 'J'}, + {'k', 'K'}, + {'l', 'L'}, + {'m', 'M'}, + {'\xf9', '%'}, // ù / % + {'*', '\xb5'} },// * / µ + // Row 4: WXCVBN row + {{'<', '>'}, + {'w', 'W'}, + {'x', 'X'}, + {'c', 'C'}, + {'v', 'V'}, + {'b', 'B'}, + {'n', 'N'}, + {',', '?'}, + {';', '.'}, + {':', '/'}, + {'!', '\xa7'}, // ! / § + {'-', '_'} } +}; + +// QWERTZ KEYSET (German) +const int qwertz_keyboard_width = 12; +const int qwertz_keyboard_height = 4; +char qwertz_keyset[qwertz_keyboard_height][qwertz_keyboard_width][2] = { + // Row 1 + {{'1', '!'}, + {'2', '"'}, + {'3', '\xa7'}, // § + {'4', '$'}, + {'5', '%'}, + {'6', '&'}, + {'7', '/'}, + {'8', '('}, + {'9', ')'}, + {'0', '='}, + {'\xdf', '?'}, // ß / ? + {'\'', '`'} }, + // Row 2: QWERTZ row + {{'q', 'Q'}, + {'w', 'W'}, + {'e', 'E'}, + {'r', 'R'}, + {'t', 'T'}, + {'z', 'Z'}, + {'u', 'U'}, + {'i', 'I'}, + {'o', 'O'}, + {'p', 'P'}, + {'\xfc', '\xdc'}, // ü / Ü + {'+', '*'} }, + // Row 3: ASDF row + {{'a', 'A'}, + {'s', 'S'}, + {'d', 'D'}, + {'f', 'F'}, + {'g', 'G'}, + {'h', 'H'}, + {'j', 'J'}, + {'k', 'K'}, + {'l', 'L'}, + {'\xf6', '\xd6'}, // ö / Ö + {'\xe4', '\xc4'}, // ä / Ä + {'#', '\''}}, + // Row 4: YXCVBN row + {{'<', '>'}, + {'y', 'Y'}, + {'x', 'X'}, + {'c', 'C'}, + {'v', 'V'}, + {'b', 'B'}, + {'n', 'N'}, + {'m', 'M'}, + {',', ';'}, + {'.', ':'}, + {'-', '_'}, + {'/', '/'} } +}; + // HEX KEYSET const int hex_keyboard_width = 4; const int hex_keyboard_height = 4; @@ -1095,12 +1211,40 @@ String generalKeyboard( return current_text; } -/// This calls the QWERTY keyboard. Returns the user typed strings, return the ASCII ESC character -/// if the operation was cancelled +/// Opens a simple option menu to select the keyboard layout/language. +/// The choice is stored in bruceConfig.keyboardLang and saved to flash. +void setKeyboardLanguage() { + std::vector