Merge pull request #116274 from Nintorch/inputevent-keyboard-mouse-ids

Add device IDs to keyboard and mouse input events
This commit is contained in:
Thaddeus Crews 2026-02-18 17:28:24 -06:00
commit ae604e73e0
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
6 changed files with 25 additions and 0 deletions

View file

@ -126,5 +126,11 @@
<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>
<constant name="DEVICE_ID_KEYBOARD" value="16">
Device ID used for input from a keyboard. This can be used to distinguish keyboard input events from joypad input events.
</constant>
<constant name="DEVICE_ID_MOUSE" value="32">
Device ID used for input from a mouse. This can be used to distinguish mouse input events from joypad input events.
</constant>
</constants>
</class>

View file

@ -10,6 +10,7 @@
<link title="Using InputEvent">$DOCS_URL/tutorials/inputs/inputevent.html</link>
</tutorials>
<members>
<member name="device" type="int" setter="set_device" getter="get_device" overrides="InputEvent" default="0" />
<member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)">
The local gesture position relative to the [Viewport]. If used in [method Control._gui_input], the position is relative to the current [Control] that received this gesture.
</member>

View file

@ -13,6 +13,7 @@
<member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" enum="MouseButtonMask" is_bitfield="true" default="0">
The mouse button mask identifier, one of or a bitwise combination of the [enum MouseButton] button masks.
</member>
<member name="device" type="int" setter="set_device" getter="get_device" overrides="InputEvent" default="32" />
<member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position" default="Vector2(0, 0)">
When received in [method Node._input] or [method Node._unhandled_input], returns the mouse's position in the root [Viewport] using the coordinate system of the root [Viewport].
When received in [method Control._gui_input], returns the mouse's position in the [CanvasLayer] that the [Control] is in using the coordinate system of the [CanvasLayer].

View file

@ -35,6 +35,7 @@
<member name="ctrl_pressed" type="bool" setter="set_ctrl_pressed" getter="is_ctrl_pressed" default="false">
State of the [kbd]Ctrl[/kbd] modifier.
</member>
<member name="device" type="int" setter="set_device" getter="get_device" overrides="InputEvent" default="16" />
<member name="meta_pressed" type="bool" setter="set_meta_pressed" getter="is_meta_pressed" default="false">
State of the [kbd]Meta[/kbd] modifier. On Windows and Linux, this represents the Windows key (sometimes called "meta" or "super" on Linux). On macOS, this represents the Command key.
</member>