ja funciona el audio
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "input.h"
|
||||
#include <SDL3/SDL_error.h> // Para SDL_GetError
|
||||
#include <SDL3/SDL.h> // Para SDL_GetError
|
||||
#include <SDL3/SDL_init.h> // Para SDL_INIT_GAMEPAD, SDL_InitSubSystem
|
||||
#include <SDL3/SDL_keyboard.h> // Para SDL_GetKeyboardState
|
||||
#include <algorithm> // Para find
|
||||
@@ -33,6 +33,9 @@ Input *Input::get()
|
||||
Input::Input(const std::string &game_controller_db_path)
|
||||
: game_controller_db_path_(game_controller_db_path)
|
||||
{
|
||||
// Inicializa el subsistema SDL_INIT_GAMEPAD
|
||||
initSDL();
|
||||
|
||||
// Busca si hay mandos conectados
|
||||
discoverGameControllers();
|
||||
|
||||
@@ -221,11 +224,6 @@ bool Input::discoverGameControllers()
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMEPAD) != 1)
|
||||
{
|
||||
SDL_InitSubSystem(SDL_INIT_GAMEPAD);
|
||||
}
|
||||
|
||||
if (SDL_AddGamepadMappingsFromFile(game_controller_db_path_.c_str()) < 0)
|
||||
{
|
||||
std::cout << "Error, could not load " << game_controller_db_path_.c_str() << " file: " << SDL_GetError() << std::endl;
|
||||
@@ -430,4 +428,19 @@ bool Input::checkAxisInput(InputAction input, int controller_index, bool repeat)
|
||||
// Mantener el estado actual
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Input::initSDL()
|
||||
{
|
||||
if (SDL_WasInit(SDL_INIT_GAMEPAD) != 1)
|
||||
{
|
||||
if (!SDL_InitSubSystem(SDL_INIT_GAMEPAD))
|
||||
{
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GAMEPAD could not initialize! SDL Error: %s", SDL_GetError());
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "SDL_GAMEPAD: Initialization complete.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user