Skip to content

Set inputs to 0 upon controller disconnect#177

Open
charlielee206 wants to merge 1 commit into
DanielOgorchock:masterfrom
charlielee206:master
Open

Set inputs to 0 upon controller disconnect#177
charlielee206 wants to merge 1 commit into
DanielOgorchock:masterfrom
charlielee206:master

Conversation

@charlielee206

Copy link
Copy Markdown

tl;dr: Set inputs to 0 upon controller disconnect.

I don't know if this was a bug or a feature, but I found out that if the joycons disconnected while in use, the last button states were kept until the controller was reconnected.
I found this quite annoying, especially since my switch is old, and the slack in the rails cause the controllers tend to disconnect for a short while. even a short disconnect creates a "phantom drift" state where the mouse pointer keeps drifting. I would have to wait until the controller reconnected to stop this movement.
Also, if the controller was receiving an input while it was disconnected, it took significantly longer to reconnect. I assume this is due to some kind of packet loss assumption -> timeout operation on the kernel level. This additional reconnection delay combined with the previous issue and caused me a headache.

I made some simple changes to the code so it resets every input to 0 when it detects a controller disconnect. This seemed to fix both the "phantom drift upon controller disconnect" problem and "Takes longer to reconnect" problems.

This "fix" still does not take care of everything. If the stick is not at (0,0) while being reconnected, the cursor will be whipped back in the opposite direction upon release of the stick. I assume this is due to a calibration process upon controller connection, and the process tries to make up for an massive imaginary stick drift. I'm sure someone smarter than me will be able to create some kind of stick state memory and compare it and sync it upon reconnection or something.

I do not know enough about linux driver programming or programming in general to know what problems this "fix" will cause, but it worked for me, and I am hoping it will work for someone else, or someone smarter than me will look at the code and make a better fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant