multiplication optimization

This commit is contained in:
NepEgor 2023-03-20 01:22:44 +04:00
parent 2688d5c281
commit 058c9d2449

View File

@ -109,10 +109,10 @@ TouchJoystick::TouchState TouchJoystick::touch(int8_t fid, int32_t tx, int32_t t
}
else // in bounds outside of outer dead zone
{
float len = sqrt(t2);
float factor = dead_zone_outer / sqrt(t2) * pos2usb;
x = (tx * dead_zone_outer / len) * pos2usb + usb_x;
y = (ty * dead_zone_outer / len) * pos2usb + usb_y;
x = tx * factor + usb_x;
y = ty * factor + usb_y;
}
if (invert_x) x = 2 * usb_x - x;