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.cpp136
1 files changed, 119 insertions, 17 deletions
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 11390fec0..a188eef92 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -81,7 +81,6 @@ void PlayerControlPreview::UpdateColors() {
colors.outline = QColor(0, 0, 0);
colors.primary = QColor(225, 225, 225);
colors.button = QColor(109, 111, 114);
- colors.button2 = QColor(109, 111, 114);
colors.button2 = QColor(77, 80, 84);
colors.slider_arrow = QColor(65, 68, 73);
colors.font2 = QColor(0, 0, 0);
@@ -100,12 +99,17 @@ void PlayerControlPreview::UpdateColors() {
colors.led_off = QColor(170, 238, 255);
colors.indicator2 = QColor(59, 165, 93);
colors.charging = QColor(250, 168, 26);
+ colors.button_turbo = QColor(217, 158, 4);
colors.left = colors.primary;
colors.right = colors.primary;
- // Possible alternative to set colors from settings
- // colors.left = QColor(controller->GetColors().left.body);
- // colors.right = QColor(controller->GetColors().right.body);
+
+ const auto color_left = controller->GetColorsValues()[0].body;
+ const auto color_right = controller->GetColorsValues()[1].body;
+ if (color_left != 0 && color_right != 0) {
+ colors.left = QColor(color_left);
+ colors.right = QColor(color_right);
+ }
}
void PlayerControlPreview::ResetInputs() {
@@ -176,6 +180,10 @@ void PlayerControlPreview::ControllerUpdate(Core::HID::ControllerTriggerType typ
battery_values = controller->GetBatteryValues();
needs_redraw = true;
break;
+ case Core::HID::ControllerTriggerType::Motion:
+ motion_values = controller->GetMotions();
+ needs_redraw = true;
+ break;
default:
break;
}
@@ -309,6 +317,15 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center)
DrawRawJoystick(p, center + QPointF(-140, 90), QPointF(0, 0));
}
+ {
+ // Draw motion cubes
+ using namespace Settings::NativeMotion;
+ p.setPen(colors.outline);
+ p.setBrush(colors.transparent);
+ Draw3dCube(p, center + QPointF(-140, 90),
+ motion_values[Settings::NativeMotion::MotionLeft].euler, 20.0f);
+ }
+
using namespace Settings::NativeButton;
// D-pad constants
@@ -431,6 +448,15 @@ void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center
DrawRawJoystick(p, QPointF(0, 0), center + QPointF(140, 90));
}
+ {
+ // Draw motion cubes
+ using namespace Settings::NativeMotion;
+ p.setPen(colors.outline);
+ p.setBrush(colors.transparent);
+ Draw3dCube(p, center + QPointF(140, 90),
+ motion_values[Settings::NativeMotion::MotionRight].euler, 20.0f);
+ }
+
using namespace Settings::NativeButton;
// Face buttons constants
@@ -551,6 +577,17 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center)
DrawRawJoystick(p, center + QPointF(-180, 90), center + QPointF(180, 90));
}
+ {
+ // Draw motion cubes
+ using namespace Settings::NativeMotion;
+ p.setPen(colors.outline);
+ p.setBrush(colors.transparent);
+ Draw3dCube(p, center + QPointF(-180, 90),
+ motion_values[Settings::NativeMotion::MotionLeft].euler, 20.0f);
+ Draw3dCube(p, center + QPointF(180, 90),
+ motion_values[Settings::NativeMotion::MotionRight].euler, 20.0f);
+ }
+
using namespace Settings::NativeButton;
// Face buttons constants
@@ -643,6 +680,15 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen
DrawRawJoystick(p, center + QPointF(-50, 0), center + QPointF(50, 0));
}
+ {
+ // Draw motion cubes
+ using namespace Settings::NativeMotion;
+ p.setPen(colors.outline);
+ p.setBrush(colors.transparent);
+ Draw3dCube(p, center + QPointF(0, -115),
+ motion_values[Settings::NativeMotion::MotionLeft].euler, 15.0f);
+ }
+
using namespace Settings::NativeButton;
// Face buttons constants
@@ -746,6 +792,15 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
DrawRawJoystick(p, center + QPointF(-50, 105), center + QPointF(50, 105));
}
+ {
+ // Draw motion cubes
+ using namespace Settings::NativeMotion;
+ p.setPen(colors.button);
+ p.setBrush(colors.transparent);
+ Draw3dCube(p, center + QPointF(0, -100),
+ motion_values[Settings::NativeMotion::MotionLeft].euler, 15.0f);
+ }
+
using namespace Settings::NativeButton;
// Face buttons constants
@@ -2465,7 +2520,6 @@ void PlayerControlPreview::DrawJoystickDot(QPainter& p, const QPointF center,
void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center,
const Common::Input::ButtonStatus& pressed, float width,
float height, Direction direction, float radius) {
- p.setBrush(button_color);
if (pressed.value) {
switch (direction) {
case Direction::Left:
@@ -2483,16 +2537,16 @@ void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center,
case Direction::None:
break;
}
- p.setBrush(colors.highlight);
}
QRectF rect = {center.x() - width, center.y() - height, width * 2.0f, height * 2.0f};
+ p.setBrush(GetButtonColor(button_color, pressed.value, pressed.turbo));
p.drawRoundedRect(rect, radius, radius);
}
void PlayerControlPreview::DrawMinusButton(QPainter& p, const QPointF center,
const Common::Input::ButtonStatus& pressed,
int button_size) {
p.setPen(colors.outline);
- p.setBrush(pressed.value ? colors.highlight : colors.button);
+ p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo));
DrawRectangle(p, center, button_size, button_size / 3.0f);
}
void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center,
@@ -2500,7 +2554,7 @@ void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center,
int button_size) {
// Draw outer line
p.setPen(colors.outline);
- p.setBrush(pressed.value ? colors.highlight : colors.button);
+ p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo));
DrawRectangle(p, center, button_size, button_size / 3.0f);
DrawRectangle(p, center, button_size / 3.0f, button_size);
@@ -2522,7 +2576,7 @@ void PlayerControlPreview::DrawGCButtonX(QPainter& p, const QPointF center,
}
p.setPen(colors.outline);
- p.setBrush(pressed.value ? colors.highlight : colors.button);
+ p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo));
DrawPolygon(p, button_x);
}
@@ -2535,7 +2589,7 @@ void PlayerControlPreview::DrawGCButtonY(QPainter& p, const QPointF center,
}
p.setPen(colors.outline);
- p.setBrush(pressed.value ? colors.highlight : colors.button);
+ p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo));
DrawPolygon(p, button_x);
}
@@ -2549,17 +2603,15 @@ void PlayerControlPreview::DrawGCButtonZ(QPainter& p, const QPointF center,
}
p.setPen(colors.outline);
- p.setBrush(pressed.value ? colors.highlight : colors.button2);
+ p.setBrush(GetButtonColor(colors.button2, pressed.value, pressed.turbo));
DrawPolygon(p, button_x);
}
void PlayerControlPreview::DrawCircleButton(QPainter& p, const QPointF center,
const Common::Input::ButtonStatus& pressed,
float button_size) {
- p.setBrush(button_color);
- if (pressed.value) {
- p.setBrush(colors.highlight);
- }
+
+ p.setBrush(GetButtonColor(button_color, pressed.value, pressed.turbo));
p.drawEllipse(center, button_size, button_size);
}
@@ -2616,7 +2668,7 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
// Draw arrow button
p.setPen(pressed.value ? colors.highlight : colors.button);
- p.setBrush(pressed.value ? colors.highlight : colors.button);
+ p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo));
DrawPolygon(p, arrow_button);
switch (direction) {
@@ -2668,10 +2720,20 @@ void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center,
// Draw arrow button
p.setPen(colors.outline);
- p.setBrush(pressed.value ? colors.highlight : colors.button);
+ p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo));
DrawPolygon(p, qtrigger_button);
}
+QColor PlayerControlPreview::GetButtonColor(QColor default_color, bool is_pressed, bool turbo) {
+ if (is_pressed && turbo) {
+ return colors.button_turbo;
+ }
+ if (is_pressed) {
+ return colors.highlight;
+ }
+ return default_color;
+}
+
void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center,
Common::Input::BatteryLevel battery) {
if (battery == Common::Input::BatteryLevel::None) {
@@ -2860,6 +2922,46 @@ void PlayerControlPreview::DrawArrow(QPainter& p, const QPointF center, const Di
DrawPolygon(p, arrow_symbol);
}
+// Draw motion functions
+void PlayerControlPreview::Draw3dCube(QPainter& p, QPointF center, const Common::Vec3f& euler,
+ float size) {
+ std::array<Common::Vec3f, 8> cube{
+ Common::Vec3f{-0.7f, -1, -0.5f},
+ {-0.7f, 1, -0.5f},
+ {0.7f, 1, -0.5f},
+ {0.7f, -1, -0.5f},
+ {-0.7f, -1, 0.5f},
+ {-0.7f, 1, 0.5f},
+ {0.7f, 1, 0.5f},
+ {0.7f, -1, 0.5f},
+ };
+
+ for (Common::Vec3f& point : cube) {
+ point.RotateFromOrigin(euler.x, euler.y, euler.z);
+ point *= size;
+ }
+
+ const std::array<QPointF, 4> front_face{
+ center + QPointF{cube[0].x, cube[0].y},
+ center + QPointF{cube[1].x, cube[1].y},
+ center + QPointF{cube[2].x, cube[2].y},
+ center + QPointF{cube[3].x, cube[3].y},
+ };
+ const std::array<QPointF, 4> back_face{
+ center + QPointF{cube[4].x, cube[4].y},
+ center + QPointF{cube[5].x, cube[5].y},
+ center + QPointF{cube[6].x, cube[6].y},
+ center + QPointF{cube[7].x, cube[7].y},
+ };
+
+ DrawPolygon(p, front_face);
+ DrawPolygon(p, back_face);
+ p.drawLine(center + QPointF{cube[0].x, cube[0].y}, center + QPointF{cube[4].x, cube[4].y});
+ p.drawLine(center + QPointF{cube[1].x, cube[1].y}, center + QPointF{cube[5].x, cube[5].y});
+ p.drawLine(center + QPointF{cube[2].x, cube[2].y}, center + QPointF{cube[6].x, cube[6].y});
+ p.drawLine(center + QPointF{cube[3].x, cube[3].y}, center + QPointF{cube[7].x, cube[7].y});
+}
+
template <size_t N>
void PlayerControlPreview::DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon) {
p.drawPolygon(polygon.data(), static_cast<int>(polygon.size()));