summaryrefslogtreecommitdiff
path: root/scene
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 /scene
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 'scene')
-rw-r--r--scene/gui/file_dialog.cpp2
-rw-r--r--scene/gui/gradient_edit.cpp2
-rw-r--r--scene/gui/graph_edit.cpp8
-rw-r--r--scene/gui/line_edit.cpp8
-rw-r--r--scene/gui/popup_menu.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp2
-rw-r--r--scene/gui/text_edit.cpp100
-rw-r--r--scene/gui/tree.cpp2
-rw-r--r--scene/main/scene_tree.cpp2
9 files changed, 64 insertions, 64 deletions
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index e27e7d1490..8c61531192 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -85,7 +85,7 @@ void FileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
bool handled = true;
- switch (k->get_scancode()) {
+ switch (k->get_keycode()) {
case KEY_H: {
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index 98c2d3a0e9..48a1a27570 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -96,7 +96,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
- if (k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_DELETE && grabbed != -1) {
+ if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && grabbed != -1) {
points.remove(grabbed);
grabbed = -1;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index a325859625..884bc685f7 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -1043,22 +1043,22 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
if (k.is_valid()) {
- if (k->get_scancode() == KEY_D && k->is_pressed() && k->get_command()) {
+ if (k->get_keycode() == KEY_D && k->is_pressed() && k->get_command()) {
emit_signal("duplicate_nodes_request");
accept_event();
}
- if (k->get_scancode() == KEY_C && k->is_pressed() && k->get_command()) {
+ if (k->get_keycode() == KEY_C && k->is_pressed() && k->get_command()) {
emit_signal("copy_nodes_request");
accept_event();
}
- if (k->get_scancode() == KEY_V && k->is_pressed() && k->get_command()) {
+ if (k->get_keycode() == KEY_V && k->is_pressed() && k->get_command()) {
emit_signal("paste_nodes_request");
accept_event();
}
- if (k->get_scancode() == KEY_DELETE && k->is_pressed()) {
+ if (k->get_keycode() == KEY_DELETE && k->is_pressed()) {
emit_signal("delete_nodes_request");
accept_event();
}
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 700eaecf43..9416db8517 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -165,7 +165,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
#ifdef APPLE_STYLE_KEYS
if (k->get_control() && !k->get_shift() && !k->get_alt() && !k->get_command()) {
uint32_t remap_key = KEY_UNKNOWN;
- switch (k->get_scancode()) {
+ switch (k->get_keycode()) {
case KEY_F: {
remap_key = KEY_RIGHT;
} break;
@@ -193,13 +193,13 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
}
if (remap_key != KEY_UNKNOWN) {
- k->set_scancode(remap_key);
+ k->set_keycode(remap_key);
k->set_control(false);
}
}
#endif
- unsigned int code = k->get_scancode();
+ unsigned int code = k->get_keycode();
if (k->get_command() && is_shortcut_keys_enabled()) {
@@ -550,7 +550,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
if (handled) {
accept_event();
} else if (!k->get_command()) {
- if (k->get_unicode() >= 32 && k->get_scancode() != KEY_DELETE) {
+ if (k->get_unicode() >= 32 && k->get_keycode() != KEY_DELETE) {
if (editable) {
selection_delete();
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 2416931dae..c261e6f557 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -1074,7 +1074,7 @@ bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_fo
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
- code = k->get_scancode();
+ code = k->get_keycode();
if (code == 0)
code = k->get_unicode();
if (k->get_control())
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 3727860321..ea6230b9ae 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -1209,7 +1209,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
if (k.is_valid()) {
if (k->is_pressed() && !k->get_alt() && !k->get_shift()) {
bool handled = false;
- switch (k->get_scancode()) {
+ switch (k->get_keycode()) {
case KEY_PAGEUP: {
if (vscroll->is_visible_in_tree()) {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 52cb711bfe..76d83529e8 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2556,9 +2556,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
k = k->duplicate(); // It will be modified later on.
#ifdef OSX_ENABLED
- if (k->get_scancode() == KEY_META) {
+ if (k->get_keycode() == KEY_META) {
#else
- if (k->get_scancode() == KEY_CONTROL) {
+ if (k->get_keycode() == KEY_CONTROL) {
#endif
if (select_identifiers_enabled) {
@@ -2589,7 +2589,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (valid) {
if (!k->get_alt()) {
- if (k->get_scancode() == KEY_UP) {
+ if (k->get_keycode() == KEY_UP) {
if (completion_index > 0) {
completion_index--;
@@ -2603,7 +2603,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
- if (k->get_scancode() == KEY_DOWN) {
+ if (k->get_keycode() == KEY_DOWN) {
if (completion_index < completion_options.size() - 1) {
completion_index++;
@@ -2617,7 +2617,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
- if (k->get_scancode() == KEY_PAGEUP) {
+ if (k->get_keycode() == KEY_PAGEUP) {
completion_index -= get_constant("completion_lines");
if (completion_index < 0)
@@ -2628,7 +2628,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
- if (k->get_scancode() == KEY_PAGEDOWN) {
+ if (k->get_keycode() == KEY_PAGEDOWN) {
completion_index += get_constant("completion_lines");
if (completion_index >= completion_options.size())
@@ -2639,7 +2639,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
- if (k->get_scancode() == KEY_HOME && completion_index > 0) {
+ if (k->get_keycode() == KEY_HOME && completion_index > 0) {
completion_index = 0;
completion_current = completion_options[completion_index];
@@ -2648,7 +2648,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
- if (k->get_scancode() == KEY_END && completion_index < completion_options.size() - 1) {
+ if (k->get_keycode() == KEY_END && completion_index < completion_options.size() - 1) {
completion_index = completion_options.size() - 1;
completion_current = completion_options[completion_index];
@@ -2657,14 +2657,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
- if (k->get_scancode() == KEY_KP_ENTER || k->get_scancode() == KEY_ENTER || k->get_scancode() == KEY_TAB) {
+ if (k->get_keycode() == KEY_KP_ENTER || k->get_keycode() == KEY_ENTER || k->get_keycode() == KEY_TAB) {
_confirm_completion();
accept_event();
return;
}
- if (k->get_scancode() == KEY_BACKSPACE) {
+ if (k->get_keycode() == KEY_BACKSPACE) {
_reset_caret_blink_timer();
@@ -2674,7 +2674,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
- if (k->get_scancode() == KEY_SHIFT) {
+ if (k->get_keycode() == KEY_SHIFT) {
accept_event();
return;
}
@@ -2718,20 +2718,20 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
/* TEST CONTROL FIRST! */
// Some remaps for duplicate functions.
- if (k->get_command() && !k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_scancode() == KEY_INSERT) {
+ if (k->get_command() && !k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_keycode() == KEY_INSERT) {
- k->set_scancode(KEY_C);
+ k->set_keycode(KEY_C);
}
- if (!k->get_command() && k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_scancode() == KEY_INSERT) {
+ if (!k->get_command() && k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_keycode() == KEY_INSERT) {
- k->set_scancode(KEY_V);
+ k->set_keycode(KEY_V);
k->set_command(true);
k->set_shift(false);
}
#ifdef APPLE_STYLE_KEYS
if (k->get_control() && !k->get_shift() && !k->get_alt() && !k->get_command()) {
uint32_t remap_key = KEY_UNKNOWN;
- switch (k->get_scancode()) {
+ switch (k->get_keycode()) {
case KEY_F: {
remap_key = KEY_RIGHT;
} break;
@@ -2753,7 +2753,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (remap_key != KEY_UNKNOWN) {
- k->set_scancode(remap_key);
+ k->set_keycode(remap_key);
k->set_control(false);
}
}
@@ -2771,7 +2771,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
bool unselect = false;
bool dobreak = false;
- switch (k->get_scancode()) {
+ switch (k->get_keycode()) {
case KEY_TAB: {
if (k->get_shift()) {
@@ -2845,11 +2845,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
selection.selecting_text = false;
- bool scancode_handled = true;
+ bool keycode_handled = true;
- // Special scancode test.
+ // Special keycode test.
- switch (k->get_scancode()) {
+ switch (k->get_keycode()) {
case KEY_KP_ENTER:
case KEY_ENTER: {
@@ -2971,7 +2971,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
completion_hint = "";
update();
} else {
- scancode_handled = false;
+ keycode_handled = false;
}
} break;
case KEY_TAB: {
@@ -3044,7 +3044,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (k->get_alt() && cursor.column > 1) {
#else
if (k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
} else if (k->get_command() && cursor.column > 1) {
#endif
@@ -3101,7 +3101,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_KP_4: {
if (k->get_unicode() != 0) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
[[fallthrough]];
@@ -3137,7 +3137,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} else if (k->get_alt()) {
#else
if (k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
} else if (k->get_command()) {
#endif
@@ -3177,7 +3177,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_KP_6: {
if (k->get_unicode() != 0) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
[[fallthrough]];
@@ -3199,7 +3199,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} else if (k->get_alt()) {
#else
if (k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
} else if (k->get_command()) {
#endif
@@ -3238,7 +3238,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_KP_8: {
if (k->get_unicode() != 0) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
[[fallthrough]];
@@ -3246,7 +3246,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
case KEY_UP: {
if (k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
#ifndef APPLE_STYLE_KEYS
@@ -3291,7 +3291,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_KP_2: {
if (k->get_unicode() != 0) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
[[fallthrough]];
@@ -3299,7 +3299,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
case KEY_DOWN: {
if (k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
#ifndef APPLE_STYLE_KEYS
@@ -3359,7 +3359,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (k->get_alt() && cursor.column < curline_len - 1) {
#else
if (k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
} else if (k->get_command() && cursor.column < curline_len - 1) {
#endif
@@ -3414,7 +3414,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_KP_7: {
if (k->get_unicode() != 0) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
[[fallthrough]];
@@ -3475,7 +3475,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_KP_1: {
if (k->get_unicode() != 0) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
[[fallthrough]];
@@ -3522,7 +3522,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_KP_9: {
if (k->get_unicode() != 0) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
[[fallthrough]];
@@ -3545,7 +3545,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_KP_3: {
if (k->get_unicode() != 0) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
[[fallthrough]];
@@ -3570,7 +3570,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
#ifndef APPLE_STYLE_KEYS
if (!k->get_control() || k->get_shift() || k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
if (is_shortcut_keys_enabled()) {
@@ -3578,7 +3578,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
#else
if ((!k->get_command() && !k->get_control())) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
if (!k->get_shift() && k->get_command() && is_shortcut_keys_enabled())
@@ -3609,7 +3609,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
case KEY_E: {
if (!k->get_control() || k->get_command() || k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
@@ -3634,7 +3634,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
break;
}
if (!k->get_command() || k->get_shift() || k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
if (is_shortcut_keys_enabled()) {
@@ -3645,7 +3645,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
case KEY_C: {
if (!k->get_command() || k->get_shift() || k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
@@ -3661,7 +3661,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (!k->get_command()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
@@ -3679,7 +3679,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (!k->get_command()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
@@ -3692,7 +3692,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
break;
}
if (!k->get_command() || k->get_shift() || k->get_alt()) {
- scancode_handled = false;
+ keycode_handled = false;
break;
}
@@ -3709,9 +3709,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
#endif
query_code_comple();
- scancode_handled = true;
+ keycode_handled = true;
} else {
- scancode_handled = false;
+ keycode_handled = false;
}
} break;
@@ -3728,20 +3728,20 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
default: {
- scancode_handled = false;
+ keycode_handled = false;
} break;
}
- if (scancode_handled)
+ if (keycode_handled)
accept_event();
- if (k->get_scancode() == KEY_INSERT) {
+ if (k->get_keycode() == KEY_INSERT) {
set_insert_mode(!insert_mode);
accept_event();
return;
}
- if (!scancode_handled && !k->get_command()) { // For German keyboards.
+ if (!keycode_handled && !k->get_command()) { // For German keyboards.
if (k->get_unicode() >= 32) {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 940692ebd7..1761ba96bc 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2439,7 +2439,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
return;
} else {
- if (k->get_scancode() != KEY_SHIFT)
+ if (k->get_keycode() != KEY_SHIFT)
last_keypress = 0;
}
}
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index f27415ee6f..6378d93328 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -435,7 +435,7 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) {
if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote()) {
//quit from game window using F8
Ref<InputEventKey> k = ev;
- if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_scancode() == KEY_F8) {
+ if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_F8) {
ScriptDebugger::get_singleton()->request_quit();
}
}