how to write a program that can detect joystick and its movement?!!!!

plis help!!!!!! thanx!!!!!!