Rename InputFilter back to Input

It changed name as part of the DisplayServer and input refactoring
in #37317, with the rationale that input no longer goes through the
main loop, so the previous Input singleton now only does filtering.

But the gains in consistency are quite limited in the renaming, and
it breaks compatibility for all scripts and tutorials that access
the Input singleton via the scripting language. A temporary option
was suggested to keep the scripting singleton named `Input` even if
its type is `InputFilter`, but that adds inconsistency and breaks C#.

Fixes godotengine/godot-proposals#639.
Fixes #37319.
Fixes #37690.
This commit is contained in:
Rémi Verschelde 2020-04-28 15:19:37 +02:00
parent 39f7a40925
commit fdf58a5858
82 changed files with 482 additions and 480 deletions

View file

@ -30,7 +30,7 @@
#include "animation_blend_space_2d_editor.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/io/resource_loader.h"
#include "core/math/delaunay.h"
#include "core/os/keyboard.h"

View file

@ -30,7 +30,7 @@
#include "animation_blend_tree_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/io/resource_loader.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"

View file

@ -30,7 +30,7 @@
#include "animation_player_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/keyboard.h"
@ -488,7 +488,7 @@ double AnimationPlayerEditor::_get_editor_step() const {
ERR_FAIL_COND_V(!anim.is_valid(), 0.0);
// Use more precise snapping when holding Shift
return InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT) ? anim->get_step() * 0.25 : anim->get_step();
return Input::get_singleton()->is_key_pressed(KEY_SHIFT) ? anim->get_step() * 0.25 : anim->get_step();
}
return 0.0;

View file

@ -30,7 +30,7 @@
#include "animation_state_machine_editor.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/io/resource_loader.h"
#include "core/math/delaunay.h"
#include "core/os/keyboard.h"

View file

@ -34,7 +34,7 @@
#include "animation_blend_space_2d_editor.h"
#include "animation_blend_tree_editor_plugin.h"
#include "animation_state_machine_editor.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/io/resource_loader.h"
#include "core/math/delaunay.h"
#include "core/os/keyboard.h"

View file

@ -30,7 +30,7 @@
#include "asset_library_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/io/json.h"
#include "core/os/keyboard.h"
#include "core/version.h"

View file

