godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Add optional device number to Input polling methods #10775

Closed iiMidknightii closed 7 hours ago

iiMidknightii commented 1 day ago

Describe the project you are working on

A multiplayer game where I need to get the input vector on analog sticks from multiple controllers.

Describe the problem or limitation you are having in your project

I need to poll analog stick axes, button states, etc. from _process to allow players to directly control nodes' rotations and positions. Right now, there is Input.get_joy_axis which does support device filtering, but that doesn't have deadzones or a way to use mapped actions.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Maybe all the Input methods that poll action vectors, axes, or press states could have an optional device: int = 0 added to their API.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

var camera_vec := Input.get_vector("camera_look_left", "camera_look_right", "camera_look_down", "camera_look_up", -1.0, device)

If this enhancement will not be used often, can it be worked around with a few lines of script?

I'm not sure. I guess you could go through the convoluted process of looking through the entire InputMap, find your action, and use the events to poll. You'd also have to do all the other under-the-hood stuff like deadzone correction, etc.

Is there a reason why this should be core and not an add-on in the asset library?

I don't know if Input could be modified this way in an add-on.

Calinou commented 1 day ago

I feel a more generic solution like https://github.com/godotengine/godot-proposals/issues/4295 or https://github.com/godotengine/godot-proposals/issues/10070 would make more sense, as it would also work for is_action_pressed(), is_action_just_pressed() and the like.

iiMidknightii commented 19 hours ago

Yeah those proposals look like they are pretty much the same thing but with a lot extra, so mine is probably a (much simpler) duplicate.

Calinou commented 7 hours ago

Thanks for the proposal! Consolidating in https://github.com/godotengine/godot-proposals/issues/4295 and https://github.com/godotengine/godot-proposals/issues/10070.