Skip to content
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

Merged
merged 1 commit into from
Jun 13, 2017

Conversation

spycrab
Copy link
Contributor

@spycrab spycrab commented May 25, 2017

Screenshots:

@spycrab spycrab force-pushed the qt_mapping_io_win branch 4 times, most recently from 7e408cc to ad845f4 Compare May 25, 2017 22:01
@spycrab spycrab changed the title Qt mapping I/O windows Qt: Implement advanced mapping I/O windows May 25, 2017
#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.

This comment was marked as off-topic.

This comment was marked as off-topic.

: 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.

This comment was marked as off-topic.

This comment was marked as off-topic.

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.


void IOWindow::Update()
{
if (m_controller == nullptr)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

#include <QSpinBox>
#include <QVBoxLayout>

static constexpr int SLIDER_TICK_COUNT = 100;

This comment was marked as off-topic.

// 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.

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.

}
else
{
for (auto* output : device->Outputs())

This comment was marked as off-topic.

#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.

#include <QPushButton>
#include <QSlider>
#include <QSpinBox>
#include <QVBoxLayout>

This comment was marked as off-topic.

This comment was marked as off-topic.

#include "InputCommon/ControllerInterface/Device.h"

#include <QRegExp>
#include <QString>

This comment was marked as off-topic.

@spycrab spycrab force-pushed the qt_mapping_io_win branch 2 times, most recently from 45198f4 to 09cc362 Compare May 29, 2017 17:02
@spycrab
Copy link
Contributor Author

spycrab commented May 30, 2017

@ligfx Can you take a look again?

Copy link
Contributor

@ligfx ligfx left a 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.


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.

&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.

m_expression_text->clear();
return;
}
else

This comment was marked as off-topic.

return;

m_block = true;
std::thread([this] {

This comment was marked as off-topic.

This comment was marked as off-topic.

&IOWindow::OnRangeChanged);
}

void IOWindow::AppendSelectedOption(const QString& prefix)

This comment was marked as off-topic.

return;

m_expression_text->insertPlainText(
MappingCommon::GetExpressionForControl(m_option_list->currentItem()->text(), &m_devq,

This comment was marked as off-topic.

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.

This comment was marked as off-topic.


const auto default_device = m_controller->default_device.ToString();

m_devices_combo->addItem(QString::fromStdString(default_device));

This comment was marked as off-topic.

#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.

@spycrab spycrab force-pushed the qt_mapping_io_win branch 2 times, most recently from a90418d to b09a066 Compare June 3, 2017 11:32
m_buttons.push_back(button);
m_iowindows.push_back(iowindow);

This comment was marked as off-topic.

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.

@@ -87,6 +100,12 @@ void MappingWidget::OnClearFields()

void MappingWidget::Update()
{
for (auto* io : m_iowindows)

This comment was marked as off-topic.

setLayout(m_main_layout);
}

void IOWindow::Update()

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

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.


Update();
exec();
m_parent->Update();

This comment was marked as off-topic.

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.

@spycrab spycrab force-pushed the qt_mapping_io_win branch 2 times, most recently from 22678cf to 58339df Compare June 4, 2017 00:30
@spycrab
Copy link
Contributor Author

spycrab commented Jun 5, 2017

Would you mind taking a look again, @ligfx?

Copy link
Contributor

@ligfx ligfx left a 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.


constexpr int SLIDER_TICK_COUNT = 100;

IOWindow::IOWindow(MappingWidget* parent, ControllerEmu::EmulatedController* controller,

This comment was marked as off-topic.

Output
};

explicit IOWindow(MappingWidget* parent, ControllerEmu::EmulatedController* m_controller,

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

m_option_list->setCurrentItem(list[0]);
}
m_block = false;
}).detach();

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@MayImilae
Copy link
Contributor

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.

@spycrab
Copy link
Contributor Author

spycrab commented Jun 7, 2017

@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.

@MayImilae
Copy link
Contributor

Well, as long as you know it works!

@spycrab spycrab force-pushed the qt_mapping_io_win branch 2 times, most recently from f94b8ba to 7173e7f Compare June 7, 2017 13:08
Copy link
Contributor

@MayImilae MayImilae left a 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!

Copy link
Contributor

@ligfx ligfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@spycrab
Copy link
Contributor Author

spycrab commented Jun 8, 2017

@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.

@leoetlino leoetlino merged commit 38c6015 into dolphin-emu:master Jun 13, 2017
@spycrab spycrab deleted the qt_mapping_io_win branch June 14, 2017 11:53
@leoetlino leoetlino modified the milestone: Qt Sep 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants