DS4Windows icon indicating copy to clipboard operation
DS4Windows copied to clipboard

Ability to Calibrate Analog Stick Center

Open BigheadSMZ opened this issue 2 years ago • 2 comments

Currently there is no way to calibrate the "center" of analog sticks. My joycons were drifting so I replaced the analogs in them with 3rd party replacements. They are not as accurate as the original analog sticks, the center on the left joycon is slightly off to the left, and the center on the right analog stick is slightly off to the top.

Thinking this could be fixed in non-convenient ways, I started digging into where the joycon stores its calibration data. There is two sets in the firmware: factory calibration (x603D-x604E) and user calibration (x8010-x8025). I stumbled onto a program called "Joy Con Toolkit" which allows dumping the SPI of the joycons. After a little while, I learned where the analog center/min/max values are and how they are stored. I managed to figure out new values, edit them in a hex editor, then upload the modified SPI to the joycon. When testing on my Switch.. perfect! When testing on DS4Windows, not so perfect...

My assumption is that DS4Windows doesn't even read the calibration data (either user or factory), and instead just uses the raw values of the analog sticks. Altering the calibration data of either has zero effect on where the "center" is determined. So I was wondering if it's possible to add some feature to calibrate analog sticks natively in DS4Windows. Even something like an "offset value" to the default center value would suffice.

For example, my left joycon default "X" value is 118, adding an offset of "10" would make it perfectly centered. My right joycon default "Y" value is 133, adding an offset of "-5" would fix that. I think this would be rather simple to implement and it would be easy to use. There should be no issues applying the offset to the entire range (e.g. wherever the stick is currently positioned), as when I'm playing any game, my character runs slightly to the left when pushing the analog straight up. Which means the X/Y values in that situation are 118/0 where having an offset of 10 would put it perfectly at 128/0.

Now I know similar results can be had with just throwing a deadzone in there (Edit: although, this will not fix the problem above, forward-movement will always be slightly tilted to the left). But the joycons are already starving for range, the joycon analog sticks aren't exactly the greatest. And I've seen reports where the centering on replacement sticks is way worse than the ones I'm using. I eventually intend to purchase and try out the Gulikit analog sticks for the joycons, which uses hall effect sensors so they never wear out. Not sure if they will give a perfect center by default, from a youtube video, when someone tested on a real switch, it was off far enough a deadzone would have crippled half of the range. Luckily the switch allows calibration.

Obviously an alternative to all of this would be to somehow read the calibration data off the joycon itself. Yuzu appears to do this. If I connect my controllers directly to Yuzu without using something like DS4Windows or BetterJoy, the calibration is perfect. But that's all, sorry for the long winded rant. I've been using DS4Windows for years, and the lack of a means to calibrate is the only problem I've ever had with it. I replaced the analogs on a DS3 controller years ago, similar calibration issue using DSHMC + DS4Windows, and eventually gave up.

BigheadSMZ avatar May 05 '23 10:05 BigheadSMZ

I plan on taking off the current JoyCon stick coordinate compensation with the next release of DS4Windows; it only seems to work well for my JoyCons. The problem is not finding the current stick center but finding the reachable ends of the analog stick. The factory provided numbers given by the JoyCon can almost never be fully reached unless you really try to jam the stick in a certain direction. The main workaround is to shrink the circle down and adjust the center based on the new bounds. Although, that is not really the approach DS4Windows uses for JoyCons because LX(?) is messed up on my Left JoyCon so a larger portion of the coordinates are cut off; the cut off coordinates are not symmetrical either IIRC.

Normally, I would assume people trying to use JoyCons on PC already have a Switch console. DS4Windows can pull the calibration data from a JoyCon that has been set from a Switch and that is the main way I would recommend calibrating a JoyCon analog stick. I believe there is a way to perform the same calibration on PC but I cannot remember the program used to do it.

Ryochan7 avatar May 26 '23 18:05 Ryochan7

Ended up adding a different workaround. Instead of adding a center offset, the stick position is read for the first input report received and compared to the mid position given by the calibration data. Either the max or min calibration position will be adjusted depending on which direction the first stick position favors. It seems to work well enough for me and it solves my original problem with my JoyCon L stick.

https://github.com/Ryochan7/DS4Windows/commit/1bb44dcd87fa99322184cec8a239abdc0da010b2

Ryochan7 avatar Jun 23 '23 17:06 Ryochan7