-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qt: Implement advanced mapping I/O windows #5479
Conversation
7e408cc
to
ad845f4
Compare
ad845f4
to
68dca77
Compare
#include "InputCommon/ControllerInterface/Device.h" | ||
|
||
static QString TrunicateDisplayString(const QString& string) | ||
{ |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
: QPushButton(QString::fromStdString(ref->expression)), m_parent(widget), m_reference(ref) | ||
: QPushButton(TrunicateDisplayString(QString::fromStdString(ref->expression))), | ||
m_parent(widget), m_reference(ref), | ||
m_io_window( |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Clear(); | ||
break; | ||
case Qt::MouseButton::RightButton: | ||
if (m_parent->GetParent()->GetDevice() == nullptr) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
||
void IOWindow::Update() | ||
{ | ||
if (m_controller == nullptr) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
#include <QSpinBox> | ||
#include <QVBoxLayout> | ||
|
||
static constexpr int SLIDER_TICK_COUNT = 100; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
// Options (Buttons, Outputs) and action buttons | ||
for (QPushButton* button : {m_select_button, m_detect_button, m_or_button, m_and_button, | ||
m_add_button, m_not_button, m_test_button}) | ||
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
const auto device = g_controller_interface.FindDevice(m_devq); | ||
if (m_reference->IsInput()) | ||
{ | ||
for (auto* input : device->Inputs()) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
} | ||
else | ||
{ | ||
for (auto* output : device->Outputs()) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
#include "DolphinQt2/Config/Mapping/MappingWidget.h" | ||
#include "DolphinQt2/Config/Mapping/MappingWindow.h" | ||
#include "InputCommon/ControlReference/ControlReference.h" | ||
#include "InputCommon/ControllerEmu/ControllerEmu.h" | ||
#include "InputCommon/ControllerInterface/ControllerInterface.h" | ||
#include "InputCommon/ControllerInterface/Device.h" | ||
|
||
static QString TrunicateDisplayString(const QString& string) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
#include <QPushButton> | ||
#include <QSlider> | ||
#include <QSpinBox> | ||
#include <QVBoxLayout> |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
#include "InputCommon/ControllerInterface/Device.h" | ||
|
||
#include <QRegExp> | ||
#include <QString> |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
45198f4
to
09cc362
Compare
@ligfx Can you take a look again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, controllers are complicated. Still wrapping my head around everything going on here, but I put some initial comments.
|
||
void IOWindow::ConnectWidgets() | ||
{ | ||
connect(m_select_button, &QPushButton::clicked, this, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
||
connect(m_button_box, &QDialogButtonBox::clicked, this, &IOWindow::OnDialogButtonPressed); | ||
connect(m_devices_combo, | ||
static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged), this, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
&IOWindow::OnDeviceChanged); | ||
connect(m_range_spinbox, static_cast<void (QSpinBox::*)(int value)>(&QSpinBox::valueChanged), | ||
this, &IOWindow::OnRangeChanged); | ||
connect(m_range_slider, static_cast<void (QSlider::*)(int value)>(&QSlider::valueChanged), this, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
m_expression_text->clear(); | ||
return; | ||
} | ||
else |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
return; | ||
|
||
m_block = true; | ||
std::thread([this] { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
&IOWindow::OnRangeChanged); | ||
} | ||
|
||
void IOWindow::AppendSelectedOption(const QString& prefix) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
return; | ||
|
||
m_expression_text->insertPlainText( | ||
MappingCommon::GetExpressionForControl(m_option_list->currentItem()->text(), &m_devq, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
m_option_list->clear(); | ||
|
||
const auto device = g_controller_interface.FindDevice(m_devq); | ||
if (m_reference->IsInput()) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
||
const auto default_device = m_controller->default_device.ToString(); | ||
|
||
m_devices_combo->addItem(QString::fromStdString(default_device)); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
#include "DolphinQt2/Config/Mapping/MappingWidget.h" | ||
#include "DolphinQt2/Config/Mapping/MappingWindow.h" | ||
#include "InputCommon/ControlReference/ControlReference.h" | ||
#include "InputCommon/ControllerEmu/ControllerEmu.h" | ||
#include "InputCommon/ControllerInterface/ControllerInterface.h" | ||
#include "InputCommon/ControllerInterface/Device.h" | ||
|
||
static QString TruncateDisplayString(const QString& string) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
a90418d
to
b09a066
Compare
m_buttons.push_back(button); | ||
m_iowindows.push_back(iowindow); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
connect(button, &MappingButton::AdvancedPressed, [this, &iowindow, control_ref] { | ||
iowindow = new IOWindow(this, control_ref, control_ref->IsInput() ? IOWindow::Type::Input : | ||
IOWindow::Type::Output); | ||
iowindow->Open(); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -87,6 +100,12 @@ void MappingWidget::OnClearFields() | |||
|
|||
void MappingWidget::Update() | |||
{ | |||
for (auto* io : m_iowindows) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
setLayout(m_main_layout); | ||
} | ||
|
||
void IOWindow::Update() |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
constexpr int SLIDER_TICK_COUNT = 100; | ||
|
||
IOWindow::IOWindow(MappingWidget* parent, ControlReference* ref, IOWindow::Type type) | ||
: QDialog(static_cast<QWidget*>(parent)), m_reference(ref), m_parent(parent), m_type(type) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
||
Update(); | ||
exec(); | ||
m_parent->Update(); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
QString expr; | ||
|
||
// non-default device | ||
// operator== is overloaded, but operator!= isn't |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
22678cf
to
58339df
Compare
Would you mind taking a look again, @ligfx? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of small code things, though I've gone through this code so many times now (thanks for hiding old comments, GitHub) I'm going to assume it's good.
I did find an issue in testing: the text box in the advanced mapping window needs to be disabled when detecting controls, otherwise keyboard presses will show up.
ControllerEmu::EmulatedController* m_controller; | ||
|
||
ciface::Core::DeviceQualifier m_devq; | ||
bool m_block = false; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
||
constexpr int SLIDER_TICK_COUNT = 100; | ||
|
||
IOWindow::IOWindow(MappingWidget* parent, ControllerEmu::EmulatedController* controller, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Output | ||
}; | ||
|
||
explicit IOWindow(MappingWidget* parent, ControllerEmu::EmulatedController* m_controller, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
m_option_list->setCurrentItem(list[0]); | ||
} | ||
m_block = false; | ||
}).detach(); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Well, I tried to test this to make sure everything is working, but Qt (at least in the build I just downloaded, the builder is having trouble) doesn't have any indicator lights of when buttons are pressed! Without that ability, testing would require running a game and seeing if it responds, and that's MUCH harder! I think it might be a good idea to hold off on merging this until after button press notification is added, then it will be a LOT easier to test this PR and make sure everything is working correctly. |
@MayImilae I disagree: The only thing worth testing is whether it's creating correct expressions and I think most cases can be handled with one single expression that uses everything once. |
Well, as long as you know it works! |
f94b8ba
to
7173e7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No complaints on the visual design now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@lioncash Any other suggestions? |
return; | ||
case Qt::MouseButton::MiddleButton: | ||
Clear(); | ||
break; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
7173e7f
to
50c13c1
Compare
Screenshots: