Skip to content

Commit d5745ca

Browse files
PabloMK7OpenSauce04
authored andcommitted
Add LLE modules for online features option + AM Refactor w/ various improvements/fixes
- Added option to enable required LLE modules for online features. - (Android) Fixed bug that would cause FS RenameFile to fail sometimes on Android. - (Android) Moved New 3DS mode and LLE applets to system settings tab on Android. - (Android) Fixed cfg save data related issues (mostly Console ID). - Made AM title scanning asynchronous, which makes game boot way faster on Android on most cases. - Made more AM functions asynchronous, to prevent stutter. - Fixed bug in SOC that could cause the emulator to crash when disconnecting. - Fixed keys not being initialized when processing console unique files.
1 parent 518b3d7 commit d5745ca

31 files changed

Lines changed: 648 additions & 256 deletions

src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,11 @@ object NativeLibrary {
567567
@JvmStatic
568568
fun createDir(directory: String, directoryName: String): Boolean =
569569
if (FileUtil.isNativePath(directory)) {
570-
CitraApplication.documentsTree.createDir(directory, directoryName)
570+
try {
571+
CitraApplication.documentsTree.createDir(directory, directoryName)
572+
} catch (e: Exception) {
573+
false
574+
}
571575
} else {
572576
FileUtil.createDir(directory, directoryName) != null
573577
}
@@ -641,7 +645,11 @@ object NativeLibrary {
641645
@JvmStatic
642646
fun renameFile(path: String, destinationFilename: String): Boolean =
643647
if (FileUtil.isNativePath(path)) {
644-
CitraApplication.documentsTree.renameFile(path, destinationFilename)
648+
try {
649+
CitraApplication.documentsTree.renameFile(path, destinationFilename)
650+
} catch (e: Exception) {
651+
false
652+
}
645653
} else {
646654
FileUtil.renameFile(path, destinationFilename)
647655
}

src/android/app/src/main/java/org/citra/citra_emu/features/settings/model/BooleanSetting.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ enum class BooleanSetting(
1717
INSTANT_DEBUG_LOG("instant_debug_log", Settings.SECTION_DEBUG, false),
1818
CUSTOM_LAYOUT("custom_layout",Settings.SECTION_LAYOUT,false),
1919
DELAY_START_LLE_MODULES("delay_start_for_lle_modules", Settings.SECTION_DEBUG, true),
20-
DETERMINISTIC_ASYNC_OPERATIONS("deterministic_async_operations", Settings.SECTION_DEBUG, false);
20+
DETERMINISTIC_ASYNC_OPERATIONS("deterministic_async_operations", Settings.SECTION_DEBUG, false),
21+
REQUIRED_ONLINE_LLE_MODULES("enable_required_online_lle_modules", Settings.SECTION_SYSTEM, false);
2122

2223
override var boolean: Boolean = defaultValue
2324

@@ -41,6 +42,7 @@ enum class BooleanSetting(
4142
ASYNC_SHADERS,
4243
DELAY_START_LLE_MODULES,
4344
DETERMINISTIC_ASYNC_OPERATIONS,
45+
REQUIRED_ONLINE_LLE_MODULES,
4446
)
4547

4648
fun from(key: String): BooleanSetting? =

src/android/app/src/main/java/org/citra/citra_emu/features/settings/model/IntSetting.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Citra Emulator Project
1+
// Copyright Citra Emulator Project / Azahar Emulator Project
22
// Licensed under GPLv2 or any later version
33
// Refer to the license.txt file included.
44

@@ -44,7 +44,7 @@ enum class IntSetting(
4444
PORTRAIT_BOTTOM_HEIGHT("custom_portrait_bottom_height",Settings.SECTION_LAYOUT,480),
4545
AUDIO_INPUT_TYPE("output_type", Settings.SECTION_AUDIO, 0),
4646
NEW_3DS("is_new_3ds", Settings.SECTION_SYSTEM, 1),
47-
LLE_APPLETS("lle_applets", Settings.SECTION_SYSTEM, 0),
47+
LLE_APPLETS("lle_applets", Settings.SECTION_SYSTEM, 1),
4848
CPU_CLOCK_SPEED("cpu_clock_percentage", Settings.SECTION_CORE, 100),
4949
LINEAR_FILTERING("filter_mode", Settings.SECTION_RENDERER, 1),
5050
SHADERS_ACCURATE_MUL("shaders_accurate_mul", Settings.SECTION_RENDERER, 0),

src/android/app/src/main/java/org/citra/citra_emu/features/settings/ui/SettingsActivity.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView {
110110
presenter.saveState(outState)
111111
}
112112

113+
override fun onPause() {
114+
super.onPause()
115+
presenter.onPause()
116+
}
117+
118+
override fun onResume() {
119+
super.onResume()
120+
presenter.onResume()
121+
}
122+
113123
override fun onStart() {
114124
super.onStart()
115125
presenter.onStart()

src/android/app/src/main/java/org/citra/citra_emu/features/settings/ui/SettingsActivityPresenter.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Citra Emulator Project
1+
// Copyright Citra Emulator Project / Azahar Emulator Project
22
// Licensed under GPLv2 or any later version
33
// Refer to the license.txt file included.
44

@@ -28,8 +28,15 @@ class SettingsActivityPresenter(private val activityView: SettingsActivityView)
2828
}
2929
}
3030

31-
fun onStart() {
31+
fun onResume() {
3232
SystemSaveGame.load()
33+
}
34+
35+
fun onPause() {
36+
SystemSaveGame.save()
37+
}
38+
39+
fun onStart() {
3340
prepareDirectoriesIfNeeded()
3441
}
3542

@@ -56,7 +63,6 @@ class SettingsActivityPresenter(private val activityView: SettingsActivityView)
5663
if (finishing && shouldSave) {
5764
Log.debug("[SettingsActivity] Settings activity stopping. Saving settings to INI...")
5865
settings.saveSettings(activityView)
59-
SystemSaveGame.save()
6066
//added to ensure that layout changes take effect as soon as settings window closes
6167
NativeLibrary.reloadSettings()
6268
NativeLibrary.updateFramebuffer(NativeLibrary.isPortraitMode)

src/android/app/src/main/java/org/citra/citra_emu/features/settings/ui/SettingsFragmentPresenter.kt

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,35 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
253253
override val valueAsString get() = string
254254
override val defaultValue = "AZAHAR"
255255
}
256+
add(HeaderSetting(R.string.emulation_settings))
257+
add(
258+
SwitchSetting(
259+
IntSetting.NEW_3DS,
260+
R.string.new_3ds,
261+
0,
262+
IntSetting.NEW_3DS.key,
263+
IntSetting.NEW_3DS.defaultValue
264+
)
265+
)
266+
add(
267+
SwitchSetting(
268+
IntSetting.LLE_APPLETS,
269+
R.string.lle_applets,
270+
0,
271+
IntSetting.LLE_APPLETS.key,
272+
IntSetting.LLE_APPLETS.defaultValue
273+
)
274+
)
275+
add(
276+
SwitchSetting(
277+
BooleanSetting.REQUIRED_ONLINE_LLE_MODULES,
278+
R.string.enable_required_online_lle_modules,
279+
R.string.enable_required_online_lle_modules_desc,
280+
BooleanSetting.REQUIRED_ONLINE_LLE_MODULES.key,
281+
BooleanSetting.REQUIRED_ONLINE_LLE_MODULES.defaultValue
282+
)
283+
)
284+
add(HeaderSetting(R.string.profile_settings))
256285
add(
257286
StringInputSetting(
258287
usernameSetting,
@@ -1285,24 +1314,6 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
12851314
settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_debug))
12861315
sl.apply {
12871316
add(HeaderSetting(R.string.debug_warning))
1288-
add(
1289-
SwitchSetting(
1290-
IntSetting.NEW_3DS,
1291-
R.string.new_3ds,
1292-
0,
1293-
IntSetting.NEW_3DS.key,
1294-
IntSetting.NEW_3DS.defaultValue
1295-
)
1296-
)
1297-
add(
1298-
SwitchSetting(
1299-
IntSetting.LLE_APPLETS,
1300-
R.string.lle_applets,
1301-
0,
1302-
IntSetting.LLE_APPLETS.key,
1303-
IntSetting.LLE_APPLETS.defaultValue
1304-
)
1305-
)
13061317
add(
13071318
SliderSetting(
13081319
IntSetting.CPU_CLOCK_SPEED,

src/android/app/src/main/java/org/citra/citra_emu/fragments/SystemFilesFragment.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ class SystemFilesFragment : Fragment() {
8787
}
8888
}
8989

90+
override fun onResume() {
91+
super.onResume()
92+
SystemSaveGame.load()
93+
}
94+
9095
override fun onPause() {
9196
super.onPause()
9297
SystemSaveGame.save()

src/android/app/src/main/java/org/citra/citra_emu/utils/DocumentsTree.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright Citra Emulator Project / Lime3DS Emulator Project
1+
// Copyright Citra Emulator Project / Azahar Emulator Project
22
// Licensed under GPLv2 or any later version
33
// Refer to the license.txt file included.
44

@@ -161,8 +161,8 @@ class DocumentsTree {
161161
val node = resolvePath(filepath) ?: return false
162162
try {
163163
val filename = URLDecoder.decode(destinationFilename, FileUtil.DECODE_METHOD)
164-
DocumentsContract.renameDocument(context.contentResolver, node.uri!!, filename)
165-
node.rename(filename)
164+
val newUri = DocumentsContract.renameDocument(context.contentResolver, node.uri!!, filename)
165+
node.rename(filename, newUri)
166166
return true
167167
} catch (e: Exception) {
168168
error("[DocumentsTree]: Cannot rename file, error: " + e.message)
@@ -255,10 +255,11 @@ class DocumentsTree {
255255
}
256256

257257
@Synchronized
258-
fun rename(name: String) {
258+
fun rename(name: String, uri: Uri?) {
259259
parent ?: return
260260
parent!!.removeChild(this)
261261
this.name = name
262+
this.uri = uri
262263
parent!!.addChild(this)
263264
}
264265

src/android/app/src/main/jni/config.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 Citra Emulator Project
1+
// Copyright Citra Emulator Project / Azahar Emulator Project
22
// Licensed under GPLv2 or any later version
33
// Refer to the license.txt file included.
44

@@ -235,6 +235,7 @@ void Config::ReadValues() {
235235
// System
236236
ReadSetting("System", Settings::values.is_new_3ds);
237237
ReadSetting("System", Settings::values.lle_applets);
238+
ReadSetting("System", Settings::values.enable_required_online_lle_modules);
238239
ReadSetting("System", Settings::values.region_value);
239240
ReadSetting("System", Settings::values.init_clock);
240241
{

src/android/app/src/main/jni/default_ini.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,13 @@ use_virtual_sd =
326326
is_new_3ds =
327327
328328
# Whether to use LLE system applets, if installed
329-
# 0 (default): No, 1: Yes
329+
# 0: No, 1 (default): Yes
330330
lle_applets =
331331
332+
# Whether to enable LLE modules for online play
333+
# 0 (default): No, 1: Yes
334+
enable_required_online_lle_modules =
335+
332336
# The system region that Citra will use during emulation
333337
# -1: Auto-select (default), 0: Japan, 1: USA, 2: Europe, 3: Australia, 4: China, 5: Korea, 6: Taiwan
334338
region_value =

0 commit comments

Comments
 (0)