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.cpp155
-rw-r--r--src/yuzu/applets/qt_controller.h20
-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.cpp135
-rw-r--r--src/yuzu/applets/qt_software_keyboard.h12
-rw-r--r--src/yuzu/applets/qt_web_browser.cpp70
-rw-r--r--src/yuzu/applets/qt_web_browser.h12
8 files changed, 232 insertions, 197 deletions
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp
index bf8445a89..c5685db2e 100644
--- a/src/yuzu/applets/qt_controller.cpp
+++ b/src/yuzu/applets/qt_controller.cpp
@@ -6,8 +6,12 @@
#include <thread>
#include "common/assert.h"
+#include "common/param_package.h"
#include "common/string_util.h"
#include "core/core.h"
+#include "core/hid/emulated_controller.h"
+#include "core/hid/hid_core.h"
+#include "core/hid/hid_types.h"
#include "core/hle/lock.h"
#include "core/hle/service/hid/controllers/npad.h"
#include "core/hle/service/hid/hid.h"
@@ -23,49 +27,32 @@
namespace {
-constexpr std::size_t HANDHELD_INDEX = 8;
-
-constexpr std::array<std::array<bool, 4>, 8> led_patterns{{
- {true, false, false, false},
- {true, true, false, false},
- {true, true, true, false},
- {true, true, true, true},
- {true, false, false, true},
- {true, false, true, false},
- {true, false, true, true},
- {false, true, true, false},
-}};
-
-void UpdateController(Settings::ControllerType controller_type, std::size_t npad_index,
- bool connected, Core::System& system) {
- if (!system.IsPoweredOn()) {
- return;
+void UpdateController(Core::HID::EmulatedController* controller,
+ Core::HID::NpadStyleIndex controller_type, bool connected) {
+ if (controller->IsConnected(true)) {
+ controller->Disconnect();
+ }
+ controller->SetNpadStyleIndex(controller_type);
+ if (connected) {
+ controller->Connect();
}
-
- auto& npad =
- system.ServiceManager()
- .GetService<Service::HID::Hid>("hid")
- ->GetAppletResource()
- ->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad);
-
- npad.UpdateControllerAt(npad.MapSettingsTypeToNPad(controller_type), npad_index, connected);
}
// Returns true if the given controller type is compatible with the given parameters.
-bool IsControllerCompatible(Settings::ControllerType controller_type,
+bool IsControllerCompatible(Core::HID::NpadStyleIndex controller_type,
Core::Frontend::ControllerParameters parameters) {
switch (controller_type) {
- case Settings::ControllerType::ProController:
+ case Core::HID::NpadStyleIndex::ProController:
return parameters.allow_pro_controller;
- case Settings::ControllerType::DualJoyconDetached:
+ case Core::HID::NpadStyleIndex::JoyconDual:
return parameters.allow_dual_joycons;
- case Settings::ControllerType::LeftJoycon:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
return parameters.allow_left_joycon;
- case Settings::ControllerType::RightJoycon:
+ case Core::HID::NpadStyleIndex::JoyconRight:
return parameters.allow_right_joycon;
- case Settings::ControllerType::Handheld:
+ case Core::HID::NpadStyleIndex::Handheld:
return parameters.enable_single_mode && parameters.allow_handheld;
- case Settings::ControllerType::GameCube:
+ case Core::HID::NpadStyleIndex::GameCube:
return parameters.allow_gamecube_controller;
default:
return false;
@@ -196,7 +183,7 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
connect(emulated_controllers[i], qOverload<int>(&QComboBox::currentIndexChanged),
[this, i](int index) {
UpdateDockedState(GetControllerTypeFromIndex(index, i) ==
- Settings::ControllerType::Handheld);
+ Core::HID::NpadStyleIndex::Handheld);
});
}
}
@@ -230,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) {
@@ -249,17 +238,20 @@ void QtControllerSelectorDialog::ApplyConfiguration() {
}
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);
const auto connected =
- Settings::values.players.GetValue()[index].connected ||
- (index == 0 && Settings::values.players.GetValue()[HANDHELD_INDEX].connected);
+ controller->IsConnected(true) || (index == 0 && handheld->IsConnected(true));
player_groupboxes[index]->setChecked(connected);
connected_controller_checkboxes[index]->setChecked(connected);
- emulated_controllers[index]->setCurrentIndex(GetIndexFromControllerType(
- Settings::values.players.GetValue()[index].controller_type, index));
+ emulated_controllers[index]->setCurrentIndex(
+ GetIndexFromControllerType(controller->GetNpadStyleIndex(true), index));
}
- UpdateDockedState(Settings::values.players.GetValue()[HANDHELD_INDEX].connected);
+ UpdateDockedState(handheld->IsConnected(true));
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue());
@@ -415,33 +407,33 @@ void QtControllerSelectorDialog::SetEmulatedControllers(std::size_t player_index
emulated_controllers[player_index]->clear();
pairs.emplace_back(emulated_controllers[player_index]->count(),
- Settings::ControllerType::ProController);
+ Core::HID::NpadStyleIndex::ProController);
emulated_controllers[player_index]->addItem(tr("Pro Controller"));
pairs.emplace_back(emulated_controllers[player_index]->count(),
- Settings::ControllerType::DualJoyconDetached);
+ Core::HID::NpadStyleIndex::JoyconDual);
emulated_controllers[player_index]->addItem(tr("Dual Joycons"));
pairs.emplace_back(emulated_controllers[player_index]->count(),
- Settings::ControllerType::LeftJoycon);
+ Core::HID::NpadStyleIndex::JoyconLeft);
emulated_controllers[player_index]->addItem(tr("Left Joycon"));
pairs.emplace_back(emulated_controllers[player_index]->count(),
- Settings::ControllerType::RightJoycon);
+ Core::HID::NpadStyleIndex::JoyconRight);
emulated_controllers[player_index]->addItem(tr("Right Joycon"));
if (player_index == 0) {
pairs.emplace_back(emulated_controllers[player_index]->count(),
- Settings::ControllerType::Handheld);
+ Core::HID::NpadStyleIndex::Handheld);
emulated_controllers[player_index]->addItem(tr("Handheld"));
}
pairs.emplace_back(emulated_controllers[player_index]->count(),
- Settings::ControllerType::GameCube);
+ Core::HID::NpadStyleIndex::GameCube);
emulated_controllers[player_index]->addItem(tr("GameCube Controller"));
}
-Settings::ControllerType QtControllerSelectorDialog::GetControllerTypeFromIndex(
+Core::HID::NpadStyleIndex QtControllerSelectorDialog::GetControllerTypeFromIndex(
int index, std::size_t player_index) const {
const auto& pairs = index_controller_type_pairs[player_index];
@@ -449,13 +441,13 @@ Settings::ControllerType QtControllerSelectorDialog::GetControllerTypeFromIndex(
[index](const auto& pair) { return pair.first == index; });
if (it == pairs.end()) {
- return Settings::ControllerType::ProController;
+ return Core::HID::NpadStyleIndex::ProController;
}
return it->second;
}
-int QtControllerSelectorDialog::GetIndexFromControllerType(Settings::ControllerType type,
+int QtControllerSelectorDialog::GetIndexFromControllerType(Core::HID::NpadStyleIndex type,
std::size_t player_index) const {
const auto& pairs = index_controller_type_pairs[player_index];
@@ -479,16 +471,16 @@ void QtControllerSelectorDialog::UpdateControllerIcon(std::size_t player_index)
const QString stylesheet = [this, player_index] {
switch (GetControllerTypeFromIndex(emulated_controllers[player_index]->currentIndex(),
player_index)) {
- case Settings::ControllerType::ProController:
- case Settings::ControllerType::GameCube:
+ case Core::HID::NpadStyleIndex::ProController:
+ case Core::HID::NpadStyleIndex::GameCube:
return QStringLiteral("image: url(:/controller/applet_pro_controller%0); ");
- case Settings::ControllerType::DualJoyconDetached:
+ case Core::HID::NpadStyleIndex::JoyconDual:
return QStringLiteral("image: url(:/controller/applet_dual_joycon%0); ");
- case Settings::ControllerType::LeftJoycon:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
return QStringLiteral("image: url(:/controller/applet_joycon_left%0); ");
- case Settings::ControllerType::RightJoycon:
+ case Core::HID::NpadStyleIndex::JoyconRight:
return QStringLiteral("image: url(:/controller/applet_joycon_right%0); ");
- case Settings::ControllerType::Handheld:
+ case Core::HID::NpadStyleIndex::Handheld:
return QStringLiteral("image: url(:/controller/applet_handheld%0); ");
default:
return QString{};
@@ -516,54 +508,38 @@ void QtControllerSelectorDialog::UpdateControllerIcon(std::size_t player_index)
}
void QtControllerSelectorDialog::UpdateControllerState(std::size_t player_index) {
- auto& player = Settings::values.players.GetValue()[player_index];
+ auto* controller = system.HIDCore().GetEmulatedControllerByIndex(player_index);
const auto controller_type = GetControllerTypeFromIndex(
emulated_controllers[player_index]->currentIndex(), player_index);
const auto player_connected = player_groupboxes[player_index]->isChecked() &&
- controller_type != Settings::ControllerType::Handheld;
+ controller_type != Core::HID::NpadStyleIndex::Handheld;
- if (player.controller_type == controller_type && player.connected == player_connected) {
- // Set vibration devices in the event that the input device has changed.
- ConfigureVibration::SetVibrationDevices(player_index);
+ if (controller->GetNpadStyleIndex(true) == controller_type &&
+ controller->IsConnected(true) == player_connected) {
return;
}
// Disconnect the controller first.
- UpdateController(controller_type, player_index, false, system);
-
- player.controller_type = controller_type;
- player.connected = player_connected;
-
- ConfigureVibration::SetVibrationDevices(player_index);
+ UpdateController(controller, controller_type, false);
// Handheld
if (player_index == 0) {
- auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
- if (controller_type == Settings::ControllerType::Handheld) {
- handheld = player;
+ if (controller_type == Core::HID::NpadStyleIndex::Handheld) {
+ auto* handheld =
+ system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ UpdateController(handheld, Core::HID::NpadStyleIndex::Handheld,
+ player_groupboxes[player_index]->isChecked());
}
- handheld.connected = player_groupboxes[player_index]->isChecked() &&
- controller_type == Settings::ControllerType::Handheld;
- UpdateController(Settings::ControllerType::Handheld, 8, handheld.connected, system);
- }
-
- if (!player.connected) {
- return;
}
- // This emulates a delay between disconnecting and reconnecting controllers as some games
- // do not respond to a change in controller type if it was instantaneous.
- using namespace std::chrono_literals;
- std::this_thread::sleep_for(60ms);
-
- UpdateController(controller_type, player_index, player_connected, system);
+ UpdateController(controller, controller_type, player_connected);
}
void QtControllerSelectorDialog::UpdateLEDPattern(std::size_t player_index) {
if (!player_groupboxes[player_index]->isChecked() ||
GetControllerTypeFromIndex(emulated_controllers[player_index]->currentIndex(),
- player_index) == Settings::ControllerType::Handheld) {
+ player_index) == Core::HID::NpadStyleIndex::Handheld) {
led_patterns_boxes[player_index][0]->setChecked(false);
led_patterns_boxes[player_index][1]->setChecked(false);
led_patterns_boxes[player_index][2]->setChecked(false);
@@ -571,10 +547,12 @@ void QtControllerSelectorDialog::UpdateLEDPattern(std::size_t player_index) {
return;
}
- led_patterns_boxes[player_index][0]->setChecked(led_patterns[player_index][0]);
- led_patterns_boxes[player_index][1]->setChecked(led_patterns[player_index][1]);
- led_patterns_boxes[player_index][2]->setChecked(led_patterns[player_index][2]);
- led_patterns_boxes[player_index][3]->setChecked(led_patterns[player_index][3]);
+ const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(player_index);
+ const auto led_pattern = controller->GetLedPattern();
+ led_patterns_boxes[player_index][0]->setChecked(led_pattern.position1);
+ led_patterns_boxes[player_index][1]->setChecked(led_pattern.position2);
+ led_patterns_boxes[player_index][2]->setChecked(led_pattern.position3);
+ led_patterns_boxes[player_index][3]->setChecked(led_pattern.position4);
}
void QtControllerSelectorDialog::UpdateBorderColor(std::size_t player_index) {
@@ -654,10 +632,9 @@ void QtControllerSelectorDialog::DisableUnsupportedPlayers() {
}
for (std::size_t index = max_supported_players; index < NUM_PLAYERS; ++index) {
+ auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index);
// Disconnect any unsupported players here and disable or hide them if applicable.
- Settings::values.players.GetValue()[index].connected = false;
- UpdateController(Settings::values.players.GetValue()[index].controller_type, index, false,
- system);
+ UpdateController(controller, controller->GetNpadStyleIndex(true), false);
// Hide the player widgets when max_supported_controllers is less than or equal to 4.
if (max_supported_players <= 4) {
player_widgets[index]->hide();
diff --git a/src/yuzu/applets/qt_controller.h b/src/yuzu/applets/qt_controller.h
index 037325f50..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;
@@ -23,14 +22,19 @@ namespace InputCommon {
class InputSubsystem;
}
-namespace Settings {
-enum class ControllerType;
-}
-
namespace Ui {
class QtControllerSelectorDialog;
}
+namespace Core {
+class System;
+}
+
+namespace Core::HID {
+class HIDCore;
+enum class NpadStyleIndex : u8;
+} // namespace Core::HID
+
class QtControllerSelectorDialog final : public QDialog {
Q_OBJECT
@@ -70,10 +74,10 @@ private:
void SetEmulatedControllers(std::size_t player_index);
// Gets the Controller Type for a given controller combobox index per player.
- Settings::ControllerType GetControllerTypeFromIndex(int index, std::size_t player_index) const;
+ Core::HID::NpadStyleIndex GetControllerTypeFromIndex(int index, std::size_t player_index) const;
// Gets the controller combobox index for a given Controller Type per player.
- int GetIndexFromControllerType(Settings::ControllerType type, std::size_t player_index) const;
+ int GetIndexFromControllerType(Core::HID::NpadStyleIndex type, std::size_t player_index) const;
// Updates the controller icons per player.
void UpdateControllerIcon(std::size_t player_index);
@@ -135,7 +139,7 @@ private:
std::array<QComboBox*, NUM_PLAYERS> emulated_controllers;
/// Pairs of emulated controller index and Controller Type enum per player.
- std::array<std::vector<std::pair<int, Settings::ControllerType>>, NUM_PLAYERS>
+ std::array<std::vector<std::pair<int, Core::HID::NpadStyleIndex>>, NUM_PLAYERS>
index_controller_type_pairs;
// Labels representing the number of connected controllers
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 a83a11a95..c3857fc98 100644
--- a/src/yuzu/applets/qt_software_keyboard.cpp
+++ b/src/yuzu/applets/qt_software_keyboard.cpp
@@ -10,7 +10,10 @@
#include "common/settings.h"
#include "common/string_util.h"
#include "core/core.h"
-#include "core/frontend/input_interpreter.h"
+#include "core/hid/emulated_controller.h"
+#include "core/hid/hid_core.h"
+#include "core/hid/hid_types.h"
+#include "core/hid/input_interpreter.h"
#include "ui_qt_software_keyboard.h"
#include "yuzu/applets/qt_software_keyboard.h"
#include "yuzu/main.h"
@@ -472,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();
}
@@ -484,7 +502,7 @@ void QtSoftwareKeyboardDialog::open() {
void QtSoftwareKeyboardDialog::reject() {
// Pressing the ESC key in a dialog calls QDialog::reject().
// We will override this behavior to the "Cancel" action on the software keyboard.
- TranslateButtonPress(HIDButton::X);
+ TranslateButtonPress(Core::HID::NpadButton::X);
}
void QtSoftwareKeyboardDialog::keyPressEvent(QKeyEvent* event) {
@@ -722,7 +740,7 @@ void QtSoftwareKeyboardDialog::SetTextDrawType() {
connect(
ui->line_edit_osk, &QLineEdit::returnPressed, this,
- [this] { TranslateButtonPress(HIDButton::Plus); }, Qt::QueuedConnection);
+ [this] { TranslateButtonPress(Core::HID::NpadButton::Plus); }, Qt::QueuedConnection);
ui->line_edit_osk->setPlaceholderText(
QString::fromStdU16String(initialize_parameters.guide_text));
@@ -795,9 +813,10 @@ void QtSoftwareKeyboardDialog::SetTextDrawType() {
}
void QtSoftwareKeyboardDialog::SetControllerImage() {
- const auto controller_type = Settings::values.players.GetValue()[8].connected
- ? Settings::values.players.GetValue()[8].controller_type
- : Settings::values.players.GetValue()[0].controller_type;
+ const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ const auto* player_1 = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
+ const auto controller_type =
+ handheld->IsConnected() ? handheld->GetNpadStyleIndex() : player_1->GetNpadStyleIndex();
const QString theme = [] {
if (QIcon::themeName().contains(QStringLiteral("dark")) ||
@@ -809,8 +828,8 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
}();
switch (controller_type) {
- case Settings::ControllerType::ProController:
- case Settings::ControllerType::GameCube:
+ case Core::HID::NpadStyleIndex::ProController:
+ case Core::HID::NpadStyleIndex::GameCube:
ui->icon_controller->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_pro%1.png);").arg(theme));
ui->icon_controller_shift->setStyleSheet(
@@ -818,7 +837,7 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
ui->icon_controller_num->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_pro%1.png);").arg(theme));
break;
- case Settings::ControllerType::DualJoyconDetached:
+ case Core::HID::NpadStyleIndex::JoyconDual:
ui->icon_controller->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_dual_joycon%1.png);").arg(theme));
ui->icon_controller_shift->setStyleSheet(
@@ -826,7 +845,7 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
ui->icon_controller_num->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_dual_joycon%1.png);").arg(theme));
break;
- case Settings::ControllerType::LeftJoycon:
+ case Core::HID::NpadStyleIndex::JoyconLeft:
ui->icon_controller->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_single_joycon_left%1.png);")
.arg(theme));
@@ -837,7 +856,7 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
QStringLiteral("image: url(:/overlay/controller_single_joycon_left%1.png);")
.arg(theme));
break;
- case Settings::ControllerType::RightJoycon:
+ case Core::HID::NpadStyleIndex::JoyconRight:
ui->icon_controller->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_single_joycon_right%1.png);")
.arg(theme));
@@ -848,7 +867,7 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
QStringLiteral("image: url(:/overlay/controller_single_joycon_right%1.png);")
.arg(theme));
break;
- case Settings::ControllerType::Handheld:
+ case Core::HID::NpadStyleIndex::Handheld:
ui->icon_controller->setStyleSheet(
QStringLiteral("image: url(:/overlay/controller_handheld%1.png);").arg(theme));
ui->icon_controller_shift->setStyleSheet(
@@ -1208,9 +1227,9 @@ void QtSoftwareKeyboardDialog::SetupMouseHover() {
}
}
-template <HIDButton... T>
+template <Core::HID::NpadButton... T>
void QtSoftwareKeyboardDialog::HandleButtonPressedOnce() {
- const auto f = [this](HIDButton button) {
+ const auto f = [this](Core::HID::NpadButton button) {
if (input_interpreter->IsButtonPressedOnce(button)) {
TranslateButtonPress(button);
}
@@ -1219,9 +1238,9 @@ void QtSoftwareKeyboardDialog::HandleButtonPressedOnce() {
(f(T), ...);
}
-template <HIDButton... T>
+template <Core::HID::NpadButton... T>
void QtSoftwareKeyboardDialog::HandleButtonHold() {
- const auto f = [this](HIDButton button) {
+ const auto f = [this](Core::HID::NpadButton button) {
if (input_interpreter->IsButtonHeld(button)) {
TranslateButtonPress(button);
}
@@ -1230,9 +1249,9 @@ void QtSoftwareKeyboardDialog::HandleButtonHold() {
(f(T), ...);
}
-void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
+void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button) {
switch (button) {
- case HIDButton::A:
+ case Core::HID::NpadButton::A:
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
case BottomOSKIndex::UpperCase:
@@ -1245,7 +1264,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
break;
}
break;
- case HIDButton::B:
+ case Core::HID::NpadButton::B:
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
ui->button_backspace->click();
@@ -1260,7 +1279,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
break;
}
break;
- case HIDButton::X:
+ case Core::HID::NpadButton::X:
if (is_inline) {
emit SubmitInlineText(SwkbdReplyType::DecidedCancel, current_text, cursor_position);
} else {
@@ -1271,7 +1290,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
emit SubmitNormalText(SwkbdResult::Cancel, std::move(text));
}
break;
- case HIDButton::Y:
+ case Core::HID::NpadButton::Y:
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
ui->button_space->click();
@@ -1284,8 +1303,8 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
break;
}
break;
- case HIDButton::LStick:
- case HIDButton::RStick:
+ case Core::HID::NpadButton::StickL:
+ case Core::HID::NpadButton::StickR:
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
ui->button_shift->click();
@@ -1298,13 +1317,13 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
break;
}
break;
- case HIDButton::L:
+ case Core::HID::NpadButton::L:
MoveTextCursorDirection(Direction::Left);
break;
- case HIDButton::R:
+ case Core::HID::NpadButton::R:
MoveTextCursorDirection(Direction::Right);
break;
- case HIDButton::Plus:
+ case Core::HID::NpadButton::Plus:
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
ui->button_ok->click();
@@ -1319,24 +1338,24 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
break;
}
break;
- case HIDButton::DLeft:
- case HIDButton::LStickLeft:
- case HIDButton::RStickLeft:
+ case Core::HID::NpadButton::Left:
+ case Core::HID::NpadButton::StickLLeft:
+ case Core::HID::NpadButton::StickRLeft:
MoveButtonDirection(Direction::Left);
break;
- case HIDButton::DUp:
- case HIDButton::LStickUp:
- case HIDButton::RStickUp:
+ case Core::HID::NpadButton::Up:
+ case Core::HID::NpadButton::StickLUp:
+ case Core::HID::NpadButton::StickRUp:
MoveButtonDirection(Direction::Up);
break;
- case HIDButton::DRight:
- case HIDButton::LStickRight:
- case HIDButton::RStickRight:
+ case Core::HID::NpadButton::Right:
+ case Core::HID::NpadButton::StickLRight:
+ case Core::HID::NpadButton::StickRRight:
MoveButtonDirection(Direction::Right);
break;
- case HIDButton::DDown:
- case HIDButton::LStickDown:
- case HIDButton::RStickDown:
+ case Core::HID::NpadButton::Down:
+ case Core::HID::NpadButton::StickLDown:
+ case Core::HID::NpadButton::StickRDown:
MoveButtonDirection(Direction::Down);
break;
default:
@@ -1467,19 +1486,25 @@ void QtSoftwareKeyboardDialog::InputThread() {
while (input_thread_running) {
input_interpreter->PollInput();
- HandleButtonPressedOnce<HIDButton::A, HIDButton::B, HIDButton::X, HIDButton::Y,
- HIDButton::LStick, HIDButton::RStick, HIDButton::L, HIDButton::R,
- HIDButton::Plus, HIDButton::DLeft, HIDButton::DUp,
- HIDButton::DRight, HIDButton::DDown, HIDButton::LStickLeft,
- HIDButton::LStickUp, HIDButton::LStickRight, HIDButton::LStickDown,
- HIDButton::RStickLeft, HIDButton::RStickUp, HIDButton::RStickRight,
- HIDButton::RStickDown>();
-
- HandleButtonHold<HIDButton::B, HIDButton::L, HIDButton::R, HIDButton::DLeft, HIDButton::DUp,
- HIDButton::DRight, HIDButton::DDown, HIDButton::LStickLeft,
- HIDButton::LStickUp, HIDButton::LStickRight, HIDButton::LStickDown,
- HIDButton::RStickLeft, HIDButton::RStickUp, HIDButton::RStickRight,
- HIDButton::RStickDown>();
+ HandleButtonPressedOnce<
+ Core::HID::NpadButton::A, Core::HID::NpadButton::B, Core::HID::NpadButton::X,
+ Core::HID::NpadButton::Y, Core::HID::NpadButton::StickL, Core::HID::NpadButton::StickR,
+ Core::HID::NpadButton::L, Core::HID::NpadButton::R, Core::HID::NpadButton::Plus,
+ Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right,
+ Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft,
+ Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight,
+ Core::HID::NpadButton::StickLDown, Core::HID::NpadButton::StickRLeft,
+ Core::HID::NpadButton::StickRUp, Core::HID::NpadButton::StickRRight,
+ Core::HID::NpadButton::StickRDown>();
+
+ HandleButtonHold<Core::HID::NpadButton::B, Core::HID::NpadButton::L,
+ Core::HID::NpadButton::R, Core::HID::NpadButton::Left,
+ Core::HID::NpadButton::Up, Core::HID::NpadButton::Right,
+ Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft,
+ Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight,
+ Core::HID::NpadButton::StickLDown, Core::HID::NpadButton::StickRLeft,
+ Core::HID::NpadButton::StickRUp, Core::HID::NpadButton::StickRRight,
+ Core::HID::NpadButton::StickRDown>();
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
diff --git a/src/yuzu/applets/qt_software_keyboard.h b/src/yuzu/applets/qt_software_keyboard.h
index 592d9c085..b030cdcf7 100644
--- a/src/yuzu/applets/qt_software_keyboard.h
+++ b/src/yuzu/applets/qt_software_keyboard.h
@@ -14,14 +14,16 @@
#include "core/frontend/applets/software_keyboard.h"
-enum class HIDButton : u8;
-
class InputInterpreter;
namespace Core {
class System;
}
+namespace Core::HID {
+enum class NpadButton : u64;
+}
+
namespace Ui {
class QtSoftwareKeyboardDialog;
}
@@ -146,7 +148,7 @@ private:
*
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
*/
- template <HIDButton... T>
+ template <Core::HID::NpadButton... T>
void HandleButtonPressedOnce();
/**
@@ -154,7 +156,7 @@ private:
*
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
*/
- template <HIDButton... T>
+ template <Core::HID::NpadButton... T>
void HandleButtonHold();
/**
@@ -162,7 +164,7 @@ private:
*
* @param button The button press to process.
*/
- void TranslateButtonPress(HIDButton button);
+ void TranslateButtonPress(Core::HID::NpadButton button);
/**
* Moves the focus of a button in a certain direction.
diff --git a/src/yuzu/applets/qt_web_browser.cpp b/src/yuzu/applets/qt_web_browser.cpp
index da8c6882a..cb3c5d826 100644
--- a/src/yuzu/applets/qt_web_browser.cpp
+++ b/src/yuzu/applets/qt_web_browser.cpp
@@ -14,9 +14,11 @@
#endif
#include "common/fs/path_util.h"
+#include "common/param_package.h"
#include "core/core.h"
-#include "core/frontend/input_interpreter.h"
-#include "input_common/keyboard.h"
+#include "core/hid/hid_types.h"
+#include "core/hid/input_interpreter.h"
+#include "input_common/drivers/keyboard.h"
#include "input_common/main.h"
#include "yuzu/applets/qt_web_browser.h"
#include "yuzu/applets/qt_web_browser_scripts.h"
@@ -27,19 +29,19 @@
namespace {
-constexpr int HIDButtonToKey(HIDButton button) {
+constexpr int HIDButtonToKey(Core::HID::NpadButton button) {
switch (button) {
- case HIDButton::DLeft:
- case HIDButton::LStickLeft:
+ case Core::HID::NpadButton::Left:
+ case Core::HID::NpadButton::StickLLeft:
return Qt::Key_Left;
- case HIDButton::DUp:
- case HIDButton::LStickUp:
+ case Core::HID::NpadButton::Up:
+ case Core::HID::NpadButton::StickLUp:
return Qt::Key_Up;
- case HIDButton::DRight:
- case HIDButton::LStickRight:
+ case Core::HID::NpadButton::Right:
+ case Core::HID::NpadButton::StickLRight:
return Qt::Key_Right;
- case HIDButton::DDown:
- case HIDButton::LStickDown:
+ case Core::HID::NpadButton::Down:
+ case Core::HID::NpadButton::StickLDown:
return Qt::Key_Down;
default:
return 0;
@@ -208,25 +210,25 @@ void QtNXWebEngineView::keyReleaseEvent(QKeyEvent* event) {
}
}
-template <HIDButton... T>
+template <Core::HID::NpadButton... T>
void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
- const auto f = [this](HIDButton button) {
+ const auto f = [this](Core::HID::NpadButton button) {
if (input_interpreter->IsButtonPressedOnce(button)) {
page()->runJavaScript(
QStringLiteral("yuzu_key_callbacks[%1] == null;").arg(static_cast<u8>(button)),
[this, button](const QVariant& variant) {
if (variant.toBool()) {
switch (button) {
- case HIDButton::A:
+ case Core::HID::NpadButton::A:
SendMultipleKeyPressEvents<Qt::Key_A, Qt::Key_Space, Qt::Key_Return>();
break;
- case HIDButton::B:
+ case Core::HID::NpadButton::B:
SendKeyPressEvent(Qt::Key_B);
break;
- case HIDButton::X:
+ case Core::HID::NpadButton::X:
SendKeyPressEvent(Qt::Key_X);
break;
- case HIDButton::Y:
+ case Core::HID::NpadButton::Y:
SendKeyPressEvent(Qt::Key_Y);
break;
default:
@@ -244,9 +246,9 @@ void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
(f(T), ...);
}
-template <HIDButton... T>
+template <Core::HID::NpadButton... T>
void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() {
- const auto f = [this](HIDButton button) {
+ const auto f = [this](Core::HID::NpadButton button) {
if (input_interpreter->IsButtonPressedOnce(button)) {
SendKeyPressEvent(HIDButtonToKey(button));
}
@@ -255,9 +257,9 @@ void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() {
(f(T), ...);
}
-template <HIDButton... T>
+template <Core::HID::NpadButton... T>
void QtNXWebEngineView::HandleWindowKeyButtonHold() {
- const auto f = [this](HIDButton button) {
+ const auto f = [this](Core::HID::NpadButton button) {
if (input_interpreter->IsButtonHeld(button)) {
SendKeyPressEvent(HIDButtonToKey(button));
}
@@ -308,17 +310,21 @@ void QtNXWebEngineView::InputThread() {
while (input_thread_running) {
input_interpreter->PollInput();
- HandleWindowFooterButtonPressedOnce<HIDButton::A, HIDButton::B, HIDButton::X, HIDButton::Y,
- HIDButton::L, HIDButton::R>();
-
- HandleWindowKeyButtonPressedOnce<HIDButton::DLeft, HIDButton::DUp, HIDButton::DRight,
- HIDButton::DDown, HIDButton::LStickLeft,
- HIDButton::LStickUp, HIDButton::LStickRight,
- HIDButton::LStickDown>();
-
- HandleWindowKeyButtonHold<HIDButton::DLeft, HIDButton::DUp, HIDButton::DRight,
- HIDButton::DDown, HIDButton::LStickLeft, HIDButton::LStickUp,
- HIDButton::LStickRight, HIDButton::LStickDown>();
+ HandleWindowFooterButtonPressedOnce<Core::HID::NpadButton::A, Core::HID::NpadButton::B,
+ Core::HID::NpadButton::X, Core::HID::NpadButton::Y,
+ Core::HID::NpadButton::L, Core::HID::NpadButton::R>();
+
+ HandleWindowKeyButtonPressedOnce<
+ Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right,
+ Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft,
+ Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight,
+ Core::HID::NpadButton::StickLDown>();
+
+ HandleWindowKeyButtonHold<
+ Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right,
+ Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft,
+ Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight,
+ Core::HID::NpadButton::StickLDown>();
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
diff --git a/src/yuzu/applets/qt_web_browser.h b/src/yuzu/applets/qt_web_browser.h
index 7e9f703fc..fa18aecac 100644
--- a/src/yuzu/applets/qt_web_browser.h
+++ b/src/yuzu/applets/qt_web_browser.h
@@ -16,8 +16,6 @@
#include "core/frontend/applets/web_browser.h"
-enum class HIDButton : u8;
-
class GMainWindow;
class InputInterpreter;
class UrlRequestInterceptor;
@@ -26,6 +24,10 @@ namespace Core {
class System;
}
+namespace Core::HID {
+enum class NpadButton : u64;
+}
+
namespace InputCommon {
class InputSubsystem;
}
@@ -114,7 +116,7 @@ private:
*
* @tparam HIDButton The list of buttons contained in yuzu_key_callbacks
*/
- template <HIDButton... T>
+ template <Core::HID::NpadButton... T>
void HandleWindowFooterButtonPressedOnce();
/**
@@ -123,7 +125,7 @@ private:
*
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
*/
- template <HIDButton... T>
+ template <Core::HID::NpadButton... T>
void HandleWindowKeyButtonPressedOnce();
/**
@@ -132,7 +134,7 @@ private:
*
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
*/
- template <HIDButton... T>
+ template <Core::HID::NpadButton... T>
void HandleWindowKeyButtonHold();
/**