mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-26 04:06:32 +00:00
Merge branch 'master' of https://github.com/dolphin-emu/dolphin into dolphin-emu-master2
This commit is contained in:
commit
86f7aa4e6a
128 changed files with 5247 additions and 4422 deletions
|
@ -329,7 +329,6 @@ void AchievementSettingsWidget::ToggleProgress()
|
|||
|
||||
void AchievementSettingsWidget::UpdateHardcoreMode()
|
||||
{
|
||||
AchievementManager::GetInstance().SetHardcoreMode();
|
||||
if (Config::Get(Config::RA_HARDCORE_ENABLED))
|
||||
{
|
||||
Settings::Instance().SetDebugModeEnabled(false);
|
||||
|
|
|
@ -115,7 +115,7 @@ void ARCodeWidget::OnItemChanged(QListWidgetItem* item)
|
|||
m_ar_codes[m_code_list->row(item)].enabled = (item->checkState() == Qt::Checked);
|
||||
|
||||
if (!m_restart_required)
|
||||
ActionReplay::ApplyCodes(m_ar_codes);
|
||||
ActionReplay::ApplyCodes(m_ar_codes, m_game_id);
|
||||
|
||||
UpdateList();
|
||||
SaveCodes();
|
||||
|
|
|
@ -206,7 +206,7 @@ void GeckoCodeWidget::OnItemChanged(QListWidgetItem* item)
|
|||
m_gecko_codes[index].enabled = (item->checkState() == Qt::Checked);
|
||||
|
||||
if (!m_restart_required)
|
||||
Gecko::SetActiveCodes(m_gecko_codes);
|
||||
Gecko::SetActiveCodes(m_gecko_codes, m_game_id);
|
||||
|
||||
SaveCodes();
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ void HardcoreWarningWidget::CreateWidgets()
|
|||
auto* icon = new QLabel;
|
||||
icon->setPixmap(warning_icon);
|
||||
|
||||
m_text = new QLabel(tr("This feature is disabled in hardcore mode."));
|
||||
m_text = new QLabel(tr("Only approved codes will be applied in hardcore mode."));
|
||||
m_settings_button = new QPushButton(tr("Achievement Settings"));
|
||||
|
||||
auto* layout = new QHBoxLayout;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <numeric>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
|
@ -19,12 +18,10 @@
|
|||
|
||||
#include "Core/HW/WiimoteEmu/Camera.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Cursor.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Force.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||
#include "InputCommon/ControllerInterface/CoreDevice.h"
|
||||
|
||||
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
||||
|
@ -289,7 +286,14 @@ void GenerateFibonacciSphere(int point_count, F&& callback)
|
|||
|
||||
void MappingIndicator::paintEvent(QPaintEvent*)
|
||||
{
|
||||
constexpr float max_elapsed_seconds = 0.1f;
|
||||
|
||||
const auto now = Clock::now();
|
||||
const float elapsed_seconds = std::chrono::duration_cast<DT_s>(now - m_last_update).count();
|
||||
m_last_update = now;
|
||||
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
Update(std::min(elapsed_seconds, max_elapsed_seconds));
|
||||
Draw();
|
||||
}
|
||||
|
||||
|
@ -321,7 +325,7 @@ void SquareIndicator::TransformPainter(QPainter& p)
|
|||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
|
||||
p.translate(width() / 2, height() / 2);
|
||||
p.translate(width() / 2.0, height() / 2.0);
|
||||
const auto scale = GetContentsScale();
|
||||
p.scale(scale, scale);
|
||||
}
|
||||
|
@ -413,10 +417,13 @@ void AnalogStickIndicator::Draw()
|
|||
(adj_coord.x || adj_coord.y) ? std::make_optional(adj_coord) : std::nullopt);
|
||||
}
|
||||
|
||||
void TiltIndicator::Update(float elapsed_seconds)
|
||||
{
|
||||
WiimoteEmu::EmulateTilt(&m_motion_state, &m_group, elapsed_seconds);
|
||||
}
|
||||
|
||||
void TiltIndicator::Draw()
|
||||
{
|
||||
WiimoteEmu::EmulateTilt(&m_motion_state, &m_group, 1.f / INDICATOR_UPDATE_FREQ);
|
||||
|
||||
auto adj_coord = Common::DVec2{-m_motion_state.angle.y, m_motion_state.angle.x} / MathUtil::PI;
|
||||
|
||||
// Angle values after dividing by pi.
|
||||
|
@ -564,28 +571,54 @@ void SwingIndicator::DrawUnderGate(QPainter& p)
|
|||
}
|
||||
}
|
||||
|
||||
void SwingIndicator::Update(float elapsed_seconds)
|
||||
{
|
||||
WiimoteEmu::EmulateSwing(&m_motion_state, &m_swing_group, elapsed_seconds);
|
||||
}
|
||||
|
||||
void SwingIndicator::Draw()
|
||||
{
|
||||
auto& force = m_swing_group;
|
||||
WiimoteEmu::EmulateSwing(&m_motion_state, &force, 1.f / INDICATOR_UPDATE_FREQ);
|
||||
|
||||
DrawReshapableInput(force, SWING_GATE_COLOR,
|
||||
DrawReshapableInput(m_swing_group, SWING_GATE_COLOR,
|
||||
Common::DVec2{-m_motion_state.position.x, m_motion_state.position.z});
|
||||
}
|
||||
|
||||
void ShakeMappingIndicator::Update(float elapsed_seconds)
|
||||
{
|
||||
WiimoteEmu::EmulateShake(&m_motion_state, &m_shake_group, elapsed_seconds);
|
||||
|
||||
for (auto& sample : m_position_samples)
|
||||
sample.age += elapsed_seconds;
|
||||
|
||||
m_position_samples.erase(
|
||||
std::ranges::find_if(m_position_samples,
|
||||
[](const ShakeSample& sample) { return sample.age > 1.f; }),
|
||||
m_position_samples.end());
|
||||
|
||||
constexpr float MAX_DISTANCE = 0.5f;
|
||||
|
||||
m_position_samples.push_front(ShakeSample{m_motion_state.position / MAX_DISTANCE});
|
||||
|
||||
const bool any_non_zero_samples =
|
||||
std::any_of(m_position_samples.begin(), m_position_samples.end(),
|
||||
[](const ShakeSample& s) { return s.state.LengthSquared() != 0.0; });
|
||||
|
||||
// Only start moving the line if there's non-zero data.
|
||||
if (m_grid_line_position || any_non_zero_samples)
|
||||
{
|
||||
m_grid_line_position += elapsed_seconds;
|
||||
|
||||
if (m_grid_line_position > 1.f)
|
||||
{
|
||||
if (any_non_zero_samples)
|
||||
m_grid_line_position = std::fmod(m_grid_line_position, 1.f);
|
||||
else
|
||||
m_grid_line_position = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShakeMappingIndicator::Draw()
|
||||
{
|
||||
constexpr std::size_t HISTORY_COUNT = INDICATOR_UPDATE_FREQ;
|
||||
|
||||
WiimoteEmu::EmulateShake(&m_motion_state, &m_shake_group, 1.f / INDICATOR_UPDATE_FREQ);
|
||||
|
||||
constexpr float MAX_DISTANCE = 0.5f;
|
||||
|
||||
m_position_samples.push_front(m_motion_state.position / MAX_DISTANCE);
|
||||
// This also holds the current state so +1.
|
||||
if (m_position_samples.size() > HISTORY_COUNT + 1)
|
||||
m_position_samples.pop_back();
|
||||
|
||||
QPainter p(this);
|
||||
DrawBoundingBox(p);
|
||||
TransformPainter(p);
|
||||
|
@ -610,15 +643,7 @@ void ShakeMappingIndicator::Draw()
|
|||
p.drawPoint(QPointF{-0.5 + c * 0.5, raw_coord.data[c]});
|
||||
}
|
||||
|
||||
// Grid line.
|
||||
if (m_grid_line_position ||
|
||||
std::any_of(m_position_samples.begin(), m_position_samples.end(),
|
||||
[](const Common::Vec3& v) { return v.LengthSquared() != 0.0; }))
|
||||
{
|
||||
// Only start moving the line if there's non-zero data.
|
||||
m_grid_line_position = (m_grid_line_position + 1) % HISTORY_COUNT;
|
||||
}
|
||||
const double grid_line_x = 1.0 - m_grid_line_position * 2.0 / HISTORY_COUNT;
|
||||
const double grid_line_x = 1.0 - m_grid_line_position * 2.0;
|
||||
p.setPen(QPen(GetRawInputColor(), 0));
|
||||
p.drawLine(QPointF{grid_line_x, -1.0}, QPointF{grid_line_x, 1.0});
|
||||
|
||||
|
@ -629,12 +654,8 @@ void ShakeMappingIndicator::Draw()
|
|||
{
|
||||
QPolygonF polyline;
|
||||
|
||||
int i = 0;
|
||||
for (auto& sample : m_position_samples)
|
||||
{
|
||||
polyline.append(QPointF{1.0 - i * 2.0 / HISTORY_COUNT, sample.data[c]});
|
||||
++i;
|
||||
}
|
||||
polyline.append(QPointF{1.0 - sample.age * 2.0, sample.state.data[c]});
|
||||
|
||||
p.setPen(QPen(component_colors[c], 0));
|
||||
p.drawPolyline(polyline);
|
||||
|
@ -692,7 +713,7 @@ void AccelerometerMappingIndicator::Draw()
|
|||
p.setBrush(Qt::NoBrush);
|
||||
|
||||
p.resetTransform();
|
||||
p.translate(width() / 2, height() / 2);
|
||||
p.translate(width() / 2.0, height() / 2.0);
|
||||
|
||||
// Red dot upright target.
|
||||
p.setPen(GetAdjustedInputColor());
|
||||
|
@ -717,6 +738,28 @@ void AccelerometerMappingIndicator::Draw()
|
|||
fmt::format("{:.2f} g", state.Length() / WiimoteEmu::GRAVITY_ACCELERATION)));
|
||||
}
|
||||
|
||||
void GyroMappingIndicator::Update(float elapsed_seconds)
|
||||
{
|
||||
const auto gyro_state = m_gyro_group.GetState();
|
||||
const auto angular_velocity = gyro_state.value_or(Common::Vec3{});
|
||||
m_state *= WiimoteEmu::GetRotationFromGyroscope(angular_velocity * Common::Vec3(-1, +1, -1) *
|
||||
elapsed_seconds);
|
||||
m_state = m_state.Normalized();
|
||||
|
||||
// Reset orientation when stable for a bit:
|
||||
constexpr float STABLE_RESET_SECONDS = 1.f;
|
||||
// Consider device stable when data (with deadzone applied) is zero.
|
||||
const bool is_stable = !angular_velocity.LengthSquared();
|
||||
|
||||
if (!is_stable)
|
||||
m_stable_time = 0;
|
||||
else if (m_stable_time < STABLE_RESET_SECONDS)
|
||||
m_stable_time += elapsed_seconds;
|
||||
|
||||
if (m_stable_time >= STABLE_RESET_SECONDS)
|
||||
m_state = Common::Quaternion::Identity();
|
||||
}
|
||||
|
||||
void GyroMappingIndicator::Draw()
|
||||
{
|
||||
const auto gyro_state = m_gyro_group.GetState();
|
||||
|
@ -725,23 +768,9 @@ void GyroMappingIndicator::Draw()
|
|||
const auto jitter = raw_gyro_state - m_previous_velocity;
|
||||
m_previous_velocity = raw_gyro_state;
|
||||
|
||||
m_state *= WiimoteEmu::GetRotationFromGyroscope(angular_velocity * Common::Vec3(-1, +1, -1) /
|
||||
INDICATOR_UPDATE_FREQ);
|
||||
m_state = m_state.Normalized();
|
||||
|
||||
// Reset orientation when stable for a bit:
|
||||
constexpr u32 STABLE_RESET_STEPS = INDICATOR_UPDATE_FREQ;
|
||||
// Consider device stable when data (with deadzone applied) is zero.
|
||||
const bool is_stable = !angular_velocity.LengthSquared();
|
||||
|
||||
if (!is_stable)
|
||||
m_stable_steps = 0;
|
||||
else if (m_stable_steps != STABLE_RESET_STEPS)
|
||||
++m_stable_steps;
|
||||
|
||||
if (STABLE_RESET_STEPS == m_stable_steps)
|
||||
m_state = Common::Quaternion::Identity();
|
||||
|
||||
// Use an empty rotation matrix if gyroscope data is not present.
|
||||
const auto rotation =
|
||||
(gyro_state.has_value() ? Common::Matrix33::FromQuaternion(m_state) : Common::Matrix33{});
|
||||
|
@ -814,7 +843,7 @@ void GyroMappingIndicator::Draw()
|
|||
p.setBrush(Qt::NoBrush);
|
||||
|
||||
p.resetTransform();
|
||||
p.translate(width() / 2, height() / 2);
|
||||
p.translate(width() / 2.0, height() / 2.0);
|
||||
|
||||
// Red dot upright target.
|
||||
p.setPen(GetAdjustedInputColor());
|
||||
|
|
|
@ -45,9 +45,12 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void Draw() {}
|
||||
virtual void Update(float elapsed_seconds) {}
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent*) override;
|
||||
|
||||
Clock::time_point m_last_update = Clock::now();
|
||||
};
|
||||
|
||||
class SquareIndicator : public MappingIndicator
|
||||
|
@ -98,6 +101,7 @@ public:
|
|||
|
||||
private:
|
||||
void Draw() override;
|
||||
void Update(float elapsed_seconds) override;
|
||||
|
||||
ControllerEmu::Tilt& m_group;
|
||||
WiimoteEmu::MotionState m_motion_state{};
|
||||
|
@ -132,6 +136,7 @@ public:
|
|||
|
||||
private:
|
||||
void Draw() override;
|
||||
void Update(float elapsed_seconds) override;
|
||||
|
||||
void DrawUnderGate(QPainter& p) override;
|
||||
|
||||
|
@ -146,11 +151,19 @@ public:
|
|||
|
||||
private:
|
||||
void Draw() override;
|
||||
void Update(float elapsed_seconds) override;
|
||||
|
||||
ControllerEmu::Shake& m_shake_group;
|
||||
WiimoteEmu::MotionState m_motion_state{};
|
||||
std::deque<ControllerEmu::Shake::StateData> m_position_samples;
|
||||
int m_grid_line_position = 0;
|
||||
|
||||
struct ShakeSample
|
||||
{
|
||||
ControllerEmu::Shake::StateData state;
|
||||
float age = 0.f;
|
||||
};
|
||||
|
||||
std::deque<ShakeSample> m_position_samples;
|
||||
float m_grid_line_position = 0;
|
||||
};
|
||||
|
||||
class AccelerometerMappingIndicator : public SquareIndicator
|
||||
|
@ -174,11 +187,12 @@ public:
|
|||
|
||||
private:
|
||||
void Draw() override;
|
||||
void Update(float elapsed_seconds) override;
|
||||
|
||||
ControllerEmu::IMUGyroscope& m_gyro_group;
|
||||
Common::Quaternion m_state = Common::Quaternion::Identity();
|
||||
Common::Vec3 m_previous_velocity = {};
|
||||
u32 m_stable_steps = 0;
|
||||
float m_stable_time = 0;
|
||||
};
|
||||
|
||||
class IRPassthroughMappingIndicator : public SquareIndicator
|
||||
|
|
|
@ -228,6 +228,8 @@ void MappingWidget::AddSettingWidgets(QFormLayout* layout, ControllerEmu::Contro
|
|||
const auto hbox = new QHBoxLayout;
|
||||
|
||||
hbox->addWidget(setting_widget);
|
||||
setting_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
hbox->addWidget(CreateSettingAdvancedMappingButton(*setting));
|
||||
|
||||
layout->addRow(tr(setting->GetUIName()), hbox);
|
||||
|
|
|
@ -27,8 +27,6 @@ class NumericSettingBase;
|
|||
enum class SettingVisibility;
|
||||
} // namespace ControllerEmu
|
||||
|
||||
constexpr int INDICATOR_UPDATE_FREQ = 30;
|
||||
|
||||
class MappingWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QScreen>
|
||||
#include <QTabWidget>
|
||||
#include <QTimer>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HotkeyManager.h"
|
||||
|
||||
#include "Common/CommonPaths.h"
|
||||
|
@ -73,12 +73,15 @@ MappingWindow::MappingWindow(QWidget* parent, Type type, int port_num)
|
|||
SetMappingType(type);
|
||||
|
||||
const auto timer = new QTimer(this);
|
||||
connect(timer, &QTimer::timeout, this, [this] {
|
||||
connect(timer, &QTimer::timeout, this, [this, timer] {
|
||||
const double refresh_rate = screen()->refreshRate();
|
||||
timer->setInterval(1000 / refresh_rate);
|
||||
|
||||
const auto lock = GetController()->GetStateLock();
|
||||
emit Update();
|
||||
});
|
||||
|
||||
timer->start(1000 / INDICATOR_UPDATE_FREQ);
|
||||
timer->start(100);
|
||||
|
||||
const auto lock = GetController()->GetStateLock();
|
||||
emit ConfigChanged();
|
||||
|
|
|
@ -379,6 +379,12 @@ void CodeWidget::UpdateSymbols()
|
|||
{
|
||||
QString name = QString::fromStdString(symbol.second.name);
|
||||
|
||||
// If the symbol has an object name, add it to the entry name.
|
||||
if (!symbol.second.object_name.empty())
|
||||
{
|
||||
name += QString::fromStdString(fmt::format(" ({})", symbol.second.object_name));
|
||||
}
|
||||
|
||||
auto* item = new QListWidgetItem(name);
|
||||
if (name == selection)
|
||||
item->setSelected(true);
|
||||
|
@ -408,8 +414,17 @@ void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
|
|||
|
||||
if (call_symbol)
|
||||
{
|
||||
const QString name =
|
||||
QString::fromStdString(fmt::format("> {} ({:08x})", call_symbol->name, addr));
|
||||
QString name;
|
||||
|
||||
if (!call_symbol->object_name.empty())
|
||||
{
|
||||
name = QString::fromStdString(
|
||||
fmt::format("< {} ({}, {:08x})", call_symbol->name, call_symbol->object_name, addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
name = QString::fromStdString(fmt::format("< {} ({:08x})", call_symbol->name, addr));
|
||||
}
|
||||
|
||||
if (!name.contains(filter, Qt::CaseInsensitive))
|
||||
continue;
|
||||
|
@ -433,8 +448,17 @@ void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
|
|||
|
||||
if (caller_symbol)
|
||||
{
|
||||
const QString name =
|
||||
QString::fromStdString(fmt::format("< {} ({:08x})", caller_symbol->name, addr));
|
||||
QString name;
|
||||
|
||||
if (!caller_symbol->object_name.empty())
|
||||
{
|
||||
name = QString::fromStdString(fmt::format("< {} ({}, {:08x})", caller_symbol->name,
|
||||
caller_symbol->object_name, addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
name = QString::fromStdString(fmt::format("< {} ({:08x})", caller_symbol->name, addr));
|
||||
}
|
||||
|
||||
if (!name.contains(filter, Qt::CaseInsensitive))
|
||||
continue;
|
||||
|
|
|
@ -271,6 +271,12 @@ void Host_PPCSymbolsChanged()
|
|||
QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->PPCSymbolsChanged(); });
|
||||
}
|
||||
|
||||
void Host_PPCBreakpointsChanged()
|
||||
{
|
||||
QueueOnObject(QApplication::instance(),
|
||||
[] { emit Host::GetInstance()->PPCBreakpointsChanged(); });
|
||||
}
|
||||
|
||||
// We ignore these, and their purpose should be questioned individually.
|
||||
// In particular, RequestRenderWindowSize, RequestFullscreen, and
|
||||
// UpdateMainFrame should almost certainly be removed.
|
||||
|
|
|
@ -82,12 +82,7 @@ void GeneralPane::OnEmulationStateChanged(Core::State state)
|
|||
const bool running = state != Core::State::Uninitialized;
|
||||
|
||||
m_checkbox_dualcore->setEnabled(!running);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
bool hardcore = AchievementManager::GetInstance().IsHardcoreModeActive();
|
||||
m_checkbox_cheats->setEnabled(!running && !hardcore);
|
||||
#else // USE_RETRO_ACHIEVEMENTS
|
||||
m_checkbox_cheats->setEnabled(!running);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
m_checkbox_override_region_settings->setEnabled(!running);
|
||||
#ifdef USE_DISCORD_PRESENCE
|
||||
m_checkbox_discord_presence->setEnabled(!running);
|
||||
|
|
|
@ -25,14 +25,14 @@ IRWidget::IRWidget(QWidget* parent) : QWidget(parent)
|
|||
|
||||
void IRWidget::SetX(u16 x)
|
||||
{
|
||||
m_x = std::min(ir_max_x, x);
|
||||
m_x = std::min(IR_MAX_X, x);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void IRWidget::SetY(u16 y)
|
||||
{
|
||||
m_y = std::min(ir_max_y, y);
|
||||
m_y = std::min(IR_MAX_Y, y);
|
||||
|
||||
update();
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ void IRWidget::paintEvent(QPaintEvent* event)
|
|||
painter.drawLine(PADDING + w / 2, PADDING, PADDING + w / 2, PADDING + h);
|
||||
|
||||
// convert from value space to widget space
|
||||
u16 x = PADDING + ((m_x * w) / ir_max_x);
|
||||
u16 y = PADDING + (h - (m_y * h) / ir_max_y);
|
||||
u16 x = PADDING + ((m_x * w) / IR_MAX_X);
|
||||
u16 y = PADDING + (h - (m_y * h) / IR_MAX_Y);
|
||||
|
||||
painter.drawLine(PADDING + w / 2, PADDING + h / 2, x, y);
|
||||
|
||||
|
@ -84,17 +84,17 @@ void IRWidget::handleMouseEvent(QMouseEvent* event)
|
|||
|
||||
if (event->button() == Qt::RightButton)
|
||||
{
|
||||
m_x = std::round(ir_max_x / 2.);
|
||||
m_y = std::round(ir_max_y / 2.);
|
||||
m_x = std::round(IR_MAX_X / 2.);
|
||||
m_y = std::round(IR_MAX_Y / 2.);
|
||||
}
|
||||
else
|
||||
{
|
||||
// convert from widget space to value space
|
||||
int new_x = (event->pos().x() * ir_max_x) / width();
|
||||
int new_y = ir_max_y - (event->pos().y() * ir_max_y) / height();
|
||||
int new_x = (event->pos().x() * IR_MAX_X) / width();
|
||||
int new_y = IR_MAX_Y - (event->pos().y() * IR_MAX_Y) / height();
|
||||
|
||||
m_x = std::max(0, std::min(static_cast<int>(ir_max_x), new_x));
|
||||
m_y = std::max(0, std::min(static_cast<int>(ir_max_y), new_y));
|
||||
m_x = std::max(0, std::min(static_cast<int>(IR_MAX_X), new_x));
|
||||
m_y = std::max(0, std::min(static_cast<int>(IR_MAX_Y), new_y));
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
|
|
|
@ -13,6 +13,11 @@ class IRWidget : public QWidget
|
|||
public:
|
||||
explicit IRWidget(QWidget* parent);
|
||||
|
||||
static constexpr u16 IR_MIN_X = 0;
|
||||
static constexpr u16 IR_MIN_Y = 0;
|
||||
static constexpr u16 IR_MAX_X = 1023;
|
||||
static constexpr u16 IR_MAX_Y = 767;
|
||||
|
||||
signals:
|
||||
void ChangedX(u16 x);
|
||||
void ChangedY(u16 y);
|
||||
|
@ -32,9 +37,3 @@ private:
|
|||
u16 m_y = 0;
|
||||
bool m_ignore_movement = false;
|
||||
};
|
||||
|
||||
// Should be part of class but fails to compile on mac os
|
||||
static const u16 ir_min_x = 0;
|
||||
static const u16 ir_min_y = 0;
|
||||
static const u16 ir_max_x = 1023;
|
||||
static const u16 ir_max_y = 767;
|
||||
|
|
|
@ -51,20 +51,20 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
|
|||
ir_x_shortcut_key_sequence.toString(QKeySequence::NativeText),
|
||||
ir_y_shortcut_key_sequence.toString(QKeySequence::NativeText)));
|
||||
|
||||
const int ir_x_center = static_cast<int>(std::round(ir_max_x / 2.));
|
||||
const int ir_y_center = static_cast<int>(std::round(ir_max_y / 2.));
|
||||
const int ir_x_center = static_cast<int>(std::round(IRWidget::IR_MAX_X / 2.));
|
||||
const int ir_y_center = static_cast<int>(std::round(IRWidget::IR_MAX_Y / 2.));
|
||||
|
||||
auto* x_layout = new QHBoxLayout;
|
||||
m_ir_x_value = CreateSliderValuePair(
|
||||
WiimoteEmu::Wiimote::IR_GROUP, ControllerEmu::ReshapableInput::X_INPUT_OVERRIDE,
|
||||
&m_wiimote_overrider, x_layout, ir_x_center, ir_x_center, ir_min_x, ir_max_x,
|
||||
ir_x_shortcut_key_sequence, Qt::Horizontal, m_ir_box);
|
||||
&m_wiimote_overrider, x_layout, ir_x_center, ir_x_center, IRWidget::IR_MIN_X,
|
||||
IRWidget::IR_MAX_X, ir_x_shortcut_key_sequence, Qt::Horizontal, m_ir_box);
|
||||
|
||||
auto* y_layout = new QVBoxLayout;
|
||||
m_ir_y_value = CreateSliderValuePair(
|
||||
WiimoteEmu::Wiimote::IR_GROUP, ControllerEmu::ReshapableInput::Y_INPUT_OVERRIDE,
|
||||
&m_wiimote_overrider, y_layout, ir_y_center, ir_y_center, ir_min_y, ir_max_y,
|
||||
ir_y_shortcut_key_sequence, Qt::Vertical, m_ir_box);
|
||||
&m_wiimote_overrider, y_layout, ir_y_center, ir_y_center, IRWidget::IR_MIN_Y,
|
||||
IRWidget::IR_MAX_Y, ir_y_shortcut_key_sequence, Qt::Vertical, m_ir_box);
|
||||
m_ir_y_value->setMaximumWidth(60);
|
||||
|
||||
auto* visual = new IRWidget(this);
|
||||
|
@ -76,7 +76,7 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
|
|||
connect(visual, &IRWidget::ChangedX, m_ir_x_value, &QSpinBox::setValue);
|
||||
connect(visual, &IRWidget::ChangedY, m_ir_y_value, &QSpinBox::setValue);
|
||||
|
||||
auto* visual_ar = new AspectRatioWidget(visual, ir_max_x, ir_max_y);
|
||||
auto* visual_ar = new AspectRatioWidget(visual, IRWidget::IR_MAX_X, IRWidget::IR_MAX_Y);
|
||||
|
||||
auto* visual_layout = new QHBoxLayout;
|
||||
visual_layout->addWidget(visual_ar);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue