I want to make a plane controller using SDL2. I want to use one joystick for pitch/roll. Y-axis sets the pitch-flaps, and X-axis sets the roll-flaps.
But there is one problem: Say I want to fully pitch and roll at the same time: I will hold the joystick at a 45 degree angle. But in SDL2, the joyAxis then get reported as 0.707... which is roughly half of the square root of 2. I understand why this happens: the physical joystick is restricted within a circle, so to move it up, you need to sacrifice a little bit of left/right. So the magnitude of the input vector is at most 1, instead of sqrt(2). How do I correct for this in code? I can't think of a good mapping.
I would like something like this:
float rawInput[2] = {0.707, 0.707};
float actualInput[2] = squaredCircle(rawInput); // {1,1}
rawInput = {1, 0};
actualInput = squaredCircle(rawInput); // {1,0}
What is a good squaredCircle
function?