early-access version 3561

This commit is contained in:
pineappleEA
2023-05-07 06:43:19 +02:00
parent 9f7d9cd3f1
commit 4fa09f2af9
25 changed files with 203 additions and 58 deletions
@@ -206,7 +206,7 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) {
}
if (param.Has("axis")) {
const QString axis = QString::fromStdString(param.Get("axis", ""));
return QObject::tr("%1%2Axis %3").arg(toggle, invert, axis);
return QObject::tr("%1%2%3Axis %4").arg(toggle, inverted, invert, axis);
}
if (param.Has("axis_x") && param.Has("axis_y") && param.Has("axis_z")) {
const QString axis_x = QString::fromStdString(param.Get("axis_x", ""));
@@ -229,7 +229,7 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) {
return QObject::tr("%1%2%3Hat %4").arg(turbo, toggle, inverted, button_name);
}
if (param.Has("axis")) {
return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name);
return QObject::tr("%1%2%3Axis %4").arg(toggle, inverted, invert, button_name);
}
if (param.Has("motion")) {
return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name);
@@ -410,6 +410,12 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
button_map[button_id]->setText(ButtonToText(param));
emulated_controller->SetButtonParam(button_id, param);
});
context_menu.addAction(tr("Invert button"), [&] {
const bool invert_value = !param.Get("inverted", false);
param.Set("inverted", invert_value);
button_map[button_id]->setText(ButtonToText(param));
emulated_controller->SetButtonParam(button_id, param);
});
context_menu.addAction(tr("Set threshold"), [&] {
const int button_threshold =
static_cast<int>(param.Get("threshold", 0.5f) * 100.0f);
@@ -180,6 +180,10 @@ void PlayerControlPreview::ControllerUpdate(Core::HID::ControllerTriggerType typ
battery_values = controller->GetBatteryValues();
needs_redraw = true;
break;
case Core::HID::ControllerTriggerType::Motion:
motion_values = controller->GetMotions();
needs_redraw = true;
break;
default:
break;
}
@@ -313,6 +317,15 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center)
DrawRawJoystick(p, center + QPointF(-140, 90), QPointF(0, 0));
}
{
// Draw motion cubes
using namespace Settings::NativeMotion;
p.setPen(colors.outline);
p.setBrush(colors.transparent);
Draw3dCube(p, center + QPointF(-140, 90),
motion_values[Settings::NativeMotion::MotionLeft].euler, 20.0f);
}
using namespace Settings::NativeButton;
// D-pad constants
@@ -435,6 +448,15 @@ void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center
DrawRawJoystick(p, QPointF(0, 0), center + QPointF(140, 90));
}
{
// Draw motion cubes
using namespace Settings::NativeMotion;
p.setPen(colors.outline);
p.setBrush(colors.transparent);
Draw3dCube(p, center + QPointF(140, 90),
motion_values[Settings::NativeMotion::MotionRight].euler, 20.0f);
}
using namespace Settings::NativeButton;
// Face buttons constants
@@ -555,6 +577,17 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center)
DrawRawJoystick(p, center + QPointF(-180, 90), center + QPointF(180, 90));
}
{
// Draw motion cubes
using namespace Settings::NativeMotion;
p.setPen(colors.outline);
p.setBrush(colors.transparent);
Draw3dCube(p, center + QPointF(-180, -5),
motion_values[Settings::NativeMotion::MotionLeft].euler, 20.0f);
Draw3dCube(p, center + QPointF(180, -5),
motion_values[Settings::NativeMotion::MotionRight].euler, 20.0f);
}
using namespace Settings::NativeButton;
// Face buttons constants
@@ -647,6 +680,15 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen
DrawRawJoystick(p, center + QPointF(-50, 0), center + QPointF(50, 0));
}
{
// Draw motion cubes
using namespace Settings::NativeMotion;
p.setPen(colors.outline);
p.setBrush(colors.transparent);
Draw3dCube(p, center + QPointF(0, -115),
motion_values[Settings::NativeMotion::MotionLeft].euler, 15.0f);
}
using namespace Settings::NativeButton;
// Face buttons constants
@@ -750,6 +792,15 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
DrawRawJoystick(p, center + QPointF(-50, 105), center + QPointF(50, 105));
}
{
// Draw motion cubes
using namespace Settings::NativeMotion;
p.setPen(colors.button);
p.setBrush(colors.transparent);
Draw3dCube(p, center + QPointF(0, -100),
motion_values[Settings::NativeMotion::MotionLeft].euler, 15.0f);
}
using namespace Settings::NativeButton;
// Face buttons constants
@@ -2871,6 +2922,46 @@ void PlayerControlPreview::DrawArrow(QPainter& p, const QPointF center, const Di
DrawPolygon(p, arrow_symbol);
}
// Draw motion functions
void PlayerControlPreview::Draw3dCube(QPainter& p, QPointF center, const Common::Vec3f& euler,
float size) {
std::array<Common::Vec3f, 8> cube{
Common::Vec3f{-1, -1, -1},
{-1, 1, -1},
{1, 1, -1},
{1, -1, -1},
{-1, -1, 1},
{-1, 1, 1},
{1, 1, 1},
{1, -1, 1},
};
for (Common::Vec3f& point : cube) {
point.RotateFromOrigin(euler.x, euler.y, euler.z);
point *= size;
}
const std::array<QPointF, 4> front_face{
center + QPointF{cube[0].x, cube[0].y},
center + QPointF{cube[1].x, cube[1].y},
center + QPointF{cube[2].x, cube[2].y},
center + QPointF{cube[3].x, cube[3].y},
};
const std::array<QPointF, 4> back_face{
center + QPointF{cube[4].x, cube[4].y},
center + QPointF{cube[5].x, cube[5].y},
center + QPointF{cube[6].x, cube[6].y},
center + QPointF{cube[7].x, cube[7].y},
};
DrawPolygon(p, front_face);
DrawPolygon(p, back_face);
p.drawLine(center + QPointF{cube[0].x, cube[0].y}, center + QPointF{cube[4].x, cube[4].y});
p.drawLine(center + QPointF{cube[1].x, cube[1].y}, center + QPointF{cube[5].x, cube[5].y});
p.drawLine(center + QPointF{cube[2].x, cube[2].y}, center + QPointF{cube[6].x, cube[6].y});
p.drawLine(center + QPointF{cube[3].x, cube[3].y}, center + QPointF{cube[7].x, cube[7].y});
}
template <size_t N>
void PlayerControlPreview::DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon) {
p.drawPolygon(polygon.data(), static_cast<int>(polygon.size()));
@@ -9,6 +9,7 @@
#include "common/input.h"
#include "common/settings_input.h"
#include "common/vector_math.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/hid_types.h"
@@ -193,6 +194,9 @@ private:
void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size);
void DrawArrow(QPainter& p, QPointF center, Direction direction, float size);
// Draw motion functions
void Draw3dCube(QPainter& p, QPointF center, const Common::Vec3f& euler, float size);
// Draw primitive types
template <size_t N>
void DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon);
@@ -222,4 +226,5 @@ private:
Core::HID::SticksValues stick_values{};
Core::HID::TriggerValues trigger_values{};
Core::HID::BatteryValues battery_values{};
Core::HID::MotionState motion_values{};
};