early-access version 2199
This commit is contained in:
@@ -6,12 +6,8 @@
|
||||
#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"
|
||||
@@ -27,32 +23,49 @@
|
||||
|
||||
namespace {
|
||||
|
||||
void UpdateController(Core::HID::EmulatedController* controller,
|
||||
Core::HID::NpadStyleIndex controller_type, bool connected) {
|
||||
if (controller->IsConnected()) {
|
||||
controller->Disconnect();
|
||||
}
|
||||
controller->SetNpadStyleIndex(controller_type);
|
||||
if (connected) {
|
||||
controller->Connect();
|
||||
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;
|
||||
}
|
||||
|
||||
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(Core::HID::NpadStyleIndex controller_type,
|
||||
bool IsControllerCompatible(Settings::ControllerType controller_type,
|
||||
Core::Frontend::ControllerParameters parameters) {
|
||||
switch (controller_type) {
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
case Settings::ControllerType::ProController:
|
||||
return parameters.allow_pro_controller;
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
case Settings::ControllerType::DualJoyconDetached:
|
||||
return parameters.allow_dual_joycons;
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
case Settings::ControllerType::LeftJoycon:
|
||||
return parameters.allow_left_joycon;
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
case Settings::ControllerType::RightJoycon:
|
||||
return parameters.allow_right_joycon;
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
case Settings::ControllerType::Handheld:
|
||||
return parameters.enable_single_mode && parameters.allow_handheld;
|
||||
case Core::HID::NpadStyleIndex::GameCube:
|
||||
case Settings::ControllerType::GameCube:
|
||||
return parameters.allow_gamecube_controller;
|
||||
default:
|
||||
return false;
|
||||
@@ -183,7 +196,7 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
|
||||
connect(emulated_controllers[i], qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
[this, i](int index) {
|
||||
UpdateDockedState(GetControllerTypeFromIndex(index, i) ==
|
||||
Core::HID::NpadStyleIndex::Handheld);
|
||||
Settings::ControllerType::Handheld);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -236,17 +249,17 @@ void QtControllerSelectorDialog::ApplyConfiguration() {
|
||||
}
|
||||
|
||||
void QtControllerSelectorDialog::LoadConfiguration() {
|
||||
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 = controller->IsConnected() || (index == 0 && handheld->IsConnected());
|
||||
const auto connected =
|
||||
Settings::values.players.GetValue()[index].connected ||
|
||||
(index == 0 && Settings::values.players.GetValue()[HANDHELD_INDEX].connected);
|
||||
player_groupboxes[index]->setChecked(connected);
|
||||
connected_controller_checkboxes[index]->setChecked(connected);
|
||||
emulated_controllers[index]->setCurrentIndex(
|
||||
GetIndexFromControllerType(controller->GetNpadStyleIndex(), index));
|
||||
emulated_controllers[index]->setCurrentIndex(GetIndexFromControllerType(
|
||||
Settings::values.players.GetValue()[index].controller_type, index));
|
||||
}
|
||||
|
||||
UpdateDockedState(handheld->IsConnected());
|
||||
UpdateDockedState(Settings::values.players.GetValue()[HANDHELD_INDEX].connected);
|
||||
|
||||
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
|
||||
ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue());
|
||||
@@ -402,33 +415,33 @@ void QtControllerSelectorDialog::SetEmulatedControllers(std::size_t player_index
|
||||
emulated_controllers[player_index]->clear();
|
||||
|
||||
pairs.emplace_back(emulated_controllers[player_index]->count(),
|
||||
Core::HID::NpadStyleIndex::ProController);
|
||||
Settings::ControllerType::ProController);
|
||||
emulated_controllers[player_index]->addItem(tr("Pro Controller"));
|
||||
|
||||
pairs.emplace_back(emulated_controllers[player_index]->count(),
|
||||
Core::HID::NpadStyleIndex::JoyconDual);
|
||||
Settings::ControllerType::DualJoyconDetached);
|
||||
emulated_controllers[player_index]->addItem(tr("Dual Joycons"));
|
||||
|
||||
pairs.emplace_back(emulated_controllers[player_index]->count(),
|
||||
Core::HID::NpadStyleIndex::JoyconLeft);
|
||||
Settings::ControllerType::LeftJoycon);
|
||||
emulated_controllers[player_index]->addItem(tr("Left Joycon"));
|
||||
|
||||
pairs.emplace_back(emulated_controllers[player_index]->count(),
|
||||
Core::HID::NpadStyleIndex::JoyconRight);
|
||||
Settings::ControllerType::RightJoycon);
|
||||
emulated_controllers[player_index]->addItem(tr("Right Joycon"));
|
||||
|
||||
if (player_index == 0) {
|
||||
pairs.emplace_back(emulated_controllers[player_index]->count(),
|
||||
Core::HID::NpadStyleIndex::Handheld);
|
||||
Settings::ControllerType::Handheld);
|
||||
emulated_controllers[player_index]->addItem(tr("Handheld"));
|
||||
}
|
||||
|
||||
pairs.emplace_back(emulated_controllers[player_index]->count(),
|
||||
Core::HID::NpadStyleIndex::GameCube);
|
||||
Settings::ControllerType::GameCube);
|
||||
emulated_controllers[player_index]->addItem(tr("GameCube Controller"));
|
||||
}
|
||||
|
||||
Core::HID::NpadStyleIndex QtControllerSelectorDialog::GetControllerTypeFromIndex(
|
||||
Settings::ControllerType QtControllerSelectorDialog::GetControllerTypeFromIndex(
|
||||
int index, std::size_t player_index) const {
|
||||
const auto& pairs = index_controller_type_pairs[player_index];
|
||||
|
||||
@@ -436,13 +449,13 @@ Core::HID::NpadStyleIndex QtControllerSelectorDialog::GetControllerTypeFromIndex
|
||||
[index](const auto& pair) { return pair.first == index; });
|
||||
|
||||
if (it == pairs.end()) {
|
||||
return Core::HID::NpadStyleIndex::ProController;
|
||||
return Settings::ControllerType::ProController;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
int QtControllerSelectorDialog::GetIndexFromControllerType(Core::HID::NpadStyleIndex type,
|
||||
int QtControllerSelectorDialog::GetIndexFromControllerType(Settings::ControllerType type,
|
||||
std::size_t player_index) const {
|
||||
const auto& pairs = index_controller_type_pairs[player_index];
|
||||
|
||||
@@ -466,16 +479,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 Core::HID::NpadStyleIndex::ProController:
|
||||
case Core::HID::NpadStyleIndex::GameCube:
|
||||
case Settings::ControllerType::ProController:
|
||||
case Settings::ControllerType::GameCube:
|
||||
return QStringLiteral("image: url(:/controller/applet_pro_controller%0); ");
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
case Settings::ControllerType::DualJoyconDetached:
|
||||
return QStringLiteral("image: url(:/controller/applet_dual_joycon%0); ");
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
case Settings::ControllerType::LeftJoycon:
|
||||
return QStringLiteral("image: url(:/controller/applet_joycon_left%0); ");
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
case Settings::ControllerType::RightJoycon:
|
||||
return QStringLiteral("image: url(:/controller/applet_joycon_right%0); ");
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
case Settings::ControllerType::Handheld:
|
||||
return QStringLiteral("image: url(:/controller/applet_handheld%0); ");
|
||||
default:
|
||||
return QString{};
|
||||
@@ -503,42 +516,54 @@ void QtControllerSelectorDialog::UpdateControllerIcon(std::size_t player_index)
|
||||
}
|
||||
|
||||
void QtControllerSelectorDialog::UpdateControllerState(std::size_t player_index) {
|
||||
auto* controller = system.HIDCore().GetEmulatedControllerByIndex(player_index);
|
||||
auto& player = Settings::values.players.GetValue()[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 != Core::HID::NpadStyleIndex::Handheld;
|
||||
controller_type != Settings::ControllerType::Handheld;
|
||||
|
||||
if (controller->GetNpadStyleIndex() == controller_type &&
|
||||
controller->IsConnected() == player_connected) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
// Disconnect the controller first.
|
||||
UpdateController(controller, controller_type, false);
|
||||
UpdateController(controller_type, player_index, false, system);
|
||||
|
||||
player.controller_type = controller_type;
|
||||
player.connected = player_connected;
|
||||
|
||||
ConfigureVibration::SetVibrationDevices(player_index);
|
||||
|
||||
// Handheld
|
||||
if (player_index == 0) {
|
||||
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());
|
||||
auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
|
||||
if (controller_type == Settings::ControllerType::Handheld) {
|
||||
handheld = player;
|
||||
}
|
||||
handheld.connected = player_groupboxes[player_index]->isChecked() &&
|
||||
controller_type == Settings::ControllerType::Handheld;
|
||||
UpdateController(Settings::ControllerType::Handheld, 8, handheld.connected, system);
|
||||
}
|
||||
|
||||
UpdateController(controller, controller_type, player_connected);
|
||||
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);
|
||||
}
|
||||
|
||||
void QtControllerSelectorDialog::UpdateLEDPattern(std::size_t player_index) {
|
||||
if (!player_groupboxes[player_index]->isChecked() ||
|
||||
GetControllerTypeFromIndex(emulated_controllers[player_index]->currentIndex(),
|
||||
player_index) == Core::HID::NpadStyleIndex::Handheld) {
|
||||
player_index) == Settings::ControllerType::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);
|
||||
@@ -546,12 +571,10 @@ void QtControllerSelectorDialog::UpdateLEDPattern(std::size_t player_index) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
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]);
|
||||
}
|
||||
|
||||
void QtControllerSelectorDialog::UpdateBorderColor(std::size_t player_index) {
|
||||
@@ -631,9 +654,10 @@ 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.
|
||||
UpdateController(controller, controller->GetNpadStyleIndex(), false);
|
||||
Settings::values.players.GetValue()[index].connected = false;
|
||||
UpdateController(Settings::values.players.GetValue()[index].controller_type, index, false,
|
||||
system);
|
||||
// Hide the player widgets when max_supported_controllers is less than or equal to 4.
|
||||
if (max_supported_players <= 4) {
|
||||
player_widgets[index]->hide();
|
||||
|
||||
@@ -23,18 +23,14 @@ namespace InputCommon {
|
||||
class InputSubsystem;
|
||||
}
|
||||
|
||||
namespace Settings {
|
||||
enum class ControllerType;
|
||||
}
|
||||
|
||||
namespace Ui {
|
||||
class QtControllerSelectorDialog;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Core::HID {
|
||||
enum class NpadStyleIndex : u8;
|
||||
}
|
||||
|
||||
class QtControllerSelectorDialog final : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -74,10 +70,10 @@ private:
|
||||
void SetEmulatedControllers(std::size_t player_index);
|
||||
|
||||
// Gets the Controller Type for a given controller combobox index per player.
|
||||
Core::HID::NpadStyleIndex GetControllerTypeFromIndex(int index, std::size_t player_index) const;
|
||||
Settings::ControllerType GetControllerTypeFromIndex(int index, std::size_t player_index) const;
|
||||
|
||||
// Gets the controller combobox index for a given Controller Type per player.
|
||||
int GetIndexFromControllerType(Core::HID::NpadStyleIndex type, std::size_t player_index) const;
|
||||
int GetIndexFromControllerType(Settings::ControllerType type, std::size_t player_index) const;
|
||||
|
||||
// Updates the controller icons per player.
|
||||
void UpdateControllerIcon(std::size_t player_index);
|
||||
@@ -139,7 +135,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, Core::HID::NpadStyleIndex>>, NUM_PLAYERS>
|
||||
std::array<std::vector<std::pair<int, Settings::ControllerType>>, NUM_PLAYERS>
|
||||
index_controller_type_pairs;
|
||||
|
||||
// Labels representing the number of connected controllers
|
||||
|
||||
@@ -10,10 +10,7 @@
|
||||
#include "common/settings.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/hid/input_interpreter.h"
|
||||
#include "core/frontend/input_interpreter.h"
|
||||
#include "ui_qt_software_keyboard.h"
|
||||
#include "yuzu/applets/qt_software_keyboard.h"
|
||||
#include "yuzu/main.h"
|
||||
@@ -487,7 +484,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(Core::HID::NpadButton::X);
|
||||
TranslateButtonPress(HIDButton::X);
|
||||
}
|
||||
|
||||
void QtSoftwareKeyboardDialog::keyPressEvent(QKeyEvent* event) {
|
||||
@@ -725,7 +722,7 @@ void QtSoftwareKeyboardDialog::SetTextDrawType() {
|
||||
|
||||
connect(
|
||||
ui->line_edit_osk, &QLineEdit::returnPressed, this,
|
||||
[this] { TranslateButtonPress(Core::HID::NpadButton::Plus); }, Qt::QueuedConnection);
|
||||
[this] { TranslateButtonPress(HIDButton::Plus); }, Qt::QueuedConnection);
|
||||
|
||||
ui->line_edit_osk->setPlaceholderText(
|
||||
QString::fromStdU16String(initialize_parameters.guide_text));
|
||||
@@ -798,10 +795,9 @@ void QtSoftwareKeyboardDialog::SetTextDrawType() {
|
||||
}
|
||||
|
||||
void QtSoftwareKeyboardDialog::SetControllerImage() {
|
||||
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 auto controller_type = Settings::values.players.GetValue()[8].connected
|
||||
? Settings::values.players.GetValue()[8].controller_type
|
||||
: Settings::values.players.GetValue()[0].controller_type;
|
||||
|
||||
const QString theme = [] {
|
||||
if (QIcon::themeName().contains(QStringLiteral("dark")) ||
|
||||
@@ -813,8 +809,8 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
|
||||
}();
|
||||
|
||||
switch (controller_type) {
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
case Core::HID::NpadStyleIndex::GameCube:
|
||||
case Settings::ControllerType::ProController:
|
||||
case Settings::ControllerType::GameCube:
|
||||
ui->icon_controller->setStyleSheet(
|
||||
QStringLiteral("image: url(:/overlay/controller_pro%1.png);").arg(theme));
|
||||
ui->icon_controller_shift->setStyleSheet(
|
||||
@@ -822,7 +818,7 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
|
||||
ui->icon_controller_num->setStyleSheet(
|
||||
QStringLiteral("image: url(:/overlay/controller_pro%1.png);").arg(theme));
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
case Settings::ControllerType::DualJoyconDetached:
|
||||
ui->icon_controller->setStyleSheet(
|
||||
QStringLiteral("image: url(:/overlay/controller_dual_joycon%1.png);").arg(theme));
|
||||
ui->icon_controller_shift->setStyleSheet(
|
||||
@@ -830,7 +826,7 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
|
||||
ui->icon_controller_num->setStyleSheet(
|
||||
QStringLiteral("image: url(:/overlay/controller_dual_joycon%1.png);").arg(theme));
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
case Settings::ControllerType::LeftJoycon:
|
||||
ui->icon_controller->setStyleSheet(
|
||||
QStringLiteral("image: url(:/overlay/controller_single_joycon_left%1.png);")
|
||||
.arg(theme));
|
||||
@@ -841,7 +837,7 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
|
||||
QStringLiteral("image: url(:/overlay/controller_single_joycon_left%1.png);")
|
||||
.arg(theme));
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
case Settings::ControllerType::RightJoycon:
|
||||
ui->icon_controller->setStyleSheet(
|
||||
QStringLiteral("image: url(:/overlay/controller_single_joycon_right%1.png);")
|
||||
.arg(theme));
|
||||
@@ -852,7 +848,7 @@ void QtSoftwareKeyboardDialog::SetControllerImage() {
|
||||
QStringLiteral("image: url(:/overlay/controller_single_joycon_right%1.png);")
|
||||
.arg(theme));
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
case Settings::ControllerType::Handheld:
|
||||
ui->icon_controller->setStyleSheet(
|
||||
QStringLiteral("image: url(:/overlay/controller_handheld%1.png);").arg(theme));
|
||||
ui->icon_controller_shift->setStyleSheet(
|
||||
@@ -1212,9 +1208,9 @@ void QtSoftwareKeyboardDialog::SetupMouseHover() {
|
||||
}
|
||||
}
|
||||
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void QtSoftwareKeyboardDialog::HandleButtonPressedOnce() {
|
||||
const auto f = [this](Core::HID::NpadButton button) {
|
||||
const auto f = [this](HIDButton button) {
|
||||
if (input_interpreter->IsButtonPressedOnce(button)) {
|
||||
TranslateButtonPress(button);
|
||||
}
|
||||
@@ -1223,9 +1219,9 @@ void QtSoftwareKeyboardDialog::HandleButtonPressedOnce() {
|
||||
(f(T), ...);
|
||||
}
|
||||
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void QtSoftwareKeyboardDialog::HandleButtonHold() {
|
||||
const auto f = [this](Core::HID::NpadButton button) {
|
||||
const auto f = [this](HIDButton button) {
|
||||
if (input_interpreter->IsButtonHeld(button)) {
|
||||
TranslateButtonPress(button);
|
||||
}
|
||||
@@ -1234,9 +1230,9 @@ void QtSoftwareKeyboardDialog::HandleButtonHold() {
|
||||
(f(T), ...);
|
||||
}
|
||||
|
||||
void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button) {
|
||||
void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
|
||||
switch (button) {
|
||||
case Core::HID::NpadButton::A:
|
||||
case HIDButton::A:
|
||||
switch (bottom_osk_index) {
|
||||
case BottomOSKIndex::LowerCase:
|
||||
case BottomOSKIndex::UpperCase:
|
||||
@@ -1249,7 +1245,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Core::HID::NpadButton::B:
|
||||
case HIDButton::B:
|
||||
switch (bottom_osk_index) {
|
||||
case BottomOSKIndex::LowerCase:
|
||||
ui->button_backspace->click();
|
||||
@@ -1264,7 +1260,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Core::HID::NpadButton::X:
|
||||
case HIDButton::X:
|
||||
if (is_inline) {
|
||||
emit SubmitInlineText(SwkbdReplyType::DecidedCancel, current_text, cursor_position);
|
||||
} else {
|
||||
@@ -1275,7 +1271,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button
|
||||
emit SubmitNormalText(SwkbdResult::Cancel, std::move(text));
|
||||
}
|
||||
break;
|
||||
case Core::HID::NpadButton::Y:
|
||||
case HIDButton::Y:
|
||||
switch (bottom_osk_index) {
|
||||
case BottomOSKIndex::LowerCase:
|
||||
ui->button_space->click();
|
||||
@@ -1288,8 +1284,8 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Core::HID::NpadButton::StickL:
|
||||
case Core::HID::NpadButton::StickR:
|
||||
case HIDButton::LStick:
|
||||
case HIDButton::RStick:
|
||||
switch (bottom_osk_index) {
|
||||
case BottomOSKIndex::LowerCase:
|
||||
ui->button_shift->click();
|
||||
@@ -1302,13 +1298,13 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Core::HID::NpadButton::L:
|
||||
case HIDButton::L:
|
||||
MoveTextCursorDirection(Direction::Left);
|
||||
break;
|
||||
case Core::HID::NpadButton::R:
|
||||
case HIDButton::R:
|
||||
MoveTextCursorDirection(Direction::Right);
|
||||
break;
|
||||
case Core::HID::NpadButton::Plus:
|
||||
case HIDButton::Plus:
|
||||
switch (bottom_osk_index) {
|
||||
case BottomOSKIndex::LowerCase:
|
||||
ui->button_ok->click();
|
||||
@@ -1323,24 +1319,24 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Core::HID::NpadButton::Left:
|
||||
case Core::HID::NpadButton::StickLLeft:
|
||||
case Core::HID::NpadButton::StickRLeft:
|
||||
case HIDButton::DLeft:
|
||||
case HIDButton::LStickLeft:
|
||||
case HIDButton::RStickLeft:
|
||||
MoveButtonDirection(Direction::Left);
|
||||
break;
|
||||
case Core::HID::NpadButton::Up:
|
||||
case Core::HID::NpadButton::StickLUp:
|
||||
case Core::HID::NpadButton::StickRUp:
|
||||
case HIDButton::DUp:
|
||||
case HIDButton::LStickUp:
|
||||
case HIDButton::RStickUp:
|
||||
MoveButtonDirection(Direction::Up);
|
||||
break;
|
||||
case Core::HID::NpadButton::Right:
|
||||
case Core::HID::NpadButton::StickLRight:
|
||||
case Core::HID::NpadButton::StickRRight:
|
||||
case HIDButton::DRight:
|
||||
case HIDButton::LStickRight:
|
||||
case HIDButton::RStickRight:
|
||||
MoveButtonDirection(Direction::Right);
|
||||
break;
|
||||
case Core::HID::NpadButton::Down:
|
||||
case Core::HID::NpadButton::StickLDown:
|
||||
case Core::HID::NpadButton::StickRDown:
|
||||
case HIDButton::DDown:
|
||||
case HIDButton::LStickDown:
|
||||
case HIDButton::RStickDown:
|
||||
MoveButtonDirection(Direction::Down);
|
||||
break;
|
||||
default:
|
||||
@@ -1471,25 +1467,19 @@ void QtSoftwareKeyboardDialog::InputThread() {
|
||||
while (input_thread_running) {
|
||||
input_interpreter->PollInput();
|
||||
|
||||
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>();
|
||||
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<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>();
|
||||
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>();
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
}
|
||||
|
||||
@@ -14,16 +14,14 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -148,7 +146,7 @@ private:
|
||||
*
|
||||
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
|
||||
*/
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void HandleButtonPressedOnce();
|
||||
|
||||
/**
|
||||
@@ -156,7 +154,7 @@ private:
|
||||
*
|
||||
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
|
||||
*/
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void HandleButtonHold();
|
||||
|
||||
/**
|
||||
@@ -164,7 +162,7 @@ private:
|
||||
*
|
||||
* @param button The button press to process.
|
||||
*/
|
||||
void TranslateButtonPress(Core::HID::NpadButton button);
|
||||
void TranslateButtonPress(HIDButton button);
|
||||
|
||||
/**
|
||||
* Moves the focus of a button in a certain direction.
|
||||
|
||||
@@ -14,11 +14,9 @@
|
||||
#endif
|
||||
|
||||
#include "common/fs/path_util.h"
|
||||
#include "common/param_package.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hid/hid_types.h"
|
||||
#include "core/hid/input_interpreter.h"
|
||||
#include "input_common/drivers/keyboard.h"
|
||||
#include "core/frontend/input_interpreter.h"
|
||||
#include "input_common/keyboard.h"
|
||||
#include "input_common/main.h"
|
||||
#include "yuzu/applets/qt_web_browser.h"
|
||||
#include "yuzu/applets/qt_web_browser_scripts.h"
|
||||
@@ -29,19 +27,19 @@
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int HIDButtonToKey(Core::HID::NpadButton button) {
|
||||
constexpr int HIDButtonToKey(HIDButton button) {
|
||||
switch (button) {
|
||||
case Core::HID::NpadButton::Left:
|
||||
case Core::HID::NpadButton::StickLLeft:
|
||||
case HIDButton::DLeft:
|
||||
case HIDButton::LStickLeft:
|
||||
return Qt::Key_Left;
|
||||
case Core::HID::NpadButton::Up:
|
||||
case Core::HID::NpadButton::StickLUp:
|
||||
case HIDButton::DUp:
|
||||
case HIDButton::LStickUp:
|
||||
return Qt::Key_Up;
|
||||
case Core::HID::NpadButton::Right:
|
||||
case Core::HID::NpadButton::StickLRight:
|
||||
case HIDButton::DRight:
|
||||
case HIDButton::LStickRight:
|
||||
return Qt::Key_Right;
|
||||
case Core::HID::NpadButton::Down:
|
||||
case Core::HID::NpadButton::StickLDown:
|
||||
case HIDButton::DDown:
|
||||
case HIDButton::LStickDown:
|
||||
return Qt::Key_Down;
|
||||
default:
|
||||
return 0;
|
||||
@@ -210,25 +208,25 @@ void QtNXWebEngineView::keyReleaseEvent(QKeyEvent* event) {
|
||||
}
|
||||
}
|
||||
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
|
||||
const auto f = [this](Core::HID::NpadButton button) {
|
||||
const auto f = [this](HIDButton 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 Core::HID::NpadButton::A:
|
||||
case HIDButton::A:
|
||||
SendMultipleKeyPressEvents<Qt::Key_A, Qt::Key_Space, Qt::Key_Return>();
|
||||
break;
|
||||
case Core::HID::NpadButton::B:
|
||||
case HIDButton::B:
|
||||
SendKeyPressEvent(Qt::Key_B);
|
||||
break;
|
||||
case Core::HID::NpadButton::X:
|
||||
case HIDButton::X:
|
||||
SendKeyPressEvent(Qt::Key_X);
|
||||
break;
|
||||
case Core::HID::NpadButton::Y:
|
||||
case HIDButton::Y:
|
||||
SendKeyPressEvent(Qt::Key_Y);
|
||||
break;
|
||||
default:
|
||||
@@ -246,9 +244,9 @@ void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
|
||||
(f(T), ...);
|
||||
}
|
||||
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() {
|
||||
const auto f = [this](Core::HID::NpadButton button) {
|
||||
const auto f = [this](HIDButton button) {
|
||||
if (input_interpreter->IsButtonPressedOnce(button)) {
|
||||
SendKeyPressEvent(HIDButtonToKey(button));
|
||||
}
|
||||
@@ -257,9 +255,9 @@ void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() {
|
||||
(f(T), ...);
|
||||
}
|
||||
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void QtNXWebEngineView::HandleWindowKeyButtonHold() {
|
||||
const auto f = [this](Core::HID::NpadButton button) {
|
||||
const auto f = [this](HIDButton button) {
|
||||
if (input_interpreter->IsButtonHeld(button)) {
|
||||
SendKeyPressEvent(HIDButtonToKey(button));
|
||||
}
|
||||
@@ -310,21 +308,17 @@ void QtNXWebEngineView::InputThread() {
|
||||
while (input_thread_running) {
|
||||
input_interpreter->PollInput();
|
||||
|
||||
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>();
|
||||
HandleWindowFooterButtonPressedOnce<HIDButton::A, HIDButton::B, HIDButton::X, HIDButton::Y,
|
||||
HIDButton::L, HIDButton::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>();
|
||||
HandleWindowKeyButtonPressedOnce<HIDButton::DLeft, HIDButton::DUp, HIDButton::DRight,
|
||||
HIDButton::DDown, HIDButton::LStickLeft,
|
||||
HIDButton::LStickUp, HIDButton::LStickRight,
|
||||
HIDButton::LStickDown>();
|
||||
|
||||
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>();
|
||||
HandleWindowKeyButtonHold<HIDButton::DLeft, HIDButton::DUp, HIDButton::DRight,
|
||||
HIDButton::DDown, HIDButton::LStickLeft, HIDButton::LStickUp,
|
||||
HIDButton::LStickRight, HIDButton::LStickDown>();
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "core/frontend/applets/web_browser.h"
|
||||
|
||||
enum class HIDButton : u8;
|
||||
|
||||
class GMainWindow;
|
||||
class InputInterpreter;
|
||||
class UrlRequestInterceptor;
|
||||
@@ -24,10 +26,6 @@ namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Core::HID {
|
||||
enum class NpadButton : u64;
|
||||
}
|
||||
|
||||
namespace InputCommon {
|
||||
class InputSubsystem;
|
||||
}
|
||||
@@ -116,7 +114,7 @@ private:
|
||||
*
|
||||
* @tparam HIDButton The list of buttons contained in yuzu_key_callbacks
|
||||
*/
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void HandleWindowFooterButtonPressedOnce();
|
||||
|
||||
/**
|
||||
@@ -125,7 +123,7 @@ private:
|
||||
*
|
||||
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
|
||||
*/
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void HandleWindowKeyButtonPressedOnce();
|
||||
|
||||
/**
|
||||
@@ -134,7 +132,7 @@ private:
|
||||
*
|
||||
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
|
||||
*/
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void HandleWindowKeyButtonHold();
|
||||
|
||||
/**
|
||||
|
||||
+33
-298
@@ -32,11 +32,10 @@
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "core/frontend/framebuffer_layout.h"
|
||||
#include "input_common/drivers/keyboard.h"
|
||||
#include "input_common/drivers/mouse.h"
|
||||
#include "input_common/drivers/tas_input.h"
|
||||
#include "input_common/drivers/touch_screen.h"
|
||||
#include "input_common/keyboard.h"
|
||||
#include "input_common/main.h"
|
||||
#include "input_common/mouse/mouse_input.h"
|
||||
#include "input_common/tas/tas_input.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
#include "video_core/video_core.h"
|
||||
#include "yuzu/bootmanager.h"
|
||||
@@ -297,6 +296,7 @@ GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_,
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(layout);
|
||||
input_subsystem->Initialize();
|
||||
|
||||
this->setMouseTracking(true);
|
||||
|
||||
connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete);
|
||||
@@ -383,306 +383,34 @@ void GRenderWindow::closeEvent(QCloseEvent* event) {
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
int GRenderWindow::QtKeyToSwitchKey(Qt::Key qt_key) {
|
||||
switch (qt_key) {
|
||||
case Qt::Key_A:
|
||||
return Settings::NativeKeyboard::A;
|
||||
case Qt::Key_B:
|
||||
return Settings::NativeKeyboard::B;
|
||||
case Qt::Key_C:
|
||||
return Settings::NativeKeyboard::C;
|
||||
case Qt::Key_D:
|
||||
return Settings::NativeKeyboard::D;
|
||||
case Qt::Key_E:
|
||||
return Settings::NativeKeyboard::E;
|
||||
case Qt::Key_F:
|
||||
return Settings::NativeKeyboard::F;
|
||||
case Qt::Key_G:
|
||||
return Settings::NativeKeyboard::G;
|
||||
case Qt::Key_H:
|
||||
return Settings::NativeKeyboard::H;
|
||||
case Qt::Key_I:
|
||||
return Settings::NativeKeyboard::I;
|
||||
case Qt::Key_J:
|
||||
return Settings::NativeKeyboard::J;
|
||||
case Qt::Key_K:
|
||||
return Settings::NativeKeyboard::K;
|
||||
case Qt::Key_L:
|
||||
return Settings::NativeKeyboard::L;
|
||||
case Qt::Key_M:
|
||||
return Settings::NativeKeyboard::M;
|
||||
case Qt::Key_N:
|
||||
return Settings::NativeKeyboard::N;
|
||||
case Qt::Key_O:
|
||||
return Settings::NativeKeyboard::O;
|
||||
case Qt::Key_P:
|
||||
return Settings::NativeKeyboard::P;
|
||||
case Qt::Key_Q:
|
||||
return Settings::NativeKeyboard::Q;
|
||||
case Qt::Key_R:
|
||||
return Settings::NativeKeyboard::R;
|
||||
case Qt::Key_S:
|
||||
return Settings::NativeKeyboard::S;
|
||||
case Qt::Key_T:
|
||||
return Settings::NativeKeyboard::T;
|
||||
case Qt::Key_U:
|
||||
return Settings::NativeKeyboard::U;
|
||||
case Qt::Key_V:
|
||||
return Settings::NativeKeyboard::V;
|
||||
case Qt::Key_W:
|
||||
return Settings::NativeKeyboard::W;
|
||||
case Qt::Key_X:
|
||||
return Settings::NativeKeyboard::X;
|
||||
case Qt::Key_Y:
|
||||
return Settings::NativeKeyboard::Y;
|
||||
case Qt::Key_Z:
|
||||
return Settings::NativeKeyboard::Z;
|
||||
case Qt::Key_1:
|
||||
return Settings::NativeKeyboard::N1;
|
||||
case Qt::Key_2:
|
||||
return Settings::NativeKeyboard::N2;
|
||||
case Qt::Key_3:
|
||||
return Settings::NativeKeyboard::N3;
|
||||
case Qt::Key_4:
|
||||
return Settings::NativeKeyboard::N4;
|
||||
case Qt::Key_5:
|
||||
return Settings::NativeKeyboard::N5;
|
||||
case Qt::Key_6:
|
||||
return Settings::NativeKeyboard::N6;
|
||||
case Qt::Key_7:
|
||||
return Settings::NativeKeyboard::N7;
|
||||
case Qt::Key_8:
|
||||
return Settings::NativeKeyboard::N8;
|
||||
case Qt::Key_9:
|
||||
return Settings::NativeKeyboard::N9;
|
||||
case Qt::Key_0:
|
||||
return Settings::NativeKeyboard::N0;
|
||||
case Qt::Key_Return:
|
||||
return Settings::NativeKeyboard::Return;
|
||||
case Qt::Key_Escape:
|
||||
return Settings::NativeKeyboard::Escape;
|
||||
case Qt::Key_Backspace:
|
||||
return Settings::NativeKeyboard::Backspace;
|
||||
case Qt::Key_Tab:
|
||||
return Settings::NativeKeyboard::Tab;
|
||||
case Qt::Key_Space:
|
||||
return Settings::NativeKeyboard::Space;
|
||||
case Qt::Key_Minus:
|
||||
return Settings::NativeKeyboard::Minus;
|
||||
case Qt::Key_Plus:
|
||||
case Qt::Key_questiondown:
|
||||
return Settings::NativeKeyboard::Plus;
|
||||
case Qt::Key_BracketLeft:
|
||||
case Qt::Key_BraceLeft:
|
||||
return Settings::NativeKeyboard::OpenBracket;
|
||||
case Qt::Key_BracketRight:
|
||||
case Qt::Key_BraceRight:
|
||||
return Settings::NativeKeyboard::CloseBracket;
|
||||
case Qt::Key_Bar:
|
||||
return Settings::NativeKeyboard::Pipe;
|
||||
case Qt::Key_Dead_Tilde:
|
||||
return Settings::NativeKeyboard::Tilde;
|
||||
case Qt::Key_Ntilde:
|
||||
case Qt::Key_Semicolon:
|
||||
return Settings::NativeKeyboard::Semicolon;
|
||||
case Qt::Key_Apostrophe:
|
||||
return Settings::NativeKeyboard::Quote;
|
||||
case Qt::Key_Dead_Grave:
|
||||
return Settings::NativeKeyboard::Backquote;
|
||||
case Qt::Key_Comma:
|
||||
return Settings::NativeKeyboard::Comma;
|
||||
case Qt::Key_Period:
|
||||
return Settings::NativeKeyboard::Period;
|
||||
case Qt::Key_Slash:
|
||||
return Settings::NativeKeyboard::Slash;
|
||||
case Qt::Key_CapsLock:
|
||||
return Settings::NativeKeyboard::CapsLock;
|
||||
case Qt::Key_F1:
|
||||
return Settings::NativeKeyboard::F1;
|
||||
case Qt::Key_F2:
|
||||
return Settings::NativeKeyboard::F2;
|
||||
case Qt::Key_F3:
|
||||
return Settings::NativeKeyboard::F3;
|
||||
case Qt::Key_F4:
|
||||
return Settings::NativeKeyboard::F4;
|
||||
case Qt::Key_F5:
|
||||
return Settings::NativeKeyboard::F5;
|
||||
case Qt::Key_F6:
|
||||
return Settings::NativeKeyboard::F6;
|
||||
case Qt::Key_F7:
|
||||
return Settings::NativeKeyboard::F7;
|
||||
case Qt::Key_F8:
|
||||
return Settings::NativeKeyboard::F8;
|
||||
case Qt::Key_F9:
|
||||
return Settings::NativeKeyboard::F9;
|
||||
case Qt::Key_F10:
|
||||
return Settings::NativeKeyboard::F10;
|
||||
case Qt::Key_F11:
|
||||
return Settings::NativeKeyboard::F11;
|
||||
case Qt::Key_F12:
|
||||
return Settings::NativeKeyboard::F12;
|
||||
case Qt::Key_Print:
|
||||
return Settings::NativeKeyboard::PrintScreen;
|
||||
case Qt::Key_ScrollLock:
|
||||
return Settings::NativeKeyboard::ScrollLock;
|
||||
case Qt::Key_Pause:
|
||||
return Settings::NativeKeyboard::Pause;
|
||||
case Qt::Key_Insert:
|
||||
return Settings::NativeKeyboard::Insert;
|
||||
case Qt::Key_Home:
|
||||
return Settings::NativeKeyboard::Home;
|
||||
case Qt::Key_PageUp:
|
||||
return Settings::NativeKeyboard::PageUp;
|
||||
case Qt::Key_Delete:
|
||||
return Settings::NativeKeyboard::Delete;
|
||||
case Qt::Key_End:
|
||||
return Settings::NativeKeyboard::End;
|
||||
case Qt::Key_PageDown:
|
||||
return Settings::NativeKeyboard::PageDown;
|
||||
case Qt::Key_Right:
|
||||
return Settings::NativeKeyboard::Right;
|
||||
case Qt::Key_Left:
|
||||
return Settings::NativeKeyboard::Left;
|
||||
case Qt::Key_Down:
|
||||
return Settings::NativeKeyboard::Down;
|
||||
case Qt::Key_Up:
|
||||
return Settings::NativeKeyboard::Up;
|
||||
case Qt::Key_NumLock:
|
||||
return Settings::NativeKeyboard::NumLock;
|
||||
// Numpad keys are missing here
|
||||
case Qt::Key_F13:
|
||||
return Settings::NativeKeyboard::F13;
|
||||
case Qt::Key_F14:
|
||||
return Settings::NativeKeyboard::F14;
|
||||
case Qt::Key_F15:
|
||||
return Settings::NativeKeyboard::F15;
|
||||
case Qt::Key_F16:
|
||||
return Settings::NativeKeyboard::F16;
|
||||
case Qt::Key_F17:
|
||||
return Settings::NativeKeyboard::F17;
|
||||
case Qt::Key_F18:
|
||||
return Settings::NativeKeyboard::F18;
|
||||
case Qt::Key_F19:
|
||||
return Settings::NativeKeyboard::F19;
|
||||
case Qt::Key_F20:
|
||||
return Settings::NativeKeyboard::F20;
|
||||
case Qt::Key_F21:
|
||||
return Settings::NativeKeyboard::F21;
|
||||
case Qt::Key_F22:
|
||||
return Settings::NativeKeyboard::F22;
|
||||
case Qt::Key_F23:
|
||||
return Settings::NativeKeyboard::F23;
|
||||
case Qt::Key_F24:
|
||||
return Settings::NativeKeyboard::F24;
|
||||
// case Qt:::
|
||||
// return Settings::NativeKeyboard::KPComma;
|
||||
// case Qt:::
|
||||
// return Settings::NativeKeyboard::Ro;
|
||||
case Qt::Key_Hiragana_Katakana:
|
||||
return Settings::NativeKeyboard::KatakanaHiragana;
|
||||
case Qt::Key_yen:
|
||||
return Settings::NativeKeyboard::Yen;
|
||||
case Qt::Key_Henkan:
|
||||
return Settings::NativeKeyboard::Henkan;
|
||||
case Qt::Key_Muhenkan:
|
||||
return Settings::NativeKeyboard::Muhenkan;
|
||||
// case Qt:::
|
||||
// return Settings::NativeKeyboard::NumPadCommaPc98;
|
||||
case Qt::Key_Hangul:
|
||||
return Settings::NativeKeyboard::HangulEnglish;
|
||||
case Qt::Key_Hangul_Hanja:
|
||||
return Settings::NativeKeyboard::Hanja;
|
||||
case Qt::Key_Katakana:
|
||||
return Settings::NativeKeyboard::KatakanaKey;
|
||||
case Qt::Key_Hiragana:
|
||||
return Settings::NativeKeyboard::HiraganaKey;
|
||||
case Qt::Key_Zenkaku_Hankaku:
|
||||
return Settings::NativeKeyboard::ZenkakuHankaku;
|
||||
// Modifier keys are handled by the modifier property
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int GRenderWindow::QtModifierToSwitchModdifier(quint32 qt_moddifiers) {
|
||||
int moddifier = 0;
|
||||
// The values are obtained through testing, Qt doesn't seem to provide a proper enum
|
||||
if ((qt_moddifiers & 0x1) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::LeftShift;
|
||||
}
|
||||
if ((qt_moddifiers & 0x2) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::LeftControl;
|
||||
}
|
||||
if ((qt_moddifiers & 0x4) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::LeftAlt;
|
||||
}
|
||||
if ((qt_moddifiers & 0x08) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::LeftMeta;
|
||||
}
|
||||
if ((qt_moddifiers & 0x10) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::RightShift;
|
||||
}
|
||||
if ((qt_moddifiers & 0x20) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::RightControl;
|
||||
}
|
||||
if ((qt_moddifiers & 0x40) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::RightAlt;
|
||||
}
|
||||
if ((qt_moddifiers & 0x80) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::RightMeta;
|
||||
}
|
||||
if ((qt_moddifiers & 0x100) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::CapsLock;
|
||||
}
|
||||
if ((qt_moddifiers & 0x200) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::NumLock;
|
||||
}
|
||||
// Verify the last two keys
|
||||
if ((qt_moddifiers & 0x400) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::Katakana;
|
||||
}
|
||||
if ((qt_moddifiers & 0x800) != 0) {
|
||||
moddifier |= 1 << Settings::NativeKeyboard::Hiragana;
|
||||
}
|
||||
return moddifier;
|
||||
}
|
||||
|
||||
void GRenderWindow::keyPressEvent(QKeyEvent* event) {
|
||||
if (!event->isAutoRepeat()) {
|
||||
const auto moddifier = QtModifierToSwitchModdifier(event->nativeModifiers());
|
||||
// Replace event->key() with event->nativeVirtualKey() since the second one provides raw key
|
||||
// buttons
|
||||
const auto key = QtKeyToSwitchKey(Qt::Key(event->key()));
|
||||
input_subsystem->GetKeyboard()->SetModifiers(moddifier);
|
||||
input_subsystem->GetKeyboard()->PressKey(key);
|
||||
input_subsystem->GetKeyboard()->PressKey(event->key());
|
||||
}
|
||||
}
|
||||
|
||||
void GRenderWindow::keyReleaseEvent(QKeyEvent* event) {
|
||||
if (!event->isAutoRepeat()) {
|
||||
const auto moddifier = QtModifierToSwitchModdifier(event->nativeModifiers());
|
||||
const auto key = QtKeyToSwitchKey(Qt::Key(event->key()));
|
||||
input_subsystem->GetKeyboard()->SetModifiers(moddifier);
|
||||
input_subsystem->GetKeyboard()->ReleaseKey(key);
|
||||
input_subsystem->GetKeyboard()->ReleaseKey(event->key());
|
||||
}
|
||||
}
|
||||
|
||||
InputCommon::MouseButton GRenderWindow::QtButtonToMouseButton(Qt::MouseButton button) {
|
||||
MouseInput::MouseButton GRenderWindow::QtButtonToMouseButton(Qt::MouseButton button) {
|
||||
switch (button) {
|
||||
case Qt::LeftButton:
|
||||
return InputCommon::MouseButton::Left;
|
||||
return MouseInput::MouseButton::Left;
|
||||
case Qt::RightButton:
|
||||
return InputCommon::MouseButton::Right;
|
||||
return MouseInput::MouseButton::Right;
|
||||
case Qt::MiddleButton:
|
||||
return InputCommon::MouseButton::Wheel;
|
||||
return MouseInput::MouseButton::Wheel;
|
||||
case Qt::BackButton:
|
||||
return InputCommon::MouseButton::Backward;
|
||||
return MouseInput::MouseButton::Backward;
|
||||
case Qt::ForwardButton:
|
||||
return InputCommon::MouseButton::Forward;
|
||||
return MouseInput::MouseButton::Forward;
|
||||
case Qt::TaskButton:
|
||||
return InputCommon::MouseButton::Task;
|
||||
return MouseInput::MouseButton::Task;
|
||||
default:
|
||||
return InputCommon::MouseButton::Extra;
|
||||
return MouseInput::MouseButton::Extra;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,9 +423,12 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) {
|
||||
// coordinates and map them to the current render area
|
||||
const auto pos = mapFromGlobal(QCursor::pos());
|
||||
const auto [x, y] = ScaleTouch(pos);
|
||||
const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
|
||||
const auto button = QtButtonToMouseButton(event->button());
|
||||
input_subsystem->GetMouse()->PressButton(x, y, touch_x, touch_y, button);
|
||||
input_subsystem->GetMouse()->PressButton(x, y, button);
|
||||
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
this->TouchPressed(x, y, 0);
|
||||
}
|
||||
|
||||
emit MouseActivity();
|
||||
}
|
||||
@@ -711,10 +442,10 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) {
|
||||
// coordinates and map them to the current render area
|
||||
const auto pos = mapFromGlobal(QCursor::pos());
|
||||
const auto [x, y] = ScaleTouch(pos);
|
||||
const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
|
||||
const int center_x = width() / 2;
|
||||
const int center_y = height() / 2;
|
||||
input_subsystem->GetMouse()->MouseMove(x, y, touch_x, touch_y, center_x, center_y);
|
||||
input_subsystem->GetMouse()->MouseMove(x, y, center_x, center_y);
|
||||
this->TouchMoved(x, y, 0);
|
||||
|
||||
if (Settings::values.mouse_panning) {
|
||||
QCursor::setPos(mapToGlobal({center_x, center_y}));
|
||||
@@ -731,6 +462,10 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) {
|
||||
|
||||
const auto button = QtButtonToMouseButton(event->button());
|
||||
input_subsystem->GetMouse()->ReleaseButton(button);
|
||||
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
this->TouchReleased(0);
|
||||
}
|
||||
}
|
||||
|
||||
void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) {
|
||||
@@ -753,7 +488,7 @@ void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) {
|
||||
for (std::size_t id = 0; id < touch_ids.size(); ++id) {
|
||||
if (!TouchExist(touch_ids[id], touch_points)) {
|
||||
touch_ids[id] = 0;
|
||||
input_subsystem->GetTouchScreen()->TouchReleased(id);
|
||||
this->TouchReleased(id + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -762,28 +497,28 @@ void GRenderWindow::TouchEndEvent() {
|
||||
for (std::size_t id = 0; id < touch_ids.size(); ++id) {
|
||||
if (touch_ids[id] != 0) {
|
||||
touch_ids[id] = 0;
|
||||
input_subsystem->GetTouchScreen()->TouchReleased(id);
|
||||
this->TouchReleased(id + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GRenderWindow::TouchStart(const QTouchEvent::TouchPoint& touch_point) {
|
||||
bool GRenderWindow::TouchStart(const QTouchEvent::TouchPoint& touch_point) {
|
||||
for (std::size_t id = 0; id < touch_ids.size(); ++id) {
|
||||
if (touch_ids[id] == 0) {
|
||||
touch_ids[id] = touch_point.id() + 1;
|
||||
const auto [x, y] = ScaleTouch(touch_point.pos());
|
||||
const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
|
||||
input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, id);
|
||||
this->TouchPressed(x, y, id + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GRenderWindow::TouchUpdate(const QTouchEvent::TouchPoint& touch_point) {
|
||||
for (std::size_t id = 0; id < touch_ids.size(); ++id) {
|
||||
if (touch_ids[id] == static_cast<std::size_t>(touch_point.id() + 1)) {
|
||||
const auto [x, y] = ScaleTouch(touch_point.pos());
|
||||
const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
|
||||
input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, id);
|
||||
this->TouchMoved(x, y, id + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -816,7 +551,7 @@ void GRenderWindow::focusOutEvent(QFocusEvent* event) {
|
||||
QWidget::focusOutEvent(event);
|
||||
input_subsystem->GetKeyboard()->ReleaseAllKeys();
|
||||
input_subsystem->GetMouse()->ReleaseAllButtons();
|
||||
input_subsystem->GetTouchScreen()->ReleaseAllTouch();
|
||||
this->TouchReleased(0);
|
||||
}
|
||||
|
||||
void GRenderWindow::resizeEvent(QResizeEvent* event) {
|
||||
|
||||
@@ -30,8 +30,11 @@ class System;
|
||||
|
||||
namespace InputCommon {
|
||||
class InputSubsystem;
|
||||
}
|
||||
|
||||
namespace MouseInput {
|
||||
enum class MouseButton;
|
||||
} // namespace InputCommon
|
||||
}
|
||||
|
||||
namespace VideoCore {
|
||||
enum class LoadCallbackStage;
|
||||
@@ -154,17 +157,11 @@ public:
|
||||
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
|
||||
/// Converts a Qt keybard key into NativeKeyboard key
|
||||
static int QtKeyToSwitchKey(Qt::Key qt_keys);
|
||||
|
||||
/// Converts a Qt modifier keys into NativeKeyboard modifier keys
|
||||
static int QtModifierToSwitchModdifier(quint32 qt_moddifiers);
|
||||
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
|
||||
/// Converts a Qt mouse button into MouseInput mouse button
|
||||
static InputCommon::MouseButton QtButtonToMouseButton(Qt::MouseButton button);
|
||||
static MouseInput::MouseButton QtButtonToMouseButton(Qt::MouseButton button);
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
@@ -212,7 +209,7 @@ private:
|
||||
void TouchUpdateEvent(const QTouchEvent* event);
|
||||
void TouchEndEvent();
|
||||
|
||||
void TouchStart(const QTouchEvent::TouchPoint& touch_point);
|
||||
bool TouchStart(const QTouchEvent::TouchPoint& touch_point);
|
||||
bool TouchUpdate(const QTouchEvent::TouchPoint& touch_point);
|
||||
bool TouchExist(std::size_t id, const QList<QTouchEvent::TouchPoint>& touch_points) const;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "core/hle/service/acc/profile_manager.h"
|
||||
#include "core/hle/service/hid/controllers/npad.h"
|
||||
#include "input_common/main.h"
|
||||
#include "input_common/udp/client.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
|
||||
namespace FS = Common::FS;
|
||||
@@ -65,6 +66,157 @@ const std::array<int, Settings::NativeMouseButton::NumMouseButtons> Config::defa
|
||||
Qt::Key_BracketLeft, Qt::Key_BracketRight, Qt::Key_Apostrophe, Qt::Key_Minus, Qt::Key_Equal,
|
||||
};
|
||||
|
||||
const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> Config::default_keyboard_keys = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
Qt::Key_A,
|
||||
Qt::Key_B,
|
||||
Qt::Key_C,
|
||||
Qt::Key_D,
|
||||
Qt::Key_E,
|
||||
Qt::Key_F,
|
||||
Qt::Key_G,
|
||||
Qt::Key_H,
|
||||
Qt::Key_I,
|
||||
Qt::Key_J,
|
||||
Qt::Key_K,
|
||||
Qt::Key_L,
|
||||
Qt::Key_M,
|
||||
Qt::Key_N,
|
||||
Qt::Key_O,
|
||||
Qt::Key_P,
|
||||
Qt::Key_Q,
|
||||
Qt::Key_R,
|
||||
Qt::Key_S,
|
||||
Qt::Key_T,
|
||||
Qt::Key_U,
|
||||
Qt::Key_V,
|
||||
Qt::Key_W,
|
||||
Qt::Key_X,
|
||||
Qt::Key_Y,
|
||||
Qt::Key_Z,
|
||||
Qt::Key_1,
|
||||
Qt::Key_2,
|
||||
Qt::Key_3,
|
||||
Qt::Key_4,
|
||||
Qt::Key_5,
|
||||
Qt::Key_6,
|
||||
Qt::Key_7,
|
||||
Qt::Key_8,
|
||||
Qt::Key_9,
|
||||
Qt::Key_0,
|
||||
Qt::Key_Enter,
|
||||
Qt::Key_Escape,
|
||||
Qt::Key_Backspace,
|
||||
Qt::Key_Tab,
|
||||
Qt::Key_Space,
|
||||
Qt::Key_Minus,
|
||||
Qt::Key_Equal,
|
||||
Qt::Key_BracketLeft,
|
||||
Qt::Key_BracketRight,
|
||||
Qt::Key_Backslash,
|
||||
Qt::Key_Dead_Tilde,
|
||||
Qt::Key_Semicolon,
|
||||
Qt::Key_Apostrophe,
|
||||
Qt::Key_Dead_Grave,
|
||||
Qt::Key_Comma,
|
||||
Qt::Key_Period,
|
||||
Qt::Key_Slash,
|
||||
Qt::Key_CapsLock,
|
||||
|
||||
Qt::Key_F1,
|
||||
Qt::Key_F2,
|
||||
Qt::Key_F3,
|
||||
Qt::Key_F4,
|
||||
Qt::Key_F5,
|
||||
Qt::Key_F6,
|
||||
Qt::Key_F7,
|
||||
Qt::Key_F8,
|
||||
Qt::Key_F9,
|
||||
Qt::Key_F10,
|
||||
Qt::Key_F11,
|
||||
Qt::Key_F12,
|
||||
|
||||
Qt::Key_SysReq,
|
||||
Qt::Key_ScrollLock,
|
||||
Qt::Key_Pause,
|
||||
Qt::Key_Insert,
|
||||
Qt::Key_Home,
|
||||
Qt::Key_PageUp,
|
||||
Qt::Key_Delete,
|
||||
Qt::Key_End,
|
||||
Qt::Key_PageDown,
|
||||
Qt::Key_Right,
|
||||
Qt::Key_Left,
|
||||
Qt::Key_Down,
|
||||
Qt::Key_Up,
|
||||
|
||||
Qt::Key_NumLock,
|
||||
Qt::Key_Slash,
|
||||
Qt::Key_Asterisk,
|
||||
Qt::Key_Minus,
|
||||
Qt::Key_Plus,
|
||||
Qt::Key_Enter,
|
||||
Qt::Key_1,
|
||||
Qt::Key_2,
|
||||
Qt::Key_3,
|
||||
Qt::Key_4,
|
||||
Qt::Key_5,
|
||||
Qt::Key_6,
|
||||
Qt::Key_7,
|
||||
Qt::Key_8,
|
||||
Qt::Key_9,
|
||||
Qt::Key_0,
|
||||
Qt::Key_Period,
|
||||
|
||||
0,
|
||||
0,
|
||||
Qt::Key_PowerOff,
|
||||
Qt::Key_Equal,
|
||||
|
||||
Qt::Key_F13,
|
||||
Qt::Key_F14,
|
||||
Qt::Key_F15,
|
||||
Qt::Key_F16,
|
||||
Qt::Key_F17,
|
||||
Qt::Key_F18,
|
||||
Qt::Key_F19,
|
||||
Qt::Key_F20,
|
||||
Qt::Key_F21,
|
||||
Qt::Key_F22,
|
||||
Qt::Key_F23,
|
||||
Qt::Key_F24,
|
||||
|
||||
Qt::Key_Open,
|
||||
Qt::Key_Help,
|
||||
Qt::Key_Menu,
|
||||
0,
|
||||
Qt::Key_Stop,
|
||||
Qt::Key_AudioRepeat,
|
||||
Qt::Key_Undo,
|
||||
Qt::Key_Cut,
|
||||
Qt::Key_Copy,
|
||||
Qt::Key_Paste,
|
||||
Qt::Key_Find,
|
||||
Qt::Key_VolumeMute,
|
||||
Qt::Key_VolumeUp,
|
||||
Qt::Key_VolumeDown,
|
||||
Qt::Key_CapsLock,
|
||||
Qt::Key_NumLock,
|
||||
Qt::Key_ScrollLock,
|
||||
Qt::Key_Comma,
|
||||
|
||||
Qt::Key_ParenLeft,
|
||||
Qt::Key_ParenRight,
|
||||
};
|
||||
|
||||
const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> Config::default_keyboard_mods = {
|
||||
Qt::Key_Control, Qt::Key_Shift, Qt::Key_Alt, Qt::Key_ApplicationLeft,
|
||||
Qt::Key_Control, Qt::Key_Shift, Qt::Key_AltGr, Qt::Key_ApplicationRight,
|
||||
};
|
||||
|
||||
// This shouldn't have anything except static initializers (no functions). So
|
||||
// QKeySequence(...).toString() is NOT ALLOWED HERE.
|
||||
// This must be in alphabetical order according to action name as it must have the same order as
|
||||
@@ -345,14 +497,14 @@ void Config::ReadDebugValues() {
|
||||
void Config::ReadKeyboardValues() {
|
||||
ReadBasicSetting(Settings::values.keyboard_enabled);
|
||||
|
||||
for (std::size_t i = 0; i < Settings::values.keyboard_keys.size(); ++i) {
|
||||
Settings::values.keyboard_keys[i] = InputCommon::GenerateKeyboardParam(static_cast<int>(i));
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < Settings::values.keyboard_mods.size(); ++i) {
|
||||
Settings::values.keyboard_mods[i] =
|
||||
InputCommon::GenerateModdifierKeyboardParam(static_cast<int>(i));
|
||||
}
|
||||
std::transform(default_keyboard_keys.begin(), default_keyboard_keys.end(),
|
||||
Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam);
|
||||
std::transform(default_keyboard_mods.begin(), default_keyboard_mods.end(),
|
||||
Settings::values.keyboard_keys.begin() +
|
||||
Settings::NativeKeyboard::LeftControlKey,
|
||||
InputCommon::GenerateKeyboardParam);
|
||||
std::transform(default_keyboard_mods.begin(), default_keyboard_mods.end(),
|
||||
Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam);
|
||||
}
|
||||
|
||||
void Config::ReadMouseValues() {
|
||||
@@ -422,6 +574,7 @@ void Config::ReadControlValues() {
|
||||
|
||||
ReadBasicSetting(Settings::values.tas_enable);
|
||||
ReadBasicSetting(Settings::values.tas_loop);
|
||||
ReadBasicSetting(Settings::values.tas_swap_controllers);
|
||||
ReadBasicSetting(Settings::values.pause_tas_on_load);
|
||||
|
||||
ReadGlobalSetting(Settings::values.use_docked_mode);
|
||||
@@ -472,7 +625,9 @@ void Config::ReadMotionTouchValues() {
|
||||
}
|
||||
qt_config->endArray();
|
||||
|
||||
ReadBasicSetting(Settings::values.motion_device);
|
||||
ReadBasicSetting(Settings::values.touch_device);
|
||||
ReadBasicSetting(Settings::values.use_touch_from_button);
|
||||
ReadBasicSetting(Settings::values.touch_from_button_map_index);
|
||||
Settings::values.touch_from_button_map_index = std::clamp(
|
||||
Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1);
|
||||
@@ -978,7 +1133,9 @@ void Config::SaveTouchscreenValues() {
|
||||
}
|
||||
|
||||
void Config::SaveMotionTouchValues() {
|
||||
WriteBasicSetting(Settings::values.motion_device);
|
||||
WriteBasicSetting(Settings::values.touch_device);
|
||||
WriteBasicSetting(Settings::values.use_touch_from_button);
|
||||
WriteBasicSetting(Settings::values.touch_from_button_map_index);
|
||||
WriteBasicSetting(Settings::values.udp_input_servers);
|
||||
|
||||
@@ -1053,6 +1210,7 @@ void Config::SaveControlValues() {
|
||||
|
||||
WriteBasicSetting(Settings::values.tas_enable);
|
||||
WriteBasicSetting(Settings::values.tas_loop);
|
||||
WriteBasicSetting(Settings::values.tas_swap_controllers);
|
||||
WriteBasicSetting(Settings::values.pause_tas_on_load);
|
||||
|
||||
qt_config->endGroup();
|
||||
|
||||
@@ -2,18 +2,17 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/core.h"
|
||||
#include "ui_configure_debug_controller.h"
|
||||
#include "yuzu/configuration/configure_debug_controller.h"
|
||||
#include "yuzu/configuration/configure_input_player.h"
|
||||
|
||||
ConfigureDebugController::ConfigureDebugController(QWidget* parent,
|
||||
InputCommon::InputSubsystem* input_subsystem,
|
||||
InputProfiles* profiles,
|
||||
Core::HID::HIDCore& hid_core, bool is_powered_on)
|
||||
InputProfiles* profiles, Core::System& system)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigureDebugController>()),
|
||||
debug_controller(new ConfigureInputPlayer(this, 9, nullptr, input_subsystem, profiles,
|
||||
hid_core, is_powered_on, true)) {
|
||||
debug_controller(
|
||||
new ConfigureInputPlayer(this, 9, nullptr, input_subsystem, profiles, system, true)) {
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->controllerLayout->addWidget(debug_controller);
|
||||
|
||||
@@ -13,8 +13,8 @@ class ConfigureInputPlayer;
|
||||
|
||||
class InputProfiles;
|
||||
|
||||
namespace Core::HID {
|
||||
class HIDCore;
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace InputCommon {
|
||||
@@ -30,8 +30,7 @@ class ConfigureDebugController : public QDialog {
|
||||
|
||||
public:
|
||||
explicit ConfigureDebugController(QWidget* parent, InputCommon::InputSubsystem* input_subsystem,
|
||||
InputProfiles* profiles, Core::HID::HIDCore& hid_core,
|
||||
bool is_powered_on);
|
||||
InputProfiles* profiles, Core::System& system);
|
||||
~ConfigureDebugController() override;
|
||||
|
||||
void ApplyConfiguration();
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "core/core.h"
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/am/am.h"
|
||||
#include "core/hle/service/am/applet_ae.h"
|
||||
#include "core/hle/service/am/applet_oe.h"
|
||||
@@ -77,25 +75,23 @@ ConfigureInput::~ConfigureInput() = default;
|
||||
|
||||
void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
|
||||
std::size_t max_players) {
|
||||
const bool is_powered_on = system.IsPoweredOn();
|
||||
auto& hid_core = system.HIDCore();
|
||||
player_controllers = {
|
||||
new ConfigureInputPlayer(this, 0, ui->consoleInputSettings, input_subsystem, profiles.get(),
|
||||
hid_core, is_powered_on),
|
||||
system),
|
||||
new ConfigureInputPlayer(this, 1, ui->consoleInputSettings, input_subsystem, profiles.get(),
|
||||
hid_core, is_powered_on),
|
||||
system),
|
||||
new ConfigureInputPlayer(this, 2, ui->consoleInputSettings, input_subsystem, profiles.get(),
|
||||
hid_core, is_powered_on),
|
||||
system),
|
||||
new ConfigureInputPlayer(this, 3, ui->consoleInputSettings, input_subsystem, profiles.get(),
|
||||
hid_core, is_powered_on),
|
||||
system),
|
||||
new ConfigureInputPlayer(this, 4, ui->consoleInputSettings, input_subsystem, profiles.get(),
|
||||
hid_core, is_powered_on),
|
||||
system),
|
||||
new ConfigureInputPlayer(this, 5, ui->consoleInputSettings, input_subsystem, profiles.get(),
|
||||
hid_core, is_powered_on),
|
||||
system),
|
||||
new ConfigureInputPlayer(this, 6, ui->consoleInputSettings, input_subsystem, profiles.get(),
|
||||
hid_core, is_powered_on),
|
||||
system),
|
||||
new ConfigureInputPlayer(this, 7, ui->consoleInputSettings, input_subsystem, profiles.get(),
|
||||
hid_core, is_powered_on),
|
||||
system),
|
||||
};
|
||||
|
||||
player_tabs = {
|
||||
@@ -118,7 +114,6 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
|
||||
player_tabs[i]->setLayout(new QHBoxLayout(player_tabs[i]));
|
||||
player_tabs[i]->layout()->addWidget(player_controllers[i]);
|
||||
connect(player_controllers[i], &ConfigureInputPlayer::Connected, [&, i](bool is_connected) {
|
||||
// Ensures that the controllers are always connected in sequential order
|
||||
if (is_connected) {
|
||||
for (std::size_t index = 0; index <= i; ++index) {
|
||||
player_connected[index]->setChecked(is_connected);
|
||||
@@ -151,12 +146,10 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
|
||||
advanced = new ConfigureInputAdvanced(this);
|
||||
ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced));
|
||||
ui->tabAdvanced->layout()->addWidget(advanced);
|
||||
|
||||
connect(advanced, &ConfigureInputAdvanced::CallDebugControllerDialog,
|
||||
[this, input_subsystem, &hid_core, is_powered_on] {
|
||||
CallConfigureDialog<ConfigureDebugController>(
|
||||
*this, input_subsystem, profiles.get(), hid_core, is_powered_on);
|
||||
});
|
||||
connect(advanced, &ConfigureInputAdvanced::CallDebugControllerDialog, [this, input_subsystem] {
|
||||
CallConfigureDialog<ConfigureDebugController>(*this, input_subsystem, profiles.get(),
|
||||
system);
|
||||
});
|
||||
connect(advanced, &ConfigureInputAdvanced::CallMouseConfigDialog, [this, input_subsystem] {
|
||||
CallConfigureDialog<ConfigureMouseAdvanced>(*this, input_subsystem);
|
||||
});
|
||||
@@ -191,8 +184,22 @@ QList<QWidget*> ConfigureInput::GetSubTabs() const {
|
||||
void ConfigureInput::ApplyConfiguration() {
|
||||
for (auto* controller : player_controllers) {
|
||||
controller->ApplyConfiguration();
|
||||
controller->TryDisconnectSelectedController();
|
||||
}
|
||||
|
||||
// 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(150ms);
|
||||
|
||||
for (auto* controller : player_controllers) {
|
||||
controller->TryConnectSelectedController();
|
||||
}
|
||||
|
||||
// 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.
|
||||
std::this_thread::sleep_for(150ms);
|
||||
|
||||
advanced->ApplyConfiguration();
|
||||
|
||||
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
|
||||
@@ -216,10 +223,8 @@ void ConfigureInput::RetranslateUI() {
|
||||
}
|
||||
|
||||
void ConfigureInput::LoadConfiguration() {
|
||||
const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||
|
||||
LoadPlayerControllerIndices();
|
||||
UpdateDockedState(handheld->IsConnected());
|
||||
UpdateDockedState(Settings::values.players.GetValue()[8].connected);
|
||||
|
||||
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
|
||||
ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue());
|
||||
@@ -227,16 +232,9 @@ void ConfigureInput::LoadConfiguration() {
|
||||
|
||||
void ConfigureInput::LoadPlayerControllerIndices() {
|
||||
for (std::size_t i = 0; i < player_connected.size(); ++i) {
|
||||
if (i == 0) {
|
||||
auto* handheld =
|
||||
system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||
if (handheld->IsConnected()) {
|
||||
player_connected[i]->setChecked(true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(i);
|
||||
player_connected[i]->setChecked(controller->IsConnected());
|
||||
const auto connected = Settings::values.players.GetValue()[i].connected ||
|
||||
(i == 0 && Settings::values.players.GetValue()[8].connected);
|
||||
player_connected[i]->setChecked(connected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,37 +29,48 @@ class QWidget;
|
||||
|
||||
class InputProfiles;
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace InputCommon {
|
||||
class InputSubsystem;
|
||||
}
|
||||
|
||||
namespace InputCommon::Polling {
|
||||
enum class InputType;
|
||||
class DevicePoller;
|
||||
enum class DeviceType;
|
||||
} // namespace InputCommon::Polling
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureInputPlayer;
|
||||
}
|
||||
|
||||
namespace Core::HID {
|
||||
class HIDCore;
|
||||
class EmulatedController;
|
||||
enum class NpadStyleIndex : u8;
|
||||
} // namespace Core::HID
|
||||
|
||||
class ConfigureInputPlayer : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigureInputPlayer(QWidget* parent, std::size_t player_index, QWidget* bottom_row,
|
||||
InputCommon::InputSubsystem* input_subsystem_,
|
||||
InputProfiles* profiles_, Core::HID::HIDCore& hid_core_,
|
||||
bool is_powered_on_, bool debug = false);
|
||||
InputProfiles* profiles_, Core::System& system_,
|
||||
bool debug = false);
|
||||
~ConfigureInputPlayer() override;
|
||||
|
||||
/// Save all button configurations to settings file.
|
||||
void ApplyConfiguration();
|
||||
|
||||
/**
|
||||
* Attempts to connect the currently selected controller in the HID backend.
|
||||
* This function will not do anything if it is not connected in the frontend.
|
||||
*/
|
||||
void TryConnectSelectedController();
|
||||
|
||||
/**
|
||||
* Attempts to disconnect the currently selected controller in the HID backend.
|
||||
* This function will not do anything if the configuration has not changed.
|
||||
*/
|
||||
void TryDisconnectSelectedController();
|
||||
|
||||
/// Set the connection state checkbox (used to sync state).
|
||||
void ConnectPlayer(bool connected);
|
||||
|
||||
@@ -93,10 +104,6 @@ protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
private:
|
||||
QString ButtonToText(const Common::ParamPackage& param);
|
||||
|
||||
QString AnalogToText(const Common::ParamPackage& param, const std::string& dir);
|
||||
|
||||
void changeEvent(QEvent* event) override;
|
||||
void RetranslateUI();
|
||||
|
||||
@@ -106,7 +113,7 @@ private:
|
||||
/// Called when the button was pressed.
|
||||
void HandleClick(QPushButton* button, std::size_t button_id,
|
||||
std::function<void(const Common::ParamPackage&)> new_input_setter,
|
||||
InputCommon::Polling::InputType type);
|
||||
InputCommon::Polling::DeviceType type);
|
||||
|
||||
/// Finish polling and configure input using the input_setter.
|
||||
void SetPollingResult(const Common::ParamPackage& params, bool abort);
|
||||
@@ -127,14 +134,17 @@ private:
|
||||
void SetConnectableControllers();
|
||||
|
||||
/// Gets the Controller Type for a given controller combobox index.
|
||||
Core::HID::NpadStyleIndex GetControllerTypeFromIndex(int index) const;
|
||||
Settings::ControllerType GetControllerTypeFromIndex(int index) const;
|
||||
|
||||
/// Gets the controller combobox index for a given Controller Type.
|
||||
int GetIndexFromControllerType(Core::HID::NpadStyleIndex type) const;
|
||||
int GetIndexFromControllerType(Settings::ControllerType type) const;
|
||||
|
||||
/// Update the available input devices.
|
||||
void UpdateInputDevices();
|
||||
|
||||
/// Update the current controller icon.
|
||||
void UpdateControllerIcon();
|
||||
|
||||
/// Hides and disables controller settings based on the current controller type.
|
||||
void UpdateControllerAvailableButtons();
|
||||
|
||||
@@ -166,7 +176,6 @@ private:
|
||||
|
||||
std::size_t player_index;
|
||||
bool debug;
|
||||
bool is_powered_on;
|
||||
|
||||
InputCommon::InputSubsystem* input_subsystem;
|
||||
|
||||
@@ -176,7 +185,7 @@ private:
|
||||
std::unique_ptr<QTimer> poll_timer;
|
||||
|
||||
/// Stores a pair of "Connected Controllers" combobox index and Controller Type enum.
|
||||
std::vector<std::pair<int, Core::HID::NpadStyleIndex>> index_controller_type_pairs;
|
||||
std::vector<std::pair<int, Settings::ControllerType>> index_controller_type_pairs;
|
||||
|
||||
static constexpr int PLAYER_COUNT = 8;
|
||||
std::array<QCheckBox*, PLAYER_COUNT> player_connected_checkbox;
|
||||
@@ -184,7 +193,9 @@ private:
|
||||
/// This will be the the setting function when an input is awaiting configuration.
|
||||
std::optional<std::function<void(const Common::ParamPackage&)>> input_setter;
|
||||
|
||||
Core::HID::EmulatedController* emulated_controller;
|
||||
std::array<Common::ParamPackage, Settings::NativeButton::NumButtons> buttons_param;
|
||||
std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs> analogs_param;
|
||||
std::array<Common::ParamPackage, Settings::NativeMotion::NumMotions> motions_param;
|
||||
|
||||
static constexpr int ANALOG_SUB_BUTTONS_NUM = 4;
|
||||
|
||||
@@ -210,9 +221,15 @@ private:
|
||||
|
||||
static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons;
|
||||
|
||||
std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers;
|
||||
|
||||
/// A flag to indicate that the "Map Analog Stick" pop-up has been shown and accepted once.
|
||||
bool map_analog_stick_accepted{};
|
||||
|
||||
/// A flag to indicate if keyboard keys are okay when configuring an input. If this is false,
|
||||
/// keyboard events are ignored.
|
||||
bool want_keyboard_mouse{};
|
||||
|
||||
/// List of physical devices users can map with. If a SDL backed device is selected, then you
|
||||
/// can use this device to get a default mapping.
|
||||
std::vector<Common::ParamPackage> input_devices;
|
||||
@@ -222,5 +239,5 @@ private:
|
||||
/// parent of the widget to this widget (but thats fine).
|
||||
QWidget* bottom_row;
|
||||
|
||||
Core::HID::HIDCore& hid_core;
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
@@ -89,6 +89,31 @@
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Pro Controller</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dual Joycons</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Joycon</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Joycon</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Handheld</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -117,9 +142,22 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboDevices">
|
||||
<property name="minimumContentsLength">
|
||||
<number>60</number>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Any</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Keyboard/Mouse</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -304,7 +342,7 @@
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
@@ -880,7 +918,7 @@
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
@@ -2183,7 +2221,7 @@
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
@@ -2532,7 +2570,7 @@
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,11 +7,9 @@
|
||||
#include <array>
|
||||
#include <QFrame>
|
||||
#include <QPointer>
|
||||
|
||||
#include "common/input.h"
|
||||
#include "common/settings_input.h"
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/hid_types.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/frontend/input.h"
|
||||
#include "yuzu/debugger/controller.h"
|
||||
|
||||
class QLabel;
|
||||
|
||||
@@ -26,26 +24,17 @@ public:
|
||||
explicit PlayerControlPreview(QWidget* parent);
|
||||
~PlayerControlPreview() override;
|
||||
|
||||
// Sets the emulated controller to be displayed
|
||||
void SetController(Core::HID::EmulatedController* controller);
|
||||
|
||||
// Disables events from the emulated controller
|
||||
void UnloadController();
|
||||
|
||||
// Starts blinking animation at the button specified
|
||||
void SetPlayerInput(std::size_t index, const ButtonParam& buttons_param,
|
||||
const AnalogParam& analogs_param);
|
||||
void SetPlayerInputRaw(std::size_t index, const Settings::ButtonsRaw& buttons_,
|
||||
Settings::AnalogsRaw analogs_);
|
||||
void SetConnectedStatus(bool checked);
|
||||
void SetControllerType(Settings::ControllerType type);
|
||||
void BeginMappingButton(std::size_t button_id);
|
||||
|
||||
// Starts moving animation at the stick specified
|
||||
void BeginMappingAnalog(std::size_t stick_id);
|
||||
|
||||
// Stops any ongoing animation
|
||||
void BeginMappingAnalog(std::size_t button_id);
|
||||
void EndMapping();
|
||||
|
||||
// Handles emulated controller events
|
||||
void ControllerUpdate(Core::HID::ControllerTriggerType type);
|
||||
|
||||
// Updates input on sheduled interval
|
||||
void UpdateInput();
|
||||
void SetCallBack(ControllerCallback callback_);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
@@ -74,6 +63,22 @@ private:
|
||||
SR,
|
||||
};
|
||||
|
||||
struct AxisValue {
|
||||
QPointF value{};
|
||||
QPointF raw_value{};
|
||||
Input::AnalogProperties properties{};
|
||||
int size{};
|
||||
QPoint offset{};
|
||||
bool active{};
|
||||
};
|
||||
|
||||
struct LedPattern {
|
||||
bool position1;
|
||||
bool position2;
|
||||
bool position3;
|
||||
bool position4;
|
||||
};
|
||||
|
||||
struct ColorMapping {
|
||||
QColor outline{};
|
||||
QColor primary{};
|
||||
@@ -96,6 +101,7 @@ private:
|
||||
QColor deadzone{};
|
||||
};
|
||||
|
||||
static LedPattern GetColorPattern(std::size_t index, bool player_on);
|
||||
void UpdateColors();
|
||||
void ResetInputs();
|
||||
|
||||
@@ -116,75 +122,47 @@ private:
|
||||
void DrawGCBody(QPainter& p, QPointF center);
|
||||
|
||||
// Draw triggers functions
|
||||
void DrawProTriggers(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& left_pressed,
|
||||
const Common::Input::ButtonStatus& right_pressed);
|
||||
void DrawGCTriggers(QPainter& p, QPointF center, Common::Input::TriggerStatus left_trigger,
|
||||
Common::Input::TriggerStatus right_trigger);
|
||||
void DrawHandheldTriggers(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& left_pressed,
|
||||
const Common::Input::ButtonStatus& right_pressed);
|
||||
void DrawDualTriggers(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& left_pressed,
|
||||
const Common::Input::ButtonStatus& right_pressed);
|
||||
void DrawDualTriggersTopView(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& left_pressed,
|
||||
const Common::Input::ButtonStatus& right_pressed);
|
||||
void DrawDualZTriggersTopView(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& left_pressed,
|
||||
const Common::Input::ButtonStatus& right_pressed);
|
||||
void DrawLeftTriggers(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& left_pressed);
|
||||
void DrawLeftZTriggers(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& left_pressed);
|
||||
void DrawLeftTriggersTopView(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& left_pressed);
|
||||
void DrawLeftZTriggersTopView(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& left_pressed);
|
||||
void DrawRightTriggers(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& right_pressed);
|
||||
void DrawRightZTriggers(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& right_pressed);
|
||||
void DrawRightTriggersTopView(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& right_pressed);
|
||||
void DrawRightZTriggersTopView(QPainter& p, QPointF center,
|
||||
const Common::Input::ButtonStatus& right_pressed);
|
||||
void DrawProTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
|
||||
void DrawGCTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
|
||||
void DrawHandheldTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
|
||||
void DrawDualTriggers(QPainter& p, QPointF center, bool left_pressed, bool right_pressed);
|
||||
void DrawDualTriggersTopView(QPainter& p, QPointF center, bool left_pressed,
|
||||
bool right_pressed);
|
||||
void DrawDualZTriggersTopView(QPainter& p, QPointF center, bool left_pressed,
|
||||
bool right_pressed);
|
||||
void DrawLeftTriggers(QPainter& p, QPointF center, bool left_pressed);
|
||||
void DrawLeftZTriggers(QPainter& p, QPointF center, bool left_pressed);
|
||||
void DrawLeftTriggersTopView(QPainter& p, QPointF center, bool left_pressed);
|
||||
void DrawLeftZTriggersTopView(QPainter& p, QPointF center, bool left_pressed);
|
||||
void DrawRightTriggers(QPainter& p, QPointF center, bool right_pressed);
|
||||
void DrawRightZTriggers(QPainter& p, QPointF center, bool right_pressed);
|
||||
void DrawRightTriggersTopView(QPainter& p, QPointF center, bool right_pressed);
|
||||
void DrawRightZTriggersTopView(QPainter& p, QPointF center, bool right_pressed);
|
||||
|
||||
// Draw joystick functions
|
||||
void DrawJoystick(QPainter& p, QPointF center, float size,
|
||||
const Common::Input::ButtonStatus& pressed);
|
||||
void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size,
|
||||
const Common::Input::ButtonStatus& pressed);
|
||||
void DrawJoystick(QPainter& p, QPointF center, float size, bool pressed);
|
||||
void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, bool pressed);
|
||||
void DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right);
|
||||
void DrawJoystickProperties(QPainter& p, QPointF center,
|
||||
const Common::Input::AnalogProperties& properties);
|
||||
void DrawJoystickDot(QPainter& p, QPointF center, const Common::Input::StickStatus& stick,
|
||||
bool raw);
|
||||
void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar,
|
||||
const Common::Input::ButtonStatus& pressed);
|
||||
void DrawGCJoystick(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed);
|
||||
const Input::AnalogProperties& properties);
|
||||
void DrawJoystickDot(QPainter& p, QPointF center, QPointF value,
|
||||
const Input::AnalogProperties& properties);
|
||||
void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, bool pressed);
|
||||
void DrawGCJoystick(QPainter& p, QPointF center, bool pressed);
|
||||
|
||||
// Draw button functions
|
||||
void DrawCircleButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed,
|
||||
float button_size);
|
||||
void DrawRoundButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed,
|
||||
float width, float height, Direction direction = Direction::None,
|
||||
float radius = 2);
|
||||
void DrawMinusButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed,
|
||||
int button_size);
|
||||
void DrawPlusButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed,
|
||||
int button_size);
|
||||
void DrawGCButtonX(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed);
|
||||
void DrawGCButtonY(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed);
|
||||
void DrawGCButtonZ(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed);
|
||||
void DrawCircleButton(QPainter& p, QPointF center, bool pressed, float button_size);
|
||||
void DrawRoundButton(QPainter& p, QPointF center, bool pressed, float width, float height,
|
||||
Direction direction = Direction::None, float radius = 2);
|
||||
void DrawMinusButton(QPainter& p, QPointF center, bool pressed, int button_size);
|
||||
void DrawPlusButton(QPainter& p, QPointF center, bool pressed, int button_size);
|
||||
void DrawGCButtonX(QPainter& p, QPointF center, bool pressed);
|
||||
void DrawGCButtonY(QPainter& p, QPointF center, bool pressed);
|
||||
void DrawGCButtonZ(QPainter& p, QPointF center, bool pressed);
|
||||
void DrawArrowButtonOutline(QPainter& p, const QPointF center, float size = 1.0f);
|
||||
void DrawArrowButton(QPainter& p, QPointF center, Direction direction,
|
||||
const Common::Input::ButtonStatus& pressed, float size = 1.0f);
|
||||
void DrawTriggerButton(QPainter& p, QPointF center, Direction direction,
|
||||
const Common::Input::ButtonStatus& pressed);
|
||||
|
||||
// Draw battery functions
|
||||
void DrawBattery(QPainter& p, QPointF center, Common::Input::BatteryLevel battery);
|
||||
void DrawArrowButton(QPainter& p, QPointF center, Direction direction, bool pressed,
|
||||
float size = 1.0f);
|
||||
void DrawTriggerButton(QPainter& p, QPointF center, Direction direction, bool pressed);
|
||||
|
||||
// Draw icon functions
|
||||
void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size);
|
||||
@@ -200,23 +178,24 @@ private:
|
||||
void SetTextFont(QPainter& p, float text_size,
|
||||
const QString& font_family = QStringLiteral("sans-serif"));
|
||||
|
||||
bool is_controller_set{};
|
||||
bool is_connected{};
|
||||
bool needs_redraw{};
|
||||
Core::HID::NpadStyleIndex controller_type;
|
||||
using ButtonArray =
|
||||
std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::BUTTON_NS_END>;
|
||||
using StickArray =
|
||||
std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>;
|
||||
|
||||
ControllerCallback controller_callback;
|
||||
bool is_enabled{};
|
||||
bool mapping_active{};
|
||||
int blink_counter{};
|
||||
int callback_key;
|
||||
QColor button_color{};
|
||||
ColorMapping colors{};
|
||||
Core::HID::LedPattern led_pattern{0, 0, 0, 0};
|
||||
std::array<QColor, 4> led_color{};
|
||||
ButtonArray buttons{};
|
||||
StickArray sticks{};
|
||||
std::size_t player_index{};
|
||||
Core::HID::EmulatedController* controller;
|
||||
std::size_t button_mapping_index{Settings::NativeButton::NumButtons};
|
||||
std::size_t analog_mapping_index{Settings::NativeAnalog::NumAnalogs};
|
||||
Core::HID::ButtonValues button_values{};
|
||||
Core::HID::SticksValues stick_values{};
|
||||
Core::HID::TriggerValues trigger_values{};
|
||||
Core::HID::BatteryValues battery_values{};
|
||||
std::size_t button_mapping_index{Settings::NativeButton::BUTTON_NS_END};
|
||||
std::size_t analog_mapping_index{Settings::NativeAnalog::NUM_STICKS_HID};
|
||||
std::array<AxisValue, Settings::NativeAnalog::NUM_STICKS_HID> axis_values{};
|
||||
std::array<bool, Settings::NativeButton::NumButtons> button_values{};
|
||||
Settings::ControllerType controller_type{Settings::ControllerType::ProController};
|
||||
};
|
||||
|
||||
@@ -11,8 +11,8 @@ ConfigureInputProfileDialog::ConfigureInputProfileDialog(
|
||||
QWidget* parent, InputCommon::InputSubsystem* input_subsystem, InputProfiles* profiles,
|
||||
Core::System& system)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigureInputProfileDialog>()),
|
||||
profile_widget(new ConfigureInputPlayer(this, 9, nullptr, input_subsystem, profiles,
|
||||
system.HIDCore(), system.IsPoweredOn(), false)) {
|
||||
profile_widget(
|
||||
new ConfigureInputPlayer(this, 9, nullptr, input_subsystem, profiles, system, false)) {
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->controllerLayout->addWidget(profile_widget);
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "common/settings.h"
|
||||
#include "input_common/drivers/udp_client.h"
|
||||
#include "input_common/helpers/udp_protocol.h"
|
||||
#include "input_common/main.h"
|
||||
#include "input_common/udp/client.h"
|
||||
#include "input_common/udp/udp.h"
|
||||
#include "ui_configure_motion_touch.h"
|
||||
#include "yuzu/configuration/configure_motion_touch.h"
|
||||
#include "yuzu/configuration/configure_touch_from_button.h"
|
||||
@@ -93,7 +93,6 @@ ConfigureMotionTouch::ConfigureMotionTouch(QWidget* parent,
|
||||
"using-a-controller-or-android-phone-for-motion-or-touch-input'><span "
|
||||
"style=\"text-decoration: underline; color:#039be5;\">Learn More</span></a>"));
|
||||
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
SetConfiguration();
|
||||
UpdateUiDisplay();
|
||||
ConnectEvents();
|
||||
@@ -102,14 +101,17 @@ ConfigureMotionTouch::ConfigureMotionTouch(QWidget* parent,
|
||||
ConfigureMotionTouch::~ConfigureMotionTouch() = default;
|
||||
|
||||
void ConfigureMotionTouch::SetConfiguration() {
|
||||
const Common::ParamPackage motion_param(Settings::values.motion_device.GetValue());
|
||||
const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue());
|
||||
|
||||
ui->touch_from_button_checkbox->setChecked(Settings::values.use_touch_from_button.GetValue());
|
||||
touch_from_button_maps = Settings::values.touch_from_button_maps;
|
||||
for (const auto& touch_map : touch_from_button_maps) {
|
||||
ui->touch_from_button_map->addItem(QString::fromStdString(touch_map.name));
|
||||
}
|
||||
ui->touch_from_button_map->setCurrentIndex(
|
||||
Settings::values.touch_from_button_map_index.GetValue());
|
||||
ui->motion_sensitivity->setValue(motion_param.Get("sensitivity", 0.01f));
|
||||
|
||||
min_x = touch_param.Get("min_x", 100);
|
||||
min_y = touch_param.Get("min_y", 50);
|
||||
@@ -137,6 +139,9 @@ void ConfigureMotionTouch::SetConfiguration() {
|
||||
void ConfigureMotionTouch::UpdateUiDisplay() {
|
||||
const QString cemuhook_udp = QStringLiteral("cemuhookudp");
|
||||
|
||||
ui->motion_sensitivity_label->setVisible(true);
|
||||
ui->motion_sensitivity->setVisible(true);
|
||||
|
||||
ui->touch_calibration->setVisible(true);
|
||||
ui->touch_calibration_config->setVisible(true);
|
||||
ui->touch_calibration_label->setVisible(true);
|
||||
@@ -307,6 +312,7 @@ void ConfigureMotionTouch::ApplyConfiguration() {
|
||||
touch_param.Set("max_y", max_y);
|
||||
|
||||
Settings::values.touch_device = touch_param.Serialize();
|
||||
Settings::values.use_touch_from_button = ui->touch_from_button_checkbox->isChecked();
|
||||
Settings::values.touch_from_button_map_index = ui->touch_from_button_map->currentIndex();
|
||||
Settings::values.touch_from_button_maps = touch_from_button_maps;
|
||||
Settings::values.udp_input_servers = GetUDPServerString();
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
<ui version="4.0">
|
||||
<class>ConfigureMotionTouch</class>
|
||||
<widget class="QDialog" name="ConfigureMotionTouch">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>482</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Configure Motion / Touch</string>
|
||||
</property>
|
||||
@@ -9,6 +17,48 @@
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="motion_group_box">
|
||||
<property name="title">
|
||||
<string>Mouse Motion</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="motion_sensitivity_label">
|
||||
<property name="text">
|
||||
<string>Sensitivity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="motion_sensitivity">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.001000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="touch_group_box">
|
||||
<property name="title">
|
||||
@@ -51,13 +101,19 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="touch_from_button_label">
|
||||
<property name="text">
|
||||
<string>Touch from button profile:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="touch_from_button_checkbox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use button mapping:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="touch_from_button_map"/>
|
||||
</item>
|
||||
|
||||
@@ -11,11 +11,8 @@
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/param_package.h"
|
||||
#include "input_common/drivers/keyboard.h"
|
||||
#include "input_common/drivers/mouse.h"
|
||||
#include "input_common/main.h"
|
||||
#include "ui_configure_mouse_advanced.h"
|
||||
#include "yuzu/bootmanager.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
#include "yuzu/configuration/configure_mouse_advanced.h"
|
||||
|
||||
@@ -104,7 +101,7 @@ ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent,
|
||||
[=, this](const Common::ParamPackage& params) {
|
||||
buttons_param[button_id] = params;
|
||||
},
|
||||
InputCommon::Polling::InputType::Button);
|
||||
InputCommon::Polling::DeviceType::Button);
|
||||
});
|
||||
connect(button, &QPushButton::customContextMenuRequested,
|
||||
[=, this](const QPoint& menu_location) {
|
||||
@@ -130,10 +127,13 @@ ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent,
|
||||
connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
|
||||
|
||||
connect(poll_timer.get(), &QTimer::timeout, [this] {
|
||||
const auto& params = input_subsystem->GetNextInput();
|
||||
if (params.Has("engine")) {
|
||||
SetPollingResult(params, false);
|
||||
return;
|
||||
Common::ParamPackage params;
|
||||
for (auto& poller : device_pollers) {
|
||||
params = poller->GetNextInput();
|
||||
if (params.Has("engine")) {
|
||||
SetPollingResult(params, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -196,13 +196,26 @@ void ConfigureMouseAdvanced::UpdateButtonLabels() {
|
||||
|
||||
void ConfigureMouseAdvanced::HandleClick(
|
||||
QPushButton* button, std::function<void(const Common::ParamPackage&)> new_input_setter,
|
||||
InputCommon::Polling::InputType type) {
|
||||
InputCommon::Polling::DeviceType type) {
|
||||
button->setText(tr("[press key]"));
|
||||
button->setFocus();
|
||||
|
||||
// Keyboard keys or mouse buttons can only be used as button devices
|
||||
want_keyboard_mouse = type == InputCommon::Polling::DeviceType::Button;
|
||||
if (want_keyboard_mouse) {
|
||||
const auto iter = std::find(button_map.begin(), button_map.end(), button);
|
||||
ASSERT(iter != button_map.end());
|
||||
const auto index = std::distance(button_map.begin(), iter);
|
||||
ASSERT(index < Settings::NativeButton::NumButtons && index >= 0);
|
||||
}
|
||||
|
||||
input_setter = new_input_setter;
|
||||
|
||||
input_subsystem->BeginMapping(type);
|
||||
device_pollers = input_subsystem->GetPollers(type);
|
||||
|
||||
for (auto& poller : device_pollers) {
|
||||
poller->Start();
|
||||
}
|
||||
|
||||
QWidget::grabMouse();
|
||||
QWidget::grabKeyboard();
|
||||
@@ -214,7 +227,9 @@ void ConfigureMouseAdvanced::HandleClick(
|
||||
void ConfigureMouseAdvanced::SetPollingResult(const Common::ParamPackage& params, bool abort) {
|
||||
timeout_timer->stop();
|
||||
poll_timer->stop();
|
||||
input_subsystem->StopMapping();
|
||||
for (auto& poller : device_pollers) {
|
||||
poller->Stop();
|
||||
}
|
||||
|
||||
QWidget::releaseMouse();
|
||||
QWidget::releaseKeyboard();
|
||||
@@ -232,8 +247,15 @@ void ConfigureMouseAdvanced::mousePressEvent(QMouseEvent* event) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
|
||||
input_subsystem->GetMouse()->PressButton(0, 0, 0, 0, button);
|
||||
if (want_keyboard_mouse) {
|
||||
SetPollingResult(Common::ParamPackage{InputCommon::GenerateKeyboardParam(event->button())},
|
||||
false);
|
||||
} else {
|
||||
// We don't want any mouse buttons, so don't stop polling
|
||||
return;
|
||||
}
|
||||
|
||||
SetPollingResult({}, true);
|
||||
}
|
||||
|
||||
void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) {
|
||||
@@ -242,6 +264,13 @@ void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) {
|
||||
}
|
||||
|
||||
if (event->key() != Qt::Key_Escape) {
|
||||
input_subsystem->GetKeyboard()->PressKey(event->key());
|
||||
if (want_keyboard_mouse) {
|
||||
SetPollingResult(Common::ParamPackage{InputCommon::GenerateKeyboardParam(event->key())},
|
||||
false);
|
||||
} else {
|
||||
// Escape key wasn't pressed and we don't want any keyboard keys, so don't stop polling
|
||||
return;
|
||||
}
|
||||
}
|
||||
SetPollingResult({}, true);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ private:
|
||||
/// Called when the button was pressed.
|
||||
void HandleClick(QPushButton* button,
|
||||
std::function<void(const Common::ParamPackage&)> new_input_setter,
|
||||
InputCommon::Polling::InputType type);
|
||||
InputCommon::Polling::DeviceType type);
|
||||
|
||||
/// Finish polling and configure input using the input_setter
|
||||
void SetPollingResult(const Common::ParamPackage& params, bool abort);
|
||||
@@ -67,6 +67,12 @@ private:
|
||||
std::array<QPushButton*, Settings::NativeMouseButton::NumMouseButtons> button_map;
|
||||
std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons> buttons_param;
|
||||
|
||||
std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers;
|
||||
|
||||
std::unique_ptr<QTimer> timeout_timer;
|
||||
std::unique_ptr<QTimer> poll_timer;
|
||||
|
||||
/// A flag to indicate if keyboard keys are okay when configuring an input. If this is false,
|
||||
/// keyboard events are ignored.
|
||||
bool want_keyboard_mouse = false;
|
||||
};
|
||||
|
||||
@@ -32,6 +32,7 @@ void ConfigureTasDialog::LoadConfiguration() {
|
||||
ui->tas_path_edit->setText(
|
||||
QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::TASDir)));
|
||||
ui->tas_enable->setChecked(Settings::values.tas_enable.GetValue());
|
||||
ui->tas_control_swap->setChecked(Settings::values.tas_swap_controllers.GetValue());
|
||||
ui->tas_loop_script->setChecked(Settings::values.tas_loop.GetValue());
|
||||
ui->tas_pause_on_load->setChecked(Settings::values.pause_tas_on_load.GetValue());
|
||||
}
|
||||
@@ -39,6 +40,7 @@ void ConfigureTasDialog::LoadConfiguration() {
|
||||
void ConfigureTasDialog::ApplyConfiguration() {
|
||||
Common::FS::SetYuzuPath(Common::FS::YuzuPath::TASDir, ui->tas_path_edit->text().toStdString());
|
||||
Settings::values.tas_enable.SetValue(ui->tas_enable->isChecked());
|
||||
Settings::values.tas_swap_controllers.SetValue(ui->tas_control_swap->isChecked());
|
||||
Settings::values.tas_loop.SetValue(ui->tas_loop_script->isChecked());
|
||||
Settings::values.pause_tas_on_load.SetValue(ui->tas_pause_on_load->isChecked());
|
||||
}
|
||||
|
||||
@@ -59,13 +59,20 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QCheckBox" name="tas_control_swap">
|
||||
<property name="text">
|
||||
<string>Automatic controller profile swapping</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="4">
|
||||
<widget class="QCheckBox" name="tas_loop_script">
|
||||
<property name="text">
|
||||
<string>Loop script</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="4">
|
||||
<item row="3" column="0" colspan="4">
|
||||
<widget class="QCheckBox" name="tas_pause_on_load">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
|
||||
@@ -163,10 +163,13 @@ void ConfigureTouchFromButton::ConnectEvents() {
|
||||
connect(timeout_timer.get(), &QTimer::timeout, [this]() { SetPollingResult({}, true); });
|
||||
|
||||
connect(poll_timer.get(), &QTimer::timeout, [this]() {
|
||||
const auto& params = input_subsystem->GetNextInput();
|
||||
if (params.Has("engine")) {
|
||||
SetPollingResult(params, false);
|
||||
return;
|
||||
Common::ParamPackage params;
|
||||
for (auto& poller : device_pollers) {
|
||||
params = poller->GetNextInput();
|
||||
if (params.Has("engine")) {
|
||||
SetPollingResult(params, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -245,7 +248,11 @@ void ConfigureTouchFromButton::GetButtonInput(const int row_index, const bool is
|
||||
}
|
||||
};
|
||||
|
||||
input_subsystem->BeginMapping(InputCommon::Polling::InputType::Button);
|
||||
device_pollers = input_subsystem->GetPollers(InputCommon::Polling::DeviceType::Button);
|
||||
|
||||
for (auto& poller : device_pollers) {
|
||||
poller->Start();
|
||||
}
|
||||
|
||||
grabKeyboard();
|
||||
grabMouse();
|
||||
@@ -358,14 +365,14 @@ void ConfigureTouchFromButton::SetCoordinates(const int dot_id, const QPoint& po
|
||||
|
||||
void ConfigureTouchFromButton::SetPollingResult(const Common::ParamPackage& params,
|
||||
const bool cancel) {
|
||||
timeout_timer->stop();
|
||||
poll_timer->stop();
|
||||
input_subsystem->StopMapping();
|
||||
|
||||
releaseKeyboard();
|
||||
releaseMouse();
|
||||
qApp->restoreOverrideCursor();
|
||||
|
||||
timeout_timer->stop();
|
||||
poll_timer->stop();
|
||||
for (auto& poller : device_pollers) {
|
||||
poller->Stop();
|
||||
}
|
||||
if (input_setter) {
|
||||
(*input_setter)(params, cancel);
|
||||
input_setter.reset();
|
||||
|
||||
@@ -24,6 +24,10 @@ namespace InputCommon {
|
||||
class InputSubsystem;
|
||||
}
|
||||
|
||||
namespace InputCommon::Polling {
|
||||
class DevicePoller;
|
||||
}
|
||||
|
||||
namespace Settings {
|
||||
struct TouchFromButtonMap;
|
||||
}
|
||||
@@ -81,6 +85,7 @@ private:
|
||||
|
||||
std::unique_ptr<QTimer> timeout_timer;
|
||||
std::unique_ptr<QTimer> poll_timer;
|
||||
std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers;
|
||||
std::optional<std::function<void(const Common::ParamPackage&, bool)>> input_setter;
|
||||
|
||||
static constexpr int DataRoleDot = Qt::ItemDataRole::UserRole + 2;
|
||||
|
||||
@@ -97,7 +97,7 @@ void ConfigureVibration::SetVibrationDevices(std::size_t player_index) {
|
||||
|
||||
const auto engine = param.Get("engine", "");
|
||||
const auto guid = param.Get("guid", "");
|
||||
const auto port = param.Get("port", 0);
|
||||
const auto port = param.Get("port", "");
|
||||
|
||||
if (engine.empty() || engine == "keyboard" || engine == "mouse" || engine == "tas") {
|
||||
continue;
|
||||
@@ -105,7 +105,7 @@ void ConfigureVibration::SetVibrationDevices(std::size_t player_index) {
|
||||
|
||||
vibration_param_str += fmt::format("engine:{}", engine);
|
||||
|
||||
if (port != 0) {
|
||||
if (!port.empty()) {
|
||||
vibration_param_str += fmt::format(",port:{}", port);
|
||||
}
|
||||
if (!guid.empty()) {
|
||||
|
||||
@@ -6,17 +6,13 @@
|
||||
#include <QLayout>
|
||||
#include <QString>
|
||||
#include "common/settings.h"
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "input_common/drivers/tas_input.h"
|
||||
#include "input_common/main.h"
|
||||
#include "input_common/tas/tas_input.h"
|
||||
#include "yuzu/configuration/configure_input_player_widget.h"
|
||||
#include "yuzu/debugger/controller.h"
|
||||
|
||||
ControllerDialog::ControllerDialog(Core::HID::HIDCore& hid_core_,
|
||||
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_,
|
||||
QWidget* parent)
|
||||
: QWidget(parent, Qt::Dialog), hid_core{hid_core_}, input_subsystem{input_subsystem_} {
|
||||
ControllerDialog::ControllerDialog(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_)
|
||||
: QWidget(parent, Qt::Dialog), input_subsystem{input_subsystem_} {
|
||||
setObjectName(QStringLiteral("Controller"));
|
||||
setWindowTitle(tr("Controller P1"));
|
||||
resize(500, 350);
|
||||
@@ -35,24 +31,20 @@ ControllerDialog::ControllerDialog(Core::HID::HIDCore& hid_core_,
|
||||
// Configure focus so that widget is focusable and the dialog automatically forwards focus to
|
||||
// it.
|
||||
setFocusProxy(widget);
|
||||
widget->SetConnectedStatus(false);
|
||||
widget->setFocusPolicy(Qt::StrongFocus);
|
||||
widget->setFocus();
|
||||
}
|
||||
|
||||
void ControllerDialog::refreshConfiguration() {
|
||||
UnloadController();
|
||||
auto* player_1 = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||
auto* handheld = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||
// Display the correct controller
|
||||
controller = handheld->IsConnected() ? handheld : player_1;
|
||||
|
||||
Core::HID::ControllerUpdateCallback engine_callback{
|
||||
.on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); },
|
||||
.is_npad_service = true,
|
||||
};
|
||||
callback_key = controller->SetCallback(engine_callback);
|
||||
widget->SetController(controller);
|
||||
is_controller_set = true;
|
||||
const auto& players = Settings::values.players.GetValue();
|
||||
constexpr std::size_t player = 0;
|
||||
widget->SetPlayerInputRaw(player, players[player].buttons, players[player].analogs);
|
||||
widget->SetControllerType(players[player].controller_type);
|
||||
ControllerCallback callback{[this](ControllerInput input) { InputController(input); }};
|
||||
widget->SetCallBack(callback);
|
||||
widget->repaint();
|
||||
widget->SetConnectedStatus(players[player].connected);
|
||||
}
|
||||
|
||||
QAction* ControllerDialog::toggleViewAction() {
|
||||
@@ -66,18 +58,11 @@ QAction* ControllerDialog::toggleViewAction() {
|
||||
return toggle_view_action;
|
||||
}
|
||||
|
||||
void ControllerDialog::UnloadController() {
|
||||
widget->UnloadController();
|
||||
if (is_controller_set) {
|
||||
controller->DeleteCallback(callback_key);
|
||||
is_controller_set = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerDialog::showEvent(QShowEvent* ev) {
|
||||
if (toggle_view_action) {
|
||||
toggle_view_action->setChecked(isVisible());
|
||||
}
|
||||
refreshConfiguration();
|
||||
QWidget::showEvent(ev);
|
||||
}
|
||||
|
||||
@@ -85,34 +70,16 @@ void ControllerDialog::hideEvent(QHideEvent* ev) {
|
||||
if (toggle_view_action) {
|
||||
toggle_view_action->setChecked(isVisible());
|
||||
}
|
||||
widget->SetConnectedStatus(false);
|
||||
QWidget::hideEvent(ev);
|
||||
}
|
||||
|
||||
void ControllerDialog::ControllerUpdate(Core::HID::ControllerTriggerType type) {
|
||||
// TODO(german77): Remove TAS from here
|
||||
switch (type) {
|
||||
case Core::HID::ControllerTriggerType::Button:
|
||||
case Core::HID::ControllerTriggerType::Stick: {
|
||||
const auto buttons_values = controller->GetButtonsValues();
|
||||
const auto stick_values = controller->GetSticksValues();
|
||||
u64 buttons = 0;
|
||||
std::size_t index = 0;
|
||||
for (const auto& button : buttons_values) {
|
||||
buttons |= button.value ? 1LLU << index : 0;
|
||||
index++;
|
||||
}
|
||||
const InputCommon::TasInput::TasAnalog left_axis = {
|
||||
.x = stick_values[Settings::NativeAnalog::LStick].x.value,
|
||||
.y = stick_values[Settings::NativeAnalog::LStick].y.value,
|
||||
};
|
||||
const InputCommon::TasInput::TasAnalog right_axis = {
|
||||
.x = stick_values[Settings::NativeAnalog::RStick].x.value,
|
||||
.y = stick_values[Settings::NativeAnalog::RStick].y.value,
|
||||
};
|
||||
input_subsystem->GetTas()->RecordInput(buttons, left_axis, right_axis);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
void ControllerDialog::InputController(ControllerInput input) {
|
||||
u32 buttons = 0;
|
||||
int index = 0;
|
||||
for (bool btn : input.button_values) {
|
||||
buttons |= (btn ? 1U : 0U) << index;
|
||||
index++;
|
||||
}
|
||||
input_subsystem->GetTas()->RecordInput(buttons, input.axis_values);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QWidget>
|
||||
#include "common/settings.h"
|
||||
|
||||
class QAction;
|
||||
class QHideEvent;
|
||||
@@ -15,43 +17,35 @@ namespace InputCommon {
|
||||
class InputSubsystem;
|
||||
}
|
||||
|
||||
namespace Core::HID {
|
||||
class HIDCore;
|
||||
class EmulatedController;
|
||||
enum class ControllerTriggerType;
|
||||
} // namespace Core::HID
|
||||
struct ControllerInput {
|
||||
std::array<std::pair<float, float>, Settings::NativeAnalog::NUM_STICKS_HID> axis_values{};
|
||||
std::array<bool, Settings::NativeButton::NumButtons> button_values{};
|
||||
bool changed{};
|
||||
};
|
||||
|
||||
struct ControllerCallback {
|
||||
std::function<void(ControllerInput)> input;
|
||||
};
|
||||
|
||||
class ControllerDialog : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ControllerDialog(Core::HID::HIDCore& hid_core_,
|
||||
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_,
|
||||
QWidget* parent = nullptr);
|
||||
explicit ControllerDialog(QWidget* parent = nullptr,
|
||||
InputCommon::InputSubsystem* input_subsystem_ = nullptr);
|
||||
|
||||
/// Returns a QAction that can be used to toggle visibility of this dialog.
|
||||
QAction* toggleViewAction();
|
||||
|
||||
/// Reloads the widget to apply any changes in the configuration
|
||||
void refreshConfiguration();
|
||||
|
||||
/// Disables events from the emulated controller
|
||||
void UnloadController();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* ev) override;
|
||||
void hideEvent(QHideEvent* ev) override;
|
||||
|
||||
private:
|
||||
/// Redirects input from the widget to the TAS driver
|
||||
void ControllerUpdate(Core::HID::ControllerTriggerType type);
|
||||
|
||||
int callback_key;
|
||||
bool is_controller_set{};
|
||||
Core::HID::EmulatedController* controller;
|
||||
|
||||
void InputController(ControllerInput input);
|
||||
QAction* toggle_view_action = nullptr;
|
||||
QFileSystemWatcher* watcher = nullptr;
|
||||
PlayerControlPreview* widget;
|
||||
Core::HID::HIDCore& hid_core;
|
||||
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem;
|
||||
InputCommon::InputSubsystem* input_subsystem;
|
||||
};
|
||||
|
||||
+11
-19
@@ -26,8 +26,6 @@
|
||||
#include "core/frontend/applets/controller.h"
|
||||
#include "core/frontend/applets/general_frontend.h"
|
||||
#include "core/frontend/applets/software_keyboard.h"
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/acc/profile_manager.h"
|
||||
#include "core/hle/service/am/applet_ae.h"
|
||||
#include "core/hle/service/am/applet_oe.h"
|
||||
@@ -108,8 +106,8 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/perf_stats.h"
|
||||
#include "core/telemetry_session.h"
|
||||
#include "input_common/drivers/tas_input.h"
|
||||
#include "input_common/main.h"
|
||||
#include "input_common/tas/tas_input.h"
|
||||
#include "ui_main.h"
|
||||
#include "util/overlay_dialog.h"
|
||||
#include "video_core/gpu.h"
|
||||
@@ -229,9 +227,6 @@ GMainWindow::GMainWindow()
|
||||
ConnectMenuEvents();
|
||||
ConnectWidgetEvents();
|
||||
|
||||
system->HIDCore().ReloadInputDevices();
|
||||
controller_dialog->refreshConfiguration();
|
||||
|
||||
const auto branch_name = std::string(Common::g_scm_branch);
|
||||
const auto description = std::string(Common::g_scm_desc);
|
||||
const auto build_id = std::string(Common::g_build_id);
|
||||
@@ -834,16 +829,15 @@ void GMainWindow::InitializeWidgets() {
|
||||
dock_status_button->setFocusPolicy(Qt::NoFocus);
|
||||
connect(dock_status_button, &QPushButton::clicked, [&] {
|
||||
const bool is_docked = Settings::values.use_docked_mode.GetValue();
|
||||
auto* player_1 = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||
auto* handheld = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||
auto& controller_type = Settings::values.players.GetValue()[0].controller_type;
|
||||
|
||||
if (!is_docked && handheld->IsConnected()) {
|
||||
if (!is_docked && controller_type == Settings::ControllerType::Handheld) {
|
||||
QMessageBox::warning(this, tr("Invalid config detected"),
|
||||
tr("Handheld controller can't be used on docked mode. Pro "
|
||||
"controller will be selected."));
|
||||
handheld->Disconnect();
|
||||
player_1->SetNpadStyleIndex(Core::HID::NpadStyleIndex::ProController);
|
||||
player_1->Connect();
|
||||
controller_type = Settings::ControllerType::ProController;
|
||||
ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system);
|
||||
configure_dialog.ApplyConfiguration();
|
||||
controller_dialog->refreshConfiguration();
|
||||
}
|
||||
|
||||
@@ -928,7 +922,7 @@ void GMainWindow::InitializeDebugWidgets() {
|
||||
waitTreeWidget->hide();
|
||||
debug_menu->addAction(waitTreeWidget->toggleViewAction());
|
||||
|
||||
controller_dialog = new ControllerDialog(system->HIDCore(), input_subsystem, this);
|
||||
controller_dialog = new ControllerDialog(this, input_subsystem.get());
|
||||
controller_dialog->hide();
|
||||
debug_menu->addAction(controller_dialog->toggleViewAction());
|
||||
|
||||
@@ -2780,6 +2774,7 @@ void GMainWindow::OnConfigure() {
|
||||
|
||||
ShowTelemetryCallout();
|
||||
}
|
||||
controller_dialog->refreshConfiguration();
|
||||
InitializeHotkeys();
|
||||
|
||||
if (UISettings::values.theme != old_theme) {
|
||||
@@ -2812,7 +2807,6 @@ void GMainWindow::OnConfigure() {
|
||||
}
|
||||
|
||||
UpdateStatusButtons();
|
||||
controller_dialog->refreshConfiguration();
|
||||
}
|
||||
|
||||
void GMainWindow::OnConfigureTas() {
|
||||
@@ -3009,11 +3003,11 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie
|
||||
QString GMainWindow::GetTasStateDescription() const {
|
||||
auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus();
|
||||
switch (tas_status) {
|
||||
case InputCommon::TasInput::TasState::Running:
|
||||
case TasInput::TasState::Running:
|
||||
return tr("TAS state: Running %1/%2").arg(current_tas_frame).arg(total_tas_frames);
|
||||
case InputCommon::TasInput::TasState::Recording:
|
||||
case TasInput::TasState::Recording:
|
||||
return tr("TAS state: Recording %1").arg(total_tas_frames);
|
||||
case InputCommon::TasInput::TasState::Stopped:
|
||||
case TasInput::TasState::Stopped:
|
||||
return tr("TAS state: Idle %1/%2").arg(current_tas_frame).arg(total_tas_frames);
|
||||
default:
|
||||
return tr("TAS State: Invalid");
|
||||
@@ -3392,8 +3386,6 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
|
||||
UpdateUISettings();
|
||||
game_list->SaveInterfaceLayout();
|
||||
hotkey_registry.SaveHotkeys();
|
||||
controller_dialog->UnloadController();
|
||||
system->HIDCore().UnloadInputDevices();
|
||||
|
||||
// Shutdown session if the emu thread is active...
|
||||
if (emu_thread != nullptr) {
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include <QScreen>
|
||||
|
||||
#include "core/core.h"
|
||||
#include "core/hid/hid_types.h"
|
||||
#include "core/hid/input_interpreter.h"
|
||||
#include "core/frontend/input_interpreter.h"
|
||||
#include "ui_overlay_dialog.h"
|
||||
#include "yuzu/util/overlay_dialog.h"
|
||||
|
||||
@@ -180,9 +179,9 @@ void OverlayDialog::MoveAndResizeWindow() {
|
||||
QDialog::resize(width, height);
|
||||
}
|
||||
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void OverlayDialog::HandleButtonPressedOnce() {
|
||||
const auto f = [this](Core::HID::NpadButton button) {
|
||||
const auto f = [this](HIDButton button) {
|
||||
if (input_interpreter->IsButtonPressedOnce(button)) {
|
||||
TranslateButtonPress(button);
|
||||
}
|
||||
@@ -191,7 +190,7 @@ void OverlayDialog::HandleButtonPressedOnce() {
|
||||
(f(T), ...);
|
||||
}
|
||||
|
||||
void OverlayDialog::TranslateButtonPress(Core::HID::NpadButton button) {
|
||||
void OverlayDialog::TranslateButtonPress(HIDButton button) {
|
||||
QPushButton* left_button = use_rich_text ? ui->button_cancel_rich : ui->button_cancel;
|
||||
QPushButton* right_button = use_rich_text ? ui->button_ok_rich : ui->button_ok_label;
|
||||
|
||||
@@ -199,20 +198,20 @@ void OverlayDialog::TranslateButtonPress(Core::HID::NpadButton button) {
|
||||
// TODO (Morph): focusPrevious/NextChild() doesn't work well with the rich text dialog, fix it
|
||||
|
||||
switch (button) {
|
||||
case Core::HID::NpadButton::A:
|
||||
case Core::HID::NpadButton::B:
|
||||
case HIDButton::A:
|
||||
case HIDButton::B:
|
||||
if (left_button->hasFocus()) {
|
||||
left_button->click();
|
||||
} else if (right_button->hasFocus()) {
|
||||
right_button->click();
|
||||
}
|
||||
break;
|
||||
case Core::HID::NpadButton::Left:
|
||||
case Core::HID::NpadButton::StickLLeft:
|
||||
case HIDButton::DLeft:
|
||||
case HIDButton::LStickLeft:
|
||||
focusPreviousChild();
|
||||
break;
|
||||
case Core::HID::NpadButton::Right:
|
||||
case Core::HID::NpadButton::StickLRight:
|
||||
case HIDButton::DRight:
|
||||
case HIDButton::LStickRight:
|
||||
focusNextChild();
|
||||
break;
|
||||
default:
|
||||
@@ -242,10 +241,8 @@ void OverlayDialog::InputThread() {
|
||||
while (input_thread_running) {
|
||||
input_interpreter->PollInput();
|
||||
|
||||
HandleButtonPressedOnce<Core::HID::NpadButton::A, Core::HID::NpadButton::B,
|
||||
Core::HID::NpadButton::Left, Core::HID::NpadButton::Right,
|
||||
Core::HID::NpadButton::StickLLeft,
|
||||
Core::HID::NpadButton::StickLRight>();
|
||||
HandleButtonPressedOnce<HIDButton::A, HIDButton::B, HIDButton::DLeft, HIDButton::DRight,
|
||||
HIDButton::LStickLeft, HIDButton::LStickRight>();
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
}
|
||||
|
||||
@@ -13,16 +13,14 @@
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
enum class HIDButton : u8;
|
||||
|
||||
class InputInterpreter;
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Core::HID {
|
||||
enum class NpadButton : u64;
|
||||
}
|
||||
|
||||
namespace Ui {
|
||||
class OverlayDialog;
|
||||
}
|
||||
@@ -81,7 +79,7 @@ private:
|
||||
*
|
||||
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
|
||||
*/
|
||||
template <Core::HID::NpadButton... T>
|
||||
template <HIDButton... T>
|
||||
void HandleButtonPressedOnce();
|
||||
|
||||
/**
|
||||
@@ -89,7 +87,7 @@ private:
|
||||
*
|
||||
* @param button The button press to process.
|
||||
*/
|
||||
void TranslateButtonPress(Core::HID::NpadButton button);
|
||||
void TranslateButtonPress(HIDButton button);
|
||||
|
||||
void StartInputThread();
|
||||
void StopInputThread();
|
||||
|
||||
Reference in New Issue
Block a user