2021-01-21 16:51:24 -08:00
|
|
|
// Copyright 2015 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
#include <QLayout>
|
|
|
|
#include <QString>
|
2021-04-14 16:07:40 -07:00
|
|
|
#include "common/settings.h"
|
2021-09-20 17:59:09 -07:00
|
|
|
#include "core/core.h"
|
2021-01-21 16:51:24 -08:00
|
|
|
#include "yuzu/configuration/configure_input_player_widget.h"
|
|
|
|
#include "yuzu/debugger/controller.h"
|
|
|
|
|
2021-10-15 17:07:47 -07:00
|
|
|
ControllerDialog::ControllerDialog(Core::System& system, QWidget* parent)
|
|
|
|
: QWidget(parent, Qt::Dialog) {
|
2021-01-21 16:51:24 -08:00
|
|
|
setObjectName(QStringLiteral("Controller"));
|
|
|
|
setWindowTitle(tr("Controller P1"));
|
|
|
|
resize(500, 350);
|
|
|
|
setMinimumSize(500, 350);
|
|
|
|
// Remove the "?" button from the titlebar and enable the maximize button
|
|
|
|
setWindowFlags((windowFlags() & ~Qt::WindowContextHelpButtonHint) |
|
|
|
|
Qt::WindowMaximizeButtonHint);
|
|
|
|
|
2021-02-04 06:54:27 -08:00
|
|
|
widget = new PlayerControlPreview(this);
|
2021-10-24 09:22:20 -07:00
|
|
|
widget->SetController(system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1));
|
2021-01-21 16:51:24 -08:00
|
|
|
QLayout* layout = new QVBoxLayout(this);
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
layout->addWidget(widget);
|
|
|
|
setLayout(layout);
|
|
|
|
|
|
|
|
// Configure focus so that widget is focusable and the dialog automatically forwards focus to
|
|
|
|
// it.
|
|
|
|
setFocusProxy(widget);
|
|
|
|
widget->setFocusPolicy(Qt::StrongFocus);
|
|
|
|
widget->setFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction* ControllerDialog::toggleViewAction() {
|
|
|
|
if (toggle_view_action == nullptr) {
|
2021-02-14 12:57:47 -08:00
|
|
|
toggle_view_action = new QAction(tr("&Controller P1"), this);
|
2021-01-21 16:51:24 -08:00
|
|
|
toggle_view_action->setCheckable(true);
|
|
|
|
toggle_view_action->setChecked(isVisible());
|
|
|
|
connect(toggle_view_action, &QAction::toggled, this, &ControllerDialog::setVisible);
|
|
|
|
}
|
|
|
|
|
|
|
|
return toggle_view_action;
|
|
|
|
}
|
|
|
|
|
2021-10-15 17:07:47 -07:00
|
|
|
void ControllerDialog::UnloadController() {
|
|
|
|
widget->UnloadController();
|
|
|
|
}
|
|
|
|
|
2021-01-21 16:51:24 -08:00
|
|
|
void ControllerDialog::showEvent(QShowEvent* ev) {
|
|
|
|
if (toggle_view_action) {
|
|
|
|
toggle_view_action->setChecked(isVisible());
|
|
|
|
}
|
|
|
|
QWidget::showEvent(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerDialog::hideEvent(QHideEvent* ev) {
|
|
|
|
if (toggle_view_action) {
|
|
|
|
toggle_view_action->setChecked(isVisible());
|
|
|
|
}
|
|
|
|
QWidget::hideEvent(ev);
|
|
|
|
}
|