diff --git a/src/android/app/src/main/jni/applets/mii_selector.cpp b/src/android/app/src/main/jni/applets/mii_selector.cpp index 409941918..305426b35 100644 --- a/src/android/app/src/main/jni/applets/mii_selector.cpp +++ b/src/android/app/src/main/jni/applets/mii_selector.cpp @@ -69,13 +69,13 @@ void InitJNI(JNIEnv* env) { env->NewGlobalRef(env->FindClass("io/github/lime3ds/android/applets/MiiSelector"))); s_mii_selector_config_class = reinterpret_cast(env->NewGlobalRef( env->FindClass("io/github/lime3ds/android/applets/MiiSelector$MiiSelectorConfig"))); - s_mii_selector_data_class = reinterpret_cast( - env->NewGlobalRef(env->FindClass("io/github/lime3ds/android/applets/MiiSelector$MiiSelectorData"))); + s_mii_selector_data_class = reinterpret_cast(env->NewGlobalRef( + env->FindClass("io/github/lime3ds/android/applets/MiiSelector$MiiSelectorData"))); - s_mii_selector_execute = - env->GetStaticMethodID(s_mii_selector_class, "Execute", - "(Lio/github/lime3ds/android/applets/MiiSelector$MiiSelectorConfig;)Lio/" - "github/lime3ds/android/applets/MiiSelector$MiiSelectorData;"); + s_mii_selector_execute = env->GetStaticMethodID( + s_mii_selector_class, "Execute", + "(Lio/github/lime3ds/android/applets/MiiSelector$MiiSelectorConfig;)Lio/" + "github/lime3ds/android/applets/MiiSelector$MiiSelectorData;"); } void CleanupJNI(JNIEnv* env) { diff --git a/src/android/app/src/main/jni/applets/swkbd.cpp b/src/android/app/src/main/jni/applets/swkbd.cpp index fa3986fc9..e6293bb23 100644 --- a/src/android/app/src/main/jni/applets/swkbd.cpp +++ b/src/android/app/src/main/jni/applets/swkbd.cpp @@ -83,10 +83,11 @@ void InitJNI(JNIEnv* env) { s_validation_error_class = reinterpret_cast(env->NewGlobalRef( env->FindClass("io/github/lime3ds/android/applets/SoftwareKeyboard$ValidationError"))); - s_swkbd_execute = env->GetStaticMethodID( - s_software_keyboard_class, "Execute", - "(Lio/github/lime3ds/android/applets/SoftwareKeyboard$KeyboardConfig;)Lio/github/lime3ds/android/" - "applets/SoftwareKeyboard$KeyboardData;"); + s_swkbd_execute = + env->GetStaticMethodID(s_software_keyboard_class, "Execute", + "(Lio/github/lime3ds/android/applets/" + "SoftwareKeyboard$KeyboardConfig;)Lio/github/lime3ds/android/" + "applets/SoftwareKeyboard$KeyboardData;"); s_swkbd_show_error = env->GetStaticMethodID(s_software_keyboard_class, "ShowError", "(Ljava/lang/String;)V"); } @@ -120,20 +121,23 @@ jobject ToJavaValidationError(Frontend::ValidationError error) { JNIEnv* env = IDCache::GetEnvForThread(); return env->GetStaticObjectField( s_validation_error_class, - env->GetStaticFieldID(s_validation_error_class, ValidationErrorNameMap.at(error), - "Lio/github/lime3ds/android/applets/SoftwareKeyboard$ValidationError;")); + env->GetStaticFieldID( + s_validation_error_class, ValidationErrorNameMap.at(error), + "Lio/github/lime3ds/android/applets/SoftwareKeyboard$ValidationError;")); } -jobject Java_io_github_lime3ds_android_applets_SoftwareKeyboard_ValidateFilters(JNIEnv* env, jclass clazz, - jstring text) { +jobject Java_io_github_lime3ds_android_applets_SoftwareKeyboard_ValidateFilters(JNIEnv* env, + jclass clazz, + jstring text) { const auto ret = Core::System::GetInstance().GetSoftwareKeyboard()->ValidateFilters(GetJString(env, text)); return ToJavaValidationError(ret); } -jobject Java_io_github_lime3ds_android_applets_SoftwareKeyboard_ValidateInput(JNIEnv* env, jclass clazz, - jstring text) { +jobject Java_io_github_lime3ds_android_applets_SoftwareKeyboard_ValidateInput(JNIEnv* env, + jclass clazz, + jstring text) { const auto ret = Core::System::GetInstance().GetSoftwareKeyboard()->ValidateInput(GetJString(env, text)); diff --git a/src/android/app/src/main/jni/camera/still_image_camera.cpp b/src/android/app/src/main/jni/camera/still_image_camera.cpp index e86599d2b..6971cdb5a 100644 --- a/src/android/app/src/main/jni/camera/still_image_camera.cpp +++ b/src/android/app/src/main/jni/camera/still_image_camera.cpp @@ -15,8 +15,8 @@ static jmethodID s_load_image_from_file; namespace Camera::StillImage { void InitJNI(JNIEnv* env) { - s_still_image_camera_helper_class = reinterpret_cast( - env->NewGlobalRef(env->FindClass("io/github/lime3ds/android/camera/StillImageCameraHelper"))); + s_still_image_camera_helper_class = reinterpret_cast(env->NewGlobalRef( + env->FindClass("io/github/lime3ds/android/camera/StillImageCameraHelper"))); s_open_file_picker = env->GetStaticMethodID(s_still_image_camera_helper_class, "OpenFilePicker", "()Ljava/lang/String;"); s_load_image_from_file = diff --git a/src/android/app/src/main/jni/cheats/cheat.cpp b/src/android/app/src/main/jni/cheats/cheat.cpp index 95d46e4d0..8410be65a 100644 --- a/src/android/app/src/main/jni/cheats/cheat.cpp +++ b/src/android/app/src/main/jni/cheats/cheat.cpp @@ -29,23 +29,23 @@ jobject CheatToJava(JNIEnv* env, std::shared_ptr cheat) { extern "C" { -JNIEXPORT void JNICALL Java_io_github_lime3ds_android_features_cheats_model_Cheat_finalize(JNIEnv* env, - jobject obj) { +JNIEXPORT void JNICALL +Java_io_github_lime3ds_android_features_cheats_model_Cheat_finalize(JNIEnv* env, jobject obj) { delete CheatFromJava(env, obj); } -JNIEXPORT jstring JNICALL Java_io_github_lime3ds_android_features_cheats_model_Cheat_getName(JNIEnv* env, - jobject obj) { +JNIEXPORT jstring JNICALL +Java_io_github_lime3ds_android_features_cheats_model_Cheat_getName(JNIEnv* env, jobject obj) { return ToJString(env, (*CheatFromJava(env, obj))->GetName()); } -JNIEXPORT jstring JNICALL Java_io_github_lime3ds_android_features_cheats_model_Cheat_getNotes(JNIEnv* env, - jobject obj) { +JNIEXPORT jstring JNICALL +Java_io_github_lime3ds_android_features_cheats_model_Cheat_getNotes(JNIEnv* env, jobject obj) { return ToJString(env, (*CheatFromJava(env, obj))->GetComments()); } -JNIEXPORT jstring JNICALL Java_io_github_lime3ds_android_features_cheats_model_Cheat_getCode(JNIEnv* env, - jobject obj) { +JNIEXPORT jstring JNICALL +Java_io_github_lime3ds_android_features_cheats_model_Cheat_getCode(JNIEnv* env, jobject obj) { return ToJString(env, (*CheatFromJava(env, obj))->GetCode()); } @@ -59,8 +59,9 @@ JNIEXPORT void JNICALL Java_io_github_lime3ds_android_features_cheats_model_Chea (*CheatFromJava(env, obj))->SetEnabled(static_cast(j_enabled)); } -JNIEXPORT jint JNICALL Java_io_github_lime3ds_android_features_cheats_model_Cheat_isValidGatewayCode( - JNIEnv* env, jclass, jstring j_code) { +JNIEXPORT jint JNICALL +Java_io_github_lime3ds_android_features_cheats_model_Cheat_isValidGatewayCode(JNIEnv* env, jclass, + jstring j_code) { const std::string code = GetJString(env, j_code); const auto code_lines = Common::SplitString(code, '\n'); @@ -74,8 +75,11 @@ JNIEXPORT jint JNICALL Java_io_github_lime3ds_android_features_cheats_model_Chea return 0; } -JNIEXPORT jobject JNICALL Java_io_github_lime3ds_android_features_cheats_model_Cheat_createGatewayCode( - JNIEnv* env, jclass, jstring j_name, jstring j_notes, jstring j_code) { +JNIEXPORT jobject JNICALL +Java_io_github_lime3ds_android_features_cheats_model_Cheat_createGatewayCode(JNIEnv* env, jclass, + jstring j_name, + jstring j_notes, + jstring j_code) { return CheatToJava(env, std::make_shared(GetJString(env, j_name), GetJString(env, j_code), GetJString(env, j_notes))); diff --git a/src/android/app/src/main/jni/cheats/cheat_engine.cpp b/src/android/app/src/main/jni/cheats/cheat_engine.cpp index 5a04236bd..9fae689ad 100644 --- a/src/android/app/src/main/jni/cheats/cheat_engine.cpp +++ b/src/android/app/src/main/jni/cheats/cheat_engine.cpp @@ -20,13 +20,15 @@ static Cheats::CheatEngine& GetEngine() { return system.CheatEngine(); } -JNIEXPORT void JNICALL Java_io_github_lime3ds_android_features_cheats_model_CheatEngine_loadCheatFile( - JNIEnv* env, jclass, jlong title_id) { +JNIEXPORT void JNICALL +Java_io_github_lime3ds_android_features_cheats_model_CheatEngine_loadCheatFile(JNIEnv* env, jclass, + jlong title_id) { GetEngine().LoadCheatFile(title_id); } -JNIEXPORT void JNICALL Java_io_github_lime3ds_android_features_cheats_model_CheatEngine_saveCheatFile( - JNIEnv* env, jclass, jlong title_id) { +JNIEXPORT void JNICALL +Java_io_github_lime3ds_android_features_cheats_model_CheatEngine_saveCheatFile(JNIEnv* env, jclass, + jlong title_id) { GetEngine().SaveCheatFile(title_id); } diff --git a/src/android/app/src/main/jni/game_info.cpp b/src/android/app/src/main/jni/game_info.cpp index b6c784ab9..86ab19a0a 100644 --- a/src/android/app/src/main/jni/game_info.cpp +++ b/src/android/app/src/main/jni/game_info.cpp @@ -60,8 +60,9 @@ static Loader::SMDH* GetPointer(JNIEnv* env, jobject obj) { return reinterpret_cast(env->GetLongField(obj, IDCache::GetGameInfoPointer())); } -JNIEXPORT jlong JNICALL Java_io_github_lime3ds_android_model_GameInfo_initialize(JNIEnv* env, jclass, - jstring j_path) { +JNIEXPORT jlong JNICALL Java_io_github_lime3ds_android_model_GameInfo_initialize(JNIEnv* env, + jclass, + jstring j_path) { std::vector smdh_data = GetSMDHData(GetJString(env, j_path)); Loader::SMDH* smdh = nullptr; @@ -72,7 +73,8 @@ JNIEXPORT jlong JNICALL Java_io_github_lime3ds_android_model_GameInfo_initialize return reinterpret_cast(smdh); } -JNIEXPORT void JNICALL Java_io_github_lime3ds_android_model_GameInfo_finalize(JNIEnv* env, jobject obj) { +JNIEXPORT void JNICALL Java_io_github_lime3ds_android_model_GameInfo_finalize(JNIEnv* env, + jobject obj) { delete GetPointer(env, obj); } @@ -148,7 +150,8 @@ jintArray Java_io_github_lime3ds_android_model_GameInfo_getIcon(JNIEnv* env, job return icon; } -jboolean Java_io_github_lime3ds_android_model_GameInfo_getIsVisibleSystemTitle(JNIEnv* env, jobject obj) { +jboolean Java_io_github_lime3ds_android_model_GameInfo_getIsVisibleSystemTitle(JNIEnv* env, + jobject obj) { Loader::SMDH* smdh = GetPointer(env, obj); if (smdh == nullptr) { return false; diff --git a/src/android/app/src/main/jni/id_cache.cpp b/src/android/app/src/main/jni/id_cache.cpp index 8ae487518..1b36bfd32 100644 --- a/src/android/app/src/main/jni/id_cache.cpp +++ b/src/android/app/src/main/jni/id_cache.cpp @@ -168,9 +168,9 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) { // Initialize NativeLibrary const jclass native_library_class = env->FindClass("io/github/lime3ds/android/NativeLibrary"); s_native_library_class = reinterpret_cast(env->NewGlobalRef(native_library_class)); - s_on_core_error = - env->GetStaticMethodID(s_native_library_class, "onCoreError", - "(Lio/github/lime3ds/android/NativeLibrary$CoreError;Ljava/lang/String;)Z"); + s_on_core_error = env->GetStaticMethodID( + s_native_library_class, "onCoreError", + "(Lio/github/lime3ds/android/NativeLibrary$CoreError;Ljava/lang/String;)Z"); s_is_portrait_mode = env->GetStaticMethodID(s_native_library_class, "isPortraitMode", "()Z"); s_landscape_screen_layout = env->GetStaticMethodID(s_native_library_class, "landscapeScreenLayout", "()I"); @@ -183,7 +183,8 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) { env->DeleteLocalRef(native_library_class); // Initialize Cheat - const jclass cheat_class = env->FindClass("io/github/lime3ds/android/features/cheats/model/Cheat"); + const jclass cheat_class = + env->FindClass("io/github/lime3ds/android/features/cheats/model/Cheat"); s_cheat_class = reinterpret_cast(env->NewGlobalRef(cheat_class)); s_cheat_pointer = env->GetFieldID(cheat_class, "mPointer", "J"); s_cheat_constructor = env->GetMethodID(cheat_class, "", "(J)V"); @@ -195,8 +196,8 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) { env->DeleteLocalRef(game_info_class); // Initialize Disk Shader Cache Progress Dialog - s_disk_cache_progress_class = reinterpret_cast( - env->NewGlobalRef(env->FindClass("io/github/lime3ds/android/utils/DiskShaderCacheProgress"))); + s_disk_cache_progress_class = reinterpret_cast(env->NewGlobalRef( + env->FindClass("io/github/lime3ds/android/utils/DiskShaderCacheProgress"))); jclass load_callback_stage_class = env->FindClass("io/github/lime3ds/android/utils/DiskShaderCacheProgress$LoadCallbackStage"); s_disk_cache_load_progress = env->GetStaticMethodID( diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index b4b57257c..afba7be6a 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -90,8 +90,9 @@ static jobject ToJavaCoreError(Core::System::ResultStatus result) { JNIEnv* env = IDCache::GetEnvForThread(); const jclass core_error_class = IDCache::GetCoreErrorClass(); return env->GetStaticObjectField( - core_error_class, env->GetStaticFieldID(core_error_class, name, - "Lio/github/lime3ds/android/NativeLibrary$CoreError;")); + core_error_class, + env->GetStaticFieldID(core_error_class, name, + "Lio/github/lime3ds/android/NativeLibrary$CoreError;")); } static bool HandleCoreError(Core::System::ResultStatus result, const std::string& details) { @@ -283,8 +284,9 @@ void InitializeGpuDriver(const std::string& hook_lib_dir, const std::string& cus extern "C" { -void Java_io_github_lime3ds_android_NativeLibrary_surfaceChanged(JNIEnv* env, [[maybe_unused]] jobject obj, - jobject surf) { +void Java_io_github_lime3ds_android_NativeLibrary_surfaceChanged(JNIEnv* env, + [[maybe_unused]] jobject obj, + jobject surf) { s_surf = ANativeWindow_fromSurface(env, surf); if (window) { @@ -300,7 +302,7 @@ void Java_io_github_lime3ds_android_NativeLibrary_surfaceChanged(JNIEnv* env, [[ } void Java_io_github_lime3ds_android_NativeLibrary_surfaceDestroyed([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { ANativeWindow_release(s_surf); s_surf = nullptr; if (window) { @@ -309,26 +311,22 @@ void Java_io_github_lime3ds_android_NativeLibrary_surfaceDestroyed([[maybe_unuse } void Java_io_github_lime3ds_android_NativeLibrary_doFrame([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { if (stop_run || pause_emulation) { return; } window->TryPresenting(); } -void JNICALL Java_io_github_lime3ds_android_NativeLibrary_initializeGpuDriver(JNIEnv* env, jobject obj, - jstring hook_lib_dir, - jstring custom_driver_dir, - jstring custom_driver_name, - jstring file_redirect_dir) { +void JNICALL Java_io_github_lime3ds_android_NativeLibrary_initializeGpuDriver( + JNIEnv* env, jobject obj, jstring hook_lib_dir, jstring custom_driver_dir, + jstring custom_driver_name, jstring file_redirect_dir) { InitializeGpuDriver(GetJString(env, hook_lib_dir), GetJString(env, custom_driver_dir), GetJString(env, custom_driver_name), GetJString(env, file_redirect_dir)); } -void Java_io_github_lime3ds_android_NativeLibrary_notifyOrientationChange([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - jint layout_option, - jint rotation) { +void Java_io_github_lime3ds_android_NativeLibrary_notifyOrientationChange( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, jint layout_option, jint rotation) { Settings::values.layout_option = static_cast(layout_option); auto& system = Core::System::GetInstance(); if (system.IsPoweredOn()) { @@ -339,8 +337,9 @@ void Java_io_github_lime3ds_android_NativeLibrary_notifyOrientationChange([[mayb } void Java_io_github_lime3ds_android_NativeLibrary_swapScreens([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - jboolean swap_screens, jint rotation) { + [[maybe_unused]] jobject obj, + jboolean swap_screens, + jint rotation) { Settings::values.swap_screen = swap_screens; auto& system = Core::System::GetInstance(); if (system.IsPoweredOn()) { @@ -350,16 +349,16 @@ void Java_io_github_lime3ds_android_NativeLibrary_swapScreens([[maybe_unused]] J Camera::NDK::g_rotation = rotation; } -jboolean Java_io_github_lime3ds_android_NativeLibrary_areKeysAvailable([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { +jboolean Java_io_github_lime3ds_android_NativeLibrary_areKeysAvailable( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { HW::AES::InitKeys(); return HW::AES::IsKeyXAvailable(HW::AES::KeySlotID::NCCHSecure1) && HW::AES::IsKeyXAvailable(HW::AES::KeySlotID::NCCHSecure2); } jstring Java_io_github_lime3ds_android_NativeLibrary_getHomeMenuPath(JNIEnv* env, - [[maybe_unused]] jobject obj, - jint region) { + [[maybe_unused]] jobject obj, + jint region) { const std::string path = Core::GetHomeMenuNcchPath(region); if (FileUtil::Exists(path)) { return ToJString(env, path); @@ -368,8 +367,8 @@ jstring Java_io_github_lime3ds_android_NativeLibrary_getHomeMenuPath(JNIEnv* env } void Java_io_github_lime3ds_android_NativeLibrary_setUserDirectory(JNIEnv* env, - [[maybe_unused]] jobject obj, - jstring j_directory) { + [[maybe_unused]] jobject obj, + jstring j_directory) { FileUtil::SetCurrentDir(GetJString(env, j_directory)); } @@ -411,9 +410,8 @@ jobjectArray Java_io_github_lime3ds_android_NativeLibrary_getInstalledGamePaths( return jgames; } -jlongArray Java_io_github_lime3ds_android_NativeLibrary_getSystemTitleIds(JNIEnv* env, - [[maybe_unused]] jobject obj, - jint system_type, jint region) { +jlongArray Java_io_github_lime3ds_android_NativeLibrary_getSystemTitleIds( + JNIEnv* env, [[maybe_unused]] jobject obj, jint system_type, jint region) { const auto mode = static_cast(system_type); const std::vector titles = Core::GetSystemTitleIds(mode, region); jlongArray jTitles = env->NewLongArray(titles.size()); @@ -422,9 +420,8 @@ jlongArray Java_io_github_lime3ds_android_NativeLibrary_getSystemTitleIds(JNIEnv return jTitles; } -jobject Java_io_github_lime3ds_android_NativeLibrary_downloadTitleFromNus([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - jlong title) { +jobject Java_io_github_lime3ds_android_NativeLibrary_downloadTitleFromNus( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, jlong title) { const auto title_id = static_cast(title); Service::AM::InstallStatus status = Service::AM::InstallFromNus(title_id); if (status != Service::AM::InstallStatus::Success) { @@ -455,20 +452,20 @@ jboolean JNICALL Java_io_github_lime3ds_android_utils_GpuDriverHelper_supportsCu // TODO(xperia64): ensure these cannot be called in an invalid state (e.g. after StopEmulation) void Java_io_github_lime3ds_android_NativeLibrary_unPauseEmulation([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { pause_emulation = false; running_cv.notify_all(); InputManager::NDKMotionHandler()->EnableSensors(); } void Java_io_github_lime3ds_android_NativeLibrary_pauseEmulation([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { pause_emulation = true; InputManager::NDKMotionHandler()->DisableSensors(); } void Java_io_github_lime3ds_android_NativeLibrary_stopEmulation([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { stop_run = true; pause_emulation = false; window->StopPresenting(); @@ -476,21 +473,20 @@ void Java_io_github_lime3ds_android_NativeLibrary_stopEmulation([[maybe_unused]] } jboolean Java_io_github_lime3ds_android_NativeLibrary_isRunning([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { return static_cast(!stop_run); } jlong Java_io_github_lime3ds_android_NativeLibrary_getRunningTitleId([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { u64 title_id{}; Core::System::GetInstance().GetAppLoader().ReadProgramId(title_id); return static_cast(title_id); } -jboolean Java_io_github_lime3ds_android_NativeLibrary_onGamePadEvent([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - [[maybe_unused]] jstring j_device, - jint j_button, jint action) { +jboolean Java_io_github_lime3ds_android_NativeLibrary_onGamePadEvent( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, [[maybe_unused]] jstring j_device, + jint j_button, jint action) { bool consumed{}; if (action) { consumed = InputManager::ButtonHandler()->PressKey(j_button); @@ -501,10 +497,9 @@ jboolean Java_io_github_lime3ds_android_NativeLibrary_onGamePadEvent([[maybe_unu return static_cast(consumed); } -jboolean Java_io_github_lime3ds_android_NativeLibrary_onGamePadMoveEvent([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - [[maybe_unused]] jstring j_device, - jint axis, jfloat x, jfloat y) { +jboolean Java_io_github_lime3ds_android_NativeLibrary_onGamePadMoveEvent( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, [[maybe_unused]] jstring j_device, + jint axis, jfloat x, jfloat y) { // Clamp joystick movement to supported minimum and maximum // Citra uses an inverted y axis sent by the frontend x = std::clamp(x, -1.f, 1.f); @@ -521,29 +516,30 @@ jboolean Java_io_github_lime3ds_android_NativeLibrary_onGamePadMoveEvent([[maybe return static_cast(InputManager::AnalogHandler()->MoveJoystick(axis, x, y)); } -jboolean Java_io_github_lime3ds_android_NativeLibrary_onGamePadAxisEvent([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - [[maybe_unused]] jstring j_device, - jint axis_id, jfloat axis_val) { +jboolean Java_io_github_lime3ds_android_NativeLibrary_onGamePadAxisEvent( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, [[maybe_unused]] jstring j_device, + jint axis_id, jfloat axis_val) { return static_cast( InputManager::ButtonHandler()->AnalogButtonEvent(axis_id, axis_val)); } jboolean Java_io_github_lime3ds_android_NativeLibrary_onTouchEvent([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, jfloat x, - jfloat y, jboolean pressed) { + [[maybe_unused]] jobject obj, + jfloat x, jfloat y, + jboolean pressed) { return static_cast( window->OnTouchEvent(static_cast(x + 0.5), static_cast(y + 0.5), pressed)); } void Java_io_github_lime3ds_android_NativeLibrary_onTouchMoved([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, jfloat x, - jfloat y) { + [[maybe_unused]] jobject obj, + jfloat x, jfloat y) { window->OnTouchMoved((int)x, (int)y); } -jlong Java_io_github_lime3ds_android_NativeLibrary_getTitleId(JNIEnv* env, [[maybe_unused]] jobject obj, - jstring j_filename) { +jlong Java_io_github_lime3ds_android_NativeLibrary_getTitleId(JNIEnv* env, + [[maybe_unused]] jobject obj, + jstring j_filename) { std::string filepath = GetJString(env, j_filename); const auto loader = Loader::GetLoader(filepath); @@ -555,8 +551,8 @@ jlong Java_io_github_lime3ds_android_NativeLibrary_getTitleId(JNIEnv* env, [[may } jboolean Java_io_github_lime3ds_android_NativeLibrary_getIsSystemTitle(JNIEnv* env, - [[maybe_unused]] jobject obj, - jstring path) { + [[maybe_unused]] jobject obj, + jstring path) { const std::string filepath = GetJString(env, path); const auto loader = Loader::GetLoader(filepath); @@ -571,27 +567,27 @@ jboolean Java_io_github_lime3ds_android_NativeLibrary_getIsSystemTitle(JNIEnv* e } void Java_io_github_lime3ds_android_NativeLibrary_createConfigFile([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { Config{}; } void Java_io_github_lime3ds_android_NativeLibrary_createLogFile([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { Common::Log::Initialize(); Common::Log::Start(); LOG_INFO(Frontend, "Logging backend initialised"); } void Java_io_github_lime3ds_android_NativeLibrary_logUserDirectory(JNIEnv* env, - [[maybe_unused]] jobject obj, - jstring j_path) { + [[maybe_unused]] jobject obj, + jstring j_path) { std::string_view path = env->GetStringUTFChars(j_path, 0); LOG_INFO(Frontend, "User directory path: {}", path); env->ReleaseStringUTFChars(j_path, path.data()); } void Java_io_github_lime3ds_android_NativeLibrary_reloadSettings([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { Config{}; Core::System& system{Core::System::GetInstance()}; @@ -605,8 +601,8 @@ void Java_io_github_lime3ds_android_NativeLibrary_reloadSettings([[maybe_unused] system.ApplySettings(); } -jdoubleArray Java_io_github_lime3ds_android_NativeLibrary_getPerfStats(JNIEnv* env, - [[maybe_unused]] jobject obj) { +jdoubleArray Java_io_github_lime3ds_android_NativeLibrary_getPerfStats( + JNIEnv* env, [[maybe_unused]] jobject obj) { auto& core = Core::System::GetInstance(); jdoubleArray j_stats = env->NewDoubleArray(4); @@ -623,9 +619,8 @@ jdoubleArray Java_io_github_lime3ds_android_NativeLibrary_getPerfStats(JNIEnv* e return j_stats; } -void Java_io_github_lime3ds_android_NativeLibrary_run__Ljava_lang_String_2(JNIEnv* env, - [[maybe_unused]] jobject obj, - jstring j_path) { +void Java_io_github_lime3ds_android_NativeLibrary_run__Ljava_lang_String_2( + JNIEnv* env, [[maybe_unused]] jobject obj, jstring j_path) { const std::string path = GetJString(env, j_path); if (!stop_run) { @@ -640,15 +635,16 @@ void Java_io_github_lime3ds_android_NativeLibrary_run__Ljava_lang_String_2(JNIEn } } -void Java_io_github_lime3ds_android_NativeLibrary_reloadCameraDevices([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { +void Java_io_github_lime3ds_android_NativeLibrary_reloadCameraDevices( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { if (g_ndk_factory) { g_ndk_factory->ReloadCameraDevices(); } } -jboolean Java_io_github_lime3ds_android_NativeLibrary_loadAmiibo(JNIEnv* env, [[maybe_unused]] jobject obj, - jstring j_file) { +jboolean Java_io_github_lime3ds_android_NativeLibrary_loadAmiibo(JNIEnv* env, + [[maybe_unused]] jobject obj, + jstring j_file) { std::string filepath = GetJString(env, j_file); Core::System& system{Core::System::GetInstance()}; Service::SM::ServiceManager& sm = system.ServiceManager(); @@ -661,7 +657,7 @@ jboolean Java_io_github_lime3ds_android_NativeLibrary_loadAmiibo(JNIEnv* env, [[ } void Java_io_github_lime3ds_android_NativeLibrary_removeAmiibo([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { Core::System& system{Core::System::GetInstance()}; Service::SM::ServiceManager& sm = system.ServiceManager(); auto nfc = sm.GetService("nfc:u"); @@ -672,9 +668,8 @@ void Java_io_github_lime3ds_android_NativeLibrary_removeAmiibo([[maybe_unused]] nfc->RemoveAmiibo(); } -JNIEXPORT jobject JNICALL Java_io_github_lime3ds_android_utils_CiaInstallWorker_installCIA(JNIEnv* env, - jobject jobj, - jstring jpath) { +JNIEXPORT jobject JNICALL Java_io_github_lime3ds_android_utils_CiaInstallWorker_installCIA( + JNIEnv* env, jobject jobj, jstring jpath) { std::string path = GetJString(env, jpath); Service::AM::InstallStatus res = Service::AM::InstallCIA( path, [env, jobj](std::size_t total_bytes_read, std::size_t file_size) { @@ -685,8 +680,8 @@ JNIEXPORT jobject JNICALL Java_io_github_lime3ds_android_utils_CiaInstallWorker_ return IDCache::GetJavaCiaInstallStatus(res); } -jobjectArray Java_io_github_lime3ds_android_NativeLibrary_getSavestateInfo(JNIEnv* env, - [[maybe_unused]] jobject obj) { +jobjectArray Java_io_github_lime3ds_android_NativeLibrary_getSavestateInfo( + JNIEnv* env, [[maybe_unused]] jobject obj) { const jclass date_class = env->FindClass("java/util/Date"); const auto date_constructor = env->GetMethodID(date_class, "", "(J)V"); @@ -720,17 +715,19 @@ jobjectArray Java_io_github_lime3ds_android_NativeLibrary_getSavestateInfo(JNIEn } void Java_io_github_lime3ds_android_NativeLibrary_saveState([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, jint slot) { + [[maybe_unused]] jobject obj, + jint slot) { Core::System::GetInstance().SendSignal(Core::System::Signal::Save, slot); } void Java_io_github_lime3ds_android_NativeLibrary_loadState([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, jint slot) { + [[maybe_unused]] jobject obj, + jint slot) { Core::System::GetInstance().SendSignal(Core::System::Signal::Load, slot); } void Java_io_github_lime3ds_android_NativeLibrary_logDeviceInfo([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { LOG_INFO(Frontend, "Lime3DS Version: {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc); LOG_INFO(Frontend, "Host CPU: {}", Common::GetCPUCaps().cpu_string); diff --git a/src/android/app/src/main/jni/system_save_game.cpp b/src/android/app/src/main/jni/system_save_game.cpp index bc025db76..0b9d440b6 100644 --- a/src/android/app/src/main/jni/system_save_game.cpp +++ b/src/android/app/src/main/jni/system_save_game.cpp @@ -13,12 +13,12 @@ std::shared_ptr cfg; extern "C" { void Java_io_github_lime3ds_android_utils_SystemSaveGame_save([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { cfg->UpdateConfigNANDSavegame(); } void Java_io_github_lime3ds_android_utils_SystemSaveGame_load([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { + [[maybe_unused]] jobject obj) { cfg = Service::CFG::GetModule(Core::System::GetInstance()); } @@ -27,25 +27,24 @@ jboolean Java_io_github_lime3ds_android_utils_SystemSaveGame_getIsSystemSetupNee return cfg->IsSystemSetupNeeded(); } -void Java_io_github_lime3ds_android_utils_SystemSaveGame_setSystemSetupNeeded([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - jboolean needed) { +void Java_io_github_lime3ds_android_utils_SystemSaveGame_setSystemSetupNeeded( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, jboolean needed) { cfg->SetSystemSetupNeeded(needed); } -jstring Java_io_github_lime3ds_android_utils_SystemSaveGame_getUsername([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { +jstring Java_io_github_lime3ds_android_utils_SystemSaveGame_getUsername( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { return ToJString(env, Common::UTF16ToUTF8(cfg->GetUsername())); } void Java_io_github_lime3ds_android_utils_SystemSaveGame_setUsername([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - jstring username) { + [[maybe_unused]] jobject obj, + jstring username) { cfg->SetUsername(Common::UTF8ToUTF16(GetJString(env, username))); } -jshortArray Java_io_github_lime3ds_android_utils_SystemSaveGame_getBirthday([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { +jshortArray Java_io_github_lime3ds_android_utils_SystemSaveGame_getBirthday( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { jshortArray jbirthdayArray = env->NewShortArray(2); auto birthday = cfg->GetBirthday(); jshort birthdayArray[2]{static_cast(get<0>(birthday)), @@ -55,62 +54,59 @@ jshortArray Java_io_github_lime3ds_android_utils_SystemSaveGame_getBirthday([[ma } void Java_io_github_lime3ds_android_utils_SystemSaveGame_setBirthday([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - jshort jmonth, jshort jday) { + [[maybe_unused]] jobject obj, + jshort jmonth, jshort jday) { cfg->SetBirthday(static_cast(jmonth), static_cast(jday)); } -jint Java_io_github_lime3ds_android_utils_SystemSaveGame_getSystemLanguage([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { +jint Java_io_github_lime3ds_android_utils_SystemSaveGame_getSystemLanguage( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { return cfg->GetSystemLanguage(); } -void Java_io_github_lime3ds_android_utils_SystemSaveGame_setSystemLanguage([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - jint jsystemLanguage) { +void Java_io_github_lime3ds_android_utils_SystemSaveGame_setSystemLanguage( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, jint jsystemLanguage) { cfg->SetSystemLanguage(static_cast(jsystemLanguage)); } -jint Java_io_github_lime3ds_android_utils_SystemSaveGame_getSoundOutputMode([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { +jint Java_io_github_lime3ds_android_utils_SystemSaveGame_getSoundOutputMode( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { return cfg->GetSoundOutputMode(); } -void Java_io_github_lime3ds_android_utils_SystemSaveGame_setSoundOutputMode([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - jint jmode) { +void Java_io_github_lime3ds_android_utils_SystemSaveGame_setSoundOutputMode( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, jint jmode) { cfg->SetSoundOutputMode(static_cast(jmode)); } -jshort Java_io_github_lime3ds_android_utils_SystemSaveGame_getCountryCode([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { +jshort Java_io_github_lime3ds_android_utils_SystemSaveGame_getCountryCode( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { return cfg->GetCountryCode(); } -void Java_io_github_lime3ds_android_utils_SystemSaveGame_setCountryCode([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - jshort jmode) { +void Java_io_github_lime3ds_android_utils_SystemSaveGame_setCountryCode( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, jshort jmode) { cfg->SetCountryCode(static_cast(jmode)); } -jint Java_io_github_lime3ds_android_utils_SystemSaveGame_getPlayCoins([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { +jint Java_io_github_lime3ds_android_utils_SystemSaveGame_getPlayCoins( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { return Service::PTM::Module::GetPlayCoins(); } void Java_io_github_lime3ds_android_utils_SystemSaveGame_setPlayCoins([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj, - jint jcoins) { + [[maybe_unused]] jobject obj, + jint jcoins) { Service::PTM::Module::SetPlayCoins(static_cast(jcoins)); } -jlong Java_io_github_lime3ds_android_utils_SystemSaveGame_getConsoleId([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { +jlong Java_io_github_lime3ds_android_utils_SystemSaveGame_getConsoleId( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { return cfg->GetConsoleUniqueId(); } -void Java_io_github_lime3ds_android_utils_SystemSaveGame_regenerateConsoleId([[maybe_unused]] JNIEnv* env, - [[maybe_unused]] jobject obj) { +void Java_io_github_lime3ds_android_utils_SystemSaveGame_regenerateConsoleId( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { const auto [random_number, console_id] = cfg->GenerateConsoleUniqueId(); cfg->SetConsoleUniqueId(random_number, console_id); cfg->UpdateConfigNANDSavegame();