Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation around InputEvent Device ID #7951

Open
donovani opened this issue Sep 18, 2023 · 3 comments
Open

Add documentation around InputEvent Device ID #7951

donovani opened this issue Sep 18, 2023 · 3 comments
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository enhancement topic:input

Comments

@donovani
Copy link

donovani commented Sep 18, 2023

Your Godot version:
4.1.1 C# Windows

Issue description:
InputEvent.Device does not have much documentation around it, & gives users the impression that it is a unique ID per device. However, (at least on my editor) it appears that the behavior is instead to assign device IDs that are unique to the device type (keyboard, mouse, joypad). If this is behavior that is consistent across platforms then this would be extremely helpful to document, given that this number is used by multiple methods of Input.

Valdiation:
Given the following code:

public partial class Foobar : Node3D
{
	public override void _Input(InputEvent e)
	{
		GD.Print(e.Device + "\t" + e.AsText());
	}
}
  1. Make an input with the keyboard - device ID is 0
  2. Make an input with the mouse - device ID is 0
  3. Make an input with a joypad - device ID is 0
  4. Make an input with a second joypad - device ID is 1

URL to the documentation page (if already existing):
https://docs.godotengine.org/en/stable/classes/class_inputevent.html#property-descriptions

@donovani donovani changed the title Add documentation Add documentation around InputEvent Device ID Sep 18, 2023
@Marenz
Copy link
Contributor

Marenz commented Dec 29, 2023

Related: godotengine/godot-proposals#7161

@Marenz
Copy link
Contributor

Marenz commented Dec 29, 2023

And also related: If you want to add an input mapping valid for all devices from code using InputMap.action_add_event, you must use -1 for the object passed to the event parameter.
This is also not documented.

@ievr
Copy link

ievr commented Jan 1, 2024

Got bitten by this not being documented and against initial intuition. One has to have two controllers to discover that the identifier counts per-device-type.

The relevant file is this one.
doc/classes/InputEvent.xml

@tetrapod00 tetrapod00 added area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository topic:input labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository enhancement topic:input
Projects
None yet
Development

No branches or pull requests

4 participants