guardar partida pq ja estic fent canvis a cegues a vore si trac açò

This commit is contained in:
2024-07-07 14:38:46 +02:00
parent 3ee04f7e1c
commit ceafe931f1
14 changed files with 201 additions and 111 deletions

View File

@@ -25,7 +25,8 @@ INCLUDES:= -I$(DIR_SOURCES)
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
FixPath = $(subst /,\,$1) FixPath = $(subst /,\,$1)
SOURCES := source/*.cpp source/common/*.cpp SOURCES := source/*.cpp source/common/*.cpp
CXXFLAGS:= -std=c++11 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ CXXFLAGS:= -std=c++11 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows
CXXFLAGS2:= -std=c++11 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++
LDFLAGS := -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32 LDFLAGS := -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32
RM = del /Q RM = del /Q
MKD:= mkdir MKD:= mkdir
@@ -127,19 +128,16 @@ raspi5:
windows: windows:
@echo off @echo off
$(CXX) $(SOURCES) $(CXXFLAGS) -Wl,-subsystem,windows $(LDFLAGS) -o "$(TARGET_FILE).exe" $(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE).exe"
strip -s -R .comment -R .gnu.version "$(TARGET_FILE).exe" --strip-unneeded strip -s -R .comment -R .gnu.version "$(TARGET_FILE).exe" --strip-unneeded
windows_rec: windows_rec:
@echo off @echo off
$(CXX) $(SOURCES) -D RECORDING $(CXXFLAGS) -Wl,-subsystem,windows $(LDFLAGS) -o "$(TARGET_FILE)_rec.exe" $(CXX) $(SOURCES) -D RECORDING $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)_rec.exe"
windows_debug: windows_debug:
@echo off @echo off
$(CXX) $(SOURCES) -D DEBUG $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)_debug.exe" $(CXX) $(SOURCES) -D VERBOSE $(CXXFLAGS2) $(LDFLAGS) -o "$(TARGET_FILE)_debug.exe"
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)_debug.exe" --strip-unneeded
windows_release: windows_release:
@echo off @echo off
@@ -167,19 +165,15 @@ windows_release:
# Elimina la carpeta temporal 'RELEASE_FOLDER' # Elimina la carpeta temporal 'RELEASE_FOLDER'
powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force} powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force}
macos: macos:
$(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)" $(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
macos_fast: macos_fast:
$(CXX) $(SOURCES) -D VERBOSE -std=c++11 -Wall -Wno-deprecated -lSDL2 -framework OpenGL -o "$(TARGET_FILE)" $(CXX) $(SOURCES) -D VERBOSE -std=c++11 -Wall -Wno-deprecated -lSDL2 -framework OpenGL -o "$(TARGET_FILE)"
macos_debug: macos_debug:
$(CXX) $(SOURCES) -D DEBUG $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)_debug" $(CXX) $(SOURCES) -D DEBUG $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
macos_release: macos_release:
# Elimina datos de compilaciones anteriores # Elimina datos de compilaciones anteriores
rm -rdf "$(RELEASE_FOLDER)" rm -rdf "$(RELEASE_FOLDER)"
@@ -226,17 +220,14 @@ macos_release:
$(RM) Frameworks $(RM) Frameworks
$(RM) "$(RELEASE_FOLDER)" $(RM) "$(RELEASE_FOLDER)"
linux: linux:
$(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)" $(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)" --strip-unneeded strip -s -R .comment -R .gnu.version "$(TARGET_FILE)" --strip-unneeded
linux_debug: linux_debug:
$(CXX) $(SOURCES) -D DEBUG $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)_debug" $(CXX) $(SOURCES) -D DEBUG $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)_debug" --strip-unneeded strip -s -R .comment -R .gnu.version "$(TARGET_FILE)_debug" --strip-unneeded
linux_release: linux_release:
# Elimina carpetas previas # Elimina carpetas previas
$(RM) "$(RELEASE_FOLDER)" $(RM) "$(RELEASE_FOLDER)"

View File

@@ -4,10 +4,17 @@
// Constructor // Constructor
Input::Input(std::string file) Input::Input(std::string file)
{ {
// Inicializa variables
verbose = false;
enabled = true;
// Fichero gamecontrollerdb.txt // Fichero gamecontrollerdb.txt
dbPath = file; dbPath = file;
// Inicializa las variables // Busca si hay mandos conectados
discoverGameControllers();
// Inicializa las vectores
keyBindings_t kb; keyBindings_t kb;
kb.scancode = 0; kb.scancode = 0;
kb.active = false; kb.active = false;
@@ -16,10 +23,11 @@ Input::Input(std::string file)
GameControllerBindings_t gcb; GameControllerBindings_t gcb;
gcb.button = SDL_CONTROLLER_BUTTON_INVALID; gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
gcb.active = false; gcb.active = false;
gameControllerBindings.resize(input_number_of_inputs, gcb); gameControllerBindings.resize(numGamepads);
for (int i = 0; i < numGamepads; ++i)
verbose = true; {
enabled = true; gameControllerBindings[i].resize(input_number_of_inputs, gcb);
}
// Listado de los inputs usados para jugar, excluyendo botones para la interfaz // Listado de los inputs usados para jugar, excluyendo botones para la interfaz
gameInputs.clear(); gameInputs.clear();
@@ -55,9 +63,13 @@ void Input::bindKey(inputs_e input, SDL_Scancode code)
} }
// Asigna inputs a botones del mando // Asigna inputs a botones del mando
void Input::bindGameControllerButton(inputs_e input, SDL_GameControllerButton button) void Input::bindGameControllerButton(int index, inputs_e input, SDL_GameControllerButton button)
{ {
gameControllerBindings[input].button = button; if (index >= (int)connectedControllers.size())
{
return;
}
gameControllerBindings[index][input].button = button;
} }
// Comprueba si un input esta activo // Comprueba si un input esta activo
@@ -125,7 +137,7 @@ bool Input::checkInput(inputs_e input, bool repeat, int device, int index)
{ {
if (repeat) if (repeat)
{ {
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) != 0)
{ {
successGameController = true; successGameController = true;
} }
@@ -136,11 +148,11 @@ bool Input::checkInput(inputs_e input, bool repeat, int device, int index)
} }
else else
{ {
if (!gameControllerBindings[input].active) if (!gameControllerBindings[index][input].active)
{ {
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) != 0)
{ {
gameControllerBindings[input].active = true; gameControllerBindings[index][input].active = true;
successGameController = true; successGameController = true;
} }
else else
@@ -150,9 +162,9 @@ bool Input::checkInput(inputs_e input, bool repeat, int device, int index)
} }
else else
{ {
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) == 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) == 0)
{ {
gameControllerBindings[input].active = false; gameControllerBindings[index][input].active = false;
successGameController = false; successGameController = false;
} }
else else
@@ -180,8 +192,9 @@ bool Input::checkAnyInput(int device, int index)
for (int i = 0; i < (int)keyBindings.size(); ++i) for (int i = 0; i < (int)keyBindings.size(); ++i)
{ {
if (mKeystates[keyBindings[i].scancode] != 0) if (mKeystates[keyBindings[i].scancode] != 0 && !keyBindings[i].active)
{ {
keyBindings[i].active = true;
return true; return true;
} }
} }
@@ -193,8 +206,9 @@ bool Input::checkAnyInput(int device, int index)
{ {
for (int i = 0; i < (int)gameControllerBindings.size(); ++i) for (int i = 0; i < (int)gameControllerBindings.size(); ++i)
{ {
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[i].button) != 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][i].button) != 0 && !gameControllerBindings[index][i].active)
{ {
gameControllerBindings[index][i].active = true;
return true; return true;
} }
} }
@@ -204,21 +218,22 @@ bool Input::checkAnyInput(int device, int index)
return false; return false;
} }
// Comprueba si hay algún botón pulsado. Devuelve 0 en caso de no encontrar nada o el indice del dispositivo + 1. // Comprueba si hay algún botón pulsado. Devuelve 0 en caso de no encontrar nada o el indice del dispositivo + 1. Se hace así para poder gastar el valor devuelto como un valor "booleano"
int Input::checkAnyButtonPressed() int Input::checkAnyButtonPressed(bool repeat)
{ {
const Uint8 *keyStates = SDL_GetKeyboardState(nullptr); // Solo comprueba los botones
for (auto bi : buttonInputs) for (auto bi : buttonInputs)
{ {
if (keyStates[keyBindings[bi].scancode] != 0) // Comprueba el teclado
if (checkInput(bi, repeat, INPUT_USE_KEYBOARD))
{ {
return 1; return 1;
} }
// Comprueba los mandos
for (int i = 0; i < numGamepads; ++i) for (int i = 0; i < numGamepads; ++i)
{ {
if (SDL_GameControllerGetButton(connectedControllers[i], gameControllerBindings[bi].button) != 0) if (checkInput(bi, repeat, INPUT_USE_GAMECONTROLLER, i))
{ {
return i + 1; return i + 1;
} }
@@ -228,8 +243,8 @@ int Input::checkAnyButtonPressed()
return 0; return 0;
} }
// Busca si hay un mando conectado // Busca si hay mandos conectados
bool Input::discoverGameController() bool Input::discoverGameControllers()
{ {
bool found = false; bool found = false;
@@ -281,7 +296,7 @@ bool Input::discoverGameController()
const std::string separator(" #"); const std::string separator(" #");
std::string name = SDL_GameControllerNameForIndex(i); std::string name = SDL_GameControllerNameForIndex(i);
// name.resize(25); // name.resize(25);
name = name + separator + std::to_string(i); // name = name + separator + std::to_string(i);
if (verbose) if (verbose)
{ {
std::cout << name << std::endl; std::cout << name << std::endl;
@@ -359,7 +374,68 @@ void Input::enable()
int Input::getJoyIndex(int id) int Input::getJoyIndex(int id)
{ {
for (int i = 0; i < numJoysticks; ++i) for (int i = 0; i < numJoysticks; ++i)
{
if (SDL_JoystickInstanceID(joysticks[i]) == id) if (SDL_JoystickInstanceID(joysticks[i]) == id)
{
return i; return i;
}
}
return -1; return -1;
} }
// Muestra por consola los controles asignados
void Input::printBindings(int device, int index)
{
if (device == INPUT_USE_ANY)
{
return;
}
if (device == INPUT_USE_KEYBOARD)
{
return;
}
if (device == INPUT_USE_GAMECONTROLLER)
{
if (index >= numGamepads)
{
return;
}
// Muestra el nombre del mando
std::cout << "\n" << controllerNames[index] << std::endl;
// Muestra los botones asignados
for (auto bi : buttonInputs)
{
std::cout << to_String(bi) << " : " << gameControllerBindings[index][bi].button << std::endl;
}
}
}
// Convierte un inputs_e a std::string
std::string Input::to_String(inputs_e input)
{
if (input == input_fire_left)
{
return "input_fire_left";
}
if (input == input_fire_center)
{
return "input_fire_center";
}
if (input == input_fire_right)
{
return "input_fire_right";
}
if (input == input_start)
{
return "input_start";
}
return "";
}

View File

@@ -45,8 +45,8 @@ enum inputs_e
input_number_of_inputs input_number_of_inputs
}; };
#define REPEAT_TRUE true #define ALLOW_REPEAT true
#define REPEAT_FALSE false #define DO_NOT_ALLOW_REPEAT false
#define INPUT_USE_KEYBOARD 0 #define INPUT_USE_KEYBOARD 0
#define INPUT_USE_GAMECONTROLLER 1 #define INPUT_USE_GAMECONTROLLER 1
@@ -78,7 +78,7 @@ private:
std::vector<SDL_GameController *> connectedControllers; // Vector con todos los mandos conectados std::vector<SDL_GameController *> connectedControllers; // Vector con todos los mandos conectados
std::vector<SDL_Joystick *> joysticks; // Vector con todos los joysticks conectados std::vector<SDL_Joystick *> joysticks; // Vector con todos los joysticks conectados
std::vector<keyBindings_t> keyBindings; // Vector con las teclas asociadas a los inputs predefinidos std::vector<keyBindings_t> keyBindings; // Vector con las teclas asociadas a los inputs predefinidos
std::vector<GameControllerBindings_t> gameControllerBindings; // Vector con las teclas asociadas a los inputs predefinidos std::vector<std::vector<GameControllerBindings_t>> gameControllerBindings; // Vector con los botones asociadas a los inputs predefinidos para cada mando
std::vector<std::string> controllerNames; // Vector con los nombres de los mandos std::vector<std::string> controllerNames; // Vector con los nombres de los mandos
std::vector<inputs_e> gameInputs; // Inputs usados para jugar, normalmente direcciones y botones std::vector<inputs_e> gameInputs; // Inputs usados para jugar, normalmente direcciones y botones
std::vector<inputs_e> buttonInputs; // Inputs asignados al jugador y a botones, excluyendo direcciones std::vector<inputs_e> buttonInputs; // Inputs asignados al jugador y a botones, excluyendo direcciones
@@ -89,6 +89,9 @@ private:
i_disable_e disabledUntil; // Tiempo que esta deshabilitado i_disable_e disabledUntil; // Tiempo que esta deshabilitado
bool enabled; // Indica si está habilitado bool enabled; // Indica si está habilitado
// Convierte un inputs_e a std::string
std::string to_String(inputs_e input);
public: public:
// Constructor // Constructor
Input(std::string file); Input(std::string file);
@@ -100,7 +103,7 @@ public:
void bindKey(inputs_e input, SDL_Scancode code); void bindKey(inputs_e input, SDL_Scancode code);
// Asigna inputs a botones del mando // Asigna inputs a botones del mando
void bindGameControllerButton(inputs_e input, SDL_GameControllerButton button); void bindGameControllerButton(int index, inputs_e input, SDL_GameControllerButton button);
// Comprueba si un input esta activo // Comprueba si un input esta activo
bool checkInput(inputs_e input, bool repeat = true, int device = INPUT_USE_ANY, int index = 0); bool checkInput(inputs_e input, bool repeat = true, int device = INPUT_USE_ANY, int index = 0);
@@ -109,10 +112,10 @@ public:
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0); bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);
// Comprueba si hay algún botón pulsado // Comprueba si hay algún botón pulsado
int checkAnyButtonPressed(); int checkAnyButtonPressed(bool repeat = DO_NOT_ALLOW_REPEAT);
// Busca si hay un mando conectado // Busca si hay mandos conectados
bool discoverGameController(); bool discoverGameControllers();
// Comprueba si hay algun mando conectado // Comprueba si hay algun mando conectado
bool gameControllerFound(); bool gameControllerFound();
@@ -134,6 +137,9 @@ public:
// Obtiene el indice del controlador a partir de un event.id // Obtiene el indice del controlador a partir de un event.id
int getJoyIndex(int id); int getJoyIndex(int id);
// Muestra por consola los controles asignados
void printBindings(int device = INPUT_USE_KEYBOARD, int index = 0);
}; };
#endif #endif

View File

@@ -901,7 +901,7 @@ void Menu::setDefaultActionWhenCancel(int item)
// Gestiona la entrada de teclado y mando durante el menu // Gestiona la entrada de teclado y mando durante el menu
void Menu::checkInput() void Menu::checkInput()
{ {
if (input->checkInput(input_up, REPEAT_FALSE)) if (input->checkInput(input_up, DO_NOT_ALLOW_REPEAT))
{ {
if (decreaseSelectorIndex()) if (decreaseSelectorIndex())
{ {
@@ -912,7 +912,7 @@ void Menu::checkInput()
} }
} }
if (input->checkInput(input_down, REPEAT_FALSE)) if (input->checkInput(input_down, DO_NOT_ALLOW_REPEAT))
{ {
if (increaseSelectorIndex()) if (increaseSelectorIndex())
{ {
@@ -923,7 +923,7 @@ void Menu::checkInput()
} }
} }
if (input->checkInput(input_accept, REPEAT_FALSE)) if (input->checkInput(input_accept, DO_NOT_ALLOW_REPEAT))
{ {
itemSelected = selector.index; itemSelected = selector.index;
if (soundAccept) if (soundAccept)
@@ -932,7 +932,7 @@ void Menu::checkInput()
} }
} }
if (input->checkInput(input_cancel, REPEAT_FALSE)) if (input->checkInput(input_cancel, DO_NOT_ALLOW_REPEAT))
{ {
itemSelected = defaultActionWhenCancel; itemSelected = defaultActionWhenCancel;
if (soundCancel) if (soundCancel)

View File

@@ -373,22 +373,22 @@ void Screen::update()
// Comprueba las entradas // Comprueba las entradas
void Screen::checkInput() void Screen::checkInput()
{ {
if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) if (input->checkInput(input_window_fullscreen, DO_NOT_ALLOW_REPEAT))
{ {
switchVideoMode(); switchVideoMode();
} }
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) else if (input->checkInput(input_window_dec_size, DO_NOT_ALLOW_REPEAT))
{ {
decWindowSize(); decWindowSize();
} }
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) else if (input->checkInput(input_window_inc_size, DO_NOT_ALLOW_REPEAT))
{ {
incWindowSize(); incWindowSize();
} }
else if (input->checkInput(input_video_shaders, REPEAT_FALSE)) else if (input->checkInput(input_video_shaders, DO_NOT_ALLOW_REPEAT))
{ {
switchShaders(); switchShaders();
} }

View File

@@ -72,9 +72,12 @@ void DefineButtons::render()
text->writeCentered(x, y - 20, "PLAYER " + std::to_string(indexController + 1)); text->writeCentered(x, y - 20, "PLAYER " + std::to_string(indexController + 1));
text->writeCentered(x, y - 10, controllerNames[indexController]); text->writeCentered(x, y - 10, controllerNames[indexController]);
text->writeCentered(x, y, buttons[indexButton].label); text->writeCentered(x, y, buttons[indexButton].label);
if (indexButton > 0)
text->writeCentered(x, y + 10, std::to_string(buttons[indexButton - 1].button));
} }
} }
// Comprueba el botón que se ha pulsado
void DefineButtons::doJoystickButtonDown(SDL_JoyButtonEvent *event) void DefineButtons::doJoystickButtonDown(SDL_JoyButtonEvent *event)
{ {
int i = input->getJoyIndex(event->which); int i = input->getJoyIndex(event->which);
@@ -89,6 +92,15 @@ void DefineButtons::doJoystickButtonDown(SDL_JoyButtonEvent *event)
incIndexButton(); incIndexButton();
} }
// Asigna los botones definidos al input
void DefineButtons::bindButtons()
{
for (int i = 0; i < (int)buttons.size(); ++i)
{
input->bindGameControllerButton(indexController, buttons[i].input, buttons[i].button);
}
}
// Comprueba las entradas // Comprueba las entradas
void DefineButtons::checkInput() void DefineButtons::checkInput()
{ {
@@ -109,8 +121,10 @@ void DefineButtons::checkInput()
void DefineButtons::enable(int index) void DefineButtons::enable(int index)
{ {
enabled = true; enabled = true;
indexController = index - 1; indexController = index;
indexButton = 0; indexButton = 0;
input->printBindings(INPUT_USE_GAMECONTROLLER, indexController);
} }
// Comprueba si está habilitado // Comprueba si está habilitado
@@ -124,8 +138,16 @@ void DefineButtons::incIndexButton()
{ {
indexButton++; indexButton++;
// Comprueba si ha finalizado
if (indexButton == (int)buttons.size()) if (indexButton == (int)buttons.size())
{ {
// Asigna los botones definidos al input
bindButtons();
input->printBindings(INPUT_USE_GAMECONTROLLER, indexController);
// Reinicia variables
indexButton = 0;
indexController = 0;
enabled = false; enabled = false;
} }
} }

View File

@@ -37,8 +37,12 @@ private:
// Incrementa el indice de los botones // Incrementa el indice de los botones
void incIndexButton(); void incIndexButton();
// Comprueba el botón que se ha pulsado
void doJoystickButtonDown(SDL_JoyButtonEvent *event); void doJoystickButtonDown(SDL_JoyButtonEvent *event);
// Asigna los botones definidos al input
void bindButtons();
public: public:
// Constructor // Constructor
DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options); DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options);

View File

@@ -23,11 +23,7 @@ Director::Director(int argc, char *argv[])
// Crea la carpeta del sistema donde guardar datos // Crea la carpeta del sistema donde guardar datos
createSystemFolder("jailgames"); createSystemFolder("jailgames");
#ifdef DEBUG
createSystemFolder("jailgames/coffee_crisis_arcade_edition_debug");
#else
createSystemFolder("jailgames/coffee_crisis_arcade_edition"); createSystemFolder("jailgames/coffee_crisis_arcade_edition");
#endif
// Inicializa las opciones del programa // Inicializa las opciones del programa
initOptions(); initOptions();
@@ -100,8 +96,9 @@ void Director::initInput()
#else #else
input->setVerbose(options->console); input->setVerbose(options->console);
#endif #endif
// Busca si hay un mando conectado // Busca si hay mandos conectados
input->discoverGameController(); input->discoverGameControllers();
const int numGamePads = input->getNumControllers();
// Teclado - Movimiento del jugador // Teclado - Movimiento del jugador
input->bindKey(input_up, SDL_SCANCODE_UP); input->bindKey(input_up, SDL_SCANCODE_UP);
@@ -123,21 +120,24 @@ void Director::initInput()
input->bindKey(input_window_fullscreen, SDL_SCANCODE_F3); input->bindKey(input_window_fullscreen, SDL_SCANCODE_F3);
input->bindKey(input_video_shaders, SDL_SCANCODE_F4); input->bindKey(input_video_shaders, SDL_SCANCODE_F4);
for (int i = 0; i < numGamePads; ++i)
{
// Mando - Movimiento del jugador // Mando - Movimiento del jugador
input->bindGameControllerButton(input_up, SDL_CONTROLLER_BUTTON_DPAD_UP); input->bindGameControllerButton(i, input_up, SDL_CONTROLLER_BUTTON_DPAD_UP);
input->bindGameControllerButton(input_down, SDL_CONTROLLER_BUTTON_DPAD_DOWN); input->bindGameControllerButton(i, input_down, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
input->bindGameControllerButton(input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT); input->bindGameControllerButton(i, input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
input->bindGameControllerButton(input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); input->bindGameControllerButton(i, input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
input->bindGameControllerButton(input_fire_left, SDL_CONTROLLER_BUTTON_X); input->bindGameControllerButton(i, input_fire_left, SDL_CONTROLLER_BUTTON_X);
input->bindGameControllerButton(input_fire_center, SDL_CONTROLLER_BUTTON_Y); input->bindGameControllerButton(i, input_fire_center, SDL_CONTROLLER_BUTTON_Y);
input->bindGameControllerButton(input_fire_right, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); input->bindGameControllerButton(i, input_fire_right, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
input->bindGameControllerButton(input_start, SDL_CONTROLLER_BUTTON_START); input->bindGameControllerButton(i, input_start, SDL_CONTROLLER_BUTTON_START);
// Mando - Otros // Mando - Otros
input->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_START); input->bindGameControllerButton(i, input_accept, SDL_CONTROLLER_BUTTON_START);
input->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A); input->bindGameControllerButton(i, input_cancel, SDL_CONTROLLER_BUTTON_A);
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_B); input->bindGameControllerButton(i, input_pause, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK); input->bindGameControllerButton(i, input_exit, SDL_CONTROLLER_BUTTON_BACK);
}
// Pone valores por defecto a las opciones de control // Pone valores por defecto a las opciones de control
options->game.input.clear(); options->game.input.clear();

View File

@@ -2730,13 +2730,13 @@ void Game::updateMenace()
void Game::checkInput() void Game::checkInput()
{ {
// Comprueba las teclas que afectan al programa (solo para el primer jugador) // Comprueba las teclas que afectan al programa (solo para el primer jugador)
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
return; return;
} }
else if (input->checkInput(input_pause, REPEAT_FALSE)) else if (input->checkInput(input_pause, DO_NOT_ALLOW_REPEAT))
{ {
pause(!paused); pause(!paused);
} }
@@ -2817,7 +2817,7 @@ void Game::checkInput()
if (player->isAlive() && player->isEnabled()) if (player->isAlive() && player->isEnabled())
{ {
// Input a la izquierda // Input a la izquierda
if (input->checkInput(input_left, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id)) if (input->checkInput(input_left, ALLOW_REPEAT, options->game.input[i].deviceType, options->game.input[i].id))
{ {
player->setInput(input_left); player->setInput(input_left);
#ifdef RECORDING #ifdef RECORDING
@@ -2827,7 +2827,7 @@ void Game::checkInput()
else else
{ {
// Input a la derecha // Input a la derecha
if (input->checkInput(input_right, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id)) if (input->checkInput(input_right, ALLOW_REPEAT, options->game.input[i].deviceType, options->game.input[i].id))
{ {
player->setInput(input_right); player->setInput(input_right);
#ifdef RECORDING #ifdef RECORDING
@@ -2844,7 +2844,7 @@ void Game::checkInput()
} }
} }
// Comprueba el input de disparar al centro // Comprueba el input de disparar al centro
if (input->checkInput(input_fire_center, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id)) if (input->checkInput(input_fire_center, ALLOW_REPEAT, options->game.input[i].deviceType, options->game.input[i].id))
{ {
if (player->canFire()) if (player->canFire())
{ {
@@ -2861,7 +2861,7 @@ void Game::checkInput()
} }
// Comprueba el input de disparar a la izquierda // Comprueba el input de disparar a la izquierda
else if (input->checkInput(input_fire_left, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id)) else if (input->checkInput(input_fire_left, ALLOW_REPEAT, options->game.input[i].deviceType, options->game.input[i].id))
{ {
if (player->canFire()) if (player->canFire())
{ {
@@ -2878,7 +2878,7 @@ void Game::checkInput()
} }
// Comprueba el input de disparar a la derecha // Comprueba el input de disparar a la derecha
else if (input->checkInput(input_fire_right, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id)) else if (input->checkInput(input_fire_right, ALLOW_REPEAT, options->game.input[i].deviceType, options->game.input[i].id))
{ {
if (player->canFire()) if (player->canFire())
{ {
@@ -2906,7 +2906,7 @@ void Game::checkInput()
} }
else else
{ {
if (input->checkInput(input_start, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id)) if (input->checkInput(input_start, ALLOW_REPEAT, options->game.input[i].deviceType, options->game.input[i].id))
{ {
player->enable(true); player->enable(true);
} }

View File

@@ -172,7 +172,7 @@ void HiScoreTable::checkEvents()
// Comprueba las entradas // Comprueba las entradas
void HiScoreTable::checkInput() void HiScoreTable::checkInput()
{ {
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
} }

View File

@@ -304,7 +304,7 @@ void Instructions::checkEvents()
// Comprueba las entradas // Comprueba las entradas
void Instructions::checkInput() void Instructions::checkInput()
{ {
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
} }

View File

@@ -195,7 +195,7 @@ void Intro::checkEvents()
// Comprueba las entradas // Comprueba las entradas
void Intro::checkInput() void Intro::checkInput()
{ {
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
} }

View File

@@ -101,7 +101,7 @@ void Logo::checkEvents()
// Comprueba las entradas // Comprueba las entradas
void Logo::checkInput() void Logo::checkInput()
{ {
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
} }

View File

@@ -234,15 +234,6 @@ void Title::checkInput()
// Comprueba los controladores solo si no se estan definiendo los botones // Comprueba los controladores solo si no se estan definiendo los botones
if (!defineButtons->isEnabled()) if (!defineButtons->isEnabled())
{ {
// Comprueba todos los controladores para salir
for (int i = 0; i < numControllers; ++i)
{
if (input->checkInput(input_exit, REPEAT_FALSE, options->game.input[i].deviceType, options->game.input[i].id))
{
section->name = SECTION_PROG_QUIT;
}
}
// Comprueba si se ha pulsado algún botón para empezar a jugar // Comprueba si se ha pulsado algún botón para empezar a jugar
const int index = input->checkAnyButtonPressed(); const int index = input->checkAnyButtonPressed();
if (index) if (index)
@@ -253,7 +244,7 @@ void Title::checkInput()
} }
// Comprueba el teclado para salir // Comprueba el teclado para salir
if (input->checkInput(input_exit, REPEAT_FALSE)) if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
} }
@@ -265,12 +256,12 @@ void Title::checkInput()
if (keyStates[SDL_SCANCODE_1] != 0) if (keyStates[SDL_SCANCODE_1] != 0)
{ {
defineButtons->enable(1); defineButtons->enable(0);
} }
else if (keyStates[SDL_SCANCODE_2] != 0) else if (keyStates[SDL_SCANCODE_2] != 0)
{ {
defineButtons->enable(2); defineButtons->enable(1);
} }
} }