diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt index 9ebd6c732a8a6b6f4c26f3fc60f10b47af88888e..f2ba2504c4e6bcd1f9d9d219656344b6a4726cf2 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt @@ -230,8 +230,6 @@ object NativeLibrary { */ external fun onTouchReleased(finger_id: Int) - external fun reloadSettings() - external fun initGameIni(gameID: String?) external fun setAppDirectory(directory: String) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt index 2bf0e1b0dbf8643c829aeb20b270b2ce982c16ea..d005c656e07595dfab8330f5bd300f065cc91b80 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt @@ -7,7 +7,7 @@ import android.text.TextUtils import android.widget.Toast import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.YuzuApplication -import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile +import org.yuzu.yuzu_emu.utils.NativeConfig object Settings { private val context get() = YuzuApplication.appContext @@ -19,7 +19,7 @@ object Settings { context.getString(R.string.ini_saved), Toast.LENGTH_SHORT ).show() - SettingsFile.saveFile(SettingsFile.FILE_NAME_CONFIG) + NativeConfig.saveSettings() } else { // TODO: Save custom game settings Toast.makeText( diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt index c73edd50e2360b2dab3ddc0e8d979370b9c3b697..48bdbdd75f33634732bc406deccec012d3b3462f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt @@ -21,7 +21,6 @@ import androidx.navigation.navArgs import com.google.android.material.color.MaterialColors import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch -import org.yuzu.yuzu_emu.NativeLibrary import java.io.IOException import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.databinding.ActivitySettingsBinding @@ -165,11 +164,12 @@ class SettingsActivity : AppCompatActivity() { settingsViewModel.shouldSave = false // Delete settings file because the user may have changed values that do not exist in the UI + NativeConfig.unloadConfig() val settingsFile = SettingsFile.getSettingsFile(SettingsFile.FILE_NAME_CONFIG) if (!settingsFile.delete()) { throw IOException("Failed to delete $settingsFile") } - NativeLibrary.reloadSettings() + NativeConfig.initializeConfig() Toast.makeText( applicationContext, diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt index ace5dddea6d8bc2d8c2726d4e53d5aabed944fd6..bd2f4cd256b9196dc27a5af820be0e78e8e610d6 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt @@ -625,6 +625,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider { } // Clear existing user data + NativeConfig.unloadConfig() File(DirectoryInitialization.userDirectory!!).deleteRecursively() // Copy archive to internal storage @@ -643,6 +644,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider { // Reinitialize relevant data NativeLibrary.initializeSystem(true) + NativeConfig.initializeConfig() gamesViewModel.reloadGames(false) return@newInstance getString(R.string.user_data_import_success) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DirectoryInitialization.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DirectoryInitialization.kt index 5e9a1176adb3e94fbbe4b60aba7b4acc6887e173..21270fc84361b4dacda488fd9914c23696fcb9c4 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DirectoryInitialization.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DirectoryInitialization.kt @@ -16,6 +16,7 @@ object DirectoryInitialization { if (!areDirectoriesReady) { initializeInternalStorage() NativeLibrary.initializeSystem(false) + NativeConfig.initializeConfig() areDirectoriesReady = true } } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/NativeConfig.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/NativeConfig.kt index 9425f8b99193164abc25b9d1ee53fe22216f88fa..87e579fa7ad8e4fc2d4ec2c64df3ca4b1f4c6ace 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/NativeConfig.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/NativeConfig.kt @@ -4,6 +4,30 @@ package org.yuzu.yuzu_emu.utils object NativeConfig { + /** + * Creates a Config object and opens the emulation config. + */ + @Synchronized + external fun initializeConfig() + + /** + * Destroys the stored config object. This automatically saves the existing config. + */ + @Synchronized + external fun unloadConfig() + + /** + * Reads values saved to the config file and saves them. + */ + @Synchronized + external fun reloadSettings() + + /** + * Saves settings values in memory to disk. + */ + @Synchronized + external fun saveSettings() + external fun getBoolean(key: String, getDefault: Boolean): Boolean external fun setBoolean(key: String, value: Boolean)