This is not an explanation, but it appears to be almost fully working code. I don’t know which axes are which, but if you apply it to your robot, you can test what the controls do and adjust the axis names accordingly. However, I’m reluctant to hand out answers without explanations, so I’m obligated to remind you that if you copy code you don’t understand, when it breaks you can’t fix it and you don’t learn anything. Here is a post with five other links about x-drives, and maybe some of them will contain explanations of the code.
I’m going to look for a video I was once explaining it.* Actually, YouTube is another one of those free resourses with hard-to-find nuggets, so search it up yourself a few times.
* Found it.