Add support for joystick controller pads (especially DPad)

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2019-09-29 19:12:09 +01:00
parent d8e4853971
commit 1577455a67
2 changed files with 9 additions and 0 deletions

View File

@ -103,5 +103,8 @@ namespace Gaming {
virtual void handleJoyButtonDown(SDL_JoyButtonEvent event) {}
virtual void handleJoyButtonUp(SDL_JoyButtonEvent event) {}
virtual void handleControllerButtonDown(SDL_ControllerButtonEvent event) {}
virtual void handleControllerButtonUp(SDL_ControllerButtonEvent event) {}
};
}

View File

@ -94,6 +94,12 @@ void Game::runLoop() {
case SDL_JOYBUTTONUP:
handleJoyButtonUp(e.jbutton);
break;
case SDL_CONTROLLERBUTTONDOWN:
handleControllerButtonDown(e.cbutton);
break;
case SDL_CONTROLLERBUTTONUP:
handleControllerButtonUp(e.cbutton);
break;
case SDL_JOYDEVICEADDED:
addJoystick(e);
break;