INPUT_USE_* → enum class Input::Device

This commit is contained in:
2026-05-16 19:54:52 +02:00
parent d72630523a
commit 40e1140734
8 changed files with 42 additions and 39 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ Game::Game(int num_players, int current_stage, SDL_Renderer *renderer, bool demo
#endif
if (num_players == 1) { // Si solo juega un jugador, permite jugar tanto con teclado como con mando
player_one_control_ = Options::inputs[0].device_type;
Options::inputs[0].device_type = INPUT_USE_ANY;
Options::inputs[0].device_type = Input::Device::ANY;
}
difficulty_ = Options::settings.difficulty;
+1 -1
View File
@@ -372,7 +372,7 @@ class Game {
Uint8 difficulty_; // Dificultad del juego
float difficulty_score_multiplier_; // Multiplicador de puntos en función de la dificultad
Color difficulty_color_; // Color asociado a la dificultad
Uint8 player_one_control_; // Variable para almacenar el valor de las opciones
Input::Device player_one_control_; // Variable para almacenar el valor de las opciones
EnemyFormation enemy_formation_[NUMBER_OF_ENEMY_FORMATIONS]; // Vector con todas las formaciones enemigas
EnemyPool enemy_pool_[10]; // Variable con los diferentes conjuntos de formaciones enemigas
Uint8 last_stage_reached_; // Contiene el numero de la última pantalla que se ha alcanzado
+7 -7
View File
@@ -7,7 +7,7 @@
#include <iostream>
#include <string>
#include "core/input/input.h" // for INPUT_USE_KEYBOARD, INPUT_USE_GAMECONTROLLER
#include "core/input/input.h" // for Input::Device::KEYBOARD, Input::Device::GAMECONTROLLER
#include "core/locale/lang.h" // for Lang::Code, Lang::MAX_LANGUAGES
#include "external/fkyaml_node.hpp" // for fkyaml::node
#include "utils/utils.h" // for boolToString
@@ -163,9 +163,9 @@ namespace Options {
size_t i = 0;
for (const auto &entry : ins) {
if (i >= inputs.size()) { break; }
int device_type_int = inputs[i].device_type;
int device_type_int = static_cast<int>(inputs[i].device_type);
if (tryGet<int>(entry, "device_type", device_type_int)) {
inputs[i].device_type = static_cast<Uint8>(device_type_int);
inputs[i].device_type = static_cast<Input::Device>(device_type_int);
}
++i;
}
@@ -202,13 +202,13 @@ namespace Options {
InputDevice kb;
kb.id = 0;
kb.name = "KEYBOARD";
kb.device_type = INPUT_USE_KEYBOARD;
kb.device_type = Input::Device::KEYBOARD;
inputs.push_back(kb);
InputDevice gc;
gc.id = 0;
gc.name = "GAME CONTROLLER";
gc.device_type = INPUT_USE_GAMECONTROLLER;
gc.device_type = Input::Device::GAMECONTROLLER;
inputs.push_back(gc);
}
@@ -325,8 +325,8 @@ namespace Options {
// INPUT
file << "# INPUT DEVICES (device_type: "
<< static_cast<int>(INPUT_USE_KEYBOARD) << "=KEYBOARD, "
<< static_cast<int>(INPUT_USE_GAMECONTROLLER) << "=GAMECONTROLLER)\n";
<< static_cast<int>(Input::Device::KEYBOARD) << "=KEYBOARD, "
<< static_cast<int>(Input::Device::GAMECONTROLLER) << "=GAMECONTROLLER)\n";
file << "input:\n";
for (size_t i = 0; i < inputs.size(); ++i) {
file << " - slot: " << i << "\n";
+11 -11
View File
@@ -8,7 +8,7 @@
#include "core/audio/audio.hpp" // for Audio
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
#include "core/input/input.h" // for Input, INPUT_USE_GAMECONTROLLER, INPUT_...
#include "core/input/input.h" // for Input, Input::Device::GAMECONTROLLER, INPUT_...
#include "core/locale/lang.h" // for Lang, Lang::Code
#include "core/rendering/animatedsprite.h" // for AnimatedSprite
#include "core/rendering/fade.h" // for Fade
@@ -115,12 +115,12 @@ void Title::init() {
InputDevice inp;
inp.id = 0;
inp.name = "KEYBOARD";
inp.device_type = INPUT_USE_KEYBOARD;
inp.device_type = Input::Device::KEYBOARD;
Options::inputs.push_back(inp);
inp.id = 0;
inp.name = "GAME CONTROLLER";
inp.device_type = INPUT_USE_GAMECONTROLLER;
inp.device_type = Input::Device::GAMECONTROLLER;
Options::inputs.push_back(inp);
// Comprueba si hay mandos conectados
@@ -676,12 +676,12 @@ void Title::updateMenuLabels() const {
i++;
// PLAYER 1 CONTROLS - OPTIONS
switch (Options::inputs[0].device_type) {
case INPUT_USE_KEYBOARD:
case Input::Device::KEYBOARD:
menu_.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD
menu_.options->setGreyed(i, false);
break;
case INPUT_USE_GAMECONTROLLER:
case Input::Device::GAMECONTROLLER:
menu_.options->setItemCaption(i, Lang::get()->getText(70)); // GAME CONTROLLER
if (!Input::get()->gameControllerFound()) {
menu_.options->setGreyed(i, true);
@@ -703,12 +703,12 @@ void Title::updateMenuLabels() const {
i++;
// PLAYER 2 CONTROLS - OPTIONS
switch (Options::inputs[1].device_type) {
case INPUT_USE_KEYBOARD:
case Input::Device::KEYBOARD:
menu_.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD
menu_.options->setGreyed(i, false);
break;
case INPUT_USE_GAMECONTROLLER:
case Input::Device::GAMECONTROLLER:
menu_.options->setItemCaption(i, Lang::get()->getText(70)); // GAME CONTROLLER
if (!Input::get()->gameControllerFound()) {
menu_.options->setGreyed(i, true);
@@ -963,11 +963,11 @@ auto Title::updatePlayerInputs(int num_player) -> bool {
Options::inputs[0].id = -1;
Options::inputs[0].name = "KEYBOARD";
Options::inputs[0].device_type = INPUT_USE_KEYBOARD;
Options::inputs[0].device_type = Input::Device::KEYBOARD;
Options::inputs[1].id = 0;
Options::inputs[1].name = "GAME CONTROLLER";
Options::inputs[1].device_type = INPUT_USE_GAMECONTROLLER;
Options::inputs[1].device_type = Input::Device::GAMECONTROLLER;
return true;
} // Si hay mas de un dispositivo, se recorre el vector
@@ -1059,7 +1059,7 @@ void Title::checkInputDevices() {
for (int i = 0; i < NUM_CONTROLLERS; ++i) {
temp.id = i;
temp.name = Input::get()->getControllerName(i);
temp.device_type = INPUT_USE_GAMECONTROLLER;
temp.device_type = Input::Device::GAMECONTROLLER;
available_input_devices_.push_back(temp);
if (Options::settings.console) {
std::cout << "Device " << (int)available_input_devices_.size() << " - " << temp.name.c_str() << '\n';
@@ -1070,7 +1070,7 @@ void Title::checkInputDevices() {
// Añade el teclado al final
temp.id = -1;
temp.name = "KEYBOARD";
temp.device_type = INPUT_USE_KEYBOARD;
temp.device_type = Input::Device::KEYBOARD;
available_input_devices_.push_back(temp);
if (Options::settings.console) {
std::cout << "Device " << (int)available_input_devices_.size() << " - " << temp.name.c_str() << '\n';