write the function of joystick