diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-07-10 12:41:05 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-10 12:41:05 -0300 |
commit | 28641fd9b8e73b3fae57ea4ccf0356629507ea3a (patch) | |
tree | 1aaf9668577261aa4f8f6a2e011d8951476b7d71 /platform/windows | |
parent | b06eca108af4da333e84f553ac1e8ca25e6c1cdf (diff) | |
parent | 7a142780f05d56aa751690c8716bd8aab429b140 (diff) |
Merge pull request #5525 from SuperUserNameMan/window_get_latin_kb_variant
windows get_latin_keyboard_variant() implementation and gdscript binding, #5503
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/os_windows.cpp | 62 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 1 |
2 files changed, 63 insertions, 0 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 89de969cff..b0a50ca4b8 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2178,6 +2178,68 @@ String OS_Windows::get_locale() const { return "en"; } + +OS::LatinKeyboardVariant OS_Windows::get_latin_keyboard_variant() const { + + unsigned long azerty[] = { + 0x00020401, // Arabic (102) AZERTY + 0x0001080c, // Belgian (Comma) + 0x0000080c, // Belgian French + 0x0000040c, // French + 0 // <--- STOP MARK + }; + unsigned long qwertz[] = { + 0x0000041a, // Croation + 0x00000405, // Czech + 0x00000407, // German + 0x00010407, // German (IBM) + 0x0000040e, // Hungarian + 0x0000046e, // Luxembourgish + 0x00010415, // Polish (214) + 0x00000418, // Romanian (Legacy) + 0x0000081a, // Serbian (Latin) + 0x0000041b, // Slovak + 0x00000424, // Slovenian + 0x0001042e, // Sorbian Extended + 0x0002042e, // Sorbian Standard + 0x0000042e, // Sorbian Standard (Legacy) + 0x0000100c, // Swiss French + 0x00000807, // Swiss German + 0 // <--- STOP MARK + }; + unsigned long dvorak[] = { + 0x00010409, // US-Dvorak + 0x00030409, // US-Dvorak for left hand + 0x00040409, // US-Dvorak for right hand + 0 // <--- STOP MARK + }; + + char name[ KL_NAMELENGTH + 1 ]; name[0] = 0; + GetKeyboardLayoutNameA( name ); + + unsigned long hex = strtoul(name, NULL, 16); + + int i=0; + while( azerty[i] != 0 ) { + if (azerty[i] == hex) return LATIN_KEYBOARD_AZERTY; + i++; + } + + i = 0; + while( qwertz[i] != 0 ) { + if (qwertz[i] == hex) return LATIN_KEYBOARD_QWERTZ; + i++; + } + + i = 0; + while( dvorak[i] != 0 ) { + if (dvorak[i] == hex) return LATIN_KEYBOARD_DVORAK; + i++; + } + + return LATIN_KEYBOARD_QWERTY; +} + void OS_Windows::release_rendering_thread() { gl_context->release_current(); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index d2249bf352..5acb300c0f 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -266,6 +266,7 @@ public: virtual String get_executable_path() const; virtual String get_locale() const; + virtual LatinKeyboardVariant get_latin_keyboard_variant() const; virtual void move_window_to_foreground(); virtual String get_data_dir() const; |