aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/configuration/configure_input_player_widget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu/configuration/configure_input_player_widget.cpp')
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.cpp279
1 files changed, 157 insertions, 122 deletions
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index b8bcb44a4..61ba91cef 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -37,7 +37,8 @@ void PlayerControlPreview::SetPlayerInput(std::size_t index, const ButtonParam&
Input::CreateDevice<Input::AnalogDevice>);
UpdateColors();
}
-void PlayerControlPreview::SetPlayerInputRaw(std::size_t index, const Settings::ButtonsRaw buttons_,
+void PlayerControlPreview::SetPlayerInputRaw(std::size_t index,
+ const Settings::ButtonsRaw& buttons_,
Settings::AnalogsRaw analogs_) {
player_index = index;
std::transform(buttons_.begin() + Settings::NativeButton::BUTTON_HID_BEGIN,
@@ -520,14 +521,15 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center)
{
// Draw joysticks
using namespace Settings::NativeAnalog;
- DrawJoystick(p, center + QPointF(-65, -65) + (axis_values[LStick].value * 7), 1.62f,
- button_values[Settings::NativeButton::LStick]);
- DrawJoystick(p, center + QPointF(65, 12) + (axis_values[RStick].value * 7), 1.62f,
- button_values[Settings::NativeButton::RStick]);
- DrawRawJoystick(p, center + QPointF(-180, 90), axis_values[LStick].raw_value,
- axis_values[LStick].properties);
- DrawRawJoystick(p, center + QPointF(180, 90), axis_values[RStick].raw_value,
- axis_values[RStick].properties);
+ const auto& l_stick = axis_values[LStick];
+ const auto l_button = button_values[Settings::NativeButton::LStick];
+ const auto& r_stick = axis_values[RStick];
+ const auto r_button = button_values[Settings::NativeButton::RStick];
+
+ DrawJoystick(p, center + QPointF(-65, -65) + (l_stick.value * 7), 1.62f, l_button);
+ DrawJoystick(p, center + QPointF(65, 12) + (r_stick.value * 7), 1.62f, r_button);
+ DrawRawJoystick(p, center + QPointF(-180, 90), l_stick.raw_value, l_stick.properties);
+ DrawRawJoystick(p, center + QPointF(180, 90), r_stick.raw_value, r_stick.properties);
}
using namespace Settings::NativeButton;
@@ -606,14 +608,15 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen
{
// Draw joysticks
using namespace Settings::NativeAnalog;
- DrawJoystick(p, center + QPointF(-171, -41) + (axis_values[LStick].value * 4), 1.0f,
- button_values[Settings::NativeButton::LStick]);
- DrawJoystick(p, center + QPointF(171, 8) + (axis_values[RStick].value * 4), 1.0f,
- button_values[Settings::NativeButton::RStick]);
- DrawRawJoystick(p, center + QPointF(-50, 0), axis_values[LStick].raw_value,
- axis_values[LStick].properties);
- DrawRawJoystick(p, center + QPointF(50, 0), axis_values[RStick].raw_value,
- axis_values[RStick].properties);
+ const auto& l_stick = axis_values[LStick];
+ const auto l_button = button_values[Settings::NativeButton::LStick];
+ const auto& r_stick = axis_values[RStick];
+ const auto r_button = button_values[Settings::NativeButton::RStick];
+
+ DrawJoystick(p, center + QPointF(-171, -41) + (l_stick.value * 4), 1.0f, l_button);
+ DrawJoystick(p, center + QPointF(171, 8) + (r_stick.value * 4), 1.0f, r_button);
+ DrawRawJoystick(p, center + QPointF(-50, 0), l_stick.raw_value, l_stick.properties);
+ DrawRawJoystick(p, center + QPointF(50, 0), r_stick.raw_value, r_stick.properties);
}
using namespace Settings::NativeButton;
@@ -702,9 +705,9 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
{
// Draw joysticks
using namespace Settings::NativeAnalog;
- DrawProJoystick(p, center + QPointF(-111, -55) + (axis_values[LStick].value * 11),
+ DrawProJoystick(p, center + QPointF(-111, -55), axis_values[LStick].value, 11,
button_values[Settings::NativeButton::LStick]);
- DrawProJoystick(p, center + QPointF(51, 0) + (axis_values[RStick].value * 11),
+ DrawProJoystick(p, center + QPointF(51, 0), axis_values[RStick].value, 11,
button_values[Settings::NativeButton::RStick]);
DrawRawJoystick(p, center + QPointF(-50, 105), axis_values[LStick].raw_value,
axis_values[LStick].properties);
@@ -1005,12 +1008,6 @@ constexpr std::array<float, 3 * 2> up_arrow_symbol = {
0.0f, -3.0f, -3.0f, 2.0f, 3.0f, 2.0f,
};
-constexpr std::array<float, 13 * 2> up_arrow = {
- 9.4f, -9.8f, 9.4f, -10.2f, 8.9f, -29.8f, 8.5f, -30.0f, 8.1f,
- -30.1f, 7.7f, -30.1f, -8.6f, -30.0f, -9.0f, -29.8f, -9.3f, -29.5f,
- -9.5f, -29.1f, -9.5f, -28.7f, -9.1f, -9.1f, -8.8f, -8.8f,
-};
-
constexpr std::array<float, 64 * 2> trigger_button = {
5.5f, -12.6f, 5.8f, -12.6f, 6.7f, -12.5f, 8.1f, -12.3f, 8.6f, -12.2f, 9.2f, -12.0f,
9.5f, -11.9f, 9.9f, -11.8f, 10.6f, -11.5f, 11.0f, -11.3f, 11.2f, -11.2f, 11.4f, -11.1f,
@@ -1460,15 +1457,18 @@ void PlayerControlPreview::DrawProBody(QPainter& p, const QPointF center) {
constexpr int radius1 = 32;
for (std::size_t point = 0; point < pro_left_handle.size() / 2; ++point) {
- qleft_handle[point] =
- center + QPointF(pro_left_handle[point * 2], pro_left_handle[point * 2 + 1]);
- qright_handle[point] =
- center + QPointF(-pro_left_handle[point * 2], pro_left_handle[point * 2 + 1]);
+ const float left_x = pro_left_handle[point * 2 + 0];
+ const float left_y = pro_left_handle[point * 2 + 1];
+
+ qleft_handle[point] = center + QPointF(left_x, left_y);
+ qright_handle[point] = center + QPointF(-left_x, left_y);
}
for (std::size_t point = 0; point < pro_body.size() / 2; ++point) {
- qbody[point] = center + QPointF(pro_body[point * 2], pro_body[point * 2 + 1]);
- qbody[pro_body.size() - 1 - point] =
- center + QPointF(-pro_body[point * 2], pro_body[point * 2 + 1]);
+ const float body_x = pro_body[point * 2 + 0];
+ const float body_y = pro_body[point * 2 + 1];
+
+ qbody[point] = center + QPointF(body_x, body_y);
+ qbody[pro_body.size() - 1 - point] = center + QPointF(-body_x, body_y);
}
// Draw left handle body
@@ -1499,21 +1499,25 @@ void PlayerControlPreview::DrawGCBody(QPainter& p, const QPointF center) {
constexpr float angle = 2 * 3.1415f / 8;
for (std::size_t point = 0; point < gc_left_body.size() / 2; ++point) {
- qleft_handle[point] =
- center + QPointF(gc_left_body[point * 2], gc_left_body[point * 2 + 1]);
- qright_handle[point] =
- center + QPointF(-gc_left_body[point * 2], gc_left_body[point * 2 + 1]);
+ const float body_x = gc_left_body[point * 2 + 0];
+ const float body_y = gc_left_body[point * 2 + 1];
+
+ qleft_handle[point] = center + QPointF(body_x, body_y);
+ qright_handle[point] = center + QPointF(-body_x, body_y);
}
for (std::size_t point = 0; point < gc_body.size() / 2; ++point) {
- qbody[point] = center + QPointF(gc_body[point * 2], gc_body[point * 2 + 1]);
- qbody[gc_body.size() - 1 - point] =
- center + QPointF(-gc_body[point * 2], gc_body[point * 2 + 1]);
+ const float body_x = gc_body[point * 2 + 0];
+ const float body_y = gc_body[point * 2 + 1];
+
+ qbody[point] = center + QPointF(body_x, body_y);
+ qbody[gc_body.size() - 1 - point] = center + QPointF(-body_x, body_y);
}
for (std::size_t point = 0; point < 8; ++point) {
- left_hex[point] =
- center + QPointF(34 * std::cos(point * angle) - 111, 34 * std::sin(point * angle) - 44);
- right_hex[point] =
- center + QPointF(26 * std::cos(point * angle) + 61, 26 * std::sin(point * angle) + 37);
+ const float point_cos = std::cos(point * angle);
+ const float point_sin = std::sin(point * angle);
+
+ left_hex[point] = center + QPointF(34 * point_cos - 111, 34 * point_sin - 44);
+ right_hex[point] = center + QPointF(26 * point_cos + 61, 26 * point_sin + 37);
}
// Draw body
@@ -1634,32 +1638,36 @@ void PlayerControlPreview::DrawDualBody(QPainter& p, const QPointF center) {
constexpr float offset = 209.3f;
for (std::size_t point = 0; point < left_joycon_body.size() / 2; ++point) {
- left_joycon[point] = center + QPointF(left_joycon_body[point * 2] * size + offset,
- left_joycon_body[point * 2 + 1] * size - 1);
- right_joycon[point] = center + QPointF(-left_joycon_body[point * 2] * size - offset,
- left_joycon_body[point * 2 + 1] * size - 1);
+ const float body_x = left_joycon_body[point * 2 + 0];
+ const float body_y = left_joycon_body[point * 2 + 1];
+
+ left_joycon[point] = center + QPointF(body_x * size + offset, body_y * size - 1);
+ right_joycon[point] = center + QPointF(-body_x * size - offset, body_y * size - 1);
}
for (std::size_t point = 0; point < left_joycon_slider.size() / 2; ++point) {
- qleft_joycon_slider[point] =
- center + QPointF(left_joycon_slider[point * 2], left_joycon_slider[point * 2 + 1]);
- qright_joycon_slider[point] =
- center + QPointF(-left_joycon_slider[point * 2], left_joycon_slider[point * 2 + 1]);
+ const float slider_x = left_joycon_slider[point * 2 + 0];
+ const float slider_y = left_joycon_slider[point * 2 + 1];
+
+ qleft_joycon_slider[point] = center + QPointF(slider_x, slider_y);
+ qright_joycon_slider[point] = center + QPointF(-slider_x, slider_y);
}
for (std::size_t point = 0; point < left_joycon_topview.size() / 2; ++point) {
+ const float top_view_x = left_joycon_topview[point * 2 + 0];
+ const float top_view_y = left_joycon_topview[point * 2 + 1];
+
qleft_joycon_topview[point] =
- center + QPointF(left_joycon_topview[point * 2] * size2 - 52,
- left_joycon_topview[point * 2 + 1] * size2 - 52);
+ center + QPointF(top_view_x * size2 - 52, top_view_y * size2 - 52);
qright_joycon_topview[point] =
- center + QPointF(-left_joycon_topview[point * 2] * size2 + 52,
- left_joycon_topview[point * 2 + 1] * size2 - 52);
+ center + QPointF(-top_view_x * size2 + 52, top_view_y * size2 - 52);
}
for (std::size_t point = 0; point < left_joycon_slider_topview.size() / 2; ++point) {
+ const float top_view_x = left_joycon_slider_topview[point * 2 + 0];
+ const float top_view_y = left_joycon_slider_topview[point * 2 + 1];
+
qleft_joycon_slider_topview[point] =
- center + QPointF(left_joycon_slider_topview[point * 2] * size2 - 52,
- left_joycon_slider_topview[point * 2 + 1] * size2 - 52);
+ center + QPointF(top_view_x * size2 - 52, top_view_y * size2 - 52);
qright_joycon_slider_topview[point] =
- center + QPointF(-left_joycon_slider_topview[point * 2] * size2 + 52,
- left_joycon_slider_topview[point * 2 + 1] * size2 - 52);
+ center + QPointF(-top_view_x * size2 + 52, top_view_y * size2 - 52);
}
// right joycon body
@@ -1908,18 +1916,19 @@ void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center, bo
std::array<QPointF, pro_body_top.size()> qbody_top;
for (std::size_t point = 0; point < pro_left_trigger.size() / 2; ++point) {
- qleft_trigger[point] =
- center + QPointF(pro_left_trigger[point * 2],
- pro_left_trigger[point * 2 + 1] + (left_pressed ? 2 : 0));
- qright_trigger[point] =
- center + QPointF(-pro_left_trigger[point * 2],
- pro_left_trigger[point * 2 + 1] + (right_pressed ? 2 : 0));
+ const float trigger_x = pro_left_trigger[point * 2 + 0];
+ const float trigger_y = pro_left_trigger[point * 2 + 1];
+
+ qleft_trigger[point] = center + QPointF(trigger_x, trigger_y + (left_pressed ? 2 : 0));
+ qright_trigger[point] = center + QPointF(-trigger_x, trigger_y + (right_pressed ? 2 : 0));
}
for (std::size_t point = 0; point < pro_body_top.size() / 2; ++point) {
- qbody_top[pro_body_top.size() - 1 - point] =
- center + QPointF(-pro_body_top[point * 2], pro_body_top[point * 2 + 1]);
- qbody_top[point] = center + QPointF(pro_body_top[point * 2], pro_body_top[point * 2 + 1]);
+ const float top_x = pro_body_top[point * 2 + 0];
+ const float top_y = pro_body_top[point * 2 + 1];
+
+ qbody_top[pro_body_top.size() - 1 - point] = center + QPointF(-top_x, top_y);
+ qbody_top[point] = center + QPointF(top_x, top_y);
}
// Pro body detail
@@ -1942,12 +1951,11 @@ void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center, boo
std::array<QPointF, left_gc_trigger.size() / 2> qright_trigger;
for (std::size_t point = 0; point < left_gc_trigger.size() / 2; ++point) {
- qleft_trigger[point] =
- center + QPointF(left_gc_trigger[point * 2],
- left_gc_trigger[point * 2 + 1] + (left_pressed ? 10 : 0));
- qright_trigger[point] =
- center + QPointF(-left_gc_trigger[point * 2],
- left_gc_trigger[point * 2 + 1] + (right_pressed ? 10 : 0));
+ const float trigger_x = left_gc_trigger[point * 2 + 0];
+ const float trigger_y = left_gc_trigger[point * 2 + 1];
+
+ qleft_trigger[point] = center + QPointF(trigger_x, trigger_y + (left_pressed ? 10 : 0));
+ qright_trigger[point] = center + QPointF(-trigger_x, trigger_y + (right_pressed ? 10 : 0));
}
// Left trigger
@@ -1976,12 +1984,13 @@ void PlayerControlPreview::DrawHandheldTriggers(QPainter& p, const QPointF cente
std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger;
for (std::size_t point = 0; point < left_joycon_trigger.size() / 2; ++point) {
+ const float left_trigger_x = left_joycon_trigger[point * 2 + 0];
+ const float left_trigger_y = left_joycon_trigger[point * 2 + 1];
+
qleft_trigger[point] =
- center + QPointF(left_joycon_trigger[point * 2],
- left_joycon_trigger[point * 2 + 1] + (left_pressed ? 0.5f : 0));
+ center + QPointF(left_trigger_x, left_trigger_y + (left_pressed ? 0.5f : 0));
qright_trigger[point] =
- center + QPointF(-left_joycon_trigger[point * 2],
- left_joycon_trigger[point * 2 + 1] + (right_pressed ? 0.5f : 0));
+ center + QPointF(-left_trigger_x, left_trigger_y + (right_pressed ? 0.5f : 0));
}
// Left trigger
@@ -2001,12 +2010,14 @@ void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center, b
constexpr float size = 1.62f;
constexpr float offset = 210.6f;
for (std::size_t point = 0; point < left_joycon_trigger.size() / 2; ++point) {
- qleft_trigger[point] =
- center + QPointF(left_joycon_trigger[point * 2] * size + offset,
- left_joycon_trigger[point * 2 + 1] * size + (left_pressed ? 0.5f : 0));
- qright_trigger[point] = center + QPointF(-left_joycon_trigger[point * 2] * size - offset,
- left_joycon_trigger[point * 2 + 1] * size +
- (right_pressed ? 0.5f : 0));
+ const float left_trigger_x = left_joycon_trigger[point * 2 + 0];
+ const float left_trigger_y = left_joycon_trigger[point * 2 + 1];
+
+ qleft_trigger[point] = center + QPointF(left_trigger_x * size + offset,
+ left_trigger_y * size + (left_pressed ? 0.5f : 0));
+ qright_trigger[point] =
+ center + QPointF(-left_trigger_x * size - offset,
+ left_trigger_y * size + (right_pressed ? 0.5f : 0));
}
// Left trigger
@@ -2026,13 +2037,16 @@ void PlayerControlPreview::DrawDualTriggersTopView(QPainter& p, const QPointF ce
constexpr float size = 0.9f;
for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) {
- qleft_trigger[point] = center + QPointF(left_joystick_L_topview[point * 2] * size - 50,
- left_joystick_L_topview[point * 2 + 1] * size - 52);
+ const float top_view_x = left_joystick_L_topview[point * 2 + 0];
+ const float top_view_y = left_joystick_L_topview[point * 2 + 1];
+
+ qleft_trigger[point] = center + QPointF(top_view_x * size - 50, top_view_y * size - 52);
}
for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) {
- qright_trigger[point] =
- center + QPointF(-left_joystick_L_topview[point * 2] * size + 50,
- left_joystick_L_topview[point * 2 + 1] * size - 52);
+ const float top_view_x = left_joystick_L_topview[point * 2 + 0];
+ const float top_view_y = left_joystick_L_topview[point * 2 + 1];
+
+ qright_trigger[point] = center + QPointF(-top_view_x * size + 50, top_view_y * size - 52);
}
p.setPen(colors.outline);
@@ -2276,15 +2290,39 @@ void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF cente
p.drawLine(p2.at(32), p2.at(71));
}
-void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, bool pressed) {
+void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, const QPointF offset,
+ float offset_scalar, bool pressed) {
+ const float radius1 = 24.0f;
+ const float radius2 = 17.0f;
+
+ const QPointF offset_center = center + offset * offset_scalar;
+
+ const auto amplitude = static_cast<float>(
+ 1.0 - std::sqrt((offset.x() * offset.x()) + (offset.y() * offset.y())) * 0.1f);
+
+ const float rotation =
+ ((offset.x() == 0) ? atan(1) * 2 : atan(offset.y() / offset.x())) * (180 / (atan(1) * 4));
+
+ p.save();
+ p.translate(offset_center);
+ p.rotate(rotation);
+
// Outer circle
p.setPen(colors.outline);
p.setBrush(pressed ? colors.highlight : colors.button);
- DrawCircle(p, center, 24.0f);
+ p.drawEllipse(QPointF(0, 0), radius1 * amplitude, radius1);
// Inner circle
p.setBrush(pressed ? colors.highlight2 : colors.button2);
- DrawCircle(p, center, 17.0f);
+
+ const float inner_offset =
+ (radius1 - radius2) * 0.4f * ((offset.x() == 0 && offset.y() < 0) ? -1.0f : 1.0f);
+ const float offset_factor = (1.0f - amplitude) / 0.1f;
+
+ p.drawEllipse(QPointF((offset.x() < 0) ? -inner_offset : inner_offset, 0) * offset_factor,
+ radius2 * amplitude, radius2);
+
+ p.restore();
}
void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, bool pressed) {
@@ -2302,7 +2340,7 @@ void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, boo
}
void PlayerControlPreview::DrawRawJoystick(QPainter& p, const QPointF center, const QPointF value,
- const Input::AnalogProperties properties) {
+ const Input::AnalogProperties& properties) {
constexpr float size = 45.0f;
const float range = size * properties.range;
const float deadzone = size * properties.deadzone;
@@ -2425,17 +2463,16 @@ void PlayerControlPreview::DrawArrowButtonOutline(QPainter& p, const QPointF cen
std::array<QPointF, (arrow_points - 1) * 4> arrow_button_outline;
for (std::size_t point = 0; point < arrow_points - 1; ++point) {
- arrow_button_outline[point] = center + QPointF(up_arrow_button[point * 2] * size,
- up_arrow_button[point * 2 + 1] * size);
+ const float up_arrow_x = up_arrow_button[point * 2 + 0];
+ const float up_arrow_y = up_arrow_button[point * 2 + 1];
+
+ arrow_button_outline[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size);
arrow_button_outline[(arrow_points - 1) * 2 - point - 1] =
- center +
- QPointF(up_arrow_button[point * 2 + 1] * size, up_arrow_button[point * 2] * size);
+ center + QPointF(up_arrow_y * size, up_arrow_x * size);
arrow_button_outline[(arrow_points - 1) * 2 + point] =
- center +
- QPointF(-up_arrow_button[point * 2] * size, -up_arrow_button[point * 2 + 1] * size);
+ center + QPointF(-up_arrow_x * size, -up_arrow_y * size);
arrow_button_outline[(arrow_points - 1) * 4 - point - 1] =
- center +
- QPointF(-up_arrow_button[point * 2 + 1] * size, -up_arrow_button[point * 2] * size);
+ center + QPointF(-up_arrow_y * size, -up_arrow_x * size);
}
// Draw arrow button outline
p.setPen(colors.outline);
@@ -2449,22 +2486,21 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
QPoint offset;
for (std::size_t point = 0; point < up_arrow_button.size() / 2; ++point) {
+ const float up_arrow_x = up_arrow_button[point * 2 + 0];
+ const float up_arrow_y = up_arrow_button[point * 2 + 1];
+
switch (direction) {
case Direction::Up:
- arrow_button[point] = center + QPointF(up_arrow_button[point * 2] * size,
- up_arrow_button[point * 2 + 1] * size);
+ arrow_button[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size);
break;
case Direction::Left:
- arrow_button[point] = center + QPointF(up_arrow_button[point * 2 + 1] * size,
- up_arrow_button[point * 2] * size);
+ arrow_button[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size);
break;
case Direction::Right:
- arrow_button[point] = center + QPointF(-up_arrow_button[point * 2 + 1] * size,
- up_arrow_button[point * 2] * size);
+ arrow_button[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size);
break;
case Direction::Down:
- arrow_button[point] = center + QPointF(up_arrow_button[point * 2] * size,
- -up_arrow_button[point * 2 + 1] * size);
+ arrow_button[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size);
break;
case Direction::None:
break;
@@ -2503,17 +2539,17 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center,
const Direction direction, bool pressed) {
std::array<QPointF, trigger_button.size() / 2> qtrigger_button;
- QPoint offset;
for (std::size_t point = 0; point < trigger_button.size() / 2; ++point) {
+ const float trigger_button_x = trigger_button[point * 2 + 0];
+ const float trigger_button_y = trigger_button[point * 2 + 1];
+
switch (direction) {
case Direction::Left:
- qtrigger_button[point] =
- center + QPointF(-trigger_button[point * 2], trigger_button[point * 2 + 1]);
+ qtrigger_button[point] = center + QPointF(-trigger_button_x, trigger_button_y);
break;
case Direction::Right:
- qtrigger_button[point] =
- center + QPointF(trigger_button[point * 2], trigger_button[point * 2 + 1]);
+ qtrigger_button[point] = center + QPointF(trigger_button_x, trigger_button_y);
break;
case Direction::Up:
case Direction::Down:
@@ -2636,22 +2672,21 @@ void PlayerControlPreview::DrawArrow(QPainter& p, const QPointF center, const Di
std::array<QPointF, up_arrow_symbol.size() / 2> arrow_symbol;
for (std::size_t point = 0; point < up_arrow_symbol.size() / 2; ++point) {
+ const float up_arrow_x = up_arrow_symbol[point * 2 + 0];
+ const float up_arrow_y = up_arrow_symbol[point * 2 + 1];
+
switch (direction) {
case Direction::Up:
- arrow_symbol[point] = center + QPointF(up_arrow_symbol[point * 2] * size,
- up_arrow_symbol[point * 2 + 1] * size);
+ arrow_symbol[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size);
break;
case Direction::Left:
- arrow_symbol[point] = center + QPointF(up_arrow_symbol[point * 2 + 1] * size,
- up_arrow_symbol[point * 2] * size);
+ arrow_symbol[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size);
break;
case Direction::Right:
- arrow_symbol[point] = center + QPointF(-up_arrow_symbol[point * 2 + 1] * size,
- up_arrow_symbol[point * 2] * size);
+ arrow_symbol[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size);
break;
case Direction::Down:
- arrow_symbol[point] = center + QPointF(up_arrow_symbol[point * 2] * size,
- -up_arrow_symbol[point * 2 + 1] * size);
+ arrow_symbol[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size);
break;
case Direction::None:
break;