Implemented OS get_latin_keyboard_variant on x11

This commit is contained in:
Marcelo Fernandez 2017-10-30 11:40:42 -03:00
parent fd89924ea5
commit be6ac69f75
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();
};