MCPcopy Create free account
hub / github.com/AntiMicroX/antimicrox / getNormalizedAbsoluteDistance

Method getNormalizedAbsoluteDistance

src/joycontrolstick.cpp:707–722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

705}
706
707double JoyControlStick::getNormalizedAbsoluteDistance()
708{
709 int axis1Value = axisX->getCurrentRawValue();
710 int axis2Value = axisY->getCurrentRawValue();
711
712 int square_dist = (axis1Value * axis1Value) + (axis2Value * axis2Value);
713
714 double distance = sqrt(square_dist) / static_cast<double>(maxZone);
715
716 if (distance > 1.0)
717 distance = 1.0;
718 else if (distance < 0.0)
719 distance = 0.0;
720
721 return distance;
722}
723
724double JoyControlStick::getRadialDistance(int axisXValue, int axisYValue)
725{

Callers

nothing calls this directly

Calls 1

getCurrentRawValueMethod · 0.80

Tested by

no test coverage detected