summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/core_bind.cpp21
-rw-r--r--core/core_bind.h29
-rw-r--r--core/input/input.cpp6
-rw-r--r--core/input/input_event.cpp41
-rw-r--r--core/input/input_event.h12
-rw-r--r--core/os/os.h28
-rw-r--r--core/os/time.cpp4
-rw-r--r--core/os/time.h28
-rw-r--r--core/os/time_enums.h63
-rw-r--r--core/variant/variant_call.cpp2
10 files changed, 127 insertions, 107 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 9503bd2575..58b2bc0492 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -613,27 +613,6 @@ void OS::_bind_methods() {
BIND_ENUM_CONSTANT(RENDERING_DRIVER_VULKAN);
BIND_ENUM_CONSTANT(RENDERING_DRIVER_OPENGL3);
- BIND_ENUM_CONSTANT(DAY_SUNDAY);
- BIND_ENUM_CONSTANT(DAY_MONDAY);
- BIND_ENUM_CONSTANT(DAY_TUESDAY);
- BIND_ENUM_CONSTANT(DAY_WEDNESDAY);
- BIND_ENUM_CONSTANT(DAY_THURSDAY);
- BIND_ENUM_CONSTANT(DAY_FRIDAY);
- BIND_ENUM_CONSTANT(DAY_SATURDAY);
-
- BIND_ENUM_CONSTANT(MONTH_JANUARY);
- BIND_ENUM_CONSTANT(MONTH_FEBRUARY);
- BIND_ENUM_CONSTANT(MONTH_MARCH);
- BIND_ENUM_CONSTANT(MONTH_APRIL);
- BIND_ENUM_CONSTANT(MONTH_MAY);
- BIND_ENUM_CONSTANT(MONTH_JUNE);
- BIND_ENUM_CONSTANT(MONTH_JULY);
- BIND_ENUM_CONSTANT(MONTH_AUGUST);
- BIND_ENUM_CONSTANT(MONTH_SEPTEMBER);
- BIND_ENUM_CONSTANT(MONTH_OCTOBER);
- BIND_ENUM_CONSTANT(MONTH_NOVEMBER);
- BIND_ENUM_CONSTANT(MONTH_DECEMBER);
-
BIND_ENUM_CONSTANT(SYSTEM_DIR_DESKTOP);
BIND_ENUM_CONSTANT(SYSTEM_DIR_DCIM);
BIND_ENUM_CONSTANT(SYSTEM_DIR_DOCUMENTS);
diff --git a/core/core_bind.h b/core/core_bind.h
index c863a8094c..e556b1878f 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -129,33 +129,6 @@ public:
RENDERING_DRIVER_OPENGL3,
};
- enum Weekday {
- DAY_SUNDAY,
- DAY_MONDAY,
- DAY_TUESDAY,
- DAY_WEDNESDAY,
- DAY_THURSDAY,
- DAY_FRIDAY,
- DAY_SATURDAY
- };
-
- enum Month {
- // Start at 1 to follow Windows SYSTEMTIME structure
- // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
- MONTH_JANUARY = 1,
- MONTH_FEBRUARY,
- MONTH_MARCH,
- MONTH_APRIL,
- MONTH_MAY,
- MONTH_JUNE,
- MONTH_JULY,
- MONTH_AUGUST,
- MONTH_SEPTEMBER,
- MONTH_OCTOBER,
- MONTH_NOVEMBER,
- MONTH_DECEMBER
- };
-
virtual PackedStringArray get_connected_midi_inputs();
virtual void open_midi_inputs();
virtual void close_midi_inputs();
@@ -583,8 +556,6 @@ VARIANT_ENUM_CAST(core_bind::ResourceLoader::CacheMode);
VARIANT_BITFIELD_CAST(core_bind::ResourceSaver::SaverFlags);
VARIANT_ENUM_CAST(core_bind::OS::RenderingDriver);
-VARIANT_ENUM_CAST(core_bind::OS::Weekday);
-VARIANT_ENUM_CAST(core_bind::OS::Month);
VARIANT_ENUM_CAST(core_bind::OS::SystemDir);
VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyBooleanOperation);
diff --git a/core/input/input.cpp b/core/input/input.cpp
index cb65d2569c..554f8fad00 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -540,6 +540,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
drag_event->set_position(position);
drag_event->set_relative(relative);
+ drag_event->set_tilt(mm->get_tilt());
+ drag_event->set_pen_inverted(mm->get_pen_inverted());
+ drag_event->set_pressure(mm->get_pressure());
drag_event->set_velocity(get_last_mouse_velocity());
event_dispatch_function(drag_event);
@@ -605,6 +608,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
motion_event.instantiate();
motion_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE);
+ motion_event->set_tilt(sd->get_tilt());
+ motion_event->set_pen_inverted(sd->get_pen_inverted());
+ motion_event->set_pressure(sd->get_pressure());
motion_event->set_position(sd->get_position());
motion_event->set_global_position(sd->get_position());
motion_event->set_relative(sd->get_relative());
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index 0a32b4bf68..4859490230 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -1223,6 +1223,30 @@ int InputEventScreenDrag::get_index() const {
return index;
}
+void InputEventScreenDrag::set_tilt(const Vector2 &p_tilt) {
+ tilt = p_tilt;
+}
+
+Vector2 InputEventScreenDrag::get_tilt() const {
+ return tilt;
+}
+
+void InputEventScreenDrag::set_pressure(float p_pressure) {
+ pressure = p_pressure;
+}
+
+float InputEventScreenDrag::get_pressure() const {
+ return pressure;
+}
+
+void InputEventScreenDrag::set_pen_inverted(bool p_inverted) {
+ pen_inverted = p_inverted;
+}
+
+bool InputEventScreenDrag::get_pen_inverted() const {
+ return pen_inverted;
+}
+
void InputEventScreenDrag::set_position(const Vector2 &p_pos) {
pos = p_pos;
}
@@ -1256,6 +1280,9 @@ Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, con
sd->set_window_id(get_window_id());
sd->set_index(index);
+ sd->set_pressure(get_pressure());
+ sd->set_pen_inverted(get_pen_inverted());
+ sd->set_tilt(get_tilt());
sd->set_position(p_xform.xform(pos + p_local_ofs));
sd->set_relative(p_xform.basis_xform(relative));
sd->set_velocity(p_xform.basis_xform(velocity));
@@ -1268,7 +1295,7 @@ String InputEventScreenDrag::as_text() const {
}
String InputEventScreenDrag::to_string() {
- return vformat("InputEventScreenDrag: index=%d, position=(%s), relative=(%s), velocity=(%s)", index, String(get_position()), String(get_relative()), String(get_velocity()));
+ return vformat("InputEventScreenDrag: index=%d, position=(%s), relative=(%s), velocity=(%s), pressure=%.2f, tilt=(%s), pen_inverted=(%s)", index, String(get_position()), String(get_relative()), String(get_velocity()), get_pressure(), String(get_tilt()), get_pen_inverted());
}
bool InputEventScreenDrag::accumulate(const Ref<InputEvent> &p_event) {
@@ -1292,6 +1319,15 @@ void InputEventScreenDrag::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenDrag::set_index);
ClassDB::bind_method(D_METHOD("get_index"), &InputEventScreenDrag::get_index);
+ ClassDB::bind_method(D_METHOD("set_tilt", "tilt"), &InputEventScreenDrag::set_tilt);
+ ClassDB::bind_method(D_METHOD("get_tilt"), &InputEventScreenDrag::get_tilt);
+
+ ClassDB::bind_method(D_METHOD("set_pressure", "pressure"), &InputEventScreenDrag::set_pressure);
+ ClassDB::bind_method(D_METHOD("get_pressure"), &InputEventScreenDrag::get_pressure);
+
+ ClassDB::bind_method(D_METHOD("set_pen_inverted", "pen_inverted"), &InputEventScreenDrag::set_pen_inverted);
+ ClassDB::bind_method(D_METHOD("get_pen_inverted"), &InputEventScreenDrag::get_pen_inverted);
+
ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventScreenDrag::set_position);
ClassDB::bind_method(D_METHOD("get_position"), &InputEventScreenDrag::get_position);
@@ -1302,6 +1338,9 @@ void InputEventScreenDrag::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_velocity"), &InputEventScreenDrag::get_velocity);
ADD_PROPERTY(PropertyInfo(Variant::INT, "index"), "set_index", "get_index");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "tilt"), "set_tilt", "get_tilt");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pressure"), "set_pressure", "get_pressure");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pen_inverted"), "set_pen_inverted", "get_pen_inverted");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_NONE, "suffix:px"), "set_position", "get_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative", PROPERTY_HINT_NONE, "suffix:px"), "set_relative", "get_relative");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "velocity", PROPERTY_HINT_NONE, "suffix:px/s"), "set_velocity", "get_velocity");
diff --git a/core/input/input_event.h b/core/input/input_event.h
index adbcb7cf68..06c3118abc 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -384,6 +384,9 @@ class InputEventScreenDrag : public InputEventFromWindow {
Vector2 pos;
Vector2 relative;
Vector2 velocity;
+ Vector2 tilt;
+ float pressure = 0;
+ bool pen_inverted = false;
protected:
static void _bind_methods();
@@ -392,6 +395,15 @@ public:
void set_index(int p_index);
int get_index() const;
+ void set_tilt(const Vector2 &p_tilt);
+ Vector2 get_tilt() const;
+
+ void set_pressure(float p_pressure);
+ float get_pressure() const;
+
+ void set_pen_inverted(bool p_inverted);
+ bool get_pen_inverted() const;
+
void set_position(const Vector2 &p_pos);
Vector2 get_position() const;
diff --git a/core/os/os.h b/core/os/os.h
index 07e9020a51..a5885b1aaa 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -34,6 +34,7 @@
#include "core/config/engine.h"
#include "core/io/image.h"
#include "core/io/logger.h"
+#include "core/os/time_enums.h"
#include "core/string/ustring.h"
#include "core/templates/list.h"
#include "core/templates/vector.h"
@@ -185,33 +186,6 @@ public:
virtual void yield();
- enum Weekday : uint8_t {
- WEEKDAY_SUNDAY,
- WEEKDAY_MONDAY,
- WEEKDAY_TUESDAY,
- WEEKDAY_WEDNESDAY,
- WEEKDAY_THURSDAY,
- WEEKDAY_FRIDAY,
- WEEKDAY_SATURDAY,
- };
-
- enum Month : uint8_t {
- /// Start at 1 to follow Windows SYSTEMTIME structure
- /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
- MONTH_JANUARY = 1,
- MONTH_FEBRUARY,
- MONTH_MARCH,
- MONTH_APRIL,
- MONTH_MAY,
- MONTH_JUNE,
- MONTH_JULY,
- MONTH_AUGUST,
- MONTH_SEPTEMBER,
- MONTH_OCTOBER,
- MONTH_NOVEMBER,
- MONTH_DECEMBER,
- };
-
struct DateTime {
int64_t year;
Month month;
diff --git a/core/os/time.cpp b/core/os/time.cpp
index a3c2c99b4c..3fc831d124 100644
--- a/core/os/time.cpp
+++ b/core/os/time.cpp
@@ -52,8 +52,8 @@ static const uint8_t MONTH_DAYS_TABLE[2][12] = {
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
-VARIANT_ENUM_CAST(Time::Month);
-VARIANT_ENUM_CAST(Time::Weekday);
+VARIANT_ENUM_CAST(Month);
+VARIANT_ENUM_CAST(Weekday);
#define UNIX_TIME_TO_HMS \
uint8_t hour, minute, second; \
diff --git a/core/os/time.h b/core/os/time.h
index 4b4ce3526a..379a224f34 100644
--- a/core/os/time.h
+++ b/core/os/time.h
@@ -32,6 +32,7 @@
#define TIME_H
#include "core/object/class_db.h"
+#include "time_enums.h"
// This Time class conforms with as many of the ISO 8601 standards as possible.
// * As per ISO 8601:2004 4.3.2.1, all dates follow the Proleptic Gregorian
@@ -51,33 +52,6 @@ class Time : public Object {
public:
static Time *get_singleton();
- enum Month {
- /// Start at 1 to follow Windows SYSTEMTIME structure
- /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
- MONTH_JANUARY = 1,
- MONTH_FEBRUARY,
- MONTH_MARCH,
- MONTH_APRIL,
- MONTH_MAY,
- MONTH_JUNE,
- MONTH_JULY,
- MONTH_AUGUST,
- MONTH_SEPTEMBER,
- MONTH_OCTOBER,
- MONTH_NOVEMBER,
- MONTH_DECEMBER,
- };
-
- enum Weekday : uint8_t {
- WEEKDAY_SUNDAY,
- WEEKDAY_MONDAY,
- WEEKDAY_TUESDAY,
- WEEKDAY_WEDNESDAY,
- WEEKDAY_THURSDAY,
- WEEKDAY_FRIDAY,
- WEEKDAY_SATURDAY,
- };
-
// Methods that convert times.
Dictionary get_datetime_dict_from_unix_time(int64_t p_unix_time_val) const;
Dictionary get_date_dict_from_unix_time(int64_t p_unix_time_val) const;
diff --git a/core/os/time_enums.h b/core/os/time_enums.h
new file mode 100644
index 0000000000..aa2d97a308
--- /dev/null
+++ b/core/os/time_enums.h
@@ -0,0 +1,63 @@
+/*************************************************************************/
+/* time_enums.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef TIME_ENUMS_H
+#define TIME_ENUMS_H
+
+#include <cstdint>
+
+enum Month {
+ /// Start at 1 to follow Windows SYSTEMTIME structure
+ /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
+ MONTH_JANUARY = 1,
+ MONTH_FEBRUARY,
+ MONTH_MARCH,
+ MONTH_APRIL,
+ MONTH_MAY,
+ MONTH_JUNE,
+ MONTH_JULY,
+ MONTH_AUGUST,
+ MONTH_SEPTEMBER,
+ MONTH_OCTOBER,
+ MONTH_NOVEMBER,
+ MONTH_DECEMBER,
+};
+
+enum Weekday : uint8_t {
+ WEEKDAY_SUNDAY,
+ WEEKDAY_MONDAY,
+ WEEKDAY_TUESDAY,
+ WEEKDAY_WEDNESDAY,
+ WEEKDAY_THURSDAY,
+ WEEKDAY_FRIDAY,
+ WEEKDAY_SATURDAY,
+};
+
+#endif // TIME_ENUMS_H
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index ac569941bf..57d62dac91 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -65,11 +65,13 @@ static _FORCE_INLINE_ void vc_method_call(R (T::*method)(P...) const, Variant *b
template <class T, class... P>
static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
+ VariantInternal::clear(&r_ret);
call_with_variant_args_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_error, p_defvals);
}
template <class T, class... P>
static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
+ VariantInternal::clear(&r_ret);
call_with_variant_argsc_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_error, p_defvals);
}