diff --git a/app/include/keyboard_view.hpp b/app/include/keyboard_view.hpp index 72fbfb8..181f8f8 100644 --- a/app/include/keyboard_view.hpp +++ b/app/include/keyboard_view.hpp @@ -8,6 +8,7 @@ #pragma once #include +#include enum KeyboardKeys { @@ -25,6 +26,7 @@ enum KeyboardKeys struct KeyboardLocale { std::string name; std::string localization[_VK_KEY_MAX][2]; + std::map keyMapper; }; struct KeyboardState { @@ -56,6 +58,7 @@ class ButtonView : public brls::Box { bool focusJustGained = false; void applyTitle(); + KeyboardLocale getCurrentLocale(); KeyboardView* keyboardView; }; diff --git a/app/src/keyboard_view.cpp b/app/src/keyboard_view.cpp index 8d472c9..8bb24da 100644 --- a/app/src/keyboard_view.cpp +++ b/app/src/keyboard_view.cpp @@ -135,11 +135,7 @@ void ButtonView::onFocusLost() { } } -void ButtonView::applyTitle() { - if (dummy) - return; - - bool shifted = keysState[VK_RSHIFT]; +KeyboardLocale ButtonView::getCurrentLocale() { int selectedLang = keyboardView->keyboardLangLock != -1 ? keyboardView->keyboardLangLock : Settings::instance().get_keyboard_locale(); @@ -147,16 +143,31 @@ void ButtonView::applyTitle() { Settings::instance().set_keyboard_locale(0); selectedLang = 0; } - charLabel->setText( - KeyboardView::getLocales()[selectedLang].localization[key][shifted]); + + return KeyboardView::getLocales()[selectedLang]; +} + +void ButtonView::applyTitle() { + if (dummy) + return; + + bool shifted = keysState[VK_RSHIFT]; + auto selectedLang = getCurrentLocale(); + charLabel->setText(selectedLang.localization[key][shifted]); } void ButtonView::setKey(KeyboardKeys key) { + auto selectedLang = getCurrentLocale(); + KeyboardKeys mappedKey = key; + if (selectedLang.keyMapper.contains(key)) { + mappedKey = selectedLang.keyMapper[key]; + } + this->dummy = false; - this->key = key; + this->key = mappedKey; this->applyTitle(); - if (keysState[key]) + if (keysState[mappedKey]) this->playClickAnimation(false, false, true); } diff --git a/app/src/keyboards/keyboard_locales.cpp b/app/src/keyboards/keyboard_locales.cpp index 8fa8a75..ed6c57e 100644 --- a/app/src/keyboards/keyboard_locales.cpp +++ b/app/src/keyboards/keyboard_locales.cpp @@ -37,5 +37,23 @@ void KeyboardView::createLocales() { } }); + locales.push_back(KeyboardLocale{ + .name = "French", + .localization = { + {"Remove", "Remove"}, {"Esc", "Esc"}, {"à", "0"}, {"&", "1"}, {"é", "2"}, {"\"", "3"}, {"'", "4"}, {"(", "5"}, {"-", "6"}, + {"è", "7"}, {"_", "8"}, {"ç", "9"}, {"a", "A"}, {"b", "B"}, {"c", "C"}, {"d", "D"}, {"e", "E"}, {"f", "F"}, {"g", "G"}, + {"h", "H"}, {"i", "I"}, {"j", "J"}, {"k", "K"}, {"l", "L"}, {"m", "M"}, {"n", "N"}, {"o", "O"}, {"p", "P"}, {"q", "Q"}, + {"r", "R"}, {"s", "S"}, {"t", "T"}, {"u", "U"}, {"v", "V"}, {"w", "W"}, {"x", "X"}, {"y", "Y"}, {"z", "Z"}, {"Return", "Return"}, {"Space", "Space"}, + {"Ctrl", "Ctrl"}, {"Alt", "Alt"}, {"Shift", "Shift"}, {"Win", "Win"}, {",", "?"}, {";", "."}, {"F1", "F1"}, {"F2", "F2"}, {"F3", "F3"}, {"F4", "F4"}, + {"F5", "F5"}, {"F6", "F6"}, {"F7", "F7"}, {"F8", "F8"}, {"F9", "F9"}, {"F10", "F10"}, {"F11", "F11"}, {"F12", "F12"}, {"Tab", "Tab"}, {"Delete", "Delete"}, + {"!", "§"}, {":", "/"}, {"<", ">"}, {"ù", "%"}, {"*", "μ"}, {"=", "+"}, {")", "°"}, {"^", "¨"}, {"$", "£"}, {"\u2193", "\u2193"}, + {"\u2190", "\u2190"}, {"\u2192", "\u2192"}, {"\u2191", "\u2191"}, {"CapsLock", "CapsLock"}, + }, + .keyMapper = {{VK_OEM_MINUS, VK_OEM_7}, {VK_OEM_PLUS, VK_OEM_6}, + {VK_KEY_Q, VK_KEY_A}, {VK_KEY_W, VK_KEY_Z}, {VK_OEM_4, VK_OEM_MINUS}, {VK_OEM_6, VK_OEM_PLUS}, + {VK_KEY_A, VK_KEY_Q}, {VK_OEM_1, VK_KEY_M}, {VK_OEM_7, VK_OEM_4}, + {VK_KEY_Z, VK_KEY_W}, {VK_KEY_M, VK_OEM_PERIOD}, {VK_OEM_PERIOD, VK_OEM_2}, {VK_OEM_2, VK_OEM_1}} + }); + // TODO: - Add more languages }