diff --git a/src/android/app/src/main/cpp/NativeGameTitles.cpp b/src/android/app/src/main/cpp/NativeGameTitles.cpp index 6cd6fbed..181c1538 100644 --- a/src/android/app/src/main/cpp/NativeGameTitles.cpp +++ b/src/android/app/src/main/cpp/NativeGameTitles.cpp @@ -119,7 +119,6 @@ extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_cemu_nativeinterface_NativeGameTitles_setGameTitleFavorite([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jlong game_title_id, jboolean isFavorite) { GetConfig().SetGameListFavorite(game_title_id, isFavorite); - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT void JNICALL diff --git a/src/android/app/src/main/cpp/NativeGraphicPacks.cpp b/src/android/app/src/main/cpp/NativeGraphicPacks.cpp index 8582f454..a822b7ab 100644 --- a/src/android/app/src/main/cpp/NativeGraphicPacks.cpp +++ b/src/android/app/src/main/cpp/NativeGraphicPacks.cpp @@ -38,7 +38,6 @@ namespace NativeGraphicPacks auto& it = data.graphic_pack_entries[filename]; it.try_emplace("_disabled", "false"); } - g_config.Save(); } jobject getGraphicPresets(JNIEnv* env, GraphicPackPtr graphicPack, sint64 id) diff --git a/src/android/app/src/main/cpp/NativeSettings.cpp b/src/android/app/src/main/cpp/NativeSettings.cpp index d491ea9a..3efbaa5e 100644 --- a/src/android/app/src/main/cpp/NativeSettings.cpp +++ b/src/android/app/src/main/cpp/NativeSettings.cpp @@ -12,7 +12,6 @@ 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" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -25,7 +24,6 @@ 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" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -38,7 +36,6 @@ 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" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -51,7 +48,6 @@ 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" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -64,7 +60,6 @@ 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" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -77,7 +72,6 @@ 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" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -90,7 +84,6 @@ 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" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -103,7 +96,6 @@ 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" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -116,7 +108,6 @@ 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" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -129,7 +120,6 @@ 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" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -142,7 +132,6 @@ 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" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -155,7 +144,6 @@ 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" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -168,7 +156,6 @@ 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" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -181,7 +168,6 @@ 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; - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT void JNICALL @@ -192,7 +178,6 @@ Java_info_cemu_cemu_nativeinterface_NativeSettings_addGamesPath(JNIEnv* env, [[m if (std::any_of(gamePaths.begin(), gamePaths.end(), [&](auto path) { return path == gamePath; })) return; gamePaths.push_back(gamePath); - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT void JNICALL @@ -201,7 +186,6 @@ Java_info_cemu_cemu_nativeinterface_NativeSettings_removeGamesPath(JNIEnv* env, auto gamePath = JNIUtils::toString(env, uri); auto& gamePaths = g_config.data().game_paths; std::erase_if(gamePaths, [&](auto path) { return path == gamePath; }); - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jobject JNICALL @@ -220,7 +204,6 @@ extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_cemu_nativeinterface_NativeSettings_setAsyncShaderCompile([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().async_compile = enabled; - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -233,7 +216,6 @@ extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_cemu_nativeinterface_NativeSettings_setVsyncMode([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint vsync_mode) { g_config.data().vsync = vsync_mode; - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -246,7 +228,6 @@ extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_cemu_nativeinterface_NativeSettings_setUpscalingFilter([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint upscaling_filter) { g_config.data().upscale_filter = upscaling_filter; - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -259,7 +240,6 @@ extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_cemu_nativeinterface_NativeSettings_setDownscalingFilter([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint downscaling_filter) { g_config.data().downscale_filter = downscaling_filter; - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -272,7 +252,6 @@ extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_cemu_nativeinterface_NativeSettings_setFullscreenScaling([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint fullscreen_scaling) { g_config.data().fullscreen_scaling = fullscreen_scaling; - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -285,7 +264,6 @@ extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_cemu_nativeinterface_NativeSettings_setAccurateBarriers([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jboolean enabled) { g_config.data().vk_accurate_barriers = enabled; - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jboolean JNICALL @@ -303,7 +281,6 @@ Java_info_cemu_cemu_nativeinterface_NativeSettings_setAudioDeviceEnabled([[maybe device = L"Default"; else device.clear(); - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -318,7 +295,6 @@ Java_info_cemu_cemu_nativeinterface_NativeSettings_setAudioDeviceChannels([[mayb { auto& deviceChannels = tv ? g_config.data().tv_channels : g_config.data().pad_channels; deviceChannels = static_cast(channels); - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -333,7 +309,6 @@ Java_info_cemu_cemu_nativeinterface_NativeSettings_setAudioDeviceVolume([[maybe_ { auto& deviceVolume = tv ? g_config.data().tv_volume : g_config.data().pad_volume; deviceVolume = volume; - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -347,7 +322,6 @@ Java_info_cemu_cemu_nativeinterface_NativeSettings_setAudioLatency([[maybe_unuse { g_config.data().audio_delay = latency / 12; IAudioAPI::SetAudioDelay(g_config.data().audio_delay); - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jint JNICALL @@ -360,7 +334,6 @@ extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_cemu_nativeinterface_NativeSettings_setConsoleLanguage([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jint console_language) { g_config.data().console_language = static_cast(console_language); - g_config.Save(); } extern "C" [[maybe_unused]] JNIEXPORT jstring JNICALL @@ -376,5 +349,10 @@ extern "C" [[maybe_unused]] JNIEXPORT void JNICALL Java_info_cemu_cemu_nativeinterface_NativeSettings_setCustomDriverPath(JNIEnv* env, [[maybe_unused]] jclass clazz, jstring custom_driver_path) { g_config.data().custom_driver_path = JNIUtils::toString(env, custom_driver_path); - g_config.Save(); } + +extern "C" [[maybe_unused]] JNIEXPORT void JNICALL +Java_info_cemu_cemu_nativeinterface_NativeSettings_saveSettings([[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz) +{ + g_config.Save(); +} \ No newline at end of file diff --git a/src/android/app/src/main/java/info/cemu/cemu/MainActivity.kt b/src/android/app/src/main/java/info/cemu/cemu/MainActivity.kt index 9f9ef5d7..2212aea3 100644 --- a/src/android/app/src/main/java/info/cemu/cemu/MainActivity.kt +++ b/src/android/app/src/main/java/info/cemu/cemu/MainActivity.kt @@ -40,6 +40,7 @@ import info.cemu.cemu.gamelist.GamesListScreenActions import info.cemu.cemu.graphicpacks.GraphicPacksActivity import info.cemu.cemu.guicore.ActivityContent import info.cemu.cemu.nativeinterface.NativeGameTitles.Game +import info.cemu.cemu.nativeinterface.NativeSettings import info.cemu.cemu.settings.SettingsActivity import info.cemu.cemu.titlemanager.TitleManagerActivity import kotlinx.serialization.Serializable @@ -53,6 +54,11 @@ class MainActivity : ComponentActivity() { } } } + + override fun onPause() { + super.onPause() + NativeSettings.saveSettings() + } } private fun startGame(context: Context, game: Game) { diff --git a/src/android/app/src/main/java/info/cemu/cemu/graphicpacks/GraphicPacksActivity.kt b/src/android/app/src/main/java/info/cemu/cemu/graphicpacks/GraphicPacksActivity.kt index 508c0df4..80be99db 100644 --- a/src/android/app/src/main/java/info/cemu/cemu/graphicpacks/GraphicPacksActivity.kt +++ b/src/android/app/src/main/java/info/cemu/cemu/graphicpacks/GraphicPacksActivity.kt @@ -16,6 +16,7 @@ import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController import info.cemu.cemu.guicore.ActivityContent +import info.cemu.cemu.nativeinterface.NativeSettings import kotlinx.serialization.Serializable class GraphicPacksActivity : ComponentActivity() { @@ -27,6 +28,11 @@ class GraphicPacksActivity : ComponentActivity() { } } } + + override fun onPause() { + super.onPause() + NativeSettings.saveSettings() + } } object GraphicPackRoutes { diff --git a/src/android/app/src/main/java/info/cemu/cemu/nativeinterface/NativeSettings.kt b/src/android/app/src/main/java/info/cemu/cemu/nativeinterface/NativeSettings.kt index 358e5cf2..a686d6e3 100644 --- a/src/android/app/src/main/java/info/cemu/cemu/nativeinterface/NativeSettings.kt +++ b/src/android/app/src/main/java/info/cemu/cemu/nativeinterface/NativeSettings.kt @@ -1,6 +1,9 @@ package info.cemu.cemu.nativeinterface object NativeSettings { + @JvmStatic + external fun saveSettings() + @JvmStatic external fun addGamesPath(uri: String?) diff --git a/src/android/app/src/main/java/info/cemu/cemu/settings/SettingsActivity.kt b/src/android/app/src/main/java/info/cemu/cemu/settings/SettingsActivity.kt index 5b52bc6c..2f53a257 100644 --- a/src/android/app/src/main/java/info/cemu/cemu/settings/SettingsActivity.kt +++ b/src/android/app/src/main/java/info/cemu/cemu/settings/SettingsActivity.kt @@ -12,6 +12,7 @@ import androidx.navigation.compose.navigation import androidx.navigation.compose.rememberNavController import androidx.navigation.toRoute import info.cemu.cemu.guicore.ActivityContent +import info.cemu.cemu.nativeinterface.NativeSettings import info.cemu.cemu.settings.audio.AudioSettingsScreen import info.cemu.cemu.settings.customdrivers.CustomDriversScreen import info.cemu.cemu.settings.gamespath.GamePathsScreen @@ -33,6 +34,11 @@ class SettingsActivity : ComponentActivity() { } } } + + override fun onPause() { + super.onPause() + NativeSettings.saveSettings() + } } private sealed class SettingsRoutes {