|
|
|
@ -7,9 +7,10 @@ |
|
|
|
#include <array> |
|
|
|
#include <QFrame> |
|
|
|
#include <QPointer> |
|
|
|
#include "common/input.h" |
|
|
|
#include "common/settings.h" |
|
|
|
#include "core/frontend/input.h" |
|
|
|
#include "yuzu/debugger/controller.h" |
|
|
|
#include "core/hid/hid_core.h" |
|
|
|
#include "core/hid/hid_types.h" |
|
|
|
|
|
|
|
class QLabel; |
|
|
|
|
|
|
|
@ -24,17 +25,12 @@ public: |
|
|
|
explicit PlayerControlPreview(QWidget* parent); |
|
|
|
~PlayerControlPreview() override; |
|
|
|
|
|
|
|
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 SetController(Core::HID::EmulatedController* controller); |
|
|
|
void BeginMappingButton(std::size_t button_id); |
|
|
|
void BeginMappingAnalog(std::size_t button_id); |
|
|
|
void EndMapping(); |
|
|
|
void ControllerUpdate(Core::HID::ControllerTriggerType type); |
|
|
|
void UpdateInput(); |
|
|
|
void SetCallBack(ControllerCallback callback_); |
|
|
|
|
|
|
|
protected: |
|
|
|
void paintEvent(QPaintEvent* event) override; |
|
|
|
@ -63,15 +59,6 @@ private: |
|
|
|
SR, |
|
|
|
}; |
|
|
|
|
|
|
|
struct AxisValue { |
|
|
|
QPointF value{}; |
|
|
|
QPointF raw_value{}; |
|
|
|
Input::AnalogProperties properties{}; |
|
|
|
int size{}; |
|
|
|
QPoint offset{}; |
|
|
|
bool active{}; |
|
|
|
}; |
|
|
|
|
|
|
|
struct LedPattern { |
|
|
|
bool position1; |
|
|
|
bool position2; |
|
|
|
@ -122,47 +109,66 @@ private: |
|
|
|
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, |
|
|
|
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); |
|
|
|
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); |
|
|
|
void DrawProTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed, |
|
|
|
const Input::ButtonStatus& right_pressed); |
|
|
|
void DrawGCTriggers(QPainter& p, QPointF center, Input::TriggerStatus left_trigger, |
|
|
|
Input::TriggerStatus right_trigger); |
|
|
|
void DrawHandheldTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed, |
|
|
|
const Input::ButtonStatus& right_pressed); |
|
|
|
void DrawDualTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed, |
|
|
|
const Input::ButtonStatus& right_pressed); |
|
|
|
void DrawDualTriggersTopView(QPainter& p, QPointF center, |
|
|
|
const Input::ButtonStatus& left_pressed, |
|
|
|
const Input::ButtonStatus& right_pressed); |
|
|
|
void DrawDualZTriggersTopView(QPainter& p, QPointF center, |
|
|
|
const Input::ButtonStatus& left_pressed, |
|
|
|
const Input::ButtonStatus& right_pressed); |
|
|
|
void DrawLeftTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed); |
|
|
|
void DrawLeftZTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed); |
|
|
|
void DrawLeftTriggersTopView(QPainter& p, QPointF center, |
|
|
|
const Input::ButtonStatus& left_pressed); |
|
|
|
void DrawLeftZTriggersTopView(QPainter& p, QPointF center, |
|
|
|
const Input::ButtonStatus& left_pressed); |
|
|
|
void DrawRightTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& right_pressed); |
|
|
|
void DrawRightZTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& right_pressed); |
|
|
|
void DrawRightTriggersTopView(QPainter& p, QPointF center, |
|
|
|
const Input::ButtonStatus& right_pressed); |
|
|
|
void DrawRightZTriggersTopView(QPainter& p, QPointF center, |
|
|
|
const Input::ButtonStatus& 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 DrawJoystick(QPainter& p, QPointF center, float size, const Input::ButtonStatus& pressed); |
|
|
|
void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, |
|
|
|
const Input::ButtonStatus& pressed); |
|
|
|
void DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right); |
|
|
|
void DrawJoystickProperties(QPainter& p, QPointF center, |
|
|
|
const Input::AnalogProperties& properties); |
|
|
|
void DrawJoystickDot(QPainter& p, QPointF center, QPointF value, |
|
|
|
const Input::AnalogProperties& properties); |
|
|
|
void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, bool pressed); |
|
|
|
void DrawGCJoystick(QPainter& p, QPointF center, bool pressed); |
|
|
|
void DrawJoystickDot(QPainter& p, QPointF center, const Input::StickStatus& stick, bool raw); |
|
|
|
void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, |
|
|
|
const Input::ButtonStatus& pressed); |
|
|
|
void DrawGCJoystick(QPainter& p, QPointF center, const Input::ButtonStatus& pressed); |
|
|
|
|
|
|
|
// Draw button functions |
|
|
|
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); |
|
|
|
void DrawPlusButton(QPainter& p, QPointF center, bool pressed, int button_size); |
|
|
|
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 DrawCircleButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed, |
|
|
|
float button_size); |
|
|
|
void DrawRoundButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed, |
|
|
|
float width, float height, Direction direction = Direction::None, |
|
|
|
float radius = 2); |
|
|
|
void DrawMinusButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed, |
|
|
|
int button_size); |
|
|
|
void DrawPlusButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed, |
|
|
|
int button_size); |
|
|
|
void DrawGCButtonX(QPainter& p, QPointF center, const Input::ButtonStatus& pressed); |
|
|
|
void DrawGCButtonY(QPainter& p, QPointF center, const Input::ButtonStatus& pressed); |
|
|
|
void DrawGCButtonZ(QPainter& p, QPointF center, const Input::ButtonStatus& 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); |
|
|
|
void DrawArrowButton(QPainter& p, QPointF center, Direction direction, |
|
|
|
const Input::ButtonStatus& pressed, float size = 1.0f); |
|
|
|
void DrawTriggerButton(QPainter& p, QPointF center, Direction direction, |
|
|
|
const Input::ButtonStatus& pressed); |
|
|
|
|
|
|
|
// Draw battery functions |
|
|
|
void DrawBattery(QPainter& p, QPointF center, Input::BatteryLevel battery); |
|
|
|
|
|
|
|
// Draw icon functions |
|
|
|
void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size); |
|
|
|
@ -178,24 +184,23 @@ private: |
|
|
|
void SetTextFont(QPainter& p, float text_size, |
|
|
|
const QString& font_family = QStringLiteral("sans-serif")); |
|
|
|
|
|
|
|
using ButtonArray = |
|
|
|
std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::BUTTON_NS_END>; |
|
|
|
using StickArray = |
|
|
|
std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>; |
|
|
|
bool is_controller_set{}; |
|
|
|
bool is_connected{}; |
|
|
|
bool needs_redraw{}; |
|
|
|
Core::HID::NpadType controller_type; |
|
|
|
|
|
|
|
ControllerCallback controller_callback; |
|
|
|
bool is_enabled{}; |
|
|
|
bool mapping_active{}; |
|
|
|
int blink_counter{}; |
|
|
|
int callback_key; |
|
|
|
QColor button_color{}; |
|
|
|
ColorMapping colors{}; |
|
|
|
std::array<QColor, 4> 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<AxisValue, Settings::NativeAnalog::NUM_STICKS_HID> axis_values{}; |
|
|
|
std::array<bool, Settings::NativeButton::NumButtons> button_values{}; |
|
|
|
Settings::ControllerType controller_type{Settings::ControllerType::ProController}; |
|
|
|
Core::HID::EmulatedController* controller; |
|
|
|
std::size_t button_mapping_index{Settings::NativeButton::NumButtons}; |
|
|
|
std::size_t analog_mapping_index{Settings::NativeAnalog::NumAnalogs}; |
|
|
|
Core::HID::ButtonValues button_values{}; |
|
|
|
Core::HID::SticksValues stick_values{}; |
|
|
|
Core::HID::TriggerValues trigger_values{}; |
|
|
|
Core::HID::BatteryValues battery_values{}; |
|
|
|
}; |