diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-03-01 23:00:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-01 23:00:42 +0100 |
commit | e2b66cacf78ae39b94df748e9740b98a1f011e77 (patch) | |
tree | 56d468d762c43879c20b342702e8fc999221e6c6 /editor/plugins | |
parent | 55396d6e06f8e4e355e9ab0595bdb7f27c1c36dd (diff) | |
parent | 1af06d3d4608b17c74caed951cd9579ccbba229d (diff) |
Merge pull request #18020 from bruvzg/input_fix_non_latin_and_add_hw_scancodes
Fix non-latin layout scancodes on Linux, adds access to physical scancodes.
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/abstract_polygon_2d_editor.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/animation_blend_space_1d_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/animation_blend_space_2d_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/animation_player_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/animation_state_machine_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 22 | ||||
-rw-r--r-- | editor/plugins/curve_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 8 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 8 | ||||
-rw-r--r-- | editor/plugins/text_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 18 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 8 |
15 files changed, 44 insertions, 44 deletions
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 6e950e8c0b..8d5444db73 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<InputEvent> &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<InputEvent> &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 d5d5727ad9..7916ac71ea 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<InputEvent> &p_event) { Ref<InputEventKey> 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 363c3a0e0a..663f2dde05 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<InputEvent> &p_event) { Ref<InputEventKey> 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 0450f3c472..af12335a27 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<InputEvent> &p_ev) { Ref<InputEventKey> 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 77a8489f9e..cae959e1f4 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<InputEv return; Ref<InputEventKey> 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 e598fc5d8b..ea5da1d9ac 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -617,7 +617,7 @@ void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &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 fd522f9109..af7f8cf5d6 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<InputEvent> &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<InputEvent> &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<CanvasItem *> 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<InputEvent> &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<InputEvent> &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<InputEvent> &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<InputEvent> &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<InputEvent> &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<InputEvent> &p_event) { @@ -2387,7 +2387,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &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 adf859eb1e..878787231d 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<InputEvent> &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 fd9c8f6f39..60bed10351 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<InputEvent> &p_ie) { Ref<InputEventKey> 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 d3d64f0dc5..02168a4c97 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1600,7 +1600,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &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 31f126cc0a..01b1e21153 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -522,7 +522,7 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { } Ref<InputEventKey> 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 dd006316f7..0bbcbb0080 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -1873,11 +1873,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &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 8d3788dea7..35f23ccf1d 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -582,7 +582,7 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { } Ref<InputEventKey> 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 82f04aaac4..017f986469 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<InputEvent> &p_ie) { Ref<InputEventKey> 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<InputEvent> &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<InputEvent> &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<InputEvent> &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<InputEvent> &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 b3b9afb811..e7b7c05901 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1663,10 +1663,10 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) { void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) { Ref<InputEventKey> 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(); |