guardar partida pq ja estic fent canvis a cegues a vore si trac açò
This commit is contained in:
19
Makefile
19
Makefile
@@ -25,7 +25,8 @@ INCLUDES:= -I$(DIR_SOURCES)
|
||||
ifeq ($(OS),Windows_NT)
|
||||
FixPath = $(subst /,\,$1)
|
||||
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
|
||||
RM = del /Q
|
||||
MKD:= mkdir
|
||||
@@ -127,19 +128,16 @@ raspi5:
|
||||
|
||||
windows:
|
||||
@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
|
||||
|
||||
windows_rec:
|
||||
@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:
|
||||
@echo off
|
||||
$(CXX) $(SOURCES) -D DEBUG $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)_debug.exe"
|
||||
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)_debug.exe" --strip-unneeded
|
||||
|
||||
$(CXX) $(SOURCES) -D VERBOSE $(CXXFLAGS2) $(LDFLAGS) -o "$(TARGET_FILE)_debug.exe"
|
||||
|
||||
windows_release:
|
||||
@echo off
|
||||
@@ -167,19 +165,15 @@ windows_release:
|
||||
# Elimina la carpeta temporal 'RELEASE_FOLDER'
|
||||
powershell if (Test-Path "$(RELEASE_FOLDER)") {Remove-Item "$(RELEASE_FOLDER)" -Recurse -Force}
|
||||
|
||||
|
||||
macos:
|
||||
$(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
||||
|
||||
|
||||
macos_fast:
|
||||
$(CXX) $(SOURCES) -D VERBOSE -std=c++11 -Wall -Wno-deprecated -lSDL2 -framework OpenGL -o "$(TARGET_FILE)"
|
||||
|
||||
|
||||
macos_debug:
|
||||
$(CXX) $(SOURCES) -D DEBUG $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||
|
||||
|
||||
macos_release:
|
||||
# Elimina datos de compilaciones anteriores
|
||||
rm -rdf "$(RELEASE_FOLDER)"
|
||||
@@ -226,17 +220,14 @@ macos_release:
|
||||
$(RM) Frameworks
|
||||
$(RM) "$(RELEASE_FOLDER)"
|
||||
|
||||
|
||||
linux:
|
||||
$(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)"
|
||||
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)" --strip-unneeded
|
||||
|
||||
|
||||
linux_debug:
|
||||
$(CXX) $(SOURCES) -D DEBUG $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||
strip -s -R .comment -R .gnu.version "$(TARGET_FILE)_debug" --strip-unneeded
|
||||
|
||||
|
||||
linux_release:
|
||||
# Elimina carpetas previas
|
||||
$(RM) "$(RELEASE_FOLDER)"
|
||||
|
||||
@@ -4,10 +4,17 @@
|
||||
// Constructor
|
||||
Input::Input(std::string file)
|
||||
{
|
||||
// Inicializa variables
|
||||
verbose = false;
|
||||
enabled = true;
|
||||
|
||||
// Fichero gamecontrollerdb.txt
|
||||
dbPath = file;
|
||||
|
||||
// Inicializa las variables
|
||||
// Busca si hay mandos conectados
|
||||
discoverGameControllers();
|
||||
|
||||
// Inicializa las vectores
|
||||
keyBindings_t kb;
|
||||
kb.scancode = 0;
|
||||
kb.active = false;
|
||||
@@ -16,10 +23,11 @@ Input::Input(std::string file)
|
||||
GameControllerBindings_t gcb;
|
||||
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
gcb.active = false;
|
||||
gameControllerBindings.resize(input_number_of_inputs, gcb);
|
||||
|
||||
verbose = true;
|
||||
enabled = true;
|
||||
gameControllerBindings.resize(numGamepads);
|
||||
for (int i = 0; i < numGamepads; ++i)
|
||||
{
|
||||
gameControllerBindings[i].resize(input_number_of_inputs, gcb);
|
||||
}
|
||||
|
||||
// Listado de los inputs usados para jugar, excluyendo botones para la interfaz
|
||||
gameInputs.clear();
|
||||
@@ -55,9 +63,13 @@ void Input::bindKey(inputs_e input, SDL_Scancode code)
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -125,7 +137,7 @@ bool Input::checkInput(inputs_e input, bool repeat, int device, int index)
|
||||
{
|
||||
if (repeat)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
|
||||
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[index][input].button) != 0)
|
||||
{
|
||||
successGameController = true;
|
||||
}
|
||||
@@ -136,11 +148,11 @@ bool Input::checkInput(inputs_e input, bool repeat, int device, int index)
|
||||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
@@ -150,9 +162,9 @@ bool Input::checkInput(inputs_e input, bool repeat, int device, int index)
|
||||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
@@ -180,8 +192,9 @@ bool Input::checkAnyInput(int device, int index)
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -193,8 +206,9 @@ bool Input::checkAnyInput(int device, int index)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -204,21 +218,22 @@ bool Input::checkAnyInput(int device, int index)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Comprueba si hay algún botón pulsado. Devuelve 0 en caso de no encontrar nada o el indice del dispositivo + 1.
|
||||
int Input::checkAnyButtonPressed()
|
||||
// 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(bool repeat)
|
||||
{
|
||||
const Uint8 *keyStates = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
// Solo comprueba los botones
|
||||
for (auto bi : buttonInputs)
|
||||
{
|
||||
if (keyStates[keyBindings[bi].scancode] != 0)
|
||||
// Comprueba el teclado
|
||||
if (checkInput(bi, repeat, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Comprueba los mandos
|
||||
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;
|
||||
}
|
||||
@@ -228,8 +243,8 @@ int Input::checkAnyButtonPressed()
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Busca si hay un mando conectado
|
||||
bool Input::discoverGameController()
|
||||
// Busca si hay mandos conectados
|
||||
bool Input::discoverGameControllers()
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
@@ -281,7 +296,7 @@ bool Input::discoverGameController()
|
||||
const std::string separator(" #");
|
||||
std::string name = SDL_GameControllerNameForIndex(i);
|
||||
// name.resize(25);
|
||||
name = name + separator + std::to_string(i);
|
||||
// name = name + separator + std::to_string(i);
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << name << std::endl;
|
||||
@@ -359,7 +374,68 @@ void Input::enable()
|
||||
int Input::getJoyIndex(int id)
|
||||
{
|
||||
for (int i = 0; i < numJoysticks; ++i)
|
||||
{
|
||||
if (SDL_JoystickInstanceID(joysticks[i]) == id)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
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 "";
|
||||
}
|
||||
@@ -45,8 +45,8 @@ enum inputs_e
|
||||
input_number_of_inputs
|
||||
};
|
||||
|
||||
#define REPEAT_TRUE true
|
||||
#define REPEAT_FALSE false
|
||||
#define ALLOW_REPEAT true
|
||||
#define DO_NOT_ALLOW_REPEAT false
|
||||
|
||||
#define INPUT_USE_KEYBOARD 0
|
||||
#define INPUT_USE_GAMECONTROLLER 1
|
||||
@@ -78,7 +78,7 @@ private:
|
||||
std::vector<SDL_GameController *> connectedControllers; // Vector con todos los mandos 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<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<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
|
||||
@@ -89,6 +89,9 @@ private:
|
||||
i_disable_e disabledUntil; // Tiempo que esta deshabilitado
|
||||
bool enabled; // Indica si está habilitado
|
||||
|
||||
// Convierte un inputs_e a std::string
|
||||
std::string to_String(inputs_e input);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Input(std::string file);
|
||||
@@ -100,7 +103,7 @@ public:
|
||||
void bindKey(inputs_e input, SDL_Scancode code);
|
||||
|
||||
// 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
|
||||
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);
|
||||
|
||||
// Comprueba si hay algún botón pulsado
|
||||
int checkAnyButtonPressed();
|
||||
int checkAnyButtonPressed(bool repeat = DO_NOT_ALLOW_REPEAT);
|
||||
|
||||
// Busca si hay un mando conectado
|
||||
bool discoverGameController();
|
||||
// Busca si hay mandos conectados
|
||||
bool discoverGameControllers();
|
||||
|
||||
// Comprueba si hay algun mando conectado
|
||||
bool gameControllerFound();
|
||||
@@ -134,6 +137,9 @@ public:
|
||||
|
||||
// Obtiene el indice del controlador a partir de un event.id
|
||||
int getJoyIndex(int id);
|
||||
|
||||
// Muestra por consola los controles asignados
|
||||
void printBindings(int device = INPUT_USE_KEYBOARD, int index = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -901,7 +901,7 @@ void Menu::setDefaultActionWhenCancel(int item)
|
||||
// Gestiona la entrada de teclado y mando durante el menu
|
||||
void Menu::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_up, REPEAT_FALSE))
|
||||
if (input->checkInput(input_up, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
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())
|
||||
{
|
||||
@@ -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;
|
||||
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;
|
||||
if (soundCancel)
|
||||
|
||||
@@ -373,22 +373,22 @@ void Screen::update()
|
||||
// Comprueba las entradas
|
||||
void Screen::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||
if (input->checkInput(input_window_fullscreen, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
switchVideoMode();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||
else if (input->checkInput(input_window_dec_size, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
decWindowSize();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||
else if (input->checkInput(input_window_inc_size, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
incWindowSize();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_video_shaders, REPEAT_FALSE))
|
||||
else if (input->checkInput(input_video_shaders, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
switchShaders();
|
||||
}
|
||||
|
||||
@@ -72,9 +72,12 @@ void DefineButtons::render()
|
||||
text->writeCentered(x, y - 20, "PLAYER " + std::to_string(indexController + 1));
|
||||
text->writeCentered(x, y - 10, controllerNames[indexController]);
|
||||
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)
|
||||
{
|
||||
int i = input->getJoyIndex(event->which);
|
||||
@@ -89,6 +92,15 @@ void DefineButtons::doJoystickButtonDown(SDL_JoyButtonEvent *event)
|
||||
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
|
||||
void DefineButtons::checkInput()
|
||||
{
|
||||
@@ -109,8 +121,10 @@ void DefineButtons::checkInput()
|
||||
void DefineButtons::enable(int index)
|
||||
{
|
||||
enabled = true;
|
||||
indexController = index - 1;
|
||||
indexController = index;
|
||||
indexButton = 0;
|
||||
|
||||
input->printBindings(INPUT_USE_GAMECONTROLLER, indexController);
|
||||
}
|
||||
|
||||
// Comprueba si está habilitado
|
||||
@@ -124,8 +138,16 @@ void DefineButtons::incIndexButton()
|
||||
{
|
||||
indexButton++;
|
||||
|
||||
// Comprueba si ha finalizado
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,12 @@ private:
|
||||
// Incrementa el indice de los botones
|
||||
void incIndexButton();
|
||||
|
||||
// Comprueba el botón que se ha pulsado
|
||||
void doJoystickButtonDown(SDL_JoyButtonEvent *event);
|
||||
|
||||
// Asigna los botones definidos al input
|
||||
void bindButtons();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options);
|
||||
|
||||
@@ -23,11 +23,7 @@ Director::Director(int argc, char *argv[])
|
||||
|
||||
// Crea la carpeta del sistema donde guardar datos
|
||||
createSystemFolder("jailgames");
|
||||
#ifdef DEBUG
|
||||
createSystemFolder("jailgames/coffee_crisis_arcade_edition_debug");
|
||||
#else
|
||||
createSystemFolder("jailgames/coffee_crisis_arcade_edition");
|
||||
#endif
|
||||
|
||||
// Inicializa las opciones del programa
|
||||
initOptions();
|
||||
@@ -100,8 +96,9 @@ void Director::initInput()
|
||||
#else
|
||||
input->setVerbose(options->console);
|
||||
#endif
|
||||
// Busca si hay un mando conectado
|
||||
input->discoverGameController();
|
||||
// Busca si hay mandos conectados
|
||||
input->discoverGameControllers();
|
||||
const int numGamePads = input->getNumControllers();
|
||||
|
||||
// Teclado - Movimiento del jugador
|
||||
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_video_shaders, SDL_SCANCODE_F4);
|
||||
|
||||
for (int i = 0; i < numGamePads; ++i)
|
||||
{
|
||||
// Mando - Movimiento del jugador
|
||||
input->bindGameControllerButton(input_up, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
||||
input->bindGameControllerButton(input_down, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
||||
input->bindGameControllerButton(input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||
input->bindGameControllerButton(input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||
input->bindGameControllerButton(input_fire_left, SDL_CONTROLLER_BUTTON_X);
|
||||
input->bindGameControllerButton(input_fire_center, SDL_CONTROLLER_BUTTON_Y);
|
||||
input->bindGameControllerButton(input_fire_right, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||
input->bindGameControllerButton(input_start, SDL_CONTROLLER_BUTTON_START);
|
||||
input->bindGameControllerButton(i, input_up, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
||||
input->bindGameControllerButton(i, input_down, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
||||
input->bindGameControllerButton(i, input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||
input->bindGameControllerButton(i, input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||
input->bindGameControllerButton(i, input_fire_left, SDL_CONTROLLER_BUTTON_X);
|
||||
input->bindGameControllerButton(i, input_fire_center, SDL_CONTROLLER_BUTTON_Y);
|
||||
input->bindGameControllerButton(i, input_fire_right, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||
input->bindGameControllerButton(i, input_start, SDL_CONTROLLER_BUTTON_START);
|
||||
|
||||
// Mando - Otros
|
||||
input->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_START);
|
||||
input->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A);
|
||||
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_B);
|
||||
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK);
|
||||
input->bindGameControllerButton(i, input_accept, SDL_CONTROLLER_BUTTON_START);
|
||||
input->bindGameControllerButton(i, input_cancel, SDL_CONTROLLER_BUTTON_A);
|
||||
input->bindGameControllerButton(i, input_pause, SDL_CONTROLLER_BUTTON_B);
|
||||
input->bindGameControllerButton(i, input_exit, SDL_CONTROLLER_BUTTON_BACK);
|
||||
}
|
||||
|
||||
// Pone valores por defecto a las opciones de control
|
||||
options->game.input.clear();
|
||||
|
||||
@@ -2730,13 +2730,13 @@ void Game::updateMenace()
|
||||
void Game::checkInput()
|
||||
{
|
||||
// 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;
|
||||
return;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_pause, REPEAT_FALSE))
|
||||
else if (input->checkInput(input_pause, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
pause(!paused);
|
||||
}
|
||||
@@ -2817,7 +2817,7 @@ void Game::checkInput()
|
||||
if (player->isAlive() && player->isEnabled())
|
||||
{
|
||||
// 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);
|
||||
#ifdef RECORDING
|
||||
@@ -2827,7 +2827,7 @@ void Game::checkInput()
|
||||
else
|
||||
{
|
||||
// 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);
|
||||
#ifdef RECORDING
|
||||
@@ -2844,7 +2844,7 @@ void Game::checkInput()
|
||||
}
|
||||
}
|
||||
// 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())
|
||||
{
|
||||
@@ -2861,7 +2861,7 @@ void Game::checkInput()
|
||||
}
|
||||
|
||||
// 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())
|
||||
{
|
||||
@@ -2878,7 +2878,7 @@ void Game::checkInput()
|
||||
}
|
||||
|
||||
// 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())
|
||||
{
|
||||
@@ -2906,7 +2906,7 @@ void Game::checkInput()
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ void HiScoreTable::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void HiScoreTable::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ void Instructions::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Instructions::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ void Intro::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Intro::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ void Logo::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Logo::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT))
|
||||
{
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
@@ -234,15 +234,6 @@ void Title::checkInput()
|
||||
// Comprueba los controladores solo si no se estan definiendo los botones
|
||||
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
|
||||
const int index = input->checkAnyButtonPressed();
|
||||
if (index)
|
||||
@@ -253,7 +244,7 @@ void Title::checkInput()
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
@@ -265,12 +256,12 @@ void Title::checkInput()
|
||||
|
||||
if (keyStates[SDL_SCANCODE_1] != 0)
|
||||
{
|
||||
defineButtons->enable(1);
|
||||
defineButtons->enable(0);
|
||||
}
|
||||
|
||||
else if (keyStates[SDL_SCANCODE_2] != 0)
|
||||
{
|
||||
defineButtons->enable(2);
|
||||
defineButtons->enable(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user