MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / InitGameControllers

Method InitGameControllers

src/InputManager.cpp:20–40  ·  view source on GitHub ↗

* Initialize game controller inputs */

Source from the content-addressed store, hash-verified

18 * Initialize game controller inputs
19 */
20void InputManager::InitGameControllers() {
21 //setup game controllers
22 int numControllers = 0;
23
24 //determine which are controllers
25 int numJoysticks = SDL_NumJoysticks();
26 for (int i = 0; i < numJoysticks; ++i) {
27 if (SDL_IsGameController(i)) {
28 ++numControllers;
29 }
30 }
31
32 //register all the controllers
33 for (int i = 0; i < numControllers; ++i) {
34 SDL_GameController* controller = SDL_GameControllerOpen(i);
35 if (SDL_GameControllerGetAttached(controller) == 1) {
36 connectedControllers.insert(controller);
37 }
38 }
39 SDL_GameControllerEventState(SDL_ENABLE);
40}
41
42void InputManager::tick() {
43 //action mappings

Callers

nothing calls this directly

Calls 6

SDL_NumJoysticksFunction · 0.85
SDL_IsGameControllerFunction · 0.85
SDL_GameControllerOpenFunction · 0.85
insertMethod · 0.45

Tested by

no test coverage detected