The first thing that is going to happen we are going to create new variables as such:
We are creating these variables as type int because the controller outputs only whole integers, and so there is no need for float point variables.
next you want to assign these variables a value and that value will come from the controller joystick axes. Mine are set to drive and turn from the right, while the left is for strafing. So if your on VEXcode it will look little something like such:
power = Controller1.Axis2.value();
turn = Controller1.Axis1.value();
strafe = Controller1.Axis4.value();
You then add this these values to new variables which will become your motor output like such
*note you should instantiate this variables together and not as we go along I am theoretically instantiate them apart for the ease of explanation.
int lfPower, lbPower, rfPower, rbPower;
after that you utilize the code I gave above to to combine the variables to one value for motor output:
lfPower = (power + turn + strafe) * (scaler);
lbPower = (power + turn - strafe) * (scaler);
rfPower = (power - turn - strafe) * (scaler);
rbPower = (power - turn + strafe) * (scaler);
The scaler in the code above can be set to anything you like, or completely remove and will act like sensitivity.
The last step is output the code to the motors. again this is going to be used in the correct syntax for VEX code
lf.spin(fwd, lfPower voltageUnits::volt);
lb.spin(fwd, lbPower, voltageUnits::volt);
rf.spin(fwd, rfPower voltageUnits::volt);
rb.spin(fwd, rbPower, voltageUnits::volt);
This should leave you with working X-drive code. if you have any issues feel free to DM me or reply on the thread.