From deb307ef95c6fbc8670b2e3cf41b7d275348900b Mon Sep 17 00:00:00 2001 From: SSimco <37044560+SSimco@users.noreply.github.com> Date: Sun, 13 Oct 2024 13:08:04 +0300 Subject: [PATCH] Refactored code --- .../app/src/main/cpp/NativeEmulation.cpp | 5 +- .../app/src/main/cpp/NativeGraphicPacks.cpp | 12 ++-- src/android/app/src/main/cpp/NativeInput.cpp | 14 ++--- .../app/src/main/cpp/NativeSettings.cpp | 56 +++++++++---------- .../Cemu/nativeinterface/NativeException.java | 1 - 5 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/android/app/src/main/cpp/NativeEmulation.cpp b/src/android/app/src/main/cpp/NativeEmulation.cpp index be04690c..8ae26200 100644 --- a/src/android/app/src/main/cpp/NativeEmulation.cpp +++ b/src/android/app/src/main/cpp/NativeEmulation.cpp @@ -151,7 +151,7 @@ namespace NativeEmulation } } // namespace NativeEmulation -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeEmulation_setReplaceTVWithPadView([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean swapped) { // Emulate pressing the TAB key for showing DRC instead of TV @@ -178,9 +178,8 @@ Java_info_cemu_Cemu_nativeinterface_NativeEmulation_initializeEmulation([[maybe_ LatteOverlay_init(); CemuCommonInit(); InitializeGlobalVulkan(); - // TODO: move this - // fillGraphicPacks(); } + extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeEmulation_initializerRenderer(JNIEnv* env, [[maybe_unused]] jclass clazz, jobject testSurface) { diff --git a/src/android/app/src/main/cpp/NativeGraphicPacks.cpp b/src/android/app/src/main/cpp/NativeGraphicPacks.cpp index 3e642beb..6190f8eb 100644 --- a/src/android/app/src/main/cpp/NativeGraphicPacks.cpp +++ b/src/android/app/src/main/cpp/NativeGraphicPacks.cpp @@ -85,7 +85,7 @@ namespace NativeGraphicPacks } } // namespace NativeGraphicPacks -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_refreshGraphicPacks([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { if (!CafeSystem::IsTitleRunning()) @@ -96,7 +96,7 @@ Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_refreshGraphicPacks([[may } } -extern "C" JNIEXPORT jobject JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jobject JNICALL Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_getGraphicPackBasicInfos(JNIEnv* env, [[maybe_unused]] jclass clazz) { auto graphicPackInfoClass = env->FindClass("info/cemu/Cemu/nativeinterface/NativeGraphicPacks$GraphicPackBasicInfo"); @@ -114,7 +114,7 @@ Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_getGraphicPackBasicInfos( return JNIUtils::createArrayList(env, graphicPackInfoJObjects); } -extern "C" JNIEXPORT jobject JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jobject JNICALL Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_getGraphicPack(JNIEnv* env, [[maybe_unused]] jclass clazz, jlong id) { auto graphicPackClass = env->FindClass("info/cemu/Cemu/nativeinterface/NativeGraphicPacks$GraphicPack"); @@ -133,7 +133,7 @@ Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_getGraphicPack(JNIEnv* en NativeGraphicPacks::getGraphicPresets(env, graphicPack, id)); } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_setGraphicPackActive([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jlong id, jboolean active) { auto graphicPack = NativeGraphicPacks::s_graphicPacks.at(id); @@ -141,7 +141,7 @@ Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_setGraphicPackActive([[ma NativeGraphicPacks::saveGraphicPackStateToConfig(graphicPack); } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_setGraphicPackActivePreset([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jlong id, jstring category, jstring preset) { std::string presetCategory = category == nullptr ? "" : JNIUtils::JStringToString(env, category); @@ -150,7 +150,7 @@ Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_setGraphicPackActivePrese NativeGraphicPacks::saveGraphicPackStateToConfig(graphicPack); } -extern "C" JNIEXPORT jobject JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jobject JNICALL Java_info_cemu_Cemu_nativeinterface_NativeGraphicPacks_getGraphicPackPresets(JNIEnv* env, [[maybe_unused]] jclass clazz, jlong id) { return NativeGraphicPacks::getGraphicPresets(env, NativeGraphicPacks::s_graphicPacks.at(id), id); diff --git a/src/android/app/src/main/cpp/NativeInput.cpp b/src/android/app/src/main/cpp/NativeInput.cpp index 20ea3c66..df4231f3 100644 --- a/src/android/app/src/main/cpp/NativeInput.cpp +++ b/src/android/app/src/main/cpp/NativeInput.cpp @@ -140,25 +140,25 @@ Java_info_cemu_Cemu_nativeinterface_NativeInput_getControllerMappings(JNIEnv* en return hashMapObj; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeInput_onTouchDown([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint x, jint y, jboolean isTV) { NativeInput::onTouchEvent(x, y, isTV, true); } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeInput_onTouchUp([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint x, jint y, jboolean isTV) { NativeInput::onTouchEvent(x, y, isTV, false); } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeInput_onTouchMove([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint x, jint y, jboolean isTV) { NativeInput::onTouchEvent(x, y, isTV); } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeInput_onMotion([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jlong timestamp, jfloat gyroX, jfloat gyroY, jfloat gyroZ, jfloat accelX, jfloat accelY, jfloat accelZ) { float deltaTime = (timestamp - NativeInput::s_lastMotionTimestamp) * 1e-9f; @@ -169,7 +169,7 @@ Java_info_cemu_Cemu_nativeinterface_NativeInput_onMotion([[maybe_unused]] JNIEnv deviceMotion.m_motion_sample = NativeInput::s_wiiUMotionHandler.getMotionSample(); } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeInput_setMotionEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean motionEnabled) { auto& deviceMotion = InputManager::instance().m_device_motion; @@ -177,13 +177,13 @@ Java_info_cemu_Cemu_nativeinterface_NativeInput_setMotionEnabled([[maybe_unused] deviceMotion.m_device_motion_enabled = motionEnabled; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeInput_onOverlayButton([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint controllerIndex, jint mappingId, jboolean state) { AndroidEmulatedController::getAndroidEmulatedController(controllerIndex).setButtonValue(mappingId, state); } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeInput_onOverlayAxis([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint controllerIndex, jint mappingId, jfloat value) { AndroidEmulatedController::getAndroidEmulatedController(controllerIndex).setAxisValue(mappingId, value); diff --git a/src/android/app/src/main/cpp/NativeSettings.cpp b/src/android/app/src/main/cpp/NativeSettings.cpp index 4e470c1d..fe68d2e4 100644 --- a/src/android/app/src/main/cpp/NativeSettings.cpp +++ b/src/android/app/src/main/cpp/NativeSettings.cpp @@ -1,182 +1,182 @@ #include "JNIUtils.h" #include "config/CemuConfig.h" -extern "C" JNIEXPORT jint JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_getOverlayPosition([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return static_cast(g_config.data().overlay.position); } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setOverlayPosition([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint position) { g_config.data().overlay.position = static_cast(position); g_config.Save(); } -extern "C" JNIEXPORT jint JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_getOverlayTextScalePercentage([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().overlay.text_scale; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setOverlayTextScalePercentage([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint scalePercentage) { g_config.data().overlay.text_scale = scalePercentage; g_config.Save(); } -extern "C" JNIEXPORT jboolean JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_isOverlayFPSEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().overlay.fps; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setOverlayFPSEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().overlay.fps = enabled; g_config.Save(); } -extern "C" JNIEXPORT jboolean JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_isOverlayDrawCallsPerFrameEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().overlay.drawcalls; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setOverlayDrawCallsPerFrameEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().overlay.drawcalls = enabled; g_config.Save(); } -extern "C" JNIEXPORT jboolean JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_isOverlayCPUUsageEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().overlay.cpu_usage; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setOverlayCPUUsageEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().overlay.cpu_usage = enabled; g_config.Save(); } -extern "C" JNIEXPORT jboolean JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_isOverlayCPUPerCoreUsageEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().overlay.cpu_per_core_usage; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setOverlayCPUPerCoreUsageEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().overlay.cpu_per_core_usage = enabled; g_config.Save(); } -extern "C" JNIEXPORT jboolean JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_isOverlayRAMUsageEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().overlay.ram_usage; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setOverlayRAMUsageEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().overlay.ram_usage = enabled; g_config.Save(); } -extern "C" JNIEXPORT jboolean JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_isOverlayVRAMUsageEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().overlay.vram_usage; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setOverlayVRAMUsageEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().overlay.vram_usage = enabled; g_config.Save(); } -extern "C" JNIEXPORT jboolean JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_isOverlayDebugEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().overlay.debug; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setOverlayDebugEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().overlay.debug = enabled; g_config.Save(); } -extern "C" JNIEXPORT jint JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_getNotificationsPosition([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return static_cast(g_config.data().notification.position); } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setNotificationsPosition([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint position) { g_config.data().notification.position = static_cast(position); g_config.Save(); } -extern "C" JNIEXPORT jint JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_getNotificationsTextScalePercentage([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().notification.text_scale; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setNotificationsTextScalePercentage([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint scalePercentage) { g_config.data().notification.text_scale = scalePercentage; g_config.Save(); } -extern "C" JNIEXPORT jboolean JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_isNotificationControllerProfilesEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().notification.controller_profiles; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setNotificationControllerProfilesEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().notification.controller_profiles = enabled; g_config.Save(); } -extern "C" JNIEXPORT jboolean JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_isNotificationShaderCompilerEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().notification.shader_compiling; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setNotificationShaderCompilerEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().notification.shader_compiling = enabled; g_config.Save(); } -extern "C" JNIEXPORT jboolean JNICALL +extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_isNotificationFriendListEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) { return g_config.data().notification.friends; } -extern "C" JNIEXPORT void JNICALL +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_Cemu_nativeinterface_NativeSettings_setNotificationFriendListEnabled([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().notification.friends = enabled; diff --git a/src/android/app/src/main/java/info/cemu/Cemu/nativeinterface/NativeException.java b/src/android/app/src/main/java/info/cemu/Cemu/nativeinterface/NativeException.java index 483c8459..facbd751 100644 --- a/src/android/app/src/main/java/info/cemu/Cemu/nativeinterface/NativeException.java +++ b/src/android/app/src/main/java/info/cemu/Cemu/nativeinterface/NativeException.java @@ -1,6 +1,5 @@ package info.cemu.Cemu.nativeinterface; -@SuppressWarnings("unused") public final class NativeException extends RuntimeException { public NativeException(String message) { super(message);