summaryrefslogtreecommitdiff
path: root/src/yuzu/applets
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu/applets')
-rw-r--r--src/yuzu/applets/qt_controller.cpp10
-rw-r--r--src/yuzu/applets/qt_controller.h4
-rw-r--r--src/yuzu/applets/qt_profile_select.cpp17
-rw-r--r--src/yuzu/applets/qt_profile_select.h8
-rw-r--r--src/yuzu/applets/qt_software_keyboard.cpp23
5 files changed, 48 insertions, 14 deletions
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp
index 589e0577a..c5685db2e 100644
--- a/src/yuzu/applets/qt_controller.cpp
+++ b/src/yuzu/applets/qt_controller.cpp
@@ -139,7 +139,6 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
DisableUnsupportedPlayers();
for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) {
- system.HIDCore().GetEmulatedControllerByIndex(player_index)->EnableConfiguration();
SetEmulatedControllers(player_index);
}
@@ -218,7 +217,9 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
resize(0, 0);
}
-QtControllerSelectorDialog::~QtControllerSelectorDialog() = default;
+QtControllerSelectorDialog::~QtControllerSelectorDialog() {
+ system.HIDCore().DisableAllControllerConfiguration();
+}
int QtControllerSelectorDialog::exec() {
if (parameters_met && parameters.enable_single_mode) {
@@ -234,12 +235,11 @@ void QtControllerSelectorDialog::ApplyConfiguration() {
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
- for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) {
- system.HIDCore().GetEmulatedControllerByIndex(player_index)->DisableConfiguration();
- }
}
void QtControllerSelectorDialog::LoadConfiguration() {
+ system.HIDCore().EnableAllControllerConfiguration();
+
const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
for (std::size_t index = 0; index < NUM_PLAYERS; ++index) {
const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index);
diff --git a/src/yuzu/applets/qt_controller.h b/src/yuzu/applets/qt_controller.h
index cc343e5ae..7ab9ced3d 100644
--- a/src/yuzu/applets/qt_controller.h
+++ b/src/yuzu/applets/qt_controller.h
@@ -7,7 +7,6 @@
#include <array>
#include <memory>
#include <QDialog>
-#include "core/core.h"
#include "core/frontend/applets/controller.h"
class GMainWindow;
@@ -32,8 +31,9 @@ class System;
}
namespace Core::HID {
+class HIDCore;
enum class NpadStyleIndex : u8;
-}
+} // namespace Core::HID
class QtControllerSelectorDialog final : public QDialog {
Q_OBJECT
diff --git a/src/yuzu/applets/qt_profile_select.cpp b/src/yuzu/applets/qt_profile_select.cpp
index a56638e21..7b19f1f8d 100644
--- a/src/yuzu/applets/qt_profile_select.cpp
+++ b/src/yuzu/applets/qt_profile_select.cpp
@@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <mutex>
+#include <QApplication>
#include <QDialogButtonBox>
#include <QHeaderView>
#include <QLabel>
@@ -16,6 +17,7 @@
#include "core/hle/lock.h"
#include "yuzu/applets/qt_profile_select.h"
#include "yuzu/main.h"
+#include "yuzu/util/controller_navigation.h"
namespace {
QString FormatUserEntryText(const QString& username, Common::UUID uuid) {
@@ -45,7 +47,7 @@ QPixmap GetIcon(Common::UUID uuid) {
}
} // Anonymous namespace
-QtProfileSelectionDialog::QtProfileSelectionDialog(QWidget* parent)
+QtProfileSelectionDialog::QtProfileSelectionDialog(Core::HID::HIDCore& hid_core, QWidget* parent)
: QDialog(parent), profile_manager(std::make_unique<Service::Account::ProfileManager>()) {
outer_layout = new QVBoxLayout;
@@ -65,6 +67,7 @@ QtProfileSelectionDialog::QtProfileSelectionDialog(QWidget* parent)
tree_view = new QTreeView;
item_model = new QStandardItemModel(tree_view);
tree_view->setModel(item_model);
+ controller_navigation = new ControllerNavigation(hid_core, this);
tree_view->setAlternatingRowColors(true);
tree_view->setSelectionMode(QHeaderView::SingleSelection);
@@ -91,6 +94,14 @@ QtProfileSelectionDialog::QtProfileSelectionDialog(QWidget* parent)
scroll_area->setLayout(layout);
connect(tree_view, &QTreeView::clicked, this, &QtProfileSelectionDialog::SelectUser);
+ connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent,
+ [this](Qt::Key key) {
+ if (!this->isActiveWindow()) {
+ return;
+ }
+ QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier);
+ QCoreApplication::postEvent(tree_view, event);
+ });
const auto& profiles = profile_manager->GetAllUsers();
for (const auto& user : profiles) {
@@ -113,7 +124,9 @@ QtProfileSelectionDialog::QtProfileSelectionDialog(QWidget* parent)
resize(550, 400);
}
-QtProfileSelectionDialog::~QtProfileSelectionDialog() = default;
+QtProfileSelectionDialog::~QtProfileSelectionDialog() {
+ controller_navigation->UnloadController();
+};
int QtProfileSelectionDialog::exec() {
// Skip profile selection when there's only one.
diff --git a/src/yuzu/applets/qt_profile_select.h b/src/yuzu/applets/qt_profile_select.h
index 4e9037488..56496ed31 100644
--- a/src/yuzu/applets/qt_profile_select.h
+++ b/src/yuzu/applets/qt_profile_select.h
@@ -11,6 +11,7 @@
#include "core/frontend/applets/profile_select.h"
#include "core/hle/service/acc/profile_manager.h"
+class ControllerNavigation;
class GMainWindow;
class QDialogButtonBox;
class QGraphicsScene;
@@ -20,11 +21,15 @@ class QStandardItem;
class QStandardItemModel;
class QVBoxLayout;
+namespace Core::HID {
+class HIDCore;
+} // namespace Core::HID
+
class QtProfileSelectionDialog final : public QDialog {
Q_OBJECT
public:
- explicit QtProfileSelectionDialog(QWidget* parent);
+ explicit QtProfileSelectionDialog(Core::HID::HIDCore& hid_core, QWidget* parent);
~QtProfileSelectionDialog() override;
int exec() override;
@@ -51,6 +56,7 @@ private:
QDialogButtonBox* buttons;
std::unique_ptr<Service::Account::ProfileManager> profile_manager;
+ ControllerNavigation* controller_navigation = nullptr;
};
class QtProfileSelector final : public QObject, public Core::Frontend::ProfileSelectApplet {
diff --git a/src/yuzu/applets/qt_software_keyboard.cpp b/src/yuzu/applets/qt_software_keyboard.cpp
index de7f98c4f..c3857fc98 100644
--- a/src/yuzu/applets/qt_software_keyboard.cpp
+++ b/src/yuzu/applets/qt_software_keyboard.cpp
@@ -475,11 +475,26 @@ void QtSoftwareKeyboardDialog::open() {
row = 0;
column = 0;
- const auto* const curr_button =
- keyboard_buttons[static_cast<int>(bottom_osk_index)][row][column];
+ switch (bottom_osk_index) {
+ case BottomOSKIndex::LowerCase:
+ case BottomOSKIndex::UpperCase: {
+ const auto* const curr_button =
+ keyboard_buttons[static_cast<std::size_t>(bottom_osk_index)][row][column];
+
+ // This is a workaround for setFocus() randomly not showing focus in the UI
+ QCursor::setPos(curr_button->mapToGlobal(curr_button->rect().center()));
+ break;
+ }
+ case BottomOSKIndex::NumberPad: {
+ const auto* const curr_button = numberpad_buttons[row][column];
- // This is a workaround for setFocus() randomly not showing focus in the UI
- QCursor::setPos(curr_button->mapToGlobal(curr_button->rect().center()));
+ // This is a workaround for setFocus() randomly not showing focus in the UI
+ QCursor::setPos(curr_button->mapToGlobal(curr_button->rect().center()));
+ break;
+ }
+ default:
+ break;
+ }
StartInputThread();
}