summaryrefslogtreecommitdiffstats
path: root/src/common/android/applets/software_keyboard.h
diff options
context:
space:
mode:
authort895 <clombardo169@gmail.com>2024-02-05 12:07:29 +0100
committert895 <clombardo169@gmail.com>2024-02-08 19:45:26 +0100
commite7c4c8b993ce27a50b7a56f90247056048d20f7d (patch)
treeb87c275f4ea92092f7c8b6cdcb0f50d32819490f /src/common/android/applets/software_keyboard.h
parentMerge pull request #12892 from liamwhite/serialization-stuff (diff)
downloadyuzu-e7c4c8b993ce27a50b7a56f90247056048d20f7d.tar
yuzu-e7c4c8b993ce27a50b7a56f90247056048d20f7d.tar.gz
yuzu-e7c4c8b993ce27a50b7a56f90247056048d20f7d.tar.bz2
yuzu-e7c4c8b993ce27a50b7a56f90247056048d20f7d.tar.lz
yuzu-e7c4c8b993ce27a50b7a56f90247056048d20f7d.tar.xz
yuzu-e7c4c8b993ce27a50b7a56f90247056048d20f7d.tar.zst
yuzu-e7c4c8b993ce27a50b7a56f90247056048d20f7d.zip
Diffstat (limited to 'src/common/android/applets/software_keyboard.h')
-rw-r--r--src/common/android/applets/software_keyboard.h78
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 100644
index 000000000..9fd09d27c
--- /dev/null
+++ b/src/common/android/applets/software_keyboard.h
@@ -0,0 +1,78 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <jni.h>
+
+#include "core/frontend/applets/software_keyboard.h"
+
+namespace Common::Android::SoftwareKeyboard {
+
+class AndroidKeyboard final : public Core::Frontend::SoftwareKeyboardApplet {
+public:
+ ~AndroidKeyboard() override;
+
+ void Close() const override {
+ ExitKeyboard();
+ }
+
+ void InitializeKeyboard(bool is_inline,
+ Core::Frontend::KeyboardInitializeParameters initialize_parameters,
+ SubmitNormalCallback submit_normal_callback_,
+ SubmitInlineCallback submit_inline_callback_) override;
+
+ void ShowNormalKeyboard() const override;
+
+ void ShowTextCheckDialog(Service::AM::Frontend::SwkbdTextCheckResult text_check_result,
+ std::u16string text_check_message) const override;
+
+ void ShowInlineKeyboard(
+ Core::Frontend::InlineAppearParameters appear_parameters) const override;
+
+ void HideInlineKeyboard() const override;
+
+ void InlineTextChanged(Core::Frontend::InlineTextParameters text_parameters) const override;
+
+ void ExitKeyboard() const override;
+
+ void SubmitInlineKeyboardText(std::u16string submitted_text);
+
+ void SubmitInlineKeyboardInput(int key_code);
+
+private:
+ struct ResultData {
+ static ResultData CreateFromFrontend(jobject object);
+
+ std::string text;
+ Service::AM::Frontend::SwkbdResult result{};
+ };
+
+ void SubmitNormalText(const ResultData& result) const;
+
+ Core::Frontend::KeyboardInitializeParameters parameters{};
+
+ mutable SubmitNormalCallback submit_normal_callback;
+ mutable SubmitInlineCallback submit_inline_callback;
+
+private:
+ mutable bool m_is_inline_active{};
+ std::u16string m_current_text;
+};
+
+// Should be called in JNI_Load
+void InitJNI(JNIEnv* env);
+
+// Should be called in JNI_Unload
+void CleanupJNI(JNIEnv* env);
+
+} // namespace Common::Android::SoftwareKeyboard
+
+// Native function calls
+extern "C" {
+JNIEXPORT jobject JNICALL Java_org_citra_citra_1emu_applets_SoftwareKeyboard_ValidateFilters(
+ JNIEnv* env, jclass clazz, jstring text);
+
+JNIEXPORT jobject JNICALL Java_org_citra_citra_1emu_applets_SoftwareKeyboard_ValidateInput(
+ JNIEnv* env, jclass clazz, jstring text);
+}