web_applet: Replace HIDButton with NpadButton
This commit is contained in:
parent
b564f024f0
commit
cc651c7c99
|
@ -28,7 +28,8 @@ namespace {
|
||||||
|
|
||||||
constexpr std::size_t HANDHELD_INDEX = 8;
|
constexpr std::size_t HANDHELD_INDEX = 8;
|
||||||
|
|
||||||
void UpdateController(Core::HID::EmulatedController* controller, Core::HID::NpadType controller_type, bool connected) {
|
void UpdateController(Core::HID::EmulatedController* controller,
|
||||||
|
Core::HID::NpadType controller_type, bool connected) {
|
||||||
if (controller->IsConnected()) {
|
if (controller->IsConnected()) {
|
||||||
controller->Disconnect();
|
controller->Disconnect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
|
#include "core/hid/hid_types.h"
|
||||||
#include "core/hid/input_interpreter.h"
|
#include "core/hid/input_interpreter.h"
|
||||||
#include "input_common/drivers/keyboard.h"
|
#include "input_common/drivers/keyboard.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
|
@ -28,19 +29,19 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr int HIDButtonToKey(HIDButton button) {
|
constexpr int HIDButtonToKey(Core::HID::NpadButton button) {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case HIDButton::DLeft:
|
case Core::HID::NpadButton::Left:
|
||||||
case HIDButton::LStickLeft:
|
case Core::HID::NpadButton::StickLLeft:
|
||||||
return Qt::Key_Left;
|
return Qt::Key_Left;
|
||||||
case HIDButton::DUp:
|
case Core::HID::NpadButton::Up:
|
||||||
case HIDButton::LStickUp:
|
case Core::HID::NpadButton::StickLUp:
|
||||||
return Qt::Key_Up;
|
return Qt::Key_Up;
|
||||||
case HIDButton::DRight:
|
case Core::HID::NpadButton::Right:
|
||||||
case HIDButton::LStickRight:
|
case Core::HID::NpadButton::StickLRight:
|
||||||
return Qt::Key_Right;
|
return Qt::Key_Right;
|
||||||
case HIDButton::DDown:
|
case Core::HID::NpadButton::Down:
|
||||||
case HIDButton::LStickDown:
|
case Core::HID::NpadButton::StickLDown:
|
||||||
return Qt::Key_Down;
|
return Qt::Key_Down;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -209,25 +210,25 @@ void QtNXWebEngineView::keyReleaseEvent(QKeyEvent* event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <HIDButton... T>
|
template <Core::HID::NpadButton... T>
|
||||||
void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
|
void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
|
||||||
const auto f = [this](HIDButton button) {
|
const auto f = [this](Core::HID::NpadButton button) {
|
||||||
if (input_interpreter->IsButtonPressedOnce(button)) {
|
if (input_interpreter->IsButtonPressedOnce(button)) {
|
||||||
page()->runJavaScript(
|
page()->runJavaScript(
|
||||||
QStringLiteral("yuzu_key_callbacks[%1] == null;").arg(static_cast<u8>(button)),
|
QStringLiteral("yuzu_key_callbacks[%1] == null;").arg(static_cast<u8>(button)),
|
||||||
[this, button](const QVariant& variant) {
|
[this, button](const QVariant& variant) {
|
||||||
if (variant.toBool()) {
|
if (variant.toBool()) {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case HIDButton::A:
|
case Core::HID::NpadButton::A:
|
||||||
SendMultipleKeyPressEvents<Qt::Key_A, Qt::Key_Space, Qt::Key_Return>();
|
SendMultipleKeyPressEvents<Qt::Key_A, Qt::Key_Space, Qt::Key_Return>();
|
||||||
break;
|
break;
|
||||||
case HIDButton::B:
|
case Core::HID::NpadButton::B:
|
||||||
SendKeyPressEvent(Qt::Key_B);
|
SendKeyPressEvent(Qt::Key_B);
|
||||||
break;
|
break;
|
||||||
case HIDButton::X:
|
case Core::HID::NpadButton::X:
|
||||||
SendKeyPressEvent(Qt::Key_X);
|
SendKeyPressEvent(Qt::Key_X);
|
||||||
break;
|
break;
|
||||||
case HIDButton::Y:
|
case Core::HID::NpadButton::Y:
|
||||||
SendKeyPressEvent(Qt::Key_Y);
|
SendKeyPressEvent(Qt::Key_Y);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -245,9 +246,9 @@ void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
|
||||||
(f(T), ...);
|
(f(T), ...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <HIDButton... T>
|
template <Core::HID::NpadButton... T>
|
||||||
void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() {
|
void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() {
|
||||||
const auto f = [this](HIDButton button) {
|
const auto f = [this](Core::HID::NpadButton button) {
|
||||||
if (input_interpreter->IsButtonPressedOnce(button)) {
|
if (input_interpreter->IsButtonPressedOnce(button)) {
|
||||||
SendKeyPressEvent(HIDButtonToKey(button));
|
SendKeyPressEvent(HIDButtonToKey(button));
|
||||||
}
|
}
|
||||||
|
@ -256,9 +257,9 @@ void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() {
|
||||||
(f(T), ...);
|
(f(T), ...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <HIDButton... T>
|
template <Core::HID::NpadButton... T>
|
||||||
void QtNXWebEngineView::HandleWindowKeyButtonHold() {
|
void QtNXWebEngineView::HandleWindowKeyButtonHold() {
|
||||||
const auto f = [this](HIDButton button) {
|
const auto f = [this](Core::HID::NpadButton button) {
|
||||||
if (input_interpreter->IsButtonHeld(button)) {
|
if (input_interpreter->IsButtonHeld(button)) {
|
||||||
SendKeyPressEvent(HIDButtonToKey(button));
|
SendKeyPressEvent(HIDButtonToKey(button));
|
||||||
}
|
}
|
||||||
|
@ -309,17 +310,21 @@ void QtNXWebEngineView::InputThread() {
|
||||||
while (input_thread_running) {
|
while (input_thread_running) {
|
||||||
input_interpreter->PollInput();
|
input_interpreter->PollInput();
|
||||||
|
|
||||||
HandleWindowFooterButtonPressedOnce<HIDButton::A, HIDButton::B, HIDButton::X, HIDButton::Y,
|
HandleWindowFooterButtonPressedOnce<Core::HID::NpadButton::A, Core::HID::NpadButton::B,
|
||||||
HIDButton::L, HIDButton::R>();
|
Core::HID::NpadButton::X, Core::HID::NpadButton::Y,
|
||||||
|
Core::HID::NpadButton::L, Core::HID::NpadButton::R>();
|
||||||
|
|
||||||
HandleWindowKeyButtonPressedOnce<HIDButton::DLeft, HIDButton::DUp, HIDButton::DRight,
|
HandleWindowKeyButtonPressedOnce<
|
||||||
HIDButton::DDown, HIDButton::LStickLeft,
|
Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right,
|
||||||
HIDButton::LStickUp, HIDButton::LStickRight,
|
Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft,
|
||||||
HIDButton::LStickDown>();
|
Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight,
|
||||||
|
Core::HID::NpadButton::StickLDown>();
|
||||||
|
|
||||||
HandleWindowKeyButtonHold<HIDButton::DLeft, HIDButton::DUp, HIDButton::DRight,
|
HandleWindowKeyButtonHold<
|
||||||
HIDButton::DDown, HIDButton::LStickLeft, HIDButton::LStickUp,
|
Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right,
|
||||||
HIDButton::LStickRight, HIDButton::LStickDown>();
|
Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft,
|
||||||
|
Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight,
|
||||||
|
Core::HID::NpadButton::StickLDown>();
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
#include "core/frontend/applets/web_browser.h"
|
#include "core/frontend/applets/web_browser.h"
|
||||||
|
|
||||||
enum class HIDButton : u8;
|
|
||||||
|
|
||||||
class GMainWindow;
|
class GMainWindow;
|
||||||
class InputInterpreter;
|
class InputInterpreter;
|
||||||
class UrlRequestInterceptor;
|
class UrlRequestInterceptor;
|
||||||
|
@ -26,6 +24,10 @@ namespace Core {
|
||||||
class System;
|
class System;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Core::HID {
|
||||||
|
enum class NpadButton : u64;
|
||||||
|
}
|
||||||
|
|
||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
class InputSubsystem;
|
class InputSubsystem;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +116,7 @@ private:
|
||||||
*
|
*
|
||||||
* @tparam HIDButton The list of buttons contained in yuzu_key_callbacks
|
* @tparam HIDButton The list of buttons contained in yuzu_key_callbacks
|
||||||
*/
|
*/
|
||||||
template <HIDButton... T>
|
template <Core::HID::NpadButton... T>
|
||||||
void HandleWindowFooterButtonPressedOnce();
|
void HandleWindowFooterButtonPressedOnce();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,7 +125,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 HandleWindowKeyButtonPressedOnce();
|
void HandleWindowKeyButtonPressedOnce();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,7 +134,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 HandleWindowKeyButtonHold();
|
void HandleWindowKeyButtonHold();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in New Issue