diff options
Diffstat (limited to 'src/common/android/applets/software_keyboard.h')
-rwxr-xr-x | src/common/android/applets/software_keyboard.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/common/android/applets/software_keyboard.h b/src/common/android/applets/software_keyboard.h new file mode 100755 index 000000000..9fd09d27c --- /dev/null +++ b/src/common/android/applets/software_keyboard.h | |||
@@ -0,0 +1,78 @@ | |||
1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
3 | |||
4 | #pragma once | ||
5 | |||
6 | #include <jni.h> | ||
7 | |||
8 | #include "core/frontend/applets/software_keyboard.h" | ||
9 | |||
10 | namespace Common::Android::SoftwareKeyboard { | ||
11 | |||
12 | class AndroidKeyboard final : public Core::Frontend::SoftwareKeyboardApplet { | ||
13 | public: | ||
14 | ~AndroidKeyboard() override; | ||
15 | |||
16 | void Close() const override { | ||
17 | ExitKeyboard(); | ||
18 | } | ||
19 | |||
20 | void InitializeKeyboard(bool is_inline, | ||
21 | Core::Frontend::KeyboardInitializeParameters initialize_parameters, | ||
22 | SubmitNormalCallback submit_normal_callback_, | ||
23 | SubmitInlineCallback submit_inline_callback_) override; | ||
24 | |||
25 | void ShowNormalKeyboard() const override; | ||
26 | |||
27 | void ShowTextCheckDialog(Service::AM::Frontend::SwkbdTextCheckResult text_check_result, | ||
28 | std::u16string text_check_message) const override; | ||
29 | |||
30 | void ShowInlineKeyboard( | ||
31 | Core::Frontend::InlineAppearParameters appear_parameters) const override; | ||
32 | |||
33 | void HideInlineKeyboard() const override; | ||
34 | |||
35 | void InlineTextChanged(Core::Frontend::InlineTextParameters text_parameters) const override; | ||
36 | |||
37 | void ExitKeyboard() const override; | ||
38 | |||
39 | void SubmitInlineKeyboardText(std::u16string submitted_text); | ||
40 | |||
41 | void SubmitInlineKeyboardInput(int key_code); | ||
42 | |||
43 | private: | ||
44 | struct ResultData { | ||
45 | static ResultData CreateFromFrontend(jobject object); | ||
46 | |||
47 | std::string text; | ||
48 | Service::AM::Frontend::SwkbdResult result{}; | ||
49 | }; | ||
50 | |||
51 | void SubmitNormalText(const ResultData& result) const; | ||
52 | |||
53 | Core::Frontend::KeyboardInitializeParameters parameters{}; | ||
54 | |||
55 | mutable SubmitNormalCallback submit_normal_callback; | ||
56 | mutable SubmitInlineCallback submit_inline_callback; | ||
57 | |||
58 | private: | ||
59 | mutable bool m_is_inline_active{}; | ||
60 | std::u16string m_current_text; | ||
61 | }; | ||
62 | |||
63 | // Should be called in JNI_Load | ||
64 | void InitJNI(JNIEnv* env); | ||
65 | |||
66 | // Should be called in JNI_Unload | ||
67 | void CleanupJNI(JNIEnv* env); | ||
68 | |||
69 | } // namespace Common::Android::SoftwareKeyboard | ||
70 | |||
71 | // Native function calls | ||
72 | extern "C" { | ||
73 | JNIEXPORT jobject JNICALL Java_org_citra_citra_1emu_applets_SoftwareKeyboard_ValidateFilters( | ||
74 | JNIEnv* env, jclass clazz, jstring text); | ||
75 | |||
76 | JNIEXPORT jobject JNICALL Java_org_citra_citra_1emu_applets_SoftwareKeyboard_ValidateInput( | ||
77 | JNIEnv* env, jclass clazz, jstring text); | ||
78 | } | ||