Rebase and mods from maheshkk (Gamepad support).