This commit is contained in:
Nayla Hanegan 2024-05-12 02:17:59 -04:00
commit 98c174edc4
520 changed files with 74815 additions and 58942 deletions

View file

@ -587,28 +587,25 @@ void IOWindow::UpdateOptionList()
if (m_selected_device == nullptr)
return;
const auto add_rows = [this](auto& container) {
int row = 0;
for (ciface::Core::Device::Control* control : container)
{
m_option_list->insertRow(row);
if (control->IsHidden())
m_option_list->hideRow(row);
m_option_list->setItem(row, 0,
new QTableWidgetItem(QString::fromStdString(control->GetName())));
++row;
}
};
if (m_reference->IsInput())
{
int row = 0;
for (const auto* input : m_selected_device->Inputs())
{
m_option_list->insertRow(row);
m_option_list->setItem(row, 0,
new QTableWidgetItem(QString::fromStdString(input->GetName())));
++row;
}
}
add_rows(m_selected_device->Inputs());
else
{
int row = 0;
for (const auto* output : m_selected_device->Outputs())
{
m_option_list->insertRow(row);
m_option_list->setItem(row, 0,
new QTableWidgetItem(QString::fromStdString(output->GetName())));
++row;
}
}
add_rows(m_selected_device->Outputs());
}
void IOWindow::UpdateDeviceList()

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;
}
@ -167,7 +172,9 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
{
QPushButton* mouse_button = new QPushButton(tr("Use Mouse Controlled Pointing"));
form_layout->insertRow(2, mouse_button);
connect(mouse_button, &QCheckBox::clicked, [this, group] {
using ControllerEmu::Cursor;
connect(mouse_button, &QCheckBox::clicked, [this, group = static_cast<Cursor*>(group)] {
std::string default_device = g_controller_interface.GetDefaultDeviceString() + ":";
const std::string controller_device = GetController()->GetDefaultDevice().ToString() + ":";
if (default_device == controller_device)
@ -178,6 +185,9 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
group->SetControlExpression(1, fmt::format("`{}Cursor Y+`", default_device));
group->SetControlExpression(2, fmt::format("`{}Cursor X-`", default_device));
group->SetControlExpression(3, fmt::format("`{}Cursor X+`", default_device));
group->SetRelativeInput(false);
emit ConfigChanged();
GetController()->UpdateReferences(g_controller_interface);
});
@ -327,6 +337,9 @@ MappingWidget::CreateSettingAdvancedMappingButton(ControllerEmu::NumericSettingB
if (setting.IsSimpleValue())
setting.SetExpressionFromValue();
// Ensure the UI has the game-controller indicator while editing the expression.
ConfigChanged();
IOWindow io(this, GetController(), &setting.GetInputReference(), IOWindow::Type::Input);
SetQWidgetWindowDecorations(&io);
io.exec();

View file

@ -48,6 +48,8 @@ void WiimoteEmuMotionControlIMU::CreateMainLayout()
auto* groups_layout = new QHBoxLayout();
groups_layout->addWidget(
CreateGroupBox(Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUPoint)));
groups_layout->addWidget(
CreateGroupBox(Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IRPassthrough)));
groups_layout->addWidget(CreateGroupBox(
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUAccelerometer)));
groups_layout->addWidget(