diff options
Diffstat (limited to '')
| -rw-r--r-- | src/citra_qt/configure_input.cpp | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/src/citra_qt/configure_input.cpp b/src/citra_qt/configure_input.cpp index 9c7a67174..af473f841 100644 --- a/src/citra_qt/configure_input.cpp +++ b/src/citra_qt/configure_input.cpp | |||
| @@ -2,41 +2,42 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <QTimer> | ||
| 5 | #include <memory> | 6 | #include <memory> |
| 6 | #include <utility> | 7 | #include <utility> |
| 7 | #include <QTimer> | ||
| 8 | 8 | ||
| 9 | #include "citra_qt/configure_input.h" | 9 | #include "citra_qt/configure_input.h" |
| 10 | 10 | ||
| 11 | ConfigureInput::ConfigureInput(QWidget* parent) : QWidget(parent), ui(std::make_unique<Ui::ConfigureInput>()) { | 11 | ConfigureInput::ConfigureInput(QWidget* parent) |
| 12 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureInput>()) { | ||
| 12 | ui->setupUi(this); | 13 | ui->setupUi(this); |
| 13 | 14 | ||
| 14 | // Initialize mapping of input enum to UI button. | 15 | // Initialize mapping of input enum to UI button. |
| 15 | input_mapping = { | 16 | input_mapping = { |
| 16 | { std::make_pair(Settings::NativeInput::Values::A, ui->buttonA) }, | 17 | {std::make_pair(Settings::NativeInput::Values::A, ui->buttonA)}, |
| 17 | { std::make_pair(Settings::NativeInput::Values::B, ui->buttonB) }, | 18 | {std::make_pair(Settings::NativeInput::Values::B, ui->buttonB)}, |
| 18 | { std::make_pair(Settings::NativeInput::Values::X, ui->buttonX) }, | 19 | {std::make_pair(Settings::NativeInput::Values::X, ui->buttonX)}, |
| 19 | { std::make_pair(Settings::NativeInput::Values::Y, ui->buttonY) }, | 20 | {std::make_pair(Settings::NativeInput::Values::Y, ui->buttonY)}, |
| 20 | { std::make_pair(Settings::NativeInput::Values::L, ui->buttonL) }, | 21 | {std::make_pair(Settings::NativeInput::Values::L, ui->buttonL)}, |
| 21 | { std::make_pair(Settings::NativeInput::Values::R, ui->buttonR) }, | 22 | {std::make_pair(Settings::NativeInput::Values::R, ui->buttonR)}, |
| 22 | { std::make_pair(Settings::NativeInput::Values::ZL, ui->buttonZL) }, | 23 | {std::make_pair(Settings::NativeInput::Values::ZL, ui->buttonZL)}, |
| 23 | { std::make_pair(Settings::NativeInput::Values::ZR, ui->buttonZR) }, | 24 | {std::make_pair(Settings::NativeInput::Values::ZR, ui->buttonZR)}, |
| 24 | { std::make_pair(Settings::NativeInput::Values::START, ui->buttonStart) }, | 25 | {std::make_pair(Settings::NativeInput::Values::START, ui->buttonStart)}, |
| 25 | { std::make_pair(Settings::NativeInput::Values::SELECT, ui->buttonSelect) }, | 26 | {std::make_pair(Settings::NativeInput::Values::SELECT, ui->buttonSelect)}, |
| 26 | { std::make_pair(Settings::NativeInput::Values::HOME, ui->buttonHome) }, | 27 | {std::make_pair(Settings::NativeInput::Values::HOME, ui->buttonHome)}, |
| 27 | { std::make_pair(Settings::NativeInput::Values::DUP, ui->buttonDpadUp) }, | 28 | {std::make_pair(Settings::NativeInput::Values::DUP, ui->buttonDpadUp)}, |
| 28 | { std::make_pair(Settings::NativeInput::Values::DDOWN, ui->buttonDpadDown) }, | 29 | {std::make_pair(Settings::NativeInput::Values::DDOWN, ui->buttonDpadDown)}, |
| 29 | { std::make_pair(Settings::NativeInput::Values::DLEFT, ui->buttonDpadLeft) }, | 30 | {std::make_pair(Settings::NativeInput::Values::DLEFT, ui->buttonDpadLeft)}, |
| 30 | { std::make_pair(Settings::NativeInput::Values::DRIGHT, ui->buttonDpadRight) }, | 31 | {std::make_pair(Settings::NativeInput::Values::DRIGHT, ui->buttonDpadRight)}, |
| 31 | { std::make_pair(Settings::NativeInput::Values::CUP, ui->buttonCStickUp) }, | 32 | {std::make_pair(Settings::NativeInput::Values::CUP, ui->buttonCStickUp)}, |
| 32 | { std::make_pair(Settings::NativeInput::Values::CDOWN, ui->buttonCStickDown) }, | 33 | {std::make_pair(Settings::NativeInput::Values::CDOWN, ui->buttonCStickDown)}, |
| 33 | { std::make_pair(Settings::NativeInput::Values::CLEFT, ui->buttonCStickLeft) }, | 34 | {std::make_pair(Settings::NativeInput::Values::CLEFT, ui->buttonCStickLeft)}, |
| 34 | { std::make_pair(Settings::NativeInput::Values::CRIGHT, ui->buttonCStickRight) }, | 35 | {std::make_pair(Settings::NativeInput::Values::CRIGHT, ui->buttonCStickRight)}, |
| 35 | { std::make_pair(Settings::NativeInput::Values::CIRCLE_UP, ui->buttonCircleUp) }, | 36 | {std::make_pair(Settings::NativeInput::Values::CIRCLE_UP, ui->buttonCircleUp)}, |
| 36 | { std::make_pair(Settings::NativeInput::Values::CIRCLE_DOWN, ui->buttonCircleDown) }, | 37 | {std::make_pair(Settings::NativeInput::Values::CIRCLE_DOWN, ui->buttonCircleDown)}, |
| 37 | { std::make_pair(Settings::NativeInput::Values::CIRCLE_LEFT, ui->buttonCircleLeft) }, | 38 | {std::make_pair(Settings::NativeInput::Values::CIRCLE_LEFT, ui->buttonCircleLeft)}, |
| 38 | { std::make_pair(Settings::NativeInput::Values::CIRCLE_RIGHT, ui->buttonCircleRight) }, | 39 | {std::make_pair(Settings::NativeInput::Values::CIRCLE_RIGHT, ui->buttonCircleRight)}, |
| 39 | { std::make_pair(Settings::NativeInput::Values::CIRCLE_MODIFIER, ui->buttonCircleMod) }, | 40 | {std::make_pair(Settings::NativeInput::Values::CIRCLE_MODIFIER, ui->buttonCircleMod)}, |
| 40 | }; | 41 | }; |
| 41 | 42 | ||
| 42 | // Attach handle click method to each button click. | 43 | // Attach handle click method to each button click. |
| @@ -47,7 +48,10 @@ ConfigureInput::ConfigureInput(QWidget* parent) : QWidget(parent), ui(std::make_ | |||
| 47 | setFocusPolicy(Qt::ClickFocus); | 48 | setFocusPolicy(Qt::ClickFocus); |
| 48 | timer = new QTimer(this); | 49 | timer = new QTimer(this); |
| 49 | timer->setSingleShot(true); | 50 | timer->setSingleShot(true); |
| 50 | connect(timer, &QTimer::timeout, this, [&]() { key_pressed = Qt::Key_Escape; setKey(); }); | 51 | connect(timer, &QTimer::timeout, this, [&]() { |
| 52 | key_pressed = Qt::Key_Escape; | ||
| 53 | setKey(); | ||
| 54 | }); | ||
| 51 | this->setConfiguration(); | 55 | this->setConfiguration(); |
| 52 | } | 56 | } |
| 53 | 57 | ||
| @@ -59,7 +63,7 @@ void ConfigureInput::handleClick() { | |||
| 59 | grabKeyboard(); | 63 | grabKeyboard(); |
| 60 | grabMouse(); | 64 | grabMouse(); |
| 61 | changing_button = sender; | 65 | changing_button = sender; |
| 62 | timer->start(5000); //Cancel after 5 seconds | 66 | timer->start(5000); // Cancel after 5 seconds |
| 63 | } | 67 | } |
| 64 | 68 | ||
| 65 | void ConfigureInput::applyConfiguration() { | 69 | void ConfigureInput::applyConfiguration() { |