working on game controller input

This commit is contained in:
2021-08-24 19:56:25 +02:00
parent 7c0201f913
commit 39a59336e4
2 changed files with 8 additions and 4 deletions

View File

@@ -1551,7 +1551,7 @@ void Game::renderScoreBoard()
color_t color = {0, 0, 0}; color_t color = {0, 0, 0};
// Si el jugador esta muerto, no pintes el fondo del marcador, así que pase por encima cuando sale despedido // Si el jugador esta muerto, no pintes el fondo del marcador, así que pase por encima cuando sale despedido
if (mPlayer[0]->isAlive()) //if (mPlayer[0]->isAlive())
mSpriteScoreBoard->render(); mSpriteScoreBoard->render();
// SCORE // SCORE

View File

@@ -1,5 +1,6 @@
#include "input.h" #include "input.h"
#include <stdio.h> #include <stdio.h>
#include <iostream>
// Constructor // Constructor
Input::Input(int source) Input::Input(int source)
@@ -185,16 +186,16 @@ bool Input::checkInput(Uint8 input, bool repeat)
// Comprueba si hay un mando conectado // Comprueba si hay un mando conectado
bool Input::discoverGameController() bool Input::discoverGameController()
{ {
if (SDL_NumJoysticks() < 1) /*if (SDL_NumJoysticks() < 1)
{ {
printf("Warning: No joysticks connected!\n"); printf("Warning: No joysticks connected!\n");
mGameControllerFound = false; mGameControllerFound = false;
std::cout << "Warning: No joysticks connected!\n";
} }
else else*/
{ {
// Carga el mando // Carga el mando
mGameController = SDL_GameControllerOpen(0); mGameController = SDL_GameControllerOpen(0);
mGameControllerFound = true;
if (mGameController == NULL) if (mGameController == NULL)
{ {
@@ -204,6 +205,9 @@ bool Input::discoverGameController()
else else
{ {
printf("%i joysticks were found.\n", SDL_NumJoysticks()); printf("%i joysticks were found.\n", SDL_NumJoysticks());
std::cout << "joysticks were found!\n";
mGameControllerFound = true;
//printf("%i buttons\n", SDL_JoystickNumButtons(mGameController)); //printf("%i buttons\n", SDL_JoystickNumButtons(mGameController));
// Obtiene el dispositivo de control háptico // Obtiene el dispositivo de control háptico