Skip to content

Commit

Permalink
Merge pull request #89526 from Calinou/inputevent-add-emulation-inter…
Browse files Browse the repository at this point in the history
…nal-constants

Expose `DEVICE_ID_EMULATION` constant in InputEvent
  • Loading branch information
akien-mga committed Mar 24, 2024
2 parents 4389f85 + 6818e50 commit 5940fd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/input/input_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

///////////////////////////////////
Expand Down
7 changes: 6 additions & 1 deletion doc/classes/InputEvent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 5940fd5

Please sign in to comment.