git repos / blockattack-game

blame: source/code/gamecontroller.cpp

normal view · raw

826cf176 sago007 2016-03-12 10:53 1
/*
826cf176 sago007 2016-03-12 10:53 2
===========================================================================
826cf176 sago007 2016-03-12 10:53 3
blockattack - Block Attack - Rise of the Blocks
826cf176 sago007 2016-03-12 10:53 4
Copyright (C) 2005-2016 Poul Sander
826cf176 sago007 2016-03-12 10:53 5
826cf176 sago007 2016-03-12 10:53 6
This program is free software: you can redistribute it and/or modify
826cf176 sago007 2016-03-12 10:53 7
it under the terms of the GNU General Public License as published by
826cf176 sago007 2016-03-12 10:53 8
the Free Software Foundation, either version 2 of the License, or
826cf176 sago007 2016-03-12 10:53 9
(at your option) any later version.
826cf176 sago007 2016-03-12 10:53 10
826cf176 sago007 2016-03-12 10:53 11
This program is distributed in the hope that it will be useful,
826cf176 sago007 2016-03-12 10:53 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
826cf176 sago007 2016-03-12 10:53 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
826cf176 sago007 2016-03-12 10:53 14
GNU General Public License for more details.
826cf176 sago007 2016-03-12 10:53 15
826cf176 sago007 2016-03-12 10:53 16
You should have received a copy of the GNU General Public License
826cf176 sago007 2016-03-12 10:53 17
along with this program.  If not, see http://www.gnu.org/licenses/
826cf176 sago007 2016-03-12 10:53 18
826cf176 sago007 2016-03-12 10:53 19
Source information and contacts persons can be found at
826cf176 sago007 2016-03-12 10:53 20
http://www.blockattack.net
826cf176 sago007 2016-03-12 10:53 21
===========================================================================
826cf176 sago007 2016-03-12 10:53 22
*/
826cf176 sago007 2016-03-12 10:53 23
826cf176 sago007 2016-03-12 10:53 24
#include "gamecontroller.h"
826cf176 sago007 2016-03-12 10:53 25
#include "SDL_gamecontroller.h"
826cf176 sago007 2016-03-12 10:53 26
#include <iostream>
826cf176 sago007 2016-03-12 10:53 27
826cf176 sago007 2016-03-12 10:53 28
void InitGameControllers() {
826cf176 sago007 2016-03-12 10:53 29
	std::cout << "Number of Game controllers: " << SDL_NumJoysticks() << std::endl;
826cf176 sago007 2016-03-12 10:53 30
	SDL_GameController *controller = nullptr;
826cf176 sago007 2016-03-12 10:53 31
	for (int i = 0; i < SDL_NumJoysticks(); ++i) {
826cf176 sago007 2016-03-12 10:53 32
		if (SDL_IsGameController(i)) {
826cf176 sago007 2016-03-12 10:53 33
			controller = SDL_GameControllerOpen(i);
826cf176 sago007 2016-03-12 10:53 34
			std::cout << "Supported game controller detected: " << SDL_GameControllerName(controller) << std::endl;
826cf176 sago007 2016-03-12 10:53 35
		}
826cf176 sago007 2016-03-12 10:53 36
	}
826cf176 sago007 2016-03-12 10:53 37
}
1970-01-01 00:00 38