diff options
| author | 2018-11-20 08:24:11 -0800 | |
|---|---|---|
| committer | 2018-11-20 08:24:11 -0800 | |
| commit | b6d2c64f4dcb01f1ffc99f9a057910ec65c6a401 (patch) | |
| tree | b75fde22327ac851821d58078614e62cc1c29916 /src/core/frontend | |
| parent | Merge pull request #1739 from lioncash/lm (diff) | |
| parent | software_keyboard: Fix erroneous extra PushNormalData (diff) | |
| download | yuzu-b6d2c64f4dcb01f1ffc99f9a057910ec65c6a401.tar.gz yuzu-b6d2c64f4dcb01f1ffc99f9a057910ec65c6a401.tar.xz yuzu-b6d2c64f4dcb01f1ffc99f9a057910ec65c6a401.zip | |
Merge pull request #1667 from DarkLordZach/swkbd
am: Implement HLE software keyboard applet
Diffstat (limited to 'src/core/frontend')
| -rw-r--r-- | src/core/frontend/applets/software_keyboard.cpp | 29 | ||||
| -rw-r--r-- | src/core/frontend/applets/software_keyboard.h | 54 |
2 files changed, 83 insertions, 0 deletions
diff --git a/src/core/frontend/applets/software_keyboard.cpp b/src/core/frontend/applets/software_keyboard.cpp new file mode 100644 index 000000000..856ed33da --- /dev/null +++ b/src/core/frontend/applets/software_keyboard.cpp | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/logging/backend.h" | ||
| 6 | #include "common/string_util.h" | ||
| 7 | #include "core/frontend/applets/software_keyboard.h" | ||
| 8 | |||
| 9 | namespace Core::Frontend { | ||
| 10 | SoftwareKeyboardApplet::~SoftwareKeyboardApplet() = default; | ||
| 11 | |||
| 12 | void DefaultSoftwareKeyboardApplet::RequestText( | ||
| 13 | std::function<void(std::optional<std::u16string>)> out, | ||
| 14 | SoftwareKeyboardParameters parameters) const { | ||
| 15 | if (parameters.initial_text.empty()) | ||
| 16 | out(u"yuzu"); | ||
| 17 | |||
| 18 | out(parameters.initial_text); | ||
| 19 | } | ||
| 20 | |||
| 21 | void DefaultSoftwareKeyboardApplet::SendTextCheckDialog( | ||
| 22 | std::u16string error_message, std::function<void()> finished_check) const { | ||
| 23 | LOG_WARNING(Service_AM, | ||
| 24 | "(STUBBED) called - Default fallback software keyboard does not support text " | ||
| 25 | "check! (error_message={})", | ||
| 26 | Common::UTF16ToUTF8(error_message)); | ||
| 27 | finished_check(); | ||
| 28 | } | ||
| 29 | } // namespace Core::Frontend | ||
diff --git a/src/core/frontend/applets/software_keyboard.h b/src/core/frontend/applets/software_keyboard.h new file mode 100644 index 000000000..f9b202664 --- /dev/null +++ b/src/core/frontend/applets/software_keyboard.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <functional> | ||
| 8 | #include <optional> | ||
| 9 | #include <string> | ||
| 10 | #include "common/bit_field.h" | ||
| 11 | #include "common/common_types.h" | ||
| 12 | |||
| 13 | namespace Core::Frontend { | ||
| 14 | struct SoftwareKeyboardParameters { | ||
| 15 | std::u16string submit_text; | ||
| 16 | std::u16string header_text; | ||
| 17 | std::u16string sub_text; | ||
| 18 | std::u16string guide_text; | ||
| 19 | std::u16string initial_text; | ||
| 20 | std::size_t max_length; | ||
| 21 | bool password; | ||
| 22 | bool cursor_at_beginning; | ||
| 23 | |||
| 24 | union { | ||
| 25 | u8 value; | ||
| 26 | |||
| 27 | BitField<1, 1, u8> disable_space; | ||
| 28 | BitField<2, 1, u8> disable_address; | ||
| 29 | BitField<3, 1, u8> disable_percent; | ||
| 30 | BitField<4, 1, u8> disable_slash; | ||
| 31 | BitField<6, 1, u8> disable_number; | ||
| 32 | BitField<7, 1, u8> disable_download_code; | ||
| 33 | }; | ||
| 34 | }; | ||
| 35 | |||
| 36 | class SoftwareKeyboardApplet { | ||
| 37 | public: | ||
| 38 | virtual ~SoftwareKeyboardApplet(); | ||
| 39 | |||
| 40 | virtual void RequestText(std::function<void(std::optional<std::u16string>)> out, | ||
| 41 | SoftwareKeyboardParameters parameters) const = 0; | ||
| 42 | virtual void SendTextCheckDialog(std::u16string error_message, | ||
| 43 | std::function<void()> finished_check) const = 0; | ||
| 44 | }; | ||
| 45 | |||
| 46 | class DefaultSoftwareKeyboardApplet final : public SoftwareKeyboardApplet { | ||
| 47 | public: | ||
| 48 | void RequestText(std::function<void(std::optional<std::u16string>)> out, | ||
| 49 | SoftwareKeyboardParameters parameters) const override; | ||
| 50 | void SendTextCheckDialog(std::u16string error_message, | ||
| 51 | std::function<void()> finished_check) const override; | ||
| 52 | }; | ||
| 53 | |||
| 54 | } // namespace Core::Frontend | ||