Cleanups in the joystick code. Removed some redundant state and other confusions. Fixes Bugzilla #2738.