-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Axis-based actions can get stuck as pressed #81164
Comments
cc @Sauermann |
Without a joypad I am having trouble replicating this issue. Not sure, how I can help with this. :-/ |
I cannot replicate this. System: In the reproduction project the action is tied to all devices. Could that cause some problems if there are more than one controller connected? With that "All devices" action only my number 1 controller works (Nintendo), controller 0 (Xbox360) doesn't work. I need to tie the action only to devide 0 or 1 to be able to use a certain controller. |
I have only one controller connected (Xbox One S). |
Can confirm (Windows 10, PS4 controller via DS4Windows), by wiggling the control stick to the right without recentering it the input gets stuck as pressed. |
I have code that emulates a joystick using This is my code for joystick emulation:
I tried releasing the event in a loop as workaround, but that seems to be an infinite loop. |
In case anyone else is currently working around this issue, I've had success by implementing analog ("joystick") input at a lower level, via:
For example, to work around how this issue impacts func _update_directions() -> void:
move_direction = _fixed_get_vector(JOY_AXIS_LEFT_X, JOY_AXIS_LEFT_Y).normalized()
look_direction = _fixed_get_vector(JOY_AXIS_RIGHT_X, JOY_AXIS_RIGHT_Y, LookMagnitude2)
# workaround https://github.com/godotengine/godot/issues/81164
func _fixed_get_vector(horizontal: JoyAxis, vertical: JoyAxis, dead_squared := DeadZone2) -> Vector2:
var vector := Vector2(Input.get_joy_axis(device, horizontal), Input.get_joy_axis(device, vertical))
return vector if vector.length_squared() >= dead_squared else Vector2.ZERO And to work around how this issue plus others in Godot 4 impact trigger-based actions, I'm using: # workaround https://github.com/godotengine/godot/issues/81164
# and https://github.com/godotengine/godot/issues/72636
var _trigger_actions = {
"dash": false,
"use": false,
}
func _read_triggers() -> void:
_read_trigger("dash", JOY_AXIS_TRIGGER_LEFT)
_read_trigger("use", JOY_AXIS_TRIGGER_RIGHT)
func _read_trigger(action: String, axis: JoyAxis) -> void:
var trigger := Input.get_joy_axis(device, axis)
if trigger >= DeadZone and not _trigger_actions[action]:
_trigger_actions[action] = true
_simulate_action(action, true)
elif trigger <= DeadZone and _trigger_actions[action]:
_trigger_actions[action] = false
_simulate_action(action, false)
func _simulate_action(action: String, pressed: bool) -> void:
var event = InputEventAction.new()
event.action = action
event.pressed = pressed
event.device = device
Input.parse_input_event(event) |
I can confirm this issue on macOS with Using the D-pad, pressing buttons will work for 1 second and then be stuck. Regarding the joystick, if I use it, the vector2 I get from |
I'm seeing this when using a key that is also on half an axis, works fine on a system using a joystick, but on a system without a joystick just using the key it will get stuck from time to time, no matter how many times the key is pressed or the key on the other side of the axis, the axis is stuck on left... |
I'm now getting this in 4.3 beta 1, in dev5 and below it is fine Holding arrow key down, then releasing, never gets released in engine, and always is pressed, rendering game unplayable |
Godot version
4.2 bc88dca
System information
Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 30.0.15.1403) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)
Issue description
After #80859 if you have an action that uses joypad axis, it can get stuck very easily and don't get released until more input. The
pressed
counter can go above 1, because multiple pressed events are received in a row, without equivalent release events that would release the action.Steps to reproduce
Minimal reproduction project
BrokenAxis.zip
The text was updated successfully, but these errors were encountered: