Address review comments and fix code compilation
This commit is contained in:
parent
e6bd1fd1b8
commit
d176feffad
13 changed files with 218 additions and 155 deletions
|
@ -175,9 +175,11 @@ const GCButtonFactory* InputSubsystem::GetGCButtons() const {
|
||||||
return impl->gcbuttons.get();
|
return impl->gcbuttons.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReloadInputDevices() {
|
void InputSubsystem::ReloadInputDevices() {
|
||||||
if (udp)
|
if (!impl->udp) {
|
||||||
udp->ReloadUDPClient();
|
return;
|
||||||
|
}
|
||||||
|
impl->udp->ReloadUDPClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers(
|
std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers(
|
||||||
|
|
|
@ -118,6 +118,8 @@ public:
|
||||||
/// Retrieves the underlying GameCube button handler.
|
/// Retrieves the underlying GameCube button handler.
|
||||||
[[nodiscard]] const GCButtonFactory* GetGCButtons() const;
|
[[nodiscard]] const GCButtonFactory* GetGCButtons() const;
|
||||||
|
|
||||||
|
void ReloadInputDevices();
|
||||||
|
|
||||||
/// Get all DevicePoller from all backends for a specific device type
|
/// Get all DevicePoller from all backends for a specific device type
|
||||||
[[nodiscard]] std::vector<std::unique_ptr<Polling::DevicePoller>> GetPollers(
|
[[nodiscard]] std::vector<std::unique_ptr<Polling::DevicePoller>> GetPollers(
|
||||||
Polling::DeviceType type) const;
|
Polling::DeviceType type) const;
|
||||||
|
|
|
@ -30,14 +30,15 @@ public:
|
||||||
static_cast<int>(Layout::ScreenUndocked::Width);
|
static_cast<int>(Layout::ScreenUndocked::Width);
|
||||||
const float y = static_cast<float>(std::get<2>(m)) /
|
const float y = static_cast<float>(std::get<2>(m)) /
|
||||||
static_cast<int>(Layout::ScreenUndocked::Height);
|
static_cast<int>(Layout::ScreenUndocked::Height);
|
||||||
return std::make_tuple(x, y, true);
|
return {x, y, true};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return std::make_tuple(0.0f, 0.0f, false);
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::tuple<std::unique_ptr<Input::ButtonDevice>, int, int>> map; // button, x, y
|
// A vector of the mapped button, its x and its y-coordinate
|
||||||
|
std::vector<std::tuple<std::unique_ptr<Input::ButtonDevice>, int, int>> map;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Input::TouchDevice> TouchFromButtonFactory::Create(
|
std::unique_ptr<Input::TouchDevice> TouchFromButtonFactory::Create(
|
||||||
|
|
|
@ -420,10 +420,17 @@ void Config::ReadControlValues() {
|
||||||
ReadKeyboardValues();
|
ReadKeyboardValues();
|
||||||
ReadMouseValues();
|
ReadMouseValues();
|
||||||
ReadTouchscreenValues();
|
ReadTouchscreenValues();
|
||||||
|
ReadMotionTouchValues();
|
||||||
|
|
||||||
Settings::values.vibration_enabled =
|
Settings::values.vibration_enabled =
|
||||||
ReadSetting(QStringLiteral("vibration_enabled"), true).toBool();
|
ReadSetting(QStringLiteral("vibration_enabled"), true).toBool();
|
||||||
|
Settings::values.use_docked_mode =
|
||||||
|
ReadSetting(QStringLiteral("use_docked_mode"), false).toBool();
|
||||||
|
|
||||||
|
qt_config->endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Config::ReadMotionTouchValues() {
|
||||||
int num_touch_from_button_maps =
|
int num_touch_from_button_maps =
|
||||||
qt_config->beginReadArray(QStringLiteral("touch_from_button_maps"));
|
qt_config->beginReadArray(QStringLiteral("touch_from_button_maps"));
|
||||||
|
|
||||||
|
@ -481,10 +488,6 @@ void Config::ReadControlValues() {
|
||||||
.toInt());
|
.toInt());
|
||||||
Settings::values.udp_pad_index =
|
Settings::values.udp_pad_index =
|
||||||
static_cast<u8>(ReadSetting(QStringLiteral("udp_pad_index"), 0).toUInt());
|
static_cast<u8>(ReadSetting(QStringLiteral("udp_pad_index"), 0).toUInt());
|
||||||
Settings::values.use_docked_mode =
|
|
||||||
ReadSetting(QStringLiteral("use_docked_mode"), false).toBool();
|
|
||||||
|
|
||||||
qt_config->endGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::ReadCoreValues() {
|
void Config::ReadCoreValues() {
|
||||||
|
@ -977,6 +980,43 @@ void Config::SaveTouchscreenValues() {
|
||||||
WriteSetting(QStringLiteral("touchscreen_diameter_y"), touchscreen.diameter_y, 15);
|
WriteSetting(QStringLiteral("touchscreen_diameter_y"), touchscreen.diameter_y, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Config::SaveMotionTouchValues() {
|
||||||
|
WriteSetting(QStringLiteral("motion_device"),
|
||||||
|
QString::fromStdString(Settings::values.motion_device),
|
||||||
|
QStringLiteral("engine:motion_emu,update_period:100,sensitivity:0.01"));
|
||||||
|
WriteSetting(QStringLiteral("touch_device"),
|
||||||
|
QString::fromStdString(Settings::values.touch_device),
|
||||||
|
QStringLiteral("engine:emu_window"));
|
||||||
|
WriteSetting(QStringLiteral("use_touch_from_button"), Settings::values.use_touch_from_button,
|
||||||
|
false);
|
||||||
|
WriteSetting(QStringLiteral("touch_from_button_map"),
|
||||||
|
Settings::values.touch_from_button_map_index, 0);
|
||||||
|
WriteSetting(QStringLiteral("udp_input_address"),
|
||||||
|
QString::fromStdString(Settings::values.udp_input_address),
|
||||||
|
QString::fromUtf8(InputCommon::CemuhookUDP::DEFAULT_ADDR));
|
||||||
|
WriteSetting(QStringLiteral("udp_input_port"), Settings::values.udp_input_port,
|
||||||
|
InputCommon::CemuhookUDP::DEFAULT_PORT);
|
||||||
|
WriteSetting(QStringLiteral("udp_pad_index"), Settings::values.udp_pad_index, 0);
|
||||||
|
|
||||||
|
qt_config->beginWriteArray(QStringLiteral("touch_from_button_maps"));
|
||||||
|
for (std::size_t p = 0; p < Settings::values.touch_from_button_maps.size(); ++p) {
|
||||||
|
qt_config->setArrayIndex(static_cast<int>(p));
|
||||||
|
WriteSetting(QStringLiteral("name"),
|
||||||
|
QString::fromStdString(Settings::values.touch_from_button_maps[p].name),
|
||||||
|
QStringLiteral("default"));
|
||||||
|
qt_config->beginWriteArray(QStringLiteral("entries"));
|
||||||
|
for (std::size_t q = 0; q < Settings::values.touch_from_button_maps[p].buttons.size();
|
||||||
|
++q) {
|
||||||
|
qt_config->setArrayIndex(static_cast<int>(q));
|
||||||
|
WriteSetting(
|
||||||
|
QStringLiteral("bind"),
|
||||||
|
QString::fromStdString(Settings::values.touch_from_button_maps[p].buttons[q]));
|
||||||
|
}
|
||||||
|
qt_config->endArray();
|
||||||
|
}
|
||||||
|
qt_config->endArray();
|
||||||
|
}
|
||||||
|
|
||||||
void Config::SaveValues() {
|
void Config::SaveValues() {
|
||||||
if (global) {
|
if (global) {
|
||||||
SaveControlValues();
|
SaveControlValues();
|
||||||
|
@ -1019,6 +1059,7 @@ void Config::SaveControlValues() {
|
||||||
SaveDebugValues();
|
SaveDebugValues();
|
||||||
SaveMouseValues();
|
SaveMouseValues();
|
||||||
SaveTouchscreenValues();
|
SaveTouchscreenValues();
|
||||||
|
SaveMotionTouchValues();
|
||||||
|
|
||||||
WriteSetting(QStringLiteral("vibration_enabled"), Settings::values.vibration_enabled, true);
|
WriteSetting(QStringLiteral("vibration_enabled"), Settings::values.vibration_enabled, true);
|
||||||
WriteSetting(QStringLiteral("motion_device"),
|
WriteSetting(QStringLiteral("motion_device"),
|
||||||
|
@ -1028,36 +1069,8 @@ void Config::SaveControlValues() {
|
||||||
QString::fromStdString(Settings::values.touch_device),
|
QString::fromStdString(Settings::values.touch_device),
|
||||||
QStringLiteral("engine:emu_window"));
|
QStringLiteral("engine:emu_window"));
|
||||||
WriteSetting(QStringLiteral("keyboard_enabled"), Settings::values.keyboard_enabled, false);
|
WriteSetting(QStringLiteral("keyboard_enabled"), Settings::values.keyboard_enabled, false);
|
||||||
WriteSetting(QStringLiteral("use_touch_from_button"), Settings::values.use_touch_from_button,
|
|
||||||
false);
|
|
||||||
WriteSetting(QStringLiteral("touch_from_button_map"),
|
|
||||||
Settings::values.touch_from_button_map_index, 0);
|
|
||||||
WriteSetting(QStringLiteral("udp_input_address"),
|
|
||||||
QString::fromStdString(Settings::values.udp_input_address),
|
|
||||||
QString::fromUtf8(InputCommon::CemuhookUDP::DEFAULT_ADDR));
|
|
||||||
WriteSetting(QStringLiteral("udp_input_port"), Settings::values.udp_input_port,
|
|
||||||
InputCommon::CemuhookUDP::DEFAULT_PORT);
|
|
||||||
WriteSetting(QStringLiteral("udp_pad_index"), Settings::values.udp_pad_index, 0);
|
|
||||||
WriteSetting(QStringLiteral("use_docked_mode"), Settings::values.use_docked_mode, false);
|
WriteSetting(QStringLiteral("use_docked_mode"), Settings::values.use_docked_mode, false);
|
||||||
|
|
||||||
qt_config->beginWriteArray(QStringLiteral("touch_from_button_maps"));
|
|
||||||
for (std::size_t p = 0; p < Settings::values.touch_from_button_maps.size(); ++p) {
|
|
||||||
qt_config->setArrayIndex(static_cast<int>(p));
|
|
||||||
WriteSetting(QStringLiteral("name"),
|
|
||||||
QString::fromStdString(Settings::values.touch_from_button_maps[p].name),
|
|
||||||
QStringLiteral("default"));
|
|
||||||
qt_config->beginWriteArray(QStringLiteral("entries"));
|
|
||||||
for (std::size_t q = 0; q < Settings::values.touch_from_button_maps[p].buttons.size();
|
|
||||||
++q) {
|
|
||||||
qt_config->setArrayIndex(static_cast<int>(q));
|
|
||||||
WriteSetting(
|
|
||||||
QStringLiteral("bind"),
|
|
||||||
QString::fromStdString(Settings::values.touch_from_button_maps[p].buttons[q]));
|
|
||||||
}
|
|
||||||
qt_config->endArray();
|
|
||||||
}
|
|
||||||
qt_config->endArray();
|
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ private:
|
||||||
void ReadKeyboardValues();
|
void ReadKeyboardValues();
|
||||||
void ReadMouseValues();
|
void ReadMouseValues();
|
||||||
void ReadTouchscreenValues();
|
void ReadTouchscreenValues();
|
||||||
|
void ReadMotionTouchValues();
|
||||||
|
|
||||||
// Read functions bases off the respective config section names.
|
// Read functions bases off the respective config section names.
|
||||||
void ReadAudioValues();
|
void ReadAudioValues();
|
||||||
|
@ -64,6 +65,7 @@ private:
|
||||||
void SaveDebugValues();
|
void SaveDebugValues();
|
||||||
void SaveMouseValues();
|
void SaveMouseValues();
|
||||||
void SaveTouchscreenValues();
|
void SaveTouchscreenValues();
|
||||||
|
void SaveMotionTouchValues();
|
||||||
|
|
||||||
// Save functions based off the respective config section names.
|
// Save functions based off the respective config section names.
|
||||||
void SaveAudioValues();
|
void SaveAudioValues();
|
||||||
|
|
|
@ -128,15 +128,14 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem) {
|
||||||
});
|
});
|
||||||
connect(advanced, &ConfigureInputAdvanced::CallTouchscreenConfigDialog,
|
connect(advanced, &ConfigureInputAdvanced::CallTouchscreenConfigDialog,
|
||||||
[this] { CallConfigureDialog<ConfigureTouchscreenAdvanced>(*this); });
|
[this] { CallConfigureDialog<ConfigureTouchscreenAdvanced>(*this); });
|
||||||
|
connect(advanced, &ConfigureInputAdvanced::CallMotionTouchConfigDialog,
|
||||||
|
[this, input_subsystem] {
|
||||||
|
CallConfigureDialog<ConfigureMotionTouch>(*this, input_subsystem);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->buttonClearAll, &QPushButton::clicked, [this] { ClearAll(); });
|
connect(ui->buttonClearAll, &QPushButton::clicked, [this] { ClearAll(); });
|
||||||
connect(ui->buttonRestoreDefaults, &QPushButton::clicked, [this] { RestoreDefaults(); });
|
connect(ui->buttonRestoreDefaults, &QPushButton::clicked, [this] { RestoreDefaults(); });
|
||||||
|
|
||||||
connect(ui->buttonMotionTouch, &QPushButton::clicked, [this] {
|
|
||||||
QDialog* motion_touch_dialog = new ConfigureMotionTouch(this);
|
|
||||||
return motion_touch_dialog->exec();
|
|
||||||
});
|
|
||||||
|
|
||||||
RetranslateUI();
|
RetranslateUI();
|
||||||
LoadConfiguration();
|
LoadConfiguration();
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,8 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent)
|
||||||
connect(ui->mouse_advanced, &QPushButton::clicked, this, [this] { CallMouseConfigDialog(); });
|
connect(ui->mouse_advanced, &QPushButton::clicked, this, [this] { CallMouseConfigDialog(); });
|
||||||
connect(ui->touchscreen_advanced, &QPushButton::clicked, this,
|
connect(ui->touchscreen_advanced, &QPushButton::clicked, this,
|
||||||
[this] { CallTouchscreenConfigDialog(); });
|
[this] { CallTouchscreenConfigDialog(); });
|
||||||
|
connect(ui->buttonMotionTouch, &QPushButton::clicked, this,
|
||||||
|
[this] { CallMotionTouchConfigDialog(); });
|
||||||
|
|
||||||
LoadConfiguration();
|
LoadConfiguration();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ signals:
|
||||||
void CallDebugControllerDialog();
|
void CallDebugControllerDialog();
|
||||||
void CallMouseConfigDialog();
|
void CallMouseConfigDialog();
|
||||||
void CallTouchscreenConfigDialog();
|
void CallTouchscreenConfigDialog();
|
||||||
|
void CallMotionTouchConfigDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
|
|
|
@ -8,7 +8,11 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include "common/logging/log.h"
|
||||||
|
#include "core/settings.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
|
#include "input_common/udp/client.h"
|
||||||
|
#include "input_common/udp/udp.h"
|
||||||
#include "ui_configure_motion_touch.h"
|
#include "ui_configure_motion_touch.h"
|
||||||
#include "yuzu/configuration/configure_motion_touch.h"
|
#include "yuzu/configuration/configure_motion_touch.h"
|
||||||
#include "yuzu/configuration/configure_touch_from_button.h"
|
#include "yuzu/configuration/configure_touch_from_button.h"
|
||||||
|
@ -21,8 +25,9 @@ CalibrationConfigurationDialog::CalibrationConfigurationDialog(QWidget* parent,
|
||||||
status_label = new QLabel(tr("Communicating with the server..."));
|
status_label = new QLabel(tr("Communicating with the server..."));
|
||||||
cancel_button = new QPushButton(tr("Cancel"));
|
cancel_button = new QPushButton(tr("Cancel"));
|
||||||
connect(cancel_button, &QPushButton::clicked, this, [this] {
|
connect(cancel_button, &QPushButton::clicked, this, [this] {
|
||||||
if (!completed)
|
if (!completed) {
|
||||||
job->Stop();
|
job->Stop();
|
||||||
|
}
|
||||||
accept();
|
accept();
|
||||||
});
|
});
|
||||||
layout->addWidget(status_label);
|
layout->addWidget(status_label);
|
||||||
|
@ -61,36 +66,40 @@ CalibrationConfigurationDialog::CalibrationConfigurationDialog(QWidget* parent,
|
||||||
|
|
||||||
CalibrationConfigurationDialog::~CalibrationConfigurationDialog() = default;
|
CalibrationConfigurationDialog::~CalibrationConfigurationDialog() = default;
|
||||||
|
|
||||||
void CalibrationConfigurationDialog::UpdateLabelText(QString text) {
|
void CalibrationConfigurationDialog::UpdateLabelText(const QString& text) {
|
||||||
status_label->setText(text);
|
status_label->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalibrationConfigurationDialog::UpdateButtonText(QString text) {
|
void CalibrationConfigurationDialog::UpdateButtonText(const QString& text) {
|
||||||
cancel_button->setText(text);
|
cancel_button->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::array<std::pair<const char*, const char*>, 2> MotionProviders = {
|
constexpr std::array<std::pair<const char*, const char*>, 2> MotionProviders = {{
|
||||||
{{"motion_emu", QT_TRANSLATE_NOOP("ConfigureMotionTouch", "Mouse (Right Click)")},
|
{"motion_emu", QT_TRANSLATE_NOOP("ConfigureMotionTouch", "Mouse (Right Click)")},
|
||||||
{"cemuhookudp", QT_TRANSLATE_NOOP("ConfigureMotionTouch", "CemuhookUDP")}}};
|
{"cemuhookudp", QT_TRANSLATE_NOOP("ConfigureMotionTouch", "CemuhookUDP")},
|
||||||
|
}};
|
||||||
|
|
||||||
const std::array<std::pair<const char*, const char*>, 2> TouchProviders = {
|
constexpr std::array<std::pair<const char*, const char*>, 2> TouchProviders = {{
|
||||||
{{"emu_window", QT_TRANSLATE_NOOP("ConfigureMotionTouch", "Emulator Window")},
|
{"emu_window", QT_TRANSLATE_NOOP("ConfigureMotionTouch", "Emulator Window")},
|
||||||
{"cemuhookudp", QT_TRANSLATE_NOOP("ConfigureMotionTouch", "CemuhookUDP")}}};
|
{"cemuhookudp", QT_TRANSLATE_NOOP("ConfigureMotionTouch", "CemuhookUDP")},
|
||||||
|
}};
|
||||||
|
|
||||||
ConfigureMotionTouch::ConfigureMotionTouch(QWidget* parent)
|
ConfigureMotionTouch::ConfigureMotionTouch(QWidget* parent,
|
||||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigureMotionTouch>()) {
|
InputCommon::InputSubsystem* input_subsystem_)
|
||||||
|
: QDialog(parent), input_subsystem{input_subsystem_},
|
||||||
|
ui(std::make_unique<Ui::ConfigureMotionTouch>()) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
for (auto [provider, name] : MotionProviders) {
|
for (const auto [provider, name] : MotionProviders) {
|
||||||
ui->motion_provider->addItem(tr(name), QString::fromUtf8(provider));
|
ui->motion_provider->addItem(tr(name), QString::fromUtf8(provider));
|
||||||
}
|
}
|
||||||
for (auto [provider, name] : TouchProviders) {
|
for (const auto [provider, name] : TouchProviders) {
|
||||||
ui->touch_provider->addItem(tr(name), QString::fromUtf8(provider));
|
ui->touch_provider->addItem(tr(name), QString::fromUtf8(provider));
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->udp_learn_more->setOpenExternalLinks(true);
|
ui->udp_learn_more->setOpenExternalLinks(true);
|
||||||
ui->udp_learn_more->setText(
|
ui->udp_learn_more->setText(
|
||||||
tr("<a "
|
tr("<a "
|
||||||
"href='https://citra-emu.org/wiki/"
|
"href='https://yuzu-emu.org/wiki/"
|
||||||
"using-a-controller-or-android-phone-for-motion-or-touch-input'><span "
|
"using-a-controller-or-android-phone-for-motion-or-touch-input'><span "
|
||||||
"style=\"text-decoration: underline; color:#039be5;\">Learn More</span></a>"));
|
"style=\"text-decoration: underline; color:#039be5;\">Learn More</span></a>"));
|
||||||
|
|
||||||
|
@ -130,10 +139,11 @@ void ConfigureMotionTouch::SetConfiguration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureMotionTouch::UpdateUiDisplay() {
|
void ConfigureMotionTouch::UpdateUiDisplay() {
|
||||||
std::string motion_engine = ui->motion_provider->currentData().toString().toStdString();
|
const QString motion_engine = ui->motion_provider->currentData().toString();
|
||||||
std::string touch_engine = ui->touch_provider->currentData().toString().toStdString();
|
const QString touch_engine = ui->touch_provider->currentData().toString();
|
||||||
|
QString cemuhook_udp = QStringLiteral("cemuhookudp");
|
||||||
|
|
||||||
if (motion_engine == "motion_emu") {
|
if (motion_engine == QStringLiteral("motion_emu")) {
|
||||||
ui->motion_sensitivity_label->setVisible(true);
|
ui->motion_sensitivity_label->setVisible(true);
|
||||||
ui->motion_sensitivity->setVisible(true);
|
ui->motion_sensitivity->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -141,20 +151,19 @@ void ConfigureMotionTouch::UpdateUiDisplay() {
|
||||||
ui->motion_sensitivity->setVisible(false);
|
ui->motion_sensitivity->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (touch_engine == "cemuhookudp") {
|
if (touch_engine == cemuhook_udp) {
|
||||||
ui->touch_calibration->setVisible(true);
|
ui->touch_calibration->setVisible(true);
|
||||||
ui->touch_calibration_config->setVisible(true);
|
ui->touch_calibration_config->setVisible(true);
|
||||||
ui->touch_calibration_label->setVisible(true);
|
ui->touch_calibration_label->setVisible(true);
|
||||||
ui->touch_calibration->setText(QStringLiteral("(%1, %2) - (%3, %4)")
|
ui->touch_calibration->setText(
|
||||||
.arg(QString::number(min_x), QString::number(min_y),
|
QStringLiteral("(%1, %2) - (%3, %4)").arg(min_x).arg(min_y).arg(max_x).arg(max_y));
|
||||||
QString::number(max_x), QString::number(max_y)));
|
|
||||||
} else {
|
} else {
|
||||||
ui->touch_calibration->setVisible(false);
|
ui->touch_calibration->setVisible(false);
|
||||||
ui->touch_calibration_config->setVisible(false);
|
ui->touch_calibration_config->setVisible(false);
|
||||||
ui->touch_calibration_label->setVisible(false);
|
ui->touch_calibration_label->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (motion_engine == "cemuhookudp" || touch_engine == "cemuhookudp") {
|
if (motion_engine == cemuhook_udp || touch_engine == cemuhook_udp) {
|
||||||
ui->udp_config_group_box->setVisible(true);
|
ui->udp_config_group_box->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
ui->udp_config_group_box->setVisible(false);
|
ui->udp_config_group_box->setVisible(false);
|
||||||
|
@ -162,11 +171,9 @@ void ConfigureMotionTouch::UpdateUiDisplay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureMotionTouch::ConnectEvents() {
|
void ConfigureMotionTouch::ConnectEvents() {
|
||||||
connect(ui->motion_provider,
|
connect(ui->motion_provider, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
|
||||||
[this](int index) { UpdateUiDisplay(); });
|
[this](int index) { UpdateUiDisplay(); });
|
||||||
connect(ui->touch_provider,
|
connect(ui->touch_provider, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
|
||||||
[this](int index) { UpdateUiDisplay(); });
|
[this](int index) { UpdateUiDisplay(); });
|
||||||
connect(ui->udp_test, &QPushButton::clicked, this, &ConfigureMotionTouch::OnCemuhookUDPTest);
|
connect(ui->udp_test, &QPushButton::clicked, this, &ConfigureMotionTouch::OnCemuhookUDPTest);
|
||||||
connect(ui->touch_calibration_config, &QPushButton::clicked, this,
|
connect(ui->touch_calibration_config, &QPushButton::clicked, this,
|
||||||
|
@ -174,8 +181,9 @@ void ConfigureMotionTouch::ConnectEvents() {
|
||||||
connect(ui->touch_from_button_config_btn, &QPushButton::clicked, this,
|
connect(ui->touch_from_button_config_btn, &QPushButton::clicked, this,
|
||||||
&ConfigureMotionTouch::OnConfigureTouchFromButton);
|
&ConfigureMotionTouch::OnConfigureTouchFromButton);
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [this] {
|
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [this] {
|
||||||
if (CanCloseDialog())
|
if (CanCloseDialog()) {
|
||||||
reject();
|
reject();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,15 +207,15 @@ void ConfigureMotionTouch::OnCemuhookUDPTest() {
|
||||||
void ConfigureMotionTouch::OnConfigureTouchCalibration() {
|
void ConfigureMotionTouch::OnConfigureTouchCalibration() {
|
||||||
ui->touch_calibration_config->setEnabled(false);
|
ui->touch_calibration_config->setEnabled(false);
|
||||||
ui->touch_calibration_config->setText(tr("Configuring"));
|
ui->touch_calibration_config->setText(tr("Configuring"));
|
||||||
CalibrationConfigurationDialog* dialog = new CalibrationConfigurationDialog(
|
CalibrationConfigurationDialog dialog(
|
||||||
this, ui->udp_server->text().toStdString(), static_cast<u16>(ui->udp_port->text().toUInt()),
|
this, ui->udp_server->text().toStdString(), static_cast<u16>(ui->udp_port->text().toUInt()),
|
||||||
static_cast<u8>(ui->udp_pad_index->currentIndex()), 24872);
|
static_cast<u8>(ui->udp_pad_index->currentIndex()), 24872);
|
||||||
dialog->exec();
|
dialog.exec();
|
||||||
if (dialog->completed) {
|
if (dialog.completed) {
|
||||||
min_x = dialog->min_x;
|
min_x = dialog.min_x;
|
||||||
min_y = dialog->min_y;
|
min_y = dialog.min_y;
|
||||||
max_x = dialog->max_x;
|
max_x = dialog.max_x;
|
||||||
max_y = dialog->max_y;
|
max_y = dialog.max_y;
|
||||||
LOG_INFO(Frontend,
|
LOG_INFO(Frontend,
|
||||||
"UDP touchpad calibration config success: min_x={}, min_y={}, max_x={}, max_y={}",
|
"UDP touchpad calibration config success: min_x={}, min_y={}, max_x={}, max_y={}",
|
||||||
min_x, min_y, max_x, max_y);
|
min_x, min_y, max_x, max_y);
|
||||||
|
@ -220,10 +228,11 @@ void ConfigureMotionTouch::OnConfigureTouchCalibration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureMotionTouch::closeEvent(QCloseEvent* event) {
|
void ConfigureMotionTouch::closeEvent(QCloseEvent* event) {
|
||||||
if (CanCloseDialog())
|
if (CanCloseDialog()) {
|
||||||
event->accept();
|
event->accept();
|
||||||
else
|
} else {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureMotionTouch::ShowUDPTestResult(bool result) {
|
void ConfigureMotionTouch::ShowUDPTestResult(bool result) {
|
||||||
|
@ -242,7 +251,7 @@ void ConfigureMotionTouch::ShowUDPTestResult(bool result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureMotionTouch::OnConfigureTouchFromButton() {
|
void ConfigureMotionTouch::OnConfigureTouchFromButton() {
|
||||||
ConfigureTouchFromButton dialog{this, touch_from_button_maps,
|
ConfigureTouchFromButton dialog{this, touch_from_button_maps, input_subsystem,
|
||||||
ui->touch_from_button_map->currentIndex()};
|
ui->touch_from_button_map->currentIndex()};
|
||||||
if (dialog.exec() != QDialog::Accepted) {
|
if (dialog.exec() != QDialog::Accepted) {
|
||||||
return;
|
return;
|
||||||
|
@ -269,8 +278,9 @@ bool ConfigureMotionTouch::CanCloseDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureMotionTouch::ApplyConfiguration() {
|
void ConfigureMotionTouch::ApplyConfiguration() {
|
||||||
if (!CanCloseDialog())
|
if (!CanCloseDialog()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::string motion_engine = ui->motion_provider->currentData().toString().toStdString();
|
std::string motion_engine = ui->motion_provider->currentData().toString().toStdString();
|
||||||
std::string touch_engine = ui->touch_provider->currentData().toString().toStdString();
|
std::string touch_engine = ui->touch_provider->currentData().toString().toStdString();
|
||||||
|
@ -298,7 +308,7 @@ void ConfigureMotionTouch::ApplyConfiguration() {
|
||||||
Settings::values.udp_input_address = ui->udp_server->text().toStdString();
|
Settings::values.udp_input_address = ui->udp_server->text().toStdString();
|
||||||
Settings::values.udp_input_port = static_cast<u16>(ui->udp_port->text().toInt());
|
Settings::values.udp_input_port = static_cast<u16>(ui->udp_port->text().toInt());
|
||||||
Settings::values.udp_pad_index = static_cast<u8>(ui->udp_pad_index->currentIndex());
|
Settings::values.udp_pad_index = static_cast<u8>(ui->udp_pad_index->currentIndex());
|
||||||
InputCommon::ReloadInputDevices();
|
input_subsystem->ReloadInputDevices();
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,29 +7,30 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
#include "core/settings.h"
|
|
||||||
#include "input_common/udp/client.h"
|
|
||||||
#include "input_common/udp/udp.h"
|
|
||||||
|
|
||||||
class QVBoxLayout;
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QVBoxLayout;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConfigureMotionTouch;
|
class ConfigureMotionTouch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace InputCommon::CemuhookUDP {
|
||||||
|
class CalibrationConfigurationJob;
|
||||||
|
}
|
||||||
|
|
||||||
/// A dialog for touchpad calibration configuration.
|
/// A dialog for touchpad calibration configuration.
|
||||||
class CalibrationConfigurationDialog : public QDialog {
|
class CalibrationConfigurationDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CalibrationConfigurationDialog(QWidget* parent, const std::string& host, u16 port,
|
explicit CalibrationConfigurationDialog(QWidget* parent, const std::string& host, u16 port,
|
||||||
u8 pad_index, u16 client_id);
|
u8 pad_index, u16 client_id);
|
||||||
~CalibrationConfigurationDialog();
|
~CalibrationConfigurationDialog() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_INVOKABLE void UpdateLabelText(QString text);
|
Q_INVOKABLE void UpdateLabelText(const QString& text);
|
||||||
Q_INVOKABLE void UpdateButtonText(QString text);
|
Q_INVOKABLE void UpdateButtonText(const QString& text);
|
||||||
|
|
||||||
QVBoxLayout* layout;
|
QVBoxLayout* layout;
|
||||||
QLabel* status_label;
|
QLabel* status_label;
|
||||||
|
@ -38,7 +39,10 @@ private:
|
||||||
|
|
||||||
// Configuration results
|
// Configuration results
|
||||||
bool completed{};
|
bool completed{};
|
||||||
u16 min_x, min_y, max_x, max_y;
|
u16 min_x{};
|
||||||
|
u16 min_y{};
|
||||||
|
u16 max_x{};
|
||||||
|
u16 max_y{};
|
||||||
|
|
||||||
friend class ConfigureMotionTouch;
|
friend class ConfigureMotionTouch;
|
||||||
};
|
};
|
||||||
|
@ -47,7 +51,7 @@ class ConfigureMotionTouch : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConfigureMotionTouch(QWidget* parent = nullptr);
|
explicit ConfigureMotionTouch(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_);
|
||||||
~ConfigureMotionTouch() override;
|
~ConfigureMotionTouch() override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -69,9 +73,14 @@ private:
|
||||||
std::unique_ptr<Ui::ConfigureMotionTouch> ui;
|
std::unique_ptr<Ui::ConfigureMotionTouch> ui;
|
||||||
|
|
||||||
// Coordinate system of the CemuhookUDP touch provider
|
// Coordinate system of the CemuhookUDP touch provider
|
||||||
int min_x, min_y, max_x, max_y;
|
int min_x{};
|
||||||
|
int min_y{};
|
||||||
|
int max_x{};
|
||||||
|
int max_y{};
|
||||||
|
|
||||||
bool udp_test_in_progress{};
|
bool udp_test_in_progress{};
|
||||||
|
|
||||||
|
InputCommon::InputSubsystem* input_subsystem;
|
||||||
|
|
||||||
std::vector<Settings::TouchFromButtonMap> touch_from_button_maps;
|
std::vector<Settings::TouchFromButtonMap> touch_from_button_maps;
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
|
#include "core/frontend/framebuffer_layout.h"
|
||||||
|
#include "core/settings.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
#include "ui_configure_touch_from_button.h"
|
#include "ui_configure_touch_from_button.h"
|
||||||
#include "yuzu/configuration/configure_touch_from_button.h"
|
#include "yuzu/configuration/configure_touch_from_button.h"
|
||||||
|
@ -68,15 +70,16 @@ static QString ButtonToText(const Common::ParamPackage& param) {
|
||||||
|
|
||||||
ConfigureTouchFromButton::ConfigureTouchFromButton(
|
ConfigureTouchFromButton::ConfigureTouchFromButton(
|
||||||
QWidget* parent, const std::vector<Settings::TouchFromButtonMap>& touch_maps,
|
QWidget* parent, const std::vector<Settings::TouchFromButtonMap>& touch_maps,
|
||||||
const int default_index)
|
InputCommon::InputSubsystem* input_subsystem_, const int default_index)
|
||||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigureTouchFromButton>()), touch_maps(touch_maps),
|
: QDialog(parent), ui(std::make_unique<Ui::ConfigureTouchFromButton>()),
|
||||||
selected_index(default_index), timeout_timer(std::make_unique<QTimer>()),
|
touch_maps(touch_maps), input_subsystem{input_subsystem_}, selected_index(default_index),
|
||||||
poll_timer(std::make_unique<QTimer>()) {
|
timeout_timer(std::make_unique<QTimer>()), poll_timer(std::make_unique<QTimer>()) {
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
binding_list_model = std::make_unique<QStandardItemModel>(0, 3, this);
|
binding_list_model = new QStandardItemModel(0, 3, this);
|
||||||
binding_list_model->setHorizontalHeaderLabels({tr("Button"), tr("X"), tr("Y")});
|
binding_list_model->setHorizontalHeaderLabels(
|
||||||
ui->binding_list->setModel(binding_list_model.get());
|
{tr("Button"), tr("X", "X axis"), tr("Y", "Y axis")});
|
||||||
|
ui->binding_list->setModel(binding_list_model);
|
||||||
ui->bottom_screen->SetCoordLabel(ui->coord_label);
|
ui->bottom_screen->SetCoordLabel(ui->coord_label);
|
||||||
|
|
||||||
SetConfiguration();
|
SetConfiguration();
|
||||||
|
@ -92,11 +95,12 @@ void ConfigureTouchFromButton::showEvent(QShowEvent* ev) {
|
||||||
// width values are not valid in the constructor
|
// width values are not valid in the constructor
|
||||||
const int w =
|
const int w =
|
||||||
ui->binding_list->viewport()->contentsRect().width() / binding_list_model->columnCount();
|
ui->binding_list->viewport()->contentsRect().width() / binding_list_model->columnCount();
|
||||||
if (w > 0) {
|
if (w <= 0) {
|
||||||
ui->binding_list->setColumnWidth(0, w);
|
return;
|
||||||
ui->binding_list->setColumnWidth(1, w);
|
|
||||||
ui->binding_list->setColumnWidth(2, w);
|
|
||||||
}
|
}
|
||||||
|
ui->binding_list->setColumnWidth(0, w);
|
||||||
|
ui->binding_list->setColumnWidth(1, w);
|
||||||
|
ui->binding_list->setColumnWidth(2, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureTouchFromButton::SetConfiguration() {
|
void ConfigureTouchFromButton::SetConfiguration() {
|
||||||
|
@ -122,7 +126,7 @@ void ConfigureTouchFromButton::UpdateUiDisplay() {
|
||||||
QStandardItem* ycoord = new QStandardItem(QString::number(package.Get("y", 0)));
|
QStandardItem* ycoord = new QStandardItem(QString::number(package.Get("y", 0)));
|
||||||
binding_list_model->appendRow({button, xcoord, ycoord});
|
binding_list_model->appendRow({button, xcoord, ycoord});
|
||||||
|
|
||||||
int dot = ui->bottom_screen->AddDot(package.Get("x", 0), package.Get("y", 0));
|
const int dot = ui->bottom_screen->AddDot(package.Get("x", 0), package.Get("y", 0));
|
||||||
button->setData(dot, DataRoleDot);
|
button->setData(dot, DataRoleDot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +148,7 @@ void ConfigureTouchFromButton::ConnectEvents() {
|
||||||
&ConfigureTouchFromButton::EditBinding);
|
&ConfigureTouchFromButton::EditBinding);
|
||||||
connect(ui->binding_list->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
connect(ui->binding_list->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||||
&ConfigureTouchFromButton::OnBindingSelection);
|
&ConfigureTouchFromButton::OnBindingSelection);
|
||||||
connect(binding_list_model.get(), &QStandardItemModel::itemChanged, this,
|
connect(binding_list_model, &QStandardItemModel::itemChanged, this,
|
||||||
&ConfigureTouchFromButton::OnBindingChanged);
|
&ConfigureTouchFromButton::OnBindingChanged);
|
||||||
connect(ui->binding_list->model(), &QStandardItemModel::rowsAboutToBeRemoved, this,
|
connect(ui->binding_list->model(), &QStandardItemModel::rowsAboutToBeRemoved, this,
|
||||||
&ConfigureTouchFromButton::OnBindingDeleted);
|
&ConfigureTouchFromButton::OnBindingDeleted);
|
||||||
|
@ -231,7 +235,7 @@ void ConfigureTouchFromButton::GetButtonInput(const int row_index, const bool is
|
||||||
|
|
||||||
input_setter = [this, row_index, is_new](const Common::ParamPackage& params,
|
input_setter = [this, row_index, is_new](const Common::ParamPackage& params,
|
||||||
const bool cancel) {
|
const bool cancel) {
|
||||||
auto cell = binding_list_model->item(row_index, 0);
|
auto* cell = binding_list_model->item(row_index, 0);
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
if (is_new) {
|
if (is_new) {
|
||||||
binding_list_model->removeRow(row_index);
|
binding_list_model->removeRow(row_index);
|
||||||
|
@ -245,7 +249,7 @@ void ConfigureTouchFromButton::GetButtonInput(const int row_index, const bool is
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
device_pollers = InputCommon::Polling::GetPollers(InputCommon::Polling::DeviceType::Button);
|
device_pollers = input_subsystem->GetPollers(InputCommon::Polling::DeviceType::Button);
|
||||||
|
|
||||||
for (auto& poller : device_pollers) {
|
for (auto& poller : device_pollers) {
|
||||||
poller->Start();
|
poller->Start();
|
||||||
|
@ -259,15 +263,15 @@ void ConfigureTouchFromButton::GetButtonInput(const int row_index, const bool is
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureTouchFromButton::NewBinding(const QPoint& pos) {
|
void ConfigureTouchFromButton::NewBinding(const QPoint& pos) {
|
||||||
QStandardItem* button = new QStandardItem();
|
auto* button = new QStandardItem();
|
||||||
button->setEditable(false);
|
button->setEditable(false);
|
||||||
QStandardItem* xcoord = new QStandardItem(QString::number(pos.x()));
|
auto* x_coord = new QStandardItem(QString::number(pos.x()));
|
||||||
QStandardItem* ycoord = new QStandardItem(QString::number(pos.y()));
|
auto* y_coord = new QStandardItem(QString::number(pos.y()));
|
||||||
|
|
||||||
const int dot_id = ui->bottom_screen->AddDot(pos.x(), pos.y());
|
const int dot_id = ui->bottom_screen->AddDot(pos.x(), pos.y());
|
||||||
button->setData(dot_id, DataRoleDot);
|
button->setData(dot_id, DataRoleDot);
|
||||||
|
|
||||||
binding_list_model->appendRow({button, xcoord, ycoord});
|
binding_list_model->appendRow({button, x_coord, y_coord});
|
||||||
ui->binding_list->setFocus();
|
ui->binding_list->setFocus();
|
||||||
ui->binding_list->setCurrentIndex(button->index());
|
ui->binding_list->setCurrentIndex(button->index());
|
||||||
|
|
||||||
|
@ -282,11 +286,11 @@ void ConfigureTouchFromButton::EditBinding(const QModelIndex& qi) {
|
||||||
|
|
||||||
void ConfigureTouchFromButton::DeleteBinding() {
|
void ConfigureTouchFromButton::DeleteBinding() {
|
||||||
const int row_index = ui->binding_list->currentIndex().row();
|
const int row_index = ui->binding_list->currentIndex().row();
|
||||||
if (row_index >= 0) {
|
if (row_index < 0) {
|
||||||
ui->bottom_screen->RemoveDot(
|
return;
|
||||||
binding_list_model->index(row_index, 0).data(DataRoleDot).toInt());
|
|
||||||
binding_list_model->removeRow(row_index);
|
|
||||||
}
|
}
|
||||||
|
ui->bottom_screen->RemoveDot(binding_list_model->index(row_index, 0).data(DataRoleDot).toInt());
|
||||||
|
binding_list_model->removeRow(row_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureTouchFromButton::OnBindingSelection(const QItemSelection& selected,
|
void ConfigureTouchFromButton::OnBindingSelection(const QItemSelection& selected,
|
||||||
|
@ -329,7 +333,7 @@ void ConfigureTouchFromButton::OnBindingChanged(QStandardItem* item) {
|
||||||
|
|
||||||
void ConfigureTouchFromButton::OnBindingDeleted(const QModelIndex& parent, int first, int last) {
|
void ConfigureTouchFromButton::OnBindingDeleted(const QModelIndex& parent, int first, int last) {
|
||||||
for (int i = first; i <= last; ++i) {
|
for (int i = first; i <= last; ++i) {
|
||||||
auto ix = binding_list_model->index(i, 0);
|
const auto ix = binding_list_model->index(i, 0);
|
||||||
if (!ix.isValid()) {
|
if (!ix.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -422,7 +426,7 @@ int TouchScreenPreview::AddDot(const int device_x, const int device_y) {
|
||||||
dot_font.setStyleHint(QFont::Monospace);
|
dot_font.setStyleHint(QFont::Monospace);
|
||||||
dot_font.setPointSize(20);
|
dot_font.setPointSize(20);
|
||||||
|
|
||||||
QLabel* dot = new QLabel(this);
|
auto* dot = new QLabel(this);
|
||||||
dot->setAttribute(Qt::WA_TranslucentBackground);
|
dot->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
dot->setFont(dot_font);
|
dot->setFont(dot_font);
|
||||||
dot->setText(QChar(0xD7)); // U+00D7 Multiplication Sign
|
dot->setText(QChar(0xD7)); // U+00D7 Multiplication Sign
|
||||||
|
@ -440,13 +444,14 @@ int TouchScreenPreview::AddDot(const int device_x, const int device_y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchScreenPreview::RemoveDot(const int id) {
|
void TouchScreenPreview::RemoveDot(const int id) {
|
||||||
for (auto dot_it = dots.begin(); dot_it != dots.end(); ++dot_it) {
|
const auto iter = std::find_if(dots.begin(), dots.end(),
|
||||||
if (dot_it->first == id) {
|
[id](const auto& entry) { return entry.first == id; });
|
||||||
dot_it->second->deleteLater();
|
if (iter == dots.cend()) {
|
||||||
dots.erase(dot_it);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iter->second->deleteLater();
|
||||||
|
dots.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchScreenPreview::HighlightDot(const int id, const bool active) const {
|
void TouchScreenPreview::HighlightDot(const int id, const bool active) const {
|
||||||
|
@ -470,14 +475,15 @@ void TouchScreenPreview::HighlightDot(const int id, const bool active) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchScreenPreview::MoveDot(const int id, const int device_x, const int device_y) const {
|
void TouchScreenPreview::MoveDot(const int id, const int device_x, const int device_y) const {
|
||||||
for (const auto& dot : dots) {
|
const auto iter = std::find_if(dots.begin(), dots.end(),
|
||||||
if (dot.first == id) {
|
[id](const auto& entry) { return entry.first == id; });
|
||||||
dot.second->setProperty(PropX, device_x);
|
if (iter == dots.cend()) {
|
||||||
dot.second->setProperty(PropY, device_y);
|
return;
|
||||||
PositionDot(dot.second, device_x, device_y);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iter->second->setProperty(PropX, device_x);
|
||||||
|
iter->second->setProperty(PropY, device_y);
|
||||||
|
PositionDot(iter->second, device_x, device_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchScreenPreview::resizeEvent(QResizeEvent* event) {
|
void TouchScreenPreview::resizeEvent(QResizeEvent* event) {
|
||||||
|
@ -521,11 +527,12 @@ void TouchScreenPreview::leaveEvent(QEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchScreenPreview::mousePressEvent(QMouseEvent* event) {
|
void TouchScreenPreview::mousePressEvent(QMouseEvent* event) {
|
||||||
if (event->button() == Qt::MouseButton::LeftButton) {
|
if (event->button() != Qt::MouseButton::LeftButton) {
|
||||||
const auto pos = MapToDeviceCoords(event->x(), event->y());
|
return;
|
||||||
if (pos) {
|
}
|
||||||
emit DotAdded(*pos);
|
const auto pos = MapToDeviceCoords(event->x(), event->y());
|
||||||
}
|
if (pos) {
|
||||||
|
emit DotAdded(*pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,12 +608,17 @@ std::optional<QPoint> TouchScreenPreview::MapToDeviceCoords(const int screen_x,
|
||||||
|
|
||||||
void TouchScreenPreview::PositionDot(QLabel* const dot, const int device_x,
|
void TouchScreenPreview::PositionDot(QLabel* const dot, const int device_x,
|
||||||
const int device_y) const {
|
const int device_y) const {
|
||||||
dot->move(static_cast<int>(
|
const float device_coord_x =
|
||||||
static_cast<float>(device_x >= 0 ? device_x : dot->property(PropX).toInt()) *
|
static_cast<float>(device_x >= 0 ? device_x : dot->property(PropX).toInt());
|
||||||
(contentsRect().width() - 1) / (Layout::ScreenUndocked::Width - 1) +
|
int x_coord = static_cast<int>(
|
||||||
contentsMargins().left() - static_cast<float>(dot->width()) / 2 + 0.5f),
|
device_coord_x * (contentsRect().width() - 1) / (Layout::ScreenUndocked::Width - 1) +
|
||||||
static_cast<int>(
|
contentsMargins().left() - static_cast<float>(dot->width()) / 2 + 0.5f);
|
||||||
static_cast<float>(device_y >= 0 ? device_y : dot->property(PropY).toInt()) *
|
|
||||||
(contentsRect().height() - 1) / (Layout::ScreenUndocked::Height - 1) +
|
const float device_coord_y =
|
||||||
contentsMargins().top() - static_cast<float>(dot->height()) / 2 + 0.5f));
|
static_cast<float>(device_y >= 0 ? device_y : dot->property(PropY).toInt());
|
||||||
|
const int y_coord = static_cast<int>(
|
||||||
|
device_coord_y * (contentsRect().height() - 1) / (Layout::ScreenUndocked::Height - 1) +
|
||||||
|
contentsMargins().top() - static_cast<float>(dot->height()) / 2 + 0.5f);
|
||||||
|
|
||||||
|
dot->move(x_coord, y_coord);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "core/frontend/framebuffer_layout.h"
|
|
||||||
#include "core/settings.h"
|
|
||||||
|
|
||||||
class QItemSelection;
|
class QItemSelection;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
@ -18,6 +16,10 @@ class QStandardItemModel;
|
||||||
class QStandardItem;
|
class QStandardItem;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
|
namespace InputCommon {
|
||||||
|
class InputSubsystem;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
class ParamPackage;
|
class ParamPackage;
|
||||||
}
|
}
|
||||||
|
@ -32,12 +34,17 @@ namespace Ui {
|
||||||
class ConfigureTouchFromButton;
|
class ConfigureTouchFromButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Settings {
|
||||||
|
struct TouchFromButtonMap;
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigureTouchFromButton : public QDialog {
|
class ConfigureTouchFromButton : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConfigureTouchFromButton(QWidget* parent,
|
explicit ConfigureTouchFromButton(QWidget* parent,
|
||||||
const std::vector<Settings::TouchFromButtonMap>& touch_maps,
|
const std::vector<Settings::TouchFromButtonMap>& touch_maps,
|
||||||
|
InputCommon::InputSubsystem* input_subsystem_,
|
||||||
int default_index = 0);
|
int default_index = 0);
|
||||||
~ConfigureTouchFromButton() override;
|
~ConfigureTouchFromButton() override;
|
||||||
|
|
||||||
|
@ -51,8 +58,8 @@ public slots:
|
||||||
void SetCoordinates(int dot_id, const QPoint& pos);
|
void SetCoordinates(int dot_id, const QPoint& pos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent* ev) override;
|
void showEvent(QShowEvent* ev) override;
|
||||||
virtual void keyPressEvent(QKeyEvent* event) override;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void NewMapping();
|
void NewMapping();
|
||||||
|
@ -73,10 +80,12 @@ private:
|
||||||
void SaveCurrentMapping();
|
void SaveCurrentMapping();
|
||||||
|
|
||||||
std::unique_ptr<Ui::ConfigureTouchFromButton> ui;
|
std::unique_ptr<Ui::ConfigureTouchFromButton> ui;
|
||||||
std::unique_ptr<QStandardItemModel> binding_list_model;
|
|
||||||
std::vector<Settings::TouchFromButtonMap> touch_maps;
|
std::vector<Settings::TouchFromButtonMap> touch_maps;
|
||||||
|
QStandardItemModel* binding_list_model;
|
||||||
int selected_index;
|
int selected_index;
|
||||||
|
|
||||||
|
InputCommon::InputSubsystem* input_subsystem;
|
||||||
|
|
||||||
std::unique_ptr<QTimer> timeout_timer;
|
std::unique_ptr<QTimer> timeout_timer;
|
||||||
std::unique_ptr<QTimer> poll_timer;
|
std::unique_ptr<QTimer> poll_timer;
|
||||||
std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers;
|
std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers;
|
||||||
|
|
|
@ -33,11 +33,11 @@ signals:
|
||||||
void DotMoved(int dot_id, const QPoint& pos);
|
void DotMoved(int dot_id, const QPoint& pos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeEvent(QResizeEvent*) override;
|
void resizeEvent(QResizeEvent*) override;
|
||||||
virtual void mouseMoveEvent(QMouseEvent*) override;
|
void mouseMoveEvent(QMouseEvent*) override;
|
||||||
virtual void leaveEvent(QEvent*) override;
|
void leaveEvent(QEvent*) override;
|
||||||
virtual void mousePressEvent(QMouseEvent*) override;
|
void mousePressEvent(QMouseEvent*) override;
|
||||||
virtual bool eventFilter(QObject*, QEvent*) override;
|
bool eventFilter(QObject*, QEvent*) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::optional<QPoint> MapToDeviceCoords(int screen_x, int screen_y) const;
|
std::optional<QPoint> MapToDeviceCoords(int screen_x, int screen_y) const;
|
||||||
|
@ -53,9 +53,10 @@ private:
|
||||||
static constexpr char PropX[] = "device_x";
|
static constexpr char PropX[] = "device_x";
|
||||||
static constexpr char PropY[] = "device_y";
|
static constexpr char PropY[] = "device_y";
|
||||||
|
|
||||||
struct {
|
struct DragState {
|
||||||
bool active = false;
|
bool active = false;
|
||||||
QPointer<QLabel> dot;
|
QPointer<QLabel> dot;
|
||||||
QPoint start_pos;
|
QPoint start_pos;
|
||||||
} drag_state;
|
};
|
||||||
|
DragState drag_state;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue