Input: model upate/poll finalitzat

This commit is contained in:
2025-06-29 11:37:01 +02:00
parent ce1ae74e88
commit 5006289a5d
21 changed files with 183 additions and 155 deletions

View File

@@ -11,7 +11,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
set(APP_SOURCES
# --- Archivos Principales del Sistema ---
source/main.cpp
source/game.cpp
source/director.cpp
source/section.cpp
source/screen.cpp
@@ -31,27 +30,28 @@ set(APP_SOURCES
source/ui/menu_renderer.cpp
source/ui/ui_message.cpp
# --- Lógica y Escenas del Juego ---
source/player.cpp
source/balloon.cpp
# --- Lógica del Juego ---
source/balloon_formations.cpp
source/balloon_manager.cpp
source/balloon.cpp
source/bullet.cpp
source/item.cpp
source/explosions.cpp
# --- Escenas y Flujo ---
source/title.cpp
source/logo.cpp
source/game_logo.cpp
source/intro.cpp
source/credits.cpp
source/instructions.cpp
source/hiscore_table.cpp
source/enter_name.cpp
source/explosions.cpp
source/game_logo.cpp
source/item.cpp
source/manage_hiscore_table.cpp
source/player.cpp
source/scoreboard.cpp
# --- Escenas ---
source/sections/credits.cpp
source/sections/game.cpp
source/sections/hiscore_table.cpp
source/sections/instructions.cpp
source/sections/intro.cpp
source/sections/logo.cpp
source/sections/title.cpp
# --- Sprites y Gráficos ---
source/sprite.cpp
source/animated_sprite.cpp

View File

@@ -19,14 +19,8 @@
#include <vector> // Para vector
#include "asset.h" // Para Asset, AssetType
#include "audio.h" // Para Audio
#include "credits.h" // Para Credits
#include "game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_MOD...
#include "hiscore_table.h" // Para HiScoreTable
#include "input.h" // Para Input, InputAction
#include "instructions.h" // Para Instructions
#include "intro.h" // Para Intro
#include "lang.h" // Para Code, loadFromFile
#include "logo.h" // Para Logo
#include "manage_hiscore_table.h" // Para ManageHiScoreTable
#include "notifier.h" // Para Notifier
#include "options.h" // Para GamepadOptions, Options, options
@@ -34,8 +28,14 @@
#include "resource.h" // Para Resource
#include "screen.h" // Para Screen
#include "section.h" // Para Name, Options, name, options
#include "sections/credits.h" // Para Credits
#include "sections/game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_MOD...
#include "sections/hiscore_table.h" // Para HiScoreTable
#include "sections/instructions.h" // Para Instructions
#include "sections/intro.h" // Para Intro
#include "sections/logo.h" // Para Logo
#include "sections/title.h" // Para Title
#include "ui/service_menu.h" // Para ServiceMenu
#include "title.h" // Para Title
#include "utils.h" // Para Overrides, overrides
#ifndef _WIN32

View File

@@ -195,7 +195,7 @@ namespace GlobalInputs
bool checkServiceButton()
{
// Teclado
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
toggleServiceMenu();
return true;
@@ -205,7 +205,7 @@ namespace GlobalInputs
{
for (int i = 0; i < Input::get()->getNumControllers(); ++i)
{
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::CONTROLLER, i))
{
toggleServiceMenu();
return true;
@@ -224,42 +224,42 @@ namespace GlobalInputs
// Teclado
{
// Arriba
if (Input::get()->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
ServiceMenu::get()->setSelectorUp();
return true;
}
// Abajo
if (Input::get()->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
ServiceMenu::get()->setSelectorDown();
return true;
}
// Derecha
if (Input::get()->checkInput(InputAction::RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
ServiceMenu::get()->adjustOption(true);
return true;
}
// Izquierda
if (Input::get()->checkInput(InputAction::LEFT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::LEFT, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
ServiceMenu::get()->adjustOption(false);
return true;
}
// Aceptar
if (Input::get()->checkInput(InputAction::SM_SELECT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::SM_SELECT, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
ServiceMenu::get()->selectOption();
return true;
}
// Atras
if (Input::get()->checkInput(InputAction::SM_BACK, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::SM_BACK, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
ServiceMenu::get()->moveBack();
return true;
@@ -271,42 +271,42 @@ namespace GlobalInputs
for (int i = 0; i < Input::get()->getNumControllers(); ++i)
{
// Arriba
if (Input::get()->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
if (Input::get()->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::CONTROLLER, i))
{
ServiceMenu::get()->setSelectorUp();
return true;
}
// Abajo
if (Input::get()->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
if (Input::get()->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::CONTROLLER, i))
{
ServiceMenu::get()->setSelectorDown();
return true;
}
// Derecha
if (Input::get()->checkInput(InputAction::RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
if (Input::get()->checkInput(InputAction::RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::CONTROLLER, i))
{
ServiceMenu::get()->adjustOption(true);
return true;
}
// Izquierda
if (Input::get()->checkInput(InputAction::LEFT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
if (Input::get()->checkInput(InputAction::LEFT, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::CONTROLLER, i))
{
ServiceMenu::get()->adjustOption(false);
return true;
}
// Aceptar
if (Input::get()->checkInput(InputAction::SM_SELECT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
if (Input::get()->checkInput(InputAction::SM_SELECT, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::CONTROLLER, i))
{
ServiceMenu::get()->selectOption();
return true;
}
// Atras
if (Input::get()->checkInput(InputAction::SM_BACK, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
if (Input::get()->checkInput(InputAction::SM_BACK, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::CONTROLLER, i))
{
ServiceMenu::get()->moveBack();
return true;
@@ -322,7 +322,7 @@ namespace GlobalInputs
// Teclado
{
// Comprueba el teclado para cambiar entre pantalla completa y ventana
if (Input::get()->checkInput(InputAction::WINDOW_FULLSCREEN, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::WINDOW_FULLSCREEN, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
Screen::get()->toggleFullscreen();
const std::string MODE = Options::video.fullscreen ? Lang::getText("[NOTIFICATIONS] 11") : Lang::getText("[NOTIFICATIONS] 10");
@@ -331,7 +331,7 @@ namespace GlobalInputs
}
// Comprueba el teclado para decrementar el tamaño de la ventana
if (Input::get()->checkInput(InputAction::WINDOW_DEC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::WINDOW_DEC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
if (Screen::get()->decWindowSize())
{
@@ -341,7 +341,7 @@ namespace GlobalInputs
}
// Comprueba el teclado para incrementar el tamaño de la ventana
if (Input::get()->checkInput(InputAction::WINDOW_INC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::WINDOW_INC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
if (Screen::get()->incWindowSize())
{
@@ -351,7 +351,7 @@ namespace GlobalInputs
}
// Salir
if (Input::get()->checkInput(InputAction::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
quit();
return true;
@@ -365,49 +365,49 @@ namespace GlobalInputs
}
// Reset
if (Input::get()->checkInput(InputAction::RESET, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::RESET, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
reset();
return true;
}
// Audio
if (Input::get()->checkInput(InputAction::TOGGLE_AUDIO, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::TOGGLE_AUDIO, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
toggleAudio();
return true;
}
// Autofire
if (Input::get()->checkInput(InputAction::TOGGLE_AUTO_FIRE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::TOGGLE_AUTO_FIRE, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
toggleFireMode();
return true;
}
// Idioma
if (Input::get()->checkInput(InputAction::CHANGE_LANG, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::CHANGE_LANG, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
changeLang();
return true;
}
// Shaders
if (Input::get()->checkInput(InputAction::TOGGLE_VIDEO_SHADERS, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::TOGGLE_VIDEO_SHADERS, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
toggleShaders();
return true;
}
// Integer Scale
if (Input::get()->checkInput(InputAction::TOGGLE_VIDEO_INTEGER_SCALE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::TOGGLE_VIDEO_INTEGER_SCALE, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
toggleIntegerScale();
return true;
}
// VSync
if (Input::get()->checkInput(InputAction::TOGGLE_VIDEO_VSYNC, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::TOGGLE_VIDEO_VSYNC, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
toggleVSync();
return true;
@@ -415,7 +415,7 @@ namespace GlobalInputs
#ifdef DEBUG
// Debug info
if (Input::get()->checkInput(InputAction::SHOW_INFO, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (Input::get()->checkInput(InputAction::SHOW_INFO, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
Screen::get()->toggleDebugInfo();
return true;
@@ -428,7 +428,6 @@ namespace GlobalInputs
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
bool check()
{
Input::get()->update();
if (checkServiceButton())
return true;
if (checkServiceInputs())

View File

@@ -60,27 +60,27 @@ void Input::bindGameControllerButton(int controller_index, InputAction input_tar
}
// Comprueba si un input esta activo
bool Input::checkInput(InputAction input, bool repeat, InputDeviceToUse device, int controller_index)
bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int controller_index)
{
bool success_keyboard = false;
bool success_controller = false;
const int input_index = static_cast<int>(input);
if (device == InputDeviceToUse::KEYBOARD || device == InputDeviceToUse::ANY)
if (device == InputDevice::KEYBOARD || device == InputDevice::ANY)
{
if (repeat)
{ // El usuario quiere saber si está pulsada (estado mantenido)
return key_bindings_[input_index].is_held;
success_keyboard = key_bindings_[input_index].is_held;
}
else
{ // El usuario quiere saber si ACABA de ser pulsada (evento de un solo fotograma)
return key_bindings_[input_index].just_pressed;
success_keyboard = key_bindings_[input_index].just_pressed;
}
}
if (gameControllerFound() && controller_index >= 0 && controller_index < num_gamepads_)
{
if ((device == InputDeviceToUse::CONTROLLER) || (device == InputDeviceToUse::ANY))
if ((device == InputDevice::CONTROLLER) || (device == InputDevice::ANY))
{
success_controller = checkAxisInput(input, controller_index, repeat);
@@ -88,11 +88,11 @@ bool Input::checkInput(InputAction input, bool repeat, InputDeviceToUse device,
{
if (repeat)
{ // El usuario quiere saber si está pulsada (estado mantenido)
return controller_bindings_.at(controller_index).at(input_index).is_held;
success_controller = controller_bindings_.at(controller_index).at(input_index).is_held;
}
else
{ // El usuario quiere saber si ACABA de ser pulsada (evento de un solo fotograma)
return controller_bindings_.at(controller_index).at(input_index).just_pressed;
success_controller = controller_bindings_.at(controller_index).at(input_index).just_pressed;
}
}
}
@@ -102,13 +102,13 @@ bool Input::checkInput(InputAction input, bool repeat, InputDeviceToUse device,
}
// Comprueba si hay almenos un input activo
bool Input::checkAnyInput(InputDeviceToUse device, int controller_index)
bool Input::checkAnyInput(InputDevice device, int controller_index)
{
// Obtenemos el número total de acciones posibles para iterar sobre ellas.
const int num_actions = static_cast<int>(InputAction::SIZE);
// --- Comprobación del Teclado ---
if (device == InputDeviceToUse::KEYBOARD || device == InputDeviceToUse::ANY)
if (device == InputDevice::KEYBOARD || device == InputDevice::ANY)
{
for (int i = 0; i < num_actions; ++i)
{
@@ -125,7 +125,7 @@ bool Input::checkAnyInput(InputDeviceToUse device, int controller_index)
// Comprobamos si hay mandos y si el índice solicitado es válido.
if (gameControllerFound() && controller_index >= 0 && controller_index < num_gamepads_)
{
if (device == InputDeviceToUse::CONTROLLER || device == InputDeviceToUse::ANY)
if (device == InputDevice::CONTROLLER || device == InputDevice::ANY)
{
// Bucle CORREGIDO: Iteramos sobre todas las acciones, no sobre el número de mandos.
for (int i = 0; i < num_actions; ++i)
@@ -150,7 +150,7 @@ int Input::checkAnyButton(bool repeat)
for (auto bi : button_inputs_)
{
// Comprueba el teclado
if (checkInput(bi, repeat, InputDeviceToUse::KEYBOARD))
if (checkInput(bi, repeat, InputDevice::KEYBOARD))
{
return 1;
}
@@ -158,7 +158,7 @@ int Input::checkAnyButton(bool repeat)
// Comprueba los mandos
for (int i = 0; i < num_gamepads_; ++i)
{
if (checkInput(bi, repeat, InputDeviceToUse::CONTROLLER, i))
if (checkInput(bi, repeat, InputDevice::CONTROLLER, i))
{
return i + 1;
}
@@ -273,14 +273,14 @@ int Input::getJoyIndex(SDL_JoystickID id) const
}
// Muestra por consola los controles asignados
void Input::printBindings(InputDeviceToUse device, int controller_index) const
void Input::printBindings(InputDevice device, int controller_index) const
{
if (device == InputDeviceToUse::ANY || device == InputDeviceToUse::KEYBOARD)
if (device == InputDevice::ANY || device == InputDevice::KEYBOARD)
{
return;
}
if (device == InputDeviceToUse::CONTROLLER)
if (device == InputDevice::CONTROLLER)
{
if (controller_index >= num_gamepads_)
{
@@ -349,22 +349,21 @@ InputAction Input::to_inputs_e(const std::string &name) const
bool Input::checkAxisInput(InputAction input, int controller_index, bool repeat)
{
// Umbral para considerar el eje como activo
const Sint16 threshold = 30000;
bool axis_active_now = false;
switch (input)
{
case InputAction::LEFT:
axis_active_now = SDL_GetGamepadAxis(connected_controllers_[controller_index], SDL_GAMEPAD_AXIS_LEFTX) < -threshold;
axis_active_now = SDL_GetGamepadAxis(connected_controllers_[controller_index], SDL_GAMEPAD_AXIS_LEFTX) < -AXIS_THRESHOLD_;
break;
case InputAction::RIGHT:
axis_active_now = SDL_GetGamepadAxis(connected_controllers_[controller_index], SDL_GAMEPAD_AXIS_LEFTX) > threshold;
axis_active_now = SDL_GetGamepadAxis(connected_controllers_[controller_index], SDL_GAMEPAD_AXIS_LEFTX) > AXIS_THRESHOLD_;
break;
case InputAction::UP:
axis_active_now = SDL_GetGamepadAxis(connected_controllers_[controller_index], SDL_GAMEPAD_AXIS_LEFTY) < -threshold;
axis_active_now = SDL_GetGamepadAxis(connected_controllers_[controller_index], SDL_GAMEPAD_AXIS_LEFTY) < -AXIS_THRESHOLD_;
break;
case InputAction::DOWN:
axis_active_now = SDL_GetGamepadAxis(connected_controllers_[controller_index], SDL_GAMEPAD_AXIS_LEFTY) > threshold;
axis_active_now = SDL_GetGamepadAxis(connected_controllers_[controller_index], SDL_GAMEPAD_AXIS_LEFTY) > AXIS_THRESHOLD_;
break;
default:
return false;

View File

@@ -63,7 +63,7 @@ constexpr bool INPUT_ALLOW_REPEAT = true;
constexpr bool INPUT_DO_NOT_ALLOW_REPEAT = false;
// Tipos de dispositivos de entrada
enum class InputDeviceToUse : int
enum class InputDevice : int
{
KEYBOARD = 0,
CONTROLLER = 1,
@@ -86,8 +86,8 @@ public:
// --- Métodos de consulta de entrada ---
void update(); // Comprueba fisicamente los botones y teclas que se han pulsado
bool checkInput(InputAction input, bool repeat = true, InputDeviceToUse device = InputDeviceToUse::ANY, int controller_index = 0); // Comprueba si un input está activo
bool checkAnyInput(InputDeviceToUse device = InputDeviceToUse::ANY, int controller_index = 0); // Comprueba si hay al menos un input activo
bool checkInput(InputAction input, bool repeat = true, InputDevice device = InputDevice::ANY, int controller_index = 0); // Comprueba si un input está activo
bool checkAnyInput(InputDevice device = InputDevice::ANY, int controller_index = 0); // Comprueba si hay al menos un input activo
int checkAnyButton(bool repeat = INPUT_DO_NOT_ALLOW_REPEAT); // Comprueba si hay algún botón pulsado
// --- Métodos de gestión de mandos ---
@@ -98,7 +98,7 @@ public:
int getJoyIndex(SDL_JoystickID id) const; // Obtiene el índice del controlador a partir de un event.id
// --- Métodos de consulta y utilidades ---
void printBindings(InputDeviceToUse device = InputDeviceToUse::KEYBOARD, int controller_index = 0) const; // Muestra por consola los controles asignados
void printBindings(InputDevice device = InputDevice::KEYBOARD, int controller_index = 0) const; // Muestra por consola los controles asignados
SDL_GamepadButton getControllerBinding(int controller_index, InputAction input) const; // Obtiene el SDL_GamepadButton asignado a un input
std::string to_string(InputAction input) const; // Convierte un InputAction a std::string
InputAction to_inputs_e(const std::string &name) const; // Convierte un std::string a InputAction
@@ -133,6 +133,9 @@ private:
: button(btn), is_held(is_held), just_pressed(just_pressed), axis_active(axis_act) {}
};
// --- Constantes ---
static constexpr Sint16 AXIS_THRESHOLD_ = 30000;
// --- Variables internas ---
std::vector<SDL_Gamepad *> connected_controllers_; // Vector con todos los mandos conectados
std::vector<SDL_Joystick *> joysticks_; // Vector con todos los joysticks conectados

View File

@@ -264,7 +264,7 @@ namespace Options
}
else if (var == "controller.0.type")
{
controllers.at(0).type = static_cast<InputDeviceToUse>(std::stoi(value));
controllers.at(0).type = static_cast<InputDevice>(std::stoi(value));
}
else if (var == "controller.0.button.fire_left")
{
@@ -296,7 +296,7 @@ namespace Options
}
else if (var == "controller.1.type")
{
controllers.at(1).type = static_cast<InputDeviceToUse>(std::stoi(value));
controllers.at(1).type = static_cast<InputDevice>(std::stoi(value));
}
else if (var == "controller.1.button.fire_left")
{
@@ -338,11 +338,11 @@ namespace Options
{
if (controller.player_id == player_id)
{
controller.type = InputDeviceToUse::ANY;
controller.type = InputDevice::ANY;
}
else
{
controller.type = InputDeviceToUse::CONTROLLER;
controller.type = InputDevice::CONTROLLER;
}
}
}
@@ -365,7 +365,7 @@ namespace Options
{
for (const auto &controller : controllers)
{
if (controller.type == InputDeviceToUse::ANY)
if (controller.type == InputDevice::ANY)
{
return controller.player_id;
}

View File

@@ -143,7 +143,7 @@ namespace Options
{
int index; // Índice en el vector de mandos
int player_id; // Jugador asociado al mando
InputDeviceToUse type; // Indica si se usará teclado, mando o ambos
InputDevice type; // Indica si se usará teclado, mando o ambos
std::string name; // Nombre del dispositivo
bool plugged; // Indica si el mando está conectado
std::vector<InputAction> inputs; // Listado de acciones asignadas
@@ -153,7 +153,7 @@ namespace Options
GamepadOptions()
: index(INVALID_INDEX),
player_id(INVALID_INDEX),
type(InputDeviceToUse::CONTROLLER),
type(InputDevice::CONTROLLER),
name(),
plugged(false),
inputs{

View File

@@ -27,6 +27,7 @@
#include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "utils.h" // Para Color, Zone, shdw_txt_color, no_color
#include "ui/service_menu.h"
#include "input.h"
// Textos
constexpr const char TEXT_COPYRIGHT[] = "@2020,2025 JailDesigner";
@@ -141,6 +142,8 @@ void Credits::checkEvents()
// Comprueba las entradas
void Credits::checkInput()
{
Input::get()->update();
if (!ServiceMenu::get()->isEnabled())
{
// Comprueba si se ha pulsado cualquier botón (de los usados para jugar)

View File

@@ -1330,6 +1330,8 @@ int Game::getController(int player_id)
// Gestiona la entrada durante el juego
void Game::checkInput()
{
Input::get()->update();
// Comprueba las entradas si no está el menú de servicio activo
if (!ServiceMenu::get()->isEnabled())
{
@@ -1353,7 +1355,7 @@ void Game::checkPauseInput()
// Comprueba los mandos
for (int i = 0; i < input_->getNumControllers(); ++i)
{
if (input_->checkInput(InputAction::PAUSE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
if (input_->checkInput(InputAction::PAUSE, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::CONTROLLER, i))
{
pause(!paused_);
return;
@@ -1361,7 +1363,7 @@ void Game::checkPauseInput()
}
// Comprueba el teclado
if (input_->checkInput(InputAction::PAUSE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
if (input_->checkInput(InputAction::PAUSE, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD))
{
pause(!paused_);
return;

View File

@@ -25,6 +25,7 @@
#include "text.h" // Para Text, TEXT_SHADOW, TEXT_COLOR
#include "texture.h" // Para Texture
#include "utils.h" // Para Color, easeOutQuint, fade_color, Zone
#include "input.h"
// Constructor
HiScoreTable::HiScoreTable()
@@ -142,7 +143,11 @@ void HiScoreTable::checkEvents()
}
// Comprueba las entradas
void HiScoreTable::checkInput() { GlobalInputs::check(); }
void HiScoreTable::checkInput()
{
Input::get()->update();
GlobalInputs::check();
}
// Bucle para la pantalla de instrucciones
void HiScoreTable::run()

View File

@@ -20,6 +20,7 @@
#include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR, TEXT_...
#include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "utils.h" // Para Color, shdw_txt_color, Zone, no_color
#include "input.h"
// Constructor
Instructions::Instructions()
@@ -273,7 +274,11 @@ void Instructions::checkEvents()
}
// Comprueba las entradas
void Instructions::checkInput() { GlobalInputs::check(); }
void Instructions::checkInput()
{
Input::get()->update();
GlobalInputs::check();
}
// Bucle para la pantalla de instrucciones
void Instructions::run()

View File

@@ -22,6 +22,7 @@
#include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "utils.h" // Para Color, Zone, easeOutQuint, BLOCK
#include "writer.h" // Para Writer
#include "input.h"
// Constructor
Intro::Intro()
@@ -53,7 +54,11 @@ void Intro::checkEvents()
}
// Comprueba las entradas
void Intro::checkInput() { GlobalInputs::check(); }
void Intro::checkInput()
{
Input::get()->update();
GlobalInputs::check();
}
// Actualiza las escenas de la intro
void Intro::updateScenes()

View File

@@ -12,6 +12,7 @@
#include "sprite.h" // Para Sprite
#include "texture.h" // Para Texture
#include "utils.h" // Para Color, Zone
#include "input.h"
// Constructor
Logo::Logo()
@@ -74,7 +75,11 @@ void Logo::checkEvents()
}
// Comprueba las entradas
void Logo::checkInput() { GlobalInputs::check(); }
void Logo::checkInput()
{
Input::get()->update();
GlobalInputs::check();
}
// Gestiona el logo de JAILGAMES
void Logo::updateJAILGAMES()

View File

@@ -180,6 +180,8 @@ void Title::checkEvents()
// Comprueba las entradas
void Title::checkInput()
{
Input::get()->update();
if (!ServiceMenu::get()->isEnabled())
{
// Comprueba las entradas solo si no se estan definiendo los botones