migrant input: ja compila, ja no peta... falta descomentar mig codi

This commit is contained in:
2025-07-31 12:02:16 +02:00
parent 2d9a6e744e
commit 89a0638a89
13 changed files with 171 additions and 142 deletions

View File

@@ -20,7 +20,7 @@ DefineButtons::DefineButtons()
clearButtons();
for (int i = 0; i < input_->getNumControllers(); ++i) {
controller_names_.emplace_back(input_->getControllerName(i));
// controller_names_.emplace_back(input_->getControllerName(i));
}
}
@@ -28,18 +28,18 @@ DefineButtons::DefineButtons()
void DefineButtons::render() {
static auto text = Resource::get()->getText("8bithud");
if (enabled_) {
text->writeCentered(x_, y_ - 10, Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(Options::controllers.at(index_controller_).player_id));
text->writeCentered(x_, y_, controller_names_.at(index_controller_));
text->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label);
// text->writeCentered(x_, y_ - 10, Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(Options::controllers.at(index_controller_).player_id));
// text->writeCentered(x_, y_, controller_names_.at(index_controller_));
// text->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label);
}
}
// Comprueba el botón que se ha pulsado
void DefineButtons::doControllerButtonDown(const SDL_GamepadButtonEvent &event) {
// Solo pilla botones del mando que toca
if (input_->getJoyIndex(event.which) != static_cast<int>(index_controller_)) {
return;
}
// if (input_->getJoyIndex(event.which) != static_cast<int>(index_controller_)) {
// return;
//}
const auto BUTTON = static_cast<SDL_GamepadButton>(event.button);
if (checkButtonNotInUse(BUTTON)) {
@@ -99,11 +99,11 @@ void DefineButtons::incIndexButton() {
// Guarda los cambios en las opciones
void DefineButtons::saveBindingsToOptions() {
auto &controller = Options::controllers.at(index_controller_);
controller.name = input_->getControllerName(index_controller_);
for (size_t j = 0; j < controller.inputs.size(); ++j) {
controller.buttons.at(j) = input_->getControllerBinding(index_controller_, controller.inputs.at(j));
}
// auto &controller = Options::controllers.at(index_controller_);
// controller.name = input_->getControllerName(index_controller_);
// for (size_t j = 0; j < controller.inputs.size(); ++j) {
// controller.buttons.at(j) = input_->getControllerBinding(index_controller_, controller.inputs.at(j));
// }
}
// Comprueba que un botón no esté ya asignado
@@ -126,7 +126,7 @@ void DefineButtons::clearButtons() {
// Comprueba si ha finalizado
void DefineButtons::checkEnd() {
if (finished_) {
bindButtons(); // Asigna los botones definidos al input_
// bindButtons(); // Asigna los botones definidos al input_
saveBindingsToOptions(); // Guarda los cambios en las opciones
input_->resetInputStates(); // Reinicia los estados de las pulsaciones de los botones
enabled_ = false; // Deshabilita