diff options
| author | 2021-01-10 22:09:56 -0700 | |
|---|---|---|
| committer | 2021-01-10 22:09:56 -0700 | |
| commit | 7a3c884e39fccfbb498b855080bffabc9ce2e7f1 (patch) | |
| tree | 5056f9406dec188439cb0deb87603498243a9412 /src/core/frontend | |
| parent | More forgetting... duh (diff) | |
| parent | Merge pull request #5229 from Morph1984/fullscreen-opt (diff) | |
| download | yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.gz yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.xz yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.zip | |
Merge remote-tracking branch 'upstream/master' into int-flags
Diffstat (limited to 'src/core/frontend')
| -rw-r--r-- | src/core/frontend/applets/controller.cpp | 18 | ||||
| -rw-r--r-- | src/core/frontend/applets/controller.h | 12 | ||||
| -rw-r--r-- | src/core/frontend/applets/error.cpp | 7 | ||||
| -rw-r--r-- | src/core/frontend/applets/general_frontend.cpp | 68 | ||||
| -rw-r--r-- | src/core/frontend/applets/general_frontend.h | 51 | ||||
| -rw-r--r-- | src/core/frontend/applets/web_browser.cpp | 24 | ||||
| -rw-r--r-- | src/core/frontend/applets/web_browser.h | 20 | ||||
| -rw-r--r-- | src/core/frontend/emu_window.cpp | 10 | ||||
| -rw-r--r-- | src/core/frontend/emu_window.h | 4 | ||||
| -rw-r--r-- | src/core/frontend/framebuffer_layout.cpp | 8 | ||||
| -rw-r--r-- | src/core/frontend/input.h | 23 | ||||
| -rw-r--r-- | src/core/frontend/input_interpreter.cpp | 45 | ||||
| -rw-r--r-- | src/core/frontend/input_interpreter.h | 120 |
13 files changed, 252 insertions, 158 deletions
diff --git a/src/core/frontend/applets/controller.cpp b/src/core/frontend/applets/controller.cpp index 4505da758..03bbedf8b 100644 --- a/src/core/frontend/applets/controller.cpp +++ b/src/core/frontend/applets/controller.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | ||
| 8 | #include "core/frontend/applets/controller.h" | 7 | #include "core/frontend/applets/controller.h" |
| 9 | #include "core/hle/service/hid/controllers/npad.h" | 8 | #include "core/hle/service/hid/controllers/npad.h" |
| 10 | #include "core/hle/service/hid/hid.h" | 9 | #include "core/hle/service/hid/hid.h" |
| @@ -14,32 +13,33 @@ namespace Core::Frontend { | |||
| 14 | 13 | ||
| 15 | ControllerApplet::~ControllerApplet() = default; | 14 | ControllerApplet::~ControllerApplet() = default; |
| 16 | 15 | ||
| 16 | DefaultControllerApplet::DefaultControllerApplet(Service::SM::ServiceManager& service_manager_) | ||
| 17 | : service_manager{service_manager_} {} | ||
| 18 | |||
| 17 | DefaultControllerApplet::~DefaultControllerApplet() = default; | 19 | DefaultControllerApplet::~DefaultControllerApplet() = default; |
| 18 | 20 | ||
| 19 | void DefaultControllerApplet::ReconfigureControllers(std::function<void()> callback, | 21 | void DefaultControllerApplet::ReconfigureControllers(std::function<void()> callback, |
| 20 | ControllerParameters parameters) const { | 22 | const ControllerParameters& parameters) const { |
| 21 | LOG_INFO(Service_HID, "called, deducing the best configuration based on the given parameters!"); | 23 | LOG_INFO(Service_HID, "called, deducing the best configuration based on the given parameters!"); |
| 22 | 24 | ||
| 23 | auto& npad = | 25 | auto& npad = |
| 24 | Core::System::GetInstance() | 26 | service_manager.GetService<Service::HID::Hid>("hid") |
| 25 | .ServiceManager() | ||
| 26 | .GetService<Service::HID::Hid>("hid") | ||
| 27 | ->GetAppletResource() | 27 | ->GetAppletResource() |
| 28 | ->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad); | 28 | ->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad); |
| 29 | 29 | ||
| 30 | auto& players = Settings::values.players; | 30 | auto& players = Settings::values.players.GetValue(); |
| 31 | 31 | ||
| 32 | const std::size_t min_supported_players = | 32 | const std::size_t min_supported_players = |
| 33 | parameters.enable_single_mode ? 1 : parameters.min_players; | 33 | parameters.enable_single_mode ? 1 : parameters.min_players; |
| 34 | 34 | ||
| 35 | // Disconnect Handheld first. | 35 | // Disconnect Handheld first. |
| 36 | npad.DisconnectNPadAtIndex(8); | 36 | npad.DisconnectNpadAtIndex(8); |
| 37 | 37 | ||
| 38 | // Deduce the best configuration based on the input parameters. | 38 | // Deduce the best configuration based on the input parameters. |
| 39 | for (std::size_t index = 0; index < players.size() - 2; ++index) { | 39 | for (std::size_t index = 0; index < players.size() - 2; ++index) { |
| 40 | // First, disconnect all controllers regardless of the value of keep_controllers_connected. | 40 | // First, disconnect all controllers regardless of the value of keep_controllers_connected. |
| 41 | // This makes it easy to connect the desired controllers. | 41 | // This makes it easy to connect the desired controllers. |
| 42 | npad.DisconnectNPadAtIndex(index); | 42 | npad.DisconnectNpadAtIndex(index); |
| 43 | 43 | ||
| 44 | // Only connect the minimum number of required players. | 44 | // Only connect the minimum number of required players. |
| 45 | if (index >= min_supported_players) { | 45 | if (index >= min_supported_players) { |
| @@ -66,7 +66,7 @@ void DefaultControllerApplet::ReconfigureControllers(std::function<void()> callb | |||
| 66 | npad.MapSettingsTypeToNPad(Settings::ControllerType::RightJoycon), index); | 66 | npad.MapSettingsTypeToNPad(Settings::ControllerType::RightJoycon), index); |
| 67 | } | 67 | } |
| 68 | } else if (index == 0 && parameters.enable_single_mode && parameters.allow_handheld && | 68 | } else if (index == 0 && parameters.enable_single_mode && parameters.allow_handheld && |
| 69 | !Settings::values.use_docked_mode) { | 69 | !Settings::values.use_docked_mode.GetValue()) { |
| 70 | // We should *never* reach here under any normal circumstances. | 70 | // We should *never* reach here under any normal circumstances. |
| 71 | npad.AddNewControllerAt(npad.MapSettingsTypeToNPad(Settings::ControllerType::Handheld), | 71 | npad.AddNewControllerAt(npad.MapSettingsTypeToNPad(Settings::ControllerType::Handheld), |
| 72 | index); | 72 | index); |
diff --git a/src/core/frontend/applets/controller.h b/src/core/frontend/applets/controller.h index a227f15cd..dff71d8d9 100644 --- a/src/core/frontend/applets/controller.h +++ b/src/core/frontend/applets/controller.h | |||
| @@ -8,6 +8,10 @@ | |||
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | 10 | ||
| 11 | namespace Service::SM { | ||
| 12 | class ServiceManager; | ||
| 13 | } | ||
| 14 | |||
| 11 | namespace Core::Frontend { | 15 | namespace Core::Frontend { |
| 12 | 16 | ||
| 13 | using BorderColor = std::array<u8, 4>; | 17 | using BorderColor = std::array<u8, 4>; |
| @@ -34,15 +38,19 @@ public: | |||
| 34 | virtual ~ControllerApplet(); | 38 | virtual ~ControllerApplet(); |
| 35 | 39 | ||
| 36 | virtual void ReconfigureControllers(std::function<void()> callback, | 40 | virtual void ReconfigureControllers(std::function<void()> callback, |
| 37 | ControllerParameters parameters) const = 0; | 41 | const ControllerParameters& parameters) const = 0; |
| 38 | }; | 42 | }; |
| 39 | 43 | ||
| 40 | class DefaultControllerApplet final : public ControllerApplet { | 44 | class DefaultControllerApplet final : public ControllerApplet { |
| 41 | public: | 45 | public: |
| 46 | explicit DefaultControllerApplet(Service::SM::ServiceManager& service_manager_); | ||
| 42 | ~DefaultControllerApplet() override; | 47 | ~DefaultControllerApplet() override; |
| 43 | 48 | ||
| 44 | void ReconfigureControllers(std::function<void()> callback, | 49 | void ReconfigureControllers(std::function<void()> callback, |
| 45 | ControllerParameters parameters) const override; | 50 | const ControllerParameters& parameters) const override; |
| 51 | |||
| 52 | private: | ||
| 53 | Service::SM::ServiceManager& service_manager; | ||
| 46 | }; | 54 | }; |
| 47 | 55 | ||
| 48 | } // namespace Core::Frontend | 56 | } // namespace Core::Frontend |
diff --git a/src/core/frontend/applets/error.cpp b/src/core/frontend/applets/error.cpp index 4002a9211..dceb20ff8 100644 --- a/src/core/frontend/applets/error.cpp +++ b/src/core/frontend/applets/error.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/logging/log.h" | ||
| 5 | #include "core/frontend/applets/error.h" | 6 | #include "core/frontend/applets/error.h" |
| 6 | 7 | ||
| 7 | namespace Core::Frontend { | 8 | namespace Core::Frontend { |
| @@ -10,7 +11,7 @@ ErrorApplet::~ErrorApplet() = default; | |||
| 10 | 11 | ||
| 11 | void DefaultErrorApplet::ShowError(ResultCode error, std::function<void()> finished) const { | 12 | void DefaultErrorApplet::ShowError(ResultCode error, std::function<void()> finished) const { |
| 12 | LOG_CRITICAL(Service_Fatal, "Application requested error display: {:04}-{:04} (raw={:08X})", | 13 | LOG_CRITICAL(Service_Fatal, "Application requested error display: {:04}-{:04} (raw={:08X})", |
| 13 | static_cast<u32>(error.module.Value()), error.description.Value(), error.raw); | 14 | error.module.Value(), error.description.Value(), error.raw); |
| 14 | } | 15 | } |
| 15 | 16 | ||
| 16 | void DefaultErrorApplet::ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time, | 17 | void DefaultErrorApplet::ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time, |
| @@ -18,7 +19,7 @@ void DefaultErrorApplet::ShowErrorWithTimestamp(ResultCode error, std::chrono::s | |||
| 18 | LOG_CRITICAL( | 19 | LOG_CRITICAL( |
| 19 | Service_Fatal, | 20 | Service_Fatal, |
| 20 | "Application requested error display: {:04X}-{:04X} (raw={:08X}) with timestamp={:016X}", | 21 | "Application requested error display: {:04X}-{:04X} (raw={:08X}) with timestamp={:016X}", |
| 21 | static_cast<u32>(error.module.Value()), error.description.Value(), error.raw, time.count()); | 22 | error.module.Value(), error.description.Value(), error.raw, time.count()); |
| 22 | } | 23 | } |
| 23 | 24 | ||
| 24 | void DefaultErrorApplet::ShowCustomErrorText(ResultCode error, std::string main_text, | 25 | void DefaultErrorApplet::ShowCustomErrorText(ResultCode error, std::string main_text, |
| @@ -26,7 +27,7 @@ void DefaultErrorApplet::ShowCustomErrorText(ResultCode error, std::string main_ | |||
| 26 | std::function<void()> finished) const { | 27 | std::function<void()> finished) const { |
| 27 | LOG_CRITICAL(Service_Fatal, | 28 | LOG_CRITICAL(Service_Fatal, |
| 28 | "Application requested custom error with error_code={:04X}-{:04X} (raw={:08X})", | 29 | "Application requested custom error with error_code={:04X}-{:04X} (raw={:08X})", |
| 29 | static_cast<u32>(error.module.Value()), error.description.Value(), error.raw); | 30 | error.module.Value(), error.description.Value(), error.raw); |
| 30 | LOG_CRITICAL(Service_Fatal, " Main Text: {}", main_text); | 31 | LOG_CRITICAL(Service_Fatal, " Main Text: {}", main_text); |
| 31 | LOG_CRITICAL(Service_Fatal, " Detail Text: {}", detail_text); | 32 | LOG_CRITICAL(Service_Fatal, " Detail Text: {}", detail_text); |
| 32 | } | 33 | } |
diff --git a/src/core/frontend/applets/general_frontend.cpp b/src/core/frontend/applets/general_frontend.cpp index c30b36de7..7483ffb76 100644 --- a/src/core/frontend/applets/general_frontend.cpp +++ b/src/core/frontend/applets/general_frontend.cpp | |||
| @@ -53,72 +53,4 @@ void DefaultPhotoViewerApplet::ShowAllPhotos(std::function<void()> finished) con | |||
| 53 | finished(); | 53 | finished(); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | ECommerceApplet::~ECommerceApplet() = default; | ||
| 57 | |||
| 58 | DefaultECommerceApplet::~DefaultECommerceApplet() = default; | ||
| 59 | |||
| 60 | void DefaultECommerceApplet::ShowApplicationInformation( | ||
| 61 | std::function<void()> finished, u64 title_id, std::optional<u128> user_id, | ||
| 62 | std::optional<bool> full_display, std::optional<std::string> extra_parameter) { | ||
| 63 | const auto value = user_id.value_or(u128{}); | ||
| 64 | LOG_INFO(Service_AM, | ||
| 65 | "Application requested frontend show application information for EShop, " | ||
| 66 | "title_id={:016X}, user_id={:016X}{:016X}, full_display={}, extra_parameter={}", | ||
| 67 | title_id, value[1], value[0], | ||
| 68 | full_display.has_value() ? fmt::format("{}", *full_display) : "null", | ||
| 69 | extra_parameter.value_or("null")); | ||
| 70 | finished(); | ||
| 71 | } | ||
| 72 | |||
| 73 | void DefaultECommerceApplet::ShowAddOnContentList(std::function<void()> finished, u64 title_id, | ||
| 74 | std::optional<u128> user_id, | ||
| 75 | std::optional<bool> full_display) { | ||
| 76 | const auto value = user_id.value_or(u128{}); | ||
| 77 | LOG_INFO(Service_AM, | ||
| 78 | "Application requested frontend show add on content list for EShop, " | ||
| 79 | "title_id={:016X}, user_id={:016X}{:016X}, full_display={}", | ||
| 80 | title_id, value[1], value[0], | ||
| 81 | full_display.has_value() ? fmt::format("{}", *full_display) : "null"); | ||
| 82 | finished(); | ||
| 83 | } | ||
| 84 | |||
| 85 | void DefaultECommerceApplet::ShowSubscriptionList(std::function<void()> finished, u64 title_id, | ||
| 86 | std::optional<u128> user_id) { | ||
| 87 | const auto value = user_id.value_or(u128{}); | ||
| 88 | LOG_INFO(Service_AM, | ||
| 89 | "Application requested frontend show subscription list for EShop, title_id={:016X}, " | ||
| 90 | "user_id={:016X}{:016X}", | ||
| 91 | title_id, value[1], value[0]); | ||
| 92 | finished(); | ||
| 93 | } | ||
| 94 | |||
| 95 | void DefaultECommerceApplet::ShowConsumableItemList(std::function<void()> finished, u64 title_id, | ||
| 96 | std::optional<u128> user_id) { | ||
| 97 | const auto value = user_id.value_or(u128{}); | ||
| 98 | LOG_INFO( | ||
| 99 | Service_AM, | ||
| 100 | "Application requested frontend show consumable item list for EShop, title_id={:016X}, " | ||
| 101 | "user_id={:016X}{:016X}", | ||
| 102 | title_id, value[1], value[0]); | ||
| 103 | finished(); | ||
| 104 | } | ||
| 105 | |||
| 106 | void DefaultECommerceApplet::ShowShopHome(std::function<void()> finished, u128 user_id, | ||
| 107 | bool full_display) { | ||
| 108 | LOG_INFO(Service_AM, | ||
| 109 | "Application requested frontend show home menu for EShop, user_id={:016X}{:016X}, " | ||
| 110 | "full_display={}", | ||
| 111 | user_id[1], user_id[0], full_display); | ||
| 112 | finished(); | ||
| 113 | } | ||
| 114 | |||
| 115 | void DefaultECommerceApplet::ShowSettings(std::function<void()> finished, u128 user_id, | ||
| 116 | bool full_display) { | ||
| 117 | LOG_INFO(Service_AM, | ||
| 118 | "Application requested frontend show settings menu for EShop, user_id={:016X}{:016X}, " | ||
| 119 | "full_display={}", | ||
| 120 | user_id[1], user_id[0], full_display); | ||
| 121 | finished(); | ||
| 122 | } | ||
| 123 | |||
| 124 | } // namespace Core::Frontend | 56 | } // namespace Core::Frontend |
diff --git a/src/core/frontend/applets/general_frontend.h b/src/core/frontend/applets/general_frontend.h index 4b63f828e..b713b14ee 100644 --- a/src/core/frontend/applets/general_frontend.h +++ b/src/core/frontend/applets/general_frontend.h | |||
| @@ -58,55 +58,4 @@ public: | |||
| 58 | void ShowAllPhotos(std::function<void()> finished) const override; | 58 | void ShowAllPhotos(std::function<void()> finished) const override; |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | class ECommerceApplet { | ||
| 62 | public: | ||
| 63 | virtual ~ECommerceApplet(); | ||
| 64 | |||
| 65 | // Shows a page with application icons, description, name, and price. | ||
| 66 | virtual void ShowApplicationInformation(std::function<void()> finished, u64 title_id, | ||
| 67 | std::optional<u128> user_id = {}, | ||
| 68 | std::optional<bool> full_display = {}, | ||
| 69 | std::optional<std::string> extra_parameter = {}) = 0; | ||
| 70 | |||
| 71 | // Shows a page with all of the add on content available for a game, with name, description, and | ||
| 72 | // price. | ||
| 73 | virtual void ShowAddOnContentList(std::function<void()> finished, u64 title_id, | ||
| 74 | std::optional<u128> user_id = {}, | ||
| 75 | std::optional<bool> full_display = {}) = 0; | ||
| 76 | |||
| 77 | // Shows a page with all of the subscriptions (recurring payments) for a game, with name, | ||
| 78 | // description, price, and renewal period. | ||
| 79 | virtual void ShowSubscriptionList(std::function<void()> finished, u64 title_id, | ||
| 80 | std::optional<u128> user_id = {}) = 0; | ||
| 81 | |||
| 82 | // Shows a page with a list of any additional game related purchasable items (DLC, | ||
| 83 | // subscriptions, etc) for a particular game, with name, description, type, and price. | ||
| 84 | virtual void ShowConsumableItemList(std::function<void()> finished, u64 title_id, | ||
| 85 | std::optional<u128> user_id = {}) = 0; | ||
| 86 | |||
| 87 | // Shows the home page of the shop. | ||
| 88 | virtual void ShowShopHome(std::function<void()> finished, u128 user_id, bool full_display) = 0; | ||
| 89 | |||
| 90 | // Shows the user settings page of the shop. | ||
| 91 | virtual void ShowSettings(std::function<void()> finished, u128 user_id, bool full_display) = 0; | ||
| 92 | }; | ||
| 93 | |||
| 94 | class DefaultECommerceApplet : public ECommerceApplet { | ||
| 95 | public: | ||
| 96 | ~DefaultECommerceApplet() override; | ||
| 97 | |||
| 98 | void ShowApplicationInformation(std::function<void()> finished, u64 title_id, | ||
| 99 | std::optional<u128> user_id, std::optional<bool> full_display, | ||
| 100 | std::optional<std::string> extra_parameter) override; | ||
| 101 | void ShowAddOnContentList(std::function<void()> finished, u64 title_id, | ||
| 102 | std::optional<u128> user_id, | ||
| 103 | std::optional<bool> full_display) override; | ||
| 104 | void ShowSubscriptionList(std::function<void()> finished, u64 title_id, | ||
| 105 | std::optional<u128> user_id) override; | ||
| 106 | void ShowConsumableItemList(std::function<void()> finished, u64 title_id, | ||
| 107 | std::optional<u128> user_id) override; | ||
| 108 | void ShowShopHome(std::function<void()> finished, u128 user_id, bool full_display) override; | ||
| 109 | void ShowSettings(std::function<void()> finished, u128 user_id, bool full_display) override; | ||
| 110 | }; | ||
| 111 | |||
| 112 | } // namespace Core::Frontend | 61 | } // namespace Core::Frontend |
diff --git a/src/core/frontend/applets/web_browser.cpp b/src/core/frontend/applets/web_browser.cpp index 528295ffc..50db6a654 100644 --- a/src/core/frontend/applets/web_browser.cpp +++ b/src/core/frontend/applets/web_browser.cpp | |||
| @@ -11,14 +11,22 @@ WebBrowserApplet::~WebBrowserApplet() = default; | |||
| 11 | 11 | ||
| 12 | DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; | 12 | DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; |
| 13 | 13 | ||
| 14 | void DefaultWebBrowserApplet::OpenPageLocal(std::string_view filename, | 14 | void DefaultWebBrowserApplet::OpenLocalWebPage( |
| 15 | std::function<void()> unpack_romfs_callback, | 15 | std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 16 | std::function<void()> finished_callback) { | 16 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const { |
| 17 | LOG_INFO(Service_AM, | 17 | LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open local web page at {}", |
| 18 | "(STUBBED) called - No suitable web browser implementation found to open website page " | 18 | local_url); |
| 19 | "at '{}'!", | 19 | |
| 20 | filename); | 20 | callback(Service::AM::Applets::WebExitReason::WindowClosed, "http://localhost/"); |
| 21 | finished_callback(); | 21 | } |
| 22 | |||
| 23 | void DefaultWebBrowserApplet::OpenExternalWebPage( | ||
| 24 | std::string_view external_url, | ||
| 25 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const { | ||
| 26 | LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open external web page at {}", | ||
| 27 | external_url); | ||
| 28 | |||
| 29 | callback(Service::AM::Applets::WebExitReason::WindowClosed, "http://localhost/"); | ||
| 22 | } | 30 | } |
| 23 | 31 | ||
| 24 | } // namespace Core::Frontend | 32 | } // namespace Core::Frontend |
diff --git a/src/core/frontend/applets/web_browser.h b/src/core/frontend/applets/web_browser.h index 110e33bc4..1c5ef19a9 100644 --- a/src/core/frontend/applets/web_browser.h +++ b/src/core/frontend/applets/web_browser.h | |||
| @@ -7,22 +7,34 @@ | |||
| 7 | #include <functional> | 7 | #include <functional> |
| 8 | #include <string_view> | 8 | #include <string_view> |
| 9 | 9 | ||
| 10 | #include "core/hle/service/am/applets/web_types.h" | ||
| 11 | |||
| 10 | namespace Core::Frontend { | 12 | namespace Core::Frontend { |
| 11 | 13 | ||
| 12 | class WebBrowserApplet { | 14 | class WebBrowserApplet { |
| 13 | public: | 15 | public: |
| 14 | virtual ~WebBrowserApplet(); | 16 | virtual ~WebBrowserApplet(); |
| 15 | 17 | ||
| 16 | virtual void OpenPageLocal(std::string_view url, std::function<void()> unpack_romfs_callback, | 18 | virtual void OpenLocalWebPage( |
| 17 | std::function<void()> finished_callback) = 0; | 19 | std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 20 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0; | ||
| 21 | |||
| 22 | virtual void OpenExternalWebPage( | ||
| 23 | std::string_view external_url, | ||
| 24 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0; | ||
| 18 | }; | 25 | }; |
| 19 | 26 | ||
| 20 | class DefaultWebBrowserApplet final : public WebBrowserApplet { | 27 | class DefaultWebBrowserApplet final : public WebBrowserApplet { |
| 21 | public: | 28 | public: |
| 22 | ~DefaultWebBrowserApplet() override; | 29 | ~DefaultWebBrowserApplet() override; |
| 23 | 30 | ||
| 24 | void OpenPageLocal(std::string_view url, std::function<void()> unpack_romfs_callback, | 31 | void OpenLocalWebPage(std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 25 | std::function<void()> finished_callback) override; | 32 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> |
| 33 | callback) const override; | ||
| 34 | |||
| 35 | void OpenExternalWebPage(std::string_view external_url, | ||
| 36 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> | ||
| 37 | callback) const override; | ||
| 26 | }; | 38 | }; |
| 27 | 39 | ||
| 28 | } // namespace Core::Frontend | 40 | } // namespace Core::Frontend |
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index 9a081fbd4..8c1193894 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp | |||
| @@ -84,10 +84,12 @@ void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) { | |||
| 84 | return; | 84 | return; |
| 85 | 85 | ||
| 86 | std::lock_guard guard{touch_state->mutex}; | 86 | std::lock_guard guard{touch_state->mutex}; |
| 87 | touch_state->touch_x = static_cast<float>(framebuffer_x - framebuffer_layout.screen.left) / | 87 | touch_state->touch_x = |
| 88 | (framebuffer_layout.screen.right - framebuffer_layout.screen.left); | 88 | static_cast<float>(framebuffer_x - framebuffer_layout.screen.left) / |
| 89 | touch_state->touch_y = static_cast<float>(framebuffer_y - framebuffer_layout.screen.top) / | 89 | static_cast<float>(framebuffer_layout.screen.right - framebuffer_layout.screen.left); |
| 90 | (framebuffer_layout.screen.bottom - framebuffer_layout.screen.top); | 90 | touch_state->touch_y = |
| 91 | static_cast<float>(framebuffer_y - framebuffer_layout.screen.top) / | ||
| 92 | static_cast<float>(framebuffer_layout.screen.bottom - framebuffer_layout.screen.top); | ||
| 91 | 93 | ||
| 92 | touch_state->touch_pressed = true; | 94 | touch_state->touch_pressed = true; |
| 93 | } | 95 | } |
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index 3e8780243..276d2b906 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h | |||
| @@ -102,8 +102,8 @@ public: | |||
| 102 | float render_surface_scale = 1.0f; | 102 | float render_surface_scale = 1.0f; |
| 103 | }; | 103 | }; |
| 104 | 104 | ||
| 105 | /// Polls window events | 105 | /// Called from GPU thread when a frame is displayed. |
| 106 | virtual void PollEvents() = 0; | 106 | virtual void OnFrameDisplayed() {} |
| 107 | 107 | ||
| 108 | /** | 108 | /** |
| 109 | * Returns a GraphicsContext that the frontend provides to be used for rendering. | 109 | * Returns a GraphicsContext that the frontend provides to be used for rendering. |
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index c1fbc235b..b9a270a55 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp | |||
| @@ -14,8 +14,8 @@ namespace Layout { | |||
| 14 | template <class T> | 14 | template <class T> |
| 15 | static Common::Rectangle<T> MaxRectangle(Common::Rectangle<T> window_area, | 15 | static Common::Rectangle<T> MaxRectangle(Common::Rectangle<T> window_area, |
| 16 | float screen_aspect_ratio) { | 16 | float screen_aspect_ratio) { |
| 17 | float scale = std::min(static_cast<float>(window_area.GetWidth()), | 17 | const float scale = std::min(static_cast<float>(window_area.GetWidth()), |
| 18 | window_area.GetHeight() / screen_aspect_ratio); | 18 | static_cast<float>(window_area.GetHeight()) / screen_aspect_ratio); |
| 19 | return Common::Rectangle<T>{0, 0, static_cast<T>(std::round(scale)), | 19 | return Common::Rectangle<T>{0, 0, static_cast<T>(std::round(scale)), |
| 20 | static_cast<T>(std::round(scale * screen_aspect_ratio))}; | 20 | static_cast<T>(std::round(scale * screen_aspect_ratio))}; |
| 21 | } | 21 | } |
| @@ -27,7 +27,7 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) { | |||
| 27 | // so just calculate them both even if the other isn't showing. | 27 | // so just calculate them both even if the other isn't showing. |
| 28 | FramebufferLayout res{width, height, false, {}}; | 28 | FramebufferLayout res{width, height, false, {}}; |
| 29 | 29 | ||
| 30 | const float window_aspect_ratio = static_cast<float>(height) / width; | 30 | const float window_aspect_ratio = static_cast<float>(height) / static_cast<float>(width); |
| 31 | const float emulation_aspect_ratio = EmulationAspectRatio( | 31 | const float emulation_aspect_ratio = EmulationAspectRatio( |
| 32 | static_cast<AspectRatio>(Settings::values.aspect_ratio.GetValue()), window_aspect_ratio); | 32 | static_cast<AspectRatio>(Settings::values.aspect_ratio.GetValue()), window_aspect_ratio); |
| 33 | 33 | ||
| @@ -47,7 +47,7 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) { | |||
| 47 | FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) { | 47 | FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) { |
| 48 | u32 width, height; | 48 | u32 width, height; |
| 49 | 49 | ||
| 50 | if (Settings::values.use_docked_mode) { | 50 | if (Settings::values.use_docked_mode.GetValue()) { |
| 51 | width = ScreenDocked::Width * res_scale; | 51 | width = ScreenDocked::Width * res_scale; |
| 52 | height = ScreenDocked::Height * res_scale; | 52 | height = ScreenDocked::Height * res_scale; |
| 53 | } else { | 53 | } else { |
diff --git a/src/core/frontend/input.h b/src/core/frontend/input.h index 9da0d2829..de51a754e 100644 --- a/src/core/frontend/input.h +++ b/src/core/frontend/input.h | |||
| @@ -30,7 +30,12 @@ public: | |||
| 30 | virtual StatusType GetStatus() const { | 30 | virtual StatusType GetStatus() const { |
| 31 | return {}; | 31 | return {}; |
| 32 | } | 32 | } |
| 33 | virtual bool GetAnalogDirectionStatus(AnalogDirection direction) const { | 33 | virtual bool GetAnalogDirectionStatus([[maybe_unused]] AnalogDirection direction) const { |
| 34 | return {}; | ||
| 35 | } | ||
| 36 | virtual bool SetRumblePlay([[maybe_unused]] f32 amp_low, [[maybe_unused]] f32 freq_low, | ||
| 37 | [[maybe_unused]] f32 amp_high, | ||
| 38 | [[maybe_unused]] f32 freq_high) const { | ||
| 34 | return {}; | 39 | return {}; |
| 35 | } | 40 | } |
| 36 | }; | 41 | }; |
| @@ -119,6 +124,13 @@ using ButtonDevice = InputDevice<bool>; | |||
| 119 | using AnalogDevice = InputDevice<std::tuple<float, float>>; | 124 | using AnalogDevice = InputDevice<std::tuple<float, float>>; |
| 120 | 125 | ||
| 121 | /** | 126 | /** |
| 127 | * A vibration device is an input device that returns an unsigned byte as status. | ||
| 128 | * It represents whether the vibration device supports vibration or not. | ||
| 129 | * If the status returns 1, it supports vibration. Otherwise, it does not support vibration. | ||
| 130 | */ | ||
| 131 | using VibrationDevice = InputDevice<u8>; | ||
| 132 | |||
| 133 | /** | ||
| 122 | * A motion status is an object that returns a tuple of accelerometer state vector, | 134 | * A motion status is an object that returns a tuple of accelerometer state vector, |
| 123 | * gyroscope state vector, rotation state vector and orientation state matrix. | 135 | * gyroscope state vector, rotation state vector and orientation state matrix. |
| 124 | * | 136 | * |
| @@ -151,10 +163,15 @@ using MotionStatus = std::tuple<Common::Vec3<float>, Common::Vec3<float>, Common | |||
| 151 | using MotionDevice = InputDevice<MotionStatus>; | 163 | using MotionDevice = InputDevice<MotionStatus>; |
| 152 | 164 | ||
| 153 | /** | 165 | /** |
| 154 | * A touch device is an input device that returns a tuple of two floats and a bool. The floats are | 166 | * A touch status is an object that returns a tuple of two floats and a bool. The floats are |
| 155 | * x and y coordinates in the range 0.0 - 1.0, and the bool indicates whether it is pressed. | 167 | * x and y coordinates in the range 0.0 - 1.0, and the bool indicates whether it is pressed. |
| 156 | */ | 168 | */ |
| 157 | using TouchDevice = InputDevice<std::tuple<float, float, bool>>; | 169 | using TouchStatus = std::tuple<float, float, bool>; |
| 170 | |||
| 171 | /** | ||
| 172 | * A touch device is an input device that returns a touch status object | ||
| 173 | */ | ||
| 174 | using TouchDevice = InputDevice<TouchStatus>; | ||
| 158 | 175 | ||
| 159 | /** | 176 | /** |
| 160 | * A mouse device is an input device that returns a tuple of two floats and four ints. | 177 | * A mouse device is an input device that returns a tuple of two floats and four ints. |
diff --git a/src/core/frontend/input_interpreter.cpp b/src/core/frontend/input_interpreter.cpp new file mode 100644 index 000000000..66ae506cd --- /dev/null +++ b/src/core/frontend/input_interpreter.cpp | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | // Copyright 2020 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/core.h" | ||
| 6 | #include "core/frontend/input_interpreter.h" | ||
| 7 | #include "core/hle/service/hid/controllers/npad.h" | ||
| 8 | #include "core/hle/service/hid/hid.h" | ||
| 9 | #include "core/hle/service/sm/sm.h" | ||
| 10 | |||
| 11 | InputInterpreter::InputInterpreter(Core::System& system) | ||
| 12 | : npad{system.ServiceManager() | ||
| 13 | .GetService<Service::HID::Hid>("hid") | ||
| 14 | ->GetAppletResource() | ||
| 15 | ->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad)} {} | ||
| 16 | |||
| 17 | InputInterpreter::~InputInterpreter() = default; | ||
| 18 | |||
| 19 | void InputInterpreter::PollInput() { | ||
| 20 | const u32 button_state = npad.GetAndResetPressState(); | ||
| 21 | |||
| 22 | previous_index = current_index; | ||
| 23 | current_index = (current_index + 1) % button_states.size(); | ||
| 24 | |||
| 25 | button_states[current_index] = button_state; | ||
| 26 | } | ||
| 27 | |||
| 28 | bool InputInterpreter::IsButtonPressedOnce(HIDButton button) const { | ||
| 29 | const bool current_press = | ||
| 30 | (button_states[current_index] & (1U << static_cast<u8>(button))) != 0; | ||
| 31 | const bool previous_press = | ||
| 32 | (button_states[previous_index] & (1U << static_cast<u8>(button))) != 0; | ||
| 33 | |||
| 34 | return current_press && !previous_press; | ||
| 35 | } | ||
| 36 | |||
| 37 | bool InputInterpreter::IsButtonHeld(HIDButton button) const { | ||
| 38 | u32 held_buttons{button_states[0]}; | ||
| 39 | |||
| 40 | for (std::size_t i = 1; i < button_states.size(); ++i) { | ||
| 41 | held_buttons &= button_states[i]; | ||
| 42 | } | ||
| 43 | |||
| 44 | return (held_buttons & (1U << static_cast<u8>(button))) != 0; | ||
| 45 | } | ||
diff --git a/src/core/frontend/input_interpreter.h b/src/core/frontend/input_interpreter.h new file mode 100644 index 000000000..fea9aebe6 --- /dev/null +++ b/src/core/frontend/input_interpreter.h | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | // Copyright 2020 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | |||
| 9 | #include "common/common_types.h" | ||
| 10 | |||
| 11 | namespace Core { | ||
| 12 | class System; | ||
| 13 | } | ||
| 14 | |||
| 15 | namespace Service::HID { | ||
| 16 | class Controller_NPad; | ||
| 17 | } | ||
| 18 | |||
| 19 | enum class HIDButton : u8 { | ||
| 20 | A, | ||
| 21 | B, | ||
| 22 | X, | ||
| 23 | Y, | ||
| 24 | LStick, | ||
| 25 | RStick, | ||
| 26 | L, | ||
| 27 | R, | ||
| 28 | ZL, | ||
| 29 | ZR, | ||
| 30 | Plus, | ||
| 31 | Minus, | ||
| 32 | |||
| 33 | DLeft, | ||
| 34 | DUp, | ||
| 35 | DRight, | ||
| 36 | DDown, | ||
| 37 | |||
| 38 | LStickLeft, | ||
| 39 | LStickUp, | ||
| 40 | LStickRight, | ||
| 41 | LStickDown, | ||
| 42 | |||
| 43 | RStickLeft, | ||
| 44 | RStickUp, | ||
| 45 | RStickRight, | ||
| 46 | RStickDown, | ||
| 47 | |||
| 48 | LeftSL, | ||
| 49 | LeftSR, | ||
| 50 | |||
| 51 | RightSL, | ||
| 52 | RightSR, | ||
| 53 | }; | ||
| 54 | |||
| 55 | /** | ||
| 56 | * The InputInterpreter class interfaces with HID to retrieve button press states. | ||
| 57 | * Input is intended to be polled every 50ms so that a button is considered to be | ||
| 58 | * held down after 400ms has elapsed since the initial button press and subsequent | ||
| 59 | * repeated presses occur every 50ms. | ||
| 60 | */ | ||
| 61 | class InputInterpreter { | ||
| 62 | public: | ||
| 63 | explicit InputInterpreter(Core::System& system); | ||
| 64 | virtual ~InputInterpreter(); | ||
| 65 | |||
| 66 | /// Gets a button state from HID and inserts it into the array of button states. | ||
| 67 | void PollInput(); | ||
| 68 | |||
| 69 | /** | ||
| 70 | * The specified button is considered to be pressed once | ||
| 71 | * if it is currently pressed and not pressed previously. | ||
| 72 | * | ||
| 73 | * @param button The button to check. | ||
| 74 | * | ||
| 75 | * @returns True when the button is pressed once. | ||
| 76 | */ | ||
| 77 | [[nodiscard]] bool IsButtonPressedOnce(HIDButton button) const; | ||
| 78 | |||
| 79 | /** | ||
| 80 | * Checks whether any of the buttons in the parameter list is pressed once. | ||
| 81 | * | ||
| 82 | * @tparam HIDButton The buttons to check. | ||
| 83 | * | ||
| 84 | * @returns True when at least one of the buttons is pressed once. | ||
| 85 | */ | ||
| 86 | template <HIDButton... T> | ||
| 87 | [[nodiscard]] bool IsAnyButtonPressedOnce() { | ||
| 88 | return (IsButtonPressedOnce(T) || ...); | ||
| 89 | } | ||
| 90 | |||
| 91 | /** | ||
| 92 | * The specified button is considered to be held down if it is pressed in all 9 button states. | ||
| 93 | * | ||
| 94 | * @param button The button to check. | ||
| 95 | * | ||
| 96 | * @returns True when the button is held down. | ||
| 97 | */ | ||
| 98 | [[nodiscard]] bool IsButtonHeld(HIDButton button) const; | ||
| 99 | |||
| 100 | /** | ||
| 101 | * Checks whether any of the buttons in the parameter list is held down. | ||
| 102 | * | ||
| 103 | * @tparam HIDButton The buttons to check. | ||
| 104 | * | ||
| 105 | * @returns True when at least one of the buttons is held down. | ||
| 106 | */ | ||
| 107 | template <HIDButton... T> | ||
| 108 | [[nodiscard]] bool IsAnyButtonHeld() { | ||
| 109 | return (IsButtonHeld(T) || ...); | ||
| 110 | } | ||
| 111 | |||
| 112 | private: | ||
| 113 | Service::HID::Controller_NPad& npad; | ||
| 114 | |||
| 115 | /// Stores 9 consecutive button states polled from HID. | ||
| 116 | std::array<u32, 9> button_states{}; | ||
| 117 | |||
| 118 | std::size_t previous_index{}; | ||
| 119 | std::size_t current_index{}; | ||
| 120 | }; | ||