godotengine / godot-proposals

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

Allow InputEventJoypadMotion to have an Invalid Axis without error messages. #10754

Closed JulianHeuser closed 1 day ago

JulianHeuser commented 3 days ago

Describe the project you are working on

A first-person game with optional SteamInput support.

Describe the problem or limitation you are having in your project

I'm implementing optional SteamInput support, so I need a way to unbind all joystick controls without removing them, since I rely on the index to be kept in place.

For InputEventJoypadButton, I can set the button_index to JOY_BUTTON_INVALID (-1), and this effectively unbinds the input event. I can do the same for InputEventJoypadMotion by setting axis to JOY_AXIS_INVALID (-1), but this produces the following error:

E 0:00:00:0604   ControlsManager.gd:243 @ _ready(): Condition "p_axis < JoyAxis::LEFT_X || p_axis > JoyAxis::MAX" is true.
  <C++ Source>   core/input/input_event.cpp:1019 @ set_axis()
  <Stack Trace>  ControlsManager.gd:243 @ _ready()

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

I suggest allowing a InputEventJoypadMotion's axis to be set to JOY_BUTTON_INVALID without triggering the error, as well as adding an error for if InputEventJoypadButton's button_index is below JOY_BUTTON_INVALID or above JOY_BUTTON_MAX, to make behavior between the two more consistent.

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

N/A

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

Not as far as I'm aware, unless there's another way to unbind axes without changing any indices under the input action.

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

This involves error messages within the engine.

Mickeon commented 3 days ago

The main issue of the proposal is a surprisingly trivial change: https://github.com/godotengine/godot/pull/97068