summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-11-09 20:10:58 -0500
committerGravatar Zach Hilman2018-11-18 10:53:47 -0500
commitae53b84efd5523e2aba3255f9f713d4a1df563b3 (patch)
tree6c368afbdc6c0376c9e4291a735c9c0c50b0aa91
parentam/applets: Add Applet superclass to describe a generic applet (diff)
downloadyuzu-ae53b84efd5523e2aba3255f9f713d4a1df563b3.tar.gz
yuzu-ae53b84efd5523e2aba3255f9f713d4a1df563b3.tar.xz
yuzu-ae53b84efd5523e2aba3255f9f713d4a1df563b3.zip
frontend/applets: Add frontend software keyboard provider and default
Default implementation will return "yuzu" for any string. GUI clients (or CLI) can implement the Frontend::SoftwareKeyboardApplet class and register an instance to provide functionality.
Diffstat (limited to '')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/frontend/applets/software_keyboard.cpp17
-rw-r--r--src/core/frontend/applets/software_keyboard.h44
3 files changed, 63 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 698f21a39..03ecb2c8c 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -77,6 +77,8 @@ add_library(core STATIC
77 file_sys/vfs_vector.h 77 file_sys/vfs_vector.h
78 file_sys/xts_archive.cpp 78 file_sys/xts_archive.cpp
79 file_sys/xts_archive.h 79 file_sys/xts_archive.h
80 frontend/applets/software_keyboard.cpp
81 frontend/applets/software_keyboard.h
80 frontend/emu_window.cpp 82 frontend/emu_window.cpp
81 frontend/emu_window.h 83 frontend/emu_window.h
82 frontend/framebuffer_layout.cpp 84 frontend/framebuffer_layout.cpp
diff --git a/src/core/frontend/applets/software_keyboard.cpp b/src/core/frontend/applets/software_keyboard.cpp
new file mode 100644
index 000000000..8cb888a62
--- /dev/null
+++ b/src/core/frontend/applets/software_keyboard.cpp
@@ -0,0 +1,17 @@
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 "core/frontend/applets/software_keyboard.h"
7
8namespace Frontend {
9bool DefaultSoftwareKeyboardApplet::GetText(Parameters parameters, std::u16string& text) {
10 if (parameters.initial_text.empty())
11 text = Common::UTF8ToUTF16("yuzu");
12 else
13 text = parameters.initial_text;
14
15 return true;
16}
17} // namespace 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..d368385d2
--- /dev/null
+++ b/src/core/frontend/applets/software_keyboard.h
@@ -0,0 +1,44 @@
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 <string>
8#include "common/bit_field.h"
9#include "common/common_types.h"
10
11namespace Frontend {
12class SoftwareKeyboardApplet {
13public:
14 struct Parameters {
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 virtual bool GetText(Parameters parameters, std::u16string& text) = 0;
37 virtual ~SoftwareKeyboardApplet() = default;
38};
39
40class DefaultSoftwareKeyboardApplet final : public SoftwareKeyboardApplet {
41 bool GetText(Parameters parameters, std::u16string& text) override;
42};
43
44} // namespace Frontend