summaryrefslogtreecommitdiff
path: root/platform/javascript
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2018-04-05 20:59:35 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2020-02-25 12:30:33 +0200
commit1af06d3d4608b17c74caed951cd9579ccbba229d (patch)
treea0d57c6cd3c00614a5a30290085e91a6097e78b6 /platform/javascript
parent376a8255a9b65b016fcd81634bfd54fb7fa029df (diff)
Rename `scancode` to `keycode`.
Add `physical_keycode` (keyboard layout independent keycodes) to InputEventKey and InputMap. Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).
Diffstat (limited to 'platform/javascript')
-rw-r--r--platform/javascript/dom_keys.inc2
-rw-r--r--platform/javascript/os_javascript.cpp7
2 files changed, 5 insertions, 4 deletions
diff --git a/platform/javascript/dom_keys.inc b/platform/javascript/dom_keys.inc
index 25e88f99d1..fd9df765d2 100644
--- a/platform/javascript/dom_keys.inc
+++ b/platform/javascript/dom_keys.inc
@@ -218,7 +218,7 @@
#define DOM_VK_PA1 0xFD
#define DOM_VK_WIN_OEM_CLEAR 0xFE
-int dom2godot_scancode(int dom_keycode) {
+int dom2godot_keycode(int dom_keycode) {
if (DOM_VK_0 <= dom_keycode && dom_keycode <= DOM_VK_Z) {
// ASCII intersection
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 5acdc5f602..299c469bf4 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -250,7 +250,8 @@ static Ref<InputEventKey> setup_key_event(const EmscriptenKeyboardEvent *emscrip
ev.instance();
ev->set_echo(emscripten_event->repeat);
dom2godot_mod(emscripten_event, ev);
- ev->set_scancode(dom2godot_scancode(emscripten_event->keyCode));
+ ev->set_keycode(dom2godot_keycode(emscripten_event->keyCode));
+ ev->set_physical_keycode(dom2godot_keycode(emscripten_event->keyCode));
String unicode = String::utf8(emscripten_event->key);
// Check if empty or multi-character (e.g. `CapsLock`).
@@ -270,7 +271,7 @@ EM_BOOL OS_JavaScript::keydown_callback(int p_event_type, const EmscriptenKeyboa
OS_JavaScript *os = get_singleton();
Ref<InputEventKey> ev = setup_key_event(p_event);
ev->set_pressed(true);
- if (ev->get_unicode() == 0 && keycode_has_unicode(ev->get_scancode())) {
+ if (ev->get_unicode() == 0 && keycode_has_unicode(ev->get_keycode())) {
// Defer to keypress event for legacy unicode retrieval.
os->deferred_key_event = ev;
// Do not suppress keypress event.
@@ -295,7 +296,7 @@ EM_BOOL OS_JavaScript::keyup_callback(int p_event_type, const EmscriptenKeyboard
Ref<InputEventKey> ev = setup_key_event(p_event);
ev->set_pressed(false);
get_singleton()->input->parse_input_event(ev);
- return ev->get_scancode() != KEY_UNKNOWN && ev->get_scancode() != 0;
+ return ev->get_keycode() != KEY_UNKNOWN && ev->get_keycode() != 0;
}
// Mouse