added time function and a fix for gamepad input