From 1af06d3d4608b17c74caed951cd9579ccbba229d Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 5 Apr 2018 20:59:35 +0300 Subject: 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). --- editor/plugins/abstract_polygon_2d_editor.cpp | 6 +++--- editor/plugins/animation_blend_space_1d_editor.cpp | 2 +- editor/plugins/animation_blend_space_2d_editor.cpp | 2 +- editor/plugins/animation_player_editor_plugin.cpp | 2 +- editor/plugins/animation_state_machine_editor.cpp | 2 +- editor/plugins/asset_library_editor_plugin.cpp | 2 +- editor/plugins/canvas_item_editor_plugin.cpp | 22 +++++++++++----------- editor/plugins/curve_editor_plugin.cpp | 2 +- editor/plugins/script_editor_plugin.cpp | 8 ++++---- editor/plugins/script_text_editor.cpp | 2 +- editor/plugins/shader_editor_plugin.cpp | 2 +- editor/plugins/spatial_editor_plugin.cpp | 8 ++++---- editor/plugins/text_editor.cpp | 2 +- editor/plugins/tile_map_editor_plugin.cpp | 18 +++++++++--------- editor/plugins/visual_shader_editor_plugin.cpp | 8 ++++---- 15 files changed, 44 insertions(+), 44 deletions(-) (limited to 'editor/plugins') diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 6f29b6c76a..b374d989d7 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -533,7 +533,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref &p_event) if (k.is_valid() && k->is_pressed()) { - if (k->get_scancode() == KEY_DELETE || k->get_scancode() == KEY_BACKSPACE) { + if (k->get_keycode() == KEY_DELETE || k->get_keycode() == KEY_BACKSPACE) { if (wip_active && selected_point.polygon == -1) { @@ -555,10 +555,10 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref &p_event) return true; } } - } else if (wip_active && k->get_scancode() == KEY_ENTER) { + } else if (wip_active && k->get_keycode() == KEY_ENTER) { _wip_close(); - } else if (wip_active && k->get_scancode() == KEY_ESCAPE) { + } else if (wip_active && k->get_keycode() == KEY_ESCAPE) { _wip_cancel(); } } diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index c955f2b806..54a48cc900 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -42,7 +42,7 @@ StringName AnimationNodeBlendSpace1DEditor::get_blend_position_path() const { void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref &p_event) { Ref k = p_event; - if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_DELETE && !k->is_echo()) { + if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) { if (selected_point != -1) { _erase_selected(); accept_event(); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index d2306a5d6b..2edee0389b 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -73,7 +73,7 @@ StringName AnimationNodeBlendSpace2DEditor::get_blend_position_path() const { void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref &p_event) { Ref k = p_event; - if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_DELETE && !k->is_echo()) { + if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) { if (selected_point != -1 || selected_triangle != -1) { _erase_selected(); accept_event(); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 0f2a7376f5..1d04201ce6 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1268,7 +1268,7 @@ void AnimationPlayerEditor::_unhandled_key_input(const Ref &p_ev) { Ref k = p_ev; if (is_visible_in_tree() && k.is_valid() && k->is_pressed() && !k->is_echo() && !k->get_alt() && !k->get_control() && !k->get_metakey()) { - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_A: { if (!k->get_shift()) diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 6f29aba356..cc724b6ce6 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -69,7 +69,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref k = p_event; - if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_DELETE && !k->is_echo()) { + if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) { if (selected_node != StringName() || selected_transition_to != StringName() || selected_transition_from != StringName()) { _erase_selected(); accept_event(); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 01c3c33995..a530f4ddc9 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -627,7 +627,7 @@ void EditorAssetLibrary::_unhandled_input(const Ref &p_event) { if (key.is_valid() && key->is_pressed()) { - if (key->get_scancode_with_modifiers() == (KEY_MASK_CMD | KEY_F) && is_visible_in_tree()) { + if (key->get_keycode_with_modifiers() == (KEY_MASK_CMD | KEY_F) && is_visible_in_tree()) { filter->grab_focus(); filter->select_all(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index f5cc0ccf2a..d7f87bda3f 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -472,7 +472,7 @@ void CanvasItemEditor::_unhandled_key_input(const Ref &p_ev) { if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack()) return; - if (k->get_scancode() == KEY_CONTROL || k->get_scancode() == KEY_ALT || k->get_scancode() == KEY_SHIFT) { + if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) { viewport->update(); } @@ -1315,7 +1315,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref &p_event) { // Drag the pivot (in pivot mode / with V key) if (drag_type == DRAG_NONE) { if ((b.is_valid() && b->is_pressed() && b->get_button_index() == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) || - (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_scancode() == KEY_V)) { + (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_V)) { List selection = _get_edited_canvas_items(); // Filters the selection with nodes that allow setting the pivot @@ -1367,7 +1367,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref &p_event) { // Confirm the pivot move if ((b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) || - (k.is_valid() && !k->is_pressed() && k->get_scancode() == KEY_V)) { + (k.is_valid() && !k->is_pressed() && k->get_keycode() == KEY_V)) { _commit_canvas_item_state(drag_selection, TTR("Move pivot")); drag_type = DRAG_NONE; return true; @@ -2109,7 +2109,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref &p_event) { // Move the canvas items with the arrow keys if (k.is_valid() && k->is_pressed() && (tool == TOOL_SELECT || tool == TOOL_MOVE) && - (k->get_scancode() == KEY_UP || k->get_scancode() == KEY_DOWN || k->get_scancode() == KEY_LEFT || k->get_scancode() == KEY_RIGHT)) { + (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_LEFT || k->get_keycode() == KEY_RIGHT)) { if (!k->is_echo()) { // Start moving the canvas items with the keyboard drag_selection = _get_edited_canvas_items(); @@ -2135,13 +2135,13 @@ bool CanvasItemEditor::_gui_input_move(const Ref &p_event) { bool move_local_base_rotated = k->get_control() || k->get_metakey(); Vector2 dir; - if (k->get_scancode() == KEY_UP) + if (k->get_keycode() == KEY_UP) dir += Vector2(0, -1); - else if (k->get_scancode() == KEY_DOWN) + else if (k->get_keycode() == KEY_DOWN) dir += Vector2(0, 1); - else if (k->get_scancode() == KEY_LEFT) + else if (k->get_keycode() == KEY_LEFT) dir += Vector2(-1, 0); - else if (k->get_scancode() == KEY_RIGHT) + else if (k->get_keycode() == KEY_RIGHT) dir += Vector2(1, 0); if (k->get_shift()) dir *= grid_step * Math::pow(2.0, grid_step_multiplier); @@ -2197,7 +2197,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref &p_event) { } if (k.is_valid() && !k->is_pressed() && drag_type == DRAG_KEY_MOVE && tool == TOOL_SELECT && - (k->get_scancode() == KEY_UP || k->get_scancode() == KEY_DOWN || k->get_scancode() == KEY_LEFT || k->get_scancode() == KEY_RIGHT)) { + (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_LEFT || k->get_keycode() == KEY_RIGHT)) { // Confirm canvas items move by arrow keys if ((!Input::get_singleton()->is_key_pressed(KEY_UP)) && (!Input::get_singleton()->is_key_pressed(KEY_DOWN)) && @@ -2210,7 +2210,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref &p_event) { return true; } - return (k.is_valid() && (k->get_scancode() == KEY_UP || k->get_scancode() == KEY_DOWN || k->get_scancode() == KEY_LEFT || k->get_scancode() == KEY_RIGHT)); // Accept the key event in any case + return (k.is_valid() && (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_LEFT || k->get_keycode() == KEY_RIGHT)); // Accept the key event in any case } bool CanvasItemEditor::_gui_input_select(const Ref &p_event) { @@ -2387,7 +2387,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref &p_event) { } } - if (k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_ESCAPE && drag_type == DRAG_NONE && tool == TOOL_SELECT) { + if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_ESCAPE && drag_type == DRAG_NONE && tool == TOOL_SELECT) { // Unselect everything editor_selection->clear(); viewport->update(); diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 5f4fb19d9e..e9b66b9e58 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -238,7 +238,7 @@ void CurveEditor::on_gui_input(const Ref &p_event) { const InputEventKey &key = **key_ref; if (key.is_pressed() && _selected_point != -1) { - if (key.get_scancode() == KEY_DELETE) + if (key.get_keycode() == KEY_DELETE) remove_point(_selected_point); } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 9dc98dc2a0..3123773795 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -166,10 +166,10 @@ void ScriptEditorQuickOpen::_sbox_input(const Ref &p_ie) { Ref k = p_ie; - if (k.is_valid() && (k->get_scancode() == KEY_UP || - k->get_scancode() == KEY_DOWN || - k->get_scancode() == KEY_PAGEUP || - k->get_scancode() == KEY_PAGEDOWN)) { + if (k.is_valid() && (k->get_keycode() == KEY_UP || + k->get_keycode() == KEY_DOWN || + k->get_keycode() == KEY_PAGEUP || + k->get_keycode() == KEY_PAGEDOWN)) { search_options->call("_gui_input", k); search_box->accept_event(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 4986e60ff0..a11a16b530 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1610,7 +1610,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref &ev) { if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) { local_pos = mb->get_global_position() - tx->get_global_position(); create_menu = true; - } else if (k.is_valid() && k->get_scancode() == KEY_MENU) { + } else if (k.is_valid() && k->get_keycode() == KEY_MENU) { local_pos = tx->_get_cursor_pixel_pos(); create_menu = true; } diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 6c20483cf6..bcc503cc58 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -531,7 +531,7 @@ void ShaderEditor::_text_edit_gui_input(const Ref &ev) { } Ref k = ev; - if (k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_MENU) { + if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_MENU) { TextEdit *tx = shader_editor->get_text_edit(); _make_context_menu(tx->is_selection_active(), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos())); context_menu->grab_focus(); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 6e8eeaec82..f0755fd6bb 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -1873,11 +1873,11 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) { if (!orthogonal && ED_IS_SHORTCUT("spatial_editor/freelook_toggle", p_event)) { set_freelook_active(!is_freelook_active()); - } else if (k->get_scancode() == KEY_ESCAPE) { + } else if (k->get_keycode() == KEY_ESCAPE) { set_freelook_active(false); } - if (k->get_scancode() == KEY_SPACE) { + if (k->get_keycode() == KEY_SPACE) { if (!k->is_pressed()) emit_signal("toggle_maximize_view", this); } } @@ -2074,8 +2074,8 @@ static bool is_shortcut_pressed(const String &p_path) { return false; } const Input &input = *Input::get_singleton(); - int scancode = k->get_scancode(); - return input.is_key_pressed(scancode); + int keycode = k->get_keycode(); + return input.is_key_pressed(keycode); } void SpatialEditorViewport::_update_freelook(real_t delta) { diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index a8b6d74c1f..1cf9f490cc 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -590,7 +590,7 @@ void TextEditor::_text_edit_gui_input(const Ref &ev) { } Ref k = ev; - if (k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_MENU) { + if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_MENU) { TextEdit *tx = code_editor->get_text_edit(); int line = tx->cursor_get_line(); _make_context_menu(tx->is_selection_active(), tx->can_fold(line), tx->is_folded(line), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos())); diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 10d00b2a1d..64168300af 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -359,10 +359,10 @@ void TileMapEditor::_sbox_input(const Ref &p_ie) { Ref k = p_ie; - if (k.is_valid() && (k->get_scancode() == KEY_UP || - k->get_scancode() == KEY_DOWN || - k->get_scancode() == KEY_PAGEUP || - k->get_scancode() == KEY_PAGEDOWN)) { + if (k.is_valid() && (k->get_keycode() == KEY_UP || + k->get_keycode() == KEY_DOWN || + k->get_keycode() == KEY_PAGEUP || + k->get_keycode() == KEY_PAGEDOWN)) { palette->call("_gui_input", k); search_box->accept_event(); @@ -1377,7 +1377,7 @@ bool TileMapEditor::forward_gui_input(const Ref &p_event) { if (k.is_valid() && k->is_pressed()) { - if (last_tool == TOOL_NONE && tool == TOOL_PICKING && k->get_scancode() == KEY_SHIFT && k->get_command()) { + if (last_tool == TOOL_NONE && tool == TOOL_PICKING && k->get_keycode() == KEY_SHIFT && k->get_command()) { // trying to draw a rectangle with the painting tool, so change to the correct tool tool = last_tool; @@ -1385,7 +1385,7 @@ bool TileMapEditor::forward_gui_input(const Ref &p_event) { _update_button_tool(); } - if (k->get_scancode() == KEY_ESCAPE) { + if (k->get_keycode() == KEY_ESCAPE) { if (tool == TOOL_PASTING) copydata.clear(); @@ -1506,7 +1506,7 @@ bool TileMapEditor::forward_gui_input(const Ref &p_event) { if (tool == TOOL_NONE) { - if (k->get_scancode() == KEY_SHIFT && k->get_command()) { + if (k->get_keycode() == KEY_SHIFT && k->get_command()) { tool = TOOL_PICKING; _update_button_tool(); @@ -1514,9 +1514,9 @@ bool TileMapEditor::forward_gui_input(const Ref &p_event) { } else if (tool == TOOL_PICKING) { #ifdef APPLE_STYLE_KEYS - 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 // Go back to that last tool if KEY_CONTROL was released. tool = last_tool; diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index e228f25c62..99db38c73a 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1612,10 +1612,10 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) { void VisualShaderEditor::_sbox_input(const Ref &p_ie) { Ref ie = p_ie; - if (ie.is_valid() && (ie->get_scancode() == KEY_UP || - ie->get_scancode() == KEY_DOWN || - ie->get_scancode() == KEY_ENTER || - ie->get_scancode() == KEY_KP_ENTER)) { + if (ie.is_valid() && (ie->get_keycode() == KEY_UP || + ie->get_keycode() == KEY_DOWN || + ie->get_keycode() == KEY_ENTER || + ie->get_keycode() == KEY_KP_ENTER)) { members->call("_gui_input", ie); node_filter->accept_event(); -- cgit v1.2.3