DolphinQt: Break mapping indicators into separate classes. Ensure "state lock" is held on redraw.
This commit is contained in:
parent
7accd9825f
commit
38f36be9ae
|
@ -544,7 +544,7 @@ void InputStateDelegate::paint(QPainter* painter, const QStyleOptionViewItem& op
|
||||||
rect.setWidth(rect.width() * std::clamp(state, 0.0, 1.0));
|
rect.setWidth(rect.width() * std::clamp(state, 0.0, 1.0));
|
||||||
|
|
||||||
// Create a temporary indicator object to retreive color constants.
|
// Create a temporary indicator object to retreive color constants.
|
||||||
MappingIndicator indicator(nullptr);
|
MappingIndicator indicator;
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
|
|
|
@ -105,14 +105,16 @@ void MappingIndicator::AdjustGateColor(QColor* color)
|
||||||
color->setHsvF(color->hueF(), color->saturationF(), 1 - color->valueF());
|
color->setHsvF(color->hueF(), color->saturationF(), 1 - color->valueF());
|
||||||
}
|
}
|
||||||
|
|
||||||
MappingIndicator::MappingIndicator(ControllerEmu::ControlGroup* group) : m_group(group)
|
MappingIndicator::MappingIndicator()
|
||||||
{
|
{
|
||||||
// TODO: Make these magic numbers less ugly.
|
// TODO: Make these magic numbers less ugly.
|
||||||
int required_height = 106;
|
const int required_height = 106;
|
||||||
|
setFixedHeight(required_height);
|
||||||
if (group && ControllerEmu::GroupType::MixedTriggers == group->type)
|
}
|
||||||
required_height = 64 + 1;
|
|
||||||
|
|
||||||
|
MixedTriggersIndicator::MixedTriggersIndicator(ControllerEmu::MixedTriggers& group) : m_group(group)
|
||||||
|
{
|
||||||
|
const int required_height = 64 + 1;
|
||||||
setFixedHeight(required_height);
|
setFixedHeight(required_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,8 +211,16 @@ void GenerateFibonacciSphere(int point_count, F&& callback)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void MappingIndicator::DrawCursor(ControllerEmu::Cursor& cursor)
|
void MappingIndicator::paintEvent(QPaintEvent*)
|
||||||
{
|
{
|
||||||
|
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CursorIndicator::Draw()
|
||||||
|
{
|
||||||
|
auto& cursor = m_cursor_group;
|
||||||
|
|
||||||
const auto center = cursor.GetCenter();
|
const auto center = cursor.GetCenter();
|
||||||
|
|
||||||
QColor tv_brush_color = CURSOR_TV_COLOR;
|
QColor tv_brush_color = CURSOR_TV_COLOR;
|
||||||
|
@ -291,21 +301,12 @@ void MappingIndicator::DrawCursor(ControllerEmu::Cursor& cursor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingIndicator::DrawReshapableInput(ControllerEmu::ReshapableInput& stick)
|
void ReshapableInputIndicator::DrawReshapableInput(
|
||||||
|
ControllerEmu::ReshapableInput& stick,
|
||||||
|
const ControllerEmu::ReshapableInput::ReshapeData& adj_coord, QColor gate_brush_color)
|
||||||
{
|
{
|
||||||
// Some hacks for pretty colors:
|
|
||||||
const bool is_c_stick = m_group->name == "C-Stick";
|
|
||||||
const bool is_tilt = m_group->name == "Tilt";
|
|
||||||
|
|
||||||
const auto center = stick.GetCenter();
|
const auto center = stick.GetCenter();
|
||||||
|
|
||||||
QColor gate_brush_color = STICK_GATE_COLOR;
|
|
||||||
|
|
||||||
if (is_c_stick)
|
|
||||||
gate_brush_color = C_STICK_GATE_COLOR;
|
|
||||||
else if (is_tilt)
|
|
||||||
gate_brush_color = TILT_GATE_COLOR;
|
|
||||||
|
|
||||||
QColor gate_pen_color = gate_brush_color.darker(125);
|
QColor gate_pen_color = gate_brush_color.darker(125);
|
||||||
|
|
||||||
AdjustGateColor(&gate_brush_color);
|
AdjustGateColor(&gate_brush_color);
|
||||||
|
@ -313,18 +314,6 @@ void MappingIndicator::DrawReshapableInput(ControllerEmu::ReshapableInput& stick
|
||||||
|
|
||||||
const auto raw_coord = stick.GetReshapableState(false);
|
const auto raw_coord = stick.GetReshapableState(false);
|
||||||
|
|
||||||
Common::DVec2 adj_coord;
|
|
||||||
if (is_tilt)
|
|
||||||
{
|
|
||||||
WiimoteEmu::EmulateTilt(&m_motion_state, static_cast<ControllerEmu::Tilt*>(&stick),
|
|
||||||
1.f / INDICATOR_UPDATE_FREQ);
|
|
||||||
adj_coord = Common::DVec2{-m_motion_state.angle.y, m_motion_state.angle.x} / MathUtil::PI;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
adj_coord = stick.GetReshapableState(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateCalibrationWidget(raw_coord);
|
UpdateCalibrationWidget(raw_coord);
|
||||||
|
|
||||||
// Bounding box size:
|
// Bounding box size:
|
||||||
|
@ -391,12 +380,33 @@ void MappingIndicator::DrawReshapableInput(ControllerEmu::ReshapableInput& stick
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingIndicator::DrawMixedTriggers()
|
void AnalogStickIndicator::Draw()
|
||||||
|
{
|
||||||
|
// Some hacks for pretty colors:
|
||||||
|
const bool is_c_stick = m_group.name == "C-Stick";
|
||||||
|
|
||||||
|
const auto gate_brush_color = is_c_stick ? C_STICK_GATE_COLOR : STICK_GATE_COLOR;
|
||||||
|
|
||||||
|
const auto adj_coord = m_group.GetReshapableState(true);
|
||||||
|
|
||||||
|
DrawReshapableInput(m_group, adj_coord, gate_brush_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TiltIndicator::Draw()
|
||||||
|
{
|
||||||
|
WiimoteEmu::EmulateTilt(&m_motion_state, &m_group, 1.f / INDICATOR_UPDATE_FREQ);
|
||||||
|
const auto adj_coord =
|
||||||
|
Common::DVec2{-m_motion_state.angle.y, m_motion_state.angle.x} / MathUtil::PI;
|
||||||
|
|
||||||
|
DrawReshapableInput(m_group, adj_coord, TILT_GATE_COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MixedTriggersIndicator::Draw()
|
||||||
{
|
{
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
p.setRenderHint(QPainter::TextAntialiasing, true);
|
p.setRenderHint(QPainter::TextAntialiasing, true);
|
||||||
|
|
||||||
const auto& triggers = *static_cast<ControllerEmu::MixedTriggers*>(m_group);
|
const auto& triggers = m_group;
|
||||||
const ControlState threshold = triggers.GetThreshold();
|
const ControlState threshold = triggers.GetThreshold();
|
||||||
const ControlState deadzone = triggers.GetDeadzone();
|
const ControlState deadzone = triggers.GetDeadzone();
|
||||||
|
|
||||||
|
@ -486,8 +496,10 @@ void MappingIndicator::DrawMixedTriggers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingIndicator::DrawForce(ControllerEmu::Force& force)
|
void SwingIndicator::Draw()
|
||||||
{
|
{
|
||||||
|
auto& force = m_swing_group;
|
||||||
|
|
||||||
const auto center = force.GetCenter();
|
const auto center = force.GetCenter();
|
||||||
|
|
||||||
QColor gate_brush_color = SWING_GATE_COLOR;
|
QColor gate_brush_color = SWING_GATE_COLOR;
|
||||||
|
@ -597,39 +609,7 @@ void MappingIndicator::DrawForce(ControllerEmu::Force& force)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingIndicator::paintEvent(QPaintEvent*)
|
void ShakeMappingIndicator::Draw()
|
||||||
{
|
|
||||||
switch (m_group->type)
|
|
||||||
{
|
|
||||||
case ControllerEmu::GroupType::Cursor:
|
|
||||||
DrawCursor(*static_cast<ControllerEmu::Cursor*>(m_group));
|
|
||||||
break;
|
|
||||||
case ControllerEmu::GroupType::Stick:
|
|
||||||
case ControllerEmu::GroupType::Tilt:
|
|
||||||
DrawReshapableInput(*static_cast<ControllerEmu::ReshapableInput*>(m_group));
|
|
||||||
break;
|
|
||||||
case ControllerEmu::GroupType::MixedTriggers:
|
|
||||||
DrawMixedTriggers();
|
|
||||||
break;
|
|
||||||
case ControllerEmu::GroupType::Force:
|
|
||||||
DrawForce(*static_cast<ControllerEmu::Force*>(m_group));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ShakeMappingIndicator::ShakeMappingIndicator(ControllerEmu::Shake* group)
|
|
||||||
: MappingIndicator(group), m_shake_group(*group)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShakeMappingIndicator::paintEvent(QPaintEvent*)
|
|
||||||
{
|
|
||||||
DrawShake();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShakeMappingIndicator::DrawShake()
|
|
||||||
{
|
{
|
||||||
constexpr std::size_t HISTORY_COUNT = INDICATOR_UPDATE_FREQ;
|
constexpr std::size_t HISTORY_COUNT = INDICATOR_UPDATE_FREQ;
|
||||||
|
|
||||||
|
@ -706,12 +686,7 @@ void ShakeMappingIndicator::DrawShake()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AccelerometerMappingIndicator::AccelerometerMappingIndicator(ControllerEmu::IMUAccelerometer* group)
|
void AccelerometerMappingIndicator::Draw()
|
||||||
: MappingIndicator(group), m_accel_group(*group)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AccelerometerMappingIndicator::paintEvent(QPaintEvent*)
|
|
||||||
{
|
{
|
||||||
const auto accel_state = m_accel_group.GetState();
|
const auto accel_state = m_accel_group.GetState();
|
||||||
const auto state = accel_state.value_or(Common::Vec3{});
|
const auto state = accel_state.value_or(Common::Vec3{});
|
||||||
|
@ -793,12 +768,7 @@ void AccelerometerMappingIndicator::paintEvent(QPaintEvent*)
|
||||||
fmt::format("{:.2f} g", state.Length() / WiimoteEmu::GRAVITY_ACCELERATION)));
|
fmt::format("{:.2f} g", state.Length() / WiimoteEmu::GRAVITY_ACCELERATION)));
|
||||||
}
|
}
|
||||||
|
|
||||||
GyroMappingIndicator::GyroMappingIndicator(ControllerEmu::IMUGyroscope* group)
|
void GyroMappingIndicator::Draw()
|
||||||
: MappingIndicator(group), m_gyro_group(*group), m_state(Common::Matrix33::Identity())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void GyroMappingIndicator::paintEvent(QPaintEvent*)
|
|
||||||
{
|
{
|
||||||
const auto gyro_state = m_gyro_group.GetState();
|
const auto gyro_state = m_gyro_group.GetState();
|
||||||
const auto raw_gyro_state = m_gyro_group.GetRawState();
|
const auto raw_gyro_state = m_gyro_group.GetRawState();
|
||||||
|
@ -915,7 +885,7 @@ void GyroMappingIndicator::paintEvent(QPaintEvent*)
|
||||||
p.drawEllipse(QPointF{}, INPUT_DOT_RADIUS, INPUT_DOT_RADIUS);
|
p.drawEllipse(QPointF{}, INPUT_DOT_RADIUS, INPUT_DOT_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingIndicator::DrawCalibration(QPainter& p, Common::DVec2 point)
|
void ReshapableInputIndicator::DrawCalibration(QPainter& p, Common::DVec2 point)
|
||||||
{
|
{
|
||||||
// Bounding box size:
|
// Bounding box size:
|
||||||
const double scale = GetScale();
|
const double scale = GetScale();
|
||||||
|
@ -942,24 +912,24 @@ void MappingIndicator::DrawCalibration(QPainter& p, Common::DVec2 point)
|
||||||
p.drawEllipse(QPointF{point.x, point.y} * scale, INPUT_DOT_RADIUS, INPUT_DOT_RADIUS);
|
p.drawEllipse(QPointF{point.x, point.y} * scale, INPUT_DOT_RADIUS, INPUT_DOT_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingIndicator::UpdateCalibrationWidget(Common::DVec2 point)
|
void ReshapableInputIndicator::UpdateCalibrationWidget(Common::DVec2 point)
|
||||||
{
|
{
|
||||||
if (m_calibration_widget)
|
if (m_calibration_widget)
|
||||||
m_calibration_widget->Update(point);
|
m_calibration_widget->Update(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MappingIndicator::IsCalibrating() const
|
bool ReshapableInputIndicator::IsCalibrating() const
|
||||||
{
|
{
|
||||||
return m_calibration_widget && m_calibration_widget->IsCalibrating();
|
return m_calibration_widget && m_calibration_widget->IsCalibrating();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingIndicator::SetCalibrationWidget(CalibrationWidget* widget)
|
void ReshapableInputIndicator::SetCalibrationWidget(CalibrationWidget* widget)
|
||||||
{
|
{
|
||||||
m_calibration_widget = widget;
|
m_calibration_widget = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
CalibrationWidget::CalibrationWidget(ControllerEmu::ReshapableInput& input,
|
CalibrationWidget::CalibrationWidget(ControllerEmu::ReshapableInput& input,
|
||||||
MappingIndicator& indicator)
|
ReshapableInputIndicator& indicator)
|
||||||
: m_input(input), m_indicator(indicator), m_completion_action{}
|
: m_input(input), m_indicator(indicator), m_completion_action{}
|
||||||
{
|
{
|
||||||
m_indicator.SetCalibrationWidget(this);
|
m_indicator.SetCalibrationWidget(this);
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Control;
|
||||||
class ControlGroup;
|
class ControlGroup;
|
||||||
class Cursor;
|
class Cursor;
|
||||||
class Force;
|
class Force;
|
||||||
|
class MixedTriggers;
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
@ -29,9 +30,7 @@ class CalibrationWidget;
|
||||||
class MappingIndicator : public QWidget
|
class MappingIndicator : public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MappingIndicator(ControllerEmu::ControlGroup* group);
|
MappingIndicator();
|
||||||
|
|
||||||
void SetCalibrationWidget(CalibrationWidget* widget);
|
|
||||||
|
|
||||||
QPen GetBBoxPen() const;
|
QPen GetBBoxPen() const;
|
||||||
QBrush GetBBoxBrush() const;
|
QBrush GetBBoxBrush() const;
|
||||||
|
@ -49,58 +48,126 @@ public:
|
||||||
protected:
|
protected:
|
||||||
double GetScale() const;
|
double GetScale() const;
|
||||||
|
|
||||||
WiimoteEmu::MotionState m_motion_state{};
|
virtual void Draw() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DrawCursor(ControllerEmu::Cursor& cursor);
|
|
||||||
void DrawReshapableInput(ControllerEmu::ReshapableInput& stick);
|
|
||||||
void DrawMixedTriggers();
|
|
||||||
void DrawForce(ControllerEmu::Force&);
|
|
||||||
void DrawCalibration(QPainter& p, Common::DVec2 point);
|
|
||||||
|
|
||||||
void paintEvent(QPaintEvent*) override;
|
void paintEvent(QPaintEvent*) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ReshapableInputIndicator : public MappingIndicator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void SetCalibrationWidget(CalibrationWidget* widget);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void DrawReshapableInput(ControllerEmu::ReshapableInput& group,
|
||||||
|
const ControllerEmu::ReshapableInput::ReshapeData& adj_coord,
|
||||||
|
QColor gate_color);
|
||||||
|
|
||||||
bool IsCalibrating() const;
|
bool IsCalibrating() const;
|
||||||
|
|
||||||
|
void DrawCalibration(QPainter& p, Common::DVec2 point);
|
||||||
void UpdateCalibrationWidget(Common::DVec2 point);
|
void UpdateCalibrationWidget(Common::DVec2 point);
|
||||||
|
|
||||||
ControllerEmu::ControlGroup* const m_group;
|
private:
|
||||||
CalibrationWidget* m_calibration_widget{};
|
CalibrationWidget* m_calibration_widget{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AnalogStickIndicator : public ReshapableInputIndicator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AnalogStickIndicator(ControllerEmu::ReshapableInput& stick) : m_group(stick) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Draw() override;
|
||||||
|
|
||||||
|
ControllerEmu::ReshapableInput& m_group;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TiltIndicator : public ReshapableInputIndicator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit TiltIndicator(ControllerEmu::Tilt& tilt) : m_group(tilt) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Draw() override;
|
||||||
|
|
||||||
|
ControllerEmu::Tilt& m_group;
|
||||||
|
WiimoteEmu::MotionState m_motion_state{};
|
||||||
|
};
|
||||||
|
|
||||||
|
class CursorIndicator : public ReshapableInputIndicator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit CursorIndicator(ControllerEmu::Cursor& cursor) : m_cursor_group(cursor) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Draw() override;
|
||||||
|
|
||||||
|
ControllerEmu::Cursor& m_cursor_group;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MixedTriggersIndicator : public MappingIndicator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit MixedTriggersIndicator(ControllerEmu::MixedTriggers& triggers);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Draw() override;
|
||||||
|
|
||||||
|
ControllerEmu::MixedTriggers& m_group;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SwingIndicator : public ReshapableInputIndicator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit SwingIndicator(ControllerEmu::Force& swing) : m_swing_group(swing) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Draw() override;
|
||||||
|
|
||||||
|
ControllerEmu::Force& m_swing_group;
|
||||||
|
WiimoteEmu::MotionState m_motion_state{};
|
||||||
|
};
|
||||||
|
|
||||||
class ShakeMappingIndicator : public MappingIndicator
|
class ShakeMappingIndicator : public MappingIndicator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ShakeMappingIndicator(ControllerEmu::Shake* group);
|
explicit ShakeMappingIndicator(ControllerEmu::Shake& shake) : m_shake_group(shake) {}
|
||||||
|
|
||||||
void DrawShake();
|
|
||||||
void paintEvent(QPaintEvent*) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::deque<ControllerEmu::Shake::StateData> m_position_samples;
|
void Draw() override;
|
||||||
int m_grid_line_position = 0;
|
|
||||||
|
|
||||||
ControllerEmu::Shake& m_shake_group;
|
ControllerEmu::Shake& m_shake_group;
|
||||||
|
WiimoteEmu::MotionState m_motion_state{};
|
||||||
|
std::deque<ControllerEmu::Shake::StateData> m_position_samples;
|
||||||
|
int m_grid_line_position = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AccelerometerMappingIndicator : public MappingIndicator
|
class AccelerometerMappingIndicator : public MappingIndicator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit AccelerometerMappingIndicator(ControllerEmu::IMUAccelerometer* group);
|
explicit AccelerometerMappingIndicator(ControllerEmu::IMUAccelerometer& accel)
|
||||||
void paintEvent(QPaintEvent*) override;
|
: m_accel_group(accel)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void Draw() override;
|
||||||
|
|
||||||
ControllerEmu::IMUAccelerometer& m_accel_group;
|
ControllerEmu::IMUAccelerometer& m_accel_group;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GyroMappingIndicator : public MappingIndicator
|
class GyroMappingIndicator : public MappingIndicator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit GyroMappingIndicator(ControllerEmu::IMUGyroscope* group);
|
explicit GyroMappingIndicator(ControllerEmu::IMUGyroscope& gyro) : m_gyro_group(gyro) {}
|
||||||
void paintEvent(QPaintEvent*) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void Draw() override;
|
||||||
|
|
||||||
ControllerEmu::IMUGyroscope& m_gyro_group;
|
ControllerEmu::IMUGyroscope& m_gyro_group;
|
||||||
Common::Matrix33 m_state;
|
Common::Matrix33 m_state = Common::Matrix33::Identity();
|
||||||
Common::Vec3 m_previous_velocity = {};
|
Common::Vec3 m_previous_velocity = {};
|
||||||
u32 m_stable_steps = 0;
|
u32 m_stable_steps = 0;
|
||||||
};
|
};
|
||||||
|
@ -108,7 +175,7 @@ private:
|
||||||
class CalibrationWidget : public QToolButton
|
class CalibrationWidget : public QToolButton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CalibrationWidget(ControllerEmu::ReshapableInput& input, MappingIndicator& indicator);
|
CalibrationWidget(ControllerEmu::ReshapableInput& input, ReshapableInputIndicator& indicator);
|
||||||
|
|
||||||
void Update(Common::DVec2 point);
|
void Update(Common::DVec2 point);
|
||||||
|
|
||||||
|
@ -123,7 +190,7 @@ private:
|
||||||
void SetupActions();
|
void SetupActions();
|
||||||
|
|
||||||
ControllerEmu::ReshapableInput& m_input;
|
ControllerEmu::ReshapableInput& m_input;
|
||||||
MappingIndicator& m_indicator;
|
ReshapableInputIndicator& m_indicator;
|
||||||
QAction* m_completion_action;
|
QAction* m_completion_action;
|
||||||
ControllerEmu::ReshapableInput::CalibrationData m_calibration_data;
|
ControllerEmu::ReshapableInput::CalibrationData m_calibration_data;
|
||||||
QTimer* m_informative_timer;
|
QTimer* m_informative_timer;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "InputCommon/ControlReference/ControlReference.h"
|
#include "InputCommon/ControlReference/ControlReference.h"
|
||||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
|
#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
#include "InputCommon/ControllerEmu/StickGate.h"
|
#include "InputCommon/ControllerEmu/StickGate.h"
|
||||||
|
@ -52,52 +53,63 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
|
||||||
|
|
||||||
group_box->setLayout(form_layout);
|
group_box->setLayout(form_layout);
|
||||||
|
|
||||||
const bool need_indicator = group->type == ControllerEmu::GroupType::Cursor ||
|
MappingIndicator* indicator = nullptr;
|
||||||
group->type == ControllerEmu::GroupType::Stick ||
|
|
||||||
group->type == ControllerEmu::GroupType::Tilt ||
|
switch (group->type)
|
||||||
group->type == ControllerEmu::GroupType::MixedTriggers ||
|
{
|
||||||
group->type == ControllerEmu::GroupType::Force ||
|
case ControllerEmu::GroupType::Shake:
|
||||||
group->type == ControllerEmu::GroupType::IMUAccelerometer ||
|
indicator = new ShakeMappingIndicator(*static_cast<ControllerEmu::Shake*>(group));
|
||||||
group->type == ControllerEmu::GroupType::IMUGyroscope ||
|
break;
|
||||||
group->type == ControllerEmu::GroupType::Shake;
|
|
||||||
|
case ControllerEmu::GroupType::MixedTriggers:
|
||||||
|
indicator = new MixedTriggersIndicator(*static_cast<ControllerEmu::MixedTriggers*>(group));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ControllerEmu::GroupType::Tilt:
|
||||||
|
indicator = new TiltIndicator(*static_cast<ControllerEmu::Tilt*>(group));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ControllerEmu::GroupType::Cursor:
|
||||||
|
indicator = new CursorIndicator(*static_cast<ControllerEmu::Cursor*>(group));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ControllerEmu::GroupType::Force:
|
||||||
|
indicator = new SwingIndicator(*static_cast<ControllerEmu::Force*>(group));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ControllerEmu::GroupType::IMUAccelerometer:
|
||||||
|
indicator =
|
||||||
|
new AccelerometerMappingIndicator(*static_cast<ControllerEmu::IMUAccelerometer*>(group));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ControllerEmu::GroupType::IMUGyroscope:
|
||||||
|
indicator = new GyroMappingIndicator(*static_cast<ControllerEmu::IMUGyroscope*>(group));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ControllerEmu::GroupType::Stick:
|
||||||
|
indicator = new AnalogStickIndicator(*static_cast<ControllerEmu::ReshapableInput*>(group));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (indicator)
|
||||||
|
{
|
||||||
|
form_layout->addRow(indicator);
|
||||||
|
|
||||||
|
connect(this, &MappingWidget::Update, indicator, QOverload<>::of(&MappingIndicator::update));
|
||||||
|
|
||||||
const bool need_calibration = group->type == ControllerEmu::GroupType::Cursor ||
|
const bool need_calibration = group->type == ControllerEmu::GroupType::Cursor ||
|
||||||
group->type == ControllerEmu::GroupType::Stick ||
|
group->type == ControllerEmu::GroupType::Stick ||
|
||||||
group->type == ControllerEmu::GroupType::Tilt ||
|
group->type == ControllerEmu::GroupType::Tilt ||
|
||||||
group->type == ControllerEmu::GroupType::Force;
|
group->type == ControllerEmu::GroupType::Force;
|
||||||
|
|
||||||
if (need_indicator)
|
|
||||||
{
|
|
||||||
MappingIndicator* indicator;
|
|
||||||
|
|
||||||
switch (group->type)
|
|
||||||
{
|
|
||||||
case ControllerEmu::GroupType::Shake:
|
|
||||||
indicator = new ShakeMappingIndicator(static_cast<ControllerEmu::Shake*>(group));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ControllerEmu::GroupType::IMUAccelerometer:
|
|
||||||
indicator =
|
|
||||||
new AccelerometerMappingIndicator(static_cast<ControllerEmu::IMUAccelerometer*>(group));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ControllerEmu::GroupType::IMUGyroscope:
|
|
||||||
indicator = new GyroMappingIndicator(static_cast<ControllerEmu::IMUGyroscope*>(group));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
indicator = new MappingIndicator(group);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
form_layout->addRow(indicator);
|
|
||||||
|
|
||||||
connect(this, &MappingWidget::Update, indicator, QOverload<>::of(&MappingIndicator::update));
|
|
||||||
|
|
||||||
if (need_calibration)
|
if (need_calibration)
|
||||||
{
|
{
|
||||||
const auto calibrate =
|
const auto calibrate =
|
||||||
new CalibrationWidget(*static_cast<ControllerEmu::ReshapableInput*>(group), *indicator);
|
new CalibrationWidget(*static_cast<ControllerEmu::ReshapableInput*>(group),
|
||||||
|
*static_cast<ReshapableInputIndicator*>(indicator));
|
||||||
|
|
||||||
form_layout->addRow(calibrate);
|
form_layout->addRow(calibrate);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +117,7 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
|
||||||
|
|
||||||
for (auto& control : group->controls)
|
for (auto& control : group->controls)
|
||||||
{
|
{
|
||||||
auto* button = new MappingButton(this, control->control_ref.get(), !need_indicator);
|
auto* button = new MappingButton(this, control->control_ref.get(), !indicator);
|
||||||
|
|
||||||
button->setMinimumWidth(100);
|
button->setMinimumWidth(100);
|
||||||
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
|
|
Loading…
Reference in New Issue