summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2024-03-15 18:10:41 +0100
committerHugo Locurcio <hugo.locurcio@hugo.pro>2024-03-16 19:16:40 +0100
commit6818e50adc06146aa3303acf78d95d783e3f653c (patch)
tree41ba3d311e9907bb318a2df51c884948825def28
parent68ad520da4365c866ceea42e0238b2ea24647289 (diff)
downloadredot-engine-6818e50adc06146aa3303acf78d95d783e3f653c.tar.gz
Expose `DEVICE_ID_EMULATION` constant in InputEvent
This also improves the documentation related to emulated InputEvents.
-rw-r--r--core/input/input_event.cpp2
-rw-r--r--doc/classes/InputEvent.xml7
2 files changed, 8 insertions, 1 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index bd1fde5a85..bf1de8d3b2 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -132,6 +132,8 @@ void InputEvent::_bind_methods() {
ClassDB::bind_method(D_METHOD("xformed_by", "xform", "local_ofs"), &InputEvent::xformed_by, DEFVAL(Vector2()));
ADD_PROPERTY(PropertyInfo(Variant::INT, "device"), "set_device", "get_device");
+
+ BIND_CONSTANT(DEVICE_ID_EMULATION);
}
///////////////////////////////////
diff --git a/doc/classes/InputEvent.xml b/doc/classes/InputEvent.xml
index 391d060fc3..96a4612466 100644
--- a/doc/classes/InputEvent.xml
+++ b/doc/classes/InputEvent.xml
@@ -117,7 +117,12 @@
<members>
<member name="device" type="int" setter="set_device" getter="get_device" default="0">
The event's device ID.
- [b]Note:[/b] This device ID will always be [code]-1[/code] for emulated mouse input from a touchscreen. This can be used to distinguish emulated mouse input from physical mouse input.
+ [b]Note:[/b] [member device] can be negative for special use cases that don't refer to devices physically present on the system. See [constant DEVICE_ID_EMULATION].
</member>
</members>
+ <constants>
+ <constant name="DEVICE_ID_EMULATION" value="-1">
+ Device ID used for emulated mouse input from a touchscreen, or for emulated touch input from a mouse. This can be used to distinguish emulated mouse input from physical mouse input, or emulated touch input from physical touch input.
+ </constant>
+ </constants>
</class>