2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Qt_applets: Use new input

This commit is contained in:
german77 2021-09-20 20:19:28 -05:00 committed by Narr the Reg
parent 6e2c84042d
commit 8fff6d6c67
5 changed files with 67 additions and 48 deletions

View file

@ -6,8 +6,11 @@
#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_types.h
#include "core/hle/lock.h"
#include "core/hle/service/hid/controllers/npad.h"
#include "core/hle/service/hid/hid.h"
@ -48,7 +51,8 @@ void UpdateController(Settings::ControllerType controller_type, std::size_t npad
->GetAppletResource()
->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad);
npad.UpdateControllerAt(npad.MapSettingsTypeToNPad(controller_type), npad_index, connected);
npad.UpdateControllerAt(Core::HID::EmulatedController::MapSettingsTypeToNPad(controller_type),
npad_index, connected);
}
// Returns true if the given controller type is compatible with the given parameters.

View file

@ -31,6 +31,10 @@ namespace Ui {
class QtControllerSelectorDialog;
}
namespace Core {
class System;
}
class QtControllerSelectorDialog final : public QDialog {
Q_OBJECT
@ -102,6 +106,7 @@ private:
Core::Frontend::ControllerParameters parameters;
InputCommon::InputSubsystem* input_subsystem;
Core::System& system;
std::unique_ptr<InputProfiles> input_profiles;

View file

@ -10,7 +10,8 @@
#include "common/settings.h"
#include "common/string_util.h"
#include "core/core.h"
#include "core/frontend/input_interpreter.h"
#include "core/hid/hid_types.h"
#include "core/hid/input_interpreter.h"
#include "ui_qt_software_keyboard.h"
#include "yuzu/applets/qt_software_keyboard.h"
#include "yuzu/main.h"
@ -484,7 +485,7 @@ void QtSoftwareKeyboardDialog::open() {
void QtSoftwareKeyboardDialog::reject() {
// Pressing the ESC key in a dialog calls QDialog::reject().
// We will override this behavior to the "Cancel" action on the software keyboard.
TranslateButtonPress(HIDButton::X);
TranslateButtonPress(Core::HID::NpadButton::X);
}
void QtSoftwareKeyboardDialog::keyPressEvent(QKeyEvent* event) {
@ -722,7 +723,7 @@ void QtSoftwareKeyboardDialog::SetTextDrawType() {
connect(
ui->line_edit_osk, &QLineEdit::returnPressed, this,
[this] { TranslateButtonPress(HIDButton::Plus); }, Qt::QueuedConnection);
[this] { TranslateButtonPress(Core::HID::NpadButton::Plus); }, Qt::QueuedConnection);
ui->line_edit_osk->setPlaceholderText(
QString::fromStdU16String(initialize_parameters.guide_text));
@ -1208,9 +1209,9 @@ void QtSoftwareKeyboardDialog::SetupMouseHover() {
}
}
template <HIDButton... T>
template <Core::HID::NpadButton... T>
void QtSoftwareKeyboardDialog::HandleButtonPressedOnce() {
const auto f = [this](HIDButton button) {
const auto f = [this](Core::HID::NpadButton button) {
if (input_interpreter->IsButtonPressedOnce(button)) {
TranslateButtonPress(button);
}
@ -1219,9 +1220,9 @@ void QtSoftwareKeyboardDialog::HandleButtonPressedOnce() {
(f(T), ...);
}
template <HIDButton... T>
template <Core::HID::NpadButton... T>
void QtSoftwareKeyboardDialog::HandleButtonHold() {
const auto f = [this](HIDButton button) {
const auto f = [this](Core::HID::NpadButton button) {
if (input_interpreter->IsButtonHeld(button)) {
TranslateButtonPress(button);
}
@ -1230,9 +1231,9 @@ void QtSoftwareKeyboardDialog::HandleButtonHold() {
(f(T), ...);
}
void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button) {
switch (button) {
case HIDButton::A:
case Core::HID::NpadButton::A:
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
case BottomOSKIndex::UpperCase:
@ -1245,7 +1246,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
break;
}
break;
case HIDButton::B:
case Core::HID::NpadButton::B:
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
ui->button_backspace->click();
@ -1260,7 +1261,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
break;
}
break;
case HIDButton::X:
case Core::HID::NpadButton::X:
if (is_inline) {
emit SubmitInlineText(SwkbdReplyType::DecidedCancel, current_text, cursor_position);
} else {
@ -1271,7 +1272,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
emit SubmitNormalText(SwkbdResult::Cancel, std::move(text));
}
break;
case HIDButton::Y:
case Core::HID::NpadButton::Y:
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
ui->button_space->click();
@ -1284,8 +1285,8 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
break;
}
break;
case HIDButton::LStick:
case HIDButton::RStick:
case Core::HID::NpadButton::StickL:
case Core::HID::NpadButton::StickR:
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
ui->button_shift->click();
@ -1298,13 +1299,13 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
break;
}
break;
case HIDButton::L:
case Core::HID::NpadButton::L:
MoveTextCursorDirection(Direction::Left);
break;
case HIDButton::R:
case Core::HID::NpadButton::R:
MoveTextCursorDirection(Direction::Right);
break;
case HIDButton::Plus:
case Core::HID::NpadButton::Plus:
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
ui->button_ok->click();
@ -1319,24 +1320,24 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
break;
}
break;
case HIDButton::DLeft:
case HIDButton::LStickLeft:
case HIDButton::RStickLeft:
case Core::HID::NpadButton::Left:
case Core::HID::NpadButton::StickLLeft:
case Core::HID::NpadButton::StickRLeft:
MoveButtonDirection(Direction::Left);
break;
case HIDButton::DUp:
case HIDButton::LStickUp:
case HIDButton::RStickUp:
case Core::HID::NpadButton::Up:
case Core::HID::NpadButton::StickLUp:
case Core::HID::NpadButton::StickRUp:
MoveButtonDirection(Direction::Up);
break;
case HIDButton::DRight:
case HIDButton::LStickRight:
case HIDButton::RStickRight:
case Core::HID::NpadButton::Right:
case Core::HID::NpadButton::StickLRight:
case Core::HID::NpadButton::StickRRight:
MoveButtonDirection(Direction::Right);
break;
case HIDButton::DDown:
case HIDButton::LStickDown:
case HIDButton::RStickDown:
case Core::HID::NpadButton::Down:
case Core::HID::NpadButton::StickLDown:
case Core::HID::NpadButton::StickRDown:
MoveButtonDirection(Direction::Down);
break;
default:
@ -1467,19 +1468,25 @@ void QtSoftwareKeyboardDialog::InputThread() {
while (input_thread_running) {
input_interpreter->PollInput();
HandleButtonPressedOnce<HIDButton::A, HIDButton::B, HIDButton::X, HIDButton::Y,
HIDButton::LStick, HIDButton::RStick, HIDButton::L, HIDButton::R,
HIDButton::Plus, HIDButton::DLeft, HIDButton::DUp,
HIDButton::DRight, HIDButton::DDown, HIDButton::LStickLeft,
HIDButton::LStickUp, HIDButton::LStickRight, HIDButton::LStickDown,
HIDButton::RStickLeft, HIDButton::RStickUp, HIDButton::RStickRight,
HIDButton::RStickDown>();
HandleButtonPressedOnce<
Core::HID::NpadButton::A, Core::HID::NpadButton::B, Core::HID::NpadButton::X,
Core::HID::NpadButton::Y, Core::HID::NpadButton::StickL, Core::HID::NpadButton::StickR,
Core::HID::NpadButton::L, Core::HID::NpadButton::R, Core::HID::NpadButton::Plus,
Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right,
Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft,
Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight,
Core::HID::NpadButton::StickLDown, Core::HID::NpadButton::StickRLeft,
Core::HID::NpadButton::StickRUp, Core::HID::NpadButton::StickRRight,
Core::HID::NpadButton::StickRDown>();
HandleButtonHold<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>();
HandleButtonHold<Core::HID::NpadButton::B, Core::HID::NpadButton::L,
Core::HID::NpadButton::R, Core::HID::NpadButton::Left,
Core::HID::NpadButton::Up, Core::HID::NpadButton::Right,
Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft,
Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight,
Core::HID::NpadButton::StickLDown, Core::HID::NpadButton::StickRLeft,
Core::HID::NpadButton::StickRUp, Core::HID::NpadButton::StickRRight,
Core::HID::NpadButton::StickRDown>();
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}

View file

@ -14,14 +14,16 @@
#include "core/frontend/applets/software_keyboard.h"
enum class HIDButton : u8;
class InputInterpreter;
namespace Core {
class System;
}
namespace Core::HID {
enum class NpadButton : u64;
}
namespace Ui {
class QtSoftwareKeyboardDialog;
}
@ -146,7 +148,7 @@ private:
*
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
*/
template <HIDButton... T>
template <Core::HID::NpadButton... T>
void HandleButtonPressedOnce();
/**
@ -154,7 +156,7 @@ private:
*
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
*/
template <HIDButton... T>
template <Core::HID::NpadButton... T>
void HandleButtonHold();
/**
@ -162,7 +164,7 @@ private:
*
* @param button The button press to process.
*/
void TranslateButtonPress(HIDButton button);
void TranslateButtonPress(Core::HID::NpadButton button);
/**
* Moves the focus of a button in a certain direction.

View file

@ -14,9 +14,10 @@
#endif
#include "common/fs/path_util.h"
#include "common/param_package.h"
#include "core/core.h"
#include "core/hid/input_interpreter.h"
#include "input_common/keyboard.h"
#include "input_common/drivers/keyboard.h"
#include "input_common/main.h"
#include "yuzu/applets/qt_web_browser.h"
#include "yuzu/applets/qt_web_browser_scripts.h"