Emscripten: Simplified implementation of joystick update function. The function was implemented using four loops but only needed two.