Merge pull request #12517 from marcelofg55/x11_kbd_variant

Implemented OS get_latin_keyboard_variant on x11
This commit is contained in:
Rémi Verschelde 2017-10-30 21:23:41 +01:00 committed by GitHub
commit 6a11e8c377
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View file

@ -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

View file

@ -275,6 +275,8 @@ public:
virtual Error move_to_trash(const String &p_path);
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
OS_X11();
};