Inserting this at the end of Player::handleInput will add gamepad support:
// Joystick D-pad movement and firing with A-button and right shoulder/trigger
const unsigned number{ static_cast<unsigned>(m_number) };
if (sf::Joystick::isConnected(number))
{
m_movingUp |= sf::Joystick::isButtonPressed(number, 13u);
m_movingDown |= sf::Joystick::isButtonPressed(number, 14u);
m_movingLeft |= sf::Joystick::isButtonPressed(number, 15u);
m_movingRight |= sf::Joystick::isButtonPressed(number, 16u);
m_fireLaser |= sf::Joystick::isButtonPressed(number, 0u) || sf::Joystick::isButtonPressed(number, 5u) || sf::Joystick::isButtonPressed(number, 7u);
}
It only uses buttons, because getting stick positions is a bit more complicated since that requires event polling. D-pad moves the character and you can fire the laser with the A-button, the right shoulder or right trigger. Only tested with a PS3 Sixaxis controller, but it works. Other joysticks might be mapped differently.