[3.x] Reset joy axes and buttons after joy disconnection#106212
[3.x] Reset joy axes and buttons after joy disconnection#106212orlambda wants to merge 2 commits intogodotengine:3.xfrom
Conversation
lawnjelly
left a comment
There was a problem hiding this comment.
I'm not super expert in the joystick handling but I think this looks correct.
Would be nice to get some input ( 😁 ) from a more regular input contributor to check so I'll post on rocketchat before going further.
MJacred
left a comment
There was a problem hiding this comment.
I probably don't count as a more regular input contributor, but here I go:
The approach is a hack-fix, as it basically sends another event for a device that has been disconnected.
this results currently in…
- one InputEventJoypadMotion event in
_input(with axis ==0.0) for each axis I used before disconnecting. It makes no difference whether I hold the stick on disconnect or not - the first
_process()call after disconnect outputs the axis value when usingInput.get_action_strength, not0.0
|
Just posting this for the author so they can see as discussed in input on rocketchat: MJacred lawnjelly MJacred lawnjelly MJacred lawnjelly or something like that (pseudocode)? MJacred lawnjelly MJacred |
Only sends axis event if value is not 0.0 Parses events immediately without pushing to buffered_events Removes axes from _joy_axis map
|
I tried to address the issues mentioned in the latest commit: Axes are now removed from the map using An event is now only sent for an axis if its value is not Events are now parsed immediately, rather than pushed to I couldn't observe the first (I'm using a PS5 controller on macOS 15.5. On disconnection I see values change to a #84943 addresses this in a different way in Godot 4 by updating |
|
Does this PR deal with i.e. could it clear out the current state, but then when Maybe we need to go through Another possible flaw is whether it is actually ok to call |
|
I don't know if it's ok to use Yes we'd need to deal with I think it's premature to implement the above before it's clear that pushing the reset events ahead of If I understand correctly, the point of this is to eliminate a one frame delay in resetting the values. I wonder if that would be an acceptably minor issue given the contexts in which joypads would usually be disconnected? |
|
Any thoughts on what this needs to move forward? |
Sorry I didn't see your original reply. It's a while since I read the PR but my own main concern I think was the So the implication is that when removing a controller we should probably also go through As I say I'm not an input specialist so I'm having to play it safe here unless we get an approval from an input maintainer. Another alternative might be to post the controller removed message to the It would be nice to have some testing additionally on platforms that use buffered input. Don't get me wrong, I suspect the PR as is is probably better than what we have already, but it would be nice to get it all fixed here in a sensible way rather than leaving potential further bugs open, especially on platforms that use buffered input. |
Ubuntu. |
|
Thanks, is there anyone you know from input you could bring in to have a look? |
Fixes #105047