@ -30,7 +30,7 @@
#include "canvas_item_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "core/print_string.h"
#include "core/project_settings.h"
@ -334,7 +334,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
bool is_snap_active = smart_snap_active ^ InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
// Smart snap using the canvas position
Vector2 output = p_target;
@ -462,7 +462,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
}
float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
if (((smart_snap_active || snap_rotation) ^ InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) {
if (((smart_snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) {
if (snap_relative) {
return Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset + (p_start - (int)(p_start / snap_rotation_step) * snap_rotation_step);
} else {
@ -1284,7 +1284,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
// Pan the viewport
Point2i relative;
if (bool(EditorSettings::get_singleton()->get("editors/2d/warped_mouse_panning"))) {
relative = InputFilter::get_singleton()->warp_mouse_motion(m, viewport->get_global_rect());
relative = Input::get_singleton()->warp_mouse_motion(m, viewport->get_global_rect());
} else {
relative = m->get_relative();
}
@ -1912,7 +1912,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
Transform2D simple_xform = (viewport->get_transform() * unscaled_transform).affine_inverse() * transform;
bool uniform = m->get_shift();
bool is_ctrl = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
Point2 drag_from_local = simple_xform.xform(drag_from);
Point2 drag_to_local = simple_xform.xform(drag_to);
@ -2214,10 +2214,10 @@ 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_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 ((!InputFilter::get_singleton()->is_key_pressed(KEY_UP)) &&
(!InputFilter::get_singleton()->is_key_pressed(KEY_DOWN)) &&
(!InputFilter::get_singleton()->is_key_pressed(KEY_LEFT)) &&
(!InputFilter::get_singleton()->is_key_pressed(KEY_RIGHT))) {
if ((!Input::get_singleton()->is_key_pressed(KEY_UP)) &&
(!Input::get_singleton()->is_key_pressed(KEY_DOWN)) &&
(!Input::get_singleton()->is_key_pressed(KEY_LEFT)) &&
(!Input::get_singleton()->is_key_pressed(KEY_RIGHT))) {
_commit_canvas_item_state(drag_selection, TTR("Move CanvasItem"), true);
drag_type = DRAG_NONE;
}
@ -3310,8 +3310,8 @@ void CanvasItemEditor::_draw_selection() {
}
// Draw the move handles
bool is_ctrl = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
bool is_alt = InputFilter::get_singleton()->is_key_pressed(KEY_ALT);
bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT);
if (tool == TOOL_MOVE && show_transformation_gizmos) {
if (_is_node_movable(canvas_item)) {
Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
@ -3347,7 +3347,7 @@ void CanvasItemEditor::_draw_selection() {
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE);
bool uniform = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
bool uniform = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
Point2 offset = (simple_xform.affine_inverse().xform(drag_to) - simple_xform.affine_inverse().xform(drag_from)) * zoom;
if (drag_type == DRAG_SCALE_X) {
@ -6204,8 +6204,8 @@ bool CanvasItemEditorViewport::_only_packed_scenes_selected() const {
}
void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
bool is_shift = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
bool is_alt = InputFilter::get_singleton()->is_key_pressed(KEY_ALT);
bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT);
selected_files.clear();
Dictionary d = p_data;

View file

@ -31,7 +31,7 @@
#include "collision_polygon_3d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
#include "editor/editor_settings.h"
@ -342,7 +342,7 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
Vector2 cpoint(spoint.x, spoint.y);
if (snap_ignore && !InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) {
if (snap_ignore && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
snap_ignore = false;
}

View file

@ -32,7 +32,7 @@
#include "canvas_item_editor_plugin.h"
#include "core/core_string_names.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
@ -210,7 +210,7 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
else
tangent = 9999 * (dir.y >= 0 ? 1 : -1);
bool link = !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
bool link = !Input::get_singleton()->is_key_pressed(KEY_SHIFT);
if (_selected_tangent == TANGENT_LEFT) {
curve.set_point_left_tangent(_selected_point, tangent);

View file

@ -30,7 +30,7 @@
#include "node_3d_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/math/camera_matrix.h"
#include "core/os/keyboard.h"
#include "core/print_string.h"
@ -298,10 +298,10 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) {
float zoom_inertia = EDITOR_GET("editors/3d/navigation_feel/zoom_inertia");
//determine if being manipulated
bool manipulated = InputFilter::get_singleton()->get_mouse_button_mask() & (2 | 4);
manipulated |= InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
manipulated |= InputFilter::get_singleton()->is_key_pressed(KEY_ALT);
manipulated |= InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
bool manipulated = Input::get_singleton()->get_mouse_button_mask() & (2 | 4);
manipulated |= Input::get_singleton()->is_key_pressed(KEY_SHIFT);
manipulated |= Input::get_singleton()->is_key_pressed(KEY_ALT);
manipulated |= Input::get_singleton()->is_key_pressed(KEY_CONTROL);
float orbit_inertia = MAX(0.00001, manipulated ? manip_orbit_inertia : free_orbit_inertia);
float translation_inertia = MAX(0.0001, manipulated ? manip_translation_inertia : free_translation_inertia);
@ -2260,7 +2260,7 @@ void Node3DEditorViewport::scale_freelook_speed(real_t scale) {
Point2i Node3DEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const {
Point2i relative;
if (bool(EDITOR_DEF("editors/3d/navigation/warped_mouse_panning", false))) {
relative = InputFilter::get_singleton()->warp_mouse_motion(p_ev_mouse_motion, surface->get_global_rect());
relative = Input::get_singleton()->warp_mouse_motion(p_ev_mouse_motion, surface->get_global_rect());
} else {
relative = p_ev_mouse_motion->get_relative();
}
@ -2276,7 +2276,7 @@ static bool is_shortcut_pressed(const String &p_path) {
if (k == nullptr) {
return false;
}
const InputFilter &input = *InputFilter::get_singleton();
const Input &input = *Input::get_singleton();
int keycode = k->get_keycode();
return input.is_key_pressed(keycode);
}
@ -3828,7 +3828,7 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_
if (!can_drop_data_fw(p_point, p_data, p_from))
return;
bool is_shift = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
selected_files.clear();
Dictionary d = p_data;
@ -5785,7 +5785,7 @@ void Node3DEditor::_unhandled_key_input(Ref<InputEvent> p_event) {
if (!is_visible_in_tree())
return;
snap_key_enabled = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
snap_key_enabled = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
}
void Node3DEditor::_notification(int p_what) {
@ -6446,7 +6446,7 @@ Vector3 Node3DEditor::snap_point(Vector3 p_target, Vector3 p_start) const {
float Node3DEditor::get_translate_snap() const {
float snap_value;
if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
snap_value = snap_translate->get_text().to_double() / 10.0;
} else {
snap_value = snap_translate->get_text().to_double();
@ -6457,7 +6457,7 @@ float Node3DEditor::get_translate_snap() const {
float Node3DEditor::get_rotate_snap() const {
float snap_value;
if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
snap_value = snap_rotate->get_text().to_double() / 3.0;
} else {
snap_value = snap_rotate->get_text().to_double();
@ -6468,7 +6468,7 @@ float Node3DEditor::get_rotate_snap() const {
float Node3DEditor::get_scale_snap() const {
float snap_value;
if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
snap_value = snap_scale->get_text().to_double() / 2.0;
} else {
snap_value = snap_scale->get_text().to_double();

View file

@ -31,7 +31,7 @@
#include "polygon_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
@ -810,7 +810,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
if (mm.is_valid()) {
if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || InputFilter::get_singleton()->is_key_pressed(KEY_SPACE)) {
if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
Vector2 drag(mm->get_relative().x, mm->get_relative().y);
uv_hscroll->set_value(uv_hscroll->get_value() - drag.x);

View file

@ -30,7 +30,7 @@
#include "script_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/io/resource_loader.h"
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
@ -1545,7 +1545,7 @@ void ScriptEditor::_help_overview_selected(int p_idx) {
void ScriptEditor::_script_selected(int p_idx) {
grab_focus_block = !InputFilter::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing
grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing
_go_to_tab(script_list->get_item_metadata(p_idx));
grab_focus_block = false;

View file

@ -31,7 +31,7 @@
#include "texture_region_editor_plugin.h"
#include "core/core_string_names.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
#include "scene/gui/check_box.h"
@ -307,7 +307,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) {
if (E->get().has_point(point)) {
rect = E->get();
if (InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL) && !(InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) {
if (Input::get_singleton()->is_key_pressed(KEY_CONTROL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) {
Rect2 r;
if (node_sprite)
r = node_sprite->get_region_rect();
@ -449,7 +449,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
if (mm.is_valid()) {
if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || InputFilter::get_singleton()->is_key_pressed(KEY_SPACE)) {
if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
Vector2 dragged(mm->get_relative().x / draw_zoom, mm->get_relative().y / draw_zoom);
hscroll->set_value(hscroll->get_value() - dragged.x);

View file

@ -31,7 +31,7 @@
#include "tile_map_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/math/math_funcs.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
@ -997,7 +997,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (mb->is_pressed()) {
if (InputFilter::get_singleton()->is_key_pressed(KEY_SPACE))
if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
return false; // Drag.
if (tool == TOOL_NONE) {
@ -1378,7 +1378,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
}
if (tool == TOOL_PICKING && InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
if (tool == TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
_pick_tile(over_tile);

View file

@ -30,7 +30,7 @@
#include "tile_set_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
@ -1113,7 +1113,7 @@ void TileSetEditor::_on_workspace_draw() {
void TileSetEditor::_on_workspace_process() {
if (InputFilter::get_singleton()->is_key_pressed(KEY_ALT) || tools[VISIBLE_INFO]->is_pressed()) {
if (Input::get_singleton()->is_key_pressed(KEY_ALT) || tools[VISIBLE_INFO]->is_pressed()) {
if (!tile_names_visible) {
tile_names_visible = true;
workspace_overlay->update();
@ -1395,7 +1395,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
if ((mb->get_button_index() == BUTTON_RIGHT || mb->get_button_index() == BUTTON_LEFT) && current_tile_region.has_point(mb->get_position())) {
dragging = true;
erasing = (mb->get_button_index() == BUTTON_RIGHT);
alternative = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
alternative = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
Vector2 coord((int)((mb->get_position().x - current_tile_region.position.x) / (spacing + size.x)), (int)((mb->get_position().y - current_tile_region.position.y) / (spacing + size.y)));
Vector2 pos(coord.x * (spacing + size.x), coord.y * (spacing + size.y));
pos = mb->get_position() - (pos + current_tile_region.position);

View file

@ -30,7 +30,7 @@
#include "visual_shader_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/io/resource_loader.h"
#include "core/math/math_defs.h"
#include "core/os/keyboard.h"
@ -1635,7 +1635,7 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
popup_menu->set_item_disabled(NodeMenuOptions::DELETE, to_change.empty());
popup_menu->set_item_disabled(NodeMenuOptions::DUPLICATE, to_change.empty());
menu_point = graph->get_local_mouse_position();
Point2 gpos = InputFilter::get_singleton()->get_mouse_position();
Point2 gpos = Input::get_singleton()->get_mouse_position();
popup_menu->set_position(gpos);
popup_menu->popup();
}
@ -1648,7 +1648,7 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) {
saved_node_pos_dirty = true;
saved_node_pos = graph->get_local_mouse_position();
Point2 gpos = InputFilter::get_singleton()->get_mouse_position();
Point2 gpos = Input::get_singleton()->get_mouse_position();
members_dialog->popup();
members_dialog->set_position(gpos);
} else {