mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-06-05 22:55:04 -06:00
Refactor wiimote handling: Replace hardcoded values with MAX_WIIMOTES constant for better maintainability
This commit is contained in:
parent
b7eeaac846
commit
02fb9b5cef
@ -181,7 +181,7 @@ bool wiimote_device::update()
|
|||||||
m_state.acc_z = (buf[5] << 2) | ((buf[2] >> 6) & 1);
|
m_state.acc_z = (buf[5] << 2) | ((buf[2] >> 6) & 1);
|
||||||
|
|
||||||
// Each IR point is 3 bytes in Extended report 0x33.
|
// Each IR point is 3 bytes in Extended report 0x33.
|
||||||
for (int j = 0; j < 4; j++)
|
for (usz j = 0; j < MAX_WIIMOTES; j++)
|
||||||
{
|
{
|
||||||
const u8* ir = &buf[6 + j * 3];
|
const u8* ir = &buf[6 + j * 3];
|
||||||
m_state.ir[j].x = (ir[0] | ((ir[2] & 0x30) << 4));
|
m_state.ir[j].x = (ir[0] | ((ir[2] & 0x30) << 4));
|
||||||
@ -252,8 +252,8 @@ wiimote_handler::wiimote_handler()
|
|||||||
if (!s_instance)
|
if (!s_instance)
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
|
|
||||||
// Pre-initialize 4 Wiimote slots (standard for DolphinBar and typical local multiplayer)
|
// Pre-initialize Wiimote slots (standard for DolphinBar and typical local multiplayer)
|
||||||
for (int i = 0; i < 4; i++)
|
for (usz i = 0; i < MAX_WIIMOTES; i++)
|
||||||
{
|
{
|
||||||
m_devices.push_back(std::make_unique<wiimote_device>());
|
m_devices.push_back(std::make_unique<wiimote_device>());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,8 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
static constexpr usz MAX_WIIMOTES = 4;
|
||||||
|
|
||||||
struct wiimote_ir_point
|
struct wiimote_ir_point
|
||||||
{
|
{
|
||||||
u16 x = 1023;
|
u16 x = 1023;
|
||||||
@ -58,7 +60,7 @@ struct wiimote_state
|
|||||||
s16 acc_x = 0;
|
s16 acc_x = 0;
|
||||||
s16 acc_y = 0;
|
s16 acc_y = 0;
|
||||||
s16 acc_z = 0;
|
s16 acc_z = 0;
|
||||||
std::array<wiimote_ir_point, 4> ir {};
|
std::array<wiimote_ir_point, MAX_WIIMOTES> ir {};
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -183,7 +183,7 @@ void wiimote_settings_dialog::update_state()
|
|||||||
painter.drawLine(pixmap.width() / 2, 0, pixmap.width() / 2, pixmap.height());
|
painter.drawLine(pixmap.width() / 2, 0, pixmap.width() / 2, pixmap.height());
|
||||||
painter.drawLine(0, pixmap.height() / 2, pixmap.width(), pixmap.height() / 2);
|
painter.drawLine(0, pixmap.height() / 2, pixmap.width(), pixmap.height() / 2);
|
||||||
|
|
||||||
static const std::array<QColor, 4> colors = { Qt::red, Qt::green, Qt::blue, Qt::yellow };
|
static const std::array<QColor, MAX_WIIMOTES> colors = { Qt::red, Qt::green, Qt::blue, Qt::yellow };
|
||||||
|
|
||||||
for (usz i = 0; i < state.ir.size(); ++i)
|
for (usz i = 0; i < state.ir.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user