I am trying to get an average sensitivity level between two joysticks Y axis.
Fully pressed UP is a value of 0
Fully pressed DOWN is a value of 100
.
(So I'm basically working with percentages)
The neutral zone (when the stick is not being pressed) is a value of 50 (with a padding of 3, so..)
The neutral zone for UP ends at 47
The neutral zone for DOWN ends at 53
I am able to find the average sensitivity when both sticks are pressed up or down together by using the equation:
avgSens:= (JoyY + JoyZ)/2
Both sticks values count the same direction so there is no problem here.
My problem begins when one stick is pressed up but the other is pressed down.
I want to find the average sensitivity level in the ranges of 0 to 47
and 53 to 100
and when one counts one direction but the other counts the other..
I imagine that the easiest way to do this would be to make them both count the same way.
For example if JoyY
were to be pressed to 100(down)
and JoyZ
were to be pressed to 0(up)
all I'd have to do is find the inverted value of one or the other (Counting in the same direction) and then use the same equation as before
newJoyZ:= *some equation goes here..*
avgSens:= (JoyY + newJoyZ)/2
But for the life of me I can't figure out how to find the inverted percentage of 100.
I've tried things like (JoyY + ((100-JoyZ)*2))/2
and it's just a horrible mess.
I'll be happy to provide example code or more information if necessary, please go easy on me, my math is terrible.. and thank you in advance for any help you can provide.