porting over input handling from  xna code