diff options
author | bunnei <bunneidev@gmail.com> | 2021-04-17 08:03:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-17 08:03:23 +0200 |
commit | d5c1f3929c3348691bda405dd2a4248773d02f2d (patch) | |
tree | 271ec5aceff2eab8214a06db0f33b0afac217f86 /src/core/frontend/applets/software_keyboard.h | |
parent | Merge pull request #6201 from bunnei/remove-bintray (diff) | |
parent | applets/swkbd: Implement the Qt Software Keyboard frontend (diff) | |
download | yuzu-d5c1f3929c3348691bda405dd2a4248773d02f2d.tar yuzu-d5c1f3929c3348691bda405dd2a4248773d02f2d.tar.gz yuzu-d5c1f3929c3348691bda405dd2a4248773d02f2d.tar.bz2 yuzu-d5c1f3929c3348691bda405dd2a4248773d02f2d.tar.lz yuzu-d5c1f3929c3348691bda405dd2a4248773d02f2d.tar.xz yuzu-d5c1f3929c3348691bda405dd2a4248773d02f2d.tar.zst yuzu-d5c1f3929c3348691bda405dd2a4248773d02f2d.zip |
Diffstat (limited to 'src/core/frontend/applets/software_keyboard.h')
-rw-r--r-- | src/core/frontend/applets/software_keyboard.h | 118 |
1 files changed, 90 insertions, 28 deletions
diff --git a/src/core/frontend/applets/software_keyboard.h b/src/core/frontend/applets/software_keyboard.h index f9b202664..506eb35bb 100644 --- a/src/core/frontend/applets/software_keyboard.h +++ b/src/core/frontend/applets/software_keyboard.h @@ -1,54 +1,116 @@ -// Copyright 2018 yuzu emulator team +// Copyright 2021 yuzu Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. #pragma once #include <functional> -#include <optional> -#include <string> -#include "common/bit_field.h" +#include <thread> + #include "common/common_types.h" +#include "core/hle/service/am/applets/software_keyboard_types.h" + namespace Core::Frontend { -struct SoftwareKeyboardParameters { - std::u16string submit_text; + +struct KeyboardInitializeParameters { + std::u16string ok_text; std::u16string header_text; std::u16string sub_text; std::u16string guide_text; std::u16string initial_text; - std::size_t max_length; - bool password; - bool cursor_at_beginning; - - union { - u8 value; - - BitField<1, 1, u8> disable_space; - BitField<2, 1, u8> disable_address; - BitField<3, 1, u8> disable_percent; - BitField<4, 1, u8> disable_slash; - BitField<6, 1, u8> disable_number; - BitField<7, 1, u8> disable_download_code; - }; + u32 max_text_length; + u32 min_text_length; + s32 initial_cursor_position; + Service::AM::Applets::SwkbdType type; + Service::AM::Applets::SwkbdPasswordMode password_mode; + Service::AM::Applets::SwkbdTextDrawType text_draw_type; + Service::AM::Applets::SwkbdKeyDisableFlags key_disable_flags; + bool use_blur_background; + bool enable_backspace_button; + bool enable_return_button; + bool disable_cancel_button; +}; + +struct InlineAppearParameters { + u32 max_text_length; + u32 min_text_length; + f32 key_top_scale_x; + f32 key_top_scale_y; + f32 key_top_translate_x; + f32 key_top_translate_y; + Service::AM::Applets::SwkbdType type; + Service::AM::Applets::SwkbdKeyDisableFlags key_disable_flags; + bool key_top_as_floating; + bool enable_backspace_button; + bool enable_return_button; + bool disable_cancel_button; +}; + +struct InlineTextParameters { + std::u16string input_text; + s32 cursor_position; }; class SoftwareKeyboardApplet { public: virtual ~SoftwareKeyboardApplet(); - virtual void RequestText(std::function<void(std::optional<std::u16string>)> out, - SoftwareKeyboardParameters parameters) const = 0; - virtual void SendTextCheckDialog(std::u16string error_message, - std::function<void()> finished_check) const = 0; + virtual void InitializeKeyboard( + bool is_inline, KeyboardInitializeParameters initialize_parameters, + std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> + submit_normal_callback_, + std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> + submit_inline_callback_) = 0; + + virtual void ShowNormalKeyboard() const = 0; + + virtual void ShowTextCheckDialog(Service::AM::Applets::SwkbdTextCheckResult text_check_result, + std::u16string text_check_message) const = 0; + + virtual void ShowInlineKeyboard(InlineAppearParameters appear_parameters) const = 0; + + virtual void HideInlineKeyboard() const = 0; + + virtual void InlineTextChanged(InlineTextParameters text_parameters) const = 0; + + virtual void ExitKeyboard() const = 0; }; class DefaultSoftwareKeyboardApplet final : public SoftwareKeyboardApplet { public: - void RequestText(std::function<void(std::optional<std::u16string>)> out, - SoftwareKeyboardParameters parameters) const override; - void SendTextCheckDialog(std::u16string error_message, - std::function<void()> finished_check) const override; + ~DefaultSoftwareKeyboardApplet() override; + + void InitializeKeyboard( + bool is_inline, KeyboardInitializeParameters initialize_parameters, + std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> + submit_normal_callback_, + std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> + submit_inline_callback_) override; + + void ShowNormalKeyboard() const override; + + void ShowTextCheckDialog(Service::AM::Applets::SwkbdTextCheckResult text_check_result, + std::u16string text_check_message) const override; + + void ShowInlineKeyboard(InlineAppearParameters appear_parameters) const override; + + void HideInlineKeyboard() const override; + + void InlineTextChanged(InlineTextParameters text_parameters) const override; + + void ExitKeyboard() const override; + +private: + void SubmitNormalText(std::u16string text) const; + void SubmitInlineText(std::u16string_view text) const; + + KeyboardInitializeParameters parameters; + + mutable std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> + submit_normal_callback; + mutable std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> + submit_inline_callback; }; } // namespace Core::Frontend |