diff options
| author | 2024-02-09 11:49:25 -0500 | |
|---|---|---|
| committer | 2024-02-09 11:49:25 -0500 | |
| commit | 7ec7ff0f303504950e4270e91076a33efd0ceb17 (patch) | |
| tree | 1e8346f775550eefd491aa8280412d86000dd637 /src/android/app | |
| parent | Merge pull request #12927 from german77/cheat-pause (diff) | |
| parent | android: Run OnEmulationStarted frontend callback in another thread (diff) | |
| download | yuzu-7ec7ff0f303504950e4270e91076a33efd0ceb17.tar.gz yuzu-7ec7ff0f303504950e4270e91076a33efd0ceb17.tar.xz yuzu-7ec7ff0f303504950e4270e91076a33efd0ceb17.zip | |
Merge pull request #12920 from t895/jni-common
android: Move JNI setup and helpers to common
Diffstat (limited to 'src/android/app')
| -rw-r--r-- | src/android/app/src/main/jni/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/android_common/android_common.cpp | 60 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/android_common/android_common.h | 22 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/applets/software_keyboard.cpp | 277 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/applets/software_keyboard.h | 78 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/emu_window/emu_window.cpp | 4 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/game_metadata.cpp | 22 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/id_cache.cpp | 428 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/id_cache.h | 68 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/native.cpp | 125 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/native.h | 6 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/native_config.cpp | 121 | ||||
| -rw-r--r-- | src/android/app/src/main/jni/native_log.cpp | 13 |
13 files changed, 159 insertions, 1071 deletions
diff --git a/src/android/app/src/main/jni/CMakeLists.txt b/src/android/app/src/main/jni/CMakeLists.txt index abc6055ab..20b319c12 100644 --- a/src/android/app/src/main/jni/CMakeLists.txt +++ b/src/android/app/src/main/jni/CMakeLists.txt | |||
| @@ -2,14 +2,8 @@ | |||
| 2 | # SPDX-License-Identifier: GPL-3.0-or-later | 2 | # SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | 3 | ||
| 4 | add_library(yuzu-android SHARED | 4 | add_library(yuzu-android SHARED |
| 5 | android_common/android_common.cpp | ||
| 6 | android_common/android_common.h | ||
| 7 | applets/software_keyboard.cpp | ||
| 8 | applets/software_keyboard.h | ||
| 9 | emu_window/emu_window.cpp | 5 | emu_window/emu_window.cpp |
| 10 | emu_window/emu_window.h | 6 | emu_window/emu_window.h |
| 11 | id_cache.cpp | ||
| 12 | id_cache.h | ||
| 13 | native.cpp | 7 | native.cpp |
| 14 | native.h | 8 | native.h |
| 15 | native_config.cpp | 9 | native_config.cpp |
diff --git a/src/android/app/src/main/jni/android_common/android_common.cpp b/src/android/app/src/main/jni/android_common/android_common.cpp deleted file mode 100644 index 7018a52af..000000000 --- a/src/android/app/src/main/jni/android_common/android_common.cpp +++ /dev/null | |||
| @@ -1,60 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "jni/android_common/android_common.h" | ||
| 5 | |||
| 6 | #include <string> | ||
| 7 | #include <string_view> | ||
| 8 | |||
| 9 | #include <jni.h> | ||
| 10 | |||
| 11 | #include "common/string_util.h" | ||
| 12 | #include "jni/id_cache.h" | ||
| 13 | |||
| 14 | std::string GetJString(JNIEnv* env, jstring jstr) { | ||
| 15 | if (!jstr) { | ||
| 16 | return {}; | ||
| 17 | } | ||
| 18 | |||
| 19 | const jchar* jchars = env->GetStringChars(jstr, nullptr); | ||
| 20 | const jsize length = env->GetStringLength(jstr); | ||
| 21 | const std::u16string_view string_view(reinterpret_cast<const char16_t*>(jchars), length); | ||
| 22 | const std::string converted_string = Common::UTF16ToUTF8(string_view); | ||
| 23 | env->ReleaseStringChars(jstr, jchars); | ||
| 24 | |||
| 25 | return converted_string; | ||
| 26 | } | ||
| 27 | |||
| 28 | jstring ToJString(JNIEnv* env, std::string_view str) { | ||
| 29 | const std::u16string converted_string = Common::UTF8ToUTF16(str); | ||
| 30 | return env->NewString(reinterpret_cast<const jchar*>(converted_string.data()), | ||
| 31 | static_cast<jint>(converted_string.size())); | ||
| 32 | } | ||
| 33 | |||
| 34 | jstring ToJString(JNIEnv* env, std::u16string_view str) { | ||
| 35 | return ToJString(env, Common::UTF16ToUTF8(str)); | ||
| 36 | } | ||
| 37 | |||
| 38 | double GetJDouble(JNIEnv* env, jobject jdouble) { | ||
| 39 | return env->GetDoubleField(jdouble, IDCache::GetDoubleValueField()); | ||
| 40 | } | ||
| 41 | |||
| 42 | jobject ToJDouble(JNIEnv* env, double value) { | ||
| 43 | return env->NewObject(IDCache::GetDoubleClass(), IDCache::GetDoubleConstructor(), value); | ||
| 44 | } | ||
| 45 | |||
| 46 | s32 GetJInteger(JNIEnv* env, jobject jinteger) { | ||
| 47 | return env->GetIntField(jinteger, IDCache::GetIntegerValueField()); | ||
| 48 | } | ||
| 49 | |||
| 50 | jobject ToJInteger(JNIEnv* env, s32 value) { | ||
| 51 | return env->NewObject(IDCache::GetIntegerClass(), IDCache::GetIntegerConstructor(), value); | ||
| 52 | } | ||
| 53 | |||
| 54 | bool GetJBoolean(JNIEnv* env, jobject jboolean) { | ||
| 55 | return env->GetBooleanField(jboolean, IDCache::GetBooleanValueField()); | ||
| 56 | } | ||
| 57 | |||
| 58 | jobject ToJBoolean(JNIEnv* env, bool value) { | ||
| 59 | return env->NewObject(IDCache::GetBooleanClass(), IDCache::GetBooleanConstructor(), value); | ||
| 60 | } | ||
diff --git a/src/android/app/src/main/jni/android_common/android_common.h b/src/android/app/src/main/jni/android_common/android_common.h deleted file mode 100644 index 29a338c0a..000000000 --- a/src/android/app/src/main/jni/android_common/android_common.h +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <string> | ||
| 7 | |||
| 8 | #include <jni.h> | ||
| 9 | #include "common/common_types.h" | ||
| 10 | |||
| 11 | std::string GetJString(JNIEnv* env, jstring jstr); | ||
| 12 | jstring ToJString(JNIEnv* env, std::string_view str); | ||
| 13 | jstring ToJString(JNIEnv* env, std::u16string_view str); | ||
| 14 | |||
| 15 | double GetJDouble(JNIEnv* env, jobject jdouble); | ||
| 16 | jobject ToJDouble(JNIEnv* env, double value); | ||
| 17 | |||
| 18 | s32 GetJInteger(JNIEnv* env, jobject jinteger); | ||
| 19 | jobject ToJInteger(JNIEnv* env, s32 value); | ||
| 20 | |||
| 21 | bool GetJBoolean(JNIEnv* env, jobject jboolean); | ||
| 22 | jobject ToJBoolean(JNIEnv* env, bool value); | ||
diff --git a/src/android/app/src/main/jni/applets/software_keyboard.cpp b/src/android/app/src/main/jni/applets/software_keyboard.cpp deleted file mode 100644 index 9943483e8..000000000 --- a/src/android/app/src/main/jni/applets/software_keyboard.cpp +++ /dev/null | |||
| @@ -1,277 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include <map> | ||
| 5 | #include <thread> | ||
| 6 | |||
| 7 | #include <jni.h> | ||
| 8 | |||
| 9 | #include "common/logging/log.h" | ||
| 10 | #include "common/string_util.h" | ||
| 11 | #include "core/core.h" | ||
| 12 | #include "jni/android_common/android_common.h" | ||
| 13 | #include "jni/applets/software_keyboard.h" | ||
| 14 | #include "jni/id_cache.h" | ||
| 15 | |||
| 16 | static jclass s_software_keyboard_class; | ||
| 17 | static jclass s_keyboard_config_class; | ||
| 18 | static jclass s_keyboard_data_class; | ||
| 19 | static jmethodID s_swkbd_execute_normal; | ||
| 20 | static jmethodID s_swkbd_execute_inline; | ||
| 21 | |||
| 22 | namespace SoftwareKeyboard { | ||
| 23 | |||
| 24 | static jobject ToJKeyboardParams(const Core::Frontend::KeyboardInitializeParameters& config) { | ||
| 25 | JNIEnv* env = IDCache::GetEnvForThread(); | ||
| 26 | jobject object = env->AllocObject(s_keyboard_config_class); | ||
| 27 | |||
| 28 | env->SetObjectField(object, | ||
| 29 | env->GetFieldID(s_keyboard_config_class, "ok_text", "Ljava/lang/String;"), | ||
| 30 | ToJString(env, config.ok_text)); | ||
| 31 | env->SetObjectField( | ||
| 32 | object, env->GetFieldID(s_keyboard_config_class, "header_text", "Ljava/lang/String;"), | ||
| 33 | ToJString(env, config.header_text)); | ||
| 34 | env->SetObjectField(object, | ||
| 35 | env->GetFieldID(s_keyboard_config_class, "sub_text", "Ljava/lang/String;"), | ||
| 36 | ToJString(env, config.sub_text)); | ||
| 37 | env->SetObjectField( | ||
| 38 | object, env->GetFieldID(s_keyboard_config_class, "guide_text", "Ljava/lang/String;"), | ||
| 39 | ToJString(env, config.guide_text)); | ||
| 40 | env->SetObjectField( | ||
| 41 | object, env->GetFieldID(s_keyboard_config_class, "initial_text", "Ljava/lang/String;"), | ||
| 42 | ToJString(env, config.initial_text)); | ||
| 43 | env->SetShortField(object, | ||
| 44 | env->GetFieldID(s_keyboard_config_class, "left_optional_symbol_key", "S"), | ||
| 45 | static_cast<jshort>(config.left_optional_symbol_key)); | ||
| 46 | env->SetShortField(object, | ||
| 47 | env->GetFieldID(s_keyboard_config_class, "right_optional_symbol_key", "S"), | ||
| 48 | static_cast<jshort>(config.right_optional_symbol_key)); | ||
| 49 | env->SetIntField(object, env->GetFieldID(s_keyboard_config_class, "max_text_length", "I"), | ||
| 50 | static_cast<jint>(config.max_text_length)); | ||
| 51 | env->SetIntField(object, env->GetFieldID(s_keyboard_config_class, "min_text_length", "I"), | ||
| 52 | static_cast<jint>(config.min_text_length)); | ||
| 53 | env->SetIntField(object, | ||
| 54 | env->GetFieldID(s_keyboard_config_class, "initial_cursor_position", "I"), | ||
| 55 | static_cast<jint>(config.initial_cursor_position)); | ||
| 56 | env->SetIntField(object, env->GetFieldID(s_keyboard_config_class, "type", "I"), | ||
| 57 | static_cast<jint>(config.type)); | ||
| 58 | env->SetIntField(object, env->GetFieldID(s_keyboard_config_class, "password_mode", "I"), | ||
| 59 | static_cast<jint>(config.password_mode)); | ||
| 60 | env->SetIntField(object, env->GetFieldID(s_keyboard_config_class, "text_draw_type", "I"), | ||
| 61 | static_cast<jint>(config.text_draw_type)); | ||
| 62 | env->SetIntField(object, env->GetFieldID(s_keyboard_config_class, "key_disable_flags", "I"), | ||
| 63 | static_cast<jint>(config.key_disable_flags.raw)); | ||
| 64 | env->SetBooleanField(object, | ||
| 65 | env->GetFieldID(s_keyboard_config_class, "use_blur_background", "Z"), | ||
| 66 | static_cast<jboolean>(config.use_blur_background)); | ||
| 67 | env->SetBooleanField(object, | ||
| 68 | env->GetFieldID(s_keyboard_config_class, "enable_backspace_button", "Z"), | ||
| 69 | static_cast<jboolean>(config.enable_backspace_button)); | ||
| 70 | env->SetBooleanField(object, | ||
| 71 | env->GetFieldID(s_keyboard_config_class, "enable_return_button", "Z"), | ||
| 72 | static_cast<jboolean>(config.enable_return_button)); | ||
| 73 | env->SetBooleanField(object, | ||
| 74 | env->GetFieldID(s_keyboard_config_class, "disable_cancel_button", "Z"), | ||
| 75 | static_cast<jboolean>(config.disable_cancel_button)); | ||
| 76 | |||
| 77 | return object; | ||
| 78 | } | ||
| 79 | |||
| 80 | AndroidKeyboard::ResultData AndroidKeyboard::ResultData::CreateFromFrontend(jobject object) { | ||
| 81 | JNIEnv* env = IDCache::GetEnvForThread(); | ||
| 82 | const jstring string = reinterpret_cast<jstring>(env->GetObjectField( | ||
| 83 | object, env->GetFieldID(s_keyboard_data_class, "text", "Ljava/lang/String;"))); | ||
| 84 | return ResultData{GetJString(env, string), | ||
| 85 | static_cast<Service::AM::Frontend::SwkbdResult>(env->GetIntField( | ||
| 86 | object, env->GetFieldID(s_keyboard_data_class, "result", "I")))}; | ||
| 87 | } | ||
| 88 | |||
| 89 | AndroidKeyboard::~AndroidKeyboard() = default; | ||
| 90 | |||
| 91 | void AndroidKeyboard::InitializeKeyboard( | ||
| 92 | bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters, | ||
| 93 | SubmitNormalCallback submit_normal_callback_, SubmitInlineCallback submit_inline_callback_) { | ||
| 94 | if (is_inline) { | ||
| 95 | LOG_WARNING( | ||
| 96 | Frontend, | ||
| 97 | "(STUBBED) called, backend requested to initialize the inline software keyboard."); | ||
| 98 | |||
| 99 | submit_inline_callback = std::move(submit_inline_callback_); | ||
| 100 | } else { | ||
| 101 | LOG_WARNING( | ||
| 102 | Frontend, | ||
| 103 | "(STUBBED) called, backend requested to initialize the normal software keyboard."); | ||
| 104 | |||
| 105 | submit_normal_callback = std::move(submit_normal_callback_); | ||
| 106 | } | ||
| 107 | |||
| 108 | parameters = std::move(initialize_parameters); | ||
| 109 | |||
| 110 | LOG_INFO(Frontend, | ||
| 111 | "\nKeyboardInitializeParameters:" | ||
| 112 | "\nok_text={}" | ||
| 113 | "\nheader_text={}" | ||
| 114 | "\nsub_text={}" | ||
| 115 | "\nguide_text={}" | ||
| 116 | "\ninitial_text={}" | ||
| 117 | "\nmax_text_length={}" | ||
| 118 | "\nmin_text_length={}" | ||
| 119 | "\ninitial_cursor_position={}" | ||
| 120 | "\ntype={}" | ||
| 121 | "\npassword_mode={}" | ||
| 122 | "\ntext_draw_type={}" | ||
| 123 | "\nkey_disable_flags={}" | ||
| 124 | "\nuse_blur_background={}" | ||
| 125 | "\nenable_backspace_button={}" | ||
| 126 | "\nenable_return_button={}" | ||
| 127 | "\ndisable_cancel_button={}", | ||
| 128 | Common::UTF16ToUTF8(parameters.ok_text), Common::UTF16ToUTF8(parameters.header_text), | ||
| 129 | Common::UTF16ToUTF8(parameters.sub_text), Common::UTF16ToUTF8(parameters.guide_text), | ||
| 130 | Common::UTF16ToUTF8(parameters.initial_text), parameters.max_text_length, | ||
| 131 | parameters.min_text_length, parameters.initial_cursor_position, parameters.type, | ||
| 132 | parameters.password_mode, parameters.text_draw_type, parameters.key_disable_flags.raw, | ||
| 133 | parameters.use_blur_background, parameters.enable_backspace_button, | ||
| 134 | parameters.enable_return_button, parameters.disable_cancel_button); | ||
| 135 | } | ||
| 136 | |||
| 137 | void AndroidKeyboard::ShowNormalKeyboard() const { | ||
| 138 | LOG_DEBUG(Frontend, "called, backend requested to show the normal software keyboard."); | ||
| 139 | |||
| 140 | ResultData data{}; | ||
| 141 | |||
| 142 | // Pivot to a new thread, as we cannot call GetEnvForThread() from a Fiber. | ||
| 143 | std::thread([&] { | ||
| 144 | data = ResultData::CreateFromFrontend(IDCache::GetEnvForThread()->CallStaticObjectMethod( | ||
| 145 | s_software_keyboard_class, s_swkbd_execute_normal, ToJKeyboardParams(parameters))); | ||
| 146 | }).join(); | ||
| 147 | |||
| 148 | SubmitNormalText(data); | ||
| 149 | } | ||
| 150 | |||
| 151 | void AndroidKeyboard::ShowTextCheckDialog( | ||
| 152 | Service::AM::Frontend::SwkbdTextCheckResult text_check_result, | ||
| 153 | std::u16string text_check_message) const { | ||
| 154 | LOG_WARNING(Frontend, "(STUBBED) called, backend requested to show the text check dialog."); | ||
| 155 | } | ||
| 156 | |||
| 157 | void AndroidKeyboard::ShowInlineKeyboard( | ||
| 158 | Core::Frontend::InlineAppearParameters appear_parameters) const { | ||
| 159 | LOG_WARNING(Frontend, | ||
| 160 | "(STUBBED) called, backend requested to show the inline software keyboard."); | ||
| 161 | |||
| 162 | LOG_INFO(Frontend, | ||
| 163 | "\nInlineAppearParameters:" | ||
| 164 | "\nmax_text_length={}" | ||
| 165 | "\nmin_text_length={}" | ||
| 166 | "\nkey_top_scale_x={}" | ||
| 167 | "\nkey_top_scale_y={}" | ||
| 168 | "\nkey_top_translate_x={}" | ||
| 169 | "\nkey_top_translate_y={}" | ||
| 170 | "\ntype={}" | ||
| 171 | "\nkey_disable_flags={}" | ||
| 172 | "\nkey_top_as_floating={}" | ||
| 173 | "\nenable_backspace_button={}" | ||
| 174 | "\nenable_return_button={}" | ||
| 175 | "\ndisable_cancel_button={}", | ||
| 176 | appear_parameters.max_text_length, appear_parameters.min_text_length, | ||
| 177 | appear_parameters.key_top_scale_x, appear_parameters.key_top_scale_y, | ||
| 178 | appear_parameters.key_top_translate_x, appear_parameters.key_top_translate_y, | ||
| 179 | appear_parameters.type, appear_parameters.key_disable_flags.raw, | ||
| 180 | appear_parameters.key_top_as_floating, appear_parameters.enable_backspace_button, | ||
| 181 | appear_parameters.enable_return_button, appear_parameters.disable_cancel_button); | ||
| 182 | |||
| 183 | // Pivot to a new thread, as we cannot call GetEnvForThread() from a Fiber. | ||
| 184 | m_is_inline_active = true; | ||
| 185 | std::thread([&] { | ||
| 186 | IDCache::GetEnvForThread()->CallStaticVoidMethod( | ||
| 187 | s_software_keyboard_class, s_swkbd_execute_inline, ToJKeyboardParams(parameters)); | ||
| 188 | }).join(); | ||
| 189 | } | ||
| 190 | |||
| 191 | void AndroidKeyboard::HideInlineKeyboard() const { | ||
| 192 | LOG_WARNING(Frontend, | ||
| 193 | "(STUBBED) called, backend requested to hide the inline software keyboard."); | ||
| 194 | } | ||
| 195 | |||
| 196 | void AndroidKeyboard::InlineTextChanged( | ||
| 197 | Core::Frontend::InlineTextParameters text_parameters) const { | ||
| 198 | LOG_WARNING(Frontend, | ||
| 199 | "(STUBBED) called, backend requested to change the inline keyboard text."); | ||
| 200 | |||
| 201 | LOG_INFO(Frontend, | ||
| 202 | "\nInlineTextParameters:" | ||
| 203 | "\ninput_text={}" | ||
| 204 | "\ncursor_position={}", | ||
| 205 | Common::UTF16ToUTF8(text_parameters.input_text), text_parameters.cursor_position); | ||
| 206 | |||
| 207 | submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::ChangedString, | ||
| 208 | text_parameters.input_text, text_parameters.cursor_position); | ||
| 209 | } | ||
| 210 | |||
| 211 | void AndroidKeyboard::ExitKeyboard() const { | ||
| 212 | LOG_WARNING(Frontend, "(STUBBED) called, backend requested to exit the software keyboard."); | ||
| 213 | } | ||
| 214 | |||
| 215 | void AndroidKeyboard::SubmitInlineKeyboardText(std::u16string submitted_text) { | ||
| 216 | if (!m_is_inline_active) { | ||
| 217 | return; | ||
| 218 | } | ||
| 219 | |||
| 220 | m_current_text += submitted_text; | ||
| 221 | |||
| 222 | submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::ChangedString, m_current_text, | ||
| 223 | m_current_text.size()); | ||
| 224 | } | ||
| 225 | |||
| 226 | void AndroidKeyboard::SubmitInlineKeyboardInput(int key_code) { | ||
| 227 | static constexpr int KEYCODE_BACK = 4; | ||
| 228 | static constexpr int KEYCODE_ENTER = 66; | ||
| 229 | static constexpr int KEYCODE_DEL = 67; | ||
| 230 | |||
| 231 | if (!m_is_inline_active) { | ||
| 232 | return; | ||
| 233 | } | ||
| 234 | |||
| 235 | switch (key_code) { | ||
| 236 | case KEYCODE_BACK: | ||
| 237 | case KEYCODE_ENTER: | ||
| 238 | m_is_inline_active = false; | ||
| 239 | submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::DecidedEnter, m_current_text, | ||
| 240 | static_cast<s32>(m_current_text.size())); | ||
| 241 | break; | ||
| 242 | case KEYCODE_DEL: | ||
| 243 | m_current_text.pop_back(); | ||
| 244 | submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::ChangedString, m_current_text, | ||
| 245 | m_current_text.size()); | ||
| 246 | break; | ||
| 247 | } | ||
| 248 | } | ||
| 249 | |||
| 250 | void AndroidKeyboard::SubmitNormalText(const ResultData& data) const { | ||
| 251 | submit_normal_callback(data.result, Common::UTF8ToUTF16(data.text), true); | ||
| 252 | } | ||
| 253 | |||
| 254 | void InitJNI(JNIEnv* env) { | ||
| 255 | s_software_keyboard_class = reinterpret_cast<jclass>( | ||
| 256 | env->NewGlobalRef(env->FindClass("org/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard"))); | ||
| 257 | s_keyboard_config_class = reinterpret_cast<jclass>(env->NewGlobalRef( | ||
| 258 | env->FindClass("org/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard$KeyboardConfig"))); | ||
| 259 | s_keyboard_data_class = reinterpret_cast<jclass>(env->NewGlobalRef( | ||
| 260 | env->FindClass("org/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard$KeyboardData"))); | ||
| 261 | |||
| 262 | s_swkbd_execute_normal = env->GetStaticMethodID( | ||
| 263 | s_software_keyboard_class, "executeNormal", | ||
| 264 | "(Lorg/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard$KeyboardConfig;)Lorg/yuzu/yuzu_emu/" | ||
| 265 | "applets/keyboard/SoftwareKeyboard$KeyboardData;"); | ||
| 266 | s_swkbd_execute_inline = env->GetStaticMethodID( | ||
| 267 | s_software_keyboard_class, "executeInline", | ||
| 268 | "(Lorg/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard$KeyboardConfig;)V"); | ||
| 269 | } | ||
| 270 | |||
| 271 | void CleanupJNI(JNIEnv* env) { | ||
| 272 | env->DeleteGlobalRef(s_software_keyboard_class); | ||
| 273 | env->DeleteGlobalRef(s_keyboard_config_class); | ||
| 274 | env->DeleteGlobalRef(s_keyboard_data_class); | ||
| 275 | } | ||
| 276 | |||
| 277 | } // namespace SoftwareKeyboard | ||
diff --git a/src/android/app/src/main/jni/applets/software_keyboard.h b/src/android/app/src/main/jni/applets/software_keyboard.h deleted file mode 100644 index 2affc01f6..000000000 --- a/src/android/app/src/main/jni/applets/software_keyboard.h +++ /dev/null | |||
| @@ -1,78 +0,0 @@ | |||
| 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 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 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 | } | ||
diff --git a/src/android/app/src/main/jni/emu_window/emu_window.cpp b/src/android/app/src/main/jni/emu_window/emu_window.cpp index c4f631924..c927cddda 100644 --- a/src/android/app/src/main/jni/emu_window/emu_window.cpp +++ b/src/android/app/src/main/jni/emu_window/emu_window.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include <android/native_window_jni.h> | 4 | #include <android/native_window_jni.h> |
| 5 | 5 | ||
| 6 | #include "common/android/id_cache.h" | ||
| 6 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 7 | #include "input_common/drivers/touch_screen.h" | 8 | #include "input_common/drivers/touch_screen.h" |
| 8 | #include "input_common/drivers/virtual_amiibo.h" | 9 | #include "input_common/drivers/virtual_amiibo.h" |
| @@ -60,7 +61,8 @@ void EmuWindow_Android::OnRemoveNfcTag() { | |||
| 60 | 61 | ||
| 61 | void EmuWindow_Android::OnFrameDisplayed() { | 62 | void EmuWindow_Android::OnFrameDisplayed() { |
| 62 | if (!m_first_frame) { | 63 | if (!m_first_frame) { |
| 63 | EmulationSession::GetInstance().OnEmulationStarted(); | 64 | Common::Android::RunJNIOnFiber<void>( |
| 65 | [&](JNIEnv* env) { EmulationSession::GetInstance().OnEmulationStarted(); }); | ||
| 64 | m_first_frame = true; | 66 | m_first_frame = true; |
| 65 | } | 67 | } |
| 66 | } | 68 | } |
diff --git a/src/android/app/src/main/jni/game_metadata.cpp b/src/android/app/src/main/jni/game_metadata.cpp index 8f0da1413..c33763b47 100644 --- a/src/android/app/src/main/jni/game_metadata.cpp +++ b/src/android/app/src/main/jni/game_metadata.cpp | |||
| @@ -1,13 +1,12 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "common/android/android_common.h" | ||
| 4 | #include "core/core.h" | 5 | #include "core/core.h" |
| 5 | #include "core/file_sys/fs_filesystem.h" | 6 | #include "core/file_sys/fs_filesystem.h" |
| 6 | #include "core/file_sys/patch_manager.h" | 7 | #include "core/file_sys/patch_manager.h" |
| 7 | #include "core/loader/loader.h" | 8 | #include "core/loader/loader.h" |
| 8 | #include "core/loader/nro.h" | 9 | #include "core/loader/nro.h" |
| 9 | #include "jni.h" | ||
| 10 | #include "jni/android_common/android_common.h" | ||
| 11 | #include "native.h" | 10 | #include "native.h" |
| 12 | 11 | ||
| 13 | struct RomMetadata { | 12 | struct RomMetadata { |
| @@ -79,7 +78,7 @@ extern "C" { | |||
| 79 | jboolean Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIsValid(JNIEnv* env, jobject obj, | 78 | jboolean Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIsValid(JNIEnv* env, jobject obj, |
| 80 | jstring jpath) { | 79 | jstring jpath) { |
| 81 | const auto file = EmulationSession::GetInstance().System().GetFilesystem()->OpenFile( | 80 | const auto file = EmulationSession::GetInstance().System().GetFilesystem()->OpenFile( |
| 82 | GetJString(env, jpath), FileSys::OpenMode::Read); | 81 | Common::Android::GetJString(env, jpath), FileSys::OpenMode::Read); |
| 83 | if (!file) { | 82 | if (!file) { |
| 84 | return false; | 83 | return false; |
| 85 | } | 84 | } |
| @@ -104,27 +103,31 @@ jboolean Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIsValid(JNIEnv* env, jobj | |||
| 104 | 103 | ||
| 105 | jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getTitle(JNIEnv* env, jobject obj, | 104 | jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getTitle(JNIEnv* env, jobject obj, |
| 106 | jstring jpath) { | 105 | jstring jpath) { |
| 107 | return ToJString(env, GetRomMetadata(GetJString(env, jpath)).title); | 106 | return Common::Android::ToJString( |
| 107 | env, GetRomMetadata(Common::Android::GetJString(env, jpath)).title); | ||
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getProgramId(JNIEnv* env, jobject obj, | 110 | jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getProgramId(JNIEnv* env, jobject obj, |
| 111 | jstring jpath) { | 111 | jstring jpath) { |
| 112 | return ToJString(env, std::to_string(GetRomMetadata(GetJString(env, jpath)).programId)); | 112 | return Common::Android::ToJString( |
| 113 | env, std::to_string(GetRomMetadata(Common::Android::GetJString(env, jpath)).programId)); | ||
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getDeveloper(JNIEnv* env, jobject obj, | 116 | jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getDeveloper(JNIEnv* env, jobject obj, |
| 116 | jstring jpath) { | 117 | jstring jpath) { |
| 117 | return ToJString(env, GetRomMetadata(GetJString(env, jpath)).developer); | 118 | return Common::Android::ToJString( |
| 119 | env, GetRomMetadata(Common::Android::GetJString(env, jpath)).developer); | ||
| 118 | } | 120 | } |
| 119 | 121 | ||
| 120 | jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getVersion(JNIEnv* env, jobject obj, | 122 | jstring Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getVersion(JNIEnv* env, jobject obj, |
| 121 | jstring jpath, jboolean jreload) { | 123 | jstring jpath, jboolean jreload) { |
| 122 | return ToJString(env, GetRomMetadata(GetJString(env, jpath), jreload).version); | 124 | return Common::Android::ToJString( |
| 125 | env, GetRomMetadata(Common::Android::GetJString(env, jpath), jreload).version); | ||
| 123 | } | 126 | } |
| 124 | 127 | ||
| 125 | jbyteArray Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIcon(JNIEnv* env, jobject obj, | 128 | jbyteArray Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIcon(JNIEnv* env, jobject obj, |
| 126 | jstring jpath) { | 129 | jstring jpath) { |
| 127 | auto icon_data = GetRomMetadata(GetJString(env, jpath)).icon; | 130 | auto icon_data = GetRomMetadata(Common::Android::GetJString(env, jpath)).icon; |
| 128 | jbyteArray icon = env->NewByteArray(static_cast<jsize>(icon_data.size())); | 131 | jbyteArray icon = env->NewByteArray(static_cast<jsize>(icon_data.size())); |
| 129 | env->SetByteArrayRegion(icon, 0, env->GetArrayLength(icon), | 132 | env->SetByteArrayRegion(icon, 0, env->GetArrayLength(icon), |
| 130 | reinterpret_cast<jbyte*>(icon_data.data())); | 133 | reinterpret_cast<jbyte*>(icon_data.data())); |
| @@ -133,7 +136,8 @@ jbyteArray Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIcon(JNIEnv* env, jobje | |||
| 133 | 136 | ||
| 134 | jboolean Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIsHomebrew(JNIEnv* env, jobject obj, | 137 | jboolean Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIsHomebrew(JNIEnv* env, jobject obj, |
| 135 | jstring jpath) { | 138 | jstring jpath) { |
| 136 | return static_cast<jboolean>(GetRomMetadata(GetJString(env, jpath)).isHomebrew); | 139 | return static_cast<jboolean>( |
| 140 | GetRomMetadata(Common::Android::GetJString(env, jpath)).isHomebrew); | ||
| 137 | } | 141 | } |
| 138 | 142 | ||
| 139 | void Java_org_yuzu_yuzu_1emu_utils_GameMetadata_resetMetadata(JNIEnv* env, jobject obj) { | 143 | void Java_org_yuzu_yuzu_1emu_utils_GameMetadata_resetMetadata(JNIEnv* env, jobject obj) { |
diff --git a/src/android/app/src/main/jni/id_cache.cpp b/src/android/app/src/main/jni/id_cache.cpp deleted file mode 100644 index f30100bd8..000000000 --- a/src/android/app/src/main/jni/id_cache.cpp +++ /dev/null | |||
| @@ -1,428 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include <jni.h> | ||
| 5 | |||
| 6 | #include "common/assert.h" | ||
| 7 | #include "common/fs/fs_android.h" | ||
| 8 | #include "jni/applets/software_keyboard.h" | ||
| 9 | #include "jni/id_cache.h" | ||
| 10 | #include "video_core/rasterizer_interface.h" | ||
| 11 | |||
| 12 | static JavaVM* s_java_vm; | ||
| 13 | static jclass s_native_library_class; | ||
| 14 | static jclass s_disk_cache_progress_class; | ||
| 15 | static jclass s_load_callback_stage_class; | ||
| 16 | static jclass s_game_dir_class; | ||
| 17 | static jmethodID s_game_dir_constructor; | ||
| 18 | static jmethodID s_exit_emulation_activity; | ||
| 19 | static jmethodID s_disk_cache_load_progress; | ||
| 20 | static jmethodID s_on_emulation_started; | ||
| 21 | static jmethodID s_on_emulation_stopped; | ||
| 22 | static jmethodID s_on_program_changed; | ||
| 23 | |||
| 24 | static jclass s_game_class; | ||
| 25 | static jmethodID s_game_constructor; | ||
| 26 | static jfieldID s_game_title_field; | ||
| 27 | static jfieldID s_game_path_field; | ||
| 28 | static jfieldID s_game_program_id_field; | ||
| 29 | static jfieldID s_game_developer_field; | ||
| 30 | static jfieldID s_game_version_field; | ||
| 31 | static jfieldID s_game_is_homebrew_field; | ||
| 32 | |||
| 33 | static jclass s_string_class; | ||
| 34 | static jclass s_pair_class; | ||
| 35 | static jmethodID s_pair_constructor; | ||
| 36 | static jfieldID s_pair_first_field; | ||
| 37 | static jfieldID s_pair_second_field; | ||
| 38 | |||
| 39 | static jclass s_overlay_control_data_class; | ||
| 40 | static jmethodID s_overlay_control_data_constructor; | ||
| 41 | static jfieldID s_overlay_control_data_id_field; | ||
| 42 | static jfieldID s_overlay_control_data_enabled_field; | ||
| 43 | static jfieldID s_overlay_control_data_landscape_position_field; | ||
| 44 | static jfieldID s_overlay_control_data_portrait_position_field; | ||
| 45 | static jfieldID s_overlay_control_data_foldable_position_field; | ||
| 46 | |||
| 47 | static jclass s_patch_class; | ||
| 48 | static jmethodID s_patch_constructor; | ||
| 49 | static jfieldID s_patch_enabled_field; | ||
| 50 | static jfieldID s_patch_name_field; | ||
| 51 | static jfieldID s_patch_version_field; | ||
| 52 | static jfieldID s_patch_type_field; | ||
| 53 | static jfieldID s_patch_program_id_field; | ||
| 54 | static jfieldID s_patch_title_id_field; | ||
| 55 | |||
| 56 | static jclass s_double_class; | ||
| 57 | static jmethodID s_double_constructor; | ||
| 58 | static jfieldID s_double_value_field; | ||
| 59 | |||
| 60 | static jclass s_integer_class; | ||
| 61 | static jmethodID s_integer_constructor; | ||
| 62 | static jfieldID s_integer_value_field; | ||
| 63 | |||
| 64 | static jclass s_boolean_class; | ||
| 65 | static jmethodID s_boolean_constructor; | ||
| 66 | static jfieldID s_boolean_value_field; | ||
| 67 | |||
| 68 | static constexpr jint JNI_VERSION = JNI_VERSION_1_6; | ||
| 69 | |||
| 70 | namespace IDCache { | ||
| 71 | |||
| 72 | JNIEnv* GetEnvForThread() { | ||
| 73 | thread_local static struct OwnedEnv { | ||
| 74 | OwnedEnv() { | ||
| 75 | status = s_java_vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6); | ||
| 76 | if (status == JNI_EDETACHED) | ||
| 77 | s_java_vm->AttachCurrentThread(&env, nullptr); | ||
| 78 | } | ||
| 79 | |||
| 80 | ~OwnedEnv() { | ||
| 81 | if (status == JNI_EDETACHED) | ||
| 82 | s_java_vm->DetachCurrentThread(); | ||
| 83 | } | ||
| 84 | |||
| 85 | int status; | ||
| 86 | JNIEnv* env = nullptr; | ||
| 87 | } owned; | ||
| 88 | return owned.env; | ||
| 89 | } | ||
| 90 | |||
| 91 | jclass GetNativeLibraryClass() { | ||
| 92 | return s_native_library_class; | ||
| 93 | } | ||
| 94 | |||
| 95 | jclass GetDiskCacheProgressClass() { | ||
| 96 | return s_disk_cache_progress_class; | ||
| 97 | } | ||
| 98 | |||
| 99 | jclass GetDiskCacheLoadCallbackStageClass() { | ||
| 100 | return s_load_callback_stage_class; | ||
| 101 | } | ||
| 102 | |||
| 103 | jclass GetGameDirClass() { | ||
| 104 | return s_game_dir_class; | ||
| 105 | } | ||
| 106 | |||
| 107 | jmethodID GetGameDirConstructor() { | ||
| 108 | return s_game_dir_constructor; | ||
| 109 | } | ||
| 110 | |||
| 111 | jmethodID GetExitEmulationActivity() { | ||
| 112 | return s_exit_emulation_activity; | ||
| 113 | } | ||
| 114 | |||
| 115 | jmethodID GetDiskCacheLoadProgress() { | ||
| 116 | return s_disk_cache_load_progress; | ||
| 117 | } | ||
| 118 | |||
| 119 | jmethodID GetOnEmulationStarted() { | ||
| 120 | return s_on_emulation_started; | ||
| 121 | } | ||
| 122 | |||
| 123 | jmethodID GetOnEmulationStopped() { | ||
| 124 | return s_on_emulation_stopped; | ||
| 125 | } | ||
| 126 | |||
| 127 | jmethodID GetOnProgramChanged() { | ||
| 128 | return s_on_program_changed; | ||
| 129 | } | ||
| 130 | |||
| 131 | jclass GetGameClass() { | ||
| 132 | return s_game_class; | ||
| 133 | } | ||
| 134 | |||
| 135 | jmethodID GetGameConstructor() { | ||
| 136 | return s_game_constructor; | ||
| 137 | } | ||
| 138 | |||
| 139 | jfieldID GetGameTitleField() { | ||
| 140 | return s_game_title_field; | ||
| 141 | } | ||
| 142 | |||
| 143 | jfieldID GetGamePathField() { | ||
| 144 | return s_game_path_field; | ||
| 145 | } | ||
| 146 | |||
| 147 | jfieldID GetGameProgramIdField() { | ||
| 148 | return s_game_program_id_field; | ||
| 149 | } | ||
| 150 | |||
| 151 | jfieldID GetGameDeveloperField() { | ||
| 152 | return s_game_developer_field; | ||
| 153 | } | ||
| 154 | |||
| 155 | jfieldID GetGameVersionField() { | ||
| 156 | return s_game_version_field; | ||
| 157 | } | ||
| 158 | |||
| 159 | jfieldID GetGameIsHomebrewField() { | ||
| 160 | return s_game_is_homebrew_field; | ||
| 161 | } | ||
| 162 | |||
| 163 | jclass GetStringClass() { | ||
| 164 | return s_string_class; | ||
| 165 | } | ||
| 166 | |||
| 167 | jclass GetPairClass() { | ||
| 168 | return s_pair_class; | ||
| 169 | } | ||
| 170 | |||
| 171 | jmethodID GetPairConstructor() { | ||
| 172 | return s_pair_constructor; | ||
| 173 | } | ||
| 174 | |||
| 175 | jfieldID GetPairFirstField() { | ||
| 176 | return s_pair_first_field; | ||
| 177 | } | ||
| 178 | |||
| 179 | jfieldID GetPairSecondField() { | ||
| 180 | return s_pair_second_field; | ||
| 181 | } | ||
| 182 | |||
| 183 | jclass GetOverlayControlDataClass() { | ||
| 184 | return s_overlay_control_data_class; | ||
| 185 | } | ||
| 186 | |||
| 187 | jmethodID GetOverlayControlDataConstructor() { | ||
| 188 | return s_overlay_control_data_constructor; | ||
| 189 | } | ||
| 190 | |||
| 191 | jfieldID GetOverlayControlDataIdField() { | ||
| 192 | return s_overlay_control_data_id_field; | ||
| 193 | } | ||
| 194 | |||
| 195 | jfieldID GetOverlayControlDataEnabledField() { | ||
| 196 | return s_overlay_control_data_enabled_field; | ||
| 197 | } | ||
| 198 | |||
| 199 | jfieldID GetOverlayControlDataLandscapePositionField() { | ||
| 200 | return s_overlay_control_data_landscape_position_field; | ||
| 201 | } | ||
| 202 | |||
| 203 | jfieldID GetOverlayControlDataPortraitPositionField() { | ||
| 204 | return s_overlay_control_data_portrait_position_field; | ||
| 205 | } | ||
| 206 | |||
| 207 | jfieldID GetOverlayControlDataFoldablePositionField() { | ||
| 208 | return s_overlay_control_data_foldable_position_field; | ||
| 209 | } | ||
| 210 | |||
| 211 | jclass GetPatchClass() { | ||
| 212 | return s_patch_class; | ||
| 213 | } | ||
| 214 | |||
| 215 | jmethodID GetPatchConstructor() { | ||
| 216 | return s_patch_constructor; | ||
| 217 | } | ||
| 218 | |||
| 219 | jfieldID GetPatchEnabledField() { | ||
| 220 | return s_patch_enabled_field; | ||
| 221 | } | ||
| 222 | |||
| 223 | jfieldID GetPatchNameField() { | ||
| 224 | return s_patch_name_field; | ||
| 225 | } | ||
| 226 | |||
| 227 | jfieldID GetPatchVersionField() { | ||
| 228 | return s_patch_version_field; | ||
| 229 | } | ||
| 230 | |||
| 231 | jfieldID GetPatchTypeField() { | ||
| 232 | return s_patch_type_field; | ||
| 233 | } | ||
| 234 | |||
| 235 | jfieldID GetPatchProgramIdField() { | ||
| 236 | return s_patch_program_id_field; | ||
| 237 | } | ||
| 238 | |||
| 239 | jfieldID GetPatchTitleIdField() { | ||
| 240 | return s_patch_title_id_field; | ||
| 241 | } | ||
| 242 | |||
| 243 | jclass GetDoubleClass() { | ||
| 244 | return s_double_class; | ||
| 245 | } | ||
| 246 | |||
| 247 | jmethodID GetDoubleConstructor() { | ||
| 248 | return s_double_constructor; | ||
| 249 | } | ||
| 250 | |||
| 251 | jfieldID GetDoubleValueField() { | ||
| 252 | return s_double_value_field; | ||
| 253 | } | ||
| 254 | |||
| 255 | jclass GetIntegerClass() { | ||
| 256 | return s_integer_class; | ||
| 257 | } | ||
| 258 | |||
| 259 | jmethodID GetIntegerConstructor() { | ||
| 260 | return s_integer_constructor; | ||
| 261 | } | ||
| 262 | |||
| 263 | jfieldID GetIntegerValueField() { | ||
| 264 | return s_integer_value_field; | ||
| 265 | } | ||
| 266 | |||
| 267 | jclass GetBooleanClass() { | ||
| 268 | return s_boolean_class; | ||
| 269 | } | ||
| 270 | |||
| 271 | jmethodID GetBooleanConstructor() { | ||
| 272 | return s_boolean_constructor; | ||
| 273 | } | ||
| 274 | |||
| 275 | jfieldID GetBooleanValueField() { | ||
| 276 | return s_boolean_value_field; | ||
| 277 | } | ||
| 278 | |||
| 279 | } // namespace IDCache | ||
| 280 | |||
| 281 | #ifdef __cplusplus | ||
| 282 | extern "C" { | ||
| 283 | #endif | ||
| 284 | |||
| 285 | jint JNI_OnLoad(JavaVM* vm, void* reserved) { | ||
| 286 | s_java_vm = vm; | ||
| 287 | |||
| 288 | JNIEnv* env; | ||
| 289 | if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK) | ||
| 290 | return JNI_ERR; | ||
| 291 | |||
| 292 | // Initialize Java classes | ||
| 293 | const jclass native_library_class = env->FindClass("org/yuzu/yuzu_emu/NativeLibrary"); | ||
| 294 | s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class)); | ||
| 295 | s_disk_cache_progress_class = reinterpret_cast<jclass>(env->NewGlobalRef( | ||
| 296 | env->FindClass("org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress"))); | ||
| 297 | s_load_callback_stage_class = reinterpret_cast<jclass>(env->NewGlobalRef(env->FindClass( | ||
| 298 | "org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress$LoadCallbackStage"))); | ||
| 299 | |||
| 300 | const jclass game_dir_class = env->FindClass("org/yuzu/yuzu_emu/model/GameDir"); | ||
| 301 | s_game_dir_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_dir_class)); | ||
| 302 | s_game_dir_constructor = env->GetMethodID(game_dir_class, "<init>", "(Ljava/lang/String;Z)V"); | ||
| 303 | env->DeleteLocalRef(game_dir_class); | ||
| 304 | |||
| 305 | // Initialize methods | ||
| 306 | s_exit_emulation_activity = | ||
| 307 | env->GetStaticMethodID(s_native_library_class, "exitEmulationActivity", "(I)V"); | ||
| 308 | s_disk_cache_load_progress = | ||
| 309 | env->GetStaticMethodID(s_disk_cache_progress_class, "loadProgress", "(III)V"); | ||
| 310 | s_on_emulation_started = | ||
| 311 | env->GetStaticMethodID(s_native_library_class, "onEmulationStarted", "()V"); | ||
| 312 | s_on_emulation_stopped = | ||
| 313 | env->GetStaticMethodID(s_native_library_class, "onEmulationStopped", "(I)V"); | ||
| 314 | s_on_program_changed = | ||
| 315 | env->GetStaticMethodID(s_native_library_class, "onProgramChanged", "(I)V"); | ||
| 316 | |||
| 317 | const jclass game_class = env->FindClass("org/yuzu/yuzu_emu/model/Game"); | ||
| 318 | s_game_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_class)); | ||
| 319 | s_game_constructor = env->GetMethodID(game_class, "<init>", | ||
| 320 | "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/" | ||
| 321 | "String;Ljava/lang/String;Ljava/lang/String;Z)V"); | ||
| 322 | s_game_title_field = env->GetFieldID(game_class, "title", "Ljava/lang/String;"); | ||
| 323 | s_game_path_field = env->GetFieldID(game_class, "path", "Ljava/lang/String;"); | ||
| 324 | s_game_program_id_field = env->GetFieldID(game_class, "programId", "Ljava/lang/String;"); | ||
| 325 | s_game_developer_field = env->GetFieldID(game_class, "developer", "Ljava/lang/String;"); | ||
| 326 | s_game_version_field = env->GetFieldID(game_class, "version", "Ljava/lang/String;"); | ||
| 327 | s_game_is_homebrew_field = env->GetFieldID(game_class, "isHomebrew", "Z"); | ||
| 328 | env->DeleteLocalRef(game_class); | ||
| 329 | |||
| 330 | const jclass string_class = env->FindClass("java/lang/String"); | ||
| 331 | s_string_class = reinterpret_cast<jclass>(env->NewGlobalRef(string_class)); | ||
| 332 | env->DeleteLocalRef(string_class); | ||
| 333 | |||
| 334 | const jclass pair_class = env->FindClass("kotlin/Pair"); | ||
| 335 | s_pair_class = reinterpret_cast<jclass>(env->NewGlobalRef(pair_class)); | ||
| 336 | s_pair_constructor = | ||
| 337 | env->GetMethodID(pair_class, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V"); | ||
| 338 | s_pair_first_field = env->GetFieldID(pair_class, "first", "Ljava/lang/Object;"); | ||
| 339 | s_pair_second_field = env->GetFieldID(pair_class, "second", "Ljava/lang/Object;"); | ||
| 340 | env->DeleteLocalRef(pair_class); | ||
| 341 | |||
| 342 | const jclass overlay_control_data_class = | ||
| 343 | env->FindClass("org/yuzu/yuzu_emu/overlay/model/OverlayControlData"); | ||
| 344 | s_overlay_control_data_class = | ||
| 345 | reinterpret_cast<jclass>(env->NewGlobalRef(overlay_control_data_class)); | ||
| 346 | s_overlay_control_data_constructor = | ||
| 347 | env->GetMethodID(overlay_control_data_class, "<init>", | ||
| 348 | "(Ljava/lang/String;ZLkotlin/Pair;Lkotlin/Pair;Lkotlin/Pair;)V"); | ||
| 349 | s_overlay_control_data_id_field = | ||
| 350 | env->GetFieldID(overlay_control_data_class, "id", "Ljava/lang/String;"); | ||
| 351 | s_overlay_control_data_enabled_field = | ||
| 352 | env->GetFieldID(overlay_control_data_class, "enabled", "Z"); | ||
| 353 | s_overlay_control_data_landscape_position_field = | ||
| 354 | env->GetFieldID(overlay_control_data_class, "landscapePosition", "Lkotlin/Pair;"); | ||
| 355 | s_overlay_control_data_portrait_position_field = | ||
| 356 | env->GetFieldID(overlay_control_data_class, "portraitPosition", "Lkotlin/Pair;"); | ||
| 357 | s_overlay_control_data_foldable_position_field = | ||
| 358 | env->GetFieldID(overlay_control_data_class, "foldablePosition", "Lkotlin/Pair;"); | ||
| 359 | env->DeleteLocalRef(overlay_control_data_class); | ||
| 360 | |||
| 361 | const jclass patch_class = env->FindClass("org/yuzu/yuzu_emu/model/Patch"); | ||
| 362 | s_patch_class = reinterpret_cast<jclass>(env->NewGlobalRef(patch_class)); | ||
| 363 | s_patch_constructor = env->GetMethodID( | ||
| 364 | patch_class, "<init>", | ||
| 365 | "(ZLjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)V"); | ||
| 366 | s_patch_enabled_field = env->GetFieldID(patch_class, "enabled", "Z"); | ||
| 367 | s_patch_name_field = env->GetFieldID(patch_class, "name", "Ljava/lang/String;"); | ||
| 368 | s_patch_version_field = env->GetFieldID(patch_class, "version", "Ljava/lang/String;"); | ||
| 369 | s_patch_type_field = env->GetFieldID(patch_class, "type", "I"); | ||
| 370 | s_patch_program_id_field = env->GetFieldID(patch_class, "programId", "Ljava/lang/String;"); | ||
| 371 | s_patch_title_id_field = env->GetFieldID(patch_class, "titleId", "Ljava/lang/String;"); | ||
| 372 | env->DeleteLocalRef(patch_class); | ||
| 373 | |||
| 374 | const jclass double_class = env->FindClass("java/lang/Double"); | ||
| 375 | s_double_class = reinterpret_cast<jclass>(env->NewGlobalRef(double_class)); | ||
| 376 | s_double_constructor = env->GetMethodID(double_class, "<init>", "(D)V"); | ||
| 377 | s_double_value_field = env->GetFieldID(double_class, "value", "D"); | ||
| 378 | env->DeleteLocalRef(double_class); | ||
| 379 | |||
| 380 | const jclass int_class = env->FindClass("java/lang/Integer"); | ||
| 381 | s_integer_class = reinterpret_cast<jclass>(env->NewGlobalRef(int_class)); | ||
| 382 | s_integer_constructor = env->GetMethodID(int_class, "<init>", "(I)V"); | ||
| 383 | s_integer_value_field = env->GetFieldID(int_class, "value", "I"); | ||
| 384 | env->DeleteLocalRef(int_class); | ||
| 385 | |||
| 386 | const jclass boolean_class = env->FindClass("java/lang/Boolean"); | ||
| 387 | s_boolean_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_class)); | ||
| 388 | s_boolean_constructor = env->GetMethodID(boolean_class, "<init>", "(Z)V"); | ||
| 389 | s_boolean_value_field = env->GetFieldID(boolean_class, "value", "Z"); | ||
| 390 | env->DeleteLocalRef(boolean_class); | ||
| 391 | |||
| 392 | // Initialize Android Storage | ||
| 393 | Common::FS::Android::RegisterCallbacks(env, s_native_library_class); | ||
| 394 | |||
| 395 | // Initialize applets | ||
| 396 | SoftwareKeyboard::InitJNI(env); | ||
| 397 | |||
| 398 | return JNI_VERSION; | ||
| 399 | } | ||
| 400 | |||
| 401 | void JNI_OnUnload(JavaVM* vm, void* reserved) { | ||
| 402 | JNIEnv* env; | ||
| 403 | if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK) { | ||
| 404 | return; | ||
| 405 | } | ||
| 406 | |||
| 407 | // UnInitialize Android Storage | ||
| 408 | Common::FS::Android::UnRegisterCallbacks(); | ||
| 409 | env->DeleteGlobalRef(s_native_library_class); | ||
| 410 | env->DeleteGlobalRef(s_disk_cache_progress_class); | ||
| 411 | env->DeleteGlobalRef(s_load_callback_stage_class); | ||
| 412 | env->DeleteGlobalRef(s_game_dir_class); | ||
| 413 | env->DeleteGlobalRef(s_game_class); | ||
| 414 | env->DeleteGlobalRef(s_string_class); | ||
| 415 | env->DeleteGlobalRef(s_pair_class); | ||
| 416 | env->DeleteGlobalRef(s_overlay_control_data_class); | ||
| 417 | env->DeleteGlobalRef(s_patch_class); | ||
| 418 | env->DeleteGlobalRef(s_double_class); | ||
| 419 | env->DeleteGlobalRef(s_integer_class); | ||
| 420 | env->DeleteGlobalRef(s_boolean_class); | ||
| 421 | |||
| 422 | // UnInitialize applets | ||
| 423 | SoftwareKeyboard::CleanupJNI(env); | ||
| 424 | } | ||
| 425 | |||
| 426 | #ifdef __cplusplus | ||
| 427 | } | ||
| 428 | #endif | ||
diff --git a/src/android/app/src/main/jni/id_cache.h b/src/android/app/src/main/jni/id_cache.h deleted file mode 100644 index 00e48afc0..000000000 --- a/src/android/app/src/main/jni/id_cache.h +++ /dev/null | |||
| @@ -1,68 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <jni.h> | ||
| 7 | |||
| 8 | #include "video_core/rasterizer_interface.h" | ||
| 9 | |||
| 10 | namespace IDCache { | ||
| 11 | |||
| 12 | JNIEnv* GetEnvForThread(); | ||
| 13 | jclass GetNativeLibraryClass(); | ||
| 14 | jclass GetDiskCacheProgressClass(); | ||
| 15 | jclass GetDiskCacheLoadCallbackStageClass(); | ||
| 16 | jclass GetGameDirClass(); | ||
| 17 | jmethodID GetGameDirConstructor(); | ||
| 18 | jmethodID GetExitEmulationActivity(); | ||
| 19 | jmethodID GetDiskCacheLoadProgress(); | ||
| 20 | jmethodID GetOnEmulationStarted(); | ||
| 21 | jmethodID GetOnEmulationStopped(); | ||
| 22 | jmethodID GetOnProgramChanged(); | ||
| 23 | |||
| 24 | jclass GetGameClass(); | ||
| 25 | jmethodID GetGameConstructor(); | ||
| 26 | jfieldID GetGameTitleField(); | ||
| 27 | jfieldID GetGamePathField(); | ||
| 28 | jfieldID GetGameProgramIdField(); | ||
| 29 | jfieldID GetGameDeveloperField(); | ||
| 30 | jfieldID GetGameVersionField(); | ||
| 31 | jfieldID GetGameIsHomebrewField(); | ||
| 32 | |||
| 33 | jclass GetStringClass(); | ||
| 34 | jclass GetPairClass(); | ||
| 35 | jmethodID GetPairConstructor(); | ||
| 36 | jfieldID GetPairFirstField(); | ||
| 37 | jfieldID GetPairSecondField(); | ||
| 38 | |||
| 39 | jclass GetOverlayControlDataClass(); | ||
| 40 | jmethodID GetOverlayControlDataConstructor(); | ||
| 41 | jfieldID GetOverlayControlDataIdField(); | ||
| 42 | jfieldID GetOverlayControlDataEnabledField(); | ||
| 43 | jfieldID GetOverlayControlDataLandscapePositionField(); | ||
| 44 | jfieldID GetOverlayControlDataPortraitPositionField(); | ||
| 45 | jfieldID GetOverlayControlDataFoldablePositionField(); | ||
| 46 | |||
| 47 | jclass GetPatchClass(); | ||
| 48 | jmethodID GetPatchConstructor(); | ||
| 49 | jfieldID GetPatchEnabledField(); | ||
| 50 | jfieldID GetPatchNameField(); | ||
| 51 | jfieldID GetPatchVersionField(); | ||
| 52 | jfieldID GetPatchTypeField(); | ||
| 53 | jfieldID GetPatchProgramIdField(); | ||
| 54 | jfieldID GetPatchTitleIdField(); | ||
| 55 | |||
| 56 | jclass GetDoubleClass(); | ||
| 57 | jmethodID GetDoubleConstructor(); | ||
| 58 | jfieldID GetDoubleValueField(); | ||
| 59 | |||
| 60 | jclass GetIntegerClass(); | ||
| 61 | jmethodID GetIntegerConstructor(); | ||
| 62 | jfieldID GetIntegerValueField(); | ||
| 63 | |||
| 64 | jclass GetBooleanClass(); | ||
| 65 | jmethodID GetBooleanConstructor(); | ||
| 66 | jfieldID GetBooleanValueField(); | ||
| 67 | |||
| 68 | } // namespace IDCache | ||
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 654510129..4acc60956 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp | |||
| @@ -20,6 +20,8 @@ | |||
| 20 | #include <frontend_common/content_manager.h> | 20 | #include <frontend_common/content_manager.h> |
| 21 | #include <jni.h> | 21 | #include <jni.h> |
| 22 | 22 | ||
| 23 | #include "common/android/android_common.h" | ||
| 24 | #include "common/android/id_cache.h" | ||
| 23 | #include "common/detached_tasks.h" | 25 | #include "common/detached_tasks.h" |
| 24 | #include "common/dynamic_library.h" | 26 | #include "common/dynamic_library.h" |
| 25 | #include "common/fs/path_util.h" | 27 | #include "common/fs/path_util.h" |
| @@ -57,8 +59,6 @@ | |||
| 57 | #include "hid_core/frontend/emulated_controller.h" | 59 | #include "hid_core/frontend/emulated_controller.h" |
| 58 | #include "hid_core/hid_core.h" | 60 | #include "hid_core/hid_core.h" |
| 59 | #include "hid_core/hid_types.h" | 61 | #include "hid_core/hid_types.h" |
| 60 | #include "jni/android_common/android_common.h" | ||
| 61 | #include "jni/id_cache.h" | ||
| 62 | #include "jni/native.h" | 62 | #include "jni/native.h" |
| 63 | #include "video_core/renderer_base.h" | 63 | #include "video_core/renderer_base.h" |
| 64 | #include "video_core/renderer_vulkan/renderer_vulkan.h" | 64 | #include "video_core/renderer_vulkan/renderer_vulkan.h" |
| @@ -228,7 +228,7 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string | |||
| 228 | std::make_unique<EmuWindow_Android>(&m_input_subsystem, m_native_window, m_vulkan_library); | 228 | std::make_unique<EmuWindow_Android>(&m_input_subsystem, m_native_window, m_vulkan_library); |
| 229 | 229 | ||
| 230 | // Initialize system. | 230 | // Initialize system. |
| 231 | jauto android_keyboard = std::make_unique<SoftwareKeyboard::AndroidKeyboard>(); | 231 | jauto android_keyboard = std::make_unique<Common::Android::SoftwareKeyboard::AndroidKeyboard>(); |
| 232 | m_software_keyboard = android_keyboard.get(); | 232 | m_software_keyboard = android_keyboard.get(); |
| 233 | m_system.SetShuttingDown(false); | 233 | m_system.SetShuttingDown(false); |
| 234 | m_system.ApplySettings(); | 234 | m_system.ApplySettings(); |
| @@ -411,37 +411,39 @@ void EmulationSession::OnGamepadDisconnectEvent([[maybe_unused]] int index) { | |||
| 411 | controller->Disconnect(); | 411 | controller->Disconnect(); |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | SoftwareKeyboard::AndroidKeyboard* EmulationSession::SoftwareKeyboard() { | 414 | Common::Android::SoftwareKeyboard::AndroidKeyboard* EmulationSession::SoftwareKeyboard() { |
| 415 | return m_software_keyboard; | 415 | return m_software_keyboard; |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | void EmulationSession::LoadDiskCacheProgress(VideoCore::LoadCallbackStage stage, int progress, | 418 | void EmulationSession::LoadDiskCacheProgress(VideoCore::LoadCallbackStage stage, int progress, |
| 419 | int max) { | 419 | int max) { |
| 420 | JNIEnv* env = IDCache::GetEnvForThread(); | 420 | JNIEnv* env = Common::Android::GetEnvForThread(); |
| 421 | env->CallStaticVoidMethod(IDCache::GetDiskCacheProgressClass(), | 421 | env->CallStaticVoidMethod(Common::Android::GetDiskCacheProgressClass(), |
| 422 | IDCache::GetDiskCacheLoadProgress(), static_cast<jint>(stage), | 422 | Common::Android::GetDiskCacheLoadProgress(), static_cast<jint>(stage), |
| 423 | static_cast<jint>(progress), static_cast<jint>(max)); | 423 | static_cast<jint>(progress), static_cast<jint>(max)); |
| 424 | } | 424 | } |
| 425 | 425 | ||
| 426 | void EmulationSession::OnEmulationStarted() { | 426 | void EmulationSession::OnEmulationStarted() { |
| 427 | JNIEnv* env = IDCache::GetEnvForThread(); | 427 | JNIEnv* env = Common::Android::GetEnvForThread(); |
| 428 | env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetOnEmulationStarted()); | 428 | env->CallStaticVoidMethod(Common::Android::GetNativeLibraryClass(), |
| 429 | Common::Android::GetOnEmulationStarted()); | ||
| 429 | } | 430 | } |
| 430 | 431 | ||
| 431 | void EmulationSession::OnEmulationStopped(Core::SystemResultStatus result) { | 432 | void EmulationSession::OnEmulationStopped(Core::SystemResultStatus result) { |
| 432 | JNIEnv* env = IDCache::GetEnvForThread(); | 433 | JNIEnv* env = Common::Android::GetEnvForThread(); |
| 433 | env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetOnEmulationStopped(), | 434 | env->CallStaticVoidMethod(Common::Android::GetNativeLibraryClass(), |
| 434 | static_cast<jint>(result)); | 435 | Common::Android::GetOnEmulationStopped(), static_cast<jint>(result)); |
| 435 | } | 436 | } |
| 436 | 437 | ||
| 437 | void EmulationSession::ChangeProgram(std::size_t program_index) { | 438 | void EmulationSession::ChangeProgram(std::size_t program_index) { |
| 438 | JNIEnv* env = IDCache::GetEnvForThread(); | 439 | JNIEnv* env = Common::Android::GetEnvForThread(); |
| 439 | env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetOnProgramChanged(), | 440 | env->CallStaticVoidMethod(Common::Android::GetNativeLibraryClass(), |
| 441 | Common::Android::GetOnProgramChanged(), | ||
| 440 | static_cast<jint>(program_index)); | 442 | static_cast<jint>(program_index)); |
| 441 | } | 443 | } |
| 442 | 444 | ||
| 443 | u64 EmulationSession::GetProgramId(JNIEnv* env, jstring jprogramId) { | 445 | u64 EmulationSession::GetProgramId(JNIEnv* env, jstring jprogramId) { |
| 444 | auto program_id_string = GetJString(env, jprogramId); | 446 | auto program_id_string = Common::Android::GetJString(env, jprogramId); |
| 445 | try { | 447 | try { |
| 446 | return std::stoull(program_id_string); | 448 | return std::stoull(program_id_string); |
| 447 | } catch (...) { | 449 | } catch (...) { |
| @@ -491,7 +493,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_surfaceDestroyed(JNIEnv* env, jobject | |||
| 491 | 493 | ||
| 492 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setAppDirectory(JNIEnv* env, jobject instance, | 494 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setAppDirectory(JNIEnv* env, jobject instance, |
| 493 | [[maybe_unused]] jstring j_directory) { | 495 | [[maybe_unused]] jstring j_directory) { |
| 494 | Common::FS::SetAppDirectory(GetJString(env, j_directory)); | 496 | Common::FS::SetAppDirectory(Common::Android::GetJString(env, j_directory)); |
| 495 | } | 497 | } |
| 496 | 498 | ||
| 497 | int Java_org_yuzu_yuzu_1emu_NativeLibrary_installFileToNand(JNIEnv* env, jobject instance, | 499 | int Java_org_yuzu_yuzu_1emu_NativeLibrary_installFileToNand(JNIEnv* env, jobject instance, |
| @@ -501,21 +503,22 @@ int Java_org_yuzu_yuzu_1emu_NativeLibrary_installFileToNand(JNIEnv* env, jobject | |||
| 501 | jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); | 503 | jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); |
| 502 | const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) { | 504 | const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) { |
| 503 | auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod, | 505 | auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod, |
| 504 | ToJDouble(env, max), ToJDouble(env, progress)); | 506 | Common::Android::ToJDouble(env, max), |
| 505 | return GetJBoolean(env, jwasCancelled); | 507 | Common::Android::ToJDouble(env, progress)); |
| 508 | return Common::Android::GetJBoolean(env, jwasCancelled); | ||
| 506 | }; | 509 | }; |
| 507 | 510 | ||
| 508 | return static_cast<int>( | 511 | return static_cast<int>( |
| 509 | ContentManager::InstallNSP(EmulationSession::GetInstance().System(), | 512 | ContentManager::InstallNSP(EmulationSession::GetInstance().System(), |
| 510 | *EmulationSession::GetInstance().System().GetFilesystem(), | 513 | *EmulationSession::GetInstance().System().GetFilesystem(), |
| 511 | GetJString(env, j_file), callback)); | 514 | Common::Android::GetJString(env, j_file), callback)); |
| 512 | } | 515 | } |
| 513 | 516 | ||
| 514 | jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_doesUpdateMatchProgram(JNIEnv* env, jobject jobj, | 517 | jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_doesUpdateMatchProgram(JNIEnv* env, jobject jobj, |
| 515 | jstring jprogramId, | 518 | jstring jprogramId, |
| 516 | jstring jupdatePath) { | 519 | jstring jupdatePath) { |
| 517 | u64 program_id = EmulationSession::GetProgramId(env, jprogramId); | 520 | u64 program_id = EmulationSession::GetProgramId(env, jprogramId); |
| 518 | std::string updatePath = GetJString(env, jupdatePath); | 521 | std::string updatePath = Common::Android::GetJString(env, jupdatePath); |
| 519 | std::shared_ptr<FileSys::NSP> nsp = std::make_shared<FileSys::NSP>( | 522 | std::shared_ptr<FileSys::NSP> nsp = std::make_shared<FileSys::NSP>( |
| 520 | EmulationSession::GetInstance().System().GetFilesystem()->OpenFile( | 523 | EmulationSession::GetInstance().System().GetFilesystem()->OpenFile( |
| 521 | updatePath, FileSys::OpenMode::Read)); | 524 | updatePath, FileSys::OpenMode::Read)); |
| @@ -538,8 +541,10 @@ void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeGpuDriver(JNIEnv* e | |||
| 538 | jstring custom_driver_name, | 541 | jstring custom_driver_name, |
| 539 | jstring file_redirect_dir) { | 542 | jstring file_redirect_dir) { |
| 540 | EmulationSession::GetInstance().InitializeGpuDriver( | 543 | EmulationSession::GetInstance().InitializeGpuDriver( |
| 541 | GetJString(env, hook_lib_dir), GetJString(env, custom_driver_dir), | 544 | Common::Android::GetJString(env, hook_lib_dir), |
| 542 | GetJString(env, custom_driver_name), GetJString(env, file_redirect_dir)); | 545 | Common::Android::GetJString(env, custom_driver_dir), |
| 546 | Common::Android::GetJString(env, custom_driver_name), | ||
| 547 | Common::Android::GetJString(env, file_redirect_dir)); | ||
| 543 | } | 548 | } |
| 544 | 549 | ||
| 545 | [[maybe_unused]] static bool CheckKgslPresent() { | 550 | [[maybe_unused]] static bool CheckKgslPresent() { |
| @@ -566,7 +571,7 @@ jobjectArray Java_org_yuzu_yuzu_1emu_utils_GpuDriverHelper_getSystemDriverInfo( | |||
| 566 | JNIEnv* env, jobject j_obj, jobject j_surf, jstring j_hook_lib_dir) { | 571 | JNIEnv* env, jobject j_obj, jobject j_surf, jstring j_hook_lib_dir) { |
| 567 | const char* file_redirect_dir_{}; | 572 | const char* file_redirect_dir_{}; |
| 568 | int featureFlags{}; | 573 | int featureFlags{}; |
| 569 | std::string hook_lib_dir = GetJString(env, j_hook_lib_dir); | 574 | std::string hook_lib_dir = Common::Android::GetJString(env, j_hook_lib_dir); |
| 570 | auto handle = adrenotools_open_libvulkan(RTLD_NOW, featureFlags, nullptr, hook_lib_dir.c_str(), | 575 | auto handle = adrenotools_open_libvulkan(RTLD_NOW, featureFlags, nullptr, hook_lib_dir.c_str(), |
| 571 | nullptr, nullptr, file_redirect_dir_, nullptr); | 576 | nullptr, nullptr, file_redirect_dir_, nullptr); |
| 572 | auto driver_library = std::make_shared<Common::DynamicLibrary>(handle); | 577 | auto driver_library = std::make_shared<Common::DynamicLibrary>(handle); |
| @@ -587,9 +592,10 @@ jobjectArray Java_org_yuzu_yuzu_1emu_utils_GpuDriverHelper_getSystemDriverInfo( | |||
| 587 | fmt::format("{}.{}.{}", VK_API_VERSION_MAJOR(driver_version), | 592 | fmt::format("{}.{}.{}", VK_API_VERSION_MAJOR(driver_version), |
| 588 | VK_API_VERSION_MINOR(driver_version), VK_API_VERSION_PATCH(driver_version)); | 593 | VK_API_VERSION_MINOR(driver_version), VK_API_VERSION_PATCH(driver_version)); |
| 589 | 594 | ||
| 590 | jobjectArray j_driver_info = | 595 | jobjectArray j_driver_info = env->NewObjectArray( |
| 591 | env->NewObjectArray(2, IDCache::GetStringClass(), ToJString(env, version_string)); | 596 | 2, Common::Android::GetStringClass(), Common::Android::ToJString(env, version_string)); |
| 592 | env->SetObjectArrayElement(j_driver_info, 1, ToJString(env, device.GetDriverName())); | 597 | env->SetObjectArrayElement(j_driver_info, 1, |
| 598 | Common::Android::ToJString(env, device.GetDriverName())); | ||
| 593 | return j_driver_info; | 599 | return j_driver_info; |
| 594 | } | 600 | } |
| 595 | 601 | ||
| @@ -742,15 +748,15 @@ jdoubleArray Java_org_yuzu_yuzu_1emu_NativeLibrary_getPerfStats(JNIEnv* env, jcl | |||
| 742 | 748 | ||
| 743 | jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getCpuBackend(JNIEnv* env, jclass clazz) { | 749 | jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getCpuBackend(JNIEnv* env, jclass clazz) { |
| 744 | if (Settings::IsNceEnabled()) { | 750 | if (Settings::IsNceEnabled()) { |
| 745 | return ToJString(env, "NCE"); | 751 | return Common::Android::ToJString(env, "NCE"); |
| 746 | } | 752 | } |
| 747 | 753 | ||
| 748 | return ToJString(env, "JIT"); | 754 | return Common::Android::ToJString(env, "JIT"); |
| 749 | } | 755 | } |
| 750 | 756 | ||
| 751 | jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getGpuDriver(JNIEnv* env, jobject jobj) { | 757 | jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getGpuDriver(JNIEnv* env, jobject jobj) { |
| 752 | return ToJString(env, | 758 | return Common::Android::ToJString( |
| 753 | EmulationSession::GetInstance().System().GPU().Renderer().GetDeviceVendor()); | 759 | env, EmulationSession::GetInstance().System().GPU().Renderer().GetDeviceVendor()); |
| 754 | } | 760 | } |
| 755 | 761 | ||
| 756 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_applySettings(JNIEnv* env, jobject jobj) { | 762 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_applySettings(JNIEnv* env, jobject jobj) { |
| @@ -764,13 +770,14 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_logSettings(JNIEnv* env, jobject jobj | |||
| 764 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstring j_path, | 770 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstring j_path, |
| 765 | jint j_program_index, | 771 | jint j_program_index, |
| 766 | jboolean j_frontend_initiated) { | 772 | jboolean j_frontend_initiated) { |
| 767 | const std::string path = GetJString(env, j_path); | 773 | const std::string path = Common::Android::GetJString(env, j_path); |
| 768 | 774 | ||
| 769 | const Core::SystemResultStatus result{ | 775 | const Core::SystemResultStatus result{ |
| 770 | RunEmulation(path, j_program_index, j_frontend_initiated)}; | 776 | RunEmulation(path, j_program_index, j_frontend_initiated)}; |
| 771 | if (result != Core::SystemResultStatus::Success) { | 777 | if (result != Core::SystemResultStatus::Success) { |
| 772 | env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), | 778 | env->CallStaticVoidMethod(Common::Android::GetNativeLibraryClass(), |
| 773 | IDCache::GetExitEmulationActivity(), static_cast<int>(result)); | 779 | Common::Android::GetExitEmulationActivity(), |
| 780 | static_cast<int>(result)); | ||
| 774 | } | 781 | } |
| 775 | } | 782 | } |
| 776 | 783 | ||
| @@ -781,7 +788,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_logDeviceInfo(JNIEnv* env, jclass cla | |||
| 781 | 788 | ||
| 782 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_submitInlineKeyboardText(JNIEnv* env, jclass clazz, | 789 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_submitInlineKeyboardText(JNIEnv* env, jclass clazz, |
| 783 | jstring j_text) { | 790 | jstring j_text) { |
| 784 | const std::u16string input = Common::UTF8ToUTF16(GetJString(env, j_text)); | 791 | const std::u16string input = Common::UTF8ToUTF16(Common::Android::GetJString(env, j_text)); |
| 785 | EmulationSession::GetInstance().SoftwareKeyboard()->SubmitInlineKeyboardText(input); | 792 | EmulationSession::GetInstance().SoftwareKeyboard()->SubmitInlineKeyboardText(input); |
| 786 | } | 793 | } |
| 787 | 794 | ||
| @@ -815,16 +822,16 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getAppletLaunchPath(JNIEnv* env, j | |||
| 815 | auto bis_system = | 822 | auto bis_system = |
| 816 | EmulationSession::GetInstance().System().GetFileSystemController().GetSystemNANDContents(); | 823 | EmulationSession::GetInstance().System().GetFileSystemController().GetSystemNANDContents(); |
| 817 | if (!bis_system) { | 824 | if (!bis_system) { |
| 818 | return ToJString(env, ""); | 825 | return Common::Android::ToJString(env, ""); |
| 819 | } | 826 | } |
| 820 | 827 | ||
| 821 | auto applet_nca = | 828 | auto applet_nca = |
| 822 | bis_system->GetEntry(static_cast<u64>(jid), FileSys::ContentRecordType::Program); | 829 | bis_system->GetEntry(static_cast<u64>(jid), FileSys::ContentRecordType::Program); |
| 823 | if (!applet_nca) { | 830 | if (!applet_nca) { |
| 824 | return ToJString(env, ""); | 831 | return Common::Android::ToJString(env, ""); |
| 825 | } | 832 | } |
| 826 | 833 | ||
| 827 | return ToJString(env, applet_nca->GetFullPath()); | 834 | return Common::Android::ToJString(env, applet_nca->GetFullPath()); |
| 828 | } | 835 | } |
| 829 | 836 | ||
| 830 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCurrentAppletId(JNIEnv* env, jclass clazz, | 837 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCurrentAppletId(JNIEnv* env, jclass clazz, |
| @@ -857,7 +864,7 @@ jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_isFirmwareAvailable(JNIEnv* env, | |||
| 857 | jobjectArray Java_org_yuzu_yuzu_1emu_NativeLibrary_getPatchesForFile(JNIEnv* env, jobject jobj, | 864 | jobjectArray Java_org_yuzu_yuzu_1emu_NativeLibrary_getPatchesForFile(JNIEnv* env, jobject jobj, |
| 858 | jstring jpath, | 865 | jstring jpath, |
| 859 | jstring jprogramId) { | 866 | jstring jprogramId) { |
| 860 | const auto path = GetJString(env, jpath); | 867 | const auto path = Common::Android::GetJString(env, jpath); |
| 861 | const auto vFile = | 868 | const auto vFile = |
| 862 | Core::GetGameFileFromPath(EmulationSession::GetInstance().System().GetFilesystem(), path); | 869 | Core::GetGameFileFromPath(EmulationSession::GetInstance().System().GetFilesystem(), path); |
| 863 | if (vFile == nullptr) { | 870 | if (vFile == nullptr) { |
| @@ -875,14 +882,15 @@ jobjectArray Java_org_yuzu_yuzu_1emu_NativeLibrary_getPatchesForFile(JNIEnv* env | |||
| 875 | 882 | ||
| 876 | auto patches = pm.GetPatches(update_raw); | 883 | auto patches = pm.GetPatches(update_raw); |
| 877 | jobjectArray jpatchArray = | 884 | jobjectArray jpatchArray = |
| 878 | env->NewObjectArray(patches.size(), IDCache::GetPatchClass(), nullptr); | 885 | env->NewObjectArray(patches.size(), Common::Android::GetPatchClass(), nullptr); |
| 879 | int i = 0; | 886 | int i = 0; |
| 880 | for (const auto& patch : patches) { | 887 | for (const auto& patch : patches) { |
| 881 | jobject jpatch = env->NewObject( | 888 | jobject jpatch = env->NewObject( |
| 882 | IDCache::GetPatchClass(), IDCache::GetPatchConstructor(), patch.enabled, | 889 | Common::Android::GetPatchClass(), Common::Android::GetPatchConstructor(), patch.enabled, |
| 883 | ToJString(env, patch.name), ToJString(env, patch.version), | 890 | Common::Android::ToJString(env, patch.name), |
| 884 | static_cast<jint>(patch.type), ToJString(env, std::to_string(patch.program_id)), | 891 | Common::Android::ToJString(env, patch.version), static_cast<jint>(patch.type), |
| 885 | ToJString(env, std::to_string(patch.title_id))); | 892 | Common::Android::ToJString(env, std::to_string(patch.program_id)), |
| 893 | Common::Android::ToJString(env, std::to_string(patch.title_id))); | ||
| 886 | env->SetObjectArrayElement(jpatchArray, i, jpatch); | 894 | env->SetObjectArrayElement(jpatchArray, i, jpatch); |
| 887 | ++i; | 895 | ++i; |
| 888 | } | 896 | } |
| @@ -906,7 +914,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_removeMod(JNIEnv* env, jobject jobj, | |||
| 906 | jstring jname) { | 914 | jstring jname) { |
| 907 | auto program_id = EmulationSession::GetProgramId(env, jprogramId); | 915 | auto program_id = EmulationSession::GetProgramId(env, jprogramId); |
| 908 | ContentManager::RemoveMod(EmulationSession::GetInstance().System().GetFileSystemController(), | 916 | ContentManager::RemoveMod(EmulationSession::GetInstance().System().GetFileSystemController(), |
| 909 | program_id, GetJString(env, jname)); | 917 | program_id, Common::Android::GetJString(env, jname)); |
| 910 | } | 918 | } |
| 911 | 919 | ||
| 912 | jobjectArray Java_org_yuzu_yuzu_1emu_NativeLibrary_verifyInstalledContents(JNIEnv* env, | 920 | jobjectArray Java_org_yuzu_yuzu_1emu_NativeLibrary_verifyInstalledContents(JNIEnv* env, |
| @@ -917,17 +925,18 @@ jobjectArray Java_org_yuzu_yuzu_1emu_NativeLibrary_verifyInstalledContents(JNIEn | |||
| 917 | jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); | 925 | jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); |
| 918 | const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) { | 926 | const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) { |
| 919 | auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod, | 927 | auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod, |
| 920 | ToJDouble(env, max), ToJDouble(env, progress)); | 928 | Common::Android::ToJDouble(env, max), |
| 921 | return GetJBoolean(env, jwasCancelled); | 929 | Common::Android::ToJDouble(env, progress)); |
| 930 | return Common::Android::GetJBoolean(env, jwasCancelled); | ||
| 922 | }; | 931 | }; |
| 923 | 932 | ||
| 924 | auto& session = EmulationSession::GetInstance(); | 933 | auto& session = EmulationSession::GetInstance(); |
| 925 | std::vector<std::string> result = ContentManager::VerifyInstalledContents( | 934 | std::vector<std::string> result = ContentManager::VerifyInstalledContents( |
| 926 | session.System(), *session.GetContentProvider(), callback); | 935 | session.System(), *session.GetContentProvider(), callback); |
| 927 | jobjectArray jresult = | 936 | jobjectArray jresult = env->NewObjectArray(result.size(), Common::Android::GetStringClass(), |
| 928 | env->NewObjectArray(result.size(), IDCache::GetStringClass(), ToJString(env, "")); | 937 | Common::Android::ToJString(env, "")); |
| 929 | for (size_t i = 0; i < result.size(); ++i) { | 938 | for (size_t i = 0; i < result.size(); ++i) { |
| 930 | env->SetObjectArrayElement(jresult, i, ToJString(env, result[i])); | 939 | env->SetObjectArrayElement(jresult, i, Common::Android::ToJString(env, result[i])); |
| 931 | } | 940 | } |
| 932 | return jresult; | 941 | return jresult; |
| 933 | } | 942 | } |
| @@ -939,19 +948,20 @@ jint Java_org_yuzu_yuzu_1emu_NativeLibrary_verifyGameContents(JNIEnv* env, jobje | |||
| 939 | jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); | 948 | jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); |
| 940 | const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) { | 949 | const auto callback = [env, jcallback, jlambdaInvokeMethod](size_t max, size_t progress) { |
| 941 | auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod, | 950 | auto jwasCancelled = env->CallObjectMethod(jcallback, jlambdaInvokeMethod, |
| 942 | ToJDouble(env, max), ToJDouble(env, progress)); | 951 | Common::Android::ToJDouble(env, max), |
| 943 | return GetJBoolean(env, jwasCancelled); | 952 | Common::Android::ToJDouble(env, progress)); |
| 953 | return Common::Android::GetJBoolean(env, jwasCancelled); | ||
| 944 | }; | 954 | }; |
| 945 | auto& session = EmulationSession::GetInstance(); | 955 | auto& session = EmulationSession::GetInstance(); |
| 946 | return static_cast<jint>( | 956 | return static_cast<jint>(ContentManager::VerifyGameContents( |
| 947 | ContentManager::VerifyGameContents(session.System(), GetJString(env, jpath), callback)); | 957 | session.System(), Common::Android::GetJString(env, jpath), callback)); |
| 948 | } | 958 | } |
| 949 | 959 | ||
| 950 | jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getSavePath(JNIEnv* env, jobject jobj, | 960 | jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getSavePath(JNIEnv* env, jobject jobj, |
| 951 | jstring jprogramId) { | 961 | jstring jprogramId) { |
| 952 | auto program_id = EmulationSession::GetProgramId(env, jprogramId); | 962 | auto program_id = EmulationSession::GetProgramId(env, jprogramId); |
| 953 | if (program_id == 0) { | 963 | if (program_id == 0) { |
| 954 | return ToJString(env, ""); | 964 | return Common::Android::ToJString(env, ""); |
| 955 | } | 965 | } |
| 956 | 966 | ||
| 957 | auto& system = EmulationSession::GetInstance().System(); | 967 | auto& system = EmulationSession::GetInstance().System(); |
| @@ -968,7 +978,7 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getSavePath(JNIEnv* env, jobject j | |||
| 968 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( | 978 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( |
| 969 | {}, vfsNandDir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, | 979 | {}, vfsNandDir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, |
| 970 | program_id, user_id->AsU128(), 0); | 980 | program_id, user_id->AsU128(), 0); |
| 971 | return ToJString(env, user_save_data_path); | 981 | return Common::Android::ToJString(env, user_save_data_path); |
| 972 | } | 982 | } |
| 973 | 983 | ||
| 974 | jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getDefaultProfileSaveDataRoot(JNIEnv* env, | 984 | jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getDefaultProfileSaveDataRoot(JNIEnv* env, |
| @@ -981,12 +991,13 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getDefaultProfileSaveDataRoot(JNIE | |||
| 981 | 991 | ||
| 982 | const auto user_save_data_root = | 992 | const auto user_save_data_root = |
| 983 | FileSys::SaveDataFactory::GetUserGameSaveDataRoot(user_id->AsU128(), jfuture); | 993 | FileSys::SaveDataFactory::GetUserGameSaveDataRoot(user_id->AsU128(), jfuture); |
| 984 | return ToJString(env, user_save_data_root); | 994 | return Common::Android::ToJString(env, user_save_data_root); |
| 985 | } | 995 | } |
| 986 | 996 | ||
| 987 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_addFileToFilesystemProvider(JNIEnv* env, jobject jobj, | 997 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_addFileToFilesystemProvider(JNIEnv* env, jobject jobj, |
| 988 | jstring jpath) { | 998 | jstring jpath) { |
| 989 | EmulationSession::GetInstance().ConfigureFilesystemProvider(GetJString(env, jpath)); | 999 | EmulationSession::GetInstance().ConfigureFilesystemProvider( |
| 1000 | Common::Android::GetJString(env, jpath)); | ||
| 990 | } | 1001 | } |
| 991 | 1002 | ||
| 992 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_clearFilesystemProvider(JNIEnv* env, jobject jobj) { | 1003 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_clearFilesystemProvider(JNIEnv* env, jobject jobj) { |
diff --git a/src/android/app/src/main/jni/native.h b/src/android/app/src/main/jni/native.h index e49d4e015..47936e305 100644 --- a/src/android/app/src/main/jni/native.h +++ b/src/android/app/src/main/jni/native.h | |||
| @@ -2,13 +2,13 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <android/native_window_jni.h> | 4 | #include <android/native_window_jni.h> |
| 5 | #include "common/android/applets/software_keyboard.h" | ||
| 5 | #include "common/detached_tasks.h" | 6 | #include "common/detached_tasks.h" |
| 6 | #include "core/core.h" | 7 | #include "core/core.h" |
| 7 | #include "core/file_sys/registered_cache.h" | 8 | #include "core/file_sys/registered_cache.h" |
| 8 | #include "core/hle/service/acc/profile_manager.h" | 9 | #include "core/hle/service/acc/profile_manager.h" |
| 9 | #include "core/perf_stats.h" | 10 | #include "core/perf_stats.h" |
| 10 | #include "frontend_common/content_manager.h" | 11 | #include "frontend_common/content_manager.h" |
| 11 | #include "jni/applets/software_keyboard.h" | ||
| 12 | #include "jni/emu_window/emu_window.h" | 12 | #include "jni/emu_window/emu_window.h" |
| 13 | #include "video_core/rasterizer_interface.h" | 13 | #include "video_core/rasterizer_interface.h" |
| 14 | 14 | ||
| @@ -54,7 +54,7 @@ public: | |||
| 54 | void SetDeviceType([[maybe_unused]] int index, int type); | 54 | void SetDeviceType([[maybe_unused]] int index, int type); |
| 55 | void OnGamepadConnectEvent([[maybe_unused]] int index); | 55 | void OnGamepadConnectEvent([[maybe_unused]] int index); |
| 56 | void OnGamepadDisconnectEvent([[maybe_unused]] int index); | 56 | void OnGamepadDisconnectEvent([[maybe_unused]] int index); |
| 57 | SoftwareKeyboard::AndroidKeyboard* SoftwareKeyboard(); | 57 | Common::Android::SoftwareKeyboard::AndroidKeyboard* SoftwareKeyboard(); |
| 58 | 58 | ||
| 59 | static void OnEmulationStarted(); | 59 | static void OnEmulationStarted(); |
| 60 | 60 | ||
| @@ -79,7 +79,7 @@ private: | |||
| 79 | Core::SystemResultStatus m_load_result{Core::SystemResultStatus::ErrorNotInitialized}; | 79 | Core::SystemResultStatus m_load_result{Core::SystemResultStatus::ErrorNotInitialized}; |
| 80 | std::atomic<bool> m_is_running = false; | 80 | std::atomic<bool> m_is_running = false; |
| 81 | std::atomic<bool> m_is_paused = false; | 81 | std::atomic<bool> m_is_paused = false; |
| 82 | SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; | 82 | Common::Android::SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; |
| 83 | std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider; | 83 | std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider; |
| 84 | int m_applet_id{1}; | 84 | int m_applet_id{1}; |
| 85 | 85 | ||
diff --git a/src/android/app/src/main/jni/native_config.cpp b/src/android/app/src/main/jni/native_config.cpp index c6c3343dc..8ae10fbc7 100644 --- a/src/android/app/src/main/jni/native_config.cpp +++ b/src/android/app/src/main/jni/native_config.cpp | |||
| @@ -8,11 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | #include "android_config.h" | 9 | #include "android_config.h" |
| 10 | #include "android_settings.h" | 10 | #include "android_settings.h" |
| 11 | #include "common/android/android_common.h" | ||
| 12 | #include "common/android/id_cache.h" | ||
| 11 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 12 | #include "common/settings.h" | 14 | #include "common/settings.h" |
| 13 | #include "frontend_common/config.h" | 15 | #include "frontend_common/config.h" |
| 14 | #include "jni/android_common/android_common.h" | ||
| 15 | #include "jni/id_cache.h" | ||
| 16 | #include "native.h" | 16 | #include "native.h" |
| 17 | 17 | ||
| 18 | std::unique_ptr<AndroidConfig> global_config; | 18 | std::unique_ptr<AndroidConfig> global_config; |
| @@ -20,7 +20,7 @@ std::unique_ptr<AndroidConfig> per_game_config; | |||
| 20 | 20 | ||
| 21 | template <typename T> | 21 | template <typename T> |
| 22 | Settings::Setting<T>* getSetting(JNIEnv* env, jstring jkey) { | 22 | Settings::Setting<T>* getSetting(JNIEnv* env, jstring jkey) { |
| 23 | auto key = GetJString(env, jkey); | 23 | auto key = Common::Android::GetJString(env, jkey); |
| 24 | auto basic_setting = Settings::values.linkage.by_key[key]; | 24 | auto basic_setting = Settings::values.linkage.by_key[key]; |
| 25 | if (basic_setting != 0) { | 25 | if (basic_setting != 0) { |
| 26 | return static_cast<Settings::Setting<T>*>(basic_setting); | 26 | return static_cast<Settings::Setting<T>*>(basic_setting); |
| @@ -55,7 +55,7 @@ void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_initializePerGameConfig(JNIEnv* | |||
| 55 | jstring jprogramId, | 55 | jstring jprogramId, |
| 56 | jstring jfileName) { | 56 | jstring jfileName) { |
| 57 | auto program_id = EmulationSession::GetProgramId(env, jprogramId); | 57 | auto program_id = EmulationSession::GetProgramId(env, jprogramId); |
| 58 | auto file_name = GetJString(env, jfileName); | 58 | auto file_name = Common::Android::GetJString(env, jfileName); |
| 59 | const auto config_file_name = program_id == 0 ? file_name : fmt::format("{:016X}", program_id); | 59 | const auto config_file_name = program_id == 0 ? file_name : fmt::format("{:016X}", program_id); |
| 60 | per_game_config = | 60 | per_game_config = |
| 61 | std::make_unique<AndroidConfig>(config_file_name, Config::ConfigType::PerGameConfig); | 61 | std::make_unique<AndroidConfig>(config_file_name, Config::ConfigType::PerGameConfig); |
| @@ -186,9 +186,9 @@ jstring Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getString(JNIEnv* env, jobjec | |||
| 186 | jboolean needGlobal) { | 186 | jboolean needGlobal) { |
| 187 | auto setting = getSetting<std::string>(env, jkey); | 187 | auto setting = getSetting<std::string>(env, jkey); |
| 188 | if (setting == nullptr) { | 188 | if (setting == nullptr) { |
| 189 | return ToJString(env, ""); | 189 | return Common::Android::ToJString(env, ""); |
| 190 | } | 190 | } |
| 191 | return ToJString(env, setting->GetValue(static_cast<bool>(needGlobal))); | 191 | return Common::Android::ToJString(env, setting->GetValue(static_cast<bool>(needGlobal))); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_setString(JNIEnv* env, jobject obj, jstring jkey, | 194 | void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_setString(JNIEnv* env, jobject obj, jstring jkey, |
| @@ -198,7 +198,7 @@ void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_setString(JNIEnv* env, jobject o | |||
| 198 | return; | 198 | return; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | setting->SetValue(GetJString(env, value)); | 201 | setting->SetValue(Common::Android::GetJString(env, value)); |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getIsRuntimeModifiable(JNIEnv* env, jobject obj, | 204 | jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getIsRuntimeModifiable(JNIEnv* env, jobject obj, |
| @@ -214,13 +214,13 @@ jstring Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getPairedSettingKey(JNIEnv* e | |||
| 214 | jstring jkey) { | 214 | jstring jkey) { |
| 215 | auto setting = getSetting<std::string>(env, jkey); | 215 | auto setting = getSetting<std::string>(env, jkey); |
| 216 | if (setting == nullptr) { | 216 | if (setting == nullptr) { |
| 217 | return ToJString(env, ""); | 217 | return Common::Android::ToJString(env, ""); |
| 218 | } | 218 | } |
| 219 | if (setting->PairedSetting() == nullptr) { | 219 | if (setting->PairedSetting() == nullptr) { |
| 220 | return ToJString(env, ""); | 220 | return Common::Android::ToJString(env, ""); |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | return ToJString(env, setting->PairedSetting()->GetLabel()); | 223 | return Common::Android::ToJString(env, setting->PairedSetting()->GetLabel()); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getIsSwitchable(JNIEnv* env, jobject obj, | 226 | jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getIsSwitchable(JNIEnv* env, jobject obj, |
| @@ -262,21 +262,21 @@ jstring Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getDefaultToString(JNIEnv* en | |||
| 262 | jstring jkey) { | 262 | jstring jkey) { |
| 263 | auto setting = getSetting<std::string>(env, jkey); | 263 | auto setting = getSetting<std::string>(env, jkey); |
| 264 | if (setting != nullptr) { | 264 | if (setting != nullptr) { |
| 265 | return ToJString(env, setting->DefaultToString()); | 265 | return Common::Android::ToJString(env, setting->DefaultToString()); |
| 266 | } | 266 | } |
| 267 | return ToJString(env, ""); | 267 | return Common::Android::ToJString(env, ""); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | jobjectArray Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getGameDirs(JNIEnv* env, jobject obj) { | 270 | jobjectArray Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getGameDirs(JNIEnv* env, jobject obj) { |
| 271 | jclass gameDirClass = IDCache::GetGameDirClass(); | 271 | jclass gameDirClass = Common::Android::GetGameDirClass(); |
| 272 | jmethodID gameDirConstructor = IDCache::GetGameDirConstructor(); | 272 | jmethodID gameDirConstructor = Common::Android::GetGameDirConstructor(); |
| 273 | jobjectArray jgameDirArray = | 273 | jobjectArray jgameDirArray = |
| 274 | env->NewObjectArray(AndroidSettings::values.game_dirs.size(), gameDirClass, nullptr); | 274 | env->NewObjectArray(AndroidSettings::values.game_dirs.size(), gameDirClass, nullptr); |
| 275 | for (size_t i = 0; i < AndroidSettings::values.game_dirs.size(); ++i) { | 275 | for (size_t i = 0; i < AndroidSettings::values.game_dirs.size(); ++i) { |
| 276 | jobject jgameDir = | 276 | jobject jgameDir = env->NewObject( |
| 277 | env->NewObject(gameDirClass, gameDirConstructor, | 277 | gameDirClass, gameDirConstructor, |
| 278 | ToJString(env, AndroidSettings::values.game_dirs[i].path), | 278 | Common::Android::ToJString(env, AndroidSettings::values.game_dirs[i].path), |
| 279 | static_cast<jboolean>(AndroidSettings::values.game_dirs[i].deep_scan)); | 279 | static_cast<jboolean>(AndroidSettings::values.game_dirs[i].deep_scan)); |
| 280 | env->SetObjectArrayElement(jgameDirArray, i, jgameDir); | 280 | env->SetObjectArrayElement(jgameDirArray, i, jgameDir); |
| 281 | } | 281 | } |
| 282 | return jgameDirArray; | 282 | return jgameDirArray; |
| @@ -292,14 +292,14 @@ void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_setGameDirs(JNIEnv* env, jobject | |||
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | jobject dir = env->GetObjectArrayElement(gameDirs, 0); | 294 | jobject dir = env->GetObjectArrayElement(gameDirs, 0); |
| 295 | jclass gameDirClass = IDCache::GetGameDirClass(); | 295 | jclass gameDirClass = Common::Android::GetGameDirClass(); |
| 296 | jfieldID uriStringField = env->GetFieldID(gameDirClass, "uriString", "Ljava/lang/String;"); | 296 | jfieldID uriStringField = env->GetFieldID(gameDirClass, "uriString", "Ljava/lang/String;"); |
| 297 | jfieldID deepScanBooleanField = env->GetFieldID(gameDirClass, "deepScan", "Z"); | 297 | jfieldID deepScanBooleanField = env->GetFieldID(gameDirClass, "deepScan", "Z"); |
| 298 | for (int i = 0; i < size; ++i) { | 298 | for (int i = 0; i < size; ++i) { |
| 299 | dir = env->GetObjectArrayElement(gameDirs, i); | 299 | dir = env->GetObjectArrayElement(gameDirs, i); |
| 300 | jstring juriString = static_cast<jstring>(env->GetObjectField(dir, uriStringField)); | 300 | jstring juriString = static_cast<jstring>(env->GetObjectField(dir, uriStringField)); |
| 301 | jboolean jdeepScanBoolean = env->GetBooleanField(dir, deepScanBooleanField); | 301 | jboolean jdeepScanBoolean = env->GetBooleanField(dir, deepScanBooleanField); |
| 302 | std::string uriString = GetJString(env, juriString); | 302 | std::string uriString = Common::Android::GetJString(env, juriString); |
| 303 | AndroidSettings::values.game_dirs.push_back( | 303 | AndroidSettings::values.game_dirs.push_back( |
| 304 | AndroidSettings::GameDir{uriString, static_cast<bool>(jdeepScanBoolean)}); | 304 | AndroidSettings::GameDir{uriString, static_cast<bool>(jdeepScanBoolean)}); |
| 305 | } | 305 | } |
| @@ -307,13 +307,13 @@ void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_setGameDirs(JNIEnv* env, jobject | |||
| 307 | 307 | ||
| 308 | void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_addGameDir(JNIEnv* env, jobject obj, | 308 | void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_addGameDir(JNIEnv* env, jobject obj, |
| 309 | jobject gameDir) { | 309 | jobject gameDir) { |
| 310 | jclass gameDirClass = IDCache::GetGameDirClass(); | 310 | jclass gameDirClass = Common::Android::GetGameDirClass(); |
| 311 | jfieldID uriStringField = env->GetFieldID(gameDirClass, "uriString", "Ljava/lang/String;"); | 311 | jfieldID uriStringField = env->GetFieldID(gameDirClass, "uriString", "Ljava/lang/String;"); |
| 312 | jfieldID deepScanBooleanField = env->GetFieldID(gameDirClass, "deepScan", "Z"); | 312 | jfieldID deepScanBooleanField = env->GetFieldID(gameDirClass, "deepScan", "Z"); |
| 313 | 313 | ||
| 314 | jstring juriString = static_cast<jstring>(env->GetObjectField(gameDir, uriStringField)); | 314 | jstring juriString = static_cast<jstring>(env->GetObjectField(gameDir, uriStringField)); |
| 315 | jboolean jdeepScanBoolean = env->GetBooleanField(gameDir, deepScanBooleanField); | 315 | jboolean jdeepScanBoolean = env->GetBooleanField(gameDir, deepScanBooleanField); |
| 316 | std::string uriString = GetJString(env, juriString); | 316 | std::string uriString = Common::Android::GetJString(env, juriString); |
| 317 | AndroidSettings::values.game_dirs.push_back( | 317 | AndroidSettings::values.game_dirs.push_back( |
| 318 | AndroidSettings::GameDir{uriString, static_cast<bool>(jdeepScanBoolean)}); | 318 | AndroidSettings::GameDir{uriString, static_cast<bool>(jdeepScanBoolean)}); |
| 319 | } | 319 | } |
| @@ -323,9 +323,11 @@ jobjectArray Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getDisabledAddons(JNIEnv | |||
| 323 | auto program_id = EmulationSession::GetProgramId(env, jprogramId); | 323 | auto program_id = EmulationSession::GetProgramId(env, jprogramId); |
| 324 | auto& disabledAddons = Settings::values.disabled_addons[program_id]; | 324 | auto& disabledAddons = Settings::values.disabled_addons[program_id]; |
| 325 | jobjectArray jdisabledAddonsArray = | 325 | jobjectArray jdisabledAddonsArray = |
| 326 | env->NewObjectArray(disabledAddons.size(), IDCache::GetStringClass(), ToJString(env, "")); | 326 | env->NewObjectArray(disabledAddons.size(), Common::Android::GetStringClass(), |
| 327 | Common::Android::ToJString(env, "")); | ||
| 327 | for (size_t i = 0; i < disabledAddons.size(); ++i) { | 328 | for (size_t i = 0; i < disabledAddons.size(); ++i) { |
| 328 | env->SetObjectArrayElement(jdisabledAddonsArray, i, ToJString(env, disabledAddons[i])); | 329 | env->SetObjectArrayElement(jdisabledAddonsArray, i, |
| 330 | Common::Android::ToJString(env, disabledAddons[i])); | ||
| 329 | } | 331 | } |
| 330 | return jdisabledAddonsArray; | 332 | return jdisabledAddonsArray; |
| 331 | } | 333 | } |
| @@ -339,7 +341,7 @@ void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_setDisabledAddons(JNIEnv* env, j | |||
| 339 | const int size = env->GetArrayLength(jdisabledAddons); | 341 | const int size = env->GetArrayLength(jdisabledAddons); |
| 340 | for (int i = 0; i < size; ++i) { | 342 | for (int i = 0; i < size; ++i) { |
| 341 | auto jaddon = static_cast<jstring>(env->GetObjectArrayElement(jdisabledAddons, i)); | 343 | auto jaddon = static_cast<jstring>(env->GetObjectArrayElement(jdisabledAddons, i)); |
| 342 | disabled_addons.push_back(GetJString(env, jaddon)); | 344 | disabled_addons.push_back(Common::Android::GetJString(env, jaddon)); |
| 343 | } | 345 | } |
| 344 | Settings::values.disabled_addons[program_id] = disabled_addons; | 346 | Settings::values.disabled_addons[program_id] = disabled_addons; |
| 345 | } | 347 | } |
| @@ -348,26 +350,27 @@ jobjectArray Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getOverlayControlData(JN | |||
| 348 | jobject obj) { | 350 | jobject obj) { |
| 349 | jobjectArray joverlayControlDataArray = | 351 | jobjectArray joverlayControlDataArray = |
| 350 | env->NewObjectArray(AndroidSettings::values.overlay_control_data.size(), | 352 | env->NewObjectArray(AndroidSettings::values.overlay_control_data.size(), |
| 351 | IDCache::GetOverlayControlDataClass(), nullptr); | 353 | Common::Android::GetOverlayControlDataClass(), nullptr); |
| 352 | for (size_t i = 0; i < AndroidSettings::values.overlay_control_data.size(); ++i) { | 354 | for (size_t i = 0; i < AndroidSettings::values.overlay_control_data.size(); ++i) { |
| 353 | const auto& control_data = AndroidSettings::values.overlay_control_data[i]; | 355 | const auto& control_data = AndroidSettings::values.overlay_control_data[i]; |
| 354 | jobject jlandscapePosition = | 356 | jobject jlandscapePosition = |
| 355 | env->NewObject(IDCache::GetPairClass(), IDCache::GetPairConstructor(), | 357 | env->NewObject(Common::Android::GetPairClass(), Common::Android::GetPairConstructor(), |
| 356 | ToJDouble(env, control_data.landscape_position.first), | 358 | Common::Android::ToJDouble(env, control_data.landscape_position.first), |
| 357 | ToJDouble(env, control_data.landscape_position.second)); | 359 | Common::Android::ToJDouble(env, control_data.landscape_position.second)); |
| 358 | jobject jportraitPosition = | 360 | jobject jportraitPosition = |
| 359 | env->NewObject(IDCache::GetPairClass(), IDCache::GetPairConstructor(), | 361 | env->NewObject(Common::Android::GetPairClass(), Common::Android::GetPairConstructor(), |
| 360 | ToJDouble(env, control_data.portrait_position.first), | 362 | Common::Android::ToJDouble(env, control_data.portrait_position.first), |
| 361 | ToJDouble(env, control_data.portrait_position.second)); | 363 | Common::Android::ToJDouble(env, control_data.portrait_position.second)); |
| 362 | jobject jfoldablePosition = | 364 | jobject jfoldablePosition = |
| 363 | env->NewObject(IDCache::GetPairClass(), IDCache::GetPairConstructor(), | 365 | env->NewObject(Common::Android::GetPairClass(), Common::Android::GetPairConstructor(), |
| 364 | ToJDouble(env, control_data.foldable_position.first), | 366 | Common::Android::ToJDouble(env, control_data.foldable_position.first), |
| 365 | ToJDouble(env, control_data.foldable_position.second)); | 367 | Common::Android::ToJDouble(env, control_data.foldable_position.second)); |
| 366 | 368 | ||
| 367 | jobject jcontrolData = env->NewObject( | 369 | jobject jcontrolData = |
| 368 | IDCache::GetOverlayControlDataClass(), IDCache::GetOverlayControlDataConstructor(), | 370 | env->NewObject(Common::Android::GetOverlayControlDataClass(), |
| 369 | ToJString(env, control_data.id), control_data.enabled, jlandscapePosition, | 371 | Common::Android::GetOverlayControlDataConstructor(), |
| 370 | jportraitPosition, jfoldablePosition); | 372 | Common::Android::ToJString(env, control_data.id), control_data.enabled, |
| 373 | jlandscapePosition, jportraitPosition, jfoldablePosition); | ||
| 371 | env->SetObjectArrayElement(joverlayControlDataArray, i, jcontrolData); | 374 | env->SetObjectArrayElement(joverlayControlDataArray, i, jcontrolData); |
| 372 | } | 375 | } |
| 373 | return joverlayControlDataArray; | 376 | return joverlayControlDataArray; |
| @@ -384,33 +387,41 @@ void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_setOverlayControlData( | |||
| 384 | 387 | ||
| 385 | for (int i = 0; i < size; ++i) { | 388 | for (int i = 0; i < size; ++i) { |
| 386 | jobject joverlayControlData = env->GetObjectArrayElement(joverlayControlDataArray, i); | 389 | jobject joverlayControlData = env->GetObjectArrayElement(joverlayControlDataArray, i); |
| 387 | jstring jidString = static_cast<jstring>( | 390 | jstring jidString = static_cast<jstring>(env->GetObjectField( |
| 388 | env->GetObjectField(joverlayControlData, IDCache::GetOverlayControlDataIdField())); | 391 | joverlayControlData, Common::Android::GetOverlayControlDataIdField())); |
| 389 | bool enabled = static_cast<bool>(env->GetBooleanField( | 392 | bool enabled = static_cast<bool>(env->GetBooleanField( |
| 390 | joverlayControlData, IDCache::GetOverlayControlDataEnabledField())); | 393 | joverlayControlData, Common::Android::GetOverlayControlDataEnabledField())); |
| 391 | 394 | ||
| 392 | jobject jlandscapePosition = env->GetObjectField( | 395 | jobject jlandscapePosition = env->GetObjectField( |
| 393 | joverlayControlData, IDCache::GetOverlayControlDataLandscapePositionField()); | 396 | joverlayControlData, Common::Android::GetOverlayControlDataLandscapePositionField()); |
| 394 | std::pair<double, double> landscape_position = std::make_pair( | 397 | std::pair<double, double> landscape_position = std::make_pair( |
| 395 | GetJDouble(env, env->GetObjectField(jlandscapePosition, IDCache::GetPairFirstField())), | 398 | Common::Android::GetJDouble( |
| 396 | GetJDouble(env, | 399 | env, env->GetObjectField(jlandscapePosition, Common::Android::GetPairFirstField())), |
| 397 | env->GetObjectField(jlandscapePosition, IDCache::GetPairSecondField()))); | 400 | Common::Android::GetJDouble( |
| 401 | env, | ||
| 402 | env->GetObjectField(jlandscapePosition, Common::Android::GetPairSecondField()))); | ||
| 398 | 403 | ||
| 399 | jobject jportraitPosition = env->GetObjectField( | 404 | jobject jportraitPosition = env->GetObjectField( |
| 400 | joverlayControlData, IDCache::GetOverlayControlDataPortraitPositionField()); | 405 | joverlayControlData, Common::Android::GetOverlayControlDataPortraitPositionField()); |
| 401 | std::pair<double, double> portrait_position = std::make_pair( | 406 | std::pair<double, double> portrait_position = std::make_pair( |
| 402 | GetJDouble(env, env->GetObjectField(jportraitPosition, IDCache::GetPairFirstField())), | 407 | Common::Android::GetJDouble( |
| 403 | GetJDouble(env, env->GetObjectField(jportraitPosition, IDCache::GetPairSecondField()))); | 408 | env, env->GetObjectField(jportraitPosition, Common::Android::GetPairFirstField())), |
| 409 | Common::Android::GetJDouble( | ||
| 410 | env, | ||
| 411 | env->GetObjectField(jportraitPosition, Common::Android::GetPairSecondField()))); | ||
| 404 | 412 | ||
| 405 | jobject jfoldablePosition = env->GetObjectField( | 413 | jobject jfoldablePosition = env->GetObjectField( |
| 406 | joverlayControlData, IDCache::GetOverlayControlDataFoldablePositionField()); | 414 | joverlayControlData, Common::Android::GetOverlayControlDataFoldablePositionField()); |
| 407 | std::pair<double, double> foldable_position = std::make_pair( | 415 | std::pair<double, double> foldable_position = std::make_pair( |
| 408 | GetJDouble(env, env->GetObjectField(jfoldablePosition, IDCache::GetPairFirstField())), | 416 | Common::Android::GetJDouble( |
| 409 | GetJDouble(env, env->GetObjectField(jfoldablePosition, IDCache::GetPairSecondField()))); | 417 | env, env->GetObjectField(jfoldablePosition, Common::Android::GetPairFirstField())), |
| 418 | Common::Android::GetJDouble( | ||
| 419 | env, | ||
| 420 | env->GetObjectField(jfoldablePosition, Common::Android::GetPairSecondField()))); | ||
| 410 | 421 | ||
| 411 | AndroidSettings::values.overlay_control_data.push_back(AndroidSettings::OverlayControlData{ | 422 | AndroidSettings::values.overlay_control_data.push_back(AndroidSettings::OverlayControlData{ |
| 412 | GetJString(env, jidString), enabled, landscape_position, portrait_position, | 423 | Common::Android::GetJString(env, jidString), enabled, landscape_position, |
| 413 | foldable_position}); | 424 | portrait_position, foldable_position}); |
| 414 | } | 425 | } |
| 415 | } | 426 | } |
| 416 | 427 | ||
diff --git a/src/android/app/src/main/jni/native_log.cpp b/src/android/app/src/main/jni/native_log.cpp index 33d691dc8..95dd1f057 100644 --- a/src/android/app/src/main/jni/native_log.cpp +++ b/src/android/app/src/main/jni/native_log.cpp | |||
| @@ -1,31 +1,30 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <common/android/android_common.h> | ||
| 4 | #include <common/logging/log.h> | 5 | #include <common/logging/log.h> |
| 5 | #include <jni.h> | 6 | #include <jni.h> |
| 6 | 7 | ||
| 7 | #include "android_common/android_common.h" | ||
| 8 | |||
| 9 | extern "C" { | 8 | extern "C" { |
| 10 | 9 | ||
| 11 | void Java_org_yuzu_yuzu_1emu_utils_Log_debug(JNIEnv* env, jobject obj, jstring jmessage) { | 10 | void Java_org_yuzu_yuzu_1emu_utils_Log_debug(JNIEnv* env, jobject obj, jstring jmessage) { |
| 12 | LOG_DEBUG(Frontend, "{}", GetJString(env, jmessage)); | 11 | LOG_DEBUG(Frontend, "{}", Common::Android::GetJString(env, jmessage)); |
| 13 | } | 12 | } |
| 14 | 13 | ||
| 15 | void Java_org_yuzu_yuzu_1emu_utils_Log_warning(JNIEnv* env, jobject obj, jstring jmessage) { | 14 | void Java_org_yuzu_yuzu_1emu_utils_Log_warning(JNIEnv* env, jobject obj, jstring jmessage) { |
| 16 | LOG_WARNING(Frontend, "{}", GetJString(env, jmessage)); | 15 | LOG_WARNING(Frontend, "{}", Common::Android::GetJString(env, jmessage)); |
| 17 | } | 16 | } |
| 18 | 17 | ||
| 19 | void Java_org_yuzu_yuzu_1emu_utils_Log_info(JNIEnv* env, jobject obj, jstring jmessage) { | 18 | void Java_org_yuzu_yuzu_1emu_utils_Log_info(JNIEnv* env, jobject obj, jstring jmessage) { |
| 20 | LOG_INFO(Frontend, "{}", GetJString(env, jmessage)); | 19 | LOG_INFO(Frontend, "{}", Common::Android::GetJString(env, jmessage)); |
| 21 | } | 20 | } |
| 22 | 21 | ||
| 23 | void Java_org_yuzu_yuzu_1emu_utils_Log_error(JNIEnv* env, jobject obj, jstring jmessage) { | 22 | void Java_org_yuzu_yuzu_1emu_utils_Log_error(JNIEnv* env, jobject obj, jstring jmessage) { |
| 24 | LOG_ERROR(Frontend, "{}", GetJString(env, jmessage)); | 23 | LOG_ERROR(Frontend, "{}", Common::Android::GetJString(env, jmessage)); |
| 25 | } | 24 | } |
| 26 | 25 | ||
| 27 | void Java_org_yuzu_yuzu_1emu_utils_Log_critical(JNIEnv* env, jobject obj, jstring jmessage) { | 26 | void Java_org_yuzu_yuzu_1emu_utils_Log_critical(JNIEnv* env, jobject obj, jstring jmessage) { |
| 28 | LOG_CRITICAL(Frontend, "{}", GetJString(env, jmessage)); | 27 | LOG_CRITICAL(Frontend, "{}", Common::Android::GetJString(env, jmessage)); |
| 29 | } | 28 | } |
| 30 | 29 | ||
| 31 | } // extern "C" | 30 | } // extern "C" |