style: renomenat InputType a InputActions

This commit is contained in:
2025-03-16 18:57:08 +01:00
parent 1b38a5a581
commit 43a1f1a8f6
13 changed files with 199 additions and 199 deletions

View File

@@ -16,7 +16,7 @@ device contiene el tipo de dispositivo a comprobar:
InputDeviceToUse::ANY mirará tanto el teclado como el PRIMER controlador
*/
enum class InputType : int
enum class InputAction : int
{
// Inputs de movimiento
UP,
@@ -42,14 +42,14 @@ enum class InputType : int
RESET,
MUTE,
CHANGE_LANG,
SHOWINFO,
SHOW_INFO,
CONFIG,
SWAP_CONTROLLERS,
AUTO_FIRE,
// Input obligatorio
NONE,
NUMBER_OF_INPUTS,
SIZE,
};
constexpr bool INPUT_ALLOW_REPEAT = true;
@@ -95,13 +95,13 @@ private:
std::vector<KeyBindings> key_bindings_; // Vector con las teclas asociadas a los inputs predefinidos
std::vector<std::vector<ControllerBindings>> controller_bindings_; // Vector con los botones asociadas a los inputs predefinidos para cada mando
std::vector<std::string> controller_names_; // Vector con los nombres de los mandos
std::vector<InputType> button_inputs_; // Inputs asignados al jugador y a botones, excluyendo direcciones
std::vector<InputAction> button_inputs_; // Inputs asignados al jugador y a botones, excluyendo direcciones
int num_joysticks_ = 0; // Número de joysticks conectados
int num_gamepads_ = 0; // Número de mandos conectados
std::string game_controller_db_path_; // Ruta al archivo gamecontrollerdb.txt
// Comprueba el eje del mando
bool checkAxisInput(InputType input, int controller_index, bool repeat);
bool checkAxisInput(InputAction input, int controller_index, bool repeat);
// Constructor
explicit Input(const std::string &game_controller_db_path);
@@ -120,14 +120,14 @@ public:
static Input *get();
// Asigna inputs a teclas
void bindKey(InputType input, SDL_Scancode code);
void bindKey(InputAction input, SDL_Scancode code);
// Asigna inputs a botones del mando
void bindGameControllerButton(int controller_index, InputType input, SDL_GameControllerButton button);
void bindGameControllerButton(int controller_index, InputType inputTarget, InputType inputSource);
void bindGameControllerButton(int controller_index, InputAction input, SDL_GameControllerButton button);
void bindGameControllerButton(int controller_index, InputAction inputTarget, InputAction inputSource);
// Comprueba si un input esta activo
bool checkInput(InputType input, bool repeat = true, InputDeviceToUse device = InputDeviceToUse::ANY, int controller_index = 0);
bool checkInput(InputAction input, bool repeat = true, InputDeviceToUse device = InputDeviceToUse::ANY, int controller_index = 0);
// Comprueba si hay almenos un input activo
bool checkAnyInput(InputDeviceToUse device = InputDeviceToUse::ANY, int controller_index = 0);
@@ -154,13 +154,13 @@ public:
void printBindings(InputDeviceToUse device = InputDeviceToUse::KEYBOARD, int controller_index = 0) const;
// Obtiene el SDL_GameControllerButton asignado a un input
SDL_GameControllerButton getControllerBinding(int controller_index, InputType input) const;
SDL_GameControllerButton getControllerBinding(int controller_index, InputAction input) const;
// Convierte un InputType a std::string
std::string to_string(InputType input) const;
// Convierte un InputAction a std::string
std::string to_string(InputAction input) const;
// Convierte un std::string a InputType
InputType to_inputs_e(const std::string &name) const;
// Convierte un std::string a InputAction
InputAction to_inputs_e(const std::string &name) const;
// Obtiene el indice a partir del nombre del mando
int getIndexByName(const std::string &name) const;