-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Resolve device ID conflict between joypads and mouse and keyboard #7161
Comments
Note that on some Android devices, ID 0 is taken by fingerprint reader and not joypad |
This prevents supporting multiple keyboards and mice as independent devices if we ever want to go for that route. While this isn't planned in the short term, I wouldn't want to write ourselves into a corner due to API design. |
A more general solution would be even better ... I just didn't want to overcomplicate 😅 Get devices: Get device type: connected mouse and keyboard: FYI: I am currently planning to use |
Related to this: If you want to add an input mapping for all devices, you currently have to use |
Also this becomes more relevant with godotengine/godot#79480 (comment) coming |
Describe the project you are working on
I am working on a game that supports local multiplayer (and I want to use the device ID to forward the input to the correct player).
Note: I am developing with Godot v4.0.3.stable.official [5222a99f5] on Linux
Describe the problem or limitation you are having in your project
If I understand correctly, IDs are working the following way:
-1
(Source)0
(Source: Testing)0
,1
,2
up to infinity 🚀 but whatever is returned by get_connected_joypads()Problem:
Since keyboard and mouse and the first controller share the same ID (
0
) I can't use it to uniquely refer to a device.Describe the feature / enhancement and how it helps to overcome the problem or limitation
Solution:
Change the ID for keyboard and mouse.
Option 1: Combined ID for keyboard and mouse
Possible solutions:
-2
as a new ID for keyboard and mouse, rest stays the same0
= keyboard and mouse,1
= touchscreen,2 and above
= joypadsOption 2: Separate ID for keyboard and mouse
I could imagine use cases (e.g. "asymmetric" coop where player 1 uses keyboard and player 2 uses only mouse) where it would be cleaner to differentiate between mouse and keyboard with IDs and not just by the events themselves ... but for most games it likely can be treated as one device
Possible solutions:
-2
for mouse and-3
for keyboard, rest stays the same0
= keyboard,1
= mouse,2
= touch,3 and above
= joypadsDescribe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I think code is straight forward, it's only about using different values. Problem is mainly that it would be a breaking change (even for option 1, solution 1)
If this enhancement will not be used often, can it be worked around with a few lines of script?
(1) I currently use the following code as a workaround (which is option 1, solution 1):
(Only problem is I have to map it every time I want to access the device ID, if forgotten can create input conflicts)
(2) Another workaround would be to prefix the joypad ID, e.g.
joypad_0
(3) Or increase the ID for joypads, e.g.
+= 1
, so joypad IDs start at1
and not at0
Is there a reason why this should be core and not an add-on in the asset library?
It's already core functionality
The text was updated successfully, but these errors were encountered: