Fixed bugs in joystick to motor value function

There were some bugs in the motor value function. I fixed them by changing how the function handles its input and output.