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