summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dist/qt_themes/default/style.qss4
-rw-r--r--dist/qt_themes/qdarkstyle/style.qss4
-rw-r--r--dist/qt_themes/qdarkstyle_midnight_blue/style.qss4
-rw-r--r--src/yuzu/applets/qt_controller.cpp39
-rw-r--r--src/yuzu/applets/qt_controller.h6
-rw-r--r--src/yuzu/applets/qt_controller.ui54
6 files changed, 104 insertions, 7 deletions
diff --git a/dist/qt_themes/default/style.qss b/dist/qt_themes/default/style.qss
index 12e681648..6a9cc555f 100644
--- a/dist/qt_themes/default/style.qss
+++ b/dist/qt_themes/default/style.qss
@@ -115,6 +115,10 @@ QWidget#connectedControllers {
115 background: transparent; 115 background: transparent;
116} 116}
117 117
118QWidget#closeButtons {
119 background: transparent;
120}
121
118QWidget#playersSupported, 122QWidget#playersSupported,
119QWidget#controllersSupported, 123QWidget#controllersSupported,
120QWidget#controllerSupported1, 124QWidget#controllerSupported1,
diff --git a/dist/qt_themes/qdarkstyle/style.qss b/dist/qt_themes/qdarkstyle/style.qss
index 63a636ae6..328ac942f 100644
--- a/dist/qt_themes/qdarkstyle/style.qss
+++ b/dist/qt_themes/qdarkstyle/style.qss
@@ -1380,6 +1380,10 @@ QWidget#connectedControllers {
1380 background: transparent; 1380 background: transparent;
1381} 1381}
1382 1382
1383QWidget#closeButtons {
1384 background: transparent;
1385}
1386
1383QWidget#playersSupported, 1387QWidget#playersSupported,
1384QWidget#controllersSupported, 1388QWidget#controllersSupported,
1385QWidget#controllerSupported1, 1389QWidget#controllerSupported1,
diff --git a/dist/qt_themes/qdarkstyle_midnight_blue/style.qss b/dist/qt_themes/qdarkstyle_midnight_blue/style.qss
index 49b05c8ba..8892c32d6 100644
--- a/dist/qt_themes/qdarkstyle_midnight_blue/style.qss
+++ b/dist/qt_themes/qdarkstyle_midnight_blue/style.qss
@@ -2301,6 +2301,10 @@ QWidget#connectedControllers {
2301 background: transparent; 2301 background: transparent;
2302} 2302}
2303 2303
2304QWidget#closeButtons {
2305 background: transparent;
2306}
2307
2304QWidget#playersSupported, 2308QWidget#playersSupported,
2305QWidget#controllersSupported, 2309QWidget#controllersSupported,
2306QWidget#controllerSupported1, 2310QWidget#controllerSupported1,
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp
index 00aafb8f8..3b8317598 100644
--- a/src/yuzu/applets/qt_controller.cpp
+++ b/src/yuzu/applets/qt_controller.cpp
@@ -21,6 +21,7 @@
21#include "yuzu/configuration/configure_vibration.h" 21#include "yuzu/configuration/configure_vibration.h"
22#include "yuzu/configuration/input_profiles.h" 22#include "yuzu/configuration/input_profiles.h"
23#include "yuzu/main.h" 23#include "yuzu/main.h"
24#include "yuzu/util/controller_navigation.h"
24 25
25namespace { 26namespace {
26 27
@@ -130,6 +131,8 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
130 ui->checkboxPlayer7Connected, ui->checkboxPlayer8Connected, 131 ui->checkboxPlayer7Connected, ui->checkboxPlayer8Connected,
131 }; 132 };
132 133
134 ui->labelError->setVisible(false);
135
133 // Setup/load everything prior to setting up connections. 136 // Setup/load everything prior to setting up connections.
134 // This avoids unintentionally changing the states of elements while loading them in. 137 // This avoids unintentionally changing the states of elements while loading them in.
135 SetSupportedControllers(); 138 SetSupportedControllers();
@@ -141,6 +144,8 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
141 144
142 LoadConfiguration(); 145 LoadConfiguration();
143 146
147 controller_navigation = new ControllerNavigation(system.HIDCore(), this);
148
144 for (std::size_t i = 0; i < NUM_PLAYERS; ++i) { 149 for (std::size_t i = 0; i < NUM_PLAYERS; ++i) {
145 SetExplainText(i); 150 SetExplainText(i);
146 UpdateControllerIcon(i); 151 UpdateControllerIcon(i);
@@ -149,6 +154,8 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
149 154
150 connect(player_groupboxes[i], &QGroupBox::toggled, [this, i](bool checked) { 155 connect(player_groupboxes[i], &QGroupBox::toggled, [this, i](bool checked) {
151 if (checked) { 156 if (checked) {
157 // Hide eventual error message about number of controllers
158 ui->labelError->setVisible(false);
152 for (std::size_t index = 0; index <= i; ++index) { 159 for (std::size_t index = 0; index <= i; ++index) {
153 connected_controller_checkboxes[index]->setChecked(checked); 160 connected_controller_checkboxes[index]->setChecked(checked);
154 } 161 }
@@ -197,6 +204,12 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
197 connect(ui->buttonBox, &QDialogButtonBox::accepted, this, 204 connect(ui->buttonBox, &QDialogButtonBox::accepted, this,
198 &QtControllerSelectorDialog::ApplyConfiguration); 205 &QtControllerSelectorDialog::ApplyConfiguration);
199 206
207 connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent,
208 [this](Qt::Key key) {
209 QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier);
210 QCoreApplication::postEvent(this, event);
211 });
212
200 // Enhancement: Check if the parameters have already been met before disconnecting controllers. 213 // Enhancement: Check if the parameters have already been met before disconnecting controllers.
201 // If all the parameters are met AND only allows a single player, 214 // If all the parameters are met AND only allows a single player,
202 // stop the constructor here as we do not need to continue. 215 // stop the constructor here as we do not need to continue.
@@ -215,6 +228,7 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
215} 228}
216 229
217QtControllerSelectorDialog::~QtControllerSelectorDialog() { 230QtControllerSelectorDialog::~QtControllerSelectorDialog() {
231 controller_navigation->UnloadController();
218 system.HIDCore().DisableAllControllerConfiguration(); 232 system.HIDCore().DisableAllControllerConfiguration();
219} 233}
220 234
@@ -287,6 +301,31 @@ void QtControllerSelectorDialog::CallConfigureInputProfileDialog() {
287 dialog.exec(); 301 dialog.exec();
288} 302}
289 303
304void QtControllerSelectorDialog::keyPressEvent(QKeyEvent* evt) {
305 const auto num_connected_players = static_cast<int>(
306 std::count_if(player_groupboxes.begin(), player_groupboxes.end(),
307 [](const QGroupBox* player) { return player->isChecked(); }));
308
309 const auto min_supported_players = parameters.enable_single_mode ? 1 : parameters.min_players;
310 const auto max_supported_players = parameters.enable_single_mode ? 1 : parameters.max_players;
311
312 if ((evt->key() == Qt::Key_Enter || evt->key() == Qt::Key_Return) && !parameters_met) {
313 // Display error message when trying to validate using "Enter" and "OK" button is disabled
314 ui->labelError->setVisible(true);
315 return;
316 } else if (evt->key() == Qt::Key_Left && num_connected_players > min_supported_players) {
317 // Remove a player if possible
318 connected_controller_checkboxes[num_connected_players - 1]->setChecked(false);
319 return;
320 } else if (evt->key() == Qt::Key_Right && num_connected_players < max_supported_players) {
321 // Add a player, if possible
322 ui->labelError->setVisible(false);
323 connected_controller_checkboxes[num_connected_players]->setChecked(true);
324 return;
325 }
326 QDialog::keyPressEvent(evt);
327}
328
290bool QtControllerSelectorDialog::CheckIfParametersMet() { 329bool QtControllerSelectorDialog::CheckIfParametersMet() {
291 // Here, we check and validate the current configuration against all applicable parameters. 330 // Here, we check and validate the current configuration against all applicable parameters.
292 const auto num_connected_players = static_cast<int>( 331 const auto num_connected_players = static_cast<int>(
diff --git a/src/yuzu/applets/qt_controller.h b/src/yuzu/applets/qt_controller.h
index 2fdc35857..7f0673d06 100644
--- a/src/yuzu/applets/qt_controller.h
+++ b/src/yuzu/applets/qt_controller.h
@@ -34,6 +34,8 @@ class HIDCore;
34enum class NpadStyleIndex : u8; 34enum class NpadStyleIndex : u8;
35} // namespace Core::HID 35} // namespace Core::HID
36 36
37class ControllerNavigation;
38
37class QtControllerSelectorDialog final : public QDialog { 39class QtControllerSelectorDialog final : public QDialog {
38 Q_OBJECT 40 Q_OBJECT
39 41
@@ -46,6 +48,8 @@ public:
46 48
47 int exec() override; 49 int exec() override;
48 50
51 void keyPressEvent(QKeyEvent* evt) override;
52
49private: 53private:
50 // Applies the current configuration. 54 // Applies the current configuration.
51 void ApplyConfiguration(); 55 void ApplyConfiguration();
@@ -110,6 +114,8 @@ private:
110 114
111 Core::System& system; 115 Core::System& system;
112 116
117 ControllerNavigation* controller_navigation = nullptr;
118
113 // This is true if and only if all parameters are met. Otherwise, this is false. 119 // This is true if and only if all parameters are met. Otherwise, this is false.
114 // This determines whether the "OK" button can be clicked to exit the applet. 120 // This determines whether the "OK" button can be clicked to exit the applet.
115 bool parameters_met{false}; 121 bool parameters_met{false};
diff --git a/src/yuzu/applets/qt_controller.ui b/src/yuzu/applets/qt_controller.ui
index 729e921ee..6f7cb3c13 100644
--- a/src/yuzu/applets/qt_controller.ui
+++ b/src/yuzu/applets/qt_controller.ui
@@ -2624,13 +2624,53 @@
2624 </spacer> 2624 </spacer>
2625 </item> 2625 </item>
2626 <item alignment="Qt::AlignBottom"> 2626 <item alignment="Qt::AlignBottom">
2627 <widget class="QDialogButtonBox" name="buttonBox"> 2627 <widget class="QWidget" name="closeButtons" native="true">
2628 <property name="enabled"> 2628 <layout class="QVBoxLayout" name="verticalLayout_46">
2629 <bool>true</bool> 2629 <property name="spacing">
2630 </property> 2630 <number>7</number>
2631 <property name="standardButtons"> 2631 </property>
2632 <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> 2632 <property name="leftMargin">
2633 </property> 2633 <number>0</number>
2634 </property>
2635 <property name="topMargin">
2636 <number>0</number>
2637 </property>
2638 <property name="rightMargin">
2639 <number>0</number>
2640 </property>
2641 <property name="bottomMargin">
2642 <number>0</number>
2643 </property>
2644 <item>
2645 <widget class="QLabel" name="labelError">
2646 <property name="enabled">
2647 <bool>true</bool>
2648 </property>
2649 <property name="styleSheet">
2650 <string notr="true">QLabel { color : red; }</string>
2651 </property>
2652 <property name="text">
2653 <string>Not enough controllers</string>
2654 </property>
2655 <property name="alignment">
2656 <set>Qt::AlignCenter</set>
2657 </property>
2658 <property name="margin">
2659 <number>0</number>
2660 </property>
2661 </widget>
2662 </item>
2663 <item>
2664 <widget class="QDialogButtonBox" name="buttonBox">
2665 <property name="enabled">
2666 <bool>true</bool>
2667 </property>
2668 <property name="standardButtons">
2669 <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
2670 </property>
2671 </widget>
2672 </item>
2673 </layout>
2634 </widget> 2674 </widget>
2635 </item> 2675 </item>
2636 </layout> 2676 </layout>