DolphinQt: Add IRPassthrough indicator.

This commit is contained in:
Jordan Woyak 2024-03-10 23:25:44 -05:00
parent 72bcdadc16
commit 62caa24d40
3 changed files with 50 additions and 0 deletions

View File

@ -17,6 +17,8 @@
#include "Common/MathUtil.h"
#include "Core/HW/WiimoteEmu/Camera.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
#include "InputCommon/ControllerEmu/ControlGroup/Cursor.h"
@ -823,6 +825,35 @@ void GyroMappingIndicator::Draw()
p.drawEllipse(QPointF{}, INPUT_DOT_RADIUS, INPUT_DOT_RADIUS);
}
void IRPassthroughMappingIndicator::Draw()
{
QPainter p(this);
DrawBoundingBox(p);
TransformPainter(p);
p.scale(1.0, -1.0);
auto pen = GetInputDotPen(m_ir_group.enabled ? GetAdjustedInputColor() : GetRawInputColor());
for (std::size_t i = 0; i != WiimoteEmu::CameraLogic::NUM_POINTS; ++i)
{
const auto size = m_ir_group.GetObjectSize(i);
const bool is_visible = size > 0;
if (!is_visible)
continue;
const auto point =
(QPointF{m_ir_group.GetObjectPositionX(i), m_ir_group.GetObjectPositionY(i)} -
QPointF{0.5, 0.5}) *
2.0;
pen.setWidth(size * NORMAL_INDICATOR_WIDTH / 2);
p.setPen(pen);
p.drawPoint(point);
}
}
void ReshapableInputIndicator::DrawCalibration(QPainter& p, Common::DVec2 point)
{
const auto center = m_calibration_widget->GetCenter();

View File

@ -9,6 +9,7 @@
#include <deque>
#include "Core/HW/WiimoteEmu/Dynamics.h"
#include "InputCommon/ControllerEmu/ControlGroup/IRPassthrough.h"
#include "InputCommon/ControllerEmu/StickGate.h"
namespace ControllerEmu
@ -180,6 +181,19 @@ private:
u32 m_stable_steps = 0;
};
class IRPassthroughMappingIndicator : public SquareIndicator
{
public:
explicit IRPassthroughMappingIndicator(ControllerEmu::IRPassthrough& ir_group)
: m_ir_group(ir_group)
{
}
private:
void Draw() override;
ControllerEmu::IRPassthrough& m_ir_group;
};
class CalibrationWidget : public QToolButton
{
public:

View File

@ -95,6 +95,11 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
indicator = new AnalogStickIndicator(*static_cast<ControllerEmu::ReshapableInput*>(group));
break;
case ControllerEmu::GroupType::IRPassthrough:
indicator =
new IRPassthroughMappingIndicator(*static_cast<ControllerEmu::IRPassthrough*>(group));
break;
default:
break;
}