Reasignados los controles para ordenador, mando y consola

This commit is contained in:
2023-02-12 18:50:40 +01:00
parent ca99857b5b
commit cbb5d54250
8 changed files with 154 additions and 140 deletions

View File

@@ -11,17 +11,15 @@ Input::Input(std::string file)
keyBindings_t kb;
kb.scancode = 0;
kb.active = false;
keyBindings.resize(17, kb);
keyBindings.resize(input_number_of_inputs, kb);
GameControllerBindings_t gcb;
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
gcb.active = false;
gameControllerBindings.resize(17, gcb);
gameControllerBindings.resize(input_number_of_inputs, gcb);
verbose = true;
enabled = true;
numGamepads = 0;
}
// Actualiza el estado del objeto

View File

@@ -7,23 +7,30 @@
#ifndef INPUT_H
#define INPUT_H
#define INPUT_NULL 0
#define INPUT_UP 1
#define INPUT_DOWN 2
#define INPUT_LEFT 3
#define INPUT_RIGHT 4
#define INPUT_ACCEPT 5
#define INPUT_CANCEL 6
#define INPUT_BUTTON_1 7
#define INPUT_BUTTON_2 8
#define INPUT_BUTTON_3 9
#define INPUT_BUTTON_4 10
#define INPUT_BUTTON_5 11
#define INPUT_BUTTON_6 12
#define INPUT_BUTTON_7 13
#define INPUT_BUTTON_8 14
#define INPUT_BUTTON_PAUSE 15
#define INPUT_BUTTON_ESCAPE 16
enum inputs_e
{
// Inputs obligatorios
input_null,
input_up,
input_down,
input_left,
input_right,
input_pause,
input_exit,
input_accept,
input_cancel,
// Inputs personalizados
input_fire_left,
input_fire_center,
input_fire_right,
input_window_fullscreen,
input_window_inc_size,
input_window_dec_size,
// Input obligatorio
input_number_of_inputs
};
#define REPEAT_TRUE true
#define REPEAT_FALSE false
@@ -81,7 +88,7 @@ public:
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
// Comprueba si un input esta activo
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
bool checkInput(Uint8 input, bool repeat = true, int device = INPUT_USE_ANY, int index = 0);
// Comprueba si hay almenos un input activo
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);

View File

@@ -851,7 +851,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, REPEAT_FALSE))
{
if (decreaseSelectorIndex())
{
@@ -862,7 +862,7 @@ void Menu::checkInput()
}
}
if (input->checkInput(INPUT_DOWN, REPEAT_FALSE))
if (input->checkInput(input_down, REPEAT_FALSE))
{
if (increaseSelectorIndex())
{
@@ -873,7 +873,7 @@ void Menu::checkInput()
}
}
if (input->checkInput(INPUT_ACCEPT, REPEAT_FALSE))
if (input->checkInput(input_accept, REPEAT_FALSE))
{
itemSelected = selector.index;
if (soundAccept)
@@ -882,7 +882,7 @@ void Menu::checkInput()
}
}
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE))
if (input->checkInput(input_cancel, REPEAT_FALSE))
{
itemSelected = defaultActionWhenCancel;
if (soundCancel)