summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorSuperUserNameMan <yoann@terminajones.com>2016-07-02 20:52:36 +0200
committerSuperUserNameMan <yoann@terminajones.com>2016-07-03 19:35:13 +0200
commit7a142780f05d56aa751690c8716bd8aab429b140 (patch)
tree5ed4b2c099a135fa539575d0bcfb9de97a999763 /platform/windows
parentf9bd038ca749ccedfc55170b0780925574d4042e (diff)
windows get_latin_keyboard_variant() implementation and gdscript binding
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/os_windows.cpp62
-rw-r--r--platform/windows/os_windows.h1
2 files changed, 63 insertions, 0 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 9421e0d48e..e494c0db0e 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -2164,6 +2164,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 509d76abbf..3880c2c08c 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -264,6 +264,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;