From b7eeaac846ff650d744793ca4b5a160cdb25f479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Hamil?= Date: Sat, 14 Feb 2026 09:05:04 +0300 Subject: [PATCH] Refactor wiimote_settings_dialog: Improve variable naming and initialization --- rpcs3/Emu/Io/GunCon3.cpp | 12 +++--- rpcs3/rpcs3qt/wiimote_settings_dialog.cpp | 48 +++++++++++------------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/rpcs3/Emu/Io/GunCon3.cpp b/rpcs3/Emu/Io/GunCon3.cpp index 565780e3b5..5338091c45 100644 --- a/rpcs3/Emu/Io/GunCon3.cpp +++ b/rpcs3/Emu/Io/GunCon3.cpp @@ -1,17 +1,16 @@ #include "stdafx.h" #include "GunCon3.h" #include "MouseHandler.h" -#include -#include -#include -#include #include "Emu/IdManager.h" #include "Emu/Io/guncon3_config.h" #include "Emu/Cell/lv2/sys_usbd.h" #include "Emu/system_config.h" +#include "Emu/RSX/Overlays/overlay_cursor.h" #include "Input/wiimote_handler.h" #include "Input/pad_thread.h" -#include "Emu/RSX/Overlays/overlay_cursor.h" +#include +#include +#include LOG_CHANNEL(guncon3_log); @@ -139,7 +138,8 @@ usb_device_guncon3::usb_device_guncon3(u32 controller_index, const std::arraym_controller_index < b->m_controller_index; }); } diff --git a/rpcs3/rpcs3qt/wiimote_settings_dialog.cpp b/rpcs3/rpcs3qt/wiimote_settings_dialog.cpp index d4896a1664..28271ff662 100644 --- a/rpcs3/rpcs3qt/wiimote_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/wiimote_settings_dialog.cpp @@ -85,7 +85,7 @@ void wiimote_settings_dialog::restore_defaults() if (!wm) return; // Reset to default mapping - wiimote_guncon_mapping default_map; + const wiimote_guncon_mapping default_map {}; wm->set_mapping(default_map); // Update UI @@ -112,7 +112,7 @@ void wiimote_settings_dialog::apply_mappings() auto* wm = wiimote_handler::get_instance(); if (!wm) return; - wiimote_guncon_mapping map; + wiimote_guncon_mapping map {}; const std::array targets = { &map.trigger, &map.a1, &map.a2, &map.c1, &map.b1, &map.b2, &map.b3, &map.a3, &map.c2 @@ -130,7 +130,7 @@ void wiimote_settings_dialog::apply_mappings() void wiimote_settings_dialog::update_state() { - int index = ui->wiimoteList->currentRow(); + const int index = ui->wiimoteList->currentRow(); auto* wm = wiimote_handler::get_instance(); if (!wm || index < 0) { @@ -152,27 +152,27 @@ void wiimote_settings_dialog::update_state() const auto& state = states[index]; ui->connectionStatus->setText(state.connected ? tr("Connected") : tr("Disconnected")); - QStringList pressedButtons; - if (state.buttons & 0x0001) pressedButtons << tr("Left"); - if (state.buttons & 0x0002) pressedButtons << tr("Right"); - if (state.buttons & 0x0004) pressedButtons << tr("Down"); - if (state.buttons & 0x0008) pressedButtons << tr("Up"); - if (state.buttons & 0x0010) pressedButtons << tr("Plus"); - if (state.buttons & 0x0100) pressedButtons << tr("2"); - if (state.buttons & 0x0200) pressedButtons << tr("1"); - if (state.buttons & 0x0400) pressedButtons << tr("B"); - if (state.buttons & 0x0800) pressedButtons << tr("A"); - if (state.buttons & 0x1000) pressedButtons << tr("Minus"); - if (state.buttons & 0x8000) pressedButtons << tr("Home"); + QStringList pressed_buttons; + if (state.buttons & 0x0001) pressed_buttons << tr("Left"); + if (state.buttons & 0x0002) pressed_buttons << tr("Right"); + if (state.buttons & 0x0004) pressed_buttons << tr("Down"); + if (state.buttons & 0x0008) pressed_buttons << tr("Up"); + if (state.buttons & 0x0010) pressed_buttons << tr("Plus"); + if (state.buttons & 0x0100) pressed_buttons << tr("2"); + if (state.buttons & 0x0200) pressed_buttons << tr("1"); + if (state.buttons & 0x0400) pressed_buttons << tr("B"); + if (state.buttons & 0x0800) pressed_buttons << tr("A"); + if (state.buttons & 0x1000) pressed_buttons << tr("Minus"); + if (state.buttons & 0x8000) pressed_buttons << tr("Home"); - QString buttonText = QString("0x%1").arg(state.buttons, 4, 16, QChar('0')).toUpper(); - if (!pressedButtons.isEmpty()) + QString button_text = QString("0x%1").arg(state.buttons, 4, 16, QChar('0')).toUpper(); + if (!pressed_buttons.isEmpty()) { - buttonText += " (" + pressedButtons.join(", ") + ")"; + button_text += " (" + pressed_buttons.join(", ") + ")"; } - ui->buttonState->setText(buttonText); + ui->buttonState->setText(button_text); - QString irText; + QString ir_text; QPixmap pixmap(ui->irVisual->size()); pixmap.fill(Qt::black); QPainter painter(&pixmap); @@ -183,13 +183,13 @@ void wiimote_settings_dialog::update_state() painter.drawLine(pixmap.width() / 2, 0, pixmap.width() / 2, pixmap.height()); painter.drawLine(0, pixmap.height() / 2, pixmap.width(), pixmap.height() / 2); - static const QColor colors[] = { Qt::red, Qt::green, Qt::blue, Qt::yellow }; + static const std::array colors = { Qt::red, Qt::green, Qt::blue, Qt::yellow }; - for (int i = 0; i < 4; ++i) + for (usz i = 0; i < state.ir.size(); ++i) { if (state.ir[i].size > 0 && state.ir[i].x < 1023 && state.ir[i].y < 1023) { - irText += QString("[%1: %2, %3] ").arg(i).arg(state.ir[i].x).arg(state.ir[i].y); + ir_text += QString("[%1: %2, %3] ").arg(i).arg(state.ir[i].x).arg(state.ir[i].y); // Map 0..1023 X and 0..767 Y to pixmap coordinates // Wiimote X/Y are inverted relative to pointing direction @@ -203,7 +203,7 @@ void wiimote_settings_dialog::update_state() } } ui->irVisual->setPixmap(pixmap); - ui->irData->setText(irText.isEmpty() ? tr("No IR data") : irText); + ui->irData->setText(ir_text.isEmpty() ? tr("No IR data") : ir_text); } void wiimote_settings_dialog::update_list()