button detection code for gamepad