Compare commits

...

5 Commits

2 changed files with 20 additions and 1 deletions

View File

@@ -102,6 +102,18 @@ QtNXWebEngineView::~QtNXWebEngineView() {
StopInputThread();
}
void QtNXWebEngineView::highlightFirstLink() {
QWebEngineScript highlight_element;
highlight_element.setName(QStringLiteral("highlight_element.js"));
highlight_element.setSourceCode(QString::fromStdString("document.getElementsByTagName(\"a\")[0].focus();"));
highlight_element.setWorldId(QWebEngineScript::MainWorld);
highlight_element.setInjectionPoint(QWebEngineScript::Deferred);
highlight_element.setRunsOnSubFrames(true);
default_profile->scripts()->insert(highlight_element);
}
void QtNXWebEngineView::LoadLocalWebPage(const std::string& main_url,
const std::string& additional_args) {
is_local = true;
@@ -112,6 +124,7 @@ void QtNXWebEngineView::LoadLocalWebPage(const std::string& main_url,
SetExitReason(Service::AM::Applets::WebExitReason::EndButtonPressed);
SetLastURL("http://localhost/");
StartInputThread();
highlightFirstLink();
load(QUrl(QUrl::fromLocalFile(QString::fromStdString(main_url)).toString() +
QString::fromStdString(additional_args)));
@@ -128,6 +141,8 @@ void QtNXWebEngineView::LoadExternalWebPage(const std::string& main_url,
StartInputThread();
load(QUrl(QString::fromStdString(main_url) + QString::fromStdString(additional_args)));
highlightFirstLink();
}
void QtNXWebEngineView::SetUserAgent(UserAgent user_agent) {
@@ -206,11 +221,12 @@ template <HIDButton... T>
void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
const auto f = [this](HIDButton button) {
if (input_interpreter->IsButtonPressedOnce(button)) {
int btn = (int)button; // button's getting changed somewhere so save the value
page()->runJavaScript(
QStringLiteral("yuzu_key_callbacks[%1] == null;").arg(static_cast<u8>(button)),
[&](const QVariant& variant) {
if (variant.toBool()) {
switch (button) {
switch ((HIDButton)btn) { // to use here
case HIDButton::A:
SendMultipleKeyPressEvents<Qt::Key_A, Qt::Key_Space, Qt::Key_Return>();
break;

View File

@@ -161,6 +161,9 @@ private:
/// Loads the extracted fonts using JavaScript.
void LoadExtractedFonts();
/// Focuses input on the first available link to permit controller input on linux.
void highlightFirstLink();
InputCommon::InputSubsystem* input_subsystem;
std::unique_ptr<UrlRequestInterceptor> url_interceptor;