mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
Qt_applets: Use new input
This commit is contained in:
parent
6e2c84042d
commit
8fff6d6c67
@ -6,8 +6,11 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
#include "common/param_package.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "core/core.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/lock.h"
|
||||||
#include "core/hle/service/hid/controllers/npad.h"
|
#include "core/hle/service/hid/controllers/npad.h"
|
||||||
#include "core/hle/service/hid/hid.h"
|
#include "core/hle/service/hid/hid.h"
|
||||||
@ -48,7 +51,8 @@ void UpdateController(Settings::ControllerType controller_type, std::size_t npad
|
|||||||
->GetAppletResource()
|
->GetAppletResource()
|
||||||
->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad);
|
->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.
|
// Returns true if the given controller type is compatible with the given parameters.
|
||||||
|
@ -31,6 +31,10 @@ namespace Ui {
|
|||||||
class QtControllerSelectorDialog;
|
class QtControllerSelectorDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
class QtControllerSelectorDialog final : public QDialog {
|
class QtControllerSelectorDialog final : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -102,6 +106,7 @@ private:
|
|||||||
Core::Frontend::ControllerParameters parameters;
|
Core::Frontend::ControllerParameters parameters;
|
||||||
|
|
||||||
InputCommon::InputSubsystem* input_subsystem;
|
InputCommon::InputSubsystem* input_subsystem;
|
||||||
|
Core::System& system;
|
||||||
|
|
||||||
std::unique_ptr<InputProfiles> input_profiles;
|
std::unique_ptr<InputProfiles> input_profiles;
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "core/core.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 "ui_qt_software_keyboard.h"
|
||||||
#include "yuzu/applets/qt_software_keyboard.h"
|
#include "yuzu/applets/qt_software_keyboard.h"
|
||||||
#include "yuzu/main.h"
|
#include "yuzu/main.h"
|
||||||
@ -484,7 +485,7 @@ void QtSoftwareKeyboardDialog::open() {
|
|||||||
void QtSoftwareKeyboardDialog::reject() {
|
void QtSoftwareKeyboardDialog::reject() {
|
||||||
// Pressing the ESC key in a dialog calls QDialog::reject().
|
// Pressing the ESC key in a dialog calls QDialog::reject().
|
||||||
// We will override this behavior to the "Cancel" action on the software keyboard.
|
// 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) {
|
void QtSoftwareKeyboardDialog::keyPressEvent(QKeyEvent* event) {
|
||||||
@ -722,7 +723,7 @@ void QtSoftwareKeyboardDialog::SetTextDrawType() {
|
|||||||
|
|
||||||
connect(
|
connect(
|
||||||
ui->line_edit_osk, &QLineEdit::returnPressed, this,
|
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(
|
ui->line_edit_osk->setPlaceholderText(
|
||||||
QString::fromStdU16String(initialize_parameters.guide_text));
|
QString::fromStdU16String(initialize_parameters.guide_text));
|
||||||
@ -1208,9 +1209,9 @@ void QtSoftwareKeyboardDialog::SetupMouseHover() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <HIDButton... T>
|
template <Core::HID::NpadButton... T>
|
||||||
void QtSoftwareKeyboardDialog::HandleButtonPressedOnce() {
|
void QtSoftwareKeyboardDialog::HandleButtonPressedOnce() {
|
||||||
const auto f = [this](HIDButton button) {
|
const auto f = [this](Core::HID::NpadButton button) {
|
||||||
if (input_interpreter->IsButtonPressedOnce(button)) {
|
if (input_interpreter->IsButtonPressedOnce(button)) {
|
||||||
TranslateButtonPress(button);
|
TranslateButtonPress(button);
|
||||||
}
|
}
|
||||||
@ -1219,9 +1220,9 @@ void QtSoftwareKeyboardDialog::HandleButtonPressedOnce() {
|
|||||||
(f(T), ...);
|
(f(T), ...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <HIDButton... T>
|
template <Core::HID::NpadButton... T>
|
||||||
void QtSoftwareKeyboardDialog::HandleButtonHold() {
|
void QtSoftwareKeyboardDialog::HandleButtonHold() {
|
||||||
const auto f = [this](HIDButton button) {
|
const auto f = [this](Core::HID::NpadButton button) {
|
||||||
if (input_interpreter->IsButtonHeld(button)) {
|
if (input_interpreter->IsButtonHeld(button)) {
|
||||||
TranslateButtonPress(button);
|
TranslateButtonPress(button);
|
||||||
}
|
}
|
||||||
@ -1230,9 +1231,9 @@ void QtSoftwareKeyboardDialog::HandleButtonHold() {
|
|||||||
(f(T), ...);
|
(f(T), ...);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
|
void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button) {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case HIDButton::A:
|
case Core::HID::NpadButton::A:
|
||||||
switch (bottom_osk_index) {
|
switch (bottom_osk_index) {
|
||||||
case BottomOSKIndex::LowerCase:
|
case BottomOSKIndex::LowerCase:
|
||||||
case BottomOSKIndex::UpperCase:
|
case BottomOSKIndex::UpperCase:
|
||||||
@ -1245,7 +1246,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HIDButton::B:
|
case Core::HID::NpadButton::B:
|
||||||
switch (bottom_osk_index) {
|
switch (bottom_osk_index) {
|
||||||
case BottomOSKIndex::LowerCase:
|
case BottomOSKIndex::LowerCase:
|
||||||
ui->button_backspace->click();
|
ui->button_backspace->click();
|
||||||
@ -1260,7 +1261,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HIDButton::X:
|
case Core::HID::NpadButton::X:
|
||||||
if (is_inline) {
|
if (is_inline) {
|
||||||
emit SubmitInlineText(SwkbdReplyType::DecidedCancel, current_text, cursor_position);
|
emit SubmitInlineText(SwkbdReplyType::DecidedCancel, current_text, cursor_position);
|
||||||
} else {
|
} else {
|
||||||
@ -1271,7 +1272,7 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
|
|||||||
emit SubmitNormalText(SwkbdResult::Cancel, std::move(text));
|
emit SubmitNormalText(SwkbdResult::Cancel, std::move(text));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HIDButton::Y:
|
case Core::HID::NpadButton::Y:
|
||||||
switch (bottom_osk_index) {
|
switch (bottom_osk_index) {
|
||||||
case BottomOSKIndex::LowerCase:
|
case BottomOSKIndex::LowerCase:
|
||||||
ui->button_space->click();
|
ui->button_space->click();
|
||||||
@ -1284,8 +1285,8 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HIDButton::LStick:
|
case Core::HID::NpadButton::StickL:
|
||||||
case HIDButton::RStick:
|
case Core::HID::NpadButton::StickR:
|
||||||
switch (bottom_osk_index) {
|
switch (bottom_osk_index) {
|
||||||
case BottomOSKIndex::LowerCase:
|
case BottomOSKIndex::LowerCase:
|
||||||
ui->button_shift->click();
|
ui->button_shift->click();
|
||||||
@ -1298,13 +1299,13 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HIDButton::L:
|
case Core::HID::NpadButton::L:
|
||||||
MoveTextCursorDirection(Direction::Left);
|
MoveTextCursorDirection(Direction::Left);
|
||||||
break;
|
break;
|
||||||
case HIDButton::R:
|
case Core::HID::NpadButton::R:
|
||||||
MoveTextCursorDirection(Direction::Right);
|
MoveTextCursorDirection(Direction::Right);
|
||||||
break;
|
break;
|
||||||
case HIDButton::Plus:
|
case Core::HID::NpadButton::Plus:
|
||||||
switch (bottom_osk_index) {
|
switch (bottom_osk_index) {
|
||||||
case BottomOSKIndex::LowerCase:
|
case BottomOSKIndex::LowerCase:
|
||||||
ui->button_ok->click();
|
ui->button_ok->click();
|
||||||
@ -1319,24 +1320,24 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(HIDButton button) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HIDButton::DLeft:
|
case Core::HID::NpadButton::Left:
|
||||||
case HIDButton::LStickLeft:
|
case Core::HID::NpadButton::StickLLeft:
|
||||||
case HIDButton::RStickLeft:
|
case Core::HID::NpadButton::StickRLeft:
|
||||||
MoveButtonDirection(Direction::Left);
|
MoveButtonDirection(Direction::Left);
|
||||||
break;
|
break;
|
||||||
case HIDButton::DUp:
|
case Core::HID::NpadButton::Up:
|
||||||
case HIDButton::LStickUp:
|
case Core::HID::NpadButton::StickLUp:
|
||||||
case HIDButton::RStickUp:
|
case Core::HID::NpadButton::StickRUp:
|
||||||
MoveButtonDirection(Direction::Up);
|
MoveButtonDirection(Direction::Up);
|
||||||
break;
|
break;
|
||||||
case HIDButton::DRight:
|
case Core::HID::NpadButton::Right:
|
||||||
case HIDButton::LStickRight:
|
case Core::HID::NpadButton::StickLRight:
|
||||||
case HIDButton::RStickRight:
|
case Core::HID::NpadButton::StickRRight:
|
||||||
MoveButtonDirection(Direction::Right);
|
MoveButtonDirection(Direction::Right);
|
||||||
break;
|
break;
|
||||||
case HIDButton::DDown:
|
case Core::HID::NpadButton::Down:
|
||||||
case HIDButton::LStickDown:
|
case Core::HID::NpadButton::StickLDown:
|
||||||
case HIDButton::RStickDown:
|
case Core::HID::NpadButton::StickRDown:
|
||||||
MoveButtonDirection(Direction::Down);
|
MoveButtonDirection(Direction::Down);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1467,19 +1468,25 @@ void QtSoftwareKeyboardDialog::InputThread() {
|
|||||||
while (input_thread_running) {
|
while (input_thread_running) {
|
||||||
input_interpreter->PollInput();
|
input_interpreter->PollInput();
|
||||||
|
|
||||||
HandleButtonPressedOnce<HIDButton::A, HIDButton::B, HIDButton::X, HIDButton::Y,
|
HandleButtonPressedOnce<
|
||||||
HIDButton::LStick, HIDButton::RStick, HIDButton::L, HIDButton::R,
|
Core::HID::NpadButton::A, Core::HID::NpadButton::B, Core::HID::NpadButton::X,
|
||||||
HIDButton::Plus, HIDButton::DLeft, HIDButton::DUp,
|
Core::HID::NpadButton::Y, Core::HID::NpadButton::StickL, Core::HID::NpadButton::StickR,
|
||||||
HIDButton::DRight, HIDButton::DDown, HIDButton::LStickLeft,
|
Core::HID::NpadButton::L, Core::HID::NpadButton::R, Core::HID::NpadButton::Plus,
|
||||||
HIDButton::LStickUp, HIDButton::LStickRight, HIDButton::LStickDown,
|
Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right,
|
||||||
HIDButton::RStickLeft, HIDButton::RStickUp, HIDButton::RStickRight,
|
Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft,
|
||||||
HIDButton::RStickDown>();
|
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,
|
HandleButtonHold<Core::HID::NpadButton::B, Core::HID::NpadButton::L,
|
||||||
HIDButton::DRight, HIDButton::DDown, HIDButton::LStickLeft,
|
Core::HID::NpadButton::R, Core::HID::NpadButton::Left,
|
||||||
HIDButton::LStickUp, HIDButton::LStickRight, HIDButton::LStickDown,
|
Core::HID::NpadButton::Up, Core::HID::NpadButton::Right,
|
||||||
HIDButton::RStickLeft, HIDButton::RStickUp, HIDButton::RStickRight,
|
Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft,
|
||||||
HIDButton::RStickDown>();
|
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));
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,16 @@
|
|||||||
|
|
||||||
#include "core/frontend/applets/software_keyboard.h"
|
#include "core/frontend/applets/software_keyboard.h"
|
||||||
|
|
||||||
enum class HIDButton : u8;
|
|
||||||
|
|
||||||
class InputInterpreter;
|
class InputInterpreter;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Core::HID {
|
||||||
|
enum class NpadButton : u64;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class QtSoftwareKeyboardDialog;
|
class QtSoftwareKeyboardDialog;
|
||||||
}
|
}
|
||||||
@ -146,7 +148,7 @@ private:
|
|||||||
*
|
*
|
||||||
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
|
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
|
||||||
*/
|
*/
|
||||||
template <HIDButton... T>
|
template <Core::HID::NpadButton... T>
|
||||||
void HandleButtonPressedOnce();
|
void HandleButtonPressedOnce();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,7 +156,7 @@ private:
|
|||||||
*
|
*
|
||||||
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
|
* @tparam HIDButton The list of buttons that can be converted into keyboard input.
|
||||||
*/
|
*/
|
||||||
template <HIDButton... T>
|
template <Core::HID::NpadButton... T>
|
||||||
void HandleButtonHold();
|
void HandleButtonHold();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,7 +164,7 @@ private:
|
|||||||
*
|
*
|
||||||
* @param button The button press to process.
|
* @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.
|
* Moves the focus of a button in a certain direction.
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
|
#include "common/param_package.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hid/input_interpreter.h"
|
#include "core/hid/input_interpreter.h"
|
||||||
#include "input_common/keyboard.h"
|
#include "input_common/drivers/keyboard.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
#include "yuzu/applets/qt_web_browser.h"
|
#include "yuzu/applets/qt_web_browser.h"
|
||||||
#include "yuzu/applets/qt_web_browser_scripts.h"
|
#include "yuzu/applets/qt_web_browser_scripts.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user