diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index 0c05f69..858ee22 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -51,12 +51,12 @@ void DefineButtons::doControllerButtonDown(const SDL_GamepadButtonEvent &event) // Asigna los botones definidos al input_ void DefineButtons::bindButtons() { for (const auto &button : buttons_) { - input_->bindGameControllerButton(index_controller_, button.input, button.button); + input_->bindGameControllerButton(index_controller_, button.action, button.button); } // Remapea los inputs a inputs - input_->bindGameControllerButton(index_controller_, InputAction::SM_SELECT, InputAction::FIRE_LEFT); - input_->bindGameControllerButton(index_controller_, InputAction::SM_BACK, InputAction::FIRE_CENTER); + input_->bindGameControllerButton(index_controller_, Input::Action::SM_SELECT, Input::Action::FIRE_LEFT); + input_->bindGameControllerButton(index_controller_, Input::Action::SM_BACK, Input::Action::FIRE_CENTER); } // Comprueba los eventos @@ -117,11 +117,11 @@ auto DefineButtons::checkButtonNotInUse(SDL_GamepadButton button) -> bool { // Limpia la asignación de botones void DefineButtons::clearButtons() { buttons_.clear(); - buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] FIRE_LEFT"), InputAction::FIRE_LEFT, SDL_GAMEPAD_BUTTON_INVALID); - buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] FIRE_UP"), InputAction::FIRE_CENTER, SDL_GAMEPAD_BUTTON_INVALID); - buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] FIRE_RIGHT"), InputAction::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_INVALID); - buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] START"), InputAction::START, SDL_GAMEPAD_BUTTON_INVALID); - buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] SERVICE_MENU"), InputAction::SERVICE, SDL_GAMEPAD_BUTTON_INVALID); + buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] FIRE_LEFT"), Input::Action::FIRE_LEFT, SDL_GAMEPAD_BUTTON_INVALID); + buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] FIRE_UP"), Input::Action::FIRE_CENTER, SDL_GAMEPAD_BUTTON_INVALID); + buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] FIRE_RIGHT"), Input::Action::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_INVALID); + buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] START"), Input::Action::START, SDL_GAMEPAD_BUTTON_INVALID); + buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] SERVICE_MENU"), Input::Action::SERVICE, SDL_GAMEPAD_BUTTON_INVALID); } // Comprueba si ha finalizado diff --git a/source/define_buttons.h b/source/define_buttons.h index e876238..f14a488 100644 --- a/source/define_buttons.h +++ b/source/define_buttons.h @@ -8,24 +8,22 @@ #include #include // Para vector -// Declaraciones adelantadas -class Input; -class Text; -enum class InputAction : int; - -// Estructura para definir botones -struct DefineButtonsButton { - std::string label; // Texto en pantalla - InputAction input; // Acción asociada - SDL_GamepadButton button; // Botón del mando - - DefineButtonsButton(std::string lbl, InputAction inp, SDL_GamepadButton btn) - : label(std::move(lbl)), input(inp), button(btn) {} -}; +#include "input.h" +#include "text.h" // Clase DefineButtons class DefineButtons { public: + // Estructura para definir botones + struct Button { + std::string label; // Texto en pantalla + Input::Action action; // Acción asociada + SDL_GamepadButton button; // Botón del mando + + Button(std::string label, Input::Action action, SDL_GamepadButton button) + : label(std::move(label)), action(action), button(button) {} + }; + DefineButtons(); ~DefineButtons() = default; @@ -42,7 +40,7 @@ class DefineButtons { // Variables bool enabled_ = false; // Indica si está activo int x_ = 0, y_ = 0; // Coordenadas de texto - std::vector buttons_; // Definiciones de botones + std::vector