web_browser: Add bounds checking to applet interface

This commit is contained in:
Zach Hilman 2018-12-28 18:20:29 -05:00
parent ef4c4e239d
commit cb930c4b5a
10 changed files with 160 additions and 146 deletions

View file

@ -203,6 +203,11 @@ struct System::Impl {
// Close app loader // Close app loader
app_loader.reset(); app_loader.reset();
// Clear all applets
profile_selector.reset();
software_keyboard.reset();
web_browser.reset();
LOG_DEBUG(Core, "Shutdown OK"); LOG_DEBUG(Core, "Shutdown OK");
} }

View file

@ -49,17 +49,20 @@ static_assert(sizeof(WebArgumentResult) == 0x1010, "WebArgumentResult has incorr
static std::vector<u8> GetArgumentDataForTagType(const std::vector<u8>& data, u16 type) { static std::vector<u8> GetArgumentDataForTagType(const std::vector<u8>& data, u16 type) {
WebBufferHeader header; WebBufferHeader header;
ASSERT(sizeof(WebBufferHeader) <= data.size());
std::memcpy(&header, data.data(), sizeof(WebBufferHeader)); std::memcpy(&header, data.data(), sizeof(WebBufferHeader));
u64 offset = sizeof(WebBufferHeader); u64 offset = sizeof(WebBufferHeader);
for (u16 i = 0; i < header.count; ++i) { for (u16 i = 0; i < header.count; ++i) {
WebArgumentHeader arg; WebArgumentHeader arg;
ASSERT(offset + sizeof(WebArgumentHeader) <= data.size());
std::memcpy(&arg, data.data() + offset, sizeof(WebArgumentHeader)); std::memcpy(&arg, data.data() + offset, sizeof(WebArgumentHeader));
offset += sizeof(WebArgumentHeader); offset += sizeof(WebArgumentHeader);
if (arg.type == type) { if (arg.type == type) {
std::vector<u8> out(arg.size); std::vector<u8> out(arg.size);
offset += arg.offset; offset += arg.offset;
ASSERT(offset + arg.size <= data.size());
std::memcpy(out.data(), data.data() + offset, out.size()); std::memcpy(out.data(), data.data() + offset, out.size());
return out; return out;
} }
@ -91,19 +94,17 @@ WebBrowser::WebBrowser() = default;
WebBrowser::~WebBrowser() = default; WebBrowser::~WebBrowser() = default;
void WebBrowser::Initialize() { void WebBrowser::Initialize() {
Applet::Initialize();
complete = false; complete = false;
temporary_dir.clear(); temporary_dir.clear();
filename.clear(); filename.clear();
status = RESULT_SUCCESS; status = RESULT_SUCCESS;
Applet::Initialize();
const auto web_arg_storage = broker.PopNormalDataToApplet(); const auto web_arg_storage = broker.PopNormalDataToApplet();
ASSERT(web_arg_storage != nullptr); ASSERT(web_arg_storage != nullptr);
const auto& web_arg = web_arg_storage->GetData(); const auto& web_arg = web_arg_storage->GetData();
LOG_CRITICAL(Service_AM, "{}", Common::HexVectorToString(web_arg));
const auto url_data = GetArgumentDataForTagType(web_arg, WEB_ARGUMENT_URL_TYPE); const auto url_data = GetArgumentDataForTagType(web_arg, WEB_ARGUMENT_URL_TYPE);
filename = Common::StringFromFixedZeroTerminatedBuffer( filename = Common::StringFromFixedZeroTerminatedBuffer(
reinterpret_cast<const char*>(url_data.data()), url_data.size()); reinterpret_cast<const char*>(url_data.data()), url_data.size());
@ -133,7 +134,7 @@ ResultCode WebBrowser::GetStatus() const {
} }
void WebBrowser::ExecuteInteractive() { void WebBrowser::ExecuteInteractive() {
UNIMPLEMENTED_MSG(Service_AM, "Unexpected interactive data recieved!"); UNIMPLEMENTED_MSG("Unexpected interactive data recieved!");
} }
void WebBrowser::Execute() { void WebBrowser::Execute() {
@ -147,8 +148,7 @@ void WebBrowser::Execute() {
const auto& frontend{Core::System::GetInstance().GetWebBrowser()}; const auto& frontend{Core::System::GetInstance().GetWebBrowser()};
frontend.OpenPage( frontend.OpenPage(filename, [this] { UnpackRomFS(); }, [this] { Finalize(); });
filename, [this] { UnpackRomFS(); }, [this] { Finalize(); });
} }
void WebBrowser::UnpackRomFS() { void WebBrowser::UnpackRomFS() {

View file

@ -638,10 +638,8 @@ void Controller_NPad::ClearAllControllers() {
}); });
} }
u32 Controller_NPad::GetPressState() { u32 Controller_NPad::GetAndResetPressState() {
const auto res = press_state; return std::exchange(press_state, 0);
press_state = 0;
return res;
} }
bool Controller_NPad::IsControllerSupported(NPadControllerType controller) const { bool Controller_NPad::IsControllerSupported(NPadControllerType controller) const {

View file

@ -126,7 +126,7 @@ public:
// Logical OR for all buttons presses on all controllers // Logical OR for all buttons presses on all controllers
// Specifically for cheat engine and other features. // Specifically for cheat engine and other features.
u32 GetPressState(); u32 GetAndResetPressState();
static std::size_t NPadIdToIndex(u32 npad_id); static std::size_t NPadIdToIndex(u32 npad_id);
static u32 IndexToNPad(std::size_t index); static u32 IndexToNPad(std::size_t index);

View file

@ -136,131 +136,135 @@ private:
}; };
std::shared_ptr<IAppletResource> Hid::GetAppletResource() { std::shared_ptr<IAppletResource> Hid::GetAppletResource() {
if (applet_resource == nullptr) {
applet_resource = std::make_shared<IAppletResource>();
}
return applet_resource; return applet_resource;
} }
Hid::Hid() : ServiceFramework("hid") { Hid::Hid() : ServiceFramework("hid") {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &Hid::CreateAppletResource, "CreateAppletResource"}, {0, &Hid::CreateAppletResource, "CreateAppletResource"},
{1, &Hid::ActivateDebugPad, "ActivateDebugPad"}, {1, &Hid::ActivateDebugPad, "ActivateDebugPad"},
{11, &Hid::ActivateTouchScreen, "ActivateTouchScreen"}, {11, &Hid::ActivateTouchScreen, "ActivateTouchScreen"},
{21, &Hid::ActivateMouse, "ActivateMouse"}, {21, &Hid::ActivateMouse, "ActivateMouse"},
{31, &Hid::ActivateKeyboard, "ActivateKeyboard"}, {31, &Hid::ActivateKeyboard, "ActivateKeyboard"},
{32, nullptr, "SendKeyboardLockKeyEvent"}, {32, nullptr, "SendKeyboardLockKeyEvent"},
{40, nullptr, "AcquireXpadIdEventHandle"}, {40, nullptr, "AcquireXpadIdEventHandle"},
{41, nullptr, "ReleaseXpadIdEventHandle"}, {41, nullptr, "ReleaseXpadIdEventHandle"},
{51, &Hid::ActivateXpad, "ActivateXpad"}, {51, &Hid::ActivateXpad, "ActivateXpad"},
{55, nullptr, "GetXpadIds"}, {55, nullptr, "GetXpadIds"},
{56, nullptr, "ActivateJoyXpad"}, {56, nullptr, "ActivateJoyXpad"},
{58, nullptr, "GetJoyXpadLifoHandle"}, {58, nullptr, "GetJoyXpadLifoHandle"},
{59, nullptr, "GetJoyXpadIds"}, {59, nullptr, "GetJoyXpadIds"},
{60, nullptr, "ActivateSixAxisSensor"}, {60, nullptr, "ActivateSixAxisSensor"},
{61, nullptr, "DeactivateSixAxisSensor"}, {61, nullptr, "DeactivateSixAxisSensor"},
{62, nullptr, "GetSixAxisSensorLifoHandle"}, {62, nullptr, "GetSixAxisSensorLifoHandle"},
{63, nullptr, "ActivateJoySixAxisSensor"}, {63, nullptr, "ActivateJoySixAxisSensor"},
{64, nullptr, "DeactivateJoySixAxisSensor"}, {64, nullptr, "DeactivateJoySixAxisSensor"},
{65, nullptr, "GetJoySixAxisSensorLifoHandle"}, {65, nullptr, "GetJoySixAxisSensorLifoHandle"},
{66, &Hid::StartSixAxisSensor, "StartSixAxisSensor"}, {66, &Hid::StartSixAxisSensor, "StartSixAxisSensor"},
{67, &Hid::StopSixAxisSensor, "StopSixAxisSensor"}, {67, &Hid::StopSixAxisSensor, "StopSixAxisSensor"},
{68, nullptr, "IsSixAxisSensorFusionEnabled"}, {68, nullptr, "IsSixAxisSensorFusionEnabled"},
{69, nullptr, "EnableSixAxisSensorFusion"}, {69, nullptr, "EnableSixAxisSensorFusion"},
{70, nullptr, "SetSixAxisSensorFusionParameters"}, {70, nullptr, "SetSixAxisSensorFusionParameters"},
{71, nullptr, "GetSixAxisSensorFusionParameters"}, {71, nullptr, "GetSixAxisSensorFusionParameters"},
{72, nullptr, "ResetSixAxisSensorFusionParameters"}, {72, nullptr, "ResetSixAxisSensorFusionParameters"},
{73, nullptr, "SetAccelerometerParameters"}, {73, nullptr, "SetAccelerometerParameters"},
{74, nullptr, "GetAccelerometerParameters"}, {74, nullptr, "GetAccelerometerParameters"},
{75, nullptr, "ResetAccelerometerParameters"}, {75, nullptr, "ResetAccelerometerParameters"},
{76, nullptr, "SetAccelerometerPlayMode"}, {76, nullptr, "SetAccelerometerPlayMode"},
{77, nullptr, "GetAccelerometerPlayMode"}, {77, nullptr, "GetAccelerometerPlayMode"},
{78, nullptr, "ResetAccelerometerPlayMode"}, {78, nullptr, "ResetAccelerometerPlayMode"},
{79, &Hid::SetGyroscopeZeroDriftMode, "SetGyroscopeZeroDriftMode"}, {79, &Hid::SetGyroscopeZeroDriftMode, "SetGyroscopeZeroDriftMode"},
{80, nullptr, "GetGyroscopeZeroDriftMode"}, {80, nullptr, "GetGyroscopeZeroDriftMode"},
{81, nullptr, "ResetGyroscopeZeroDriftMode"}, {81, nullptr, "ResetGyroscopeZeroDriftMode"},
{82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"}, {82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"},
{83, nullptr, "IsFirmwareUpdateAvailableForSixAxisSensor"}, {83, nullptr, "IsFirmwareUpdateAvailableForSixAxisSensor"},
{91, &Hid::ActivateGesture, "ActivateGesture"}, {91, &Hid::ActivateGesture, "ActivateGesture"},
{100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"}, {100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"},
{101, &Hid::GetSupportedNpadStyleSet, "GetSupportedNpadStyleSet"}, {101, &Hid::GetSupportedNpadStyleSet, "GetSupportedNpadStyleSet"},
{102, &Hid::SetSupportedNpadIdType, "SetSupportedNpadIdType"}, {102, &Hid::SetSupportedNpadIdType, "SetSupportedNpadIdType"},
{103, &Hid::ActivateNpad, "ActivateNpad"}, {103, &Hid::ActivateNpad, "ActivateNpad"},
{104, nullptr, "DeactivateNpad"}, {104, nullptr, "DeactivateNpad"},
{106, &Hid::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"}, {106, &Hid::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"},
{107, &Hid::DisconnectNpad, "DisconnectNpad"}, {107, &Hid::DisconnectNpad, "DisconnectNpad"},
{108, &Hid::GetPlayerLedPattern, "GetPlayerLedPattern"}, {108, &Hid::GetPlayerLedPattern, "GetPlayerLedPattern"},
{109, &Hid::ActivateNpadWithRevision, "ActivateNpadWithRevision"}, {109, &Hid::ActivateNpadWithRevision, "ActivateNpadWithRevision"},
{120, &Hid::SetNpadJoyHoldType, "SetNpadJoyHoldType"}, {120, &Hid::SetNpadJoyHoldType, "SetNpadJoyHoldType"},
{121, &Hid::GetNpadJoyHoldType, "GetNpadJoyHoldType"}, {121, &Hid::GetNpadJoyHoldType, "GetNpadJoyHoldType"},
{122, &Hid::SetNpadJoyAssignmentModeSingleByDefault, "SetNpadJoyAssignmentModeSingleByDefault"}, {122, &Hid::SetNpadJoyAssignmentModeSingleByDefault, "SetNpadJoyAssignmentModeSingleByDefault"},
{123, nullptr, "SetNpadJoyAssignmentModeSingleByDefault"}, {123, nullptr, "SetNpadJoyAssignmentModeSingleByDefault"},
{124, &Hid::SetNpadJoyAssignmentModeDual, "SetNpadJoyAssignmentModeDual"}, {124, &Hid::SetNpadJoyAssignmentModeDual, "SetNpadJoyAssignmentModeDual"},
{125, &Hid::MergeSingleJoyAsDualJoy, "MergeSingleJoyAsDualJoy"}, {125, &Hid::MergeSingleJoyAsDualJoy, "MergeSingleJoyAsDualJoy"},
{126, nullptr, "StartLrAssignmentMode"}, {126, nullptr, "StartLrAssignmentMode"},
{127, nullptr, "StopLrAssignmentMode"}, {127, nullptr, "StopLrAssignmentMode"},
{128, &Hid::SetNpadHandheldActivationMode, "SetNpadHandheldActivationMode"}, {128, &Hid::SetNpadHandheldActivationMode, "SetNpadHandheldActivationMode"},
{129, nullptr, "GetNpadHandheldActivationMode"}, {129, nullptr, "GetNpadHandheldActivationMode"},
{130, nullptr, "SwapNpadAssignment"}, {130, nullptr, "SwapNpadAssignment"},
{131, nullptr, "IsUnintendedHomeButtonInputProtectionEnabled"}, {131, nullptr, "IsUnintendedHomeButtonInputProtectionEnabled"},
{132, nullptr, "EnableUnintendedHomeButtonInputProtection"}, {132, nullptr, "EnableUnintendedHomeButtonInputProtection"},
{133, nullptr, "SetNpadJoyAssignmentModeSingleWithDestination"}, {133, nullptr, "SetNpadJoyAssignmentModeSingleWithDestination"},
{200, &Hid::GetVibrationDeviceInfo, "GetVibrationDeviceInfo"}, {200, &Hid::GetVibrationDeviceInfo, "GetVibrationDeviceInfo"},
{201, &Hid::SendVibrationValue, "SendVibrationValue"}, {201, &Hid::SendVibrationValue, "SendVibrationValue"},
{202, &Hid::GetActualVibrationValue, "GetActualVibrationValue"}, {202, &Hid::GetActualVibrationValue, "GetActualVibrationValue"},
{203, &Hid::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"}, {203, &Hid::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"},
{204, nullptr, "PermitVibration"}, {204, nullptr, "PermitVibration"},
{205, nullptr, "IsVibrationPermitted"}, {205, nullptr, "IsVibrationPermitted"},
{206, &Hid::SendVibrationValues, "SendVibrationValues"}, {206, &Hid::SendVibrationValues, "SendVibrationValues"},
{207, nullptr, "SendVibrationGcErmCommand"}, {207, nullptr, "SendVibrationGcErmCommand"},
{208, nullptr, "GetActualVibrationGcErmCommand"}, {208, nullptr, "GetActualVibrationGcErmCommand"},
{209, &Hid::BeginPermitVibrationSession, "BeginPermitVibrationSession"}, {209, &Hid::BeginPermitVibrationSession, "BeginPermitVibrationSession"},
{210, &Hid::EndPermitVibrationSession, "EndPermitVibrationSession"}, {210, &Hid::EndPermitVibrationSession, "EndPermitVibrationSession"},
{300, &Hid::ActivateConsoleSixAxisSensor, "ActivateConsoleSixAxisSensor"}, {300, &Hid::ActivateConsoleSixAxisSensor, "ActivateConsoleSixAxisSensor"},
{301, &Hid::StartConsoleSixAxisSensor, "StartConsoleSixAxisSensor"}, {301, &Hid::StartConsoleSixAxisSensor, "StartConsoleSixAxisSensor"},
{302, nullptr, "StopConsoleSixAxisSensor"}, {302, nullptr, "StopConsoleSixAxisSensor"},
{303, nullptr, "ActivateSevenSixAxisSensor"}, {303, nullptr, "ActivateSevenSixAxisSensor"},
{304, nullptr, "StartSevenSixAxisSensor"}, {304, nullptr, "StartSevenSixAxisSensor"},
{305, nullptr, "StopSevenSixAxisSensor"}, {305, nullptr, "StopSevenSixAxisSensor"},
{306, nullptr, "InitializeSevenSixAxisSensor"}, {306, nullptr, "InitializeSevenSixAxisSensor"},
{307, nullptr, "FinalizeSevenSixAxisSensor"}, {307, nullptr, "FinalizeSevenSixAxisSensor"},
{308, nullptr, "SetSevenSixAxisSensorFusionStrength"}, {308, nullptr, "SetSevenSixAxisSensorFusionStrength"},
{309, nullptr, "GetSevenSixAxisSensorFusionStrength"}, {309, nullptr, "GetSevenSixAxisSensorFusionStrength"},
{310, nullptr, "ResetSevenSixAxisSensorTimestamp"}, {310, nullptr, "ResetSevenSixAxisSensorTimestamp"},
{400, nullptr, "IsUsbFullKeyControllerEnabled"}, {400, nullptr, "IsUsbFullKeyControllerEnabled"},
{401, nullptr, "EnableUsbFullKeyController"}, {401, nullptr, "EnableUsbFullKeyController"},
{402, nullptr, "IsUsbFullKeyControllerConnected"}, {402, nullptr, "IsUsbFullKeyControllerConnected"},
{403, nullptr, "HasBattery"}, {403, nullptr, "HasBattery"},
{404, nullptr, "HasLeftRightBattery"}, {404, nullptr, "HasLeftRightBattery"},
{405, nullptr, "GetNpadInterfaceType"}, {405, nullptr, "GetNpadInterfaceType"},
{406, nullptr, "GetNpadLeftRightInterfaceType"}, {406, nullptr, "GetNpadLeftRightInterfaceType"},
{500, nullptr, "GetPalmaConnectionHandle"}, {500, nullptr, "GetPalmaConnectionHandle"},
{501, nullptr, "InitializePalma"}, {501, nullptr, "InitializePalma"},
{502, nullptr, "AcquirePalmaOperationCompleteEvent"}, {502, nullptr, "AcquirePalmaOperationCompleteEvent"},
{503, nullptr, "GetPalmaOperationInfo"}, {503, nullptr, "GetPalmaOperationInfo"},
{504, nullptr, "PlayPalmaActivity"}, {504, nullptr, "PlayPalmaActivity"},
{505, nullptr, "SetPalmaFrModeType"}, {505, nullptr, "SetPalmaFrModeType"},
{506, nullptr, "ReadPalmaStep"}, {506, nullptr, "ReadPalmaStep"},
{507, nullptr, "EnablePalmaStep"}, {507, nullptr, "EnablePalmaStep"},
{508, nullptr, "ResetPalmaStep"}, {508, nullptr, "ResetPalmaStep"},
{509, nullptr, "ReadPalmaApplicationSection"}, {509, nullptr, "ReadPalmaApplicationSection"},
{510, nullptr, "WritePalmaApplicationSection"}, {510, nullptr, "WritePalmaApplicationSection"},
{511, nullptr, "ReadPalmaUniqueCode"}, {511, nullptr, "ReadPalmaUniqueCode"},
{512, nullptr, "SetPalmaUniqueCodeInvalid"}, {512, nullptr, "SetPalmaUniqueCodeInvalid"},
{513, nullptr, "WritePalmaActivityEntry"}, {513, nullptr, "WritePalmaActivityEntry"},
{514, nullptr, "WritePalmaRgbLedPatternEntry"}, {514, nullptr, "WritePalmaRgbLedPatternEntry"},
{515, nullptr, "WritePalmaWaveEntry"}, {515, nullptr, "WritePalmaWaveEntry"},
{516, nullptr, "SetPalmaDataBaseIdentificationVersion"}, {516, nullptr, "SetPalmaDataBaseIdentificationVersion"},
{517, nullptr, "GetPalmaDataBaseIdentificationVersion"}, {517, nullptr, "GetPalmaDataBaseIdentificationVersion"},
{518, nullptr, "SuspendPalmaFeature"}, {518, nullptr, "SuspendPalmaFeature"},
{519, nullptr, "GetPalmaOperationResult"}, {519, nullptr, "GetPalmaOperationResult"},
{520, nullptr, "ReadPalmaPlayLog"}, {520, nullptr, "ReadPalmaPlayLog"},
{521, nullptr, "ResetPalmaPlayLog"}, {521, nullptr, "ResetPalmaPlayLog"},
{522, &Hid::SetIsPalmaAllConnectable, "SetIsPalmaAllConnectable"}, {522, &Hid::SetIsPalmaAllConnectable, "SetIsPalmaAllConnectable"},
{523, nullptr, "SetIsPalmaPairedConnectable"}, {523, nullptr, "SetIsPalmaPairedConnectable"},
{524, nullptr, "PairPalma"}, {524, nullptr, "PairPalma"},
{525, &Hid::SetPalmaBoostMode, "SetPalmaBoostMode"}, {525, &Hid::SetPalmaBoostMode, "SetPalmaBoostMode"},
{1000, nullptr, "SetNpadCommunicationMode"}, {1000, nullptr, "SetNpadCommunicationMode"},
{1001, nullptr, "GetNpadCommunicationMode"}, {1001, nullptr, "GetNpadCommunicationMode"},
}; };
// clang-format on // clang-format on
RegisterHandlers(functions); RegisterHandlers(functions);

View file

@ -44,7 +44,6 @@ public:
ResultStatus ReadIcon(std::vector<u8>& buffer) override; ResultStatus ReadIcon(std::vector<u8>& buffer) override;
ResultStatus ReadTitle(std::string& title) override; ResultStatus ReadTitle(std::string& title) override;
ResultStatus ReadControlData(FileSys::NACP& nacp) override; ResultStatus ReadControlData(FileSys::NACP& nacp) override;
ResultStatus ReadDeveloper(std::string& developer) override;
ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override; ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override;
private: private:

View file

@ -44,7 +44,6 @@ public:
ResultStatus ReadIcon(std::vector<u8>& buffer) override; ResultStatus ReadIcon(std::vector<u8>& buffer) override;
ResultStatus ReadTitle(std::string& title) override; ResultStatus ReadTitle(std::string& title) override;
ResultStatus ReadControlData(FileSys::NACP& control) override; ResultStatus ReadControlData(FileSys::NACP& control) override;
ResultStatus ReadDeveloper(std::string& developer) override;
ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override; ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override;
private: private:

View file

@ -10,15 +10,17 @@
#include "yuzu/applets/web_browser.h" #include "yuzu/applets/web_browser.h"
#include "yuzu/main.h" #include "yuzu/main.h"
#ifdef YUZU_USE_QT_WEB_ENGINE
constexpr char NX_SHIM_INJECT_SCRIPT[] = R"( constexpr char NX_SHIM_INJECT_SCRIPT[] = R"(
window.nx = {}; window.nx = {};
window.nx.playReport = {}; window.nx.playReport = {};
window.nx.playReport.setCounterSetIdentifier = function () { window.nx.playReport.setCounterSetIdentifier = function () {
console.log("nx.footer.setCounterSetIdentifier called - unimplemented"); console.log("nx.playReport.setCounterSetIdentifier called - unimplemented");
}; };
window.nx.playReport.incrementCounter = function () { window.nx.playReport.incrementCounter = function () {
console.log("nx.footer.incrementCounter called - unimplemented"); console.log("nx.playReport.incrementCounter called - unimplemented");
}; };
window.nx.footer = {}; window.nx.footer = {};
@ -56,6 +58,12 @@ constexpr char NX_SHIM_INJECT_SCRIPT[] = R"(
}; };
)"; )";
QString GetNXShimInjectionScript() {
return QString::fromStdString(NX_SHIM_INJECT_SCRIPT);
}
NXInputWebEngineView::NXInputWebEngineView(QWidget* parent) : QWebEngineView(parent) {}
void NXInputWebEngineView::keyPressEvent(QKeyEvent* event) { void NXInputWebEngineView::keyPressEvent(QKeyEvent* event) {
parent()->event(event); parent()->event(event);
} }
@ -64,11 +72,7 @@ void NXInputWebEngineView::keyReleaseEvent(QKeyEvent* event) {
parent()->event(event); parent()->event(event);
} }
QString GetNXShimInjectionScript() { #endif
return QString::fromStdString(NX_SHIM_INJECT_SCRIPT);
}
NXInputWebEngineView::NXInputWebEngineView(QWidget* parent) : QWebEngineView(parent) {}
QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { QtWebBrowser::QtWebBrowser(GMainWindow& main_window) {
connect(this, &QtWebBrowser::MainWindowOpenPage, &main_window, &GMainWindow::WebBrowserOpenPage, connect(this, &QtWebBrowser::MainWindowOpenPage, &main_window, &GMainWindow::WebBrowserOpenPage,

View file

@ -6,22 +6,30 @@
#include <functional> #include <functional>
#include <QObject> #include <QObject>
#ifdef YUZU_USE_QT_WEB_ENGINE
#include <QWebEngineView> #include <QWebEngineView>
#endif
#include "core/frontend/applets/web_browser.h" #include "core/frontend/applets/web_browser.h"
class GMainWindow; class GMainWindow;
#ifdef YUZU_USE_QT_WEB_ENGINE
QString GetNXShimInjectionScript(); QString GetNXShimInjectionScript();
class NXInputWebEngineView : public QWebEngineView { class NXInputWebEngineView : public QWebEngineView {
public: public:
NXInputWebEngineView(QWidget* parent = nullptr); explicit NXInputWebEngineView(QWidget* parent = nullptr);
protected: protected:
void keyPressEvent(QKeyEvent* event) override; void keyPressEvent(QKeyEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override; void keyReleaseEvent(QKeyEvent* event) override;
}; };
#endif
class QtWebBrowser final : public QObject, public Core::Frontend::WebBrowserApplet { class QtWebBrowser final : public QObject, public Core::Frontend::WebBrowserApplet {
Q_OBJECT Q_OBJECT

View file

@ -13,6 +13,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/service/acc/profile_manager.h"
#include "ui_main.h" #include "ui_main.h"
#include "yuzu/compatibility_list.h" #include "yuzu/compatibility_list.h"
#include "yuzu/hotkeys.h" #include "yuzu/hotkeys.h"
@ -39,10 +40,6 @@ class RegisteredCacheUnion;
class VfsFilesystem; class VfsFilesystem;
} // namespace FileSys } // namespace FileSys
namespace Service::Account {
struct UUID;
} // namespace Service::Account
namespace Tegra { namespace Tegra {
class DebugContext; class DebugContext;
} }