From f3fc07272cc5aae787911ed3c0224f7b37d060e7 Mon Sep 17 00:00:00 2001 From: N0hbdy Date: Tue, 24 Oct 2017 10:32:40 -0700 Subject: [PATCH] Add Colemak keybindings to editor for osx --- core/bind/core_bind.cpp | 1 + core/os/keyboard.cpp | 22 ++++++++++++++++++++++ core/os/os.h | 1 + doc/classes/OS.xml | 2 +- platform/osx/os_osx.mm | 2 ++ platform/x11/os_x11.cpp | 4 ++-- 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index b47e611a51d..12b892d8737 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -413,6 +413,7 @@ String _OS::get_latin_keyboard_variant() const { case OS::LATIN_KEYBOARD_QZERTY: return "QZERTY"; case OS::LATIN_KEYBOARD_DVORAK: return "DVORAK"; case OS::LATIN_KEYBOARD_NEO: return "NEO"; + case OS::LATIN_KEYBOARD_COLEMAK: return "COLEMAK"; default: return "ERROR"; } } diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index 30e7d5e791e..edf4f3e2f9f 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -505,6 +505,27 @@ static const _KeyCodeReplace _keycode_replace_neo[] = { { 0, 0 } }; +static const _KeyCodeReplace _keycode_replace_colemak[] = { + { KEY_E, KEY_F }, + { KEY_R, KEY_P }, + { KEY_T, KEY_G }, + { KEY_Y, KEY_J }, + { KEY_U, KEY_L }, + { KEY_I, KEY_U }, + { KEY_O, KEY_Y }, + { KEY_P, KEY_SEMICOLON }, + { KEY_S, KEY_R }, + { KEY_D, KEY_S }, + { KEY_F, KEY_T }, + { KEY_G, KEY_D }, + { KEY_J, KEY_N }, + { KEY_K, KEY_E }, + { KEY_L, KEY_I }, + { KEY_SEMICOLON, KEY_O }, + { KEY_N, KEY_K }, + { 0, 0 } +}; + int keycode_get_count() { const _KeyCodeText *kct = &_keycodes[0]; @@ -537,6 +558,7 @@ int latin_keyboard_keycode_convert(int p_keycode) { case OS::LATIN_KEYBOARD_QZERTY: kcr = _keycode_replace_qzerty; break; case OS::LATIN_KEYBOARD_DVORAK: kcr = _keycode_replace_dvorak; break; case OS::LATIN_KEYBOARD_NEO: kcr = _keycode_replace_neo; break; + case OS::LATIN_KEYBOARD_COLEMAK: kcr = _keycode_replace_colemak; break; default: return p_keycode; } diff --git a/core/os/os.h b/core/os/os.h index 48effe99da0..f5e479ac0b2 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -409,6 +409,7 @@ public: LATIN_KEYBOARD_QZERTY, LATIN_KEYBOARD_DVORAK, LATIN_KEYBOARD_NEO, + LATIN_KEYBOARD_COLEMAK, }; virtual LatinKeyboardVariant get_latin_keyboard_variant() const; diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 73b424eb128..2629e6740de 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -196,7 +196,7 @@ Returns the current latin keyboard variant as a String. - Possible return values are: "QWERTY", "AZERTY", "QZERTY", "DVORAK", "NEO" or "ERROR" + Possible return values are: "QWERTY", "AZERTY", "QZERTY", "DVORAK", "NEO", "COLEMAK" or "ERROR". diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index d67bc653c90..33586086dca 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1834,6 +1834,8 @@ OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const { layout = LATIN_KEYBOARD_DVORAK; } else if ([test isEqualToString:@"xvlcwk"]) { layout = LATIN_KEYBOARD_NEO; + } else if ([test isEqualToString:@"qwfpgj"]) { + layout = LATIN_KEYBOARD_COLEMAK; } [test release]; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index d5f0efaf00d..09193e0a2b9 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -2268,9 +2268,9 @@ OS::LatinKeyboardVariant OS_X11::get_latin_keyboard_variant() const { Vector info = String(layout).split("+"); ERR_FAIL_INDEX_V(1, info.size(), LATIN_KEYBOARD_QWERTY); - /*if (info[1].find("colemak") != -1) { + if (info[1].find("colemak") != -1) { return LATIN_KEYBOARD_COLEMAK; - } else*/ if (info[1].find("qwertz") != -1) { + } else if (info[1].find("qwertz") != -1) { return LATIN_KEYBOARD_QWERTZ; } else if (info[1].find("azerty") != -1) { return LATIN_KEYBOARD_AZERTY;