diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/configure_input_player_widget.cpp | 34 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player_widget.h | 2 |
2 files changed, 30 insertions, 6 deletions
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp index e3e8bde48..e77ccc057 100644 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ b/src/yuzu/configuration/configure_input_player_widget.cpp | |||
| @@ -699,9 +699,9 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) | |||
| 699 | { | 699 | { |
| 700 | // Draw joysticks | 700 | // Draw joysticks |
| 701 | using namespace Settings::NativeAnalog; | 701 | using namespace Settings::NativeAnalog; |
| 702 | DrawProJoystick(p, center + QPointF(-111, -55) + (axis_values[LStick].value * 11), | 702 | DrawProJoystick(p, center + QPointF(-111, -55), axis_values[LStick].value, 11, |
| 703 | button_values[Settings::NativeButton::LStick]); | 703 | button_values[Settings::NativeButton::LStick]); |
| 704 | DrawProJoystick(p, center + QPointF(51, 0) + (axis_values[RStick].value * 11), | 704 | DrawProJoystick(p, center + QPointF(51, 0), axis_values[RStick].value, 11, |
| 705 | button_values[Settings::NativeButton::RStick]); | 705 | button_values[Settings::NativeButton::RStick]); |
| 706 | DrawRawJoystick(p, center + QPointF(-50, 105), axis_values[LStick].raw_value, | 706 | DrawRawJoystick(p, center + QPointF(-50, 105), axis_values[LStick].raw_value, |
| 707 | axis_values[LStick].properties); | 707 | axis_values[LStick].properties); |
| @@ -2273,15 +2273,39 @@ void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF cente | |||
| 2273 | p.drawLine(p2.at(32), p2.at(71)); | 2273 | p.drawLine(p2.at(32), p2.at(71)); |
| 2274 | } | 2274 | } |
| 2275 | 2275 | ||
| 2276 | void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, bool pressed) { | 2276 | void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, const QPointF offset, |
| 2277 | float offset_scalar, bool pressed) { | ||
| 2278 | const float radius1 = 24.0f; | ||
| 2279 | const float radius2 = 17.0f; | ||
| 2280 | |||
| 2281 | const QPointF offset_center = center + offset * offset_scalar; | ||
| 2282 | |||
| 2283 | const auto amplitude = static_cast<float>( | ||
| 2284 | 1.0 - std::sqrt((offset.x() * offset.x()) + (offset.y() * offset.y())) * 0.1f); | ||
| 2285 | |||
| 2286 | const float rotation = | ||
| 2287 | ((offset.x() == 0) ? atan(1) * 2 : atan(offset.y() / offset.x())) * (180 / (atan(1) * 4)); | ||
| 2288 | |||
| 2289 | p.save(); | ||
| 2290 | p.translate(offset_center); | ||
| 2291 | p.rotate(rotation); | ||
| 2292 | |||
| 2277 | // Outer circle | 2293 | // Outer circle |
| 2278 | p.setPen(colors.outline); | 2294 | p.setPen(colors.outline); |
| 2279 | p.setBrush(pressed ? colors.highlight : colors.button); | 2295 | p.setBrush(pressed ? colors.highlight : colors.button); |
| 2280 | DrawCircle(p, center, 24.0f); | 2296 | p.drawEllipse(QPointF(0, 0), radius1 * amplitude, radius1); |
| 2281 | 2297 | ||
| 2282 | // Inner circle | 2298 | // Inner circle |
| 2283 | p.setBrush(pressed ? colors.highlight2 : colors.button2); | 2299 | p.setBrush(pressed ? colors.highlight2 : colors.button2); |
| 2284 | DrawCircle(p, center, 17.0f); | 2300 | |
| 2301 | const float inner_offset = | ||
| 2302 | (radius1 - radius2) * 0.4f * ((offset.x() == 0 && offset.y() < 0) ? -1.0f : 1.0f); | ||
| 2303 | const float offset_factor = (1.0f - amplitude) / 0.1f; | ||
| 2304 | |||
| 2305 | p.drawEllipse(QPointF((offset.x() < 0) ? -inner_offset : inner_offset, 0) * offset_factor, | ||
| 2306 | radius2 * amplitude, radius2); | ||
| 2307 | |||
| 2308 | p.restore(); | ||
| 2285 | } | 2309 | } |
| 2286 | 2310 | ||
| 2287 | void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, bool pressed) { | 2311 | void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, bool pressed) { |
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h index 39565f795..676effbfd 100644 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ b/src/yuzu/configuration/configure_input_player_widget.h | |||
| @@ -140,7 +140,7 @@ private: | |||
| 140 | void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, bool pressed); | 140 | void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, bool pressed); |
| 141 | void DrawRawJoystick(QPainter& p, QPointF center, const QPointF value, | 141 | void DrawRawJoystick(QPainter& p, QPointF center, const QPointF value, |
| 142 | const Input::AnalogProperties properties); | 142 | const Input::AnalogProperties properties); |
| 143 | void DrawProJoystick(QPainter& p, QPointF center, bool pressed); | 143 | void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, bool pressed); |
| 144 | void DrawGCJoystick(QPainter& p, QPointF center, bool pressed); | 144 | void DrawGCJoystick(QPainter& p, QPointF center, bool pressed); |
| 145 | 145 | ||
| 146 | // Draw button functions | 146 | // Draw button functions |