Merge pull request #5339 from german77/interactive
Settings: Make settings controller image change with controller inputnce_cpp
-
21dist/icons/controller/controller.qrc
-
BINdist/icons/controller/dual_joycon.png
-
BINdist/icons/controller/dual_joycon_dark.png
-
BINdist/icons/controller/dual_joycon_midnight.png
-
BINdist/icons/controller/handheld.png
-
BINdist/icons/controller/handheld_dark.png
-
BINdist/icons/controller/handheld_midnight.png
-
BINdist/icons/controller/pro_controller.png
-
BINdist/icons/controller/pro_controller_dark.png
-
BINdist/icons/controller/pro_controller_midnight.png
-
BINdist/icons/controller/single_joycon_left.png
-
BINdist/icons/controller/single_joycon_left_dark.png
-
BINdist/icons/controller/single_joycon_left_midnight.png
-
BINdist/icons/controller/single_joycon_left_vertical.png
-
BINdist/icons/controller/single_joycon_left_vertical_dark.png
-
BINdist/icons/controller/single_joycon_left_vertical_midnight.png
-
BINdist/icons/controller/single_joycon_right.png
-
BINdist/icons/controller/single_joycon_right_dark.png
-
BINdist/icons/controller/single_joycon_right_midnight.png
-
BINdist/icons/controller/single_joycon_right_vertical.png
-
BINdist/icons/controller/single_joycon_right_vertical_dark.png
-
BINdist/icons/controller/single_joycon_right_vertical_midnight.png
-
11src/core/frontend/input.h
-
4src/input_common/analog_from_button.cpp
-
10src/input_common/gcadapter/gc_poller.cpp
-
10src/input_common/mouse/mouse_poller.cpp
-
10src/input_common/sdl/sdl_impl.cpp
-
4src/yuzu/CMakeLists.txt
-
101src/yuzu/configuration/configure_input_player.cpp
-
2src/yuzu/configuration/configure_input_player.h
-
74src/yuzu/configuration/configure_input_player.ui
-
2694src/yuzu/configuration/configure_input_player_widget.cpp
-
192src/yuzu/configuration/configure_input_player_widget.h
-
66src/yuzu/debugger/controller.cpp
-
31src/yuzu/debugger/controller.h
-
7src/yuzu/main.cpp
-
2src/yuzu/main.h
|
Before Width: 400 | Height: 273 | Size: 36 KiB |
|
Before Width: 400 | Height: 273 | Size: 35 KiB |
|
Before Width: 400 | Height: 273 | Size: 34 KiB |
|
Before Width: 400 | Height: 170 | Size: 14 KiB |
|
Before Width: 400 | Height: 170 | Size: 13 KiB |
|
Before Width: 400 | Height: 170 | Size: 13 KiB |
|
Before Width: 400 | Height: 278 | Size: 36 KiB |
|
Before Width: 400 | Height: 278 | Size: 34 KiB |
|
Before Width: 400 | Height: 278 | Size: 35 KiB |
|
Before Width: 400 | Height: 293 | Size: 25 KiB |
|
Before Width: 400 | Height: 293 | Size: 25 KiB |
|
Before Width: 400 | Height: 293 | Size: 24 KiB |
|
Before Width: 400 | Height: 305 | Size: 24 KiB |
|
Before Width: 400 | Height: 305 | Size: 24 KiB |
|
Before Width: 400 | Height: 305 | Size: 23 KiB |
|
Before Width: 400 | Height: 293 | Size: 28 KiB |
|
Before Width: 400 | Height: 293 | Size: 28 KiB |
|
Before Width: 400 | Height: 293 | Size: 26 KiB |
|
Before Width: 400 | Height: 304 | Size: 27 KiB |
|
Before Width: 400 | Height: 304 | Size: 27 KiB |
|
Before Width: 400 | Height: 304 | Size: 26 KiB |
2694
src/yuzu/configuration/configure_input_player_widget.cpp
File diff suppressed because it is too large
View File
@ -0,0 +1,192 @@ |
|||
// Copyright 2020 yuzu Emulator Project |
|||
// Licensed under GPLv2 or any later version |
|||
// Refer to the license.txt file included. |
|||
|
|||
#pragma once |
|||
|
|||
#include <array> |
|||
#include <QFrame> |
|||
#include <QPointer> |
|||
#include "core/frontend/input.h" |
|||
#include "core/settings.h" |
|||
|
|||
class QLabel; |
|||
|
|||
using AnalogParam = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; |
|||
using ButtonParam = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; |
|||
|
|||
// 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 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 BeginMappingAnalog(std::size_t button_id); |
|||
void EndMapping(); |
|||
void UpdateInput(); |
|||
|
|||
protected: |
|||
void paintEvent(QPaintEvent* event) override; |
|||
|
|||
private: |
|||
enum class Direction : std::size_t { |
|||
None, |
|||
Up, |
|||
Right, |
|||
Down, |
|||
Left, |
|||
}; |
|||
|
|||
enum class Symbol { |
|||
House, |
|||
A, |
|||
B, |
|||
X, |
|||
Y, |
|||
L, |
|||
R, |
|||
C, |
|||
SL, |
|||
ZL, |
|||
ZR, |
|||
SR, |
|||
}; |
|||
|
|||
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); |
|||
void DrawGCController(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); |
|||
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); |
|||
|
|||
// 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); |
|||
void DrawGCJoystick(QPainter& p, QPointF center, bool 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 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 |
|||
void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size); |
|||
void DrawArrow(QPainter& p, QPointF center, Direction direction, float size); |
|||
|
|||
// Draw primitive types |
|||
template <size_t N> |
|||
void DrawPolygon(QPainter& p, const std::array<QPointF, N>& 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<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 mapping_active{}; |
|||
int blink_counter{}; |
|||
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}; |
|||
}; |
|||
@ -0,0 +1,66 @@ |
|||
// Copyright 2015 Citra Emulator Project
|
|||
// Licensed under GPLv2 or any later version
|
|||
// Refer to the license.txt file included.
|
|||
|
|||
#include <QAction>
|
|||
#include <QLayout>
|
|||
#include <QString>
|
|||
#include "core/settings.h"
|
|||
#include "yuzu/configuration/configure_input_player_widget.h"
|
|||
#include "yuzu/debugger/controller.h"
|
|||
|
|||
ControllerDialog::ControllerDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) { |
|||
setObjectName(QStringLiteral("Controller")); |
|||
setWindowTitle(tr("Controller P1")); |
|||
resize(500, 350); |
|||
setMinimumSize(500, 350); |
|||
// Remove the "?" button from the titlebar and enable the maximize button
|
|||
setWindowFlags((windowFlags() & ~Qt::WindowContextHelpButtonHint) | |
|||
Qt::WindowMaximizeButtonHint); |
|||
|
|||
widget = new PlayerControlPreview(this); |
|||
refreshConfiguration(); |
|||
QLayout* layout = new QVBoxLayout(this); |
|||
layout->setContentsMargins(0, 0, 0, 0); |
|||
layout->addWidget(widget); |
|||
setLayout(layout); |
|||
|
|||
// Configure focus so that widget is focusable and the dialog automatically forwards focus to
|
|||
// it.
|
|||
setFocusProxy(widget); |
|||
widget->setFocusPolicy(Qt::StrongFocus); |
|||
widget->setFocus(); |
|||
} |
|||
|
|||
void ControllerDialog::refreshConfiguration() { |
|||
const auto& players = Settings::values.players.GetValue(); |
|||
constexpr std::size_t player = 0; |
|||
widget->SetPlayerInputRaw(player, players[player].buttons, players[player].analogs); |
|||
widget->SetConnectedStatus(players[player].connected); |
|||
widget->SetControllerType(players[player].controller_type); |
|||
} |
|||
|
|||
QAction* ControllerDialog::toggleViewAction() { |
|||
if (toggle_view_action == nullptr) { |
|||
toggle_view_action = new QAction(windowTitle(), this); |
|||
toggle_view_action->setCheckable(true); |
|||
toggle_view_action->setChecked(isVisible()); |
|||
connect(toggle_view_action, &QAction::toggled, this, &ControllerDialog::setVisible); |
|||
} |
|||
|
|||
return toggle_view_action; |
|||
} |
|||
|
|||
void ControllerDialog::showEvent(QShowEvent* ev) { |
|||
if (toggle_view_action) { |
|||
toggle_view_action->setChecked(isVisible()); |
|||
} |
|||
QWidget::showEvent(ev); |
|||
} |
|||
|
|||
void ControllerDialog::hideEvent(QHideEvent* ev) { |
|||
if (toggle_view_action) { |
|||
toggle_view_action->setChecked(isVisible()); |
|||
} |
|||
QWidget::hideEvent(ev); |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
// Copyright 2015 Citra Emulator Project |
|||
// Licensed under GPLv2 or any later version |
|||
// Refer to the license.txt file included. |
|||
|
|||
#pragma once |
|||
|
|||
#include <QWidget> |
|||
|
|||
class QAction; |
|||
class QHideEvent; |
|||
class QShowEvent; |
|||
class PlayerControlPreview; |
|||
|
|||
class ControllerDialog : public QWidget { |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
explicit ControllerDialog(QWidget* parent = nullptr); |
|||
|
|||
/// Returns a QAction that can be used to toggle visibility of this dialog. |
|||
QAction* toggleViewAction(); |
|||
void refreshConfiguration(); |
|||
|
|||
protected: |
|||
void showEvent(QShowEvent* ev) override; |
|||
void hideEvent(QHideEvent* ev) override; |
|||
|
|||
private: |
|||
QAction* toggle_view_action = nullptr; |
|||
PlayerControlPreview* widget; |
|||
}; |
|||