summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/config/project_settings.cpp11
-rw-r--r--core/extension/gdextension.cpp2
-rw-r--r--core/input/input_event.cpp3
-rw-r--r--core/input/input_event.h5
-rw-r--r--core/input/input_map.cpp4
-rw-r--r--core/input/input_map.h5
-rw-r--r--core/io/resource_loader.cpp21
7 files changed, 27 insertions, 24 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index 6e322a019e..f4810e4170 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -516,16 +516,19 @@ void ProjectSettings::_convert_to_last_version(int p_from_version) {
}
}
}
- if (p_from_version <= 5) {
- // Converts the device in events from -1 (emulated events) to -3 (all events).
+ if (p_from_version == 5) {
+ // Converts the device in events from -3 to -1.
+ // -3 was introduced in GH-97707 as a way to prevent a clash in device IDs, but as reported in GH-99243, this leads to problems.
+ // -3 was used during dev-releases, so this conversion helps to revert such affected projects.
+ // This conversion doesn't affect any other projects, since -3 is not used otherwise.
for (KeyValue<StringName, ProjectSettings::VariantContainer> &E : props) {
if (String(E.key).begins_with("input/")) {
Dictionary action = E.value.variant;
Array events = action["events"];
for (int i = 0; i < events.size(); i++) {
Ref<InputEvent> ev = events[i];
- if (ev.is_valid() && ev->get_device() == -1) { // -1 was the previous value (GH-97707).
- ev->set_device(InputEvent::DEVICE_ID_ALL_DEVICES);
+ if (ev.is_valid() && ev->get_device() == -3) {
+ ev->set_device(-1);
}
}
}
diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp
index 2dc2735fc5..101b76eb95 100644
--- a/core/extension/gdextension.cpp
+++ b/core/extension/gdextension.cpp
@@ -156,7 +156,7 @@ public:
}
virtual bool is_vararg() const override {
- return false;
+ return vararg;
}
#ifdef TOOLS_ENABLED
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index e580ea185d..2871ef24dd 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -37,6 +37,9 @@
#include "core/os/keyboard.h"
#include "core/os/os.h"
+const int InputEvent::DEVICE_ID_EMULATION = -1;
+const int InputEvent::DEVICE_ID_INTERNAL = -2;
+
void InputEvent::set_device(int p_device) {
device = p_device;
emit_changed();
diff --git a/core/input/input_event.h b/core/input/input_event.h
index b6faac3f54..e7cd43a042 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -64,9 +64,8 @@ protected:
static void _bind_methods();
public:
- inline static constexpr int DEVICE_ID_EMULATION = -1;
- inline static constexpr int DEVICE_ID_INTERNAL = -2;
- inline static constexpr int DEVICE_ID_ALL_DEVICES = -3; // Signify that a given Action can be triggered by any device.
+ static const int DEVICE_ID_EMULATION;
+ static const int DEVICE_ID_INTERNAL;
void set_device(int p_device);
int get_device() const;
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index dad21911a9..757468b822 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -41,6 +41,8 @@
InputMap *InputMap::singleton = nullptr;
+int InputMap::ALL_DEVICES = -1;
+
void InputMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action);
ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions);
@@ -163,7 +165,7 @@ List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Re
int i = 0;
for (List<Ref<InputEvent>>::Element *E = p_action.inputs.front(); E; E = E->next()) {
int device = E->get()->get_device();
- if (device == InputEvent::DEVICE_ID_ALL_DEVICES || device == p_event->get_device()) {
+ if (device == ALL_DEVICES || device == p_event->get_device()) {
if (E->get()->action_match(p_event, p_exact_match, p_action.deadzone, r_pressed, r_strength, r_raw_strength)) {
if (r_event_index) {
*r_event_index = i;
diff --git a/core/input/input_map.h b/core/input/input_map.h
index 319ce98ebd..492bf0e9c7 100644
--- a/core/input/input_map.h
+++ b/core/input/input_map.h
@@ -45,6 +45,11 @@ class InputMap : public Object {
GDCLASS(InputMap, Object);
public:
+ /**
+ * A special value used to signify that a given Action can be triggered by any device
+ */
+ static int ALL_DEVICES;
+
struct Action {
int id;
float deadzone;
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 85781a9591..bd276010bf 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -297,13 +297,13 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
load_paths_stack.push_back(original_path);
// Try all loaders and pick the first match for the type hint
- bool loader_found = false;
+ bool found = false;
Ref<Resource> res;
for (int i = 0; i < loader_count; i++) {
if (!loader[i]->recognize_path(p_path, p_type_hint)) {
continue;
}
- loader_found = true;
+ found = true;
res = loader[i]->load(p_path, original_path, r_error, p_use_sub_threads, r_progress, p_cache_mode);
if (!res.is_null()) {
break;
@@ -318,24 +318,15 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin
return res;
}
- if (!loader_found) {
- if (r_error) {
- *r_error = ERR_FILE_UNRECOGNIZED;
- }
- ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, p_type_hint));
- }
+ ERR_FAIL_COND_V_MSG(found, Ref<Resource>(),
+ vformat("Failed loading resource: %s. Make sure resources have been imported by opening the project in the editor at least once.", p_path));
#ifdef TOOLS_ENABLED
Ref<FileAccess> file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
- if (!file_check->file_exists(p_path)) {
- if (r_error) {
- *r_error = ERR_FILE_NOT_FOUND;
- }
- ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, p_type_hint));
- }
+ ERR_FAIL_COND_V_MSG(!file_check->file_exists(p_path), Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, p_type_hint));
#endif
- ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Failed loading resource: %s. Make sure resources have been imported by opening the project in the editor at least once.", p_path));
+ ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, p_type_hint));
}
// This implementation must allow re-entrancy for a task that started awaiting in a deeper stack frame.