summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcelo Fernandez <marcelofg55@gmail.com>2017-10-30 11:40:42 -0300
committerMarcelo Fernandez <marcelofg55@gmail.com>2017-10-30 12:14:40 -0300
commitbe6ac69f75acb1114de439fbe70e7636850c2211 (patch)
tree99fd9ee3c5ce13d04d490f36e680737c115e1b51
parentfd89924ea55209ff4b1353d2b91bd019cbbbcb11 (diff)
Implemented OS get_latin_keyboard_variant on x11
-rw-r--r--platform/x11/os_x11.cpp32
-rw-r--r--platform/x11/os_x11.h2
2 files changed, 34 insertions, 0 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 48e2d8f81e..d5f0efaf00 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -2253,6 +2253,38 @@ Error OS_X11::move_to_trash(const String &p_path) {
return err;
}
+OS::LatinKeyboardVariant OS_X11::get_latin_keyboard_variant() const {
+
+ XkbDescRec *xkbdesc = XkbAllocKeyboard();
+ ERR_FAIL_COND_V(!xkbdesc, LATIN_KEYBOARD_QWERTY);
+
+ XkbGetNames(x11_display, XkbSymbolsNameMask, xkbdesc);
+ ERR_FAIL_COND_V(!xkbdesc->names, LATIN_KEYBOARD_QWERTY);
+ ERR_FAIL_COND_V(!xkbdesc->names->symbols, LATIN_KEYBOARD_QWERTY);
+
+ char *layout = XGetAtomName(x11_display, xkbdesc->names->symbols);
+ ERR_FAIL_COND_V(!layout, LATIN_KEYBOARD_QWERTY);
+
+ Vector<String> info = String(layout).split("+");
+ ERR_FAIL_INDEX_V(1, info.size(), LATIN_KEYBOARD_QWERTY);
+
+ /*if (info[1].find("colemak") != -1) {
+ return LATIN_KEYBOARD_COLEMAK;
+ } else*/ if (info[1].find("qwertz") != -1) {
+ return LATIN_KEYBOARD_QWERTZ;
+ } else if (info[1].find("azerty") != -1) {
+ return LATIN_KEYBOARD_AZERTY;
+ } else if (info[1].find("qzerty") != -1) {
+ return LATIN_KEYBOARD_QZERTY;
+ } else if (info[1].find("dvorak") != -1) {
+ return LATIN_KEYBOARD_DVORAK;
+ } else if (info[1].find("neo") != -1) {
+ return LATIN_KEYBOARD_NEO;
+ }
+
+ return LATIN_KEYBOARD_QWERTY;
+}
+
OS_X11::OS_X11() {
#ifdef PULSEAUDIO_ENABLED
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 36355f11bc..b71b456d49 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -275,6 +275,8 @@ public:
virtual Error move_to_trash(const String &p_path);
+ virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
+
OS_X11();
};