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
+8 -8
View File
@@ -104,22 +104,22 @@ void Input::bindGameControllerButton(Uint8 input, SDL_GamepadButton button) {
}
// Comprueba si un input esta activo
auto Input::checkInput(Uint8 input, Repeat repeat, int device, int index) -> bool {
auto Input::checkInput(Uint8 input, Repeat repeat, Device device, int index) -> bool {
if (!enabled_) {
return false;
}
if (device == INPUT_USE_ANY) {
if (device == Device::ANY) {
index = 0;
}
bool success_keyboard = false;
if (device == INPUT_USE_KEYBOARD || device == INPUT_USE_ANY) {
if (device == Device::KEYBOARD || device == Device::ANY) {
success_keyboard = checkKeyboardInput(input, repeat);
}
bool success_game_controller = false;
if ((device == INPUT_USE_GAMECONTROLLER || device == INPUT_USE_ANY) && gameControllerFound() && index >= 0 && index < (int)connected_controllers_.size()) {
if ((device == Device::GAMECONTROLLER || device == Device::ANY) && gameControllerFound() && index >= 0 && index < (int)connected_controllers_.size()) {
success_game_controller = checkGameControllerInput(input, repeat, index);
}
@@ -156,12 +156,12 @@ auto Input::checkGameControllerInput(Uint8 input, Repeat repeat, int index) -> b
}
// Comprueba si hay almenos un input activo
auto Input::checkAnyInput(int device, int index) -> bool {
if (device == INPUT_USE_ANY) {
auto Input::checkAnyInput(Device device, int index) -> bool {
if (device == Device::ANY) {
index = 0;
}
if (device == INPUT_USE_KEYBOARD || device == INPUT_USE_ANY) {
if (device == Device::KEYBOARD || device == Device::ANY) {
const bool *key_states = SDL_GetKeyboardState(nullptr);
if (std::ranges::any_of(key_bindings_,
@@ -171,7 +171,7 @@ auto Input::checkAnyInput(int device, int index) -> bool {
}
if (gameControllerFound() && index >= 0 && index < (int)connected_controllers_.size()) {
if (device == INPUT_USE_GAMECONTROLLER || device == INPUT_USE_ANY) {
if (device == Device::GAMECONTROLLER || device == Device::ANY) {
for (auto &game_controller_binding : game_controller_bindings_) {
if (SDL_GetGamepadButton(connected_controllers_[index], game_controller_binding.button)) {
return true;