From 481cd86722f7070b6a63f2b95c1e8bceb518eee7 Mon Sep 17 00:00:00 2001 From: german Date: Tue, 12 Jan 2021 21:09:59 -0600 Subject: Make settings controller image change with controller input --- .../configuration/configure_input_player_widget.h | 157 +++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 src/yuzu/configuration/configure_input_player_widget.h (limited to 'src/yuzu/configuration/configure_input_player_widget.h') diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h new file mode 100644 index 000000000..4122e3abd --- /dev/null +++ b/src/yuzu/configuration/configure_input_player_widget.h @@ -0,0 +1,157 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include +#include "core/frontend/input.h" +#include "core/settings.h" + +class QLabel; + +using AnalogParam = std::array; +using ButtonParam = std::array; + +// Widget for representing controller animations +class PlayerControlPreview : public QFrame { + Q_OBJECT + +public: + explicit PlayerControlPreview(QWidget* parent); + ~PlayerControlPreview() override; + + void SetPlayerInput(std::size_t index, const ButtonParam& buttons_param, + const AnalogParam& analogs_param); + void SetConnectedStatus(bool checked); + void SetControllerType(Settings::ControllerType type); + void BeginMappingButton(std::size_t button_id); + void BeginMappingAnalog(std::size_t button_id); + void EndMapping(); + +protected: + void paintEvent(QPaintEvent* event) override; + +private: + enum class Direction : std::size_t { + None, + Up, + Right, + Down, + Left, + }; + + struct AxisValue { + QPointF value{}; + QPointF raw_value{}; + Input::AnalogProperties properties{}; + int size{}; + QPoint offset{}; + bool active{}; + }; + + struct LedPattern { + bool position1; + bool position2; + bool position3; + bool position4; + }; + + struct ColorMapping { + QColor outline{}; + QColor primary{}; + QColor left{}; + QColor right{}; + QColor button{}; + QColor button2{}; + QColor font{}; + QColor font2{}; + QColor highlight{}; + QColor highlight2{}; + QColor transparent{}; + QColor indicator{}; + QColor led_on{}; + QColor led_off{}; + QColor slider{}; + QColor slider_button{}; + QColor slider_arrow{}; + QColor deadzone{}; + }; + + static LedPattern GetColorPattern(std::size_t index, bool player_on); + void UpdateColors(); + + // Draw controller functions + void DrawHandheldController(QPainter& p, QPointF center); + void DrawDualController(QPainter& p, QPointF center); + void DrawLeftController(QPainter& p, QPointF center); + void DrawRightController(QPainter& p, QPointF center); + void DrawProController(QPainter& p, QPointF center); + + // Draw body functions + void DrawHandheldBody(QPainter& p, QPointF center); + void DrawDualBody(QPainter& p, QPointF center); + void DrawLeftBody(QPainter& p, QPointF center); + void DrawRightBody(QPainter& p, QPointF center); + void DrawProBody(QPainter& p, QPointF center); + + // Draw triggers functions + void DrawProTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); + void DrawHandheldTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); + void DrawDualTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); + void DrawDualZTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); + void DrawLeftTriggers(QPainter& p, QPointF center, bool left_pressed); + void DrawLeftZTriggers(QPainter& p, QPointF center, bool left_pressed); + void DrawRightTriggers(QPainter& p, QPointF center, bool right_pressed); + void DrawRightZTriggers(QPainter& p, QPointF center, bool right_pressed); + + // Draw joystick functions + void DrawJoystick(QPainter& p, QPointF center, float size, bool pressed); + void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, bool pressed); + void DrawRawJoystick(QPainter& p, QPointF center, const QPointF value, + const Input::AnalogProperties properties); + void DrawProJoystick(QPainter& p, QPointF center, bool pressed); + + // Draw button functions + void DrawCircleButton(QPainter& p, QPointF center, bool pressed, int button_size); + void DrawRoundButton(QPainter& p, QPointF center, bool pressed, float width, float height, + Direction direction = Direction::None, float radius = 2); + void DrawMinusButton(QPainter& p, QPointF center, bool pressed, int button_size); + void DrawPlusButton(QPainter& p, QPointF center, bool pressed, int button_size); + void DrawArrowButton(QPainter& p, QPointF center, Direction direction, bool pressed); + + // Draw icon functions + void DrawHouseIcon(QPainter& p, QPointF center, float icon_size); + void DrawArrow(QPainter& p, QPointF center, Direction direction, float size); + + // Draw primitive types + template + void DrawPolygon(QPainter& p, const std::array& polygon); + void DrawCircle(QPainter& p, QPointF center, float size); + void DrawRectangle(QPainter& p, QPointF center, float width, float height); + void DrawRoundRectangle(QPainter& p, QPointF center, float width, float height, float round); + void DrawText(QPainter& p, QPointF center, float text_size, const QString& text); + void SetTextFont(QPainter& p, float text_size, + const QString& font_family = QStringLiteral("sans-serif")); + + using ButtonArray = + std::array, Settings::NativeButton::BUTTON_NS_END>; + using StickArray = + std::array, Settings::NativeAnalog::NUM_STICKS_HID>; + + bool mapping_active{}; + int blink_counter{}; + QColor button_color{}; + ColorMapping colors{}; + std::array led_color{}; + ButtonArray buttons{}; + StickArray sticks{}; + std::size_t player_index{}; + std::size_t button_mapping_index{Settings::NativeButton::BUTTON_NS_END}; + std::size_t analog_mapping_index{Settings::NativeAnalog::NUM_STICKS_HID}; + std::array axis_values{}; + std::array button_values{}; + Settings::ControllerType controller_type{Settings::ControllerType::ProController}; +}; -- cgit v1.2.3 From ea1f656d7e4a529f009845e318d88cef6549b144 Mon Sep 17 00:00:00 2001 From: german Date: Fri, 15 Jan 2021 11:18:17 -0600 Subject: Replace text with vectors --- src/yuzu/configuration/configure_input_player_widget.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/yuzu/configuration/configure_input_player_widget.h') diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h index 4122e3abd..785d37924 100644 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ b/src/yuzu/configuration/configure_input_player_widget.h @@ -43,6 +43,16 @@ private: Left, }; + enum class Symbol { + House, + A, + B, + X, + Y, + ZL, + ZR, + }; + struct AxisValue { QPointF value{}; QPointF raw_value{}; @@ -120,10 +130,12 @@ private: Direction direction = Direction::None, float radius = 2); void DrawMinusButton(QPainter& p, QPointF center, bool pressed, int button_size); void DrawPlusButton(QPainter& p, QPointF center, bool pressed, int button_size); + void DrawArrowButtonOutline(QPainter& p, const QPointF center); void DrawArrowButton(QPainter& p, QPointF center, Direction direction, bool pressed); + void DrawTriggerButton(QPainter& p, QPointF center, Direction direction, bool pressed); // Draw icon functions - void DrawHouseIcon(QPainter& p, QPointF center, float icon_size); + void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size); void DrawArrow(QPainter& p, QPointF center, Direction direction, float size); // Draw primitive types -- cgit v1.2.3 From a7f9983563f76d1bca071be7490c2abf57ce16d5 Mon Sep 17 00:00:00 2001 From: german Date: Thu, 21 Jan 2021 18:51:24 -0600 Subject: Add controller window and single joycon top view --- src/yuzu/configuration/configure_input_player_widget.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/yuzu/configuration/configure_input_player_widget.h') diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h index 785d37924..ba5e49da3 100644 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ b/src/yuzu/configuration/configure_input_player_widget.h @@ -25,6 +25,8 @@ public: void SetPlayerInput(std::size_t index, const ButtonParam& buttons_param, const AnalogParam& analogs_param); + void SetPlayerInputRaw(std::size_t index, const Settings::ButtonsRaw buttons_, + Settings::AnalogsRaw analogs_); void SetConnectedStatus(bool checked); void SetControllerType(Settings::ControllerType type); void BeginMappingButton(std::size_t button_id); @@ -114,8 +116,12 @@ private: void DrawDualZTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); void DrawLeftTriggers(QPainter& p, QPointF center, bool left_pressed); void DrawLeftZTriggers(QPainter& p, QPointF center, bool left_pressed); + void DrawLeftTriggersTopView(QPainter& p, QPointF center, bool left_pressed); + void DrawLeftZTriggersTopView(QPainter& p, QPointF center, bool left_pressed); void DrawRightTriggers(QPainter& p, QPointF center, bool right_pressed); void DrawRightZTriggers(QPainter& p, QPointF center, bool right_pressed); + void DrawRightTriggersTopView(QPainter& p, QPointF center, bool right_pressed); + void DrawRightZTriggersTopView(QPainter& p, QPointF center, bool right_pressed); // Draw joystick functions void DrawJoystick(QPainter& p, QPointF center, float size, bool pressed); @@ -125,7 +131,7 @@ private: void DrawProJoystick(QPainter& p, QPointF center, bool pressed); // Draw button functions - void DrawCircleButton(QPainter& p, QPointF center, bool pressed, int button_size); + void DrawCircleButton(QPainter& p, QPointF center, bool pressed, float button_size); void DrawRoundButton(QPainter& p, QPointF center, bool pressed, float width, float height, Direction direction = Direction::None, float radius = 2); void DrawMinusButton(QPainter& p, QPointF center, bool pressed, int button_size); -- cgit v1.2.3 From c9597af39ded9430cc94c37959fb8154abea8686 Mon Sep 17 00:00:00 2001 From: german Date: Tue, 2 Feb 2021 21:39:47 -0600 Subject: Add SL SR vectors, change dual joycon view, add missing raw data from keyboard/mouse --- src/yuzu/configuration/configure_input_player_widget.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/yuzu/configuration/configure_input_player_widget.h') diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h index ba5e49da3..7d0653faa 100644 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ b/src/yuzu/configuration/configure_input_player_widget.h @@ -51,8 +51,10 @@ private: B, X, Y, + SL, ZL, ZR, + SR, }; struct AxisValue { @@ -113,7 +115,10 @@ private: void DrawProTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); void DrawHandheldTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); void DrawDualTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); - void DrawDualZTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); + void DrawDualTriggersTopView(QPainter& p, QPointF center, bool left_pressed, + bool right_pressed); + void DrawDualZTriggersTopView(QPainter& p, QPointF center, bool left_pressed, + bool right_pressed); void DrawLeftTriggers(QPainter& p, QPointF center, bool left_pressed); void DrawLeftZTriggers(QPainter& p, QPointF center, bool left_pressed); void DrawLeftTriggersTopView(QPainter& p, QPointF center, bool left_pressed); -- cgit v1.2.3 From d6a0975e5d83ccd18543245ac880e0c57f6e0bca Mon Sep 17 00:00:00 2001 From: german Date: Tue, 2 Feb 2021 22:32:45 -0600 Subject: Refresh controller only when necessary --- src/yuzu/configuration/configure_input_player_widget.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/yuzu/configuration/configure_input_player_widget.h') diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h index 7d0653faa..33a5482ba 100644 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ b/src/yuzu/configuration/configure_input_player_widget.h @@ -32,6 +32,7 @@ public: void BeginMappingButton(std::size_t button_id); void BeginMappingAnalog(std::size_t button_id); void EndMapping(); + void UpdateInput(); protected: void paintEvent(QPaintEvent* event) override; -- cgit v1.2.3 From 8893b766c3b582e6d2594e9a544cbf9d6ee689c7 Mon Sep 17 00:00:00 2001 From: german Date: Sat, 6 Feb 2021 21:34:08 -0600 Subject: Add GC controller animation --- src/yuzu/configuration/configure_input_player_widget.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/yuzu/configuration/configure_input_player_widget.h') diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h index 33a5482ba..39565f795 100644 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ b/src/yuzu/configuration/configure_input_player_widget.h @@ -52,6 +52,9 @@ private: B, X, Y, + L, + R, + C, SL, ZL, ZR, @@ -104,6 +107,7 @@ private: void DrawLeftController(QPainter& p, QPointF center); void DrawRightController(QPainter& p, QPointF center); void DrawProController(QPainter& p, QPointF center); + void DrawGCController(QPainter& p, QPointF center); // Draw body functions void DrawHandheldBody(QPainter& p, QPointF center); @@ -111,9 +115,11 @@ private: void DrawLeftBody(QPainter& p, QPointF center); void DrawRightBody(QPainter& p, QPointF center); void DrawProBody(QPainter& p, QPointF center); + void DrawGCBody(QPainter& p, QPointF center); // Draw triggers functions void DrawProTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); + void DrawGCTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); void DrawHandheldTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); void DrawDualTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed); void DrawDualTriggersTopView(QPainter& p, QPointF center, bool left_pressed, @@ -135,6 +141,7 @@ private: void DrawRawJoystick(QPainter& p, QPointF center, const QPointF value, const Input::AnalogProperties properties); void DrawProJoystick(QPainter& p, QPointF center, bool pressed); + void DrawGCJoystick(QPainter& p, QPointF center, bool pressed); // Draw button functions void DrawCircleButton(QPainter& p, QPointF center, bool pressed, float button_size); @@ -142,8 +149,12 @@ private: Direction direction = Direction::None, float radius = 2); void DrawMinusButton(QPainter& p, QPointF center, bool pressed, int button_size); void DrawPlusButton(QPainter& p, QPointF center, bool pressed, int button_size); - void DrawArrowButtonOutline(QPainter& p, const QPointF center); - void DrawArrowButton(QPainter& p, QPointF center, Direction direction, bool pressed); + void DrawGCButtonX(QPainter& p, QPointF center, bool pressed); + void DrawGCButtonY(QPainter& p, QPointF center, bool pressed); + void DrawGCButtonZ(QPainter& p, QPointF center, bool pressed); + void DrawArrowButtonOutline(QPainter& p, const QPointF center, float size = 1.0f); + void DrawArrowButton(QPainter& p, QPointF center, Direction direction, bool pressed, + float size = 1.0f); void DrawTriggerButton(QPainter& p, QPointF center, Direction direction, bool pressed); // Draw icon functions -- cgit v1.2.3