Skip to content

Commit

Permalink
Rename InputFilter back to Input
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akien-mga committed Apr 28, 2020
1 parent 3dcee28 commit 950027c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
28 changes: 14 additions & 14 deletions visual_script_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "visual_script_editor.h"

#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/object.h"
#include "core/os/keyboard.h"
#include "core/script_language.h"
Expand Down Expand Up @@ -1073,9 +1073,9 @@ void VisualScriptEditor::_member_selected() {
if (ti->get_parent() == members->get_root()->get_children()) {

#ifdef OSX_ENABLED
bool held_ctrl = InputFilter::get_singleton()->is_key_pressed(KEY_META);
bool held_ctrl = Input::get_singleton()->is_key_pressed(KEY_META);
#else
bool held_ctrl = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
bool held_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif
if (held_ctrl) {
ERR_FAIL_COND(!script->has_function(selected));
Expand Down Expand Up @@ -1378,7 +1378,7 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
}
} else if (ti->get_parent() == root->get_children()) {
selected = ti->get_text(0);
function_name_edit->set_position(InputFilter::get_singleton()->get_mouse_position() - Vector2(60, -10));
function_name_edit->set_position(Input::get_singleton()->get_mouse_position() - Vector2(60, -10));
function_name_edit->popup();
function_name_box->set_text(selected);
function_name_box->select_all();
Expand Down Expand Up @@ -1740,7 +1740,7 @@ void VisualScriptEditor::_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> key = p_event;

if (key.is_valid() && !key->is_pressed()) {
mouse_up_position = InputFilter::get_singleton()->get_mouse_position();
mouse_up_position = Input::get_singleton()->get_mouse_position();
}
}

Expand All @@ -1750,7 +1750,7 @@ void VisualScriptEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
if (key.is_valid() && key->is_pressed() && key->get_button_mask() == BUTTON_RIGHT) {
saved_position = graph->get_local_mouse_position();

Point2 gpos = InputFilter::get_singleton()->get_mouse_position();
Point2 gpos = Input::get_singleton()->get_mouse_position();
_generic_search(script->get_instance_base_type(), gpos);
}
}
Expand Down Expand Up @@ -2004,9 +2004,9 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (String(d["type"]) == "visual_script_variable_drag") {

#ifdef OSX_ENABLED
bool use_set = InputFilter::get_singleton()->is_key_pressed(KEY_META);
bool use_set = Input::get_singleton()->is_key_pressed(KEY_META);
#else
bool use_set = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
bool use_set = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
Expand Down Expand Up @@ -2199,9 +2199,9 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}

#ifdef OSX_ENABLED
bool use_node = InputFilter::get_singleton()->is_key_pressed(KEY_META);
bool use_node = Input::get_singleton()->is_key_pressed(KEY_META);
#else
bool use_node = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
bool use_node = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif

Array nodes = d["nodes"];
Expand Down Expand Up @@ -2263,7 +2263,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da

Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);

if (!sn && !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
if (!sn && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
EditorNode::get_singleton()->show_warning(vformat(TTR("Can't drop properties because script '%s' is not used in this scene.\nDrop holding 'Shift' to just copy the signature."), get_name()));
return;
}
Expand All @@ -2283,12 +2283,12 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da

ofs /= EDSCALE;
#ifdef OSX_ENABLED
bool use_get = InputFilter::get_singleton()->is_key_pressed(KEY_META);
bool use_get = Input::get_singleton()->is_key_pressed(KEY_META);
#else
bool use_get = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
bool use_get = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif

if (!node || InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
if (!node || Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {

if (use_get)
undo_redo->create_action(TTR("Add Getter Property"));
Expand Down
2 changes: 1 addition & 1 deletion visual_script_flow_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,6 @@ void register_visual_script_flow_control_nodes() {
VisualScriptLanguage::singleton->add_register_func("flow_control/iterator", create_node_generic<VisualScriptIterator>);
VisualScriptLanguage::singleton->add_register_func("flow_control/sequence", create_node_generic<VisualScriptSequence>);
VisualScriptLanguage::singleton->add_register_func("flow_control/switch", create_node_generic<VisualScriptSwitch>);
//VisualScriptLanguage::singleton->add_register_func("flow_control/input_filter", create_node_generic<VisualScriptInputFilter>);
//VisualScriptLanguage::singleton->add_register_func("flow_control/input", create_node_generic<VisualScriptInputFilter>);
VisualScriptLanguage::singleton->add_register_func("flow_control/type_cast", create_node_generic<VisualScriptTypeCast>);
}
10 changes: 5 additions & 5 deletions visual_script_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include "core/engine.h"
#include "core/global_constants.h"
#include "core/input/input_filter.h"
#include "core/input/input.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "scene/main/node.h"
Expand Down Expand Up @@ -3870,16 +3870,16 @@ class VisualScriptNodeInstanceInputAction : public VisualScriptNodeInstance {

switch (mode) {
case VisualScriptInputAction::MODE_PRESSED: {
*p_outputs[0] = InputFilter::get_singleton()->is_action_pressed(action);
*p_outputs[0] = Input::get_singleton()->is_action_pressed(action);
} break;
case VisualScriptInputAction::MODE_RELEASED: {
*p_outputs[0] = !InputFilter::get_singleton()->is_action_pressed(action);
*p_outputs[0] = !Input::get_singleton()->is_action_pressed(action);
} break;
case VisualScriptInputAction::MODE_JUST_PRESSED: {
*p_outputs[0] = InputFilter::get_singleton()->is_action_just_pressed(action);
*p_outputs[0] = Input::get_singleton()->is_action_just_pressed(action);
} break;
case VisualScriptInputAction::MODE_JUST_RELEASED: {
*p_outputs[0] = InputFilter::get_singleton()->is_action_just_released(action);
*p_outputs[0] = Input::get_singleton()->is_action_just_released(action);
} break;
}

Expand Down

0 comments on commit 950027c

Please sign in to comment.