mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-23 14:20:41 +02:00
qt_web_browser: Fix button inputs with QtWebEngine
Button inputs were broken as button was assumed to be the bit position of NpadButton prior to the input rewrite. Since this was changed to use NpadButton directly, we should count the number of trailing zeros to determine the bit position.
This commit is contained in:
parent
770611fdf3
commit
cbef6b1fca
@ -2,6 +2,8 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#ifdef YUZU_USE_QT_WEB_ENGINE
|
#ifdef YUZU_USE_QT_WEB_ENGINE
|
||||||
|
#include <bit>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
@ -211,8 +213,10 @@ template <Core::HID::NpadButton... T>
|
|||||||
void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
|
void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
|
||||||
const auto f = [this](Core::HID::NpadButton button) {
|
const auto f = [this](Core::HID::NpadButton button) {
|
||||||
if (input_interpreter->IsButtonPressedOnce(button)) {
|
if (input_interpreter->IsButtonPressedOnce(button)) {
|
||||||
|
const auto button_index = std::countr_zero(static_cast<u64>(button));
|
||||||
|
|
||||||
page()->runJavaScript(
|
page()->runJavaScript(
|
||||||
QStringLiteral("yuzu_key_callbacks[%1] == null;").arg(static_cast<u8>(button)),
|
QStringLiteral("yuzu_key_callbacks[%1] == null;").arg(button_index),
|
||||||
[this, button](const QVariant& variant) {
|
[this, button](const QVariant& variant) {
|
||||||
if (variant.toBool()) {
|
if (variant.toBool()) {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
@ -236,7 +240,7 @@ void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
|
|||||||
|
|
||||||
page()->runJavaScript(
|
page()->runJavaScript(
|
||||||
QStringLiteral("if (yuzu_key_callbacks[%1] != null) { yuzu_key_callbacks[%1](); }")
|
QStringLiteral("if (yuzu_key_callbacks[%1] != null) { yuzu_key_callbacks[%1](); }")
|
||||||
.arg(static_cast<u8>(button)));
|
.arg(button_index));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